Skip to content

Commit f5b6338

Browse files
committed
Merge branch 'master' into nl/cutweights
2 parents 1d24d84 + e4a13b1 commit f5b6338

File tree

11 files changed

+40
-77
lines changed

11 files changed

+40
-77
lines changed

.github/workflows/ci.yml

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,13 +12,15 @@ jobs:
1212
fail-fast: false
1313
matrix:
1414
version:
15+
# FIXME! Switch from 1.6 to 'min' once we require a higher minimum
16+
# We can't switch yet as there is a method ambiguity for a depndency
17+
# in version 1.6.0.
1518
- '1.6'
19+
- 'lts'
1620
- '1' # automatically expands to the latest stable 1.x release of Julia
17-
- 'nightly'
21+
- 'pre'
1822
os:
1923
- ubuntu-latest
20-
- macOS-latest
21-
- windows-latest
2224
arch:
2325
- x64
2426
- x86

Project.toml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -48,13 +48,13 @@ Arrow = "69666777-d1a9-59fb-9406-91d4454c9d45"
4848
Dates = "ade2ca70-3891-5945-98fb-dc099432e06a"
4949
JSON = "682c06a0-de6a-54ab-a142-c8b1cf79cde6"
5050
JSON3 = "0f8b85d8-7281-11e9-16c2-39a750bddbf1"
51-
Plots = "91a5bcdd-55d7-5caf-9e0b-520d859cae80"
5251
PooledArrays = "2dfb63ee-cc39-5dd5-95bd-886bf059d720"
5352
RecipesBase = "3cdcf5f2-1ef4-517c-9805-6587b60abb01"
53+
RecipesPipeline = "01d81517-befc-4cb6-b9ec-a95719d0359c"
5454
SentinelArrays = "91c51154-3ec4-41a3-a24f-3f23e20d615c"
5555
StatsBase = "2913bbd2-ae8a-5f71-8c99-4fb6c76f3a91"
5656
StructTypes = "856f2bd8-1eba-4b0a-8007-ebc267875bd4"
5757
Test = "8dfed614-e22c-5e08-85e1-65c5234f0b40"
5858

5959
[targets]
60-
test = ["Arrow", "Dates", "JSON", "JSON3", "Plots", "PooledArrays", "RecipesBase", "SentinelArrays", "StatsBase", "StructTypes", "Test"]
60+
test = ["Arrow", "Dates", "JSON", "JSON3", "PooledArrays", "RecipesBase", "RecipesPipeline", "SentinelArrays", "StructTypes", "Test"]

src/CategoricalArrays.jl

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,8 +35,6 @@ module CategoricalArrays
3535
include("extras.jl")
3636
include("recode.jl")
3737

38-
include("deprecated.jl")
39-
4038
if !isdefined(Base, :get_extension)
4139
using Requires: @require
4240
end

src/array.jl

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -790,13 +790,7 @@ entries corresponding to omitted levels will be set to `missing`.
790790
Else, `newlevels` must include all levels which appear in the data.
791791
"""
792792
function levels!(A::CategoricalArray{T, N, R}, newlevels::AbstractVector;
793-
allowmissing::Bool=false,
794-
allow_missing::Union{Bool, Nothing}=nothing) where {T, N, R}
795-
if allow_missing !== nothing
796-
Base.depwarn("allow_missing argument is deprecated, use allowmissing instead",
797-
:levels!)
798-
allowmissing = allow_missing
799-
end
793+
allowmissing::Bool=false) where {T, N, R}
800794
(levels(A) == newlevels) && return A # nothing to do
801795

802796
# map each new level to its ref code

src/deprecated.jl

Lines changed: 0 additions & 18 deletions
This file was deleted.

src/extras.jl

Lines changed: 25 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,9 @@ function fill_refs!(refs::AbstractArray, X::AbstractArray,
2727
end
2828
end
2929

30-
const CUT_FMT = Printf.Format("%.*g")
30+
if VERSION >= v"1.10"
31+
const CUT_FMT = Printf.Format("%.*g")
32+
end
3133

3234
"""
3335
CategoricalArrays.default_formatter(from, to, i::Integer;
@@ -44,12 +46,21 @@ If they are floating points values, breaks are turned into to strings using
4446
function default_formatter(from, to, i::Integer;
4547
leftclosed::Bool, rightclosed::Bool,
4648
sigdigits::Integer)
47-
from_str = from isa AbstractFloat ?
48-
Printf.format(CUT_FMT, sigdigits, from) :
49-
string(from)
50-
to_str = to isa AbstractFloat ?
51-
Printf.format(CUT_FMT, sigdigits, to) :
52-
string(to)
49+
@static if VERSION >= v"1.10"
50+
from_str = from isa AbstractFloat ?
51+
Printf.format(CUT_FMT, sigdigits, from) :
52+
string(from)
53+
to_str = to isa AbstractFloat ?
54+
Printf.format(CUT_FMT, sigdigits, to) :
55+
string(to)
56+
else
57+
from_str = from isa AbstractFloat ?
58+
Printf.format(Printf.Format("%.$(sigdigits)g"), from) :
59+
string(from)
60+
to_str = to isa AbstractFloat ?
61+
Printf.format(Printf.Format("%.$(sigdigits)g"), to) :
62+
string(to)
63+
end
5364
string(leftclosed ? "[" : "(", from_str, ", ", to_str, rightclosed ? "]" : ")")
5465
end
5566

@@ -164,19 +175,7 @@ julia> cut(-1:0.5:1, 3, labels=fmt)
164175
extend::Union{Bool, Missing}=false,
165176
labels::Union{AbstractVector{<:SupportedTypes},Function}=default_formatter,
166177
sigdigits::Integer=3,
167-
allowmissing::Union{Bool, Nothing}=nothing,
168-
allow_missing::Union{Bool, Nothing}=nothing,
169178
allowempty::Bool=false)
170-
if allow_missing !== nothing
171-
Base.depwarn("allow_missing argument is deprecated, use extend=missing instead",
172-
:cut)
173-
extend = missing
174-
end
175-
if allowmissing !== nothing
176-
Base.depwarn("allowmissing argument is deprecated, use extend=missing instead",
177-
:cut)
178-
extend = missing
179-
end
180179
return _cut(x, breaks, extend, labels, sigdigits, allowempty)
181180
end
182181

@@ -251,8 +250,13 @@ function _cut(x::AbstractArray{T, N}, breaks::AbstractVector,
251250
b2 = breaks[i]
252251
isequal(b1, b2) && continue
253252

254-
b1_str = Printf.format(CUT_FMT, sigdigits, b1)
255-
b2_str = Printf.format(CUT_FMT, sigdigits, b2)
253+
@static if VERSION >= v"1.9"
254+
b1_str = Printf.format(CUT_FMT, sigdigits, b1)
255+
b2_str = Printf.format(CUT_FMT, sigdigits, b2)
256+
else
257+
b1_str = Printf.format(Printf.Format("%.$(sigdigits)g"), b1)
258+
b2_str = Printf.format(Printf.Format("%.$(sigdigits)g"), b2)
259+
end
256260
if b1_str == b2_str
257261
sigdigits += 1
258262
break

test/05_convert.jl

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -55,9 +55,9 @@ using CategoricalArrays: DefaultRefType, refcode, reftype, leveltype
5555
@test convert(Union{T, U}, v3)::T == v3
5656
end
5757

58-
@test unwrap(v1) === get(v1) === 1
59-
@test unwrap(v2) === get(v2) === 2
60-
@test unwrap(v3) === get(v3) === 3
58+
@test unwrap(v1) === 1
59+
@test unwrap(v2) === 2
60+
@test unwrap(v3) === 3
6161

6262
@test promote(1, v1) === (1, 1)
6363
@test promote(1.0, v1) === (1.0, 1.0)

test/11_array.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -719,7 +719,7 @@ using CategoricalArrays: DefaultRefType, leveltype
719719
@test levels(x) == ["c", "a", "b"]
720720

721721
ordered!(x, ordered)
722-
v = CategoricalValue(2, CategoricalPool(["xyz", "b"]))
722+
v = CategoricalValue(CategoricalPool(["xyz", "b"]), 2)
723723
x[1] = v
724724
@test x[1] === CategoricalValue(x.pool, 4)
725725
@test x[2] === CategoricalValue(x.pool, 1)

test/13_arraycommon.jl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ using PooledArrays
88
using JSON3
99
using StructTypes
1010
using RecipesBase
11-
using Plots
11+
using RecipesPipeline
1212
using SentinelArrays
1313
using Arrow
1414
using Missings
@@ -893,7 +893,7 @@ end
893893
@test sort(cv, rev=rev, by=byf1) sort(cv, rev=rev, by=byf1)
894894

895895
# Check that by function is not called on unused levels/missing
896-
byf2 = x -> (@assert get(x) != "b"; x)
896+
byf2 = x -> (@assert x != "b"; x)
897897
replace!(cv, missing=>"a", "b"=>"a")
898898
@test sort(cv, rev=rev, by=byf2) sort(cv, rev=rev, by=byf2)
899899
end

test/17_deprecated.jl

Lines changed: 0 additions & 16 deletions
This file was deleted.

0 commit comments

Comments
 (0)