Skip to content
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

MNT: Final refactor before v1.2 #553

Merged
merged 3 commits into from
Feb 12, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
10 changes: 5 additions & 5 deletions docs/development/style_guide.rst
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand All @@ -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.
Expand All @@ -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::
Expand All @@ -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
Expand Down
26 changes: 8 additions & 18 deletions rocketpy/mathutils/function.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down
Loading