@@ -99,16 +99,28 @@ def custom__array__(self, dtype=None, copy=None):
9999 assert_equal (np .array (o , dtype = np .float64 ), np .array (100.0 , np .float64 ))
100100 if HAS_REFCOUNT :
101101 class MyArray :
102- def __init__ (self ):
103- self .val = np .array (- 1 , dtype = dt )
102+ def __init__ (self , dtype ):
103+ self .val = np .array (- 1 , dtype = dtype )
104104
105105 def __array__ (self , dtype = None , copy = None ):
106106 return self .val .__array__ (dtype = dtype , copy = copy )
107107
108108 dt = np .dtype (np .int32 )
109109 old_refcount = sys .getrefcount (dt )
110- np .array (MyArray ())
110+ np .array (MyArray (dt ))
111111 assert_equal (old_refcount , sys .getrefcount (dt ))
112+ np .array (MyArray (dt ), dtype = dt )
113+ assert_equal (old_refcount , sys .getrefcount (dt ))
114+ np .array (MyArray (dt ), copy = None )
115+ assert_equal (old_refcount , sys .getrefcount (dt ))
116+ np .array (MyArray (dt ), dtype = dt , copy = None )
117+ assert_equal (old_refcount , sys .getrefcount (dt ))
118+ dt2 = np .dtype (np .int16 )
119+ old_refcount2 = sys .getrefcount (dt2 )
120+ np .array (MyArray (dt ), dtype = dt2 )
121+ assert_equal (old_refcount2 , sys .getrefcount (dt2 ))
122+ np .array (MyArray (dt ), dtype = dt2 , copy = None )
123+ assert_equal (old_refcount2 , sys .getrefcount (dt2 ))
112124
113125 # test recursion
114126 nested = 1.5
0 commit comments