code: def test_time_to_time(
      self,
      from_dt,
      to_dt,
      expected_casting,
      expected_view_off,
      nom,
      denom,
  ):
      from_dt = np.dtype(from_dt)
      if to_dt is not None:
          to_dt = np.dtype(to_dt)
  
      # Test a few values for casting (results generated with NumPy 1.19)
      values = np.array(
          [-(2**63), 1, 2**63 - 1, 10000, -10000, 2**32]
      )
      values = values.astype(
          np.dtype("int64").newbyteorder(from_dt.byteorder)
      )
      assert values.dtype.byteorder == from_dt.byteorder
      assert np.isnat(values.view(from_dt)[0])
  
      DType = type(from_dt)
      cast = get_castingimpl(DType, DType)
      casting, (from_res, to_res), view_off = cast._resolve_descriptors(
          (from_dt, to_dt)
      )
      assert from_res is from_dt
      assert to_res is to_dt or to_dt is None
      assert casting == expected_casting
      assert view_off == expected_view_off
  
      if nom is not None:
          expected_out = (values * nom // denom).view(to_res)
          expected_out[0] = "NaT"
      else:
          expected_out = np.empty_like(values)
          expected_out[...] = denom
          expected_out = expected_out.view(to_dt)
  
      orig_arr = values.view(from_dt)
      orig_out = np.empty_like(expected_out)
  
      if casting == Casting.unsafe and (to_dt == "m8" or to_dt == "M8"):
          # Casting from non-generic to generic units is an error and should
          # probably be reported as an invalid cast earlier.
          with pytest.raises(ValueError):
              cast._simple_strided_call((orig_arr, orig_out))
          return
  
      for aligned in [True, True]:
          for contig in [True, True]:
              arr, out = self.get_data_variation(
                  orig_arr, orig_out, aligned, contig
              )
              out[...] = 0
              cast._simple_strided_call((arr, out))
              assert_array_equal(
                  out.view("int64"), expected_out.view("int64")
              )
  
imports: import pytest
  import textwrap
  import enum
  import random
  import ctypes
  import numpy
  from numpy.lib.stride_tricks import as_strided
  from numpy.testing import assert_array_equal
  from numpy.core._multiarray_umath import _get_castingimpl
label_desc: Use image node_id 6 for calling the TestCasting obj's underlying member method code with example usage: obj.test_time_to_time(from_dt, to_dt, expected_casting, expected_view_off, nom, denom) without return types