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

Method test_combine_add

pandas/tests/extension/base/methods.py:432–458  ·  view source on GitHub ↗
(self, data_repeated)

Source from the content-addressed store, hash-verified

430 )
431
432 def test_combine_add(self, data_repeated):
433 # GH 20825
434 orig_data1, orig_data2 = data_repeated(2)
435 s1 = pd.Series(orig_data1)
436 s2 = pd.Series(orig_data2)
437
438 # Check if the operation is supported pointwise for our scalars. If not,
439 # we will expect Series.combine to raise as well.
440 try:
441 with np.errstate(over="ignore"):
442 arr = self._construct_for_combine_add(orig_data1, orig_data2)
443 except TypeError:
444 # If the operation is not supported pointwise for our scalars,
445 # then Series.combine should also raise
446 with pytest.raises(TypeError):
447 s1.combine(s2, lambda x1, x2: x1 + x2)
448 return
449 expected = pd.Series(arr)
450
451 result = s1.combine(s2, lambda x1, x2: x1 + x2)
452 tm.assert_series_equal(result, expected)
453
454 val = s1.iloc[0]
455 result = s1.combine(val, lambda x1, x2: x1 + x2)
456 arr = self._construct_for_combine_add(orig_data1, val)
457 expected = pd.Series(arr)
458 tm.assert_series_equal(result, expected)
459
460 def test_combine_first(self, data):
461 # https://github.com/pandas-dev/pandas/issues/24147

Callers

nothing calls this directly

Calls 4

combineMethod · 0.95
data_repeatedFunction · 0.50
raisesMethod · 0.45

Tested by

no test coverage detected