Skip to content

Commit 88a4dfb

Browse files
Merge pull request #3997 from bnavigator/np1.24
Remove deprecated numpy types
2 parents 1d30117 + 0c6b573 commit 88a4dfb

File tree

7 files changed

+16
-15
lines changed

7 files changed

+16
-15
lines changed

Diff for: CHANGELOG.md

+2
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,8 @@ This project adheres to [Semantic Versioning](http://semver.org/).
1111
- Introduce group attributes for `scatter` trace i.e. `alignmentgroup`, `offsetgroup`, `scattermode` and `scattergap` [[#6381](https://github.com/plotly/plotly.js/pull/6381)],
1212
this feature was anonymously sponsored: thank you to our sponsor!
1313
- Add `marker.cornerradius` attribute to `treemap` trace [[#6351](https://github.com/plotly/plotly.js/pull/6351)]
14+
### Fixed
15+
- Fixed the usage of sume deprecated NumPy types which were removed in NumPy 1.24 [[#3997](https://github.com/plotly/plotly.py/pull/3997)]
1416

1517
## [5.11.0] - 2022-10-27
1618

Diff for: packages/python/plotly/_plotly_utils/tests/validators/test_integer_validator.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ def test_acceptance_min_max(val, validator_min_max):
5858

5959

6060
@pytest.mark.parametrize(
61-
"val", [-1.01, -10, 2.1, 3, np.iinfo(np.int).max, np.iinfo(np.int).min]
61+
"val", [-1.01, -10, 2.1, 3, np.iinfo(int).max, np.iinfo(int).min]
6262
)
6363
def test_rejection_min_max(val, validator_min_max):
6464
with pytest.raises(ValueError) as validation_failure:

Diff for: packages/python/plotly/plotly/express/imshow_utils.py

-1
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,6 @@
2121
_integer_ranges = {t: (np.iinfo(t).min, np.iinfo(t).max) for t in _integer_types}
2222
dtype_range = {
2323
np.bool_: (False, True),
24-
np.bool8: (False, True),
2524
np.float16: (-1, 1),
2625
np.float32: (-1, 1),
2726
np.float64: (-1, 1),

Diff for: packages/python/plotly/plotly/figure_factory/_streamline.py

+4-4
Original file line numberDiff line numberDiff line change
@@ -180,11 +180,11 @@ def value_at(self, a, xi, yi):
180180
Set up for RK4 function, based on Bokeh's streamline code
181181
"""
182182
if isinstance(xi, np.ndarray):
183-
self.x = xi.astype(np.int)
184-
self.y = yi.astype(np.int)
183+
self.x = xi.astype(int)
184+
self.y = yi.astype(int)
185185
else:
186-
self.val_x = np.int(xi)
187-
self.val_y = np.int(yi)
186+
self.val_x = int(xi)
187+
self.val_y = int(yi)
188188
a00 = a[self.val_y, self.val_x]
189189
a01 = a[self.val_y, self.val_x + 1]
190190
a10 = a[self.val_y + 1, self.val_x]

Diff for: packages/python/plotly/plotly/figure_factory/_violin.py

+5-5
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ def calc_stats(data):
1616
"""
1717
Calculate statistics for use in violin plot.
1818
"""
19-
x = np.asarray(data, np.float)
19+
x = np.asarray(data, float)
2020
vals_min = np.min(x)
2121
vals_max = np.max(x)
2222
q2 = np.percentile(x, 50, interpolation="linear")
@@ -160,7 +160,7 @@ def violinplot(vals, fillcolor="#1f77b4", rugplot=True):
160160
"""
161161
Refer to FigureFactory.create_violin() for docstring.
162162
"""
163-
vals = np.asarray(vals, np.float)
163+
vals = np.asarray(vals, float)
164164
# summary statistics
165165
vals_min = calc_stats(vals)["min"]
166166
vals_max = calc_stats(vals)["max"]
@@ -231,7 +231,7 @@ def violin_no_colorscale(
231231
)
232232
color_index = 0
233233
for k, gr in enumerate(group_name):
234-
vals = np.asarray(gb.get_group(gr)[data_header], np.float)
234+
vals = np.asarray(gb.get_group(gr)[data_header], float)
235235
if color_index >= len(colors):
236236
color_index = 0
237237
plot_data, plot_xrange = violinplot(
@@ -319,7 +319,7 @@ def violin_colorscale(
319319
min_value = min(group_stats_values)
320320

321321
for k, gr in enumerate(group_name):
322-
vals = np.asarray(gb.get_group(gr)[data_header], np.float)
322+
vals = np.asarray(gb.get_group(gr)[data_header], float)
323323

324324
# find intermediate color from colorscale
325325
intermed = (group_stats[gr] - min_value) / (max_value - min_value)
@@ -411,7 +411,7 @@ def violin_dict(
411411
)
412412

413413
for k, gr in enumerate(group_name):
414-
vals = np.asarray(gb.get_group(gr)[data_header], np.float)
414+
vals = np.asarray(gb.get_group(gr)[data_header], float)
415415
plot_data, plot_xrange = violinplot(vals, fillcolor=colors[gr], rugplot=rugplot)
416416
layout = graph_objs.Layout()
417417

Diff for: packages/python/plotly/plotly/tests/test_optional/test_px/test_imshow.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
from plotly.express.imshow_utils import rescale_intensity
1010

1111
img_rgb = np.array([[[255, 0, 0], [0, 255, 0], [0, 0, 255]]], dtype=np.uint8)
12-
img_gray = np.arange(100, dtype=np.float).reshape((10, 10))
12+
img_gray = np.arange(100, dtype=float).reshape((10, 10))
1313

1414

1515
def decode_image_string(image_string):
@@ -47,7 +47,7 @@ def test_automatic_zmax_from_dtype():
4747
dtypes_dict = {
4848
np.uint8: 2**8 - 1,
4949
np.uint16: 2**16 - 1,
50-
np.float: 1,
50+
float: 1,
5151
bool: 255,
5252
}
5353
for key, val in dtypes_dict.items():

Diff for: packages/python/plotly/plotly/tests/test_optional/test_utils/test_utils.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -414,8 +414,8 @@ def test_numpy_integer_import(self):
414414
import plotly.graph_objects as go
415415
from plotly.subplots import make_subplots
416416

417-
indices_rows = np.array([1], dtype=np.int)
418-
indices_cols = np.array([1], dtype=np.int)
417+
indices_rows = np.array([1], dtype=int)
418+
indices_cols = np.array([1], dtype=int)
419419
fig = make_subplots(rows=1, cols=1)
420420
fig.add_trace(go.Scatter(y=[1]), row=indices_rows[0], col=indices_cols[0])
421421

0 commit comments

Comments
 (0)