def setup_method(self, _): self.lst = [3, 5, 7, -2] self.klass = FrozenNDArray with warnings.catch_warnings(record=True): warnings.simplefilter("ignore", FutureWarning) self.container = FrozenNDArray(self.lst) self.unicode_container = FrozenNDArray(["\u05d0", "\u05d1", "c"])
class TestFrozenNDArray(CheckImmutable, CheckStringMixin): mutable_methods = ('put', 'itemset', 'fill') unicode_container = FrozenNDArray([u("\u05d0"), u("\u05d1"), "c"]) def setup_method(self, method): self.lst = [3, 5, 7, -2] self.container = FrozenNDArray(self.lst) self.klass = FrozenNDArray def test_shallow_copying(self): original = self.container.copy() assert isinstance(self.container.view(), FrozenNDArray) assert not isinstance(self.container.view(np.ndarray), FrozenNDArray) assert self.container.view() is not self.container tm.assert_numpy_array_equal(self.container, original) # Shallow copy should be the same too assert isinstance(self.container._shallow_copy(), FrozenNDArray) # setting should not be allowed def testit(container): container[0] = 16 self.check_mutable_error(testit, self.container) def test_values(self): original = self.container.view(np.ndarray).copy() n = original[0] + 15 vals = self.container.values() tm.assert_numpy_array_equal(original, vals) assert original is not vals vals[0] = n assert isinstance(self.container, FrozenNDArray) tm.assert_numpy_array_equal(self.container.values(), original) assert vals[0] == n def test_searchsorted(self): expected = 2 assert self.container.searchsorted(7) == expected with tm.assert_produces_warning(FutureWarning): assert self.container.searchsorted(v=7) == expected
def test_constructor_warns(self): # see gh-9031 with tm.assert_produces_warning(FutureWarning): FrozenNDArray([1, 2, 3])
def setUp(self): self.lst = [3, 5, 7, -2] self.container = FrozenNDArray(self.lst) self.klass = FrozenNDArray
def setup_method(self, method): self.lst = [3, 5, 7, -2] self.container = FrozenNDArray(self.lst) self.klass = FrozenNDArray