Skip to content

Commit 51efa9e

Browse files
authored
Merge pull request #113 from alan-turing-institute/dev
For a 1.0 release
2 parents d07353b + 2d56d0d commit 51efa9e

File tree

6 files changed

+17
-7
lines changed

6 files changed

+17
-7
lines changed

Project.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
name = "ScientificTypes"
22
uuid = "321657f4-b219-11e9-178b-2701a2544e81"
33
authors = ["Anthony D. Blaom <[email protected]>"]
4-
version = "0.8.1"
4+
version = "1.0"
55

66
[compat]
77
julia = "1"

README.md

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -107,8 +107,8 @@ The type parameter `K` in `Table{K}` is for conveying the scientific
107107
type(s) of a table's columns. See [More on the `Table`
108108
type](#more-on-the-table-type).
109109

110-
The julia native `Missing` type is also regarded as a scientific
111-
type.
110+
The julia native types `Missing` and `Nothing` are also regarded as scientific
111+
types.
112112

113113
#### 2. The `scitype` and `Scitype` methods
114114

@@ -133,7 +133,9 @@ appropriately. However, this package provides certain rudimentary
133133
fallback behaviour; only Property 1 below should be altered by the
134134
developer:
135135

136-
**Property 0.** `scitype(missing) = Missing` (`Missing` is the only native type also regarded as a scientific type).
136+
**Property 0.** `scitype(missing) = Missing` and `scitype(nothing) =
137+
Nothing` (regarding `Missing` and `Nothing` as native scientific
138+
types).
137139

138140
**Property 1.** `scitype(X) = Unknown`, unless `X` is a tuple, an
139141
abstract array, or `missing`.

src/ScientificTypes.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -129,7 +129,7 @@ Table(S1, S2, ..., Sn) <: Table
129129
where `S1, ..., Sn` are the scientific type of the table's columns which
130130
are expected to be represented by abstract vectors.
131131
"""
132-
Table(Ts::Type{<:Scientific}...) = Table{<:Union{(Arr{<:T,1} for T in Ts)...}}
132+
Table(Ts::Type...) = Table{<:Union{(Arr{<:T,1} for T in Ts)...}}
133133

134134
# -----------------------------------------------------------------
135135
# scitype

src/scitype.jl

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@ scitype(X, C; kw...) = scitype(X, C, Val(trait(X)); kw...)
3939

4040
scitype(X, C, ::Val{:other}; kw...) = Unknown
4141
scitype(::Missing; kw...) = Missing
42+
scitype(::Nothing; kw...) = Nothing
4243

4344
scitype(t::Tuple, ::Convention; kw...) = Tuple{scitype.(t; kw...)...}
4445

@@ -106,6 +107,8 @@ Scitype(::Type{Union{T,Missing}}, C::Convention) where T =
106107
# for the case Missing, we return Missing
107108
Scitype(::Type{Missing}, C::Convention) = Missing
108109

110+
Scitype(::Type{Nothing}, C::Convention) = Nothing
111+
109112
# Broadcasting over arrays
110113

111114
scitype(A::Arr{T}, C::Convention, ::Val{:other}; kw...) where T =
@@ -120,7 +123,7 @@ If `tight=true` and `T>:Missing` then the function checks whether there are
120123
"true missing values", otherwise it constructs a "tight copy" of the array
121124
without a `Union{Missing,S}` type.
122125
"""
123-
function arr_scitype(A::Arr{T,N}, C::Convention, S::Type{<:Scientific};
126+
function arr_scitype(A::Arr{T,N}, C::Convention, S::Type;
124127
tight::Bool=false) where {T,N}
125128
# no explicit scitype available
126129
S === Unknown && return Arr{scitype_union(A),N}

test/convention.jl

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,5 +37,4 @@ end
3737
@test T1 == Table{K} where K<:Union{AbstractVector{<:Continuous}, AbstractVector{<:Count}}
3838
T2 = Table(Continuous, Union{Missing,Continuous})
3939
@test T2 == Table{K} where K<:Union{AbstractVector{<:Union{Missing,Continuous}}}
40-
@test_throws MethodError Table(Int,Float64)
4140
end

test/scitype.jl

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,9 @@
1+
@testset "void types" begin
2+
@test scitype(nothing) == Nothing
3+
@test scitype(missing) == Missing
4+
@test scitype([nothing, nothing]) == AbstractVector{Nothing}
5+
end
6+
17
@testset "scitype" begin
28
X = [1, 2, 3]
39
@test scitype(X) == AbstractVector{Unknown}

0 commit comments

Comments
 (0)