MCPcopy Index your code
hub / github.com/LabPy/lantz / _inner

Function _inner

lantz/processors.py:70–94  ·  view source on GitHub ↗
(value)

Source from the content-addressed store, hash-verified

68
69 if return_float:
70 def _inner(value):
71 if isinstance(value, Q_):
72 try:
73 return value.to(units).magnitude
74 except ValueError as e:
75 if on_incompatible == 'raise':
76 raise ValueError(e)
77 elif on_incompatible == 'warn':
78 msg = 'Unable to convert {} to {}. Ignoring source units.'.format(value, units)
79 warnings.warn(msg, DimensionalityWarning)
80 _LOG.warn(msg)
81
82 # on_incompatible == 'ignore'
83 return value.magnitude
84 else:
85 if not units.dimensionless:
86 if on_dimensionless == 'raise':
87 raise ValueError('Unable to convert {} to {}'.format(value, units))
88 elif on_dimensionless == 'warn':
89 msg = 'Assuming units `{1.units}` for {0}'.format(value, units)
90 warnings.warn(msg, DimensionalityWarning)
91 _LOG.warn(msg)
92
93 # on_incompatible == 'ignore'
94 return float(value)
95 return _inner
96 else:
97 def _inner(value):

Callers

nothing calls this directly

Calls 1

keysMethod · 0.45

Tested by

no test coverage detected