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

Inconsistent warnings when combining eras with different labels/names #27

Closed
joeroe opened this issue Dec 8, 2020 · 1 comment
Closed
Labels
bug Something isn't working
Milestone

Comments

@joeroe
Copy link
Owner

joeroe commented Dec 8, 2020

Arithmetic with yrs with functionally equivalent, but differently named, eras throws a warning as expected:

library("era")
yr(1, "BP") + yr(1, "cal BP")
#> Warning: `era(x)` and `era(y)` have different label or name parameters.
#> # BP years <yr[1]>:
#> [1] 2
#> # Era: Before Present (BP): calendar years, counted backwards from 1950

But combining the same vectors doesn't:

c(yr(1, "BP"), yr(1, "cal BP"))
#> # BP years <yr[2]>:
#> [1] 1 1
#> # Era: Before Present (BP): calendar years, counted backwards from 1950

Created on 2020-12-08 by the reprex package (v0.3.0)

The check currently in vec_arith.era_yr.era_yr() should be moved lower, to catch all instances of combination.

@joeroe joeroe added the bug Something isn't working label Dec 8, 2020
@joeroe joeroe added this to the v1.0 milestone Dec 8, 2020
@joeroe joeroe modified the milestones: 1.0.0, 0.4.0 Feb 7, 2021
@joeroe joeroe closed this as completed in d17b828 Mar 9, 2022
@joeroe
Copy link
Owner Author

joeroe commented Mar 9, 2022

Now checks for era compatibility only happen in vec_cast() and the warnings are consistent:

library("era")
yr(1, "BP") + yr(1, "cal BP")
#> Warning: eras have different label or name parameters.
#> # BP years <yr[1]>:
#> [1] 2
#> # Era: Before Present (BP): Gregorian years (365.2425 days), counted backwards from 1950
c(yr(1, "BP"), yr(1, "cal BP"))
#> Warning: eras have different label or name parameters.
#> # BP years <yr[2]>:
#> [1] 1 1
#> # Era: Before Present (BP): Gregorian years (365.2425 days), counted backwards from 1950

Created on 2022-03-09 by the reprex package (v2.0.1)

joeroe added a commit that referenced this issue Mar 9, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant