From 126c9e6a22ea081c678ed57c2b011dbe3b852085 Mon Sep 17 00:00:00 2001 From: "Anthony D. Blaom" Date: Fri, 6 Mar 2020 12:30:58 +1300 Subject: [PATCH 1/2] add Time, Day, Instant --- README.md | 49 ++++++++++++++++++++++++++---------------- src/ScientificTypes.jl | 24 ++++++--------------- 2 files changed, 37 insertions(+), 36 deletions(-) diff --git a/README.md b/README.md index b5beb09..5b16abe 100644 --- a/README.md +++ b/README.md @@ -51,25 +51,32 @@ places on the actual machine type of the data supplied. #### 1. Scientific types -ScientificTypes provides a hierarchy of Julia types -representing data types for use in method dispatch (e.g., for trait -values). Instances of the types play no role. +ScientificTypes provides new julia types signifying "scientific type" +for use in method dispatch (e.g., for trait values). Instances of the +types play no role. ``` -Found -├─ Known -│ ├─ Finite -│ │ ├─ Multiclass -│ │ └─ OrderedFactor -│ ├─ Infinite -│ │ ├─ Continuous -│ │ └─ Count -│ ├─ Image -│ │ ├─ ColorImage -│ │ └─ GrayImage -│ ├─ Table -│ └─ Textual -└─ Unknown +Finite{N} +├─ Multiclass{N} +└─ OrderedFactor{N} + +Infinite +├─ Continuous +└─ Count + +Image{W,H} +├─ ColorImage{W,H} +└─ GrayImage{W,H} + +Time +├─ Day +└─ Instant + +Table{K} + +Textual + +Unknown ``` The types `Finite{N}`, `Multiclass{N}` and `OrderedFactor{N}` are all @@ -77,8 +84,12 @@ parametrised by the number of levels `N`, while `Image{W,H}`, `GrayImage{W,H}` and `ColorImage{W,H}` are all parametrised by the image width and height dimensions, `(W, H)`. -The `Table` type also has a type parameter, for conveying the -scientific type(s) of table columns. See [More on the `Table` +The `Day` type is intended for dates (respresented, for example, by +julia's `Date.Date` type) while `Instant` is intended for finer +measurements of time (such as those represented by Date.DateTime`). + +The type parameter `K` in `Table{K}` is for conveying the scientific +type(s) of a table's columns. See [More on the `Table` type](#more-on-the-table-type). The julia native `Missing` type is also regarded as a scientific diff --git a/src/ScientificTypes.jl b/src/ScientificTypes.jl index e806ee4..b3b417b 100644 --- a/src/ScientificTypes.jl +++ b/src/ScientificTypes.jl @@ -5,8 +5,9 @@ export Convention # re-export-able types and methods export Scientific, Found, Unknown, Known, Finite, Infinite, - OrderedFactor, Multiclass, Count, Continuous, Textual, - Binary, ColorImage, GrayImage, Image, Table + OrderedFactor, Multiclass, Count, Continuous, + Time, Day, Instant, Textual, Binary, + ColorImage, GrayImage, Image, Table export scitype, scitype_union, elscitype, nonmissing, trait # utils (should not be re-exported) @@ -14,21 +15,6 @@ export TRAIT_FUNCTION_GIVEN_NAME, set_convention # ------------------------------------------------------------------- # Scientific Types -# -# Found -# ├─ Known -# │ ├─ Finite -# │ │ ├─ Multiclass -# │ │ └─ OrderedFactor -# │ ├─ Infinite -# │ │ ├─ Continuous -# │ │ └─ Count -# │ ├─ Image -# │ │ ├─ ColorImage -# │ │ └─ GrayImage -# │ └─ Textual -# └─ Unknown -# abstract type Found end abstract type Known <: Found end @@ -37,6 +23,7 @@ struct Unknown <: Found end abstract type Infinite <: Known end abstract type Finite{N} <: Known end abstract type Image{W,H} <: Known end +abstract type Time <: Known end struct Textual <: Known end struct Table{K} <: Known end @@ -46,6 +33,9 @@ struct Count <: Infinite end struct Multiclass{N} <: Finite{N} end struct OrderedFactor{N} <: Finite{N} end +struct Day <: Time end +struct Instant <: Time end + struct GrayImage{W,H} <: Image{W,H} end struct ColorImage{W,H} <: Image{W,H} end From c997016aefc20417a051e66391a6e48ce0800916 Mon Sep 17 00:00:00 2001 From: "Anthony D. Blaom" Date: Fri, 6 Mar 2020 12:34:20 +1300 Subject: [PATCH 2/2] bump 0.7.2 --- Project.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Project.toml b/Project.toml index 7f587b2..96433e0 100644 --- a/Project.toml +++ b/Project.toml @@ -1,7 +1,7 @@ name = "ScientificTypes" uuid = "321657f4-b219-11e9-178b-2701a2544e81" authors = ["Anthony D. Blaom "] -version = "0.7.1" +version = "0.7.2" [compat] julia = "1"