Skip to content

Commit 487e557

Browse files
committed
Implement fix in codegen + add test
1 parent 5cb70ff commit 487e557

File tree

9 files changed

+65
-34
lines changed

9 files changed

+65
-34
lines changed

crates/build/re_types_builder/src/codegen/python/mod.rs

+3-1
Original file line numberDiff line numberDiff line change
@@ -1995,9 +1995,11 @@ fn quote_arrow_serialization(
19951995
return Ok(unindent(
19961996
r##"
19971997
if isinstance(data, str):
1998-
array = [data]
1998+
array: Union[list[str], npt.ArrayLike] = [data]
19991999
elif isinstance(data, Sequence):
20002000
array = [str(datum) for datum in data]
2001+
elif isinstance(data, np.ndarray):
2002+
array = data
20012003
else:
20022004
array = [str(data)]
20032005

crates/store/re_types/definitions/rerun/datatypes/utf8.fbs

+1-1
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ namespace rerun.datatypes;
88
table Utf8 (
99
"attr.arrow.transparent",
1010
"attr.python.aliases": "str",
11-
"attr.python.array_aliases": "str, Sequence[str]",
11+
"attr.python.array_aliases": "str, Sequence[str], npt.ArrayLike",
1212
"attr.rust.derive": "Default, PartialEq, Eq, PartialOrd, Ord, Hash",
1313
"attr.rust.override_crate": "re_types_core",
1414
"attr.rust.repr": "transparent",

rerun_py/rerun_sdk/rerun/datatypes/entity_path.py

+5-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

rerun_py/rerun_sdk/rerun/datatypes/utf8.py

+14-4
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

rerun_py/rerun_sdk/rerun/datatypes/utf8_ext.py

-24
This file was deleted.

rerun_py/tests/test_types/components/affix_fuzzer10.py

+5-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

rerun_py/tests/test_types/components/affix_fuzzer9.py

+5-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

rerun_py/tests/test_types/datatypes/string_component.py

+5-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

rerun_py/tests/unit/test_utf8.py

+27
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
from __future__ import annotations
2+
3+
import numpy as np
4+
from rerun import datatypes
5+
6+
7+
def test_utf8_batch_single() -> None:
8+
single_string = "hello"
9+
list_of_one_string = ["hello"]
10+
array_of_one_string = np.array(["hello"])
11+
12+
assert (
13+
datatypes.Utf8Batch(single_string).as_arrow_array() == datatypes.Utf8Batch(list_of_one_string).as_arrow_array()
14+
)
15+
16+
assert (
17+
datatypes.Utf8Batch(single_string).as_arrow_array() == datatypes.Utf8Batch(array_of_one_string).as_arrow_array()
18+
)
19+
20+
21+
def test_utf8_batch_many() -> None:
22+
list_of_strings = ["hello", "world"]
23+
array_of_strings = np.array(["hello", "world"])
24+
25+
assert (
26+
datatypes.Utf8Batch(list_of_strings).as_arrow_array() == datatypes.Utf8Batch(array_of_strings).as_arrow_array()
27+
)

0 commit comments

Comments
 (0)