Skip to content

Commit a0650b1

Browse files
authored
Adjust codebase to the fact that we require at least Julia 1.10 (#3513)
1 parent fe224cb commit a0650b1

File tree

14 files changed

+123
-243
lines changed

14 files changed

+123
-243
lines changed

docs/src/lib/functions.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -29,9 +29,9 @@ This is a list of operations that currently make use of multi-threading:
2929
- `dropmissing` when the provided data frame has more than 1 column and `view=false`
3030
(subsetting of individual columns is spawned in separate tasks).
3131

32-
In general at least Julia 1.4 is required to ensure that multi-threading is used
33-
and the Julia process must be started with more than one thread. Some operations
34-
turn on multi-threading only if enough rows in the processed data frame are present
32+
In general to ensure that multi-threading is used Julia process must be started with more than one thread.
33+
Some operations turn on multi-threading only if enough rows are present
34+
in the processed data frame.
3535
(the exact threshold when multi-threading is enabled is considered to be undefined
3636
and might change in the future).
3737

docs/src/lib/indexing.md

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -71,10 +71,7 @@ In the descriptions below `df` represents a `DataFrame`, `sdf` is a
7171
`:` always expands to `axes(df, 1)` or `axes(sdf, 1)`.
7272

7373
`df.col` works like `df[!, col]` and `sdf.col` works like `sdf[!, col]` in all
74-
cases. An exception is that under Julia 1.6 or earlier
75-
`df.col .= v` and `sdf.col .= v` performs in-place broadcasting
76-
if `col` is present in `df`/`sdf` and is a valid identifier (this inconsistency
77-
is not present under Julia 1.7 and later).
74+
cases.
7875

7976
## `getindex` and `view`
8077

@@ -288,7 +285,7 @@ Additional rules:
288285
`df` with freshly allocated vectors;
289286
* `df.col .= v` syntax currently performs in-place assignment to an existing
290287
vector `df.col`; this behavior is deprecated and a new column will be
291-
allocated in the future. Starting from Julia 1.7 if `:col` is not present in
288+
allocated in the future. If `:col` is not present in
292289
`df` then a new column will be created in `df`.
293290
* in the `sdf[CartesianIndex(row, col)] .= v`, `sdf[row, col] .= v` and
294291
`sdf[row, cols] .= v` syntaxes the assignment to `sdf` is performed in-place;
@@ -308,7 +305,7 @@ Additional rules:
308305
values already present in `cols`;
309306
* `sdf.col .= v` syntax currently performs in-place assignment to an existing
310307
vector `sdf.col`; this behavior is deprecated and a new column will be
311-
allocated in the future. Starting from Julia 1.7 if `:col` is not present in
308+
allocated in the future. If `:col` is not present in
312309
`sdf` then a new column will be created in `sdf` if `sdf` was created with `:`
313310
as a column selector.
314311
* `dfr.col .= v` syntax is allowed and performs in-place assignment to a value

docs/src/lib/metadata.md

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -263,10 +263,8 @@ metadata is always dropped). These are:
263263
for row keys columns.
264264
* [`permutedims`](@ref): propagates table-level metadata and drops column-level
265265
metadata.
266-
* broadcasted assignment does not change target metadata;
267-
under Julia earlier than 1.7 operation of kind `df.a .= s` does not drop non-`:note`-style
268-
metadata; under Julia 1.7 or later this operation preserves only `:note`-style
269-
metadata
266+
* broadcasted assignment does not change target metadata:
267+
operation preserves only `:note`-style metadata
270268
* broadcasting propagates table-level metadata if some key is present
271269
in all passed data frames and value associated with it is identical in all
272270
passed data frames; column-level metadata is propagated for columns if some

docs/src/man/basics.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,8 +36,8 @@ you have installed with the `status` command.
3636
julia> ]
3737

3838
(@v1.9) pkg> status DataFrames
39-
Status `~\v1.6\Project.toml`
40-
[a93c6f00] DataFrames v1.5.0
39+
Status `~\v1.13\Project.toml`
40+
[a93c6f00] DataFrames v1.8.0
4141
```
4242

4343
Throughout the rest of the tutorial we will assume that you have installed the

src/DataFrames.jl

Lines changed: 25 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,33 @@
11
module DataFrames
22

3-
using Statistics, Printf
4-
using Reexport, SortingAlgorithms, Compat, Unicode, PooledArrays
3+
using Base.Sort,
4+
Base.Order,
5+
Base.Iterators,
6+
Base.Threads,
7+
Statistics,
8+
Printf,
9+
Reexport,
10+
SortingAlgorithms,
11+
Compat,
12+
Unicode,
13+
PooledArrays,
14+
TableTraits,
15+
IteratorInterfaceExtensions,
16+
Markdown,
17+
PrettyTables,
18+
Random
19+
520
@reexport using Missings, InvertedIndices
6-
using Base.Sort, Base.Order, Base.Iterators, Base.Threads
7-
using TableTraits, IteratorInterfaceExtensions
8-
import LinearAlgebra: norm
9-
using Markdown
10-
using PrettyTables
11-
using Random
21+
1222
using Tables: ByRow
13-
import PrecompileTools
14-
import SentinelArrays
15-
import InlineStrings
1623

17-
import DataAPI,
24+
import Base.keepat!,
25+
Base.stack,
26+
LinearAlgebra.norm,
27+
PrecompileTools,
28+
SentinelArrays,
29+
InlineStrings,
30+
DataAPI,
1831
DataAPI.allcombinations,
1932
DataAPI.All,
2033
DataAPI.Between,
@@ -112,23 +125,6 @@ export AbstractDataFrame,
112125
deletecolmetadata!,
113126
emptycolmetadata!
114127

115-
using Base.Threads: @spawn
116-
using Base: ComposedFunction
117-
118-
if isdefined(Base, :keepat!) # Introduced in 1.7.0
119-
import Base.keepat!
120-
else
121-
import Compat.keepat!
122-
export keepat!
123-
end
124-
125-
if VERSION >= v"1.9.0-DEV.1163"
126-
import Base: stack
127-
else
128-
import Compat: stack
129-
export stack
130-
end
131-
132128
const METADATA_FIXED =
133129
"""
134130
Metadata: this function preserves table-level and column-level `:note`-style metadata.

src/dataframe/dataframe.jl

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -877,11 +877,6 @@ function Base.deleteat!(df::DataFrame, inds::AbstractVector)
877877
throw(ArgumentError("unsupported index $inds"))
878878
end
879879

880-
# workaround https://github.com/JuliaLang/julia/pull/41646
881-
if VERSION <= v"1.6.2" && inds isa UnitRange{<:Integer}
882-
inds = collect(inds)
883-
end
884-
885880
if !issorted(inds, lt=<=)
886881
throw(ArgumentError("Indices passed to deleteat! must be unique and sorted"))
887882
end
@@ -893,10 +888,6 @@ function Base.deleteat!(df::DataFrame, inds::AbstractVector{Bool})
893888
if length(inds) != size(df, 1)
894889
throw(BoundsError(df, (inds, :)))
895890
end
896-
# workaround https://github.com/JuliaLang/julia/pull/41646
897-
if VERSION <= v"1.6.2" && drop isa UnitRange{<:Integer}
898-
inds = collect(inds)
899-
end
900891
return _deleteat!_helper(df, inds)
901892
end
902893

src/other/broadcasting.jl

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -183,14 +183,12 @@ function Base.dotview(df::AbstractDataFrame, ::typeof(!), cols)
183183
return LazyNewColDataFrame(df, cols isa AbstractString ? Symbol(cols) : cols)
184184
end
185185

186-
if isdefined(Base, :dotgetproperty) # Introduced in Julia 1.7
187-
function Base.dotgetproperty(df::AbstractDataFrame, col::SymbolOrString)
188-
if columnindex(df, col) == 0 && !is_column_insertion_allowed(df)
189-
throw(ArgumentError("creating new columns in a SubDataFrame that subsets " *
190-
"columns of its parent data frame is disallowed"))
191-
end
192-
return LazyNewColDataFrame(df, Symbol(col))
186+
function Base.dotgetproperty(df::AbstractDataFrame, col::SymbolOrString)
187+
if columnindex(df, col) == 0 && !is_column_insertion_allowed(df)
188+
throw(ArgumentError("creating new columns in a SubDataFrame that subsets " *
189+
"columns of its parent data frame is disallowed"))
193190
end
191+
return LazyNewColDataFrame(df, Symbol(col))
194192
end
195193

196194
function Base.copyto!(lazydf::LazyNewColDataFrame, bc::Base.Broadcast.Broadcasted{T}) where T

src/other/utils.jl

Lines changed: 4 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -225,19 +225,14 @@ macro spawn_or_run_task(threads, ex)
225225
letargs = Base._lift_one_interp!(ex)
226226

227227
thunk = :(()->($(esc(ex))))
228-
@static if VERSION >= v"1.10.0-DEV"
229-
Base.replace_linenums!(thunk, __source__)
230-
end
228+
Base.replace_linenums!(thunk, __source__)
231229
var = esc(Base.sync_varname)
232-
spawn_set_thrpool = VERSION >= v"1.9.0" ?
233-
:(Base.Threads._spawn_set_thrpool(task, :default)) :
234-
:()
235230
quote
236231
let $(letargs...)
237232
if $(esc(threads))
238233
local task = Task($thunk)
239234
task.sticky = false
240-
$(spawn_set_thrpool)
235+
Base.Threads._spawn_set_thrpool(task, :default)
241236
else
242237
# Run expr immediately
243238
res = $thunk()
@@ -264,19 +259,14 @@ macro spawn_or_run(threads, ex)
264259
letargs = Base._lift_one_interp!(ex)
265260

266261
thunk = :(()->($(esc(ex))))
267-
if VERSION >= v"1.10.0-DEV"
268-
Base.replace_linenums!(thunk, __source__)
269-
end
262+
Base.replace_linenums!(thunk, __source__)
270263
var = esc(Base.sync_varname)
271-
spawn_set_thrpool = VERSION >= v"1.9.0" ?
272-
:(Base.Threads._spawn_set_thrpool(task, :default)) :
273-
:()
274264
quote
275265
let $(letargs...)
276266
if $(esc(threads))
277267
local task = Task($thunk)
278268
task.sticky = false
279-
$(spawn_set_thrpool)
269+
Base.Threads._spawn_set_thrpool(task, :default)
280270
if $(Expr(:islocal, var))
281271
put!($var, task)
282272
end

test/broadcasting.jl

Lines changed: 42 additions & 100 deletions
Original file line numberDiff line numberDiff line change
@@ -1463,50 +1463,25 @@ end
14631463

14641464
df = copy(refdf)
14651465
v1 = df[!, 1]
1466-
if isdefined(Base, :dotgetproperty) # Introduced in Julia 1.7
1467-
df.x1 .= 'd'
1468-
@test df.x1 == ['d', 'd', 'd']
1469-
@test eltype(df.x1) === Char
1470-
@test_throws MethodError df[:, 1] .= "d"
1471-
@test_throws DimensionMismatch df[:, 1] .= [1 2 3]
1472-
@test v1 == [1.5, 2.5, 3.5]
1473-
else
1474-
df.x1 .= 'd'
1475-
@test v1 == [100.0, 100.0, 100.0]
1476-
@test_throws MethodError df[:, 1] .= "d"
1477-
@test v1 == [100.0, 100.0, 100.0]
1478-
@test_throws DimensionMismatch df[:, 1] .= [1 2 3]
1479-
@test v1 == [100.0, 100.0, 100.0]
1480-
end
1466+
df.x1 .= 'd'
1467+
@test df.x1 == ['d', 'd', 'd']
1468+
@test eltype(df.x1) === Char
1469+
@test_throws MethodError df[:, 1] .= "d"
1470+
@test_throws DimensionMismatch df[:, 1] .= [1 2 3]
1471+
@test v1 == [1.5, 2.5, 3.5]
14811472

1482-
if isdefined(Base, :dotgetproperty) # Introduced in Julia 1.7
1483-
df = DataFrame(a=1:4, b=1, c=2)
1484-
df.a .= 'a':'d'
1485-
@test df == DataFrame(a='a':'d', b=1, c=2)
1486-
dfv = view(df, 2:3, 2:3)
1487-
x = df.b
1488-
dfv.b .= 0
1489-
@test df.b == [1, 0, 0, 1]
1490-
@test x == [1, 1, 1, 1]
1491-
else
1492-
df = DataFrame(a=1:4, b=1, c=2)
1493-
df.a .= 'a':'d'
1494-
@test df == DataFrame(a=97:100, b=1, c=2)
1495-
dfv = view(df, 2:3, 2:3)
1496-
x = df.b
1497-
dfv.b .= 0
1498-
@test df.b == [1, 0, 0, 1]
1499-
@test x === df.b
1500-
end
1473+
df = DataFrame(a=1:4, b=1, c=2)
1474+
df.a .= 'a':'d'
1475+
@test df == DataFrame(a='a':'d', b=1, c=2)
1476+
dfv = view(df, 2:3, 2:3)
1477+
x = df.b
1478+
dfv.b .= 0
1479+
@test df.b == [1, 0, 0, 1]
1480+
@test x == [1, 1, 1, 1]
15011481

15021482
df = copy(refdf)
1503-
if isdefined(Base, :dotgetproperty) # Introduced in Julia 1.7
1504-
df.newcol .= 'd'
1505-
@test df == [refdf DataFrame(newcol=fill('d', 3))]
1506-
else
1507-
@test_throws ArgumentError df.newcol .= 'd'
1508-
@test df == refdf
1509-
end
1483+
df.newcol .= 'd'
1484+
@test df == [refdf DataFrame(newcol=fill('d', 3))]
15101485

15111486
df = view(copy(refdf), :, :)
15121487
v1 = df[!, 1]
@@ -1637,31 +1612,17 @@ end
16371612

16381613
df = view(copy(refdf), :, :)
16391614
v1 = df[!, 1]
1640-
if isdefined(Base, :dotgetproperty) # Introduced in Julia 1.7
1641-
df.x1 .= 'd'
1642-
@test df.x1 == ['d', 'd', 'd']
1643-
@test eltype(df.x1) === Any
1644-
df[:, 1] .= "d"
1645-
@test df.x1 == ["d", "d", "d"]
1646-
@test_throws DimensionMismatch df[:, 1] .= [1 2 3]
1647-
@test v1 == [1.5, 2.5, 3.5]
1648-
else
1649-
df.x1 .= 'd'
1650-
@test v1 == [100.0, 100.0, 100.0]
1651-
@test_throws MethodError df[:, 1] .= "d"
1652-
@test v1 == [100.0, 100.0, 100.0]
1653-
@test_throws DimensionMismatch df[:, 1] .= [1 2 3]
1654-
@test v1 == [100.0, 100.0, 100.0]
1655-
end
1615+
df.x1 .= 'd'
1616+
@test df.x1 == ['d', 'd', 'd']
1617+
@test eltype(df.x1) === Any
1618+
df[:, 1] .= "d"
1619+
@test df.x1 == ["d", "d", "d"]
1620+
@test_throws DimensionMismatch df[:, 1] .= [1 2 3]
1621+
@test v1 == [1.5, 2.5, 3.5]
16561622

16571623
df = view(copy(refdf), :, :)
1658-
if VERSION >= v"1.7"
1659-
df.newcol .= 'd'
1660-
@test df.newcol == fill('d', 3)
1661-
else
1662-
@test_throws ArgumentError df.newcol .= 'd'
1663-
@test df == refdf
1664-
end
1624+
df.newcol .= 'd'
1625+
@test df.newcol == fill('d', 3)
16651626
end
16661627

16671628
@testset "DataFrameRow getproperty broadcasted assignment" begin
@@ -1910,47 +1871,28 @@ end
19101871

19111872
@testset "broadcasting of getproperty" begin
19121873
df = DataFrame(a=1:4)
1913-
if isdefined(Base, :dotgetproperty) # Introduced in Julia 1.7
1914-
df.b .= 1
1915-
x = df.b
1916-
df.c .= 4:-1:1
1917-
df.a .= 'a':'d'
1918-
@test df.a isa Vector{Char}
1919-
@test df == DataFrame(a='a':'d', b=1, c=4:-1:1)
1920-
1921-
# in views also column replacement is performed
1922-
dfv = view(df, 2:3, 2:3)
1923-
dfv.b .= 0
1924-
@test x == [1, 1, 1, 1]
1925-
@test df.b !== x
1926-
@test df == DataFrame(a='a':'d', b=[1, 0, 0, 1], c=4:-1:1)
1927-
dfv.c .= ["p", "q"]
1928-
@test df == DataFrame(a='a':'d', b=[1, 0, 0, 1], c=[4, "p", "q", 1])
1929-
else
1930-
# Julia older than 1.7
1931-
df[!, :b] .= 1
1932-
x = df.b
1933-
df[!, :c] .= 4:-1:1
1934-
df.a .= 'a':'d'
1935-
dfv = view(df, 2:3, 2:3)
1936-
dfv.b .= 0
1937-
@test x == [1, 0, 0, 1]
1938-
@test df.b === x
1939-
@test df == DataFrame(a=97:100, b=[1, 0, 0, 1], c=4:-1:1)
1940-
@test_throws MethodError dfv.c .= ["p", "q"]
1941-
@test df == DataFrame(a=97:100, b=[1, 0, 0, 1], c=[4, 3, 2, 1])
1942-
end
1874+
df.b .= 1
1875+
x = df.b
1876+
df.c .= 4:-1:1
1877+
df.a .= 'a':'d'
1878+
@test df.a isa Vector{Char}
1879+
@test df == DataFrame(a='a':'d', b=1, c=4:-1:1)
1880+
1881+
# in views also column replacement is performed
1882+
dfv = view(df, 2:3, 2:3)
1883+
dfv.b .= 0
1884+
@test x == [1, 1, 1, 1]
1885+
@test df.b !== x
1886+
@test df == DataFrame(a='a':'d', b=[1, 0, 0, 1], c=4:-1:1)
1887+
dfv.c .= ["p", "q"]
1888+
@test df == DataFrame(a='a':'d', b=[1, 0, 0, 1], c=[4, "p", "q", 1])
19431889
end
19441890

19451891
@testset "dotgetproperty on SubDataFrame" begin
19461892
df = DataFrame(a=1:3, b=4:6)
19471893
dfv = @view df[[3, 1], :]
1948-
if isdefined(Base, :dotgetproperty) # Introduced in Julia 1.7
1949-
dfv.c .= [1, 2]
1950-
@test df DataFrame(a=1:3, b=4:6, c=[2, missing, 1])
1951-
else
1952-
@test_throws ArgumentError dfv.c .= [1, 2]
1953-
end
1894+
dfv.c .= [1, 2]
1895+
@test df DataFrame(a=1:3, b=4:6, c=[2, missing, 1])
19541896

19551897
df = DataFrame(a=1:3, b=4:6)
19561898
dfv = @view df[[3, 1], 1:2]

0 commit comments

Comments
 (0)