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

use count for +, - in Species and remove tryparse #64

Closed
mattsignorelli opened this issue Sep 25, 2024 · 11 comments
Closed

use count for +, - in Species and remove tryparse #64

mattsignorelli opened this issue Sep 25, 2024 · 11 comments
Assignees
Labels
Core Important for package functionality

Comments

@mattsignorelli
Copy link
Contributor

No description provided.

@mattsignorelli mattsignorelli added the Core Important for package functionality label Sep 25, 2024
@DavidSagan
Copy link
Member

Also make sure that something like "He+-" is caught.

@rot4te rot4te self-assigned this Sep 30, 2024
@rot4te
Copy link
Collaborator

rot4te commented Oct 4, 2024

Working on it, though I'm more certain of how to catch "+-" than how to use count; since the name needs to catch charge markers eg +, ++, +3, +4, etc. tryparse is good because it just converts the string to the int.
I'm thinking about adding a reference statement to the species construnctor where it tells you the string name of what it's building.

@DavidSagan
Copy link
Member

Try this: After the first + or - is encountered, check whether the next character is a +, -, digit, or none of the above. Then you can do the right thing (notice that something like +79 has more than one digit. count is not good in this case since you need to make sure that multiple + or - are consecutive.

@mattsignorelli
Copy link
Contributor Author

Why do the +- need to be consecutive?

@DavidSagan
Copy link
Member

Likely a typo then. Nobody writes He+-+.

@mattsignorelli
Copy link
Contributor Author

Just because nobody writes it like that doesn't mean the code needs to impose such a restriction, especially if it lets us use count instead of having to write our own code.

@DavidSagan
Copy link
Member

Catching typos is important. And parsing the species string is so simple I don't see the loss of count as of any importance.

@DavidSagan
Copy link
Member

Also allowing a non-standard syntax can possibly hinder portability with other codes.

@DavidSagan
Copy link
Member

Actually you can use count. Just make sure that + and - are not both present.

@dtabell
Copy link
Collaborator

dtabell commented Oct 5, 2024 via email

@rot4te
Copy link
Collaborator

rot4te commented Jan 14, 2025

See PR #126

@rot4te rot4te closed this as completed Jan 14, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Core Important for package functionality
Projects
None yet
Development

No branches or pull requests

4 participants