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

Check if input value is integer before conversion #169

Open
stellabelin opened this issue May 17, 2024 · 2 comments
Open

Check if input value is integer before conversion #169

stellabelin opened this issue May 17, 2024 · 2 comments

Comments

@stellabelin
Copy link
Contributor

E.g. if you run set_peripheral_compartments(model, 1.5) pharmr will convert this with as.integer making it into 1, however this should raise.

@stellabelin
Copy link
Contributor Author

If inputting something that cannot be converted to an integer such as a string (as.integer('a')) the variable will be NA of class integer. When this is then run through reticulate, this will be converted to the lowest negative value. Example:

> reticulate::r_to_py(as.integer('a'))
-2147483648

This can lead to strange edge cases, such as when using set_peripheral_compartments it gets stuck. pharmr should catch this before trying to convert values to integers.

@rikardn
Copy link
Contributor

rikardn commented May 20, 2024

I guess we should only allow integer and numeric that are exactly integers. Everything else should raise.

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

No branches or pull requests

2 participants