Skip to content

Make test suite ready for NumPy 2.0.0 #4622

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 19 commits into from
Nov 7, 2024
Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
Show all changes
19 commits
Select commit Hold shift + click to select a range
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
from datetime import datetime as dt
import numpy as np

np_list = np.array([1, 2, 3, np.NaN, np.NAN, np.Inf, dt(2014, 1, 5)])
np_list = np.array([1, 2, 3, np.nan, np.inf, dt(2014, 1, 5)])
numeric_list = [1, 2, 3]
mixed_list = [
1,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -341,7 +341,7 @@ def test_imshow_source_dtype_zmax(dtype, contrast_rescaling):
assert (
np.abs(
np.max(decode_image_string(fig.data[0].source))
- 255 * img.max() / np.iinfo(dtype).max
- np.int64(255) * img.max() / np.iinfo(dtype).max
)
< 1
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@

## JSON encoding
numeric_list = [1, 2, 3]
np_list = np.array([1, 2, 3, np.NaN, np.NAN, np.Inf, dt(2014, 1, 5)])
np_list = np.array([1, 2, 3, np.nan, np.inf, dt(2014, 1, 5)])
mixed_list = [
1,
"A",
Expand All @@ -45,7 +45,7 @@
dt_list = [dt(2014, 1, 5), dt(2014, 1, 5, 1, 1, 1), dt(2014, 1, 5, 1, 1, 1, 1)]

df = pd.DataFrame(
columns=["col 1"], data=[1, 2, 3, dt(2014, 1, 5), pd.NaT, np.NaN, np.Inf]
columns=["col 1"], data=[1, 2, 3, dt(2014, 1, 5), pd.NaT, np.nan, np.inf]
)

rng = pd.date_range("1/1/2011", periods=2, freq="H")
Expand Down Expand Up @@ -184,7 +184,7 @@ def test_figure_json_encoding(self):

assert (
js1 == '{"type": "scatter3d", "x": [1, 2, 3], '
'"y": [1, 2, 3, null, null, null, "2014-01-05T00:00:00"], '
'"y": [1, 2, 3, null, null, "2014-01-05T00:00:00"], '
'"z": [1, "A", "2014-01-05T00:00:00", '
'"2014-01-05T01:01:01", "2014-01-05T01:01:01.000001"]}'
)
Expand All @@ -195,9 +195,9 @@ def test_figure_json_encoding(self):
_json.dumps(figure, cls=utils.PlotlyJSONEncoder, sort_keys=True)

# Test data wasn't mutated
np_array = np.array([1, 2, 3, np.NaN, np.NAN, np.Inf, dt(2014, 1, 5)])
np_array = np.array([1, 2, 3, np.nan, np.inf, dt(2014, 1, 5)])
for k in range(len(np_array)):
if k in [3, 4]:
if k == 3:
# check NaN
assert np.isnan(np_list[k]) and np.isnan(np_array[k])
else:
Expand Down Expand Up @@ -237,7 +237,7 @@ def test_pandas_json_encoding(self):
# Test that data wasn't mutated
assert_series_equal(
df["col 1"],
pd.Series([1, 2, 3, dt(2014, 1, 5), pd.NaT, np.NaN, np.Inf], name="col 1"),
pd.Series([1, 2, 3, dt(2014, 1, 5), pd.NaT, np.nan, np.inf], name="col 1"),
)

j2 = _json.dumps(df.index, cls=utils.PlotlyJSONEncoder)
Expand Down