code: def test_nanfunctions_matrices_general():
      # Check that it works and that type and
      # shape are preserved
      # 2018-04-29: moved here from core.tests.test_nanfunctions
      mat = np.matrix(np.eye(3))
      for f in (
          np.nanargmin,
          np.nanargmax,
          np.nansum,
          np.nanprod,
          np.nanmean,
          np.nanvar,
          np.nanstd,
      ):
          res = f(mat, axis=0)
          assert_(isinstance(res, np.matrix))
          assert_(res.shape == (1, 3))
          res = f(mat, axis=1)
          assert_(isinstance(res, np.matrix))
          assert_(res.shape == (3, 1))
          res = f(mat)
          assert_(np.isscalar(res))
  
      for f in np.nancumsum, np.nancumprod:
          res = f(mat, axis=0)
          assert_(isinstance(res, np.matrix))
          assert_(res.shape == (3, 3))
          res = f(mat, axis=1)
          assert_(isinstance(res, np.matrix))
          assert_(res.shape == (3, 3))
          res = f(mat)
          assert_(isinstance(res, np.matrix))
          assert_(res.shape == (1, 3 * 3))
  
imports: import pytest
  import textwrap
  import warnings
  import numpy
  from numpy.testing import assert_, assert_equal, assert_raises, assert_raises_regex, assert_array_equal, assert_almost_equal, assert_array_almost_equal
label_desc: Use image node_id 14 for calling a global function with example usage: test_nanfunctions_matrices_general() without return types