Skip to content

Commit

Permalink
Merge pull request #175 from linkml/update_array_metamodel
Browse files Browse the repository at this point in the history
Update array metamodel and examples
  • Loading branch information
cmungall authored Jan 29, 2024
2 parents 986f692 + e91e36f commit dc1dd29
Show file tree
Hide file tree
Showing 3 changed files with 212 additions and 152 deletions.
159 changes: 30 additions & 129 deletions linkml_model/model/schema/array.yaml
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
id: https://w3id.org/linkml/lib/arrays
name: arrays
title: LinkML Arrays
description: >-
description: >-
LinkML templates for storing one-dimensional series, two-dimensional arrays,
and arrays of higher dimensionality.
Status: Experimental
Note that this model is not intended to be imported directly. Instead,
use `implements` to denote conformance.
status: testing
# contributors:
# - github:rly
Expand Down Expand Up @@ -39,13 +39,13 @@ classes:
DataStructure:
abstract: true

Array:
NDArray:
description: >-
a data structure consisting of a collection of *elements*, each identified by at least one array index tuple.
abstract: true
is_a: DataStructure
slots:
- dimensionality
- dimensions
- elements
- array_linearization_order
slot_usage:
Expand All @@ -55,169 +55,72 @@ classes:
an ordered sequence of values. The elements also have an *array interpretation*, where each
element has a unique index which is determined by array_linearization_order
OneDimensionalSeries:
is_a: Array
description: >-
An array that has one dimension
aliases:
- axis
- 1D array
- vector
- series
- row
slots:
- series_label
- length
# TODO: consider offset and rate
slot_usage:
dimensionality:
equals_expression: "1"

TwoDimensionalArray:
is_a: Array
description: >-
An array that has two dimensions
aliases:
- table
- matrix
- grid
slots:
- axis0
- axis1
slot_usage:
dimensionality:
equals_expression: "2"
elements:
description: >-
this will be serialized as one big long list that should be interpreted as a 2D array
ThreeDimensionalArray:
is_a: Array
DataArray:
description: >-
An array that has two dimensions
aliases:
- 3D array
a data structure containing an NDArray and a set of one-dimensional series that are used to label
the elements of the array
is_a: DataStructure
slots:
- axis0
- axis1
- axis2
slot_usage:
dimensionality:
equals_expression: "3"
- axis
- array

OrderedArray:
GroupingByArrayOrder:
mixin: true
description: >-
A mixin that describes an array whose elements are mapped from a linear sequence to an array index
via a specified mapping
ColumnOrderedArray:
mixin: true
is_a: GroupingByArrayOrder
description: >-
An array ordering that is column-order
slots:
- array_linearization_order
slot_usage:
array_linearization_order:
equals_string: COLUMN_MAJOR_ARRAY_ORDER

RowOrderedArray:
mixin: true
is_a: GroupingByArrayOrder
description: >-
An array ordering that is row-order or generalizations thereof
slots:
- array_linearization_order
slot_usage:
array_linearization_order:
equals_string: ROW_MAJOR_ARRAY_ORDER

MultiDimensionalArray:
is_a: Array
abstract: true
description: >-
An array that has more than two dimensions
ObjectAsTuple:
comments:
- not modeled as an array since this is used as a metaclass
implements:
- OneDimensionalSeries

ArrayIndex:
is_a: ObjectAsTuple

Operation:
abstract: true
description: >-
Represents the transformation of one or more inputs to one or more outputs determined by
zero to many operation parameters
slots:
- specified_input
- specified_output
- operation_parameters

ArrayIndexOperation:
description: >-
An operation that takes as input an Array and is parameterized by an array index tuple and
yields an array element
slot_usage:
specified_input:
range: Array
maximum_cardinality: 1
specified_output:
range: Any
maximum_cardinality: 1
operation_parameters:
range: ArrayIndex
maximum_cardinality: 1

slots:
dimensionality:
dimensions:
description: >-
The number of elements in the tuple used to access elements of an array
aliases:
- rank
- dimension
- dimensionality
- number of axes
- number of elements
range: integer
axis:
abstract: true
range: OneDimensionalSeries
range: NDArray
slot_usage:
dimensions:
equals_number: 1
aliases:
- dimension
description: >-
A one dimensional series that contains elements that form one part of a tuple used to access an array
axis0:
is_a: axis
aliases:
- dimension0
description: >-
An axis that is the zeroth index of the tuple used to access an array
range: OneDimensionalSeries
rank: 0
A one-dimensional series that contains elements that form one part of a tuple used to access an array
required: true
inlined: true
inlined_as_list: true
axis1:
is_a: axis
axis_index:
range: integer
description: >-
An axis that is the index after the zeroth of the tuple used to access an array
range: OneDimensionalSeries
rank: 1
required: true
inlined: true
inlined_as_list: true
axis2:
is_a: axis
aliases:
- z
range: OneDimensionalSeries
rank: 2
The position of an axis in a tuple used to access an array
array:
range: NDArray
description: >-
An array that is labeled by a set of one-dimensional series
required: true
inlined: true
inlined_as_list: true
elements:
# this will be serialized as one big long list that should be interpreted as a 2D array
range: Any
Expand Down Expand Up @@ -251,7 +154,7 @@ slots:
operation_parameters:
range: Any
multivalued: true

enums:
ArrayLinearizationOrderOptions:
description: >-
Expand All @@ -272,5 +175,3 @@ enums:
or any generalization thereof to dimensionality greater than 2
aliases:
- C order


118 changes: 118 additions & 0 deletions tests/input/examples/schema_definition-array-1.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,118 @@
id: https://example.org/arrays
name: arrays-temperature-example
title: Array Temperature Example
description: |-
Example LinkML schema to demonstrate a 3D DataArray of temperature values with labeled axes
license: MIT

prefixes:
linkml: https://w3id.org/linkml/
wgs84: http://www.w3.org/2003/01/geo/wgs84_pos#
example: https://example.org/

default_prefix: example

imports:
- linkml:types

classes:

TemperatureDataset:
tree_root: true
implements:
- linkml:DataArray
attributes:
name:
identifier: true
range: string
latitude_in_deg:
implements:
- linkml:axis
range: LatitudeSeries
required: true
annotations:
axis_index: 0
longitude_in_deg:
implements:
- linkml:axis
range: LongitudeSeries
required: true
annotations:
axis_index: 1
time_in_d:
implements:
- linkml:axis
range: DaySeries
required: true
annotations:
axis_index: 2
temperatures_in_K:
implements:
- linkml:array
range: TemperatureMatrix
required: true

TemperatureMatrix:
description: A 3D array of temperatures
implements:
- linkml:NDArray
- linkml:RowOrderedArray
attributes:
values:
range: float
multivalued: true
implements:
- linkml:elements
required: true
unit:
ucum_code: K
annotations:
dimensions: 3

LatitudeSeries:
description: A series whose values represent latitude
implements:
- linkml:NDArray
attributes:
values:
range: float
multivalued: true
implements:
- linkml:elements
required: true
unit:
ucum_code: deg
annotations:
dimensions: 1

LongitudeSeries:
description: A series whose values represent longitude
implements:
- linkml:NDArray
attributes:
values:
range: float
multivalued: true
implements:
- linkml:elements
required: true
unit:
ucum_code: deg
annotations:
dimensions: 1

DaySeries:
description: A series whose values represent the days since the start of the measurement period
implements:
- linkml:NDArray
attributes:
values:
range: float
multivalued: true
implements:
- linkml:elements
required: true
unit:
ucum_code: d
annotations:
dimensions: 1
Loading

0 comments on commit dc1dd29

Please sign in to comment.