code: def test_flat(self):
      # Test that flat can return items even for matrices [#4585, #4615]
      # test simple access
      test = masked_array(np.matrix([[1, 2, 3]]), mask=[0, 0, 1])
      assert_equal(test.flat[1], 2)
      assert_equal(test.flat[2], masked)
      assert_(np.all(test.flat[0:2] == test[0, 0:2]))
      # Test flat on masked_matrices
      test = masked_array(np.matrix([[1, 2, 3]]), mask=[0, 0, 1])
      test.flat = masked_array([3, 2, 1], mask=[1, 0, 0])
      control = masked_array(np.matrix([[3, 2, 1]]), mask=[1, 0, 0])
      assert_equal(test, control)
      # Test setting
      test = masked_array(np.matrix([[1, 2, 3]]), mask=[0, 0, 1])
      testflat = test.flat
      testflat[:] = testflat[[2, 1, 0]]
      assert_equal(test, control)
      testflat[0] = 9
      # test that matrices keep the correct shape (#4615)
      a = masked_array(np.matrix(np.eye(2)), mask=0)
      b = a.flat
      b01 = b[:2]
      assert_equal(b01.data, np.array([[1.0, 0.0]]))
      assert_equal(b01.mask, np.array([[False, False]]))
  
imports: import numpy
  from numpy.testing import assert_warns
  from numpy.ma.testutils import assert_, assert_equal, assert_raises, assert_array_equal
  from numpy.ma.core import masked_array, masked_values, masked, allequal, MaskType, getmask, MaskedArray, nomask, log, add, hypot, divide
  from numpy.ma.extras import mr_
  from numpy.compat import pickle
label_desc: Use image node_id 4 for calling the TestMaskedMatrix obj's underlying member method code with example usage: obj.test_flat() without return types