Download: https://osdyn.ifremer.fr/pyweb/notebooks/utils/mmath.ipynb
Mathematical tools
[1]:
from osdyn.utils.misc.info import what_function
from osdyn.utils.misc.mmath import bound, get_unit, get_precision
[2]:
from osdyn.utils.misc import mmath
Avalaible functions
[3]:
what_function(mmath)
[3]:
['bound',
'ceil',
'explore_regular_linear_range_bounds',
'floor',
'get_number_of_nan',
'get_number_of_notnan',
'get_precision',
'get_unit',
'main',
'set_range']
bounds for a range or colorbar
[4]:
# get inner rounds
print(bound(-1034.3285), bound(1034.3285))
-1034.0 1034.0
[5]:
# get outer rounds
print(bound(-1034.3285, shrink=False), bound(1034.3285, shrink=False))
-1035.0 1035.0
[6]:
# get outer rounds at 10^2
print(bound(-1034.3285, shrink=False, precision=2), bound(1034.3285, shrink=False, precision=2))
-1100.0 1100.0
[7]:
# get inner rounds for decimal numbers
print(bound(-0.3285), bound(0.3285))
-0.3 0.3
[8]:
# get outer rounds at 10^{-2}
print(bound(-0.3285, shrink=False, precision=-3), bound(0.3285, shrink=False, precision=-3))
-0.329 0.329
unit of a number
[9]:
get_unit(000.00399)
[9]:
0.001
[10]:
get_unit(0.99)
[10]:
0.1
[11]:
get_unit(-0.93)
[11]:
0.1
precision of a number
[12]:
get_precision(-0.00093)
[12]:
-5
[13]:
get_precision(-103.0)
[13]:
-1