Skip to content

Commit 75ef189

Browse files
Koladata Teamcopybara-github
authored andcommitted
No public description
PiperOrigin-RevId: 714388824 Change-Id: I938c879f9aa15fd8d741377f471e8fd612e08c6b
1 parent e631564 commit 75ef189

File tree

1 file changed

+115
-130
lines changed

1 file changed

+115
-130
lines changed

docs/koda_v1_api_reference.md

Lines changed: 115 additions & 130 deletions
Original file line numberDiff line numberDiff line change
@@ -2447,7 +2447,7 @@ Returns a DataSlice of Lists concatenated from the List items of `lists`.
24472447
DataSlice of concatenated Lists
24482448
```
24492449

2450-
### `kd.lists.explode(x, ndim=DataItem(1, schema: INT32))` {#kd.lists.explode}
2450+
### `kd.lists.explode(x, ndim=DataItem(1, schema: INT64))` {#kd.lists.explode}
24512451
Aliases:
24522452

24532453
- [kd.explode](#kd.explode)
@@ -3603,7 +3603,7 @@ Returns:
36033603
Result of fn applied on filtered args.
36043604
```
36053605

3606-
### `kd.py.map_py(fn, *args, schema=DataItem(None, schema: NONE), max_threads=DataItem(1, schema: INT32), ndim=DataItem(0, schema: INT32), item_completed_callback=DataItem(None, schema: NONE), **kwargs)` {#kd.py.map_py}
3606+
### `kd.py.map_py(fn, *args, schema=DataItem(None, schema: NONE), max_threads=DataItem(1, schema: INT32), ndim=DataItem(0, schema: INT32), include_missing=DataItem(None, schema: NONE), item_completed_callback=DataItem(None, schema: NONE), **kwargs)` {#kd.py.map_py}
36073607
Aliases:
36083608

36093609
- [kd.map_py](#kd.map_py)
@@ -3673,6 +3673,9 @@ Args:
36733673
schema: The schema to use for resulting DataSlice.
36743674
max_threads: maximum number of threads to use.
36753675
ndim: Dimensionality of items to pass to `fn`.
3676+
include_missing: Specifies whether `fn` should be computed to the missing
3677+
items. By default, the function is applied to all items including the
3678+
missing. `include_missing=False` can only be used with `ndim=0`.
36763679
item_completed_callback: A callback that will be called after each item is
36773680
processed. It will be called in the original thread that called `map_py`
36783681
in case `max_threads` is greater than 1, as we rely on this property for
@@ -4003,17 +4006,6 @@ Aliases:
40034006
Casts `x` to ANY using explicit (permissive) casting rules.
40044007
```
40054008

4006-
### `kd.schema.as_itemid(x)` {#kd.schema.as_itemid}
4007-
Aliases:
4008-
4009-
- [kd.as_itemid](#kd.as_itemid)
4010-
4011-
``` {.no-copy}
4012-
Casts `x` to ITEMID using explicit (permissive) casting rules.
4013-
4014-
Deprecated, use `get_itemid` instead.
4015-
```
4016-
40174009
### `kd.schema.cast_to(x, schema)` {#kd.schema.cast_to}
40184010
Aliases:
40194011

@@ -4857,72 +4849,6 @@ Operators that perform DataSlice transformations.
48574849

48584850
**Operators**
48594851

4860-
### `kd.slices.add_dim(x, sizes)` {#kd.slices.add_dim}
4861-
Aliases:
4862-
4863-
- [kd.slices.repeat](#kd.slices.repeat)
4864-
4865-
- [kd.add_dim](#kd.add_dim)
4866-
4867-
- [kd.repeat](#kd.repeat)
4868-
4869-
``` {.no-copy}
4870-
Returns `x` with values repeated according to `sizes`.
4871-
4872-
The resulting DataSlice has `rank = rank + 1`. The input `sizes` are
4873-
broadcasted to `x`, and each value is repeated the given number of times.
4874-
4875-
Example:
4876-
ds = kd.slice([[1, None], [3]])
4877-
sizes = kd.slice([[1, 2], [3]])
4878-
kd.repeat(ds, sizes) # -> kd.slice([[[1], [None, None]], [[3, 3, 3]]])
4879-
4880-
ds = kd.slice([[1, None], [3]])
4881-
sizes = kd.slice([2, 3])
4882-
kd.repeat(ds, sizes) # -> kd.slice([[[1, 1], [None, None]], [[3, 3, 3]]])
4883-
4884-
ds = kd.slice([[1, None], [3]])
4885-
size = kd.item(2)
4886-
kd.repeat(ds, size) # -> kd.slice([[[1, 1], [None, None]], [[3, 3]]])
4887-
4888-
Args:
4889-
x: A DataSlice of data.
4890-
sizes: A DataSlice of sizes that each value in `x` should be repeated for.
4891-
```
4892-
4893-
### `kd.slices.add_dim_to_present(x, sizes)` {#kd.slices.add_dim_to_present}
4894-
Aliases:
4895-
4896-
- [kd.slices.repeat_present](#kd.slices.repeat_present)
4897-
4898-
- [kd.add_dim_to_present](#kd.add_dim_to_present)
4899-
4900-
- [kd.repeat_present](#kd.repeat_present)
4901-
4902-
``` {.no-copy}
4903-
Returns `x` with present values repeated according to `sizes`.
4904-
4905-
The resulting DataSlice has `rank = rank + 1`. The input `sizes` are
4906-
broadcasted to `x`, and each value is repeated the given number of times.
4907-
4908-
Example:
4909-
ds = kd.slice([[1, None], [3]])
4910-
sizes = kd.slice([[1, 2], [3]])
4911-
kd.repeat_present(ds, sizes) # -> kd.slice([[[1], []], [[3, 3, 3]]])
4912-
4913-
ds = kd.slice([[1, None], [3]])
4914-
sizes = kd.slice([2, 3])
4915-
kd.repeat_present(ds, sizes) # -> kd.slice([[[1, 1], []], [[3, 3, 3]]])
4916-
4917-
ds = kd.slice([[1, None], [3]])
4918-
size = kd.item(2)
4919-
kd.repeat_present(ds, size) # -> kd.slice([[[1, 1], []], [[3, 3]]])
4920-
4921-
Args:
4922-
x: A DataSlice of data.
4923-
sizes: A DataSlice of sizes that each value in `x` should be repeated for.
4924-
```
4925-
49264852
### `kd.slices.agg_count(x, ndim=unspecified)` {#kd.slices.agg_count}
49274853
Aliases:
49284854

@@ -5468,7 +5394,8 @@ Example:
54685394
54695395
Args:
54705396
x: A DataSlice.
5471-
dim: The dimension to compute indices over. Requires abs(dim) < get_ndim(x).
5397+
dim: The dimension to compute indices over.
5398+
Requires -get_ndim(x) <= dim < get_ndim(x).
54725399
If dim < 0 then dim = get_ndim(x) + dim.
54735400
```
54745401

@@ -5692,12 +5619,62 @@ Returns:
56925619
```
56935620

56945621
### `kd.slices.repeat(x, sizes)` {#kd.slices.repeat}
5622+
Aliases:
5623+
5624+
- [kd.repeat](#kd.repeat)
5625+
5626+
``` {.no-copy}
5627+
Returns `x` with values repeated according to `sizes`.
5628+
5629+
The resulting DataSlice has `rank = rank + 1`. The input `sizes` are
5630+
broadcasted to `x`, and each value is repeated the given number of times.
5631+
5632+
Example:
5633+
ds = kd.slice([[1, None], [3]])
5634+
sizes = kd.slice([[1, 2], [3]])
5635+
kd.repeat(ds, sizes) # -> kd.slice([[[1], [None, None]], [[3, 3, 3]]])
5636+
5637+
ds = kd.slice([[1, None], [3]])
5638+
sizes = kd.slice([2, 3])
5639+
kd.repeat(ds, sizes) # -> kd.slice([[[1, 1], [None, None]], [[3, 3, 3]]])
5640+
5641+
ds = kd.slice([[1, None], [3]])
5642+
size = kd.item(2)
5643+
kd.repeat(ds, size) # -> kd.slice([[[1, 1], [None, None]], [[3, 3]]])
56955644
5696-
Alias for [kd.slices.add_dim](#kd.slices.add_dim) operator.
5645+
Args:
5646+
x: A DataSlice of data.
5647+
sizes: A DataSlice of sizes that each value in `x` should be repeated for.
5648+
```
56975649

56985650
### `kd.slices.repeat_present(x, sizes)` {#kd.slices.repeat_present}
5651+
Aliases:
5652+
5653+
- [kd.repeat_present](#kd.repeat_present)
56995654

5700-
Alias for [kd.slices.add_dim_to_present](#kd.slices.add_dim_to_present) operator.
5655+
``` {.no-copy}
5656+
Returns `x` with present values repeated according to `sizes`.
5657+
5658+
The resulting DataSlice has `rank = rank + 1`. The input `sizes` are
5659+
broadcasted to `x`, and each value is repeated the given number of times.
5660+
5661+
Example:
5662+
ds = kd.slice([[1, None], [3]])
5663+
sizes = kd.slice([[1, 2], [3]])
5664+
kd.repeat_present(ds, sizes) # -> kd.slice([[[1], []], [[3, 3, 3]]])
5665+
5666+
ds = kd.slice([[1, None], [3]])
5667+
sizes = kd.slice([2, 3])
5668+
kd.repeat_present(ds, sizes) # -> kd.slice([[[1, 1], []], [[3, 3, 3]]])
5669+
5670+
ds = kd.slice([[1, None], [3]])
5671+
size = kd.item(2)
5672+
kd.repeat_present(ds, size) # -> kd.slice([[[1, 1], []], [[3, 3]]])
5673+
5674+
Args:
5675+
x: A DataSlice of data.
5676+
sizes: A DataSlice of sizes that each value in `x` should be repeated for.
5677+
```
57015678

57025679
### `kd.slices.reverse(ds)` {#kd.slices.reverse}
57035680
Aliases:
@@ -6803,14 +6780,6 @@ Returns a tuple constructed from the given arguments.
68036780

68046781
Alias for [kd.core.add](#kd.core.add) operator.
68056782

6806-
### `kd.add_dim(x, sizes)` {#kd.add_dim}
6807-
6808-
Alias for [kd.slices.add_dim](#kd.slices.add_dim) operator.
6809-
6810-
### `kd.add_dim_to_present(x, sizes)` {#kd.add_dim_to_present}
6811-
6812-
Alias for [kd.slices.add_dim_to_present](#kd.slices.add_dim_to_present) operator.
6813-
68146783
### `kd.agg_all(x, ndim=unspecified)` {#kd.agg_all}
68156784

68166785
Alias for [kd.masking.agg_all](#kd.masking.agg_all) operator.
@@ -6879,10 +6848,6 @@ Alias for [kd.py.apply_py_on_selected](#kd.py.apply_py_on_selected) operator.
68796848

68806849
Alias for [kd.schema.as_any](#kd.schema.as_any) operator.
68816850

6882-
### `kd.as_itemid(x)` {#kd.as_itemid}
6883-
6884-
Alias for [kd.schema.as_itemid](#kd.schema.as_itemid) operator.
6885-
68866851
### `kd.at(x, indices)` {#kd.at}
68876852

68886853
Alias for [kd.slices.at](#kd.slices.at) operator.
@@ -7122,7 +7087,7 @@ Alias for [kd.slices.expand_to](#kd.slices.expand_to) operator.
71227087

71237088
Alias for [kd.shapes.expand_to_shape](#kd.shapes.expand_to_shape) operator.
71247089

7125-
### `kd.explode(x, ndim=DataItem(1, schema: INT32))` {#kd.explode}
7090+
### `kd.explode(x, ndim=DataItem(1, schema: INT64))` {#kd.explode}
71267091

71277092
Alias for [kd.lists.explode](#kd.lists.explode) operator.
71287093

@@ -7589,7 +7554,7 @@ Alias for [kd.tuple.make_tuple](#kd.tuple.make_tuple) operator.
75897554

75907555
Alias for [kd.functor.map](#kd.functor.map) operator.
75917556

7592-
### `kd.map_py(fn, *args, schema=DataItem(None, schema: NONE), max_threads=DataItem(1, schema: INT32), ndim=DataItem(0, schema: INT32), item_completed_callback=DataItem(None, schema: NONE), **kwargs)` {#kd.map_py}
7557+
### `kd.map_py(fn, *args, schema=DataItem(None, schema: NONE), max_threads=DataItem(1, schema: INT32), ndim=DataItem(0, schema: INT32), include_missing=DataItem(None, schema: NONE), item_completed_callback=DataItem(None, schema: NONE), **kwargs)` {#kd.map_py}
75937558

75947559
Alias for [kd.py.map_py](#kd.py.map_py) operator.
75957560

@@ -7818,11 +7783,11 @@ Alias for [kd.core.reify](#kd.core.reify) operator.
78187783

78197784
### `kd.repeat(x, sizes)` {#kd.repeat}
78207785

7821-
Alias for [kd.slices.add_dim](#kd.slices.add_dim) operator.
7786+
Alias for [kd.slices.repeat](#kd.slices.repeat) operator.
78227787

78237788
### `kd.repeat_present(x, sizes)` {#kd.repeat_present}
78247789

7825-
Alias for [kd.slices.add_dim_to_present](#kd.slices.add_dim_to_present) operator.
7790+
Alias for [kd.slices.repeat_present](#kd.slices.repeat_present) operator.
78267791

78277792
### `kd.reshape(x, shape)` {#kd.reshape}
78287793

@@ -8557,32 +8522,6 @@ Slicing helper for DataSlice.
85578522
Please see kd.subslice for more detailed explanations and examples.
85588523
```
85598524

8560-
### `DataSlice.add_dim(self, sizes)` {#DataSlice.add_dim}
8561-
8562-
``` {.no-copy}
8563-
Returns `x` with values repeated according to `sizes`.
8564-
8565-
The resulting DataSlice has `rank = rank + 1`. The input `sizes` are
8566-
broadcasted to `x`, and each value is repeated the given number of times.
8567-
8568-
Example:
8569-
ds = kd.slice([[1, None], [3]])
8570-
sizes = kd.slice([[1, 2], [3]])
8571-
kd.repeat(ds, sizes) # -> kd.slice([[[1], [None, None]], [[3, 3, 3]]])
8572-
8573-
ds = kd.slice([[1, None], [3]])
8574-
sizes = kd.slice([2, 3])
8575-
kd.repeat(ds, sizes) # -> kd.slice([[[1, 1], [None, None]], [[3, 3, 3]]])
8576-
8577-
ds = kd.slice([[1, None], [3]])
8578-
size = kd.item(2)
8579-
kd.repeat(ds, size) # -> kd.slice([[[1, 1], [None, None]], [[3, 3]]])
8580-
8581-
Args:
8582-
x: A DataSlice of data.
8583-
sizes: A DataSlice of sizes that each value in `x` should be repeated for.
8584-
```
8585-
85868525
### `DataSlice.append(value, /)` {#DataSlice.append}
85878526

85888527
``` {.no-copy}
@@ -8595,12 +8534,6 @@ Append a value to each list in this DataSlice
85958534
Returns a DataSlice with ANY schema.
85968535
```
85978536

8598-
### `DataSlice.as_itemid(self)` {#DataSlice.as_itemid}
8599-
8600-
``` {.no-copy}
8601-
Casts `x` to ITEMID using explicit (permissive) casting rules.
8602-
```
8603-
86048537
### `DataSlice.clear()` {#DataSlice.clear}
86058538

86068539
``` {.no-copy}
@@ -8801,6 +8734,32 @@ Returns:
88018734
Expanded DataSlice
88028735
```
88038736

8737+
### `DataSlice.explode(self, ndim=DataItem(1, schema: INT64))` {#DataSlice.explode}
8738+
8739+
``` {.no-copy}
8740+
Explodes a List DataSlice `x` a specified number of times.
8741+
8742+
A single list "explosion" converts a rank-K DataSlice of LIST[T] to a
8743+
rank-(K+1) DataSlice of T, by unpacking the items in the Lists in the original
8744+
DataSlice as a new DataSlice dimension in the result. Missing values in the
8745+
original DataSlice are treated as empty lists.
8746+
8747+
A single list explosion can also be done with `x[:]`.
8748+
8749+
If `ndim` is set to a non-negative integer, explodes recursively `ndim` times.
8750+
An `ndim` of zero is a no-op.
8751+
8752+
If `ndim` is set to a negative integer, explodes as many times as possible,
8753+
until at least one of the items of the resulting DataSlice is not a List.
8754+
8755+
Args:
8756+
x: DataSlice of Lists to explode
8757+
ndim: the number of explosion operations to perform, defaults to 1
8758+
8759+
Returns:
8760+
DataSlice
8761+
```
8762+
88048763
### `DataSlice.extract(self, schema=unspecified)` {#DataSlice.extract}
88058764

88068765
``` {.no-copy}
@@ -9095,6 +9054,32 @@ Returns:
90959054
attribute exists for the corresponding item.
90969055
```
90979056

9057+
### `DataSlice.implode(self, ndim=DataItem(1, schema: INT64), itemid=unspecified)` {#DataSlice.implode}
9058+
9059+
``` {.no-copy}
9060+
Implodes a Dataslice `x` a specified number of times.
9061+
9062+
A single list "implosion" converts a rank-(K+1) DataSlice of T to a rank-K
9063+
DataSlice of LIST[T], by folding the items in the last dimension of the
9064+
original DataSlice into newly-created Lists.
9065+
9066+
A single list implosion is equivalent to `kd.list(x, db)`.
9067+
9068+
If `ndim` is set to a non-negative integer, implodes recursively `ndim` times.
9069+
9070+
If `ndim` is set to a negative integer, implodes as many times as possible,
9071+
until the result is a DataItem (i.e. a rank-0 DataSlice) containing a single
9072+
nested List.
9073+
9074+
Args:
9075+
x: the DataSlice to implode
9076+
ndim: the number of implosion operations to perform
9077+
itemid: optional ITEMID DataSlice used as ItemIds of the resulting lists.
9078+
9079+
Returns:
9080+
DataSlice of nested Lists
9081+
```
9082+
90989083
### `DataSlice.internal_as_arolla_value()` {#DataSlice.internal_as_arolla_value}
90999084

91009085
``` {.no-copy}

0 commit comments

Comments
 (0)