From ce7d09108b774af68b55f668faaa8253fb45eb6b Mon Sep 17 00:00:00 2001 From: Wes McKinney Date: Tue, 29 Oct 2024 19:21:01 -0500 Subject: [PATCH] add unit test for reproduction --- .../tests/test_data_explorer.py | 25 +++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/extensions/positron-python/python_files/positron/positron_ipykernel/tests/test_data_explorer.py b/extensions/positron-python/python_files/positron/positron_ipykernel/tests/test_data_explorer.py index 99a4097de18..afa1ca15b9a 100644 --- a/extensions/positron-python/python_files/positron/positron_ipykernel/tests/test_data_explorer.py +++ b/extensions/positron-python/python_files/positron/positron_ipykernel/tests/test_data_explorer.py @@ -2876,6 +2876,31 @@ def test_pandas_polars_profile_frequency_table(dxf: DataExplorerFixture): assert result[0]["small_frequency_table"] == ex_result +def test_profile_histogram_windows_int32_bug(): + # See #5176 -- we catch errors caused by a bug in NumPy and cast + # integer arrays to float as a fallback strategy to compute histograms + from ..data_explorer import _get_histogram_numpy + + arr = np.array( + [ + -428566661, + 1901704889, + 957355142, + -401364305, + -1978594834, + 519144975, + 1384373326, + 1974689646, + 194821408, + -1564699930, + ], + dtype=np.int32, + ) + result = _get_histogram_numpy(arr, 10, method="fd")[0] + expected = _get_histogram_numpy(arr.astype(np.float64), 10, method="fd")[0] + assert (result == expected).all() + + # ---------------------------------------------------------------------- # polars backend functionality tests