An invisible character beside a setOption line (a non-breaking space, for example) makes BNG2.pl skip the line while PyBNF applies it
Les mainteneurs répondent en général sous 1 jour
Personne n'a encore pris cette issue.
Évaluation
- Difficulté
- 4/5
- Temps estimé
- 3-5 jours
- Accessibilité débutants
- 62/100
Piste de recherche
Start with BNGLModel.__init__ in pybnf/pset.py, where the scanner uses splitlines() and strip(). Compare its line handling with the BNG2.pl behavior described in the issue, then add regression coverage for invisible characters around setOption lines. Done means PyBNF rejects the file at load with the line and character identified, rather than silently applying an option that BNG2.pl ignores.
Rédigé par le modèle d'indexation à partir du texte de l'issue.
Description
What the user writes. A setOption(...) line on its own after end model, where the line begins or ends with a non-breaking space. The character arrives when text is pasted from a web page, a PDF or a word processor. An editor shows it as an ordinary space, or as nothing at the end of a line.
What happens. BNG2.pl does not recognise the line. It prints WARNING: Unidentified input! Will not attempt to execute as Perl. and carries on without the option. PyBNF removes the character when it reads the line, recognises the directive, and writes a clean copy into the model text it simulates. So a PyBNF fit applies the option, and BNG2.pl on the user's own file does not. PyBNF reports nothing, and the edition-2 actions check (#969) accepts the line.
The PEtab export writes the line as it stands, with the character still in it. So the exported model, run by BNG2.pl, also lacks the option that the fit used.
Consequence. In the example below the observable differs by a factor of two between the fit and the file, and between the fit and its own PEtab export.
What should happen. PyBNF should refuse the file at load and name the line and the character. For example: "line 18 of dimer.bngl has a non-breaking space (U+00A0) before setOption; BNG2.pl does not read this line as a directive. Delete the character." More generally, when PyBNF decides what a line is, it should count as blank space only what BNG2.pl counts.
Example
The dimer model from #981: Molecules D A(a!1).A(a!1), 50 dimers decaying at k = 0.5. CountAll reports 100 e^(-kt), and CountUnique reports 50 e^(-kt). After end model:
<line under test>
begin actions
generate_network({overwrite=>1})
simulate({method=>"ode",t_end=>4,n_steps=>4,suffix=>"tc"})
end actions
Each file was run with BNG2.pl 2.9.3, and so was the text PyBNF writes for it (BNGLModel.model_text(), with k fitted and set to 0.5):
| Line under test | BNG2.pl on the file, D at t = 0 | BNG2.pl on PyBNF's text, D at t = 0 |
|---|---|---|
setOption("MoleculesObservables","CountUnique") |
50 | 50 |
| the same, with U+00A0 before it | 100, with the warning | 50 |
| the same, with U+00A0 after it | 100, with the warning | 50 |
the same, ending ; then U+00A0 |
100, with the warning | 50 |
| the same, with U+001C (a control character) after it | 100, with the warning | 50 |
In all four cases PyBNF's text holds the line with the character removed.
Edition 2: with the simulate line taken out, require_no_protocol_actions accepts all four files. export_job on the U+00A0-before case writes \xa0setOption("MoleculesObservables","CountUnique") into the exported dimer.bngl.
Not checked
- Other characters that Python's
str.strip()removes and Perl's reader does not, such as U+2028, U+3000 and U+0085. - The same characters elsewhere in a model file: in the parameters, the rules, or beside other actions.
- Inside a
begin actionsblock, BNG2.pl aborts on such a line ("Not a CODE reference"). That is loud. I did not check what PyBNF does with that file.
Where
BNGLModel.__init__ in pybnf/pset.py. The scanner splits the file with str.splitlines() and strips each line with str.strip(). Both follow Python's Unicode definition of blank space and line breaks. BNG2.pl's reader matches bytes, and to it these characters are part of the line.
Found by the second review of #975. The behaviour is older than that PR.
- Langage dominant
- Python
- Étoiles
- 25
- Forks
- 25
- Merge moyen
- 4 h 5 min
- PR mergées (30 j)
- 10
Préparer son environnement
- Fournit un Dockerfile ou un fichier Docker Compose
- Aucun modèle de pull request
- Lire le guide de contribution
Par où commencer
- Lisez l'issue en entier, puis le guide de contribution du projet.
- Signalez en commentaire que vous la prenez — cela évite que deux personnes fassent le même travail.
- Forkez le dépôt et travaillez sur une branche.
- Ouvrez une pull request qui référence le numéro de l'issue.
Autres issues de lanl/PyBNF
-
bug
Difficulté 2/5 1-3 heures Accessibilité débutants 76/100
Les mainteneurs répondent en général sous 1 jour
-
bug minor
Difficulté 2/5 1-3 heures Accessibilité débutants 76/100
Les mainteneurs répondent en général sous 1 jour
-
bug tech debt
Difficulté 2/5 1-3 heures Accessibilité débutants 82/100
Les mainteneurs répondent en général sous 1 jour
-
bug minor
Difficulté 2/5 1-3 heures Accessibilité débutants 85/100
Les mainteneurs répondent en général sous 1 jour
-
bug silent-incorrectness
Difficulté 2/5 1-3 heures Accessibilité débutants 76/100
Les mainteneurs répondent en général sous 1 jour
Toutes les issues de lanl/PyBNF
Issues similaires
-
Difficulté 2/5 1-3 heures Accessibilité débutants 74/100
software-mansion-labs/Diplomat#20 ·
Les mainteneurs répondent en général sous 1 jour
-
[Windows] Hidden title bar: a maximized window restored from minimized on a secondary monitor gets the primary monitor's work area as its client areaPeut-être pris @lijy91 l’a pris aujourd’hui. Ouverte
Difficulté 2/5 1-3 heures Accessibilité débutants 67/100
libnativeapi/nativeapi#53 · 1 réaction ·
Les mainteneurs répondent en général sous 1 jour
-
View Counts discarded due to field name mismatchPeut-être pris @rsiva0400 l’a pris aujourd’hui. Ouvertesite-bug triage
Difficulté 2/5 1-3 heures Accessibilité débutants 72/100
Les mainteneurs répondent en général sous 1 jour
-
Model version publishes the new UK firm entity as a personPeut-être pris @vahid-ahmadi l’a pris aujourd’hui. Ouverte
Difficulté 2/5 1-3 heures Accessibilité débutants 72/100
PolicyEngine/policyengine.py#764 ·
Les mainteneurs répondent en général sous 1 jour
-
Difficulté 2/5 1-3 heures Accessibilité débutants 70/100
spcl/HPCAgent-Bench#264 ·
Les mainteneurs répondent en général sous 1 jour