docstr: Test ndtype on dtypes
docstr_tok: ["Test","ndtype","on","dtypes"]
code: def test_easy_dtype(self):
      "Test ndtype on dtypes"
      # Simple case
      ndtype = float
      assert_equal(easy_dtype(ndtype), np.dtype(float))
      # As string w/o names
      ndtype = "i4, f8"
      assert_equal(
          easy_dtype(ndtype), np.dtype([("f0", "i4"), ("f1", "f8")])
      )
      # As string w/o names but different default format
      assert_equal(
          easy_dtype(ndtype, defaultfmt="field_%03i"),
          np.dtype([("field_000", "i4"), ("field_001", "f8")]),
      )
      # As string w/ names
      ndtype = "i4, f8"
      assert_equal(
          easy_dtype(ndtype, names="a, b"),
          np.dtype([("a", "i4"), ("b", "f8")]),
      )
      # As string w/ names (too many)
      ndtype = "i4, f8"
      assert_equal(
          easy_dtype(ndtype, names="a, b, c"),
          np.dtype([("a", "i4"), ("b", "f8")]),
      )
      # As string w/ names (not enough)
      ndtype = "i4, f8"
      assert_equal(
          easy_dtype(ndtype, names=", b"),
          np.dtype([("f0", "i4"), ("b", "f8")]),
      )
      # ... (with different default format)
      assert_equal(
          easy_dtype(ndtype, names="a", defaultfmt="f%02i"),
          np.dtype([("a", "i4"), ("f00", "f8")]),
      )
      # As list of tuples w/o names
      ndtype = [("A", int), ("B", float)]
      assert_equal(
          easy_dtype(ndtype), np.dtype([("A", int), ("B", float)])
      )
      # As list of tuples w/ names
      assert_equal(
          easy_dtype(ndtype, names="a,b"),
          np.dtype([("a", int), ("b", float)]),
      )
      # As list of tuples w/ not enough names
      assert_equal(
          easy_dtype(ndtype, names="a"),
          np.dtype([("a", int), ("f0", float)]),
      )
      # As list of tuples w/ too many names
      assert_equal(
          easy_dtype(ndtype, names="a,b,c"),
          np.dtype([("a", int), ("b", float)]),
      )
      # As list of types w/o names
      ndtype = (int, float, float)
      assert_equal(
          easy_dtype(ndtype),
          np.dtype([("f0", int), ("f1", float), ("f2", float)]),
      )
      # As list of types w names
      ndtype = (int, float, float)
      assert_equal(
          easy_dtype(ndtype, names="a, b, c"),
          np.dtype([("a", int), ("b", float), ("c", float)]),
      )
      # As simple dtype w/ names
      ndtype = np.dtype(float)
      assert_equal(
          easy_dtype(ndtype, names="a, b, c"),
          np.dtype([(_, float) for _ in ("a", "b", "c")]),
      )
      # As simple dtype w/o names (but multiple fields)
      ndtype = np.dtype(float)
      assert_equal(
          easy_dtype(ndtype, names=["", "", ""], defaultfmt="f%02i"),
          np.dtype([(_, float) for _ in ("f00", "f01", "f02")]),
      )
  
imports: import time
  from datetime import date
  import numpy
  from numpy.testing import assert_, assert_equal, assert_allclose, assert_raises
  from numpy.lib._iotools import LineSplitter, NameValidator, StringConverter, has_nested_fields, easy_dtype, flatten_dtype
label_desc: Use image node_id 2 for calling the TestMiscFunctions obj's underlying member method code with example usage: obj.test_easy_dtype() without return types