-
Notifications
You must be signed in to change notification settings - Fork 2
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
add fit.py #4
base: master
Are you sure you want to change the base?
add fit.py #4
Conversation
bionmr_utils/md/process/fit.py
Outdated
|
||
|
||
def fit_limit(data: List[Union[float, int]], window_size=50, pos_diff_ratio=0.5) -> int: | ||
def fit_limit(data: List[Union[float, int]], |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
bad function name. Should be smth like estimate_acorr_fitting_limit
bionmr_utils/md/process/fit.py
Outdated
@@ -22,14 +21,18 @@ def fit_limit(data: List[Union[float, int]], window_size=50, pos_diff_ratio=0.5) | |||
amount of negative derivatives | |||
""" | |||
|
|||
def moving_average(data_set, periods=3): | |||
def moving_average(data_set, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
don't split short function signature across multiple lines
bionmr_utils/md/process/fit.py
Outdated
@@ -48,17 +51,17 @@ def __multi_exp_f(x: Union[float, int], | |||
:param C: free element | |||
:return: sum exponential functions composition | |||
""" | |||
return np.sum( | |||
return sum( | |||
(a * np.exp(-x / tau)) for a, tau in zip(A, TAU) | |||
) + C | |||
|
|||
|
|||
def multi_exp_free_amplitude(x: Union[float, int], |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
short function signature should be one line
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Rename function. Now it's name is not very telling.
bionmr_utils/md/process/fit.py
Outdated
@@ -72,7 +75,13 @@ def multi_exp_free_amplitude(x: Union[float, int], | |||
return __multi_exp_f(x, A, TAU, C) | |||
|
|||
|
|||
def mult_exp_fixed_amplitude_1(x, *args): | |||
def multi_exp_fixed_amplitude_1(x: Union[float, int], | |||
*args): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ditto
:fit_func: function for fit data | ||
:return: Fit curve parameters | ||
""" | ||
def scale_times(args, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ditto
bionmr_utils/md/process/fit.py
Outdated
@@ -90,7 +99,7 @@ def fit_auto_correlation(time: List[float], | |||
bounds: List[List[List[Union[float, int]]]]) \ | |||
-> Tuple[int, Union[np.ndarray, Iterable, int, float]]: | |||
""" | |||
Fit input data with :math:`\sum_n A_n \exp(-t/\\tau_n) + const` | |||
Fit input data with :math: sum_n(A_n exp(-t/tau_n) + const) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Don't break latex formula
bionmr_utils/md/process/fit.py
Outdated
@@ -122,12 +131,25 @@ def decorated_fit_auto_correlation(time: List[float], | |||
bounds: List[List[Union[float, int]]], |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Rename function
No description provided.