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 get_required_parameters_for_parameter_table #340

Merged
merged 1 commit into from
Dec 11, 2024

Conversation

dweindl
Copy link
Member

@dweindl dweindl commented Dec 11, 2024

The previous check did not make any sense. See discussion at #339 (comment).

Also fix a missing import.

The previous check did not make any sense. See discussion at PEtab-dev#339 (comment).
@dweindl dweindl requested a review from a team as a code owner December 11, 2024 19:17
@codecov-commenter
Copy link

Codecov Report

Attention: Patch coverage is 75.00000% with 1 line in your changes missing coverage. Please review.

Project coverage is 74.65%. Comparing base (8456635) to head (c4f13ab).

Files with missing lines Patch % Lines
petab/v2/problem.py 50.00% 1 Missing ⚠️
Additional details and impacted files
@@           Coverage Diff            @@
##           develop     #340   +/-   ##
========================================
  Coverage    74.65%   74.65%           
========================================
  Files           54       54           
  Lines         5381     5381           
  Branches       923      923           
========================================
  Hits          4017     4017           
  Misses        1012     1012           
  Partials       352      352           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

Copy link
Member

@dilpath dilpath left a comment

Choose a reason for hiding this comment

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

Thanks!

# for ALL conditions
for p in condition_df.columns[~condition_df.isnull().any()]:
# parameters that are overridden via the condition table are not allowed
for p in condition_df.columns:
Copy link
Member

Choose a reason for hiding this comment

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

Instead of try-except, could do one of these, but fine as is

for p in set(condition_df.columns).intersection(parameter_ids):
    del parameter_ids[p]

for p in condition_df.columns:
    if p in parameter_ids:
        del parameter_ids[p]

Copy link
Member Author

Choose a reason for hiding this comment

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

Right, but then one has to look up each element twice.

~problem.condition_df.isnull().any()
]:
# parameters that are overridden via the condition table are not allowed
for p in problem.condition_df.columns:
Copy link
Member

Choose a reason for hiding this comment

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

Since parameter IDs is now a set, can change try-except/loop to

parameter_ids -= set(condition_df.columns)

Copy link
Member Author

Choose a reason for hiding this comment

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

Right, but parameter_ids is still an OrderedDict (we wanted to preserve order here). Only the returned DictKeyView (or similar) acts like a set.

Copy link
Member Author

Choose a reason for hiding this comment

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

Since it's right before returning, it could be done just on the keys, but then future modifications might easily mess up the ordering. I'd leave it as is until Python has a proper OrderedSet.

Copy link
Member

Choose a reason for hiding this comment

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

Where does it become OrderedDict? In the v1 code it's initialized as an OrderedDict, but here as a set?

Copy link
Member Author

@dweindl dweindl Dec 11, 2024

Choose a reason for hiding this comment

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

You are right. I was in v1.
Not sure why I changed it to set there in the first place.

@dweindl dweindl self-assigned this Dec 11, 2024
@dweindl dweindl merged commit b83e345 into PEtab-dev:develop Dec 11, 2024
7 checks passed
@dweindl dweindl deleted the fix_req_pars branch December 11, 2024 20:14
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