Skip to content

Replaced CollectionBase with EasyList #304 - #305

Open
rozyczko wants to merge 2 commits into
sampler-engine-structure-280from
easylist-on-multifitter
Open

Replaced CollectionBase with EasyList #304#305
rozyczko wants to merge 2 commits into
sampler-engine-structure-280from
easylist-on-multifitter

Conversation

@rozyczko

@rozyczko rozyczko commented Sep 4, 2026

Copy link
Copy Markdown
Member

This pull request replaces the deprecated CollectionBase container with the new EasyList for aggregating fit objects in MultiFitter.

@rozyczko rozyczko added [scope] maintenance Code/tooling cleanup, no feature or bugfix (major.minor.PATCH) [priority] high Should be prioritized soon [area] base classes Changes to or creation of new base classes labels Sep 4, 2026
@codecov

codecov Bot commented Sep 4, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 83.66%. Comparing base (693e11c) to head (2e9d9c2).
⚠️ Report is 5 commits behind head on sampler-engine-structure-280.

Additional details and impacted files

Impacted file tree graph

@@                       Coverage Diff                        @@
##           sampler-engine-structure-280     #305      +/-   ##
================================================================
- Coverage                         83.82%   83.66%   -0.17%     
================================================================
  Files                                68       68              
  Lines                              5348     5271      -77     
================================================================
- Hits                               4483     4410      -73     
+ Misses                              865      861       -4     
Flag Coverage Δ
unittests 83.66% <100.00%> (-0.17%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

Files with missing lines Coverage Δ
src/easyscience/fitting/fitter.py 91.33% <ø> (-0.20%) ⬇️
src/easyscience/fitting/multi_fitter.py 98.70% <100.00%> (+0.10%) ⬆️

... and 13 files with indirect coverage changes

@damskii9992 damskii9992 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Small comments only, otherwise it looks good to me.

Comment on lines 28 to 29
fit_objects: list | None = None,
fit_functions: list[Callable] | None = None,

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Should this be typehinted as sequence, since we support any sequence?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Yes. And more. We have to properly initialize fit_objects and fit_functions, otherwise the code will crash on the subsequent indexing... oops. Fixed.

Comment thread src/easyscience/fitting/fitter.py Outdated
Comment on lines +214 to +216
For a ``MultiFitter`` this is not one of the supplied fit
objects but a read-only, indexable and iterable aggregate.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Why a description for the MultiFitter in the Fitter?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

fixed

Comment thread tests/unit/fitting/test_multi_fitter.py Outdated
Comment on lines +233 to +244
def test_no_collection_base_deprecation_warning(self, caplog):
"""Building a MultiFitter must not warn about CollectionBase.

The assertion is on message content rather than on the logger,
because other deprecated classes warn on the very same logger.
"""
fit_objects = [Line(1.0, 0.5), Line(2.0, 1.5)]

with caplog.at_level(logging.WARNING, logger='easyscience'):
MultiFitter(fit_objects, fit_objects)

assert not [r for r in caplog.records if 'CollectionBase is deprecated' in r.message]

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Redundant test.

Comment thread tests/unit/fitting/test_multi_fitter.py Outdated
Comment on lines +251 to +264
def test_fit_objects_are_not_retyped(self):
"""The container must not reclassify the caller's fit objects.

The old CollectionBase dummy re-typed every fit object as
'created_internal', hiding the caller's own objects from the
map's 'created' set.
"""
fit_objects = [Line(1.0, 0.5), Line(2.0, 1.5)]
types_before = [global_object.map.find_type(obj) for obj in fit_objects]

MultiFitter(fit_objects, fit_objects)

assert [global_object.map.find_type(obj) for obj in fit_objects] == types_before
assert all('created_internal' not in types for types in types_before)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

This is testing the global_object map? The one we want to get rid of? I'd remove this test.

Comment thread tests/unit/fitting/test_multi_fitter.py Outdated
Comment on lines +318 to +323
def test_rejects_legacy_obj_base_fit_objects(self):
"""Support for the deprecated ObjBase hierarchy was dropped."""
legacy = [LegacyLine(1.0, 0.5), LegacyLine(2.0, 1.5)]

with pytest.raises(TypeError, match='Items must be one of'):
MultiFitter(legacy, legacy)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Another test for deprecated content.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

[area] base classes Changes to or creation of new base classes [priority] high Should be prioritized soon [scope] maintenance Code/tooling cleanup, no feature or bugfix (major.minor.PATCH)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants