Skip to content
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

Fix class instantiations #377

Merged
merged 10 commits into from
Dec 14, 2024
Merged

Fix class instantiations #377

merged 10 commits into from
Dec 14, 2024

Conversation

BalzaniEdoardo
Copy link
Collaborator

Some functions (like np.split and others) accidentally dropped metadata. The issue was caused by the way the output TsdFrame was constructed by calling __class__ without explicitly routing the metadata of the original object.

Here I added a new abstract method of _Base named _define_instance for now, that should make sure that the appropriate properties are passed down to the newly defined object.

The method allow overwriting any parameter by passing new kwargs, if a kwarg is not passed, the parameter is grabbed from the attributes of self. I replaced all __class__(...) with _define_instance(...) everywhere in the code.

Testing

  • _define_instance: test that it behaves as expected for all time_series.
  • Class re-instantiaiton logic: check that all classes instantiation pass through _define_instance instead of __class__ directly. The test iterates over all pynapple funcitons, _Base methods and _Base subclasses methods, making sure that __class__ is not called directly.

Copy link

codecov bot commented Dec 11, 2024

Codecov Report

Attention: Patch coverage is 87.30159% with 8 lines in your changes missing coverage. Please review.

Files with missing lines Patch % Lines
pynapple/core/base_class.py 84.00% 2 Missing and 2 partials ⚠️
pynapple/core/time_series.py 88.57% 2 Missing and 2 partials ⚠️
Files with missing lines Coverage Δ
pynapple/core/utils.py 84.09% <100.00%> (-0.18%) ⬇️
pynapple/process/filtering.py 94.44% <100.00%> (-0.16%) ⬇️
pynapple/core/base_class.py 97.60% <84.00%> (-1.51%) ⬇️
pynapple/core/time_series.py 89.77% <88.57%> (+0.21%) ⬆️

... and 2 files with indirect coverage changes

@gviejo gviejo merged commit 8d9db8b into dev Dec 14, 2024
15 checks passed
@gviejo gviejo deleted the fix_class_instantiations branch December 14, 2024 18:39
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