Skip to content

ENH: create custom ensembles without a file and without a date - #1231

Merged
MateusStano merged 6 commits into
developfrom
enh/custom-ensemble-without-file
Nov 23, 2026
Merged

MateusStano merged 6 commits into
developfrom
enh/custom-ensemble-without-file

Conversation

@MateusStano

Copy link
Copy Markdown
Member

Related to #1209 and #1141. This is the #1141 item of the v1.14.0 checklist.

Pull request type

  • Code changes (bugfix, features)
  • ReadMe, Docs and GitHub updates

Checklist

Current behavior

Environment.create_ensemble (new in this release, from #1141) works, but:

  1. The file it writes only loads for the date and hour of the Environment that created it.
  2. It raises an error if the Environment has no date, even though the profiles have none.
  3. It always writes a file (custom_ensemble.nc in the current folder), so running the same cell twice raises FileExistsError.
  4. Below the lowest point of a profile the values are held constant, and the docs do not say so.

New behavior

  1. A saved custom ensemble loads on an Environment with any launch date, or with none. Its dataset already carried source = "RocketPy Environment.create_ensemble"; the loader now reads that and skips the date check. An ensemble file from anywhere else still checks the launch date.
  2. create_ensemble no longer needs a date.
  3. No file by default. create_ensemble(profiles) builds the ensemble in a netCDF dataset that only exists in memory and loads it through the same code as a file. Pass file_name to also save it; the method returns the path, or None when nothing was saved.
  4. The docs and the docstring say to start the profiles at or below ground level. The docs example started 100 m above its launch site, so it was lowered.

Also:

  • set_date and set_location leave an ensemble made from profiles as it is. Before, they tried to load it again from its file.
  • env.info() does not print a time period for these ensembles.

Breaking change

  • No

create_ensemble was never released. Its file_name default changes from "custom_ensemble.nc" to None.

Additional information

Found while testing and not fixed here, since it also happens on develop for any ensemble: select_ensemble_member fails on an Environment that was saved and loaded again (TypeError: list indices must be integers or slices, not tuple).

🤖 Generated with Claude Code

MateusStano and others added 2 commits November 20, 2026 14:11
- `Environment.create_ensemble` keeps the ensemble in memory by default.
  A file is only written when `file_name` is given.
- An ensemble created from profiles has no date: the Environment does not
  need one, and a saved ensemble loads for any launch date. Ensemble files
  from elsewhere still check the launch date.
- `set_date` and `set_location` leave such an ensemble as it is, and the
  prints skip its time period.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
@MateusStano
MateusStano requested a review from a team as a code owner November 20, 2026 17:11
@codecov

codecov Bot commented Nov 20, 2026 •

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 93.22034% with 4 lines in your changes missing coverage. Please review.
✅ Project coverage is 86.74%. Comparing base (9bf63a0) to head (bc52713).
⚠️ Report is 22 commits behind head on develop.

Files with missing lines Patch % Lines
rocketpy/environment/environment.py 92.00% 4 Missing ⚠️
Additional details and impacted files
@@             Coverage Diff             @@
##           develop    #1231      +/-   ##
===========================================
+ Coverage    86.55%   86.74%   +0.19%     
===========================================
  Files          131      131              
  Lines        18248    18321      +73     
===========================================
+ Hits         15794    15892      +98     
+ Misses        2454     2429      -25     

☔ View full report in Codecov by Harness.
📢 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 Gui-FernandesBR left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Found a few issues; details inline. The first three (in-memory name collision, file left open, docs note) are worth fixing before merge, the rest are small.

Comment thread rocketpy/environment/environment.py Resolved
Comment thread rocketpy/environment/environment.py Resolved
Comment thread rocketpy/environment/environment.py Resolved
Comment thread rocketpy/environment/environment.py Resolved
Comment thread rocketpy/prints/environment_prints.py Resolved
MateusStano and others added 4 commits November 21, 2026 21:33
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Also add docstrings and Arrange/Act/Assert comments to the profile
ensemble tests.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@MateusStano
MateusStano merged commit 447ed79 into develop Nov 23, 2026
9 checks passed
@MateusStano
MateusStano deleted the enh/custom-ensemble-without-file branch November 23, 2026 12:23
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants