Skip to content

Commit 6cefc53

Browse files
authored
Merge pull request #28 from JuliaAI/dev
For a 0.1.6 release
2 parents 4aa9cdb + b3eb286 commit 6cefc53

File tree

8 files changed

+48
-7
lines changed

8 files changed

+48
-7
lines changed

Project.toml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,23 @@
11
name = "CategoricalDistributions"
22
uuid = "af321ab8-2d2e-40a6-b165-3d674595d28e"
33
authors = ["Anthony D. Blaom <[email protected]>"]
4-
version = "0.1.5"
4+
version = "0.1.6"
55

66
[deps]
77
CategoricalArrays = "324d7699-5711-5eae-9e2f-1d82baa6b597"
88
Distributions = "31c24e10-a181-5473-b8eb-7969acd0382f"
99
Missings = "e1d29d7a-bbdc-5cf2-9ac0-f12de2c33e28"
1010
OrderedCollections = "bac558e1-5e72-5ebc-8fee-abe8a469f55d"
1111
Random = "9a3f8284-a2c9-5f02-9a11-845980a1fd5c"
12-
ScientificTypesBase = "30f210dd-8aff-4c5f-94ba-8e64358c1161"
12+
ScientificTypes = "321657f4-b219-11e9-178b-2701a2544e81"
1313
UnicodePlots = "b8865327-cd53-5732-bb35-84acbb429228"
1414

1515
[compat]
1616
CategoricalArrays = "0.9, 0.10"
1717
Distributions = "0.25"
1818
Missings = "0.4, 1"
1919
OrderedCollections = "1.1"
20-
ScientificTypesBase = "2, 3"
20+
ScientificTypes = "3.0"
2121
UnicodePlots = "2"
2222
julia = "1.3"
2323

src/CategoricalDistributions.jl

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,14 @@
11
module CategoricalDistributions
22

33
import Distributions
4-
import ScientificTypesBase: Finite, Multiclass, OrderedFactor
4+
import ScientificTypes:
5+
Finite,
6+
Multiclass,
7+
OrderedFactor,
8+
DefaultConvention,
9+
Density,
10+
ScientificTypesBase
11+
512
using OrderedCollections
613
using CategoricalArrays
714
import Missings
@@ -15,6 +22,7 @@ import Distributions: pdf, logpdf, support, mode
1522

1623
include("utilities.jl")
1724
include("types.jl")
25+
include("scitypes.jl")
1826
include("methods.jl")
1927
include("arrays.jl")
2028
include("arithmetic.jl")

src/scitypes.jl

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
const STB = ScientificTypesBase
2+
3+
STB.scitype(::UnivariateFinite{S}, ::DefaultConvention) where S = Density{S}
4+
STB.scitype(
5+
::UnivariateFiniteArray{S,V,R,P,N},
6+
::DefaultConvention
7+
) where {S,V,R,P,N} = AbstractArray{Density{S},N}
8+
9+
# For performance for ordinary arrays of `UnivariateFinite` elements:
10+
STB.Scitype(::Type{<:UnivariateFinite{S}}, ::DefaultConvention) where S =
11+
Density{S}

test/arrays.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ import Distributions
88
using StableRNGs
99
import Random
1010
using Missings
11-
using ScientificTypesBase
11+
using ScientificTypes
1212

1313
import CategoricalDistributions: classes
1414
import CategoricalArrays.unwrap

test/methods.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ import Distributions
77
using StableRNGs
88
import Random
99
rng = StableRNG(123)
10-
using ScientificTypesBase
10+
using ScientificTypes
1111

1212
import CategoricalDistributions: classes
1313

test/runtests.jl

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ using CategoricalDistributions
33
using CategoricalArrays
44
using Distributions
55
using Random
6+
using ScientificTypes
67
using StableRNGs # for RNGs stable across all julia versions
78
rng = StableRNGs.StableRNG(123)
89

@@ -16,6 +17,10 @@ end
1617
@test include("types.jl")
1718
end
1819

20+
@testset "scitypes" begin
21+
@test include("scitypes.jl")
22+
end
23+
1924
@testset "methods" begin
2025
@test include("methods.jl")
2126
end

test/scitypes.jl

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
@testset "scitype" begin
2+
d = UnivariateFinite([0.1, 0.2, 0.7], pool=missing)
3+
@test scitype(d) == Density{Multiclass{3}}
4+
d2 = UnivariateFinite([0.1, 0.2, 0.7], pool=missing, ordered=true)
5+
@test scitype(d2) == Density{OrderedFactor{3}}
6+
d = UnivariateFinite(rand(3), pool=missing)
7+
8+
v = UnivariateFinite(rand(3), augment=true, pool=missing)
9+
@test scitype(v) == AbstractVector{Density{Multiclass{2}}}
10+
v2 = UnivariateFinite(rand(3), augment=true, pool=missing, ordered=true)
11+
@test scitype(v2) == AbstractVector{Density{OrderedFactor{2}}}
12+
13+
@test scitype([d, d]) == AbstractVector{Density{Multiclass{3}}}
14+
@test scitype([d2, d2]) == AbstractVector{Density{OrderedFactor{3}}}
15+
end
16+
17+
true

test/types.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ using Test
44
using CategoricalDistributions
55
using CategoricalArrays
66
using StableRNGs
7-
using ScientificTypesBase
7+
using ScientificTypes
88
import Random
99

1010
# coverage of constructor testing is expanded in the other test files

0 commit comments

Comments
 (0)