Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Handle upcoming deprecation of np.float. #15694

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 1 commit into from
Nov 15, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
4 changes: 1 addition & 3 deletions lib/matplotlib/projections/polar.py
Original file line number Diff line number Diff line change
Expand Up @@ -719,9 +719,7 @@ class _WedgeBbox(mtransforms.Bbox):
Bbox determining the origin for the wedge, if different from *viewLim*
"""
def __init__(self, center, viewLim, originLim, **kwargs):
mtransforms.Bbox.__init__(self,
np.array([[0.0, 0.0], [1.0, 1.0]], np.float),
**kwargs)
mtransforms.Bbox.__init__(self, [[0, 0], [1, 1]], **kwargs)
self._center = center
self._viewLim = viewLim
self._originLim = originLim
Expand Down
7 changes: 3 additions & 4 deletions lib/matplotlib/transforms.py
Original file line number Diff line number Diff line change
Expand Up @@ -763,12 +763,12 @@ def invalidate(self):
@staticmethod
def unit():
"""Create a new unit `Bbox` from (0, 0) to (1, 1)."""
return Bbox(np.array([[0.0, 0.0], [1.0, 1.0]], float))
return Bbox([[0, 0], [1, 1]])

@staticmethod
def null():
"""Create a new null `Bbox` from (inf, inf) to (-inf, -inf)."""
return Bbox(np.array([[np.inf, np.inf], [-np.inf, -np.inf]], float))
return Bbox([[np.inf, np.inf], [-np.inf, -np.inf]])
Comment on lines -766 to +771
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I assume you're aware that numpy doesn't care about these lines, and you're just doing cleanup while you're here?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yes


@staticmethod
def from_bounds(x0, y0, width, height):
Expand All @@ -786,8 +786,7 @@ def from_extents(*args):

The *y*-axis increases upwards.
"""
points = np.array(args, dtype=float).reshape(2, 2)
return Bbox(points)
return Bbox(np.reshape(args, (2, 2)))

def __format__(self, fmt):
return (
Expand Down
9 changes: 4 additions & 5 deletions lib/matplotlib/units.py
Original file line number Diff line number Diff line change
Expand Up @@ -155,9 +155,8 @@ def is_numlike(x):


class DecimalConverter(ConversionInterface):
"""
Converter for decimal.Decimal data to float.
"""
"""Converter for decimal.Decimal data to float."""

@staticmethod
def convert(value, unit, axis):
"""
Expand All @@ -172,13 +171,13 @@ def convert(value, unit, axis):
"""
# If value is a Decimal
if isinstance(value, Decimal):
return np.float(value)
return float(value)
else:
# assume x is a list of Decimal
converter = np.asarray
if isinstance(value, ma.MaskedArray):
converter = ma.asarray
return converter(value, dtype=np.float)
return converter(value, dtype=float)

@staticmethod
def axisinfo(unit, axis):
Expand Down