code: def test_fromfile_complex(self):
      for ctype in ["complex", "cdouble", "cfloat"]:
          # Check spacing between separator and only real component specified
          with temppath() as path:
              with open(path, "w") as f:
                  f.write("1, 2 ,  3  ,4\n")
  
              res = np.fromfile(path, dtype=ctype, sep=",")
          assert_equal(res, np.array([1.0, 2.0, 3.0, 4.0]))
  
          # Real component not specified
          with temppath() as path:
              with open(path, "w") as f:
                  f.write("1j, -2j,  3j, 4e1j\n")
  
              res = np.fromfile(path, dtype=ctype, sep=",")
          assert_equal(res, np.array([1.0j, -2.0j, 3.0j, 40.0j]))
  
          # Both components specified
          with temppath() as path:
              with open(path, "w") as f:
                  f.write("1+1j,2-2j, -3+3j,  -4e1+4j\n")
  
              res = np.fromfile(path, dtype=ctype, sep=",")
          assert_equal(
              res,
              np.array(
                  [1.0 + 1.0j, 2.0 - 2.0j, -3.0 + 3.0j, -40.0 + 4j]
              ),
          )
  
          # Spaces at wrong places
          with temppath() as path:
              with open(path, "w") as f:
                  f.write("1+2 j,3\n")
  
              with assert_warns(DeprecationWarning):
                  res = np.fromfile(path, dtype=ctype, sep=",")
          assert_equal(res, np.array([1.0]))
  
          # Spaces at wrong places
          with temppath() as path:
              with open(path, "w") as f:
                  f.write("1+ 2j,3\n")
  
              with assert_warns(DeprecationWarning):
                  res = np.fromfile(path, dtype=ctype, sep=",")
          assert_equal(res, np.array([1.0]))
  
          # Spaces at wrong places
          with temppath() as path:
              with open(path, "w") as f:
                  f.write("1 +2j,3\n")
  
              with assert_warns(DeprecationWarning):
                  res = np.fromfile(path, dtype=ctype, sep=",")
          assert_equal(res, np.array([1.0]))
  
          # Spaces at wrong places
          with temppath() as path:
              with open(path, "w") as f:
                  f.write("1+j\n")
  
              with assert_warns(DeprecationWarning):
                  res = np.fromfile(path, dtype=ctype, sep=",")
          assert_equal(res, np.array([1.0]))
  
          # Spaces at wrong places
          with temppath() as path:
              with open(path, "w") as f:
                  f.write("1+\n")
  
              with assert_warns(DeprecationWarning):
                  res = np.fromfile(path, dtype=ctype, sep=",")
          assert_equal(res, np.array([1.0]))
  
          # Spaces at wrong places
          with temppath() as path:
              with open(path, "w") as f:
                  f.write("1j+1\n")
  
              with assert_warns(DeprecationWarning):
                  res = np.fromfile(path, dtype=ctype, sep=",")
          assert_equal(res, np.array([1.0j]))
  
imports: import warnings
  import platform
  import pytest
  import numpy
  from numpy.testing import assert_, assert_equal, assert_raises, assert_warns, assert_array_equal, temppath, IS_MUSL
  from __tests__.numpy.core.tests._locales import CommaDecimalPointLocale
label_desc: Use image node_id 2 for calling the TestFileBased obj's underlying member method code with example usage: obj.test_fromfile_complex() without return types