Skip to content

Commit dc1dd29

Browse files
authored
Merge pull request #175 from linkml/update_array_metamodel
Update array metamodel and examples
2 parents 986f692 + e91e36f commit dc1dd29

File tree

3 files changed

+212
-152
lines changed

3 files changed

+212
-152
lines changed
Lines changed: 30 additions & 129 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,15 @@
11
id: https://w3id.org/linkml/lib/arrays
22
name: arrays
33
title: LinkML Arrays
4-
description: >-
4+
description: >-
55
LinkML templates for storing one-dimensional series, two-dimensional arrays,
66
and arrays of higher dimensionality.
77
88
Status: Experimental
99
1010
Note that this model is not intended to be imported directly. Instead,
1111
use `implements` to denote conformance.
12-
12+
1313
status: testing
1414
# contributors:
1515
# - github:rly
@@ -39,13 +39,13 @@ classes:
3939
DataStructure:
4040
abstract: true
4141

42-
Array:
42+
NDArray:
4343
description: >-
4444
a data structure consisting of a collection of *elements*, each identified by at least one array index tuple.
4545
abstract: true
4646
is_a: DataStructure
4747
slots:
48-
- dimensionality
48+
- dimensions
4949
- elements
5050
- array_linearization_order
5151
slot_usage:
@@ -55,169 +55,72 @@ classes:
5555
an ordered sequence of values. The elements also have an *array interpretation*, where each
5656
element has a unique index which is determined by array_linearization_order
5757
58-
59-
OneDimensionalSeries:
60-
is_a: Array
61-
description: >-
62-
An array that has one dimension
63-
aliases:
64-
- axis
65-
- 1D array
66-
- vector
67-
- series
68-
- row
69-
slots:
70-
- series_label
71-
- length
72-
# TODO: consider offset and rate
73-
slot_usage:
74-
dimensionality:
75-
equals_expression: "1"
76-
77-
TwoDimensionalArray:
78-
is_a: Array
79-
description: >-
80-
An array that has two dimensions
81-
aliases:
82-
- table
83-
- matrix
84-
- grid
85-
slots:
86-
- axis0
87-
- axis1
88-
slot_usage:
89-
dimensionality:
90-
equals_expression: "2"
91-
elements:
92-
description: >-
93-
this will be serialized as one big long list that should be interpreted as a 2D array
94-
95-
ThreeDimensionalArray:
96-
is_a: Array
58+
DataArray:
9759
description: >-
98-
An array that has two dimensions
99-
aliases:
100-
- 3D array
60+
a data structure containing an NDArray and a set of one-dimensional series that are used to label
61+
the elements of the array
62+
is_a: DataStructure
10163
slots:
102-
- axis0
103-
- axis1
104-
- axis2
105-
slot_usage:
106-
dimensionality:
107-
equals_expression: "3"
64+
- axis
65+
- array
10866

109-
OrderedArray:
67+
GroupingByArrayOrder:
11068
mixin: true
11169
description: >-
11270
A mixin that describes an array whose elements are mapped from a linear sequence to an array index
11371
via a specified mapping
114-
72+
11573
ColumnOrderedArray:
11674
mixin: true
75+
is_a: GroupingByArrayOrder
11776
description: >-
11877
An array ordering that is column-order
11978
slots:
12079
- array_linearization_order
12180
slot_usage:
12281
array_linearization_order:
12382
equals_string: COLUMN_MAJOR_ARRAY_ORDER
124-
83+
12584
RowOrderedArray:
12685
mixin: true
86+
is_a: GroupingByArrayOrder
12787
description: >-
12888
An array ordering that is row-order or generalizations thereof
12989
slots:
13090
- array_linearization_order
13191
slot_usage:
13292
array_linearization_order:
13393
equals_string: ROW_MAJOR_ARRAY_ORDER
134-
135-
MultiDimensionalArray:
136-
is_a: Array
137-
abstract: true
138-
description: >-
139-
An array that has more than two dimensions
140-
141-
ObjectAsTuple:
142-
comments:
143-
- not modeled as an array since this is used as a metaclass
144-
implements:
145-
- OneDimensionalSeries
146-
147-
ArrayIndex:
148-
is_a: ObjectAsTuple
14994

150-
Operation:
151-
abstract: true
152-
description: >-
153-
Represents the transformation of one or more inputs to one or more outputs determined by
154-
zero to many operation parameters
155-
slots:
156-
- specified_input
157-
- specified_output
158-
- operation_parameters
159-
160-
ArrayIndexOperation:
161-
description: >-
162-
An operation that takes as input an Array and is parameterized by an array index tuple and
163-
yields an array element
164-
slot_usage:
165-
specified_input:
166-
range: Array
167-
maximum_cardinality: 1
168-
specified_output:
169-
range: Any
170-
maximum_cardinality: 1
171-
operation_parameters:
172-
range: ArrayIndex
173-
maximum_cardinality: 1
174-
17595
slots:
176-
dimensionality:
96+
dimensions:
17797
description: >-
17898
The number of elements in the tuple used to access elements of an array
17999
aliases:
180100
- rank
181-
- dimension
101+
- dimensionality
182102
- number of axes
183103
- number of elements
184104
range: integer
185105
axis:
186-
abstract: true
187-
range: OneDimensionalSeries
106+
range: NDArray
107+
slot_usage:
108+
dimensions:
109+
equals_number: 1
188110
aliases:
189111
- dimension
190112
description: >-
191-
A one dimensional series that contains elements that form one part of a tuple used to access an array
192-
axis0:
193-
is_a: axis
194-
aliases:
195-
- dimension0
196-
description: >-
197-
An axis that is the zeroth index of the tuple used to access an array
198-
range: OneDimensionalSeries
199-
rank: 0
113+
A one-dimensional series that contains elements that form one part of a tuple used to access an array
200114
required: true
201-
inlined: true
202-
inlined_as_list: true
203-
axis1:
204-
is_a: axis
115+
axis_index:
116+
range: integer
205117
description: >-
206-
An axis that is the index after the zeroth of the tuple used to access an array
207-
range: OneDimensionalSeries
208-
rank: 1
209-
required: true
210-
inlined: true
211-
inlined_as_list: true
212-
axis2:
213-
is_a: axis
214-
aliases:
215-
- z
216-
range: OneDimensionalSeries
217-
rank: 2
118+
The position of an axis in a tuple used to access an array
119+
array:
120+
range: NDArray
121+
description: >-
122+
An array that is labeled by a set of one-dimensional series
218123
required: true
219-
inlined: true
220-
inlined_as_list: true
221124
elements:
222125
# this will be serialized as one big long list that should be interpreted as a 2D array
223126
range: Any
@@ -251,7 +154,7 @@ slots:
251154
operation_parameters:
252155
range: Any
253156
multivalued: true
254-
157+
255158
enums:
256159
ArrayLinearizationOrderOptions:
257160
description: >-
@@ -272,5 +175,3 @@ enums:
272175
or any generalization thereof to dimensionality greater than 2
273176
aliases:
274177
- C order
275-
276-
Lines changed: 118 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,118 @@
1+
id: https://example.org/arrays
2+
name: arrays-temperature-example
3+
title: Array Temperature Example
4+
description: |-
5+
Example LinkML schema to demonstrate a 3D DataArray of temperature values with labeled axes
6+
license: MIT
7+
8+
prefixes:
9+
linkml: https://w3id.org/linkml/
10+
wgs84: http://www.w3.org/2003/01/geo/wgs84_pos#
11+
example: https://example.org/
12+
13+
default_prefix: example
14+
15+
imports:
16+
- linkml:types
17+
18+
classes:
19+
20+
TemperatureDataset:
21+
tree_root: true
22+
implements:
23+
- linkml:DataArray
24+
attributes:
25+
name:
26+
identifier: true
27+
range: string
28+
latitude_in_deg:
29+
implements:
30+
- linkml:axis
31+
range: LatitudeSeries
32+
required: true
33+
annotations:
34+
axis_index: 0
35+
longitude_in_deg:
36+
implements:
37+
- linkml:axis
38+
range: LongitudeSeries
39+
required: true
40+
annotations:
41+
axis_index: 1
42+
time_in_d:
43+
implements:
44+
- linkml:axis
45+
range: DaySeries
46+
required: true
47+
annotations:
48+
axis_index: 2
49+
temperatures_in_K:
50+
implements:
51+
- linkml:array
52+
range: TemperatureMatrix
53+
required: true
54+
55+
TemperatureMatrix:
56+
description: A 3D array of temperatures
57+
implements:
58+
- linkml:NDArray
59+
- linkml:RowOrderedArray
60+
attributes:
61+
values:
62+
range: float
63+
multivalued: true
64+
implements:
65+
- linkml:elements
66+
required: true
67+
unit:
68+
ucum_code: K
69+
annotations:
70+
dimensions: 3
71+
72+
LatitudeSeries:
73+
description: A series whose values represent latitude
74+
implements:
75+
- linkml:NDArray
76+
attributes:
77+
values:
78+
range: float
79+
multivalued: true
80+
implements:
81+
- linkml:elements
82+
required: true
83+
unit:
84+
ucum_code: deg
85+
annotations:
86+
dimensions: 1
87+
88+
LongitudeSeries:
89+
description: A series whose values represent longitude
90+
implements:
91+
- linkml:NDArray
92+
attributes:
93+
values:
94+
range: float
95+
multivalued: true
96+
implements:
97+
- linkml:elements
98+
required: true
99+
unit:
100+
ucum_code: deg
101+
annotations:
102+
dimensions: 1
103+
104+
DaySeries:
105+
description: A series whose values represent the days since the start of the measurement period
106+
implements:
107+
- linkml:NDArray
108+
attributes:
109+
values:
110+
range: float
111+
multivalued: true
112+
implements:
113+
- linkml:elements
114+
required: true
115+
unit:
116+
ucum_code: d
117+
annotations:
118+
dimensions: 1

0 commit comments

Comments
 (0)