Skip to content

Commit dfb6373

Browse files
Joe Jevnikjreback
Joe Jevnik
authored andcommitted
TST: remove usages of np.full_like for numpy<1.8.0 compat
closes ##14276 Author: Joe Jevnik <[email protected]> Closes #14277 from llllllllll/no-full-like and squashes the following commits: e098fd7 [Joe Jevnik] TST: remove usages of np.full_like for numpy<1.8.0 compat
1 parent 755886c commit dfb6373

File tree

1 file changed

+12
-4
lines changed

1 file changed

+12
-4
lines changed

pandas/tests/indexes/test_numeric.py

+12-4
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,14 @@
1919
from .common import Base
2020

2121

22+
def full_like(array, value):
23+
"""Compatibility for numpy<1.8.0
24+
"""
25+
ret = np.empty(array.shape, dtype=np.array(value).dtype)
26+
ret.fill(value)
27+
return ret
28+
29+
2230
class Numeric(Base):
2331

2432
def test_numeric_compat(self):
@@ -80,18 +88,18 @@ def test_numeric_compat(self):
8088
for r, e in zip(result, expected):
8189
tm.assert_index_equal(r, e)
8290

83-
result = divmod(idx, np.full_like(idx.values, 2))
91+
result = divmod(idx, full_like(idx.values, 2))
8492
with np.errstate(all='ignore'):
85-
div, mod = divmod(idx.values, np.full_like(idx.values, 2))
93+
div, mod = divmod(idx.values, full_like(idx.values, 2))
8694
expected = Index(div), Index(mod)
8795
for r, e in zip(result, expected):
8896
tm.assert_index_equal(r, e)
8997

90-
result = divmod(idx, Series(np.full_like(idx.values, 2)))
98+
result = divmod(idx, Series(full_like(idx.values, 2)))
9199
with np.errstate(all='ignore'):
92100
div, mod = divmod(
93101
idx.values,
94-
np.full_like(idx.values, 2),
102+
full_like(idx.values, 2),
95103
)
96104
expected = Index(div), Index(mod)
97105
for r, e in zip(result, expected):

0 commit comments

Comments
 (0)