Skip to content

Store unique + randomly shuffled animal names #207

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

Merged
merged 2 commits into from
Jan 6, 2025

Conversation

devmotion
Copy link
Contributor

Currently, the animal names in animals.txt are not unique ("Donkey" appears twice) and they are only converted to lowercase characters and shuffled when loaded. In particular, the random shuffling requires MacroTools to depend on Random which is not used anywhere else in the package.

This PR removes the duplicate entry and preshuffles the animal names (for reproducibility I used StableRNG(1234)). I also added tests.

PR Checklist

  • Tests are added
  • Documentation, if applicable

Copy link
Collaborator

@cstjean cstjean left a comment

Choose a reason for hiding this comment

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

LGTM I think? This will change some downstream results, but I don't think it can possibly matter...

test/utils.jl Outdated
@test length(MacroTools.animals) == 214
@test allunique(MacroTools.animals)
@test all(islowercase ∘ first ∘ string, MacroTools.animals)
@test MacroTools.animals == Random.shuffle!(StableRNGs.StableRNG(1234), sort(MacroTools.animals))
Copy link
Collaborator

@cstjean cstjean Jan 5, 2025

Choose a reason for hiding this comment

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

Is that the only reason for the test Random dependency? If so I would just take it out, along with StableRNG. I don't see why anyone would care about this particular test, and the less code the better...

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes, it is. The test is definitely not necessary, I included it only to demonstrate how the list was generated. I'll remove it together with the test dependencies.

@cstjean
Copy link
Collaborator

cstjean commented Jan 6, 2025

Thanks!

@cstjean cstjean merged commit 7d9ceb6 into FluxML:master Jan 6, 2025
10 checks passed
@devmotion devmotion deleted the dw/animals branch January 6, 2025 10:41
@devmotion
Copy link
Contributor Author

Maybe it's time for a new release? 🙂

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