From e7efe288605270435a469743418534a04f781483 Mon Sep 17 00:00:00 2001 From: nathanrboyer Date: Thu, 10 Oct 2024 10:48:37 -0400 Subject: [PATCH 1/6] Fix shuffle! docstring --- src/abstractdataframe/abstractdataframe.jl | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/abstractdataframe/abstractdataframe.jl b/src/abstractdataframe/abstractdataframe.jl index bcf70a9f4..3ebf1c7bb 100644 --- a/src/abstractdataframe/abstractdataframe.jl +++ b/src/abstractdataframe/abstractdataframe.jl @@ -2594,10 +2594,10 @@ julia> shuffle!(rng, DataFrame(a=1:5, b=1:5)) Row │ a b │ Int64 Int64 ─────┼────────────── - 1 │ 2 2 - 2 │ 1 1 - 3 │ 4 4 - 4 │ 3 3 + 1 │ 3 3 + 2 │ 4 4 + 3 │ 1 1 + 4 │ 2 2 5 │ 5 5 ``` """ From 28e33bc7eee06bcd9a9b382785847ee43228283f Mon Sep 17 00:00:00 2001 From: nathanrboyer Date: Thu, 10 Oct 2024 10:53:19 -0400 Subject: [PATCH 2/6] Fix shuffle docstring --- src/abstractdataframe/abstractdataframe.jl | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/abstractdataframe/abstractdataframe.jl b/src/abstractdataframe/abstractdataframe.jl index 3ebf1c7bb..5266ede47 100644 --- a/src/abstractdataframe/abstractdataframe.jl +++ b/src/abstractdataframe/abstractdataframe.jl @@ -2556,10 +2556,10 @@ julia> shuffle(rng, DataFrame(a=1:5, b=1:5)) Row │ a b │ Int64 Int64 ─────┼────────────── - 1 │ 2 2 - 2 │ 1 1 - 3 │ 4 4 - 4 │ 3 3 + 1 │ 3 3 + 2 │ 4 4 + 3 │ 1 1 + 4 │ 2 2 5 │ 5 5 ``` """ From 9e98beefad79ffa7528781b45dc25cd4f790f380 Mon Sep 17 00:00:00 2001 From: nathanrboyer Date: Thu, 10 Oct 2024 12:06:54 -0400 Subject: [PATCH 3/6] dev DataFrames into the docs environment This is suggested by the Documenter documentation. I was not able to locally run make.jl until I did this. (Actually the situation was worse because I was running the tests with a different version of the package than the local one, which was yielding confusing error messages.) --- docs/Project.toml | 1 + 1 file changed, 1 insertion(+) diff --git a/docs/Project.toml b/docs/Project.toml index d821a4f08..2e0111110 100755 --- a/docs/Project.toml +++ b/docs/Project.toml @@ -3,6 +3,7 @@ CSV = "336ed68f-0bac-5ca0-87d4-7b16caf5d00b" CategoricalArrays = "324d7699-5711-5eae-9e2f-1d82baa6b597" Chain = "8be319e6-bccf-4806-a6f7-6fae938471bc" DataFrameMacros = "75880514-38bc-4a95-a458-c2aea5a3a702" +DataFrames = "a93c6f00-e57d-5684-b7b6-d8193f3e46c0" DataFramesMeta = "1313f7d8-7da2-5740-9ea0-a2ca25f37964" Documenter = "e30172f5-a6a5-5a46-863b-614d45cd2de4" Missings = "e1d29d7a-bbdc-5cf2-9ac0-f12de2c33e28" From dba4dcf223a948aba3aacd59453c66cd6a312da7 Mon Sep 17 00:00:00 2001 From: nathanrboyer Date: Fri, 6 Dec 2024 16:03:54 -0500 Subject: [PATCH 4/6] Replace `MersenneTwister` rng with `StableRNG` This was suggested in a discourse post where another package had random numbers change between Julia versions. Apparently this is expected behavior. https://discourse.julialang.org/t/julia-1-11-1-gives-different-results-from-1-10-5/123433/53 --- Project.toml | 15 +++++++++++- docs/Project.toml | 1 + docs/make.jl | 1 + src/abstractdataframe/abstractdataframe.jl | 28 +++++++++++----------- test/dataframe.jl | 14 +++++------ 5 files changed, 37 insertions(+), 22 deletions(-) diff --git a/Project.toml b/Project.toml index b3bb15779..a936f4f22 100644 --- a/Project.toml +++ b/Project.toml @@ -60,8 +60,21 @@ Logging = "56ddb016-857b-54e1-b83d-db4d58db5568" OffsetArrays = "6fe1bfb0-de20-5000-8ca7-80f57d26f881" ShiftedArrays = "1277b4bf-5013-50f5-be3d-901d8477a67a" SparseArrays = "2f01184e-e22b-5df5-ae63-d93ebab69eaf" +StableRNGs = "860ef19b-820b-49d6-a774-d7a799459cd3" Test = "8dfed614-e22c-5e08-85e1-65c5234f0b40" Unitful = "1986cc42-f94f-5a68-af5c-568840ba703d" [targets] -test = ["CategoricalArrays", "Combinatorics", "DataValues", "Dates", "Logging", "OffsetArrays", "Test", "Unitful", "ShiftedArrays", "SparseArrays"] +test = [ + "CategoricalArrays", + "Combinatorics", + "DataValues", + "Dates", + "Logging", + "OffsetArrays", + "ShiftedArrays", + "SparseArrays", + "StableRNGs", + "Test", + "Unitful", +] diff --git a/docs/Project.toml b/docs/Project.toml index 2e0111110..8b2aba74d 100755 --- a/docs/Project.toml +++ b/docs/Project.toml @@ -8,6 +8,7 @@ DataFramesMeta = "1313f7d8-7da2-5740-9ea0-a2ca25f37964" Documenter = "e30172f5-a6a5-5a46-863b-614d45cd2de4" Missings = "e1d29d7a-bbdc-5cf2-9ac0-f12de2c33e28" Query = "1a8c2f83-1ff3-5112-b086-8aa67b057ba1" +StableRNGs = "860ef19b-820b-49d6-a774-d7a799459cd3" Statistics = "10745b16-79ce-11e8-11f9-7d13ad32a3b2" Tables = "bd369af6-aec1-5ad0-b16a-f7cc5008161c" TidierData = "fe2206b3-d496-4ee9-a338-6a095c4ece80" diff --git a/docs/make.jl b/docs/make.jl index a5d5a4f4e..c590c7b7e 100644 --- a/docs/make.jl +++ b/docs/make.jl @@ -1,6 +1,7 @@ using Documenter using DataFrames using CategoricalArrays +using StableRNGs DocMeta.setdocmeta!(DataFrames, :DocTestSetup, :(using DataFrames); recursive=true) diff --git a/src/abstractdataframe/abstractdataframe.jl b/src/abstractdataframe/abstractdataframe.jl index 5266ede47..4fc42e453 100644 --- a/src/abstractdataframe/abstractdataframe.jl +++ b/src/abstractdataframe/abstractdataframe.jl @@ -2547,20 +2547,20 @@ $METADATA_FIXED # Examples ```jldoctest -julia> using Random +julia> using Random, StableRNGs -julia> rng = MersenneTwister(1234); +julia> rng = StableRNG(1234); julia> shuffle(rng, DataFrame(a=1:5, b=1:5)) 5×2 DataFrame Row │ a b │ Int64 Int64 ─────┼────────────── - 1 │ 3 3 - 2 │ 4 4 - 3 │ 1 1 - 4 │ 2 2 - 5 │ 5 5 + 1 │ 2 2 + 2 │ 1 1 + 3 │ 3 3 + 4 │ 5 5 + 5 │ 4 4 ``` """ Random.shuffle(df::AbstractDataFrame) = @@ -2585,20 +2585,20 @@ Metadata having other styles is dropped (from parent data frame when `df` is a ` # Examples ```jldoctest -julia> using Random +julia> using Random, StableRNGs -julia> rng = MersenneTwister(1234); +julia> rng = StableRNG(1234); julia> shuffle!(rng, DataFrame(a=1:5, b=1:5)) 5×2 DataFrame Row │ a b │ Int64 Int64 ─────┼────────────── - 1 │ 3 3 - 2 │ 4 4 - 3 │ 1 1 - 4 │ 2 2 - 5 │ 5 5 + 1 │ 2 2 + 2 │ 1 1 + 3 │ 3 3 + 4 │ 5 5 + 5 │ 4 4 ``` """ Random.shuffle!(df::AbstractDataFrame) = diff --git a/test/dataframe.jl b/test/dataframe.jl index 940590852..74fa10784 100644 --- a/test/dataframe.jl +++ b/test/dataframe.jl @@ -1,7 +1,7 @@ module TestDataFrame using Dates, DataFrames, Statistics, Random, Test, Logging, DataStructures, - CategoricalArrays + CategoricalArrays, StableRNGs using DataFrames: _columns, index using OffsetArrays: OffsetArray const ≅ = isequal @@ -2136,8 +2136,8 @@ end refdf = DataFrame(a=1:5, b=11:15) refdf.c = refdf.a for df in (refdf, view(refdf, 2:5, [2, 1])) - x = randperm(MersenneTwister(1234), nrow(df)) - mt = MersenneTwister(1234) + x = randperm(StableRNG(1234), nrow(df)) + mt = StableRNG(1234) @test shuffle(mt, df) == df[x, :] Random.seed!(1234) x = randperm(nrow(df)) @@ -2145,8 +2145,8 @@ end @test shuffle(df) == df[x, :] end df = copy(refdf) - x = randperm(MersenneTwister(1234), nrow(df)) - mt = MersenneTwister(1234) + x = randperm(StableRNG(1234), nrow(df)) + mt = StableRNG(1234) @test shuffle!(mt, df) === df @test df == refdf[x, :] df = copy(refdf) @@ -2158,8 +2158,8 @@ end df = copy(refdf) dfv = view(df, 2:4, [3, 1]) - x = randperm(MersenneTwister(1234), nrow(dfv)) - mt = MersenneTwister(1234) + x = randperm(StableRNG(1234), nrow(dfv)) + mt = StableRNG(1234) @test shuffle!(mt, dfv) === dfv @test dfv == view(refdf, 2:4, [3, 1])[x, :] @test df[1, :] == refdf[1, :] From e8b59195f89a0df64826db6282253a32c8ecd46f Mon Sep 17 00:00:00 2001 From: nathanrboyer Date: Wed, 11 Dec 2024 16:25:43 -0500 Subject: [PATCH 5/6] Add StableRNGs docs compat --- docs/Project.toml | 1 + 1 file changed, 1 insertion(+) diff --git a/docs/Project.toml b/docs/Project.toml index 8b2aba74d..ad8350455 100755 --- a/docs/Project.toml +++ b/docs/Project.toml @@ -15,3 +15,4 @@ TidierData = "fe2206b3-d496-4ee9-a338-6a095c4ece80" [compat] Documenter = "1" +StableRNGs = "1" From f49ab77c2c56c8aea525f48bcd4f1bd1c942baa8 Mon Sep 17 00:00:00 2001 From: nathanrboyer Date: Thu, 12 Dec 2024 09:05:49 -0500 Subject: [PATCH 6/6] Add StableRNGs to src compat --- Project.toml | 1 + 1 file changed, 1 insertion(+) diff --git a/Project.toml b/Project.toml index a936f4f22..646131995 100644 --- a/Project.toml +++ b/Project.toml @@ -45,6 +45,7 @@ Reexport = "1" SentinelArrays = "1.2" ShiftedArrays = "1, 2" SortingAlgorithms = "0.3, 1" +StableRNGs = "1" Statistics = "1" TableTraits = "0.4, 1" Tables = "1.9.0"