Skip to content

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

Open

Description

@andrewheiss

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

Activity

  1. andrewheiss commented on May 16, 2023

    @andrewheiss
    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
  2. svmiller commented on May 16, 2023

    @svmiller
    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.

  3. added
    bug
    on May 16, 2023
  4. andrewheiss commented on May 16, 2023

    @andrewheiss
    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

Metadata

Metadata

Assignees

No one assigned

    Labels

    bug

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions