From 07f82fd399c9e100644173f7543aadfd96dc5804 Mon Sep 17 00:00:00 2001 From: Antony Lee Date: Wed, 29 May 2019 14:22:17 +0200 Subject: [PATCH] Make is_natively_supported private. There's no public release where that function is available, and there isn't a need to make it public for now. --- lib/matplotlib/axis.py | 2 +- lib/matplotlib/units.py | 31 +++++++++++++++---------------- 2 files changed, 16 insertions(+), 17 deletions(-) diff --git a/lib/matplotlib/axis.py b/lib/matplotlib/axis.py index ae1eae553c0d..78fea0c58b7d 100644 --- a/lib/matplotlib/axis.py +++ b/lib/matplotlib/axis.py @@ -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: diff --git a/lib/matplotlib/units.py b/lib/matplotlib/units.py index b4677bdd3bd0..f56032b4c8c1 100644 --- a/lib/matplotlib/units.py +++ b/lib/matplotlib/units.py @@ -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 @@ -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. @@ -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): """