Skip to content

Commit e906bcd

Browse files
authored
fix: PySpark like tests (#2562)
* fix: PySpark like tests * try casting to float * forgot casting callspec id
1 parent ffa797c commit e906bcd

File tree

3 files changed

+7
-2
lines changed

3 files changed

+7
-2
lines changed

narwhals/_spark_like/expr.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -816,7 +816,7 @@ def _log(_input: Column) -> Column:
816816
return (
817817
self._F.when(_input < 0, self._F.lit(float("nan")))
818818
.when(_input == 0, self._F.lit(float("-inf")))
819-
.otherwise(self._F.log(base, _input))
819+
.otherwise(self._F.log(float(base), _input))
820820
)
821821

822822
return self._with_callable(_log)

narwhals/functions.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,6 @@
2424
from narwhals.dependencies import is_pyarrow_table
2525
from narwhals.exceptions import InvalidOperationError
2626
from narwhals.expr import Expr
27-
from narwhals.series import Series
2827
from narwhals.translate import from_native
2928
from narwhals.translate import to_native
3029
from narwhals.utils import Implementation

tests/expr_and_series/skew_test.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ def test_skew_series(
3434
([0.0, 0.0, 0.0], None),
3535
([1, 2, 3, 2, 1], 0.343622),
3636
],
37+
ids=range(5),
3738
)
3839
@pytest.mark.filterwarnings("ignore:.*invalid value:RuntimeWarning:dask")
3940
def test_skew_expr(
@@ -45,5 +46,10 @@ def test_skew_expr(
4546
if "ibis" in str(constructor):
4647
# https://github.com/ibis-project/ibis/issues/11176
4748
request.applymarker(pytest.mark.xfail)
49+
50+
if "pyspark" in str(constructor) and int(request.node.callspec.id[-1]) == 0:
51+
# Can not infer schema from empty dataset.
52+
pytest.skip()
53+
4854
result = nw.from_native(constructor({"a": data})).select(nw.col("a").skew())
4955
assert_equal_data(result, {"a": [expected]})

0 commit comments

Comments
 (0)