From 4bac293fd91d6bc47bd997ffbc0194ff4f2298c1 Mon Sep 17 00:00:00 2001 From: "ekaterina.itsenko" Date: Tue, 11 Feb 2025 01:22:24 +0100 Subject: [PATCH] [pycharm] PY-78813 Tables(Jupyter, DataView): fix tests GitOrigin-RevId: 429954dd03103dd644213638adcdef4be44ba410 --- .../_pydevd_bundle/tables/pydevd_numpy.py | 16 +++- ...display_data_csv_recarray_float_values.txt | 6 +- .../display_data_csv_recarray_none_values.txt | 6 +- .../display_data_csv_with_types.txt | 6 +- ...isplay_data_html_recarray_float_values.txt | 75 ++++++++----------- ...display_data_html_recarray_none_values.txt | 75 ++++++++----------- .../get_data_recarray_float_values_12f.txt | 2 +- .../get_data_recarray_float_values_2e.txt | 2 +- .../get_data_recarray_float_values_2f.txt | 2 +- .../get_data_recarray_float_values_d.txt | 2 +- ...t_data_recarray_float_values_d_garbage.txt | 2 +- .../get_data_recarray_none_values_2e.txt | 2 +- .../python_2_7/recarray_1d_number.txt | 2 +- .../python_3_12/recarray_1d_number.txt | 2 +- .../display_data_csv_with_types.txt | 6 +- .../display_data_csv_with_types.txt | 6 +- .../python_3_12/recarray_1d_number.txt | 2 +- .../display_data_csv_with_types.txt | 6 +- 18 files changed, 99 insertions(+), 121 deletions(-) diff --git a/python/helpers/pydev/_pydevd_bundle/tables/pydevd_numpy.py b/python/helpers/pydev/_pydevd_bundle/tables/pydevd_numpy.py index 6aef9f735d37d..2a676f3c77ec7 100644 --- a/python/helpers/pydev/_pydevd_bundle/tables/pydevd_numpy.py +++ b/python/helpers/pydev/_pydevd_bundle/tables/pydevd_numpy.py @@ -90,6 +90,14 @@ def ipython_display(data, format): __compute_data(table, ipython_display) +def remove_nones_values(array_part, na_rep): + if np.issubdtype(array_part.dtype, np.number): + array_part_without_nones = np.where(array_part == None, np.nan, array_part) + else: + array_part_without_nones = np.where(array_part == None, na_rep, array_part) + return array_part_without_nones + + class _NpTable: def __init__(self, np_array, format=None): self.array = np_array @@ -190,12 +198,12 @@ def __collect_values(self, max_cols): def to_csv(self, na_rep="None", float_format=None, sep=CSV_FORMAT_SEPARATOR): csv_stream = io.StringIO() if self.array.dtype.names is not None: - np_array_without_nones = np.copy(self.array) + np_array_without_nones = [] for field in self.array.dtype.names: - np_array_without_nones[str(field)] = np.where(self.array[str(field)] == None, np.nan, self.array[str(field)]) - np_array_without_nones = np.column_stack([np_array_without_nones[str(field)] for field in self.array.dtype.names]) + np_array_without_nones.append(remove_nones_values(self.array[str(field)], na_rep)) + np_array_without_nones = np.column_stack(np_array_without_nones) else: - np_array_without_nones = np.where(self.array == None, np.nan, self.array) + np_array_without_nones = remove_nones_values(self.array, na_rep) if float_format is None or float_format == 'null': float_format = "%s" diff --git a/python/helpers/pydev/pydev_tests_tables/test_data/numpy_with_pandas/python_2_7/display_data_csv_recarray_float_values.txt b/python/helpers/pydev/pydev_tests_tables/test_data/numpy_with_pandas/python_2_7/display_data_csv_recarray_float_values.txt index ee273196ca85a..e83ee33225a80 100644 --- a/python/helpers/pydev/pydev_tests_tables/test_data/numpy_with_pandas/python_2_7/display_data_csv_recarray_float_values.txt +++ b/python/helpers/pydev/pydev_tests_tables/test_data/numpy_with_pandas/python_2_7/display_data_csv_recarray_float_values.txt @@ -1,4 +1,4 @@ ~col1~col2~col3 -0~1~1.10~1.00 -1~2~2.20~2.00 -2~3~3.30~3.00 \ No newline at end of file +0~1.0~1.1~1.001 +1~2.0~2.2~2.002 +2~3.0~3.3~3.0003 \ No newline at end of file diff --git a/python/helpers/pydev/pydev_tests_tables/test_data/numpy_with_pandas/python_2_7/display_data_csv_recarray_none_values.txt b/python/helpers/pydev/pydev_tests_tables/test_data/numpy_with_pandas/python_2_7/display_data_csv_recarray_none_values.txt index ed385a6301c86..da3c21004f72d 100644 --- a/python/helpers/pydev/pydev_tests_tables/test_data/numpy_with_pandas/python_2_7/display_data_csv_recarray_none_values.txt +++ b/python/helpers/pydev/pydev_tests_tables/test_data/numpy_with_pandas/python_2_7/display_data_csv_recarray_none_values.txt @@ -1,4 +1,4 @@ ~col1~col2~col3 -0~1.00~1.1~None -1~2.00~None~2.002 -2~3.00~3.3~3.0003 \ No newline at end of file +0~1.0~1.1~nan +1~2.0~nan~2.002 +2~3.0~3.3~3.0003 \ No newline at end of file diff --git a/python/helpers/pydev/pydev_tests_tables/test_data/numpy_with_pandas/python_2_7/display_data_csv_with_types.txt b/python/helpers/pydev/pydev_tests_tables/test_data/numpy_with_pandas/python_2_7/display_data_csv_with_types.txt index f68ef400d1a6e..228d69688a1c0 100644 --- a/python/helpers/pydev/pydev_tests_tables/test_data/numpy_with_pandas/python_2_7/display_data_csv_with_types.txt +++ b/python/helpers/pydev/pydev_tests_tables/test_data/numpy_with_pandas/python_2_7/display_data_csv_with_types.txt @@ -1,4 +1,4 @@ ~id~name~age~score -0~1~Alice~23~85 -1~2~Bob~25~92 -2~3~Charlie~22~67 \ No newline at end of file +0~1.0~Alice~23.0~85.0 +1~2.0~Bob~25.0~92.0 +2~3.0~Charlie~22.0~67.0 \ No newline at end of file diff --git a/python/helpers/pydev/pydev_tests_tables/test_data/numpy_with_pandas/python_2_7/display_data_html_recarray_float_values.txt b/python/helpers/pydev/pydev_tests_tables/test_data/numpy_with_pandas/python_2_7/display_data_html_recarray_float_values.txt index 9b4b9a7ed78d7..dbfc1f25b17ef 100644 --- a/python/helpers/pydev/pydev_tests_tables/test_data/numpy_with_pandas/python_2_7/display_data_html_recarray_float_values.txt +++ b/python/helpers/pydev/pydev_tests_tables/test_data/numpy_with_pandas/python_2_7/display_data_html_recarray_float_values.txt @@ -1,45 +1,30 @@ -
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
col1col2col3
011.101.00
122.202.00
233.303.00
-
\ No newline at end of file + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
col1col2col3
011.11.001
122.22.002
233.33.0003
\ No newline at end of file diff --git a/python/helpers/pydev/pydev_tests_tables/test_data/numpy_with_pandas/python_2_7/display_data_html_recarray_none_values.txt b/python/helpers/pydev/pydev_tests_tables/test_data/numpy_with_pandas/python_2_7/display_data_html_recarray_none_values.txt index d85b52abfe2b6..16b0e4d31b0f4 100644 --- a/python/helpers/pydev/pydev_tests_tables/test_data/numpy_with_pandas/python_2_7/display_data_html_recarray_none_values.txt +++ b/python/helpers/pydev/pydev_tests_tables/test_data/numpy_with_pandas/python_2_7/display_data_html_recarray_none_values.txt @@ -1,45 +1,30 @@ -
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
col1col2col3
01.001.10None
12.00None2.00
23.003.303.00
-
\ No newline at end of file + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
col1col2col3
01.01.1nan
12.0nan2.002
23.03.33.0003
\ No newline at end of file diff --git a/python/helpers/pydev/pydev_tests_tables/test_data/numpy_with_pandas/python_2_7/get_data_recarray_float_values_12f.txt b/python/helpers/pydev/pydev_tests_tables/test_data/numpy_with_pandas/python_2_7/get_data_recarray_float_values_12f.txt index 79061cdbf256c..6672dc6919064 100644 --- a/python/helpers/pydev/pydev_tests_tables/test_data/numpy_with_pandas/python_2_7/get_data_recarray_float_values_12f.txt +++ b/python/helpers/pydev/pydev_tests_tables/test_data/numpy_with_pandas/python_2_7/get_data_recarray_float_values_12f.txt @@ -1 +1 @@ -'
\n\n\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n
col1col2col3
011.1000000000001.001000000000
122.2000000000002.002000000000
233.3000000000003.000300000000
344.4000000000004.000040000000
455.5000000000005.000005000000
\n
' \ No newline at end of file +'\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n
col1col2col3
01.0000000000001.1000000000001.001000000000
12.0000000000002.2000000000002.002000000000
23.0000000000003.3000000000003.000300000000
34.0000000000004.4000000000004.000040000000
45.0000000000005.5000000000005.000005000000
\n' \ No newline at end of file diff --git a/python/helpers/pydev/pydev_tests_tables/test_data/numpy_with_pandas/python_2_7/get_data_recarray_float_values_2e.txt b/python/helpers/pydev/pydev_tests_tables/test_data/numpy_with_pandas/python_2_7/get_data_recarray_float_values_2e.txt index a48e36c684666..f564323fb66bb 100644 --- a/python/helpers/pydev/pydev_tests_tables/test_data/numpy_with_pandas/python_2_7/get_data_recarray_float_values_2e.txt +++ b/python/helpers/pydev/pydev_tests_tables/test_data/numpy_with_pandas/python_2_7/get_data_recarray_float_values_2e.txt @@ -1 +1 @@ -'
\n\n\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n
col1col2col3
011.10e+001.00e+00
122.20e+002.00e+00
233.30e+003.00e+00
344.40e+004.00e+00
455.50e+005.00e+00
\n
' \ No newline at end of file +'\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n
col1col2col3
01.00e+001.10e+001.00e+00
12.00e+002.20e+002.00e+00
23.00e+003.30e+003.00e+00
34.00e+004.40e+004.00e+00
45.00e+005.50e+005.00e+00
\n' \ No newline at end of file diff --git a/python/helpers/pydev/pydev_tests_tables/test_data/numpy_with_pandas/python_2_7/get_data_recarray_float_values_2f.txt b/python/helpers/pydev/pydev_tests_tables/test_data/numpy_with_pandas/python_2_7/get_data_recarray_float_values_2f.txt index 9fbc57fec00d7..b909516500a11 100644 --- a/python/helpers/pydev/pydev_tests_tables/test_data/numpy_with_pandas/python_2_7/get_data_recarray_float_values_2f.txt +++ b/python/helpers/pydev/pydev_tests_tables/test_data/numpy_with_pandas/python_2_7/get_data_recarray_float_values_2f.txt @@ -1 +1 @@ -'
\n\n\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n
col1col2col3
011.101.00
122.202.00
233.303.00
344.404.00
455.505.00
\n
' \ No newline at end of file +'\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n
col1col2col3
01.001.101.00
12.002.202.00
23.003.303.00
34.004.404.00
45.005.505.00
\n' \ No newline at end of file diff --git a/python/helpers/pydev/pydev_tests_tables/test_data/numpy_with_pandas/python_2_7/get_data_recarray_float_values_d.txt b/python/helpers/pydev/pydev_tests_tables/test_data/numpy_with_pandas/python_2_7/get_data_recarray_float_values_d.txt index 7d891d6547cd9..5bdf9ad5b250a 100644 --- a/python/helpers/pydev/pydev_tests_tables/test_data/numpy_with_pandas/python_2_7/get_data_recarray_float_values_d.txt +++ b/python/helpers/pydev/pydev_tests_tables/test_data/numpy_with_pandas/python_2_7/get_data_recarray_float_values_d.txt @@ -1 +1 @@ -'
\n\n\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n
col1col2col3
0111
1222
2333
3444
4555
\n
' \ No newline at end of file +'\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n
col1col2col3
0111
1222
2333
3444
4555
\n' \ No newline at end of file diff --git a/python/helpers/pydev/pydev_tests_tables/test_data/numpy_with_pandas/python_2_7/get_data_recarray_float_values_d_garbage.txt b/python/helpers/pydev/pydev_tests_tables/test_data/numpy_with_pandas/python_2_7/get_data_recarray_float_values_d_garbage.txt index 129310879bf64..15e9f79d3e5be 100644 --- a/python/helpers/pydev/pydev_tests_tables/test_data/numpy_with_pandas/python_2_7/get_data_recarray_float_values_d_garbage.txt +++ b/python/helpers/pydev/pydev_tests_tables/test_data/numpy_with_pandas/python_2_7/get_data_recarray_float_values_d_garbage.txt @@ -1 +1 @@ -'
\n\n\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n
col1col2col3
011 garbage1 garbage
122 garbage2 garbage
233 garbage3 garbage
344 garbage4 garbage
455 garbage5 garbage
\n
' \ No newline at end of file +'\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n
col1col2col3
01 garbage1 garbage1 garbage
12 garbage2 garbage2 garbage
23 garbage3 garbage3 garbage
34 garbage4 garbage4 garbage
45 garbage5 garbage5 garbage
\n' \ No newline at end of file diff --git a/python/helpers/pydev/pydev_tests_tables/test_data/numpy_with_pandas/python_2_7/get_data_recarray_none_values_2e.txt b/python/helpers/pydev/pydev_tests_tables/test_data/numpy_with_pandas/python_2_7/get_data_recarray_none_values_2e.txt index 1704145f96802..4b3eb210776b2 100644 --- a/python/helpers/pydev/pydev_tests_tables/test_data/numpy_with_pandas/python_2_7/get_data_recarray_none_values_2e.txt +++ b/python/helpers/pydev/pydev_tests_tables/test_data/numpy_with_pandas/python_2_7/get_data_recarray_none_values_2e.txt @@ -1 +1 @@ -'
\n\n\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n
col1col2col3
01.00e+001.10e+00None
12.00e+00None2.00e+00
23.00e+003.30e+003.00e+00
3None4.40e+004.00e+00
45.00e+00NoneNone
\n
' \ No newline at end of file +'\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n
col1col2col3
01.00e+001.10e+00nan
12.00e+00nan2.00e+00
23.00e+003.30e+003.00e+00
3nan4.40e+004.00e+00
45.00e+00nannan
\n' \ No newline at end of file diff --git a/python/helpers/pydev/pydev_tests_tables/test_data/numpy_with_pandas/python_2_7/recarray_1d_number.txt b/python/helpers/pydev/pydev_tests_tables/test_data/numpy_with_pandas/python_2_7/recarray_1d_number.txt index 395eb4752a1d6..85232970b81c3 100644 --- a/python/helpers/pydev/pydev_tests_tables/test_data/numpy_with_pandas/python_2_7/recarray_1d_number.txt +++ b/python/helpers/pydev/pydev_tests_tables/test_data/numpy_with_pandas/python_2_7/recarray_1d_number.txt @@ -4,4 +4,4 @@ __pydev_val__ __pydev_val__ col1__pydev_table_column_type_val__col2__pydev_table_column_type_val__col3 __pydev_val__ -int64__pydev_table_column_type_val__int64__pydev_table_column_type_val__float64__pydev_table_column_type_val__object \ No newline at end of file +int64__pydev_table_column_type_val__int64__pydev_table_column_type_val__float64__pydev_table_column_type_val__ + __pydev_val__ (3, 3) __pydev_val__ diff --git a/python/helpers/pydev/pydev_tests_tables/test_data/numpy_without_pandas/python_2_7/display_data_csv_with_types.txt b/python/helpers/pydev/pydev_tests_tables/test_data/numpy_without_pandas/python_2_7/display_data_csv_with_types.txt index f68ef400d1a6e..228d69688a1c0 100644 --- a/python/helpers/pydev/pydev_tests_tables/test_data/numpy_without_pandas/python_2_7/display_data_csv_with_types.txt +++ b/python/helpers/pydev/pydev_tests_tables/test_data/numpy_without_pandas/python_2_7/display_data_csv_with_types.txt @@ -1,4 +1,4 @@ ~id~name~age~score -0~1~Alice~23~85 -1~2~Bob~25~92 -2~3~Charlie~22~67 \ No newline at end of file +0~1.0~Alice~23.0~85.0 +1~2.0~Bob~25.0~92.0 +2~3.0~Charlie~22.0~67.0 \ No newline at end of file diff --git a/python/helpers/pydev/pydev_tests_tables/test_data/numpy_without_pandas/python_3_12/display_data_csv_with_types.txt b/python/helpers/pydev/pydev_tests_tables/test_data/numpy_without_pandas/python_3_12/display_data_csv_with_types.txt index f68ef400d1a6e..228d69688a1c0 100644 --- a/python/helpers/pydev/pydev_tests_tables/test_data/numpy_without_pandas/python_3_12/display_data_csv_with_types.txt +++ b/python/helpers/pydev/pydev_tests_tables/test_data/numpy_without_pandas/python_3_12/display_data_csv_with_types.txt @@ -1,4 +1,4 @@ ~id~name~age~score -0~1~Alice~23~85 -1~2~Bob~25~92 -2~3~Charlie~22~67 \ No newline at end of file +0~1.0~Alice~23.0~85.0 +1~2.0~Bob~25.0~92.0 +2~3.0~Charlie~22.0~67.0 \ No newline at end of file diff --git a/python/helpers/pydev/pydev_tests_tables/test_data/numpy_without_pandas/python_3_12/recarray_1d_number.txt b/python/helpers/pydev/pydev_tests_tables/test_data/numpy_without_pandas/python_3_12/recarray_1d_number.txt index 85232970b81c3..0203db034de6d 100644 --- a/python/helpers/pydev/pydev_tests_tables/test_data/numpy_without_pandas/python_3_12/recarray_1d_number.txt +++ b/python/helpers/pydev/pydev_tests_tables/test_data/numpy_without_pandas/python_3_12/recarray_1d_number.txt @@ -1,4 +1,4 @@ - + __pydev_val__ (3, 3) __pydev_val__ diff --git a/python/helpers/pydev/pydev_tests_tables/test_data/numpy_without_pandas/python_3_8/display_data_csv_with_types.txt b/python/helpers/pydev/pydev_tests_tables/test_data/numpy_without_pandas/python_3_8/display_data_csv_with_types.txt index f68ef400d1a6e..228d69688a1c0 100644 --- a/python/helpers/pydev/pydev_tests_tables/test_data/numpy_without_pandas/python_3_8/display_data_csv_with_types.txt +++ b/python/helpers/pydev/pydev_tests_tables/test_data/numpy_without_pandas/python_3_8/display_data_csv_with_types.txt @@ -1,4 +1,4 @@ ~id~name~age~score -0~1~Alice~23~85 -1~2~Bob~25~92 -2~3~Charlie~22~67 \ No newline at end of file +0~1.0~Alice~23.0~85.0 +1~2.0~Bob~25.0~92.0 +2~3.0~Charlie~22.0~67.0 \ No newline at end of file