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

Long character strings to char2seed() always make a seed of 0 #5

Open
andrewheiss opened this issue May 16, 2023 · 3 comments
Open
Labels
bug Something isn't working

Comments

@andrewheiss
Copy link

With codename v0.5.0 (and maybe before?), strings that are longer than 9 alphanumeric characters result in the same seed: 0:

library(codename)

char2seed("My project title is really long")
#> Warning in char2seed("My project title is really long"): probable complete loss
#> of accuracy in modulus
#> [1] 0
char2seed("Here's another really long seed")
#> Warning in char2seed("Here's another really long seed"): probable complete loss
#> of accuracy in modulus
#> [1] 0

codename(type = "ubuntu", "My project title is really long")
#> Warning in char2seed(seed): probable complete loss of accuracy in modulus
#> [1] "sapphire stoat"
codename(type = "ubuntu", "Here's another really long seed")
#> Warning in char2seed(seed): probable complete loss of accuracy in modulus
#> [1] "sapphire stoat"

The documentation for char2seed() currently says

The function may warn of "loss of accuracy", but this just means you supplied it a really long character vector.

But in practice that "loss of accuracy" warning means that the really long character vector will always generate a seed of 0.

I don't know what to do about it though :( so I've just been making sure my character seeds stay at ≤9 characters

@andrewheiss
Copy link
Author

Ack just kidding, it's not a 9 character threshold. I can get it up to 17 here:

library(codename)

# 9 characters
char2seed("abcdefghi")
#> [1] 123456789

# 10 and it works!
char2seed("abcdefghij")
#> [1] 1608260675

# It breaks here at 18
char2seed("abcdefghijklmnopqr")
#> Warning in char2seed("abcdefghijklmnopqr"): probable complete loss of accuracy
#> in modulus
#> [1] 0

@svmiller
Copy link
Owner

I've been aware of these performance issues but I'm a bit unsure how to proceed with it. I'm already kind of abusing what R's set.seed() is intended to do and there is an actual maximum integer you could set for set.seed() before R politely asks you to stop doing what you're doing. Let me look into this a bit more since it's on my radar.

@svmiller svmiller added the bug Something isn't working label May 16, 2023
@andrewheiss
Copy link
Author

Yeah, I don't know either. Maybe just a note that any long text that triggers that warning will create the same seed?

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

2 participants