Skip to content

Commit

Permalink
Add Tensorial scitype (#15)
Browse files Browse the repository at this point in the history
* Add Tensorial scitype

* Add more tests

* Update CI.yml
  • Loading branch information
juliohm committed Jun 5, 2024
1 parent 5f9fbde commit 7b93ac5
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 1 deletion.
4 changes: 3 additions & 1 deletion .github/workflows/CI.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,11 @@ jobs:
matrix:
version:
- '1.9'
- 'nightly'
- '1'
os:
- ubuntu-latest
- macos-latest
- windows-latest
arch:
- x64
steps:
Expand Down
8 changes: 8 additions & 0 deletions src/DataScienceTraits.jl
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,13 @@ Scientific type of geometrical data (See Meshes.jl)
"""
abstract type Geometrical <: SciType end

"""
Tensorial
Scientific type of tensorial data (e.g. Vector, Matrix)
"""
abstract type Tensorial <: SciType end

"""
Temporal
Expand Down Expand Up @@ -114,6 +121,7 @@ scitype(::Type{<:Number}) = Continuous
scitype(::Type{<:Integer}) = Categorical
scitype(::Type{<:AbstractChar}) = Categorical
scitype(::Type{<:AbstractString}) = Categorical
scitype(::Type{<:AbstractArray}) = Tensorial
scitype(::Type{<:TimeType}) = Temporal
scitype(::Type{Union{T,Missing}}) where {T} = scitype(T)

Expand Down
8 changes: 8 additions & 0 deletions test/runtests.jl
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,14 @@ const DST = DataScienceTraits
@test scitype('a') <: DST.Categorical
@test scitype("a") <: DST.Categorical

# Tensorial
@test scitype(Vector) <: DST.Tensorial
@test scitype(Matrix) <: DST.Tensorial
@test scitype(Array) <: DST.Tensorial
@test scitype(rand(2)) <: DST.Tensorial
@test scitype(rand(2, 2)) <: DST.Tensorial
@test scitype(rand(2, 2, 2)) <: DST.Tensorial

# Unknown
@test scitype(Nothing) <: DST.Unknown
@test scitype(Union{}) <: DST.Unknown
Expand Down

0 comments on commit 7b93ac5

Please sign in to comment.