Skip to content

Commit

Permalink
Test bad inputs
Browse files Browse the repository at this point in the history
  • Loading branch information
jleibs committed Oct 9, 2024
1 parent e757aa4 commit e04c513
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 4 deletions.
4 changes: 2 additions & 2 deletions rerun_py/src/dataframe.rs
Original file line number Diff line number Diff line change
Expand Up @@ -213,7 +213,7 @@ impl<'py> IndexLike<'py> {
let array = make_array(array.0.clone());

let int_array = array.as_any().downcast_ref::<Int64Array>().ok_or_else(|| {
PyTypeError::new_err("Expected an array of integers for index values.")
PyTypeError::new_err("pyarrow.Array for IndexLike must be of type int64.")
})?;

let values: BTreeSet<re_chunk_store::TimeInt> = int_array
Expand Down Expand Up @@ -257,7 +257,7 @@ impl<'py> IndexLike<'py> {
let int_array =
array.as_any().downcast_ref::<Int64Array>().ok_or_else(|| {
PyTypeError::new_err(
"Expected an array of integers for index values.",
"pyarrow.Array for IndexLike must be of type int64.",
)
})?;

Expand Down
15 changes: 13 additions & 2 deletions rerun_py/tests/unit/test_dataframe.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
import uuid

import pyarrow as pa
import pytest
import rerun as rr

APP_ID = "rerun_example_test_recording"
Expand Down Expand Up @@ -152,14 +153,14 @@ def test_index_values(self) -> None:

assert table3 == table2

## Manually create a pyarrow array with no matches
# Manually create a pyarrow array with no matches
view4 = view.filter_index_values(pa.array([8], type=pa.int64()))
batches = view4.select()
table4 = pa.Table.from_batches(batches, batches.schema)

assert table4.num_rows == 0

## Manually create a chunked array with 1 match
# Manually create a chunked array with 1 match
manual_chunked_selection = pa.chunked_array([
pa.array([2], type=pa.int64()),
pa.array([3, 7, 8], type=pa.int64()),
Expand All @@ -177,6 +178,16 @@ def test_index_values(self) -> None:

assert table5.num_rows == 1

# Exceptions
with pytest.raises(ValueError):
view.filter_index_values(pa.array([8, 8], type=pa.int64()))

with pytest.raises(TypeError):
view.filter_index_values("1")

with pytest.raises(TypeError):
view.filter_index_values(pa.array([1.0, 2.0], type=pa.float64()))

def test_view_syntax(self) -> None:
good_content_expressions = [
{"points": rr.components.Position3D},
Expand Down

0 comments on commit e04c513

Please sign in to comment.