Skip to content

add idx boolean selection for member and leadtime#1183

Merged
peanutfun merged 4 commits intoforecast-classfrom
idx_member_leadtime
Dec 9, 2025
Merged

add idx boolean selection for member and leadtime#1183
peanutfun merged 4 commits intoforecast-classfrom
idx_member_leadtime

Conversation

@elianekobler
Copy link
Collaborator

@elianekobler elianekobler commented Dec 9, 2025

Changes proposed in this PR:

  • two methods in forecast base class to select member and lead time with boolean indexing
  • two tests

This PR fixes #1159

PR Author Checklist

PR Reviewer Checklist

@elianekobler elianekobler removed the request for review from emanuel-schmid December 9, 2025 13:53
Parameters
----------
member : np.ndarray
Forecast ensemble members, given as integers.
Copy link
Member

Choose a reason for hiding this comment

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

That is not very clear. How about

Suggested change
Forecast ensemble members, given as integers.
Index of the forecast members in the forecast.member array.

Copy link
Member

Choose a reason for hiding this comment

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

See 12bf2b6


def test_idx_member():
"""Test idx_member method of Forecast class."""
forecast = Forecast(member=np.array([1, 2, 3, 4]))
Copy link
Member

@chahank chahank Dec 9, 2025

Choose a reason for hiding this comment

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

What happens if I put forecast = Forecast(member=np.array([1, 1, 3, -5, '6'])) ?

Copy link
Member

Choose a reason for hiding this comment

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

Works completely fine. The isin compares element-wise. Is this really necessary to test here?

Copy link
Member

Choose a reason for hiding this comment

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

Added a test for unusual data

@peanutfun peanutfun merged commit 9d6fef9 into forecast-class Dec 9, 2025
4 of 5 checks passed
@emanuel-schmid emanuel-schmid deleted the idx_member_leadtime branch December 11, 2025 08:43
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.

3 participants