Skip to content

Commit

Permalink
minor readme update
Browse files Browse the repository at this point in the history
  • Loading branch information
sivart213 committed Feb 1, 2024
1 parent ef2c76f commit c06cce7
Showing 1 changed file with 20 additions and 0 deletions.
20 changes: 20 additions & 0 deletions research_tools/functions/data_treatment.py
Original file line number Diff line number Diff line change
Expand Up @@ -435,6 +435,26 @@ def curve_fit_wrap(fcn, pnts, **params):

# %% Converters
def convert_val(val, iunit, funit, expon=1):
"""
Converts values from one unit to another by sanitizing the input and using sympy.convert_to()
Parameters
----------
val : [int, float, list/tuple/array/series of int/float]
input value(s) to be converted
iunit : [str, sympy.unit]
current unit of val
funit : [list, str]
desired units
expon : int
exponential value of unit
default : 1
Returns
-------
val : [float, array/series of floats]
returns float version of value using sympy.convert_to
"""
if isinstance(val, (list, tuple, np.ndarray, pd.Series)):
res = [convert_val(v, iunit, funit, expon) for v in val]
if isinstance(val, np.ndarray):
Expand Down

0 comments on commit c06cce7

Please sign in to comment.