8000 BUG: fix the wind velocity factors usage and better visualization of uniform distributions in Stochastic Classes by kevin-alcaniz · Pull Request #783 · RocketPy-Team/RocketPy · GitHub
[go: up one dir, main page]

Skip to content

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

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

Merged
merged 8 commits into from
Mar 23, 2025
1 change: 1 addition & 0 deletions rocketpy/stochastic/stochastic_environment.py
Original file line number Diff line number Diff line change
Expand Up @@ -184,5 +184,6 @@ def create_object(self):
# get original attribute value and multiply by factor
attribute_name = f"_{key.replace('_factor', '')}"
value = getattr(self, attribute_name) * value
key = f"{key.replace('_factor', '')}"
setattr(self.obj, key, value)
return self.obj
18 changes: 13 additions & 5 deletions rocketpy/stochastic/stochastic_model.py
Original file line number Diff line number Diff line change
Expand Up @@ -514,11 +514,19 @@
)
elif isinstance(value, tuple):
nominal_value, std_dev, dist_func = value
return (
f"\t{attr.ljust(max_str_length)} "
f"{nominal_value:.5f} ± "
f"{std_dev:.5f} ({dist_func.__name__})"
)
if callable(dist_func) and dist_func.__name__ == "uniform":
lower_bound = nominal_value
upper_bound = std_dev
return (

Check warning on line 520 in rocketpy/stochastic/stochastic_model.py

View check run for this annotation

Codecov / codecov/patch

rocketpy/stochastic/stochastic_model.py#L518-L520

Added lines #L518 - L520 were not covered by tests
f"\t{attr.ljust(max_str_length)} "
f"{lower_bound:.5f}, {upper_bound:.5f} ({dist_func.__name__})"
)
else:
return (
f"\t{attr.ljust(max_str_length)} "
f"{nominal_value:.5f} ± "
f"{std_dev:.5f} ({dist_func.__name__})"
)
return None

attributes = {k: v for k, v in self.__dict__.items() if not k.startswith("_")}
Expand Down
0