@@ -4736,7 +4736,10 @@ def test_repr(self):
4736
4736
# copies should not exist, but if they do, it should be obvious that
4737
4737
# something is wrong
4738
4738
assert_equal (repr (np .ma .masked ), 'masked' )
4739
- assert_not_equal (repr (np .ma .masked .copy ()), 'masked' )
4739
+
4740
+ # create a new instance in a weird way
4741
+ masked2 = np .ma .MaskedArray .__new__ (np .ma .core .MaskedConstant )
4742
+ assert_not_equal (repr (masked2 ), 'masked' )
4740
4743
4741
4744
def test_pickle (self ):
4742
4745
from io import BytesIO
@@ -4748,30 +4751,12 @@ def test_pickle(self):
4748
4751
res = pickle .load (f )
4749
4752
assert_ (res is np .ma .masked )
4750
4753
4751
- def test_write_to_copy (self ):
4754
+ def test_copy (self ):
4752
4755
# gh-9328
4753
- x = np .ma .masked .copy ()
4754
- x [()] = 2
4755
-
4756
- # write succeeds
4757
- assert_equal (x .data , 2 )
4758
- assert_equal (x .mask , False )
4759
-
4760
- # original should be unchanged
4761
- assert_equal (np .ma .masked .data , 0 )
4762
- assert_equal (np .ma .masked .mask , True )
4763
-
4764
- def test_no_copies (self ):
4765
- # when making a view or a copy, downcast to MaskedArray
4766
- MC = np .ma .core .MaskedConstant
4767
-
4768
- m_sl = np .ma .masked [...]
4769
- assert_equal (type (m_sl ), np .ma .MaskedArray )
4770
- assert_equal (m_sl .mask , True )
4771
-
4772
- m_copy = np .ma .masked .copy ()
4773
- assert_equal (type (m_copy ), np .ma .MaskedArray )
4774
- # assert_equal(m_copy.mask, True) - gh-9430
4756
+ # copy is a no-op, like it is with np.True_
4757
+ assert_equal (
4758
+ np .ma .masked .copy () is np .ma .masked ,
4759
+ np .True_ .copy () is np .True_ )
4775
4760
4776
4761
def test_immutable (self ):
4777
4762
assert_raises (ValueError , operator .setitem , np .ma .masked .data , (), 1 )
0 commit comments