Skip to content

BUG: fixes get_instance_attributes for Flight objects containing a Rocket object without rail buttons #786

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

Conversation

leogrosa
Copy link
Member

@leogrosa leogrosa commented Mar 19, 2025

Pull request type

  • Code changes (bugfix, features)
  • Code maintenance (refactoring, formatting, tests)
  • ReadMe, Docs and GitHub updates
  • Other (please describe):

Checklist

  • Tests for the changes have been added (if needed)
  • Docs have been reviewed and added / updated
  • Lint (black rocketpy/ tests/) has passed locally
  • All tests (pytest tests -m slow --runslow) have passed locally
  • CHANGELOG.md has been updated (if relevant)

Current behavior

When calling the function get_instance_attributes() and passing a Flight object that contains a Rocket object without rail buttons as the argument, it crashes. More specifically, it crashes when trying to calculate the rail button forces (__calculate_rail_button_forces).

Stack trace:

instance = <Flight(rocket= <rocketpy.rocket.rocket.Rocket object at 0x11370c410>, environment= <rocketpy.environment.environment.Environment object at 0x110e2b680>, rail_length= 5.2, inclination= 85, heading = 0,name= Flight)>
owner = <class 'rocketpy.simulation.flight.Flight'>

    def __get__(self, instance, owner=None):
        if instance is None:
            return self
        cache = instance.__dict__
        try:
            # If cache is ready, return it
>           val = cache[self.attrname]
E           KeyError: 'rail_button1_normal_force'

rocketpy/mathutils/function.py:3531: KeyError

During handling of the above exception, another exception occurred:

self = <rocketpy.mathutils.function.funcify_method.<locals>.funcify_method_decorator object at 0x1112cf4d0>
instance = <Flight(rocket= <rocketpy.rocket.rocket.Rocket object at 0x11370c410>, environment= <rocketpy.environment.environment.Environment object at 0x110e2b680>, rail_length= 5.2, inclination= 85, heading = 0,name= Flight)>
owner = <class 'rocketpy.simulation.flight.Flight'>

    def __get__(self, instance, owner=None):
        if instance is None:
            return self
        cache = instance.__dict__
        try:
            # If cache is ready, return it
            val = cache[self.attrname]
        except KeyError:
            # If cache is not ready, create it
            try:
                # Handle methods which return Function instances
>               val = self.func(instance).reset(*args, **kwargs)
E               AttributeError: 'list' object has no attribute 'reset'

rocketpy/mathutils/function.py:3536: AttributeError

During handling of the above exception, another exception occurred:

flight_calisto = <Flight(rocket= <rocketpy.rocket.rocket.Rocket object at 0x11370c410>, environment= <rocketpy.environment.environment.Environment object at 0x110e2b680>, rail_length= 5.2, inclination= 85, heading = 0,name= Flight)>

    def test_get_instance_attributes_with_flight_without_rail_buttons(flight_calisto):
        """Tests if get_instance_attributes returns the expected results for a
        flight object that contains a rocket object without rail buttons."""
    
>       attributes = utilities.get_instance_attributes(flight_calisto)

tests/unit/test_utilities.py:185: 
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
rocketpy/utilities.py:682: in get_instance_attributes
    members = inspect.getmembers(instance)
/opt/homebrew/Cellar/[email protected]/3.12.3/Frameworks/Python.framework/Versions/3.12/lib/python3.12/inspect.py:607: in getmembers
    return _getmembers(object, predicate, getattr)
/opt/homebrew/Cellar/[email protected]/3.12.3/Frameworks/Python.framework/Versions/3.12/lib/python3.12/inspect.py:585: in _getmembers
    value = getter(object, key)
rocketpy/simulation/flight.py:2850: in max_rail_button1_normal_force
    return np.abs(self.rail_button1_normal_force.y_array).max()
rocketpy/mathutils/function.py:3540: in __get__
    val = Function(source, *args, **kwargs)
rocketpy/mathutils/function.py:147: in __init__
    self.set_source(self.source)
rocketpy/mathutils/function.py:225: in set_source
    source = self.__validate_source(source)
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

self = <[AttributeError("'Function' object has no attribute '__dom_dim__'") raised in repr()] Function object at 0x113aee3c0>
source = array([], dtype=float64)

    def __validate_source(self, source):  # pylint: disable=too-many-statements
        """Used to validate the source parameter for creating a Function object.
    
        Parameters
        ----------
        source : np.ndarray, callable, str, Path, Function, list
            The source data of the Function object. This can be a numpy array,
            a callable function, a string or Path object to a csv or txt file,
            a Function object, or a list of numbers.
    
        Returns
        -------
        np.ndarray, callable
            The validated source parameter.
    
        Raises
        ------
        ValueError
            If the source is not a valid type or if the source is not a 2D array
            or a callable function.
        """
        if isinstance(source, Function):
            return source.get_source()
    
        if isinstance(source, (str, Path)):
            # Read csv or txt files and create a numpy array
            try:
                source = np.loadtxt(source, delimiter=",", dtype=np.float64)
            except ValueError:
                with open(source, "r") as file:
                    header, *data = file.read().splitlines()
    
                header = [label.strip("'").strip('"') for label in header.split(",")]
                source = np.loadtxt(data, delimiter=",", dtype=np.float64)
    
                if len(source[0]) == len(header):
                    if self.__inputs__ is None:
                        self.__inputs__ = header[:-1]
                    if self.__outputs__ is None:
                        self.__outputs__ = [header[-1]]
            except Exception as e:  # pragma: no cover
                raise ValueError(
                    "Could not read the csv or txt file to create Function source."
                ) from e
    
        if isinstance(source, (list, np.ndarray)):
            # Triggers an error if source is not a list of numbers
            source = np.array(source, dtype=np.float64)
    
            # Checks if 2D array
            if len(source.shape) != 2:
>               raise ValueError(
                    "Source must be a 2D array in the form [[x1, x2 ..., xn, y], ...]."
                )
E               ValueError: Source must be a 2D array in the form [[x1, x2 ..., xn, y], ...].

rocketpy/mathutils/function.py:3243: ValueError

New behavior

The function get_instance_attributes() doesn't crash when passing a Flight object that contains a Rocket object without rail buttons. More specifically, the method __calculate_rail_button_forces() correctly returns a constant Function object mapping to 0.

Breaking change

  • Yes
  • No

Additional information

The test tests/integration/test_flight.py::test_time_overshoot fails locally.

@leogrosa leogrosa requested a review from a team as a code owner March 19, 2025 03:27
@Gui-FernandesBR Gui-FernandesBR changed the base branch from master to develop March 19, 2025 11:24
Copy link
Member

@Gui-FernandesBR Gui-FernandesBR left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This PR looks great.

Only two small things tombe done:
1 - update the CHANGELOG file
2 - link this PR with the corresponding issue.

@github-project-automation github-project-automation bot moved this from Backlog to Next Version in LibDev Roadmap Mar 19, 2025
Copy link

codecov bot commented Mar 19, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 79.49%. Comparing base (83aa20e) to head (f6db943).
Report is 25 commits behind head on develop.

Additional details and impacted files
@@             Coverage Diff             @@
##           develop     #786      +/-   ##
===========================================
+ Coverage    76.42%   79.49%   +3.07%     
===========================================
  Files           95       96       +1     
  Lines        11090    11501     +411     
===========================================
+ Hits          8475     9143     +668     
+ Misses        2615     2358     -257     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@Gui-FernandesBR
Copy link
Member

@leogrosa , just a reminder you have to update the CHANGELOG.md file before we can merge this PR.

This PR should be added to the next release (this weekend).

@leogrosa
Copy link
Member Author

leogrosa commented Mar 21, 2025

@Gui-FernandesBR, CHANGELOG is now updated and the conflict has been resolved.
I'm just worried about the test that didn't pass locally.

@Gui-FernandesBR
Copy link
Member

@Gui-FernandesBR, CHANGELOG is now updated and the conflict has been resolved.
I'm just worried about the test that didn't pass locally.

@leogrosa can you specify which tests are not passing?

@leogrosa
Copy link
Member Author

@Gui-FernandesBR, the test that fails is tests/integration/test_flight.py::test_time_overshoot.
This is the stack trace:

self = <rocketpy.mathutils.function.funcify_method.<locals>.funcify_method_decorator object at 0x12035b9e0>
instance = <Flight(rocket= <rocketpy.rocket.rocket.Rocket object at 0x16369cd40>, environment= <rocketpy.environment.environment.Environment object at 0x1636407d0>, rail_length= 5.2, inclination= 85, heading = 0,name= Flight)>
owner = <class 'rocketpy.simulation.flight.Flight'>

    def __get__(self, instance, owner=None):
        if instance is None:
            return self
        cache = instance.__dict__
        try:
            # If cache is ready, return it
>           val = cache[self.attrname]
E           KeyError: 'x'

rocketpy/mathutils/function.py:3531: KeyError

During handling of the above exception, another exception occurred:

self = <rocketpy.mathutils.function.funcify_method.<locals>.funcify_method_decorator object at 0x12035b9e0>
instance = <Flight(rocket= <rocketpy.rocket.rocket.Rocket object at 0x16369cd40>, environment= <rocketpy.environment.environment.Environment object at 0x1636407d0>, rail_length= 5.2, inclination= 85, heading = 0,name= Flight)>
owner = <class 'rocketpy.simulation.flight.Flight'>

    def __get__(self, instance, owner=None):
        if instance is None:
            return self
        cache = instance.__dict__
        try:
            # If cache is ready, return it
            val = cache[self.attrname]
        except KeyError:
            # If cache is not ready, create it
            try:
                # Handle methods which return Function instances
>               val = self.func(instance).reset(*args, **kwargs)
E               AttributeError: 'numpy.ndarray' object has no attribute 'reset'. Did you mean: 'repeat'?

rocketpy/mathutils/function.py:3536: AttributeError

During handling of the above exception, another exception occurred:

mock_show = <MagicMock name='show' id='5282258032'>, calisto_robust = <rocketpy.rocket.rocket.Rocket object at 0x16369cd40>
example_spaceport_env = <rocketpy.environment.environment.Environment object at 0x1636407d0>

    @pytest.mark.slow
    @patch("matplotlib.pyplot.show")
    def test_time_overshoot(mock_show, calisto_robust, example_spaceport_env):  # pylint: disable=unused-argument
        """Test the time_overshoot parameter of the Flight class. This basically
        calls the all_info() method for a simulation without time_overshoot and
        checks if it returns None. It is not testing if the values are correct,
        just if the flight simulation is not breaking.
    
        Parameters
        ----------
        calisto_robust : rocketpy.Rocket
            The rocket to be simulated. In this case, the fixture rocket is used.
            See the conftest.py file for more information.
        example_spaceport_env : rocketpy.Environment
            The environment to be simulated. In this case, the fixture environment
            is used. See the conftest.py file for more information.
        """
    
        test_flight = Flight(
            rocket=calisto_robust,
            environment=example_spaceport_env,
            rail_length=5.2,
            inclination=85,
            heading=0,
            time_overshoot=False,
        )
    
>       assert test_flight.all_info() is None

tests/integration/test_flight.py:256: 
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
rocketpy/simulation/flight.py:3407: in all_info
    self.info()
rocketpy/simulation/flight.py:3403: in info
    self.prints.all()
rocketpy/prints/flight_prints.py:402: in all
    self.initial_conditions()
rocketpy/prints/flight_prints.py:56: in initial_conditions
    f"Position - x: {self.flight.x(t_init):.2f} m | "
rocketpy/mathutils/function.py:3540: in __get__
    val = Function(source, *args, **kwargs)
rocketpy/mathutils/function.py:147: in __init__
    self.set_source(self.source)
rocketpy/mathutils/function.py:264: in set_source
    self.set_interpolation(self.__interpolation__)
rocketpy/mathutils/function.py:309: in set_interpolation
    self.__update_interpolation_coefficients(self.__interpolation__)
rocketpy/mathutils/function.py:324: in __update_interpolation_coefficients
    self.__interpolate_spline__()
rocketpy/mathutils/function.py:1872: in __interpolate_spline__
    c = linalg.solve_banded(
venv/lib/python3.12/site-packages/scipy/linalg/_basic.py:596: in solve_banded
    b1 = _asarray_validated(b, check_finite=check_finite, as_inexact=True)
venv/lib/python3.12/site-packages/scipy/_lib/_util.py:537: in _asarray_validated
    a = toarray(a)
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

a = array([ 0.,  0.,  0.,  0.,  0.,  0.,  0.,  0.,  0.,  0.,  0.,  0.,  0.,
        0.,  0.,  0.,  0.,  0.,  0.,  0.,  0.,... 0.,  0.,  0.,
        0.,  0.,  0.,  0.,  0.,  0.,  0.,  0.,  0.,  0.,  0.,  0.,  0.,
        0.,  0.,  0.,  0.,  0.])
dtype = None, order = None

    @set_module('numpy')
    def asarray_chkfinite(a, dtype=None, order=None):
        """Convert the input to an array, checking for NaNs or Infs.
    
        Parameters
        ----------
        a : array_like
            Input data, in any form that can be converted to an array.  This
            includes lists, lists of tuples, tuples, tuples of tuples, tuples
            of lists and ndarrays.  Success requires no NaNs or Infs.
        dtype : data-type, optional
            By default, the data-type is inferred from the input data.
        order : {'C', 'F', 'A', 'K'}, optional
            Memory layout.  'A' and 'K' depend on the order of input array a.
            'C' row-major (C-style),
            'F' column-major (Fortran-style) memory representation.
            'A' (any) means 'F' if `a` is Fortran contiguous, 'C' otherwise
            'K' (keep) preserve input order
            Defaults to 'C'.
    
        Returns
        -------
        out : ndarray
            Array interpretation of `a`.  No copy is performed if the input
            is already an ndarray.  If `a` is a subclass of ndarray, a base
            class ndarray is returned.
    
        Raises
        ------
        ValueError
            Raises ValueError if `a` contains NaN (Not a Number) or Inf (Infinity).
    
        See Also
        --------
        asarray : Create and array.
        asanyarray : Similar function which passes through subclasses.
        ascontiguousarray : Convert input to a contiguous array.
        asfortranarray : Convert input to an ndarray with column-major
                         memory order.
        fromiter : Create an array from an iterator.
        fromfunction : Construct an array by executing a function on grid
                       positions.
    
        Examples
        --------
        >>> import numpy as np
    
        Convert a list into an array. If all elements are finite, then
        ``asarray_chkfinite`` is identical to ``asarray``.
    
        >>> a = [1, 2]
        >>> np.asarray_chkfinite(a, dtype=float)
        array([1., 2.])
    
        Raises ValueError if array_like contains Nans or Infs.
    
        >>> a = [1, 2, np.inf]
        >>> try:
        ...     np.asarray_chkfinite(a)
        ... except ValueError:
        ...     print('ValueError')
        ...
        ValueError
    
        """
        a = asarray(a, dtype=dtype, order=order)
        if a.dtype.char in typecodes['AllFloat'] and not np.isfinite(a).all():
>           raise ValueError(
                "array must not contain infs or NaNs")
E           ValueError: array must not contain infs or NaNs

venv/lib/python3.12/site-packages/numpy/lib/_function_base_impl.py:646: ValueError

@leogrosa
Copy link
Member Author

leogrosa commented Mar 21, 2025

I noticed that the same test also fails when running the tests on the develop branch. Maybe it's a problem with my computer — I'll investigate further.
This makes me believe that this PR is ok and ready to be merged.

@Gui-FernandesBR
Copy link
Member

@leogrosa , tests are running on CI, this is likely a problem on your own end, your environment is probably not configured as it should be. I don't see how this could be a problem introduced by this PR, I'm sorry.

My recommendation is for you to share your problem with the team during the regular meeting time so you can all debug it together.

@leogrosa leogrosa merged commit 91ac567 into develop Mar 21, 2025
10 checks passed
@leogrosa leogrosa deleted the bug/flight-without-rail-buttons-crash-on-get-instance-attributes branch March 21, 2025 21:53
@github-project-automation github-project-automation bot moved this from Next Version to Closed in LibDev Roadmap Mar 21, 2025
MateusStano added a commit that referenced this pull request Apr 21, 2025
commit c674725
Author: Kevin Alcañiz <[email protected]>
Date:   Sat Apr 12 13:40:25 2025 +0200

    ENH: Introduce Net Thrust with pressure corrections (#789)

    * wind factor bug corrected

    the wind factor wasn't applied to the env.wind_velocity properties

    * BUG: StochasticModel visualize attributes of a uniform distribution

    It showed the nominal and the standard deviation values and it doesn't make sense in a uniform distribution. In a np.random.uniform the 'nominal value' is the lower bound of the distribution, and the 'standard deviation' value is the upper bound. Now, a new condition has been added for the uniform distributions where the mean and semi range are calculated and showed. This way the visualize_attribute function will show the whole range where the random values are uniformly taken in

    * variable names corrections

    * Corrections requested by the pylint test

    * ENH: Add pressure corrections for thrust in SolidMotor

    The thrust generated by a SolidMotor is now adjusted for the atmospheric pressure. To achieve that, a new attribute, 'vacuum_thrust', has been created. The 'net_thrust' is the result of 'vacuum_thrust' minus the atmospheric pressure multiplied by the nozzle area.

    * ENH: pylint recommendations done

    * ENH: net thrust method extended to the rest of the motor classes

    * BUG: __post_processed_variables inconsistent array

    * ENH: ruff reformatting

    * Update rocketpy/motors/motor.py

    Co-authored-by: Gui-FernandesBR <[email protected]>

    * ENH: Avoid breaking change

    * ENH: Pressure Thrust method added

    * BUG: call to the thrust function wrong

    * BUG: pressure thrust evaluated when motor is turned off

    * ENH: CHANGELOG updated

    * DOC: definition of exhaust velocity improved

    ---------

    Co-authored-by: Gui-FernandesBR <[email protected]>

commit 9f2644a
Author: Lucas Prates <[email protected]>
Date:   Sat Apr 12 11:27:53 2025 +0200

    ENH: Implement Multivariate Rejection Sampling (MRS) (#738)

    * ENH: implementing a draft version of the Multivarite Rejectio Sampler (MRS).

    * MNT: quick notebook to test MRS during development

    * MNT: refactoring class to match review suggestions

    * ENH: add comparison prints, plots and ellipses to MonteCarlo and finally checks in MRS

    * MNT: add MultivariateRejectionSampler class to inits and apply format

    * DOC: writting .rst documentation for MRS

    * MNT: adding pylint flags to skip checks

    * DOC: completing missing sections in mrs.rst

    * DOC: add changelog and apply sugestions in MRS class

    * DOC: apply suggestions to the MRS.rst

    * MNT: use Union instead of | for type hinting since we have to support python3.9

    * TST: adding unit and integration tests to MRS

    * MNT: use pylint flag to fix linter

    * TST: adding tests to MonteCarlo comparison features

    * MNT: applying suggestions in .rst, better handling nested variables in MRS and applying linters

    * MNT: removing TODO comments from monte_carlo_plots

    * MNT: remove useless TODO

    * MNT: inserting pragmas for no cover and resolving changelog conflict

commit d49c40e
Author: ArthurJWH <[email protected]>
Date:   Fri Apr 11 16:11:20 2025 -0400

    ENH: Create a rocketpy file to store flight simulations (#800)

    * ENH: added .rpy file functionality (see issue 668)

    This commit add 'save_to_rpy' and 'load_from_rpy' functions, that allows saving and loading flights.

    * MNT: adjusting minor changes to .rpy functions and tests.

    Formatted docstrings correctly.
    Reverted duplication of `test_encoding.py` files.
    Version warning will be called when loaded version is more recent.

    * MNT: incorporating previous comments

    Change file management from os to Path
    Adjust docstrings

    * DOC: Added comment about outputs in `to_dict` method

    * MNT: Refactoring `RocketPyDecoder` unpacking operation and other small adjustments

    * DOC: update changelog

    * STY: formatted according to ruff

    * MNT: changing `str | Path` operation to support Python 3.9

    * MNT: fixed trailing commas on .rpy and added shield against `ruff` formatting .rpy and .json files

    * MNT: fixing error related to `test_flight_save_load_no_resimulate`

    When `include_outputs` were set to `True`, it would try to include the additional data into the flight, breaking the test

    * MNT: fixing a typo and adding comment on test coverage

    ---------

    Co-authored-by: Gui-FernandesBR <[email protected]>

commit 6bf70f3
Author: Júlio Machado <[email protected]>
Date:   Sat Apr 5 15:08:53 2025 -0300

    ENH: Support for the RSE file format has been added to the library (#798)

    * ENH: Support for the RSE file format has been added to the library. The import_rse method in the Abstract Motor class and the load_from_rse_file method in the GenericMotor class are now available. With this update, the library natively supports Rock Sim software data, eliminating the need for users to manually convert motor files. The implementation was based on the import_eng and load_from_eng_file methods, utilizing Python's standard XML library.

    * ENH: Adding tests to the methods of .rse file treatment.

    * ENH: fixing mistakes on the method and test file

    * MNT: Running ruff

    * MNT: Adding the PR to CHANGELOG.md

commit 220bb59
Merge: 4a41f7a 4df0b38
Author: Gui-FernandesBR <[email protected]>
Date:   Thu Mar 27 06:14:22 2025 -0300

    Merge pull request #797 from RocketPy-Team/master

    Updates develop after 1.9.0

commit 4df0b38
Author: MateusStano <[email protected]>
Date:   Mon Mar 24 17:35:03 2025 +0100

    REL: Update version to 1.9.0 (#795)

commit 5328d66
Author: MateusStano <[email protected]>
Date:   Mon Mar 24 13:07:52 2025 +0100

    DEP: Remove Pending Deprecations and Add Warnings Where Needed (#794)

    * DEP: Add deprecation warnings for outdated methods and functions

    * DEP: Remove deprecated methods for NOAA RUC soundings and power drag plots

    * DEV: changelog

    * MNT: ruff

    * DEP: Update deprecation warning for post_process method to specify removal in v1.10

    * MNT: Remove unused imports

commit 76fb5ef
Merge: a4b42c3 4a41f7a
Author: Gui-FernandesBR <[email protected]>
Date:   Sun Mar 23 19:17:16 2025 -0300

    Merge pull request #793 from RocketPy-Team/develop

    DEV: Master to v1.9.0

commit 4a41f7a
Author: Kevin Alcañiz <[email protected]>
Date:   Sun Mar 23 21:52:51 2025 +0100

    ENH: Introduce the StochasticAirBrakes class (#785)

    * wind factor bug corrected

    the wind factor wasn't applied to the env.wind_velocity properties

    * BUG: StochasticModel visualize attributes of a uniform distribution

    It showed the nominal and the standard deviation values and it doesn't make sense in a uniform distribution. In a np.random.uniform the 'nominal value' is the lower bound of the distribution, and the 'standard deviation' value is the upper bound. Now, a new condition has been added for the uniform distributions where the mean and semi range are calculated and showed. This way the visualize_attribute function will show the whole range where the random values are uniformly taken in

    * variable names corrections

    * Corrections requested by the pylint test

    * ENH: add multiplication for 2D functions in rocketpy.function

    Added the ability to multiply functions with 2D domains in the __mul__ function

    * ENH: StochasticAirBrakes class created

    The StochasticAirBrakes class has been created. The __init__.py files in the stochastic and rocketpy folders have also been modified accordingly to incorporate this new class

    * ENH: set_air_brakes function created

    This functions appends an airbrake and controller objects previuosly created to the rocket

    * ENH: add StochasticAirBrake to rocketpy.stochastic_rocket

    Some functions has been modified and other has been created in order to include the new StochasticAirBrakes feature into the StochasticRocket class. A new function named 'add_air_brakes' has been created to append a StochasticAirBrakes and Controller objects to the StochasticRocket object. A new function '_create_air_brake' has been introduced to create a sample of an AirBrake object through a StochasticAirBrake object. Enventually, the 'create_object' function has been modified to add the sampled AirBrakes to the sampled Rocket

    * BUG: StochasticAirBrake object input in _Controller

    When defining the _Controller object a StochasticAirBrake was input. This is already corrected and a AirBrake object is now introduced

    * ENH: add time_overshoot option to rocketpy.stochastic_flight

    Since the new StochasticAirBrake class is defined, we need the 'time_overshoot' option in the Flight class to ensure that the time step defined in the simulation is the controller sampling rate. The MonteCarlo class has had to be modified as well to include this option.

    * DOC: StochasticAirBrakes related documentation added

    Documentation related to the StochasticAirBrakes implementation has been added in StochasticAirBrakes, StochasticRocket and Rocket classes.

    * ENH: pylint recommendations done

    * ENH: Reformatted files to pass Ruff linting checks

    * ENH: Update rocketpy/stochastic/stochastic_rocket.py

    Unnecessary comment

    Co-authored-by: Gui-FernandesBR <[email protected]>

    * DOC: improve drag curve factor definition in StochasticAirBrakes

    * ENH: Change assert statement to if

    Co-authored-by: Gui-FernandesBR <[email protected]>

    * DOC: better explanation of __mul__ function

    Co-authored-by: MateusStano <[email protected]>

    * ENH: delete set_air_brakes function for simplicity

    * DOC: CHANGELOG file updated

    ---------

    Co-authored-by: Gui-FernandesBR <[email protected]>
    Co-authored-by: MateusStano <[email protected]>

commit 90553f5
Author: Kevin Alcañiz <[email protected]>
Date:   Sun Mar 23 20:31:50 2025 +0100

    ENH: Add Eccentricity to Stochastic Simulations (#792)

    * wind factor bug corrected

    the wind factor wasn't applied to the env.wind_velocity properties

    * BUG: StochasticModel visualize attributes of a uniform distribution

    It showed the nominal and the standard deviation values and it doesn't make sense in a uniform distribution. In a np.random.uniform the 'nominal value' is the lower bound of the distribution, and the 'standard deviation' value is the upper bound. Now, a new condition has been added for the uniform distributions where the mean and semi range are calculated and showed. This way the visualize_attribute function will show the whole range where the random values are uniformly taken in

    * variable names corrections

    * Corrections requested by the pylint test

    * ENH: more intuitive uniform distribution display in StochasticModel

    Co-authored-by: MateusStano <[email protected]>

    * ENH: Eccentricities added to the StochasticRocket class

    A bug has been corrected in Flight class and an enhancement has been performed in the Rocket class as well

    * BUG: thrust eccentricity bug corrected

    eccentricity_y was defined by x coordinate and eccentricity_x was defined by y coordinate

    * BUG: Undo some Rocket class changes

    * ENH: add eccentricities to StochasticRocket

    * BUG: fix MonteCarlo eccentricity inputs

    * ENH: pylint and ruff recommended changes

    * TST: fix tests with eccentricity

    ---------

    Co-authored-by: Gui-FernandesBR <[email protected]>

commit 7348053
Author: Kevin Alcañiz <[email protected]>
Date:   Sun Mar 23 13:49:35 2025 +0100

    BUG: fix the wind velocity factors usage and better visualization of uniform distributions in Stochastic Classes (#783)

    * wind factor bug corrected

    the wind factor wasn't applied to the env.wind_velocity properties

    * BUG: StochasticModel visualize attributes of a uniform distribution

    It showed the nominal and the standard deviation values and it doesn't make sense in a uniform distribution. In a np.random.uniform the 'nominal value' is the lower bound of the distribution, and the 'standard deviation' value is the upper bound. Now, a new condition has been added for the uniform distributions where the mean and semi range are calculated and showed. This way the visualize_attribute function will show the whole range where the random values are uniformly taken in

    * variable names corrections

    * Corrections requested by the pylint test

    * ENH: more intuitive uniform distribution display in StochasticModel

    Co-authored-by: MateusStano <[email protected]>

    ---------

    Co-authored-by: MateusStano <[email protected]>

commit d2f89ba
Author: Leonardo Rosa <[email protected]>
Date:   Fri Mar 21 18:57:49 2025 -0300

    DEV: add requirements-tests.txt on make install target (#791)

    * DEV: adds 'pip install -r requirements-tests.txt' recipe to 'make install' target on Makefile

    Co-authored-by: Gui-FernandesBR <[email protected]>

commit 91ac567
Author: Leonardo Rosa <[email protected]>
Date:   Fri Mar 21 18:53:53 2025 -0300

    BUG: fixes get_instance_attributes for Flight objects containing a Rocket object without rail buttons (#786)

    * DOC: fixed a typo in funcify_method() description

    * TST: created test for get_instante_attributes() with flight without rail buttons

    * BUG: fixed __calculate_rail_button_forces() by assigning a Function(0) to null_force instead of an empty array

    * DEV: updates CHANGELOG

commit 9407470
Author: Leonard <[email protected]>
Date:   Wed Mar 19 16:01:59 2025 +0100

    BUG: fixed AGL altitude in _FlightPrints.events_registered (#788)

    * BUG: fixed AGL altitude in _FlightPrints.events_registered

    * updeted CHANGELOG
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: Closed
Development

Successfully merging this pull request may close these issues.

BUG: Flight without RailButtons crash on get_instance_attributes
3 participants