-
Notifications
You must be signed in to change notification settings - Fork 373
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Codegen/IDL 7: handwritten Python tests and extensions for
Points2D
(…
…#2410) Implements all the necessary Python extensions so that the UX of the `Points2D` archetype is --dare I say-- _exquisite_. Also adds a whole bunch of tests for all of these extensions because, well.. Python... Might be easier to review commit by commit 🤷 --- Codegen/IDL PR series: - #2362 - #2363 - #2369 - #2370 - #2374 - #2375 - #2410 - #2432 --------- Co-authored-by: Andreas Reich <[email protected]>
- Loading branch information
Showing
26 changed files
with
578 additions
and
48 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
# This is a sha256 hash for all direct and indirect dependencies of this crate's build script. | ||
# It can be safely removed at anytime to force the build script to run again. | ||
# Check out build.rs to see how it's computed. | ||
2d611d0d686a6314da94b1797472e7690413465d16a611aae3560a847668d53d | ||
184f79acfe7c0608f9ec2bb5f6a6783dc2270f5cae0edb147ad08ad4ee89c825 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
from __future__ import annotations | ||
|
||
__all__ = ["ClassIdArrayExt"] | ||
|
||
from typing import Any, Sequence | ||
|
||
import numpy as np | ||
import pyarrow as pa | ||
|
||
|
||
class ClassIdArrayExt: | ||
@staticmethod | ||
def _from_similar( | ||
data: Any | None, *, mono: type, mono_aliases: Any, many: type, many_aliases: Any, arrow: type | ||
) -> pa.Array: | ||
if isinstance(data, Sequence) and (len(data) > 0 and isinstance(data[0], mono)): | ||
array = np.asarray([class_id.id for class_id in data], np.uint16) | ||
else: | ||
array = np.asarray(data, dtype=np.uint16).flatten() | ||
|
||
return arrow().wrap_array(pa.array(array, type=arrow().storage_type)) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
from __future__ import annotations | ||
|
||
__all__ = ["ColorArrayExt"] | ||
|
||
from typing import Any, Sequence | ||
|
||
import numpy as np | ||
import pyarrow as pa | ||
from rerun.color_conversion import u8_array_to_rgba | ||
|
||
|
||
class ColorArrayExt: | ||
@staticmethod | ||
def _from_similar( | ||
data: Any | None, *, mono: type, mono_aliases: Any, many: type, many_aliases: Any, arrow: type | ||
) -> pa.Array: | ||
""" | ||
Normalize flexible colors arrays. | ||
Float colors are assumed to be in 0-1 gamma sRGB space. | ||
All other colors are assumed to be in 0-255 gamma sRGB space. | ||
If there is an alpha, we assume it is in linear space, and separate (NOT pre-multiplied). | ||
""" | ||
if isinstance(data, Sequence) and len(data) == 0: | ||
array = np.array([], np.uint32) | ||
elif isinstance(data, Sequence) and (len(data) > 0 and isinstance(data[0], mono)): | ||
array = np.asarray([color.rgba for color in data], np.uint32) | ||
elif isinstance(data, Sequence) and (len(data) > 0 and isinstance(data[0], int)): | ||
array = np.asarray(data, np.uint32) | ||
else: | ||
array = np.asarray(data) | ||
# Rust expects colors in 0-255 uint8 | ||
if array.dtype.type in [np.float32, np.float64]: | ||
# Assume gamma-space colors | ||
array = u8_array_to_rgba(np.asarray(np.round(np.asarray(data).reshape((-1, 4)) * 255.0), np.uint8)) | ||
elif array.dtype.type == np.uint32: | ||
array = np.asarray(data).flatten() | ||
else: | ||
array = u8_array_to_rgba(np.asarray(data, dtype=np.uint8).reshape((-1, 4))) | ||
|
||
return arrow().wrap_array(pa.array(array, type=arrow().storage_type)) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
from __future__ import annotations | ||
|
||
__all__ = ["DrawOrderArrayExt"] | ||
|
||
from typing import Any, Sequence | ||
|
||
import numpy as np | ||
import pyarrow as pa | ||
|
||
|
||
class DrawOrderArrayExt: | ||
@staticmethod | ||
def _from_similar( | ||
data: Any | None, *, mono: type, mono_aliases: Any, many: type, many_aliases: Any, arrow: type | ||
) -> pa.Array: | ||
if isinstance(data, Sequence) and (len(data) > 0 and isinstance(data[0], mono)): | ||
array = np.asarray([draw_order.value for draw_order in data], np.float32) | ||
else: | ||
array = np.require(np.asarray(data), np.float32).flatten() | ||
|
||
return arrow().wrap_array(pa.array(array, type=arrow().storage_type)) |
Oops, something went wrong.
9393da6
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Possible performance regression was detected for benchmark 'Rust Benchmark'.
Benchmark result of this commit is worse than the previous benchmark result exceeding threshold
1.25
.datastore/num_rows=1000/num_instances=1000/packed=false/insert/default
6182181
ns/iter (± 69854
)2883912
ns/iter (± 28153
)2.14
datastore/num_rows=1000/num_instances=1000/packed=false/latest_at/default
408
ns/iter (± 2
)306
ns/iter (± 1
)1.33
datastore/num_rows=1000/num_instances=1000/packed=false/latest_at_missing/primary/default
298
ns/iter (± 0
)222
ns/iter (± 3
)1.34
datastore/num_rows=1000/num_instances=1000/packed=false/latest_at_missing/secondaries/default
456
ns/iter (± 0
)336
ns/iter (± 3
)1.36
datastore/num_rows=1000/num_instances=1000/packed=false/range/default
6745655
ns/iter (± 265327
)2930889
ns/iter (± 39330
)2.30
datastore/num_rows=1000/num_instances=1000/gc/default
2923380
ns/iter (± 47395
)1731589
ns/iter (± 26107
)1.69
mono_points_arrow/generate_message_bundles
41705506
ns/iter (± 1047502
)28157682
ns/iter (± 789944
)1.48
mono_points_arrow/generate_messages
176002109
ns/iter (± 1383778
)137173359
ns/iter (± 1238292
)1.28
mono_points_arrow/encode_log_msg
189465692
ns/iter (± 1402516
)136848583
ns/iter (± 1202825
)1.38
mono_points_arrow/encode_total
395051054
ns/iter (± 5398731
)312474889
ns/iter (± 1771228
)1.26
mono_points_arrow/decode_message_bundles
91524862
ns/iter (± 1074152
)57064034
ns/iter (± 724692
)1.60
mono_points_arrow_batched/generate_message_bundles
36408281
ns/iter (± 756893
)18653807
ns/iter (± 141047
)1.95
mono_points_arrow_batched/generate_messages
12378844
ns/iter (± 805188
)3542612
ns/iter (± 34238
)3.49
mono_points_arrow_batched/encode_total
50138704
ns/iter (± 1737361
)23717322
ns/iter (± 324048
)2.11
mono_points_arrow_batched/decode_log_msg
564645
ns/iter (± 9041
)305644
ns/iter (± 2101
)1.85
mono_points_arrow_batched/decode_message_bundles
14083774
ns/iter (± 371830
)7322670
ns/iter (± 7163
)1.92
mono_points_arrow_batched/decode_total
15026012
ns/iter (± 468225
)7750874
ns/iter (± 9891
)1.94
batch_points_arrow/decode_log_msg
78393
ns/iter (± 1404
)48811
ns/iter (± 115
)1.61
batch_points_arrow/decode_total
86696
ns/iter (± 1924
)51283
ns/iter (± 306
)1.69
arrow_mono_points/insert
3489338759
ns/iter (± 48659989
)1778287912
ns/iter (± 4089788
)1.96
arrow_mono_points/query
1849409
ns/iter (± 192078
)938186
ns/iter (± 7208
)1.97
This comment was automatically generated by workflow using github-action-benchmark.