Skip to content

Commit a4f4d15

Browse files
dilumichcopybara-github
authored andcommitted
Update the Koda Overview so that we don't mention Koda objects before they are introduced.
PiperOrigin-RevId: 720329580 Change-Id: Ia071c304f9db92ee66c13f85fe316c25286358be
1 parent fce985f commit a4f4d15

File tree

1 file changed

+31
-20
lines changed

1 file changed

+31
-20
lines changed

docs/overview.md

Lines changed: 31 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -256,34 +256,42 @@ the operation is applied to **all the items** in the DataSlice
256256
```py
257257
# Root
258258
# ├── dim_1:0
259-
# │ ├── dim_2:0 -> kd.obj(x=1, y=20)
260-
# │ └── dim_2:1 -> kd.obj(x=2, y=30)
259+
# │ ├── dim_2:0 -> kd.new(x=1, y=20, schema='Point')
260+
# │ └── dim_2:1 -> kd.new(x=2, y=30, schema='Point')
261261
# └── dim_1:1
262-
# ├── dim_2:0 -> kd.obj(x=3, y=40)
263-
# ├── dim_2:1 -> kd.obj(x=4, y=50)
264-
# └── dim_2:2 -> kd.obj(x=5, y=60)
262+
# ├── dim_2:0 -> kd.new(x=3, y=40, schema='Point')
263+
# ├── dim_2:1 -> kd.new(x=4, y=50, schema='Point')
264+
# └── dim_2:2 -> kd.new(x=5, y=60, schema='Point')
265265
kd.slice([
266-
[kd.obj(x=1, y=20), kd.obj(x=2, y=30)],
267-
[kd.obj(x=3, y=40), kd.obj(x=4, y=50), kd.obj(x=5, y=60)]])
266+
[
267+
kd.new(x=1, y=20, schema='Point'),
268+
kd.new(x=2, y=30, schema='Point')
269+
],
270+
[
271+
kd.new(x=3, y=40, schema='Point'),
272+
kd.new(x=4, y=50, schema='Point'),
273+
kd.new(x=5, y=60, schema='Point')
274+
]
275+
])
268276

269277
# Root
270-
# ├── dim_1:0 -> kd.list([20,30])
271-
# └── dim_1:1 -> kd.list([40,50,60])
272-
kd.slice([kd.list([20,30]), kd.list([40,50,60])])
278+
# ├── dim_1:0 -> kd.list([20, 30])
279+
# └── dim_1:1 -> kd.list([40, 50, 60])
280+
kd.slice([kd.list([20, 30]), kd.list([40, 50, 60])])
273281

274282
# Root
275283
# ├── dim_1:0
276-
# │ ├── dim_2:0 -> kd.dict({'a':1,'b':2})
277-
# │ └── dim_2:1 -> kd.dict({'b':3,'c':4})
284+
# │ ├── dim_2:0 -> kd.dict({'a': 1,'b': 2})
285+
# │ └── dim_2:1 -> kd.dict({'b': 3,'c': 4})
278286
# └── dim_1:1
279-
# └── dim_2:0 -> kd.dict({'a':5,'b':6,'c':7})
280-
kd.slice([[kd.dict({'a':1,'b':2}), kd.dict({'b':3,'c':4})],
281-
[kd.dict({'a':5,'b':6,'c':7})]])
287+
# └── dim_2:0 -> kd.dict({'a': 5,'b': 6,'c': 7})
288+
kd.slice([[kd.dict({'a': 1,'b': 2}), kd.dict({'b': 3,'c': 4})],
289+
[kd.dict({'a': 5,'b': 6,'c': 7})]])
282290
```
283291

284292
As a result of **attribute access** of a **DataSlice of entities**, a new
285293
DataSlice is returned, which contains attributes of every corresponding entity
286-
or object in the original DataSlice.
294+
in the original DataSlice.
287295

288296
```py
289297
a = kd.slice([kd.new(x=1, schema='Foo'),
@@ -294,9 +302,12 @@ a.x # [1, 2, 3]
294302

295303
a = kd.new(x=kd.slice([1, 2, 3]), schema='Foo') # The same as above, but more compact
296304

297-
a = kd.slice([kd.obj(x=1), kd.obj(y=2), kd.obj(z=3)])
305+
b = kd.slice([kd.new(x=1, schema='Foo'),
306+
kd.new(schema='Foo'),
307+
kd.new(x=3, schema='Foo')])
308+
b # [Entity(x=1), Entity(), Entity(x=3)]
298309

299-
a.maybe('x') # [1, None, None] - only the first one has an attribute 'x'
310+
b.maybe('x') # [1, None, 3] - only the first one has an attribute 'x'
300311
```
301312

302313
When accessing a **single element** of a **DataSlice of lists** or a **key** of
@@ -391,8 +402,8 @@ x[0] # Obj(a=1, b=2)
391402
x[:].maybe('a') # [1, None]
392403

393404
# Mix objects with different schemas
394-
kd.slice([kd.obj(1), kd.obj("hello"), kd.obj(kd.list([1,2,3]))])
395-
kd.slice([kd.obj(x=1,y=2), kd.obj(x="hello", y="world"), kd.obj(1)])
405+
kd.slice([kd.obj(1), kd.obj("hello"), kd.obj([1, 2, 3])])
406+
kd.slice([kd.obj(x=1, y=2), kd.obj(x="hello", y="world"), kd.obj(1)])
396407

397408
kd.obj(x=1).get_schema() # kd.OBJECT
398409
kd.obj(x=1).get_schema() == kd.obj(1).get_schema() # yes

0 commit comments

Comments
 (0)