FazBrowse GitHub Viewer
|
Trending
|
URL:
|
Home
Tools:
[Download Repo ZIP]
[View Raw Code]
[Original HTTPS Page]
matplotlib/lib/matplotlib/testing/jpl_units/__init__.py at main · matplotlib/matplotlib · GitHub
matplotlib
matplotlib
Repository navigation
Code
Issues
1.1k
(1.1k)
Pull requests
430
(430)
Actions
Projects
Wiki
Security and quality
Insights
Expand file tree
Breadcrumbs
matplotlib
/
lib
/
matplotlib
/
testing
/
jpl_units
/
__init__.py
Copy path
More file actions
More file actions
Latest commit
History
History
History
76 lines (62 loc) · 2.62 KB
Breadcrumbs
matplotlib
/
lib
/
matplotlib
/
testing
/
jpl_units
/
__init__.py
Copy path
File metadata and controls
76 lines (62 loc) · 2.62 KB
Raw
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
"""
A sample set of units for use with testing unit conversion
of Matplotlib routines. These are used because they use very strict
enforcement of unitized data which will test the entire spectrum of how
unitized data might be used (it is not always meaningful to convert to
a float without specific units given).
UnitDbl is essentially a unitized floating point number. It has a
minimal set of supported units (enough for testing purposes). All
of the mathematical operation are provided to fully test any behaviour
that might occur with unitized data. Remember that unitized data has
rules as to how it can be applied to one another (a value of distance
cannot be added to a value of time). Thus we need to guard against any
accidental "default" conversion that will strip away the meaning of the
data and render it neutered.
Epoch is different than a UnitDbl of time. Time is something that can be
measured where an Epoch is a specific moment in time. Epochs are typically
referenced as an offset from some predetermined epoch.
A difference of two epochs is a Duration. The distinction between a Duration
and a UnitDbl of time is made because an Epoch can have different frames (or
units). In the case of our test Epoch class the two allowed frames are 'UTC'
and 'ET' (Note that these are rough estimates provided for testing purposes
and should not be used in production code where accuracy of time frames is
desired). As such a Duration also has a frame of reference and therefore needs
to be called out as different that a simple measurement of time since a delta-t
in one frame may not be the same in another.
"""
from
.
Duration
import
Duration
from
.
Epoch
import
Epoch
from
.
UnitDbl
import
UnitDbl
from
.
StrConverter
import
StrConverter
from
.
EpochConverter
import
EpochConverter
from
.
UnitDblConverter
import
UnitDblConverter
from
.
UnitDblFormatter
import
UnitDblFormatter
__version__
=
"1.0"
__all__
=
[
'register'
,
'Duration'
,
'Epoch'
,
'UnitDbl'
,
'UnitDblFormatter'
,
]
def
register
():
"""Register the unit conversion classes with matplotlib."""
import
matplotlib
.
units
as
mplU
mplU
.
registry
[
str
]
=
StrConverter
()
mplU
.
registry
[
Epoch
]
=
EpochConverter
()
mplU
.
registry
[
Duration
]
=
EpochConverter
()
mplU
.
registry
[
UnitDbl
]
=
UnitDblConverter
()
# Some default unit instances
# Distances
m
=
UnitDbl
(
1.0
,
"m"
)
km
=
UnitDbl
(
1.0
,
"km"
)
mile
=
UnitDbl
(
1.0
,
"mile"
)
# Angles
deg
=
UnitDbl
(
1.0
,
"deg"
)
rad
=
UnitDbl
(
1.0
,
"rad"
)
# Time
sec
=
UnitDbl
(
1.0
,
"sec"
)
min
=
UnitDbl
(
1.0
,
"min"
)
hr
=
UnitDbl
(
1.0
,
"hour"
)
day
=
UnitDbl
(
24.0
,
"hour"
)
sec
=
UnitDbl
(
1.0
,
"sec"
)
Back
|
FazBrowse Home
|
New Git URL