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

added checks for inf & nan for state vars #249

Merged
merged 7 commits into from
Jan 6, 2023
Merged

Conversation

MauriceHendrix
Copy link
Contributor

@MauriceHendrix MauriceHendrix commented Dec 15, 2022

Description

This adds code to the C++ output th check for state variables becoming NON or INF.
As an example see chaste_codegen/data/tests/chaste_reference_models/Normal/non_dynamic_aslanidi_Purkinje_model_2009.cpp
The crucial bit is:

    void Cellaslanidi_Purkinje_model_2009FromCellML::VerifyStateVariables()
    {
        std::vector<double>& rY = rGetStateVariables();
        
        
        for (unsigned i=0; i < 30; i++)
        {
            if(std::isnan(rY[i])){
                EXCEPTION(DumpState("State variable " + this->rGetStateVariableNames()[i] + " is not a number"));
            }
            if(std::isinf(rY[i])){
                EXCEPTION(DumpState("State variable " + this->rGetStateVariableNames()[i] + " has become INFINITE"));
            }
        }
    }

This section also still contains the previous checks where they are required.

Motivation and Context

Types of changes

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to change)

Documentation checklist

  • I have updated all documentation in the code where necessary.
  • I have checked spelling in all (new) comments and documentation.
  • I have added a note to RELEASE.md if relevant (new feature, breaking change, or notable bug fix).
  • [-] I have updated version & citation.txt & citation.cff version.

Testing

  • Testing is done automatically and codecov shows test coverage
  • This cannot be tested automatically
    I have re-run the Codegen test pack in with current develop branch of Chaste and thiscodegen branch. That test passes without issue.

@codecov
Copy link

codecov bot commented Dec 15, 2022

Codecov Report

Merging #249 (689b65b) into master (3aa2b20) will not change coverage.
The diff coverage is 100.00%.

@@            Coverage Diff             @@
##            master      #249    +/-   ##
==========================================
  Coverage   100.00%   100.00%            
==========================================
  Files           26        30     +4     
  Lines         1522      1780   +258     
==========================================
+ Hits          1522      1780   +258     
Impacted Files Coverage Δ
chaste_codegen/__init__.py 100.00% <100.00%> (ø)
chaste_codegen/_chaste_printer.py 100.00% <100.00%> (ø)
chaste_codegen/_command_line_script.py 100.00% <100.00%> (ø)
chaste_codegen/_config.py 100.00% <100.00%> (ø)
chaste_codegen/_jacobian.py 100.00% <100.00%> (ø)
chaste_codegen/_labview_printer.py 100.00% <100.00%> (ø)
chaste_codegen/_linearity_check.py 100.00% <100.00%> (ø)
chaste_codegen/_lookup_tables.py 100.00% <100.00%> (ø)
chaste_codegen/_optimize.py 100.00% <100.00%> (ø)
chaste_codegen/_partial_eval.py 100.00% <100.00%> (ø)
... and 12 more

📣 We’re building smart automated test selection to slash your CI/CD build times. Learn more

@MauriceHendrix MauriceHendrix marked this pull request as ready for review December 15, 2022 15:57
@kwabenantim
Copy link
Member

I would probably replace INFINATE with INFINITE but otherwise looks good to me!

@MauriceHendrix MauriceHendrix merged commit aac969b into master Jan 6, 2023
@MauriceHendrix MauriceHendrix deleted the nan_inf_state_vars branch January 10, 2023 18:00
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.

3 participants