class_docstr: Test getting and setting global print options.
class_docstr_tok: ["Test","getting","and","setting","global","print","options","."]
code: def test_legacy_mode_scalars(self):
      # in legacy mode, str of floats get truncated, and complex scalars
      # use * for non-finite imaginary part
      np.set_printoptions(legacy="1.13")
      assert_equal(
          str(np.float64(1.123456789123456789)), "1.12345678912"
      )
      assert_equal(str(np.complex128(complex(1, np.nan))), "(1+nan*j)")
  
      np.set_printoptions(legacy=False)
      assert_equal(
          str(np.float64(1.123456789123456789)), "1.1234567891234568"
      )
      assert_equal(str(np.complex128(complex(1, np.nan))), "(1+nanj)")
  
imports: import sys
  import gc
  from hypothesis import given
  from hypothesis.extra import numpy
  import pytest
  import numpy
  from numpy.testing import assert_, assert_equal, assert_raises, assert_warns, HAS_REFCOUNT, assert_raises_regex
  from numpy.core.arrayprint import _typelessdata
  import textwrap
label_desc: Use image node_id 14 for calling the TestPrintOptions obj's underlying member method code with example usage: obj.test_legacy_mode_scalars() without return types