From 1c8c11f2cc8135a572221d87854115a466607a94 Mon Sep 17 00:00:00 2001 From: Jianfeng Mao <4297243+jmao-denver@users.noreply.github.com> Date: Fri, 15 Mar 2024 13:27:56 -0600 Subject: [PATCH] Make column_to_numpy_array private (#5256) * Make column_to_numpy_array private * Respond to review comments --- py/server/deephaven/numpy.py | 17 ++++++++++++++--- py/server/deephaven/table_listener.py | 4 ++-- 2 files changed, 16 insertions(+), 5 deletions(-) diff --git a/py/server/deephaven/numpy.py b/py/server/deephaven/numpy.py index 4143638c669..583c9d41514 100644 --- a/py/server/deephaven/numpy.py +++ b/py/server/deephaven/numpy.py @@ -27,8 +27,19 @@ def _to_column_name(name: str) -> str: return re.sub(r"\s+", "_", tmp_name) -def column_to_numpy_array(col_def: Column, j_array: jpy.JType) -> np.ndarray: - """ Produces a numpy array from the given Java array and the Table column definition.""" +def _column_to_numpy_array(col_def: Column, j_array: jpy.JType) -> np.ndarray: + """ Produces a numpy array from the given Java array and the Table column definition. + + Args: + col_def (Column): the column definition + j_array (jpy.JType): the Java array + + Returns: + np.ndarray + + Raises: + DHError + """ try: return _j_array_to_numpy_array(col_def.data_type, j_array, conv_null=False, type_promotion=False) except DHError: @@ -49,7 +60,7 @@ def _columns_to_2d_numpy_array(col_def: Column, j_arrays: List[jpy.JType]) -> np else: np_arrays = [] for j_array in j_arrays: - np_arrays.append(column_to_numpy_array(col_def=col_def, j_array=j_array)) + np_arrays.append(_column_to_numpy_array(col_def=col_def, j_array=j_array)) return np.stack(np_arrays, axis=1) except DHError: raise diff --git a/py/server/deephaven/table_listener.py b/py/server/deephaven/table_listener.py index d1c2a5bed2b..af7340eb9be 100644 --- a/py/server/deephaven/table_listener.py +++ b/py/server/deephaven/table_listener.py @@ -16,7 +16,7 @@ from deephaven._wrapper import JObjectWrapper from deephaven.column import Column from deephaven.jcompat import to_sequence -from deephaven.numpy import column_to_numpy_array +from deephaven.numpy import _column_to_numpy_array from deephaven.table import Table from deephaven.update_graph import UpdateGraph @@ -51,7 +51,7 @@ def _changes_to_numpy(table: Table, cols: Union[str, List[str]], row_set, chunk_ col_dict = {} for i, col_def in enumerate(col_defs): - np_array = column_to_numpy_array(col_def, j_array[i]) + np_array = _column_to_numpy_array(col_def, j_array[i]) col_dict[col_def.name] = np_array yield col_dict