8000 Make is_natively_supported private. by anntzer · Pull Request #14363 · matplotlib/matplotlib · GitHub
[go: up one dir, main page]

Skip to content

Make is_natively_supported private. #14363

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
May 29, 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
2 changes: 1 addition & 1 deletion lib/matplotlib/axis.py
Original file line number Diff line number Diff line change
Expand Up @@ -1566,7 +1566,7 @@ def have_units(self):

def convert_units(self, x):
# If x is natively supported by Matplotlib, doesn't need converting
if munits.ConversionInterface.is_natively_supported(x):
if munits._is_natively_supported(x):
return x

if self.converter is None:
Expand Down
31 changes: 15 additions & 16 deletions lib/matplotlib/units.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,11 +42,11 @@ def default_units(x, axis):

"""

from decimal import Decimal
from numbers import Number

import numpy as np
from numpy import ma
from decimal import Decimal

from matplotlib import cbook

Expand All @@ -55,6 +55,20 @@ class ConversionError(TypeError):
pass


def _is_natively_supported(x):
"""
Return whether *x* is of a type that Matplotlib natively supports or an
array of objects of such types.
"""
# Matplotlib natively supports all number types except Decimal.
if np.iterable(x):
# Assume lists are homogeneous as other functions in unit system.
for thisx in x:
return isinstance(thisx, Number) and not isinstance(thisx, Decimal)
else:
return isinstance(x, Number) and not isinstance(x, Decimal)


class AxisInfo:
"""
Information to support default axis labeling, tick labeling, and limits.
Expand Down Expand Up @@ -134,21 +148,6 @@ def is_numlike(x):
else:
return isinstance(x, Number)

@staticmethod
def is_natively_supported(x):
"""
Return whether *x* is of a type that Matplotlib natively supports or
*x* is array of objects of such types.
"""
# Matplotlib natively supports all number types except Decimal
if np.iterable(x):
# Assume lists are homogeneous as other functions in unit system
for thisx in x:
return (isinstance(thisx, Number) and
not isinstance(thisx, Decimal))
else:
return isinstance(x, Number) and not isinstance(x, Decimal)


class DecimalConverter(ConversionInterface):
"""
Expand Down
0