Skip to content

Conversation

@dweindl
Copy link
Member

@dweindl dweindl commented Jul 24, 2025

DRY

Introduce BaseTable to implement common functionality of {Observable,Parameter,...}Table.

@codecov-commenter
Copy link

codecov-commenter commented Jul 24, 2025

Codecov Report

❌ Patch coverage is 75.51020% with 24 lines in your changes missing coverage. Please review.
✅ Project coverage is 74.40%. Comparing base (8977adb) to head (59e7b34).

Files with missing lines Patch % Lines
petab/v2/core.py 75.51% 23 Missing and 1 partial ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main     #417      +/-   ##
==========================================
+ Coverage   73.98%   74.40%   +0.41%     
==========================================
  Files          61       61              
  Lines        6762     6692      -70     
  Branches     1197     1182      -15     
==========================================
- Hits         5003     4979      -24     
+ Misses       1296     1256      -40     
+ Partials      463      457       -6     

☔ View full report in Codecov by Sentry.
📢 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.

@dweindl dweindl changed the title Refactor v2.*Tables Refactor `v2.*Tables Jul 24, 2025
@dweindl dweindl changed the title Refactor `v2.*Tables Refactor v2.*Tables Jul 24, 2025
@dweindl dweindl marked this pull request as ready for review July 24, 2025 10:11
@dweindl dweindl requested a review from a team as a code owner July 24, 2025 10:11
@dweindl dweindl force-pushed the refactor_tables branch 2 times, most recently from e01dfe1 to 2ff200f Compare July 24, 2025 12:51
@dweindl dweindl self-assigned this Jul 24, 2025
Copy link
Collaborator

@m-philipps m-philipps left a comment

Choose a reason for hiding this comment

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

Looks great, feel free to ignore the comments, which are probably more relevant at the cosmetic stage.

)
return self.__class__(elements=self.elements + [other])

def __iadd__(self, other: T) -> BaseTable[T]:
Copy link
Collaborator

Choose a reason for hiding this comment

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

Why return self if this is inplace?

Copy link
Member Author

Choose a reason for hiding this comment

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

https://docs.python.org/3/reference/datamodel.html#object.__iadd__:

object.__iadd__ [...] These methods should attempt to do the operation in-place (modifying self) and return the result

]

return cls(observables=observables)
return cls(observables)
Copy link
Collaborator

Choose a reason for hiding this comment

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

This is using a positional arg instead of elements=observables unlike e.g. in the BaseTable class

Copy link
Member Author

Choose a reason for hiding this comment

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

Yes, I don't see a problem there.

self.mappings.append(other)
return self

def __getitem__(self, petab_id: str) -> Mapping:
Copy link
Collaborator

Choose a reason for hiding this comment

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

Is this still needed with having the BaseModel function?

Copy link
Member Author

Choose a reason for hiding this comment

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

Yes, because Mapping has no id attribute. There we currently select based on petab_id.

@dweindl dweindl merged commit 5e26769 into PEtab-dev:main Jul 29, 2025
7 checks passed
@dweindl dweindl deleted the refactor_tables branch July 29, 2025 05:21
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