Skip to content

Commit cf8e5d3

Browse files
feedback EK
1 parent 955517c commit cf8e5d3

2 files changed

Lines changed: 13 additions & 38 deletions

File tree

diffly/_conditions.py

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -193,8 +193,6 @@ def _compare_sequence_columns(
193193
"""Compare Array/List columns element-wise with tolerance."""
194194
assert isinstance(dtype_left, pl.List | pl.Array)
195195
assert isinstance(dtype_right, pl.List | pl.Array)
196-
inner_left = dtype_left.inner
197-
inner_right = dtype_right.inner
198196

199197
n_elements: int
200198
has_same_length: pl.Expr
@@ -232,8 +230,8 @@ def _get_element(col: pl.Expr, dtype: DataType | DataTypeClass, i: int) -> pl.Ex
232230
_compare_columns(
233231
col_left=_get_element(col_left, dtype_left, i),
234232
col_right=_get_element(col_right, dtype_right, i),
235-
dtype_left=inner_left,
236-
dtype_right=inner_right,
233+
dtype_left=dtype_left.inner,
234+
dtype_right=dtype_right.inner,
237235
abs_tol=abs_tol,
238236
rel_tol=rel_tol,
239237
abs_tol_temporal=abs_tol_temporal,

tests/test_conditions.py

Lines changed: 11 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -382,20 +382,28 @@ def test_condition_equal_columns_two_arrays_different_shapes() -> None:
382382
assert actual.to_list() == [False]
383383

384384

385-
def test_condition_equal_columns_empty_arrays() -> None:
385+
@pytest.mark.parametrize(
386+
"lhs_type", [pl.Array(pl.Float64, shape=0), pl.List(pl.Float64)]
387+
)
388+
@pytest.mark.parametrize(
389+
"rhs_type", [pl.Array(pl.Float64, shape=0), pl.List(pl.Float64)]
390+
)
391+
def test_condition_equal_columns_empty_list_array(
392+
lhs_type: pl.DataType, rhs_type: pl.DataType
393+
) -> None:
386394
lhs = pl.DataFrame(
387395
{
388396
"pk": [1, 2],
389397
"a_left": [[], None],
390398
},
391-
schema={"pk": pl.Int64, "a_left": pl.Array(pl.Float64, shape=0)},
399+
schema={"pk": pl.Int64, "a_left": lhs_type},
392400
)
393401
rhs = pl.DataFrame(
394402
{
395403
"pk": [1, 2],
396404
"a_right": [[], None],
397405
},
398-
schema={"pk": pl.Int64, "a_right": pl.Array(pl.Float64, shape=0)},
406+
schema={"pk": pl.Int64, "a_right": rhs_type},
399407
)
400408

401409
actual = (
@@ -413,37 +421,6 @@ def test_condition_equal_columns_empty_arrays() -> None:
413421
assert actual.to_list() == [True, True]
414422

415423

416-
def test_condition_equal_columns_empty_lists() -> None:
417-
lhs = pl.DataFrame(
418-
{
419-
"pk": [1, 2, 3],
420-
"a_left": [[], None, []],
421-
},
422-
schema={"pk": pl.Int64, "a_left": pl.List(pl.Float64)},
423-
)
424-
rhs = pl.DataFrame(
425-
{
426-
"pk": [1, 2, 3],
427-
"a_right": [[], None, None],
428-
},
429-
schema={"pk": pl.Int64, "a_right": pl.List(pl.Float64)},
430-
)
431-
432-
actual = (
433-
lhs.join(rhs, on="pk", maintain_order="left")
434-
.select(
435-
condition_equal_columns(
436-
"a",
437-
dtype_left=lhs.schema["a_left"],
438-
dtype_right=rhs.schema["a_right"],
439-
max_list_length=0,
440-
)
441-
)
442-
.to_series()
443-
)
444-
assert actual.to_list() == [True, True, False]
445-
446-
447424
@pytest.mark.parametrize(
448425
("dtype_left", "dtype_right", "can_compare_dtypes"),
449426
[

0 commit comments

Comments
 (0)