From 3cfa088d85533d96a6e27dda79cdb211f67ce113 Mon Sep 17 00:00:00 2001 From: "Anthony Blaom, PhD" Date: Wed, 27 Oct 2021 16:03:10 +1300 Subject: [PATCH] Add scitype overloading, formerly living at ScientificTypes 2.3.1 (#47) * add scitype overloading, formerly living at ScientificTypes 2.3.1 * add forotten files * Update src/scitypes.jl Co-authored-by: mtsch Co-authored-by: mtsch --- Project.toml | 2 ++ src/PersistenceDiagrams.jl | 2 ++ src/scitypes.jl | 3 +++ test/runtests.jl | 3 +++ test/scitypes.jl | 10 ++++++++++ 5 files changed, 20 insertions(+) create mode 100644 src/scitypes.jl create mode 100644 test/scitypes.jl diff --git a/Project.toml b/Project.toml index 9358705..de3dc38 100644 --- a/Project.toml +++ b/Project.toml @@ -9,6 +9,7 @@ Hungarian = "e91730f6-4275-51fb-a7a0-7064cfbd3b39" MLJModelInterface = "e80e1ace-859a-464e-9ed9-23947d8ae3ea" PersistenceDiagramsBase = "b1ad91c1-539c-4ace-90bd-ea06abc420fa" RecipesBase = "3cdcf5f2-1ef4-517c-9805-6587b60abb01" +ScientificTypes = "321657f4-b219-11e9-178b-2701a2544e81" Statistics = "10745b16-79ce-11e8-11f9-7d13ad32a3b2" Tables = "bd369af6-aec1-5ad0-b16a-f7cc5008161c" @@ -18,6 +19,7 @@ Hungarian = "0.6" MLJModelInterface = "^0.3.5, 0.4, 1" PersistenceDiagramsBase = "^0.1.1" RecipesBase = "1" +ScientificTypes = "2.3.2" Tables = "1" julia = "1" diff --git a/src/PersistenceDiagrams.jl b/src/PersistenceDiagrams.jl index a598ecc..a30cb51 100644 --- a/src/PersistenceDiagrams.jl +++ b/src/PersistenceDiagrams.jl @@ -44,6 +44,7 @@ using PersistenceDiagramsBase using RecipesBase using Statistics using Tables +import ScientificTypes include("matching.jl") @@ -52,6 +53,7 @@ include("persistenceimages.jl") include("plotsrecipes.jl") +include("scitypes.jl") include("mlj.jl") end diff --git a/src/scitypes.jl b/src/scitypes.jl new file mode 100644 index 0000000..2f948d7 --- /dev/null +++ b/src/scitypes.jl @@ -0,0 +1,3 @@ +const ST = ScientificTypes + +ST.scitype(::PersistenceDiagram, ::ST.DefaultConvention; kwargs...) = PersistenceDiagram diff --git a/test/runtests.jl b/test/runtests.jl index 7b4847a..ca03c31 100644 --- a/test/runtests.jl +++ b/test/runtests.jl @@ -10,6 +10,9 @@ end @safetestset "persistenceimages" begin include("persistenceimages.jl") end +@safetestset "scitypes" begin + include("scitypes.jl") +end @safetestset "mlj" begin include("mlj.jl") end diff --git a/test/scitypes.jl b/test/scitypes.jl new file mode 100644 index 0000000..a1cc919 --- /dev/null +++ b/test/scitypes.jl @@ -0,0 +1,10 @@ +using PersistenceDiagrams +using ScientificTypes + +diagram = PersistenceDiagram([(1, Inf), (2, 3)], dim=0) +@test scitype(diagram) == PersistenceDiagram + +diagrams = [diagram, diagram, diagram] +@test scitype(diagrams) == AbstractVector{PersistenceDiagram} + +true