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

Improve error message for initial_params #772

Merged
merged 7 commits into from
Jan 7, 2025

Conversation

sunxd3
Copy link
Member

@sunxd3 sunxd3 commented Jan 7, 2025

Address #774 partially.

This only improve the error message, and does not add support for using OrderedDIct for initializing.

The error messages are:

  • for Vector{Any}
ArgumentError: `initial_params` must be a vector of type `Union{Real,Missing}`. If `initial_params` is a vector of vectors, please flatten it first using `vcat`.
  • for NamedTuple (keys of NamedTuple subsumes some variables in the model, but itself not in the model)
ArgumentError: Variable X not found in model, but it subsumes a variable (X[1]) in the model. Please use AbstractVector for initial_params instead of NamedTuple.

@sunxd3 sunxd3 requested a review from penelopeysm January 7, 2025 11:18
Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
@yebai yebai requested a review from willtebbutt January 7, 2025 11:28
@yebai
Copy link
Member

yebai commented Jan 7, 2025

Cc @willtebbutt, who has a lot of experience with good error messages and robust user interfaces.

Copy link

codecov bot commented Jan 7, 2025

Codecov Report

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

Project coverage is 86.13%. Comparing base (3d18cfc) to head (d267fc6).
Report is 1 commits behind head on master.

Files with missing lines Patch % Lines
src/sampler.jl 91.66% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##           master     #772      +/-   ##
==========================================
+ Coverage   86.12%   86.13%   +0.01%     
==========================================
  Files          36       36              
  Lines        4324     4336      +12     
==========================================
+ Hits         3724     3735      +11     
- Misses        600      601       +1     

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

@coveralls
Copy link

Pull Request Test Coverage Report for Build 12650555390

Details

  • 0 of 11 (0.0%) changed or added relevant lines in 1 file are covered.
  • 1190 unchanged lines in 25 files lost coverage.
  • Overall coverage decreased (-29.1%) to 57.149%

Changes Missing Coverage Covered Lines Changed/Added Lines %
src/sampler.jl 0 11 0.0%
Files with Coverage Reduction New Missed Lines %
src/DynamicPPL.jl 1 90.91%
src/submodel_macro.jl 2 82.35%
src/selector.jl 3 42.86%
src/test_utils/varinfo.jl 5 78.26%
src/test_utils/model_interface.jl 5 22.22%
src/distribution_wrappers.jl 6 34.29%
src/logdensityfunction.jl 6 61.76%
src/model_utils.jl 7 7.14%
src/model.jl 12 80.87%
src/test_utils/contexts.jl 12 58.14%
Totals Coverage Status
Change from base Build 12602182198: -29.1%
Covered Lines: 2470
Relevant Lines: 4322

💛 - Coveralls

@coveralls
Copy link

coveralls commented Jan 7, 2025

Pull Request Test Coverage Report for Build 12656520821

Details

  • 11 of 12 (91.67%) changed or added relevant lines in 1 file are covered.
  • 29 unchanged lines in 3 files lost coverage.
  • Overall coverage increased (+0.02%) to 86.219%

Changes Missing Coverage Covered Lines Changed/Added Lines %
src/sampler.jl 11 12 91.67%
Files with Coverage Reduction New Missed Lines %
src/varinfo.jl 3 84.92%
src/model.jl 5 77.39%
src/threadsafe.jl 21 46.61%
Totals Coverage Status
Change from base Build 12602182198: 0.02%
Covered Lines: 3735
Relevant Lines: 4332

💛 - Coveralls

src/sampler.jl Show resolved Hide resolved
src/sampler.jl Outdated Show resolved Hide resolved
Copy link
Member

@willtebbutt willtebbutt left a comment

Choose a reason for hiding this comment

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

LGTM

Copy link
Member

@penelopeysm penelopeysm 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 this PR! It's great that people will get a clearer error message especially on this awkward bit with subsumed varnames :)

Just suggesting some very minor changes:

Project.toml Outdated Show resolved Hide resolved
src/sampler.jl Outdated Show resolved Hide resolved
Co-authored-by: Penelope Yong <[email protected]>
Project.toml Outdated Show resolved Hide resolved
Copy link
Member

@penelopeysm penelopeysm left a comment

Choose a reason for hiding this comment

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

feel free to add to merge queue 😄

@sunxd3 sunxd3 enabled auto-merge January 7, 2025 17:48
@sunxd3 sunxd3 added this pull request to the merge queue Jan 7, 2025
Merged via the queue into master with commit 003ff2f Jan 7, 2025
21 checks passed
@sunxd3 sunxd3 deleted the sunxd/improve_init_params_error_message branch January 7, 2025 18:55
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.

5 participants