intellecton/venv/lib/python3.12/site-packages/matplotlib/__pycache__/units.cpython-312.pyc

105 lines
7.6 KiB
Text
Raw Normal View History

<EFBFBD>
<00>Rj<00><00><><00>dZddlmZddlmZddlZddlmZddlm Z Gd<07>de
<EFBFBD>Z d <09>Z Gd
<EFBFBD>d <0B>Z Gd <0C>d <0A>ZGd<0E>de<0E>ZGd<10>de<10>Ze<11>Ze<0F>ee<y)aQ
The classes here provide support for using custom classes with
Matplotlib, e.g., those that do not expose the array interface but know
how to convert themselves to arrays. It also supports classes with
units and units conversion. Use cases include converters for custom
objects, e.g., a list of datetime objects, as well as for objects that
are unit aware. We don't assume any particular units implementation;
rather a units implementation must register with the Registry converter
dictionary and provide a `ConversionInterface`. For example,
here is a complete implementation which supports plotting with native
datetime objects::
import matplotlib.units as units
import matplotlib.dates as dates
import matplotlib.ticker as ticker
import datetime
class DateConverter(units.ConversionInterface):
@staticmethod
def convert(value, unit, axis):
"Convert a datetime value to a scalar or array."
return dates.date2num(value)
@staticmethod
def axisinfo(unit, axis):
"Return major and minor tick locators and formatters."
if unit != 'date':
return None
majloc = dates.AutoDateLocator()
majfmt = dates.AutoDateFormatter(majloc)
return units.AxisInfo(majloc=majloc, majfmt=majfmt, label='date')
@staticmethod
def default_units(x, axis):
"Return the default unit for x or None."
return 'date'
# Finally we register our object type with the Matplotlib units registry.
units.registry[datetime.date] = DateConverter()
<EFBFBD>)<01>Decimal)<01>NumberN)<01>ma)<01>cbookc<00> <00>eZdZy)<02>ConversionErrorN)<03>__name__<5F>
__module__<EFBFBD> __qualname__<5F><00><00>S/home/antigravity/intellecton/venv/lib/python3.12/site-packages/matplotlib/units.pyrr4s<00><00>r rc<00><><00>tj|<00>r?|D]9}|tjur<01>t |t
<00>xrt |t <00> cSyt |t
<00>xrt |t <00> S)zu
Return whether *x* is of a type that Matplotlib natively supports or an
array of objects of such types.
N)<07>np<6E>iterabler<00>masked<65>
isinstancerr)<02>x<>thisxs r<00>_is_natively_supportedr8si<00><00> 
<EFBFBD>{<7B>{<7B>1<EFBFBD>~<7E><16> P<01>E<EFBFBD><14><02> <09> <09>!<21><18><1D>e<EFBFBD>V<EFBFBD>,<2C>O<>Z<EFBFBD><05>w<EFBFBD>5O<35>1O<31> O<> P<01>
<1A>!<21>V<EFBFBD>$<24>C<>Z<EFBFBD><01>7<EFBFBD>-C<>)C<>Cr c<00><00>eZdZdZ dd<03>Zy)<05>AxisInfoz<6F>
Information to support default axis labeling, tick labeling, and limits.
An instance of this class must be returned by
`ConversionInterface.axisinfo`.
Nc<00>X<00>||_||_||_||_||_||_y)a:
Parameters
----------
majloc, minloc : Locator, optional
Tick locators for the major and minor ticks.
majfmt, minfmt : Formatter, optional
Tick formatters for the major and minor ticks.
label : str, optional
The default axis label.
default_limits : optional
The default min and max limits of the axis if no data has
been plotted.
Notes
-----
If any of the above are ``None``, the axis will simply use the
default value.
N)<06>majloc<6F>minloc<6F>majfmt<6D>minfmt<6D>label<65>default_limits)<07>selfrrrrrrs r<00>__init__zAxisInfo.__init__Os/<00><00>*<1D><04> <0B><1C><04> <0B><1C><04> <0B><1C><04> <0B><1A><04>
<EFBFBD>,<2C><04>r )NNNNNN)r r
r <00>__doc__r!r r rrrHs<00><00><08> ,0<>15<31> $<24>-r rc<00>@<00>eZdZdZed<02><00>Zed<03><00>Zed<04><00>Zy)<06>ConversionInterfacez<65>
The minimal interface for a converter to take custom data types (or
sequences) and convert them to values Matplotlib can use.
c<00><00>y)z<Return an `.AxisInfo` for the axis with the specified units.Nr )<02>unit<69>axiss r<00>axisinfozConversionInterface.axisinfor<00><00><00>r c<00><00>y)z?Return the default unit for *x* or ``None`` for the given axis.Nr )rr's r<00> default_unitsz!ConversionInterface.default_unitswr)r c<00><00>|S)z<>
Convert *obj* using *unit* for the specified *axis*.
If *obj* is a sequence, return the converted sequence. The output must
be a sequence of scalars that can be used by the numpy array layer.
r )<03>objr&r's r<00>convertzConversionInterface.convert|s <00><00><13>
r N)r r
r r"<00> staticmethodr(r+r.r r rr$r$lsC<00><00><08>
<12><14><12><14><12><14><12><14><12><13><12>r r$c<00> <00>eZdZdZed<02><00>Zy)<04>DecimalConverterz,Converter for decimal.Decimal data to float.c<00><><00>t|t<00>r t|<00>St|tj<00>rtj
|t<00><01>St j
|t<00><01>S)z<>
Convert Decimals to floats.
The *unit* and *axis* arguments are not used.
Parameters
----------
value : decimal.Decimal or iterable
Decimal or list of Decimal need to be converted
<20><01>dtype)rr<00>floatr<00> MaskedArray<61>asarrayr)<03>valuer&r's rr.zDecimalConverter.convert<72>sH<00><00> <16>e<EFBFBD>W<EFBFBD> %<25><18><15><<3C> <1F> <17><05>r<EFBFBD>~<7E>~<7E> .<2E><15>:<3A>:<3A>e<EFBFBD>5<EFBFBD>1<> 1<><15>:<3A>:<3A>e<EFBFBD>5<EFBFBD>1<> 1r N)r r
r r"r/r.r r rr1r1<00>s<00><00>6<><11>2<><12>2r r1c<00><00>eZdZdZd<02>Zy)<04>Registryz)Register types with conversion interface.c<00>:<00>tj|<01>}t|tj<00>rjtj
j |<01>j<00>}|js1|jtjdg|j<00><02><00>St|<01>jD] } ||cS tj|<01>}t|<03>t|<01>ur|j|<03>Sy#t$rY<00>UwxYw#t t"f$rYywxYw)z6Get the converter interface instance for *x*, or None.rr3N)r<00>_unpack_to_numpyrr<00>ndarrayr<00>getdata<74>ravel<65>size<7A> get_converter<65>arrayr4<00>type<70>__mro__<5F>KeyError<6F>_safe_first_finite<74> TypeError<6F> StopIteration)r r<00>cls<6C>firsts rrAzRegistry.get_converter<65>s<><00><00> <12> "<22> "<22>1<EFBFBD> %<25><01> <15>a<EFBFBD><12><1A><1A> $<24><13><05><05> <0A> <0A>a<EFBFBD> <20>&<26>&<26>(<28>A<EFBFBD><14>6<EFBFBD>6<EFBFBD><1B>)<29>)<29>"<22>(<28>(<28>A<EFBFBD>3<EFBFBD>a<EFBFBD>g<EFBFBD>g<EFBFBD>*F<>G<>G<><17><01>7<EFBFBD>?<3F>?<3F> <15>C<EFBFBD> <15><1B>C<EFBFBD>y<EFBFBD> <20> <15>
 1<><19>,<2C>,<2C>Q<EFBFBD>/<2F>E<EFBFBD> <14>E<EFBFBD>{<7B>$<24>q<EFBFBD>'<27>)<29><1B>)<29>)<29>%<25>0<>0<><13><><1C> <15><14> <15><><1A>=<3D>)<29> <11> <10> <14> <11>s$<00>3C9<02><D<00>9 D<05>D<05>D<03>DN)r r
r r"rAr r rr:r:<00>s
<00><00>3<>r r:)r"<00>decimalr<00>numbersr<00>numpyrr<00>
matplotlibrrGrrrr$r1<00>dictr:<00>registryr r r<00><module>rQss<00><01>(<04>T<1C><1A><12><14><1C> <09>i<EFBFBD> <09> D<01> !-<2D>!-<2D>H<13><13>62<>*<2A>2<>4<14>t<EFBFBD><14>B <14>:<3A><08>$<24>&<26><08><17>r