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

Feature find missing parameter #123

Conversation

drbergman
Copy link
Collaborator

This adds a new member function to the Parameters class. It is called find_variable_index. This function behaves exactly like the already-existing Parameters.find_index except it will return -1 when the input string is not in the user_parameters. For developers, such as PhysiPKPD, relying on user_parameters to make their code run, this gives the ability to protect their end users from missing parameters and typos.

By contrast, find_index would add the missing string to the keys of the unordered_map and assign it the default value of 0. That means the call to the missing parameter will actually return the value of the parameter (of the same type) with index 0 without warning.

There are two reasons for the similarity between the names find_variable_index and find_index.

  1. Autofill features of standard C++ editors will make both options easily findable.
  2. find_variable_index is analogous to the member function of Custom_Cell_Data class of the same name, which may help coders distinguish the two a little bit.

Define find_variable_index member function of class Parameters. It will behave like find_variable_index for Cell_Custom_Data by returning -1 if the parameter is not found.
Added member function find_variable_index to class Parameters.
@MathCancer
Copy link
Owner

Daniel, this is a terrific idea!

But I"m going to build they safety check into find_index rather than add this new function. It will be in the upcoming 1.11.0 release.

Thank you!!!

@MathCancer MathCancer closed this Mar 17, 2023
@drbergman drbergman deleted the feature-find-missing-parameter branch July 31, 2023 14: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