Repository navigation
Conversation
…ders to_mutable() and to_immutable() handed the new collection the original's header, so converting units on one silently relabeled the other. Each collection now gets its own header copy. Immutable collections also inherited the in-place convert_to_unit, convert_to_ip and convert_to_si, which changed their values. These now raise AttributeError; to_unit, to_ip and to_si convert a mutable copy. HourlyContinuousCollectionImmutable.mutable_class returned DailyCollection, which broke get_aligned_collection(mutable=True). It now returns HourlyContinuousCollection. Tests cover all five collection types.
Collections now raise ValueError instead of AssertionError when empty, but the filter wrappers still caught AssertionError. A filter that matched nothing therefore surfaced the generic "must include at least one value" message instead of explaining which condition or range matched nothing. filter_by_conditional_statement, filter_by_range and filter_collections_by_statement now catch ValueError and raise it with their original messages.
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Four fixes to the data collection classes, each in its own commit, plus a metadata tweak.
1. Immutable collections could be mutated, and corrupted their source (
6015b88)to_mutable()andto_immutable()returned a collection that shared the original's header. Converting units on one relabelled the other. For example, a collection holding Celsius values ended up labelled Fahrenheit.convert_to_unit,convert_to_ipandconvert_to_si, which changed their values. These now raiseAttributeError.to_unit(),to_ip()andto_si()return a converted mutable copy, as the module docs describe.HourlyContinuousCollectionImmutable.mutable_classreturnedDailyCollection. This madeget_aligned_collection(mutable=True)raiseTypeError. It now returnsHourlyContinuousCollection.2. Validation survives
python -O(d917b7c)Collection value checks used
assert, which Python strips under-O. They now raiseTypeErrororValueErrorexplicitly.3. Descriptive errors for no-match filters (
0fdc323)After change 2, empty results raise
ValueError, but the three filter wrappers still caughtAssertionError. A filter that matched nothing therefore showed the generic "must include at least one value" message. The wrappers now catchValueErrorand keep their original messages.4. Metadata (
a82aa91)Adds the Python 3.13 classifier (is in scope in CI, so assume this is supported)
Behaviour changes to note
TypeError/ValueError, notAssertionError. Filters that match nothing raiseValueError.to_mutable()andto_immutable()give each collection its own header. Code that relied on the old sharing will no longer see header changes propagate. I found none in this repo, and I haven't checked downstream packages.AttributeError.Testing
convert_to_*blocking, theto_*copies,mutable_class/immutable_classwiring,get_aligned_collectionmutability, and the no-match filter messages.