From 4fd6d06024895fa75e0d813d23bb4069f9f7a6a7 Mon Sep 17 00:00:00 2001 From: Gui-FernandesBR Date: Mon, 12 Feb 2024 02:01:01 -0500 Subject: [PATCH 1/3] DOC: change MAINT to MNT as our convention --- docs/development/style_guide.rst | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) 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 From 4a3a50c65f001a784ea5e369d4a381df366b7f2b Mon Sep 17 00:00:00 2001 From: Gui-FernandesBR Date: Mon, 12 Feb 2024 02:01:23 -0500 Subject: [PATCH 2/3] MNT: Add NUMERICAL_TYPES constant for type checking --- rocketpy/mathutils/function.py | 26 ++++++++------------------ 1 file changed, 8 insertions(+), 18 deletions(-) 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 From 1d819d16d5a8f768412090cbf7cad0be5b23913f Mon Sep 17 00:00:00 2001 From: Gui-FernandesBR Date: Mon, 12 Feb 2024 02:03:27 -0500 Subject: [PATCH 3/3] MNT: update CHANGELOG --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) 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)