Files
old-parkingkoncept/parkingkonceptvenv/lib/python3.7/site-packages/matplotlib/__pycache__/units.cpython-37.pyc

111 lines
5.5 KiB
Plaintext
Raw Normal View History

2019-11-17 12:44:16 +01:00
B
U<>]<00>@szdZddlmZddlZddlmZddlmZGdd<07>de<08>Z Gdd <09>d e
<EFBFBD>Z Gd
d <0B>d e
<EFBFBD>Z Gd d <0A>d e <0A>Ze<0E>ZdS)as
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 provide the register with the Registry
converter dictionary and 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 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>NumberN)<01>ma)<01>cbookc@s eZdZdS)<02>ConversionErrorN)<03>__name__<5F>
__module__<EFBFBD> __qualname__<5F>r r <00>8/tmp/pip-install-i8dhxrtk/matplotlib/matplotlib/units.pyr5src@seZdZdZddd<04>ZdS)<06>AxisInfoz<6F>
Information to support default axis labeling, tick labeling, and limits.
An instance of this class must be returned by
`ConversionInterface.axisinfo`.
NcCs(||_||_||_||_||_||_dS)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>selfr r rrrrr r r
<00>__init__@s zAxisInfo.__init__)NNNNNN)rrr<00>__doc__rr r r r
r 9sr c@s@eZdZdZedd<03><00>Zedd<05><00>Zedd<07><00>Zedd <09><00>Zd
S) <0B>ConversionInterfacez<65>
The minimal interface for a converter to take custom data types (or
sequences) and convert them to values Matplotlib can use.
cCsdS)zT
Return an `~units.AxisInfo` for the axis with the specified units.
Nr )<02>unit<69>axisr r r
<00>axisinfobszConversionInterface.axisinfocCsdS)zQ
Return the default unit for *x* or ``None`` for the given axis.
Nr )<02>xrr r r
<00> default_unitsisz!ConversionInterface.default_unitscCs|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>objrrr r r
<00>convertpszConversionInterface.convertcCs<t<00>|<00>r.x,|D]}|tjkr qt|t<05>SWn
t|t<05>SdS)a
The Matplotlib datalim, autoscaling, locators etc work with scalars
which are the units converted to floats given the current unit. The
converter may be passed these floats, or arrays of them, even when
units are set.
N)<06>np<6E>iterablerZmasked<65>
isinstancer)rZthisxr r r
<00>
is_numlikezs 


zConversionInterface.is_numlikeN) rrrr<00> staticmethodrrrr r r r r
r]s
  
rc@seZdZdZdd<03>ZdS)<05>Registryz)Register types with conversion interface.c Cs<>t|d<01>r|j}t|tj<04>rJtj<05>|<01><01><07>}|jsJ|<00> tj
dg|j d<03><02>Sy |t |<01>St k
r<EFBFBD>yt<0E>|<01>}Wnttfk
r<EFBFBD>YnXt |<02>t |<01>k r<>|<00> |<02>SYnXdS)z6Get the converter interface instance for *x*, or None.<2E>valuesr)<01>dtypeN)<12>hasattrr#rrZndarrayrZgetdataZravel<65>size<7A> get_converter<65>arrayr$<00>type<70>KeyErrorrZsafe_first_element<6E> TypeError<6F> StopIteration)rr<00>firstr r r
r'<00>s 
  zRegistry.get_converterN)rrrrr'r r r r
r"<00>sr")r<00>numbersrZnumpyrrZ
matplotlibrr+r<00>objectr r<00>dictr"<00>registryr r r r
<00><module>+s   $.