Skip to content

Commit

Permalink
Merge branch 'main' into nb/manipulation_function_basics
Browse files Browse the repository at this point in the history
  • Loading branch information
nathanrboyer authored Dec 12, 2024
2 parents 2abf894 + 86606d4 commit 113d608
Show file tree
Hide file tree
Showing 5 changed files with 36 additions and 18 deletions.
16 changes: 15 additions & 1 deletion Project.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand All @@ -60,8 +61,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",
]
3 changes: 3 additions & 0 deletions docs/Project.toml
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,16 @@ 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"
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"

[compat]
Documenter = "1"
StableRNGs = "1"
1 change: 1 addition & 0 deletions docs/make.jl
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
using Documenter
using DataFrames
using CategoricalArrays
using StableRNGs

DocMeta.setdocmeta!(DataFrames, :DocTestSetup, :(using DataFrames); recursive=true)

Expand Down
20 changes: 10 additions & 10 deletions src/abstractdataframe/abstractdataframe.jl
Original file line number Diff line number Diff line change
Expand Up @@ -2547,9 +2547,9 @@ $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
Expand All @@ -2558,9 +2558,9 @@ julia> shuffle(rng, DataFrame(a=1:5, b=1:5))
─────┼──────────────
1 │ 2 2
2 │ 1 1
3 │ 4 4
4 │ 3 3
5 │ 5 5
3 │ 3 3
4 │ 5 5
5 │ 4 4
```
"""
Random.shuffle(df::AbstractDataFrame) =
Expand All @@ -2585,9 +2585,9 @@ 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
Expand All @@ -2596,9 +2596,9 @@ julia> shuffle!(rng, DataFrame(a=1:5, b=1:5))
─────┼──────────────
1 │ 2 2
2 │ 1 1
3 │ 4 4
4 │ 3 3
5 │ 5 5
3 │ 3 3
4 │ 5 5
5 │ 4 4
```
"""
Random.shuffle!(df::AbstractDataFrame) =
Expand Down
14 changes: 7 additions & 7 deletions test/dataframe.jl
Original file line number Diff line number Diff line change
@@ -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
Expand Down Expand Up @@ -2136,17 +2136,17 @@ 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))
Random.seed!(1234)
@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)
Expand All @@ -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, :]
Expand Down

0 comments on commit 113d608

Please sign in to comment.