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 size check in Model::setStateIsNonNegative #2332

Merged
merged 1 commit into from
Mar 4, 2024

Conversation

dweindl
Copy link
Member

@dweindl dweindl commented Feb 28, 2024

Previously, the wrong array was checked 🙈:

amici_model.setAllStatesNonNegative() # works as expected
amici_model.setStateIsNonNegative([]) # should fail
amici_model.setAllStatesNonNegative() # should work, but fails

Traceback (most recent call last):
  File "<ipython-input-22-d7056e8e4e3f>", line 1, in <module>
    amici_model.setAllStatesNonNegative()
  File "python/sdist/amici/amici.py", line 2243, in setAllStatesNonNegative
    return _amici.ModelPtr_setAllStatesNonNegative(self)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
RuntimeError: Dimension of input stateIsNonNegative (0) does not agree with number of state variables (2)

Previously, the wrong array was checked :seenoevil::

```python
amici_model.setAllStatesNonNegative()
amici_model.setStateIsNonNegative([])
amici_model.setAllStatesNonNegative()

Traceback (most recent call last):
  File "<ipython-input-22-d7056e8e4e3f>", line 1, in <module>
    amici_model.setAllStatesNonNegative()
  File "python/sdist/amici/amici.py", line 2243, in setAllStatesNonNegative
    return _amici.ModelPtr_setAllStatesNonNegative(self)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
RuntimeError: Dimension of input stateIsNonNegative (0) does not agree with number of state variables (2)
```
@dweindl dweindl requested a review from a team as a code owner February 28, 2024 18:30
Copy link

codecov bot commented Feb 28, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 77.88%. Comparing base (4782cad) to head (28352d9).

Additional details and impacted files

Impacted file tree graph

@@           Coverage Diff            @@
##           develop    #2332   +/-   ##
========================================
  Coverage    77.88%   77.88%           
========================================
  Files          324      324           
  Lines        20680    20680           
  Branches      1440     1440           
========================================
  Hits         16107    16107           
  Misses        4570     4570           
  Partials         3        3           
Flag Coverage Δ
cpp 73.67% <100.00%> (ø)
cpp_python 34.36% <0.00%> (ø)
petab 36.90% <0.00%> (ø)
python 72.48% <0.00%> (ø)
sbmlsuite ?

Flags with carried forward coverage won't be shown. Click here to find out more.

Files Coverage Δ
src/model.cpp 86.24% <100.00%> (ø)

@dweindl dweindl merged commit 4a065e6 into AMICI-dev:develop Mar 4, 2024
20 checks passed
@dweindl dweindl deleted the fix_state_nonneg branch March 4, 2024 06:46
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.

2 participants