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

Add custom class to tag loss conditions #109

Merged
merged 4 commits into from
Feb 22, 2024
Merged

Add custom class to tag loss conditions #109

merged 4 commits into from
Feb 22, 2024

Conversation

Bisaloo
Copy link
Member

@Bisaloo Bisaloo commented Feb 22, 2024

  • Please check if the PR fulfills these requirements
  • I have read the CONTRIBUTING guidelines
  • A new item has been added to NEWS.md
  • Tests for the changes have been added (for bug fixes / features)
  • Docs have been added / updated (for bug fixes / features)
  • What kind of change does this PR introduce? (Bug fix, feature, docs update, ...)

New feature

  • What is the current behavior? (You can also link to an open issue here)

Linelist tagged variable loss condition are not classed.

  • What is the new behavior (if this is a feature change)?

Customs classes (linelist_error and linelist_warning) are added to conditions raised in case of tagged variable loss.
This enables advanced condition handling, as illustrated in the following reprex:

warning_counter <- 0

withCallingHandlers({
  x <- linelist::make_linelist(cars, date_onset = "dist", age = "speed")
  x <- x[, -1]
  x <- x[, -1]
  warning("This is not a linelist warning", call. = FALSE)
}, linelist_warning = function(w) {
  warning_counter <<- warning_counter + 1
})
#> Warning: The following tags have lost their variable:
#>  age:speed
#> Warning: The following tags have lost their variable:
#>  date_onset:dist
#> Warning: This is not a linelist warning

warning("This pipeline generated ", warning_counter, " linelist warnings.")
#> Warning: This pipeline generated 2 linelist warnings.
  • Does this PR introduce a breaking change? (What changes might users need to make in their application due to this PR?)

No

  • Other information:

Fix #90

@Bisaloo Bisaloo merged commit 37d5c03 into main Feb 22, 2024
10 checks passed
@Bisaloo Bisaloo deleted the condition-classes branch February 22, 2024 09:45
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.

Add class to linelist tag loss conditions
1 participant