diff --git a/CHANGELOG.md b/CHANGELOG.md index fd1f8a097..a3503a9e9 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -57,6 +57,7 @@ You can install this version by running `pip install rocketpy==1.2.0` ### Changed +- MNT: Final refactor before v1.2 [#553](https://github.com/RocketPy-Team/RocketPy/pull/553) - ENH: Plotting both power on and off drag curves in a single plot [#547](https://github.com/RocketPy-Team/RocketPy/pull/547) - DOC: Replacing git clone command with curl in notebooks. [#544](https://github.com/RocketPy-Team/RocketPy/pull/544) - DOC: Installing imageio library on dispersion analysis notebook [#540](https://github.com/RocketPy-Team/RocketPy/pull/540) diff --git a/docs/development/style_guide.rst b/docs/development/style_guide.rst index fd2f12365..de738d53a 100644 --- a/docs/development/style_guide.rst +++ b/docs/development/style_guide.rst @@ -67,7 +67,7 @@ So here are a couple of **guidelines** to help you when creating new branches to #. ``bug``: when your branch attempts to fix a bug #. ``doc``: when your branch adds documentation changes #. ``enh``: when you add new features and enhancements - #. ``maint``: when your branch is all about refactoring, fixing typos, etc. + #. ``mnt``: when your branch is all about refactoring, fixing typos, etc. #. ``rel``: when your branch makes changes related to creating new releases #. ``tst``: when your branch makes changes related to tests @@ -77,10 +77,10 @@ So here are a couple of **guidelines** to help you when creating new branches to Here are a couple of example branch names: -- ``maint/refactor-parachute-implementation`` +- ``mnt/refactor-parachute-implementation`` - ``bug/issue-98-upside-down-rockets`` - ``enh/hybrid-motor-feature`` -- ``maint/typos-flight-class`` +- ``mnt/typos-flight-class`` - ``tst/refactor-tests-flight-class`` Once you are ready to create a Pull Request for your branch, we advise you to merge with the ``develop`` branch instead of the default ``master`` branch. @@ -104,7 +104,7 @@ Commit messages should be clear and follow a few basic rules. Example:: Describing the motivation for a change, the nature of a bug for bug fixes or some details on what an enhancement does are also good to include in a commit message. Messages should be understandable without looking at the code -changes. A commit message like ``MAINT: fixed another one`` is an example of +changes. A commit message like ``MNT: fixed another one`` is an example of what not to do; the reader has to go look for context elsewhere. Standard acronyms to start the commit message with are:: @@ -115,7 +115,7 @@ Standard acronyms to start the commit message with are:: DEV: development tool or utility DOC: documentation ENH: enhancement - MAINT: maintenance commit (refactoring, typos, etc.) + MNT: maintenance commit (refactoring, typos, etc.) REV: revert an earlier commit STY: style fix (whitespace, PEP8) TST: addition or modification of tests diff --git a/rocketpy/mathutils/function.py b/rocketpy/mathutils/function.py index 048b125e2..e8b6a9318 100644 --- a/rocketpy/mathutils/function.py +++ b/rocketpy/mathutils/function.py @@ -19,6 +19,8 @@ except ImportError: from ..tools import cached_property +NUMERICAL_TYPES = (float, int, complex, np.ndarray, np.integer, np.floating) + class Function: """Class converts a python function or a data sequence into an object @@ -1937,9 +1939,7 @@ def __add__(self, other): return Function(lambda x: (self.get_value(x) + other(x))) # If other is Float except... except AttributeError: - if isinstance( - other, (float, int, complex, np.ndarray, np.integer, np.floating) - ): + if isinstance(other, NUMERICAL_TYPES): # Check if Function object source is array or callable if isinstance(self.source, np.ndarray): # Operate on grid values @@ -2069,9 +2069,7 @@ def __mul__(self, other): return Function(lambda x: (self.get_value(x) * other(x))) # If other is Float except... except AttributeError: - if isinstance( - other, (float, int, complex, np.ndarray, np.integer, np.floating) - ): + if isinstance(other, NUMERICAL_TYPES): # Check if Function object source is array or callable if isinstance(self.source, np.ndarray): # Operate on grid values @@ -2160,9 +2158,7 @@ def __truediv__(self, other): return Function(lambda x: (self.get_value_opt(x) / other(x))) # If other is Float except... except AttributeError: - if isinstance( - other, (float, int, complex, np.ndarray, np.integer, np.floating) - ): + if isinstance(other, NUMERICAL_TYPES): # Check if Function object source is array or callable if isinstance(self.source, np.ndarray): # Operate on grid values @@ -2201,9 +2197,7 @@ def __rtruediv__(self, other): A Function object which gives the result of other(x)/self(x). """ # Check if Function object source is array and other is float - if isinstance( - other, (float, int, complex, np.ndarray, np.integer, np.floating) - ): + if isinstance(other, NUMERICAL_TYPES): if isinstance(self.source, np.ndarray): # Operate on grid values ys = other / self.y_array @@ -2271,9 +2265,7 @@ def __pow__(self, other): return Function(lambda x: (self.get_value_opt(x) ** other(x))) # If other is Float except... except AttributeError: - if isinstance( - other, (float, int, complex, np.ndarray, np.integer, np.floating) - ): + if isinstance(other, NUMERICAL_TYPES): # Check if Function object source is array or callable if isinstance(self.source, np.ndarray): # Operate on grid values @@ -2312,9 +2304,7 @@ def __rpow__(self, other): A Function object which gives the result of other(x)**self(x). """ # Check if Function object source is array and other is float - if isinstance( - other, (float, int, complex, np.ndarray, np.integer, np.floating) - ): + if isinstance(other, NUMERICAL_TYPES): if isinstance(self.source, np.ndarray): # Operate on grid values ys = other**self.y_array