MCPcopy Create free account
hub / github.com/dask/dask / test_method_operators

Function test_method_operators

dask/dataframe/dask_expr/tests/test_collection.py:598–637  ·  view source on GitHub ↗
(pdf, df, axis, level, fill_value, op, series, other)

Source from the content-addressed store, hash-verified

596@pytest.mark.parametrize("series", (True, False))
597@pytest.mark.parametrize("other", ("series", "dataframe", 1))
598def test_method_operators(pdf, df, axis, level, fill_value, op, series, other):
599 kwargs = {
600 k: v
601 for k, v in (("axis", axis), ("level", level), ("fill_value", fill_value))
602 if v is not None
603 }
604
605 if level is not None:
606 with pytest.raises(NotImplementedError, match="level must be None"):
607 getattr(df, op)(other=df, **kwargs)
608 return
609
610 if other == "series":
611 pother = pdf.x
612 other = df.x
613 elif other == "dataframe":
614 pother = pdf
615 other = df
616 else:
617 pother = other
618
619 if isinstance(other, Series) and axis in (1, "columns"):
620 with pytest.raises(ValueError, match=f"Unable to {op} dd.Series with axis=1"):
621 getattr(df, op)(other=other, **kwargs)
622
623 elif (
624 not PANDAS_GE_310
625 and isinstance(other, Series)
626 and axis in (0, "index")
627 and fill_value
628 ):
629 with pytest.raises(
630 NotImplementedError, match=f"fill_value {fill_value} not supported"
631 ):
632 getattr(df, op)(other=other, **kwargs)
633
634 else:
635 expected = getattr(pdf, op)(other=pother, **kwargs)
636 actual = getattr(df, op)(other=other, **kwargs)
637 assert_eq(expected, actual)
638
639
640@pytest.mark.parametrize(

Callers

nothing calls this directly

Calls 1

assert_eqFunction · 0.90

Tested by

no test coverage detected