Skip to content

Commit 3066653

Browse files
jp-darkaaronwolen
andauthored
Update protocol to reflect change to domain/shape (#268)
* Update protocol to reflect change to domain/shape * Run formatters * Apply suggestions from code review Co-authored-by: Aaron Wolen <aaron@wolen.com> * Docstring clean-up --------- Co-authored-by: Aaron Wolen <aaron@wolen.com>
1 parent 60f585a commit 3066653

2 files changed

Lines changed: 25 additions & 54 deletions

File tree

python-spec/src/somacore/data.py

Lines changed: 14 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -38,8 +38,8 @@ def create(
3838
uri: str,
3939
*,
4040
schema: pa.Schema,
41+
domain: Sequence[tuple[Any, Any] | None],
4142
index_column_names: Sequence[str] = (options.SOMA_JOINID,),
42-
domain: Sequence[tuple[Any, Any] | None] | None = None,
4343
platform_config: options.PlatformConfig | None = None,
4444
context: Any | None = None,
4545
) -> Self:
@@ -65,23 +65,11 @@ def create(
6565
index column name is required.
6666
6767
domain:
68-
An optional sequence of tuples specifying the domain of each
69-
index column. Each tuple must be a pair consisting of the
70-
minimum and maximum values storable in the index column. For
71-
example, if there is a single int64-valued index column, then
72-
``domain`` might be ``[(100, 200)]`` to indicate that values
73-
between 100 and 200, inclusive, can be stored in that column.
74-
If provided, this sequence must have the same length as
75-
``index_column_names``, and the index-column domain will be as
76-
specified. If omitted entirely, or if ``None`` in a given
77-
dimension, the corresponding index-column domain will use an
78-
empty range, and data writes after that will fail with an
79-
exception. Unless you have a particular reason not to, you
80-
should always provide the desired `domain` at create time: this
81-
is an optional but strongly recommended parameter. See also
82-
``change_domain`` which allows you to expand the domain after
83-
create.
84-
68+
A sequence of tuples specifying the domain of each index
69+
column. Each tuple must be a pair consisting of the minimum
70+
and maximum values storable in the index column. This sequence
71+
must have the same length as ``index_column_names``. Use ``None`` for string
72+
index columns when the implementation does not support string domains.
8573
platform_config: platform-specific configuration; keys are SOMA
8674
implementation names.
8775
@@ -171,9 +159,9 @@ def change_domain(
171159
172160
The argument must be a tuple of pairs of low/high values for the desired
173161
domain, one pair per index column. For string index columns, you must
174-
offer the low/high pair as `("", "")`, or as ``None``. If ``check_only``
175-
is ``True``, returns whether the operation would succeed if attempted,
176-
and a reason why it would not.
162+
offer the low/high pair as `("", "")`, or as ``None`` for string columns. If
163+
``check_only`` is ``True``, returns whether the operation would succeed if
164+
attempted, and a reason why it would not.
177165
178166
For example, suppose the dataframe's sole index-column name is
179167
``"soma_joinid"`` (which is the default at create). If the dataframe's
@@ -263,7 +251,7 @@ def create(
263251
uri: str,
264252
*,
265253
type: pa.DataType,
266-
shape: Sequence[int | None],
254+
shape: Sequence[int],
267255
platform_config: options.PlatformConfig | None = None,
268256
context: Any | None = None,
269257
) -> Self:
@@ -273,16 +261,10 @@ def create(
273261
uri: The URI where the array will be created.
274262
type: The Arrow type to store in the array.
275263
If the type is unsupported, an error will be raised.
276-
shape: The maximum capacity of each dimension, including room
277-
for any intended future appends, specified as one element
278-
per dimension, e.g. ``(100, 10)``. All lengths must be in
279-
the positive int64 range, or ``None``. It's necessary to say
280-
``shape=(None, None)`` or ``shape=(None, None, None)``,
281-
as the sequence length determines the number of dimensions
282-
(N) in the N-dimensional array.
283-
284-
For sparse arrays only, if a slot is None, then the maximum
285-
possible int64 will be used, making a sparse array growable.
264+
shape: The initial maximum capacity of each dimension, specified
265+
as one element per dimension, e.g. ``(100, 10)`` for a 2D array.
266+
All lengths must be in the positive int64 range. The shape can
267+
be increased after creation using :meth:`resize`.
286268
287269
Returns: The newly created array, opened for writing.
288270

python-spec/src/somacore/spatial.py

Lines changed: 11 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -34,11 +34,11 @@ def create(
3434
uri: str,
3535
*,
3636
schema: pa.Schema,
37+
domain: Sequence[tuple[Any, Any]],
3738
coordinate_space: Sequence[str] | coordinates.CoordinateSpace = (
3839
"x",
3940
"y",
4041
),
41-
domain: Sequence[tuple[Any, Any] | None] | None = None,
4242
platform_config: options.PlatformConfig | None = None,
4343
context: Any | None = None,
4444
) -> Self:
@@ -63,18 +63,9 @@ def create(
6363
implementation, an error will be raised.
6464
coordinate_space: Either the coordinate space or the axis names for the
6565
coordinate space the point cloud is defined on.
66-
domain:
67-
An optional sequence of tuples specifying the domain of each
68-
index column. Each tuple must be a pair consisting of the
69-
minimum and maximum values storable in the index column.
70-
If provided, this sequence must have the same length as
71-
``index_column_names``, and the index-column domain will be as
72-
specified. If omitted entirely, or if ``None`` in a given
73-
dimension, the corresponding index-column domain will use an
74-
empty range, and data writes after that will fail with an
75-
exception. Unless you have a particular reason not to, you
76-
should always provide the desired `domain` at create time: this
77-
is an optional but strongly recommended parameter.
66+
domain: A sequence of tuples specifying the domain of each index column. Each
67+
tuple must be a pair consisting of the minimum and maximum values storable
68+
in the index column.
7869
platform_config: platform-specific configuration; keys are SOMA
7970
implementation names.
8071
context: Other implementation-specific configuration.
@@ -262,8 +253,8 @@ def create(
262253
uri: str,
263254
*,
264255
schema: pa.Schema,
256+
domain: Sequence[tuple[Any, Any] | None],
265257
coordinate_space: Sequence[str] | coordinates.CoordinateSpace = ("x", "y"),
266-
domain: Sequence[tuple[Any, Any] | None] | None = None,
267258
platform_config: options.PlatformConfig | None = None,
268259
context: Any | None = None,
269260
) -> Self:
@@ -288,14 +279,12 @@ def create(
288279
implementation, an error will be raised.
289280
coordinate_space: Either the coordinate space or the axis names for the
290281
coordinate space the point cloud is defined on.
291-
domain: An optional sequence of tuples specifying the domain of each
292-
index column. Two tuples must be provided for the ``soma_geometry``
293-
column which store the width followed by the height. Each tuple should
294-
be a pair consisting of the minimum and maximum values storable in the
295-
index column. If omitted entirely, or if ``None`` in a given dimension,
296-
the corresponding index-column domain will use the minimum and maximum
297-
possible values for the column's datatype. This makes a dataframe
298-
growable.
282+
domain: A sequence of tuples specifying the domain of each index column. Each
283+
tuple should be a pair consisting of the minimum and maximum values storable
284+
in the index column. Two tuples must be provided for the ``soma_geometry``
285+
column with the first tuple specifying the minimum and maximum values of
286+
the width and the second tuple specifying the minimum and maximum values of the
287+
height.
299288
platform_config: platform-specific configuration; keys are SOMA
300289
implementation names.
301290
context: Other implementation-specific configuration.

0 commit comments

Comments
 (0)