-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
694ae12
commit 84d14cf
Showing
5 changed files
with
93 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
numpy\_function | ||
======================= | ||
|
||
.. automodule:: numpy_function | ||
:members: | ||
:undoc-members: | ||
:show-inheritance: |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
import numpy as np | ||
|
||
def relative_error_within_boundaries(x: np.array, low: np.array, high: np.array) -> np.array: # type: ignore | ||
""" | ||
Calculate the relative error of values within specified boundaries. | ||
Args: | ||
x (np.array): The array of values. | ||
low (np.array): The lower boundary array. | ||
high (np.array): The upper boundary array. | ||
Returns: | ||
np.array: The array of relative errors. | ||
""" | ||
return np.abs(error_within_boundaries(x, low, high))/x | ||
|
||
def error_within_boundaries(x: np.array, low: np.array, high: np.array) -> np.array: # type: ignore | ||
""" | ||
Calculate the error of values within specified boundaries. | ||
Args: | ||
x (np.array): The array of values. | ||
low (np.array): The lower boundary array. | ||
high (np.array): The upper boundary array. | ||
Returns: | ||
np.array: The array of errors. | ||
""" | ||
nearest_boundary = np.where(x < low, low, np.where(x > high, high, x)) | ||
return x - nearest_boundary |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters