Skip to content

Commit

Permalink
Rename TimeColumn -> IndexColumn and assorted fixes (rerun-io#7636)
Browse files Browse the repository at this point in the history
### What
- Rename had not been completed
- Discovered column names aren't being assigned properly while testing

### Checklist
* [x] I have read and agree to [Contributor
Guide](https://github.com/rerun-io/rerun/blob/main/CONTRIBUTING.md) and
the [Code of
Conduct](https://github.com/rerun-io/rerun/blob/main/CODE_OF_CONDUCT.md)
* [x] I've included a screenshot or gif (if applicable)
* [x] I have tested the web demo (if applicable):
* Using examples from latest `main` build:
[rerun.io/viewer](https://rerun.io/viewer/pr/7636?manifest_url=https://app.rerun.io/version/main/examples_manifest.json)
* Using full set of examples from `nightly` build:
[rerun.io/viewer](https://rerun.io/viewer/pr/7636?manifest_url=https://app.rerun.io/version/nightly/examples_manifest.json)
* [x] The PR title and labels are set such as to maximize their
usefulness for the next release's CHANGELOG
* [x] If applicable, add a new check to the [release
checklist](https://github.com/rerun-io/rerun/blob/main/tests/python/release_checklist)!
* [x] If have noted any breaking changes to the log API in
`CHANGELOG.md` and the migration guide

- [PR Build Summary](https://build.rerun.io/pr/7636)
- [Recent benchmark results](https://build.rerun.io/graphs/crates.html)
- [Wasm size tracking](https://build.rerun.io/graphs/sizes.html)

To run all checks from `main`, comment on the PR with `@rerun-bot
full-check`.
  • Loading branch information
jleibs authored Oct 8, 2024
1 parent ba5bfe9 commit 5852681
Show file tree
Hide file tree
Showing 4 changed files with 46 additions and 24 deletions.
6 changes: 5 additions & 1 deletion crates/store/re_chunk_store/src/dataframe.rs
Original file line number Diff line number Diff line change
Expand Up @@ -340,7 +340,11 @@ impl ComponentColumnDescriptor {
#[inline]
pub fn to_arrow_field(&self) -> ArrowField {
ArrowField::new(
self.component_name.short_name().to_owned(),
format!(
"{}:{}",
self.entity_path,
self.component_name.short_name().to_owned()
),
self.returned_datatype(),
true, /* nullable */
)
Expand Down
4 changes: 2 additions & 2 deletions rerun_py/rerun_sdk/rerun/dataframe.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,11 @@
from rerun_bindings import (
ComponentColumnDescriptor as ComponentColumnDescriptor,
ComponentColumnSelector as ComponentColumnSelector,
IndexColumnDescriptor as IndexColumnDescriptor,
IndexColumnSelector as IndexColumnSelector,
Recording as Recording,
RRDArchive as RRDArchive,
Schema as Schema,
TimeColumnDescriptor as TimeColumnDescriptor,
TimeColumnSelector as TimeColumnSelector,
load_archive as load_archive,
load_recording as load_recording,
)
Expand Down
8 changes: 4 additions & 4 deletions rerun_py/src/dataframe.rs
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,8 @@ pub(crate) fn register(m: &Bound<'_, PyModule>) -> PyResult<()> {
Ok(())
}

/// Python binding for [`TimeColumnDescriptor`]
#[pyclass(frozen, name = "TimeColumnDescriptor")]
/// Python binding for `IndexColumnDescriptor`
#[pyclass(frozen, name = "IndexColumnDescriptor")]
#[derive(Clone)]
struct PyIndexColumnDescriptor(TimeColumnDescriptor);

Expand All @@ -59,8 +59,8 @@ impl From<TimeColumnDescriptor> for PyIndexColumnDescriptor {
}
}

/// Python binding for [`TimeColumnSelector`]
#[pyclass(frozen, name = "TimeColumnSelector")]
/// Python binding for `IndexColumnSelector`
#[pyclass(frozen, name = "IndexColumnSelector")]
#[derive(Clone)]
struct PyIndexColumnSelector(TimeColumnSelector);

Expand Down
52 changes: 35 additions & 17 deletions rerun_py/tests/unit/test_dataframe.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,9 @@ class TestDataframe:
def setup_method(self) -> None:
rr.init("rerun_example_test_recording")

rr.set_time_sequence("my_index", 1)
rr.log("points", rr.Points3D([[1, 2, 3], [4, 5, 6], [7, 8, 9]]))
rr.set_time_sequence("my_index", 7)
rr.log("points", rr.Points3D([[10, 11, 12]], colors=[[255, 0, 0]]))

with tempfile.TemporaryDirectory() as tmpdir:
Expand All @@ -21,26 +23,38 @@ def setup_method(self) -> None:
self.recording = rr.dataframe.load_recording(rrd)

def test_full_view(self) -> None:
view = self.recording.view(index="log_time", contents="points")
view = self.recording.view(index="my_index", contents="points")

batches = view.select()
table = pa.Table.from_batches(batches, batches.schema)

# log_time, log_tick, indicator, points, colors
assert table.num_columns == 5
# my_index, log_time, log_tick, indicator, points, colors
assert table.num_columns == 6
assert table.num_rows == 2

def test_select_column(self) -> None:
view = self.recording.view(index="log_time", contents="points")
def test_select_columns(self) -> None:
view = self.recording.view(index="my_index", contents="points")
log_time = rr.dataframe.IndexColumnSelector("my_index")
pos = rr.dataframe.ComponentColumnSelector("points", rr.components.Position3D)
batches = view.select(pos)

batches = view.select(log_time, pos)

table = pa.Table.from_batches(batches, batches.schema)
# points
assert table.num_columns == 1
assert table.num_columns == 2
assert table.num_rows == 2

expected0 = pa.array(
expected_index0 = pa.array(
[1],
type=pa.int64(),
)

expected_index1 = pa.array(
[7],
type=pa.int64(),
)

expected_pos0 = pa.array(
[
[1, 2, 3],
[4, 5, 6],
Expand All @@ -49,15 +63,19 @@ def test_select_column(self) -> None:
type=rr.components.Position3D.arrow_type(),
)

expected1 = pa.array(
expected_pos1 = pa.array(
[
[10, 11, 12],
],
type=rr.components.Position3D.arrow_type(),
)

assert table.column(0)[0].values.equals(expected0)
assert table.column(0)[1].values.equals(expected1)
print(table.schema)

assert table.column("my_index")[0].equals(expected_index0[0])
assert table.column("my_index")[1].equals(expected_index1[0])
assert table.column("/points:Position3D")[0].values.equals(expected_pos0)
assert table.column("/points:Position3D")[1].values.equals(expected_pos1)

def test_view_syntax(self) -> None:
good_content_expressions = [
Expand All @@ -68,12 +86,12 @@ def test_view_syntax(self) -> None:
]

for expr in good_content_expressions:
view = self.recording.view(index="log_time", contents=expr)
view = self.recording.view(index="my_index", contents=expr)
batches = view.select()
table = pa.Table.from_batches(batches, batches.schema)

# log_time, log_tick, points
assert table.num_columns == 3
# my_index, log_time, log_tick, points
assert table.num_columns == 4
assert table.num_rows == 2

bad_content_expressions = [
Expand All @@ -82,10 +100,10 @@ def test_view_syntax(self) -> None:
]

for expr in bad_content_expressions:
view = self.recording.view(index="log_time", contents=expr)
view = self.recording.view(index="my_index", contents=expr)
batches = view.select()

# log_time, log_tick
# my_index, log_time, log_tick
table = pa.Table.from_batches(batches, batches.schema)
assert table.num_columns == 2
assert table.num_columns == 3
assert table.num_rows == 0

0 comments on commit 5852681

Please sign in to comment.