MCPcopy
hub / github.com/pandas-dev/pandas / _compare_other

Method _compare_other

pandas/tests/extension/base/ops.py:213–237  ·  view source on GitHub ↗
(self, ser: pd.Series, data, op, other)

Source from the content-addressed store, hash-verified

211 """Various Series and DataFrame comparison ops methods."""
212
213 def _compare_other(self, ser: pd.Series, data, op, other):
214 if op.__name__ in ["eq", "ne"]:
215 # comparison should match point-wise comparisons
216 result = op(ser, other)
217 expected = ser.combine(other, op)
218 expected = self._cast_pointwise_result(op.__name__, ser, other, expected)
219 tm.assert_series_equal(result, expected)
220
221 else:
222 exc = None
223 try:
224 result = op(ser, other)
225 except Exception as err:
226 exc = err
227
228 if exc is None:
229 # Didn't error, then should match pointwise behavior
230 expected = ser.combine(other, op)
231 expected = self._cast_pointwise_result(
232 op.__name__, ser, other, expected
233 )
234 tm.assert_series_equal(result, expected)
235 else:
236 with pytest.raises(type(exc)):
237 ser.combine(other, op)
238
239 def test_compare_scalar(self, data, comparison_op):
240 ser = pd.Series(data)

Callers 4

test_compare_scalarMethod · 0.95
test_compare_arrayMethod · 0.95
test_compare_scalarMethod · 0.45
test_compare_arrayMethod · 0.45

Calls 4

opFunction · 0.85
combineMethod · 0.45
raisesMethod · 0.45

Tested by 4

test_compare_scalarMethod · 0.76
test_compare_arrayMethod · 0.76
test_compare_scalarMethod · 0.36
test_compare_arrayMethod · 0.36