Skip to content

Allow empty string "" in columns to be overridden with default values in priors #384

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

Open
wants to merge 1 commit into
base: develop
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion petab/v1/priors.py
Original file line number Diff line number Diff line change
Expand Up @@ -278,7 +278,10 @@ def from_par_dict(
:return: A distribution object.
"""
dist_type = d.get(f"{type_}PriorType", C.PARAMETER_SCALE_UNIFORM)
Copy link
Member

Choose a reason for hiding this comment

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

IMO the default can come first, and the override can then be stated in the "positive" case, instead of nots. This is how it's mostly done elsewhere in the code as I recall.

But fine as is too.

This suggestion is for the changed code too, but github wouldn't let me edit the block.

Suggested change
dist_type = d.get(f"{type_}PriorType", C.PARAMETER_SCALE_UNIFORM)
dist_type = C.PARAMETER_SCALE_UNIFORM
if _table_dist_type := d.get(f"{type_}PriorType") and (isinstance(_table_dist_type, str) or not np.isnan(_table_dist_type)):
dist_type = _table_dist_type

if not isinstance(dist_type, str) and np.isnan(dist_type):
if (
(not isinstance(dist_type, str) and np.isnan(dist_type))
or not dist_type
):
dist_type = C.PARAMETER_SCALE_UNIFORM

pscale = d.get(C.PARAMETER_SCALE, C.LIN)
Expand Down
Loading