code: def test_empty_string():
      # Empty strings are unfortunately often converted to S1 and we need to
      # make sure we are filling the S1 and not the (possibly) detected S0
      # result.  This should likely just return S0 and if not maybe the decision
      # to return S1 should be moved.
      res = np.array([""] * 10, dtype="S")
      assert_array_equal(res, np.array("\0", "S1"))
      assert res.dtype == "S1"
  
      arr = np.array([""] * 10, dtype=object)
  
      res = arr.astype("S")
      assert_array_equal(res, b"")
      assert res.dtype == "S1"
  
      res = np.array(arr, dtype="S")
      assert_array_equal(res, b"")
      # TODO: This is arguably weird/wrong, but seems old:
      assert res.dtype == f"S{np.dtype('O').itemsize}"
  
      res = np.array([[""] * 10, arr], dtype="S")
      assert_array_equal(res, b"")
      assert res.shape == (2, 10)
      assert res.dtype == "S1"
  
imports: from itertools import permutations, product
  import pytest
  from pytest import param
  import numpy
  import numpy._core._multiarray_umath
  from numpy._core._rational_tests import rational
  from numpy.testing import assert_array_equal, assert_warns, IS_PYPY
label_desc: Use image node_id 5 for calling a global function with example usage: test_empty_string() without return types