parameters: (self)
docstring: Tests conversions and indexing
docstring_summary: Tests conversions and indexing
docstring_tokens: Tests conversions and indexing
function: def test_2(self):
          "Tests conversions and indexing"
          x1 = np.array([1,2,4,3])
          x2 = self.array(x1, mask=[1,0,0,0])
          x3 = self.array(x1, mask=[0,1,0,1])
          x4 = self.array(x1)
      # test conversion to strings
          junk, garbage = str(x2), repr(x2)
  #        assert_equal(np.sort(x1), self.sort(x2, fill_value=0))
      # tests of indexing
          assert type(x2[1]) is type(x1[1])
          assert x1[1] == x2[1]
  #        assert self.allequal(x1[2],x2[2])
  #        assert self.allequal(x1[2:5],x2[2:5])
  #        assert self.allequal(x1[:],x2[:])
  #        assert self.allequal(x1[1:], x3[1:])
          x1[2] = 9
          x2[2] = 9
          self.assert_array_equal(x1,x2)
          x1[1:3] = 99
          x2[1:3] = 99
  #        assert self.allequal(x1,x2)
          x2[1] = self.masked
  #        assert self.allequal(x1,x2)
          x2[1:3] = self.masked
  #        assert self.allequal(x1,x2)
          x2[:] = x1
          x2[1] = self.masked
  #        assert self.allequal(self.getmask(x2),self.array([0,1,0,0]))
          x3[:] = self.masked_array([1,2,3,4],[0,1,1,0])
  #        assert self.allequal(self.getmask(x3), self.array([0,1,1,0]))
          x4[:] = self.masked_array([1,2,3,4],[0,1,1,0])
  #        assert self.allequal(self.getmask(x4), self.array([0,1,1,0]))
  #        assert self.allequal(x4, self.array([1,2,3,4]))
          x1 = np.arange(5)*1.0
          x2 = self.masked_values(x1, 3.0)
  #        assert self.allequal(x1,x2)
  #        assert self.allequal(self.array([0,0,0,1,0], self.MaskType), x2.mask)
          x1 = self.array([1,'hello',2,3],object)
          x2 = np.array([1,'hello',2,3],object)
          s1 = x1[1]
          s2 = x2[1]
          assert x1[1:1].shape == (0,)
          # Tests copy-size
          n = [0,0,1,0,0]
          m = self.make_mask(n)
          m2 = self.make_mask(m)
          assert(m is m2)
          m3 = self.make_mask(m, copy=1)
          assert(m is not m3)
function_tokens: def test_2 ( self ) : x1 = np . array ( [ 1 , 2 , 4 , 3 ] ) x2 = self . array ( x1 , mask = [ 1 , 0 , 0 , 0 ] ) x3 = self . array ( x1 , mask = [ 0 , 1 , 0 , 1 ] ) x4 = self . array ( x1 ) # test conversion to strings junk , garbage = str ( x2 ) , repr ( x2 ) #        assert_equal(np.sort(x1), self.sort(x2, fill_value=0)) # tests of indexing assert type ( x2 [ 1 ] ) is type ( x1 [ 1 ] ) assert x1 [ 1 ] == x2 [ 1 ] #        assert self.allequal(x1[2],x2[2]) #        assert self.allequal(x1[2:5],x2[2:5]) #        assert self.allequal(x1[:],x2[:]) #        assert self.allequal(x1[1:], x3[1:]) x1 [ 2 ] = 9 x2 [ 2 ] = 9 self . assert_array_equal ( x1 , x2 ) x1 [ 1 : 3 ] = 99 x2 [ 1 : 3 ] = 99 #        assert self.allequal(x1,x2) x2 [ 1 ] = self . masked #        assert self.allequal(x1,x2) x2 [ 1 : 3 ] = self . masked #        assert self.allequal(x1,x2) x2 [ : ] = x1 x2 [ 1 ] = self . masked #        assert self.allequal(self.getmask(x2),self.array([0,1,0,0])) x3 [ : ] = self . masked_array ( [ 1 , 2 , 3 , 4 ] , [ 0 , 1 , 1 , 0 ] ) #        assert self.allequal(self.getmask(x3), self.array([0,1,1,0])) x4 [ : ] = self . masked_array ( [ 1 , 2 , 3 , 4 ] , [ 0 , 1 , 1 , 0 ] ) #        assert self.allequal(self.getmask(x4), self.array([0,1,1,0])) #        assert self.allequal(x4, self.array([1,2,3,4])) x1 = np . arange ( 5 ) * 1.0 x2 = self . masked_values ( x1 , 3.0 ) #        assert self.allequal(x1,x2) #        assert self.allequal(self.array([0,0,0,1,0], self.MaskType), x2.mask) x1 = self . array ( [ 1 , 'hello' , 2 , 3 ] , object ) x2 = np . array ( [ 1 , 'hello' , 2 , 3 ] , object ) s1 = x1 [ 1 ] s2 = x2 [ 1 ] assert x1 [ 1 : 1 ] . shape == ( 0 , ) # Tests copy-size n = [ 0 , 0 , 1 , 0 , 0 ] m = self . make_mask ( n ) m2 = self . make_mask ( m ) assert ( m is m2 ) m3 = self . make_mask ( m , copy = 1 ) assert ( m is not m3 )