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

refactor: countElements returns NA if an element is invalid instead of dropping it #65

Merged
merged 3 commits into from
Aug 8, 2023

Conversation

sgibb
Copy link
Member

@sgibb sgibb commented Aug 4, 2023

This PR propose a solution to #64 .

I had to touch .sum_elements (change order of tests), calculateMass (test for NULL) and adductFormula (drop invalid formulas silently) to keep the current behaviour (and pass all unit tests).

countElements("C1Fo")

# $C1Fo
# [1] NA
# 
# Warning message:
# In (function (xx, rr)  : The given formula 'C1Fo' contains invalid symbols

Unfortunately we lose the position information (e.g. pos 3 contains "Fo").

BTW: I removed unnecessary [ and ] in the regexp.

@sgibb
Copy link
Member Author

sgibb commented Aug 4, 2023

BTW: with this PR #63 is easy to solve: containsElements could return NA / FALSE for invalid formulas (we just have to call suppressWarnings(countElements(y)) and return NA/FALSE if countElements yield NA)

Copy link
Member

@jorainer jorainer left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great! Thanks @sgibb !

Only thing missing is to bump version and update the NEWS. After that all good for a merge

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