The .net loader reads a parameter named inf, nan or Infinity, used as a whole value, as that number
Maintainers usually reply within 1 day
Nobody has claimed this yet.
Assessment
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Newbie friendliness
- 62/100
Research direction
Start in src/net_file_loader.cpp at the parameter-value read (around line 290) and the species-concentration read (around line 411), where c_stod runs before the name lookup. Compare them with the statistical-factor reader for nan*kf (issue #803), which already rejects non-finite values. Done when a test loads the five names (inf, nan, Infinity, true, q) through BNG2.pl and matches its B(0), k2 and k3 values.
Written by the indexing model from the issue text.
Description
What happens
BNG2.pl accepts a parameter named inf, nan or Infinity. When a parameter's whole value, or a seed species' whole concentration, is that one name, BNG2.pl writes the name into the .net file as it is (k2 inf, 2 B() inf). Model.from_net reads the name as the number: infinity, or NaN. BNG2.pl reads it as the parameter. Nothing warns at load, and a finite value computed from it is wrong with no error (below).
Checked on main ba094bb3 (bngsim 0.17.2), with BNG2.pl 2.9.3:
begin parameters
inf 5
k2 inf
k3 2*inf
end parameters
begin seed species
A() 100
B() inf
end seed species
| name | BNG2.pl: B(0) | from_net: B(0) |
from_net: k2 |
from_net: k3 |
|---|---|---|---|---|
inf |
5 | inf | inf | 10 |
nan |
5 | nan | nan | 10 |
Infinity |
5 | inf | inf | 10 |
true |
5 | 5 | 5 | 10 |
q |
5 | 5 | 5 | 10 |
k3 2*inf is right because it is an expression. Only a value that is the name alone is read as a number.
Why
src/net_file_loader.cpp reads a parameter's value (line 290) and a species' concentration (line 411) with c_stod first, and treats the text as a name or an expression only when that fails or leaves text over. c_stod, like strtod, accepts inf, infinity and nan in any case, so those names never reach the name lookup.
Two other readers in the same file already refuse a non-finite number: a rate's statistical factor (nan*kf, issue #803) and an observable group entry's factor. These two sites have no such check.
Reach
Model.from_neton a.netfile that BNG2.pl wrote, andModel.from_bngl, which loads BNG2.pl's.net(from_bnglon the model above: B(0) = inf, k2 = inf).- A seed species or a rate constant that is such a parameter alone is inf or NaN. An ODE run refuses it, but the message names a non-finite initial condition, not the name.
- A finite value computed from such a parameter is wrong, and nothing is said. With
k2 infandk4 1/k2, bngsim reads k4 = 0. ForA() -> B() k4from A = 100, an ODE run to t = 1 gives B(1) = 0, where BNG2.pl gives 18.1269 (the same forInfinity; fornanthe run raises).
A possible fix
At both sites, read a value that is a declared parameter's name as that parameter, before trying it as a number. Alternatively, accept only a finite number there, and read anything else as a name, as the statistical-factor reader does. Either way, a test should load the table's five names through BNG2.pl and compare B(0), k2 and k3 with BNG2.pl's values.
- Dominant language
- Python
- Stars
- 3
- Forks
- 6
- Avg merge
- 1d 1h
- Merged PRs (30d)
- 295
Getting set up
- No Dockerfile or Docker Compose file
- Has a pull request template
- Read the contributing guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from lanl/bngsim
-
testing
Difficulty 1/5 Under an hour Newbie friendliness 65/100
Maintainers usually reply within 1 day
-
bug correctness concern
Difficulty 2/5 1-3 hours Newbie friendliness 84/100
Maintainers usually reply within 1 day
-
bug latent bug low priority
Difficulty 2/5 1-3 hours Newbie friendliness 82/100
Maintainers usually reply within 1 day
-
documentation
Difficulty 2/5 1-3 hours Newbie friendliness 77/100
Maintainers usually reply within 1 day
-
benchmarks/README: 'perl BNG2.pl model.bngl' runs the whole protocol, not just generate_networkOpendocumentation
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
Maintainers usually reply within 1 day
Similar issues
-
Difficulty 2/5 1-3 hours Newbie friendliness 74/100
software-mansion-labs/Diplomat#20 ·
Maintainers usually reply within 1 day
-
[Windows] Hidden title bar: a maximized window restored from minimized on a secondary monitor gets the primary monitor's work area as its client areaPossibly taken @lijy91 claimed this today. Open
Difficulty 2/5 1-3 hours Newbie friendliness 67/100
libnativeapi/nativeapi#53 · 1 reaction ·
Maintainers usually reply within 1 day
-
View Counts discarded due to field name mismatchPossibly taken @rsiva0400 claimed this today. Opensite-bug triage
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
Maintainers usually reply within 1 day
-
Model version publishes the new UK firm entity as a personPossibly taken @vahid-ahmadi claimed this today. Open
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
PolicyEngine/policyengine.py#764 ·
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 70/100
spcl/HPCAgent-Bench#264 ·
Maintainers usually reply within 1 day