Skip to content

Commit b56c65c

Browse files
committed
Fix div by zero warnings for TensorArray pandas arith tests
1 parent f830069 commit b56c65c

File tree

1 file changed

+9
-1
lines changed

1 file changed

+9
-1
lines changed

text_extensions_for_pandas/array/test_tensor.py

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@
2424
import pandas as pd
2525
import pandas.testing as pdt
2626
from pandas.tests.extension import base
27+
from pandas.core.dtypes.generic import ABCSeries
2728
import pyarrow as pa
2829
import pytest
2930

@@ -836,11 +837,18 @@ class TestPandasArithmeticOps(base.BaseArithmeticOpsTests):
836837
base.BaseArithmeticOpsTests.frame_scalar_exc = None
837838
base.BaseArithmeticOpsTests.divmod_exc = NotImplementedError
838839

840+
def test_arith_series_with_scalar(self, data, all_arithmetic_operators):
841+
""" Override to prevent div by zero warning."""
842+
# series & scalar
843+
op_name = all_arithmetic_operators
844+
s = pd.Series(data[1:]) # Avoid zero values for div
845+
self.check_opname(s, op_name, s.iloc[0], exc=self.series_scalar_exc)
846+
839847
def test_arith_series_with_array(self, data, all_arithmetic_operators):
840848
""" Override because creates Series from list of TensorElements as dtype=object."""
841849
# ndarray & other series
842850
op_name = all_arithmetic_operators
843-
s = pd.Series(data)
851+
s = pd.Series(data[1:]) # Avoid zero values for div
844852
self.check_opname(
845853
s, op_name, pd.Series([s.iloc[0]] * len(s), dtype=TensorDtype()), exc=self.series_array_exc
846854
)

0 commit comments

Comments
 (0)