class_docstr: An ordered sequence of named coordinates of a specified dtype.
  
  A coordinate system is defined by the names of the coordinates,
  (attribute ``coord_names``) and the numpy dtype of each coordinate
  value (attribute ``coord_dtype``).  The coordinate system can also
  have a name.
  
  >>> names = ['first', 'second', 'third']
  >>> cs = CoordinateSystem(names, 'a coordinate system', np.float64)
  >>> cs.coord_names
  ('first', 'second', 'third')
  >>> cs.name
  'a coordinate system'
  >>> cs.coord_dtype
  dtype('float64')
  
  The coordinate system also has a ``dtype`` which is the composite
  numpy dtype, made from the (``names``, ``coord_dtype``).
  
  >>> dtype_template = [(name, np.float64) for name in cs.coord_names]
  >>> dtype_should_be = np.dtype(dtype_template)
  >>> cs.dtype == dtype_should_be
  True
  
  Two CoordinateSystems are equal if they have the same dtype
  and the same names and the same name.
  
  >>> another_cs = CoordinateSystem(names, 'not irrelevant', np.float64)
  >>> cs == another_cs
  False
  >>> cs.dtype == another_cs.dtype
  True
  >>> cs.name == another_cs.name
  False
class_docstr_tok: ["An","ordered","sequence","of","named","coordinates","of","a","specified","dtype",".","A","coordinate","system","is","defined","by","the","names","of","the","coordinates",",","(","attribute","``","coord_names","``",")","and","the","numpy","dtype","of","each","coordinate","value","(","attribute","``","coord_dtype","``",")",".","The","coordinate","system","can","also","have","a","name",".",">",">",">","names","=","[","'first","'",",","'second","'",",","'third","'","]",">",">",">","cs","=","CoordinateSystem","(","names",",","'","a","coordinate","system","'",",","np.float64",")",">",">",">","cs.coord_names","(","'first","'",",","'second","'",",","'third","'",")",">",">",">","cs.name","'","a","coordinate","system'",">",">",">","cs.coord_dtype","dtype","(","'float64","'",")","The","coordinate","system","also","has","a","``","dtype","``","which","is","the","composite","numpy","dtype",",","made","from","the","(","``","names","``",",","``","coord_dtype","``",")",".",">",">",">","dtype_template","=","[","(","name",",","np.float64",")","for","name","in","cs.coord_names","]",">",">",">","dtype_should_be","=","np.dtype","(","dtype_template",")",">",">",">","cs.dtype","==","dtype_should_be","True","Two","CoordinateSystems","are","equal","if","they","have","the","same","dtype","and","the","same","names","and","the","same","name",".",">",">",">","another_cs","=","CoordinateSystem","(","names",",","'not","irrelevant","'",",","np.float64",")",">",">",">","cs","==","another_cs","False",">",">",">","cs.dtype","==","another_cs.dtype","True",">",">",">","cs.name","==","another_cs.name","False"]
docstr: Check ``arr`` for valid dtype and shape as coordinate values.
  
  Raise Errors for failed checks.
  
  The dtype of ``arr`` has to be castable (without loss of precision) to
  ``self.coord_dtype``.  We use numpy ``can_cast`` for this check.
  
  The last (or only) axis of ``arr`` should be of length ``self.ndim``.
  
  Parameters
  ----------
  arr : array-like
      array to check
  
  Returns
  -------
  checked_arr : array
      Possibly reshaped array
  
  Examples
  --------
  >>> cs = CoordinateSystem('ijk', coord_dtype=np.float32)
  >>> arr = np.array([1, 2, 3], dtype=np.int16)
  >>> cs._checked_values(arr) # 1D is OK with matching dimensions
  array([[1, 2, 3]], dtype=int16)
  >>> cs._checked_values(arr.reshape(1,3)) # as is 1 by N
  array([[1, 2, 3]], dtype=int16)
  
  This next is the wrong shape:
  
  >>> cs._checked_values(arr.reshape(3,1)) #doctest: +IGNORE_EXCEPTION_DETAIL
  Traceback (most recent call last):
     ...
  CoordinateSystemError: Array shape[-1] (1) must match CoordinateSystem ndim (3).
    CoordinateSystem(coord_names=('i', 'j', 'k'), name='', coord_dtype=float32)
  
  Wrong length:
  
  >>> cs._checked_values(arr[0:2]) #doctest: +IGNORE_EXCEPTION_DETAIL
  Traceback (most recent call last):
     ...
  CoordinateSystemError: Array shape[-1] (2) must match CoordinateSystem ndim (3).
    CoordinateSystem(coord_names=('i', 'j', 'k'), name='', coord_dtype=float32)
  
  The dtype has to be castable:
  
  >>> cs._checked_values(np.array([1, 2, 3], dtype=np.float64)) #doctest: +IGNORE_EXCEPTION_DETAIL
  Traceback (most recent call last):
     ...
  CoordinateSystemError: Cannot cast array dtype float64 to CoordinateSystem coord_dtype float32.
    CoordinateSystem(coord_names=('i', 'j', 'k'), name='', coord_dtype=float32)
  
  The input array is unchanged, even if a reshape has
  occurred. The returned array points to the same data.
  
  >>> checked = cs._checked_values(arr)
  >>> checked.shape == arr.shape
  False
  >>> checked is arr
  False
  >>> arr[0]
  1
  >>> checked[0,0] = 10
  >>> arr[0]
  10
  
  For a 1D CoordinateSystem, passing a 1D vector length N could be a
  mistake (you were expecting an N-dimensional coordinate system), or it
  could be N points in 1D.  Because it is ambiguous, this is an error.
  
  >>> cs = CoordinateSystem('x')
  >>> cs._checked_values(1)
  array([[1]])
  >>> cs._checked_values([1, 2]) #doctest: +IGNORE_EXCEPTION_DETAIL
  Traceback (most recent call last):
     ...
  CoordinateSystemError: Array shape[-1] (2) must match CoordinateSystem ndim (1).
    CoordinateSystem(coord_names=('x',), name='', coord_dtype=float64)
  
  But of course 2D, N by 1 is OK
  
  >>> cs._checked_values(np.array([1,2,3]).reshape(3, 1))
  array([[1],
         [2],
         [3]])
docstr_tok: ["Check","``","arr","``","for","valid","dtype","and","shape","as","coordinate","values",".","Raise","Errors","for","failed","checks",".","The","dtype","of","``","arr","``","has","to","be","castable","(","without","loss","of","precision",")","to","``","self.coord_dtype","``",".","We","use","numpy","``","can_cast","``","for","this","check",".","The","last","(","or","only",")","axis","of","``","arr","``","should","be","of","length","``","self.ndim","``",".","Parameters","--","--","--","--","--","arr",":","array-like","array","to","check","Returns","--","--","--","-","checked_arr",":","array","Possibly","reshaped","array","Examples","--","--","--","--",">",">",">","cs","=","CoordinateSystem","(","'ijk","'",",","coord_dtype=np.float32",")",">",">",">","arr","=","np.array","(","[","1",",","2",",","3","]",",","dtype=np.int16",")",">",">",">","cs._checked_values","(","arr",")","#","1D","is","OK","with","matching","dimensions","array","(","[","[","1",",","2",",","3","]","]",",","dtype=int16",")",">",">",">","cs._checked_values","(","arr.reshape","(","1,3",")",")","#","as","is","1","by","N","array","(","[","[","1",",","2",",","3","]","]",",","dtype=int16",")","This","next","is","the","wrong","shape",":",">",">",">","cs._checked_values","(","arr.reshape","(","3,1",")",")","#","doctest",":","+IGNORE_EXCEPTION_DETAIL","Traceback","(","most","recent","call","last",")",":","...","CoordinateSystemError",":","Array","shape","[","-1","]","(","1",")","must","match","CoordinateSystem","ndim","(","3",")",".","CoordinateSystem","(","coord_names=","(","'","i","'",",","'","j","'",",","'","k","'",")",",","name=","''",",","coord_dtype=float32",")","Wrong","length",":",">",">",">","cs._checked_values","(","arr","[","0:2","]",")","#","doctest",":","+IGNORE_EXCEPTION_DETAIL","Traceback","(","most","recent","call","last",")",":","...","CoordinateSystemError",":","Array","shape","[","-1","]","(","2",")","must","match","CoordinateSystem","ndim","(","3",")",".","CoordinateSystem","(","coord_names=","(","'","i","'",",","'","j","'",",","'","k","'",")",",","name=","''",",","coord_dtype=float32",")","The","dtype","has","to","be","castable",":",">",">",">","cs._checked_values","(","np.array","(","[","1",",","2",",","3","]",",","dtype=np.float64",")",")","#","doctest",":","+IGNORE_EXCEPTION_DETAIL","Traceback","(","most","recent","call","last",")",":","...","CoordinateSystemError",":","Can","not","cast","array","dtype","float64","to","CoordinateSystem","coord_dtype","float32",".","CoordinateSystem","(","coord_names=","(","'","i","'",",","'","j","'",",","'","k","'",")",",","name=","''",",","coord_dtype=float32",")","The","input","array","is","unchanged",",","even","if","a","reshape","has","occurred",".","The","returned","array","points","to","the","same","data",".",">",">",">","checked","=","cs._checked_values","(","arr",")",">",">",">","checked.shape","==","arr.shape","False",">",">",">","checked","is","arr","False",">",">",">","arr","[","0","]","1",">",">",">","checked","[","0,0","]","=","10",">",">",">","arr","[","0","]","10","For","a","1D","CoordinateSystem",",","passing","a","1D","vector","length","N","could","be","a","mistake","(","you","were","expecting","an","N-dimensional","coordinate","system",")",",","or","it","could","be","N","points","in","1D",".","Because","it","is","ambiguous",",","this","is","an","error",".",">",">",">","cs","=","CoordinateSystem","(","'","x","'",")",">",">",">","cs._checked_values","(","1",")","array","(","[","[","1","]","]",")",">",">",">","cs._checked_values","(","[","1",",","2","]",")","#","doctest",":","+IGNORE_EXCEPTION_DETAIL","Traceback","(","most","recent","call","last",")",":","...","CoordinateSystemError",":","Array","shape","[","-1","]","(","2",")","must","match","CoordinateSystem","ndim","(","1",")",".","CoordinateSystem","(","coord_names=","(","'","x","'",",",")",",","name=","''",",","coord_dtype=float64",")","But","of","course","2D",",","N","by","1","is","OK",">",">",">","cs._checked_values","(","np.array","(","[","1,2,3","]",")",".reshape","(","3",",","1",")",")","array","(","[","[","1","]",",","[","2","]",",","[","3","]","]",")"]
code: def _checked_values(self, arr):
      """Check ``arr`` for valid dtype and shape as coordinate values.
  
      Raise Errors for failed checks.
  
      The dtype of ``arr`` has to be castable (without loss of precision) to
      ``self.coord_dtype``.  We use numpy ``can_cast`` for this check.
  
      The last (or only) axis of ``arr`` should be of length ``self.ndim``.
  
      Parameters
      ----------
      arr : array-like
          array to check
  
      Returns
      -------
      checked_arr : array
          Possibly reshaped array
  
      Examples
      --------
      >>> cs = CoordinateSystem('ijk', coord_dtype=np.float32)
      >>> arr = np.array([1, 2, 3], dtype=np.int16)
      >>> cs._checked_values(arr) # 1D is OK with matching dimensions
      array([[1, 2, 3]], dtype=int16)
      >>> cs._checked_values(arr.reshape(1,3)) # as is 1 by N
      array([[1, 2, 3]], dtype=int16)
  
      This next is the wrong shape:
  
      >>> cs._checked_values(arr.reshape(3,1)) #doctest: +IGNORE_EXCEPTION_DETAIL
      Traceback (most recent call last):
         ...
      CoordinateSystemError: Array shape[-1] (1) must match CoordinateSystem ndim (3).
        CoordinateSystem(coord_names=('i', 'j', 'k'), name='', coord_dtype=float32)
  
      Wrong length:
  
      >>> cs._checked_values(arr[0:2]) #doctest: +IGNORE_EXCEPTION_DETAIL
      Traceback (most recent call last):
         ...
      CoordinateSystemError: Array shape[-1] (2) must match CoordinateSystem ndim (3).
        CoordinateSystem(coord_names=('i', 'j', 'k'), name='', coord_dtype=float32)
  
      The dtype has to be castable:
  
      >>> cs._checked_values(np.array([1, 2, 3], dtype=np.float64)) #doctest: +IGNORE_EXCEPTION_DETAIL
      Traceback (most recent call last):
         ...
      CoordinateSystemError: Cannot cast array dtype float64 to CoordinateSystem coord_dtype float32.
        CoordinateSystem(coord_names=('i', 'j', 'k'), name='', coord_dtype=float32)
  
      The input array is unchanged, even if a reshape has
      occurred. The returned array points to the same data.
  
      >>> checked = cs._checked_values(arr)
      >>> checked.shape == arr.shape
      False
      >>> checked is arr
      False
      >>> arr[0]
      1
      >>> checked[0,0] = 10
      >>> arr[0]
      10
  
      For a 1D CoordinateSystem, passing a 1D vector length N could be a
      mistake (you were expecting an N-dimensional coordinate system), or it
      could be N points in 1D.  Because it is ambiguous, this is an error.
  
      >>> cs = CoordinateSystem('x')
      >>> cs._checked_values(1)
      array([[1]])
      >>> cs._checked_values([1, 2]) #doctest: +IGNORE_EXCEPTION_DETAIL
      Traceback (most recent call last):
         ...
      CoordinateSystemError: Array shape[-1] (2) must match CoordinateSystem ndim (1).
        CoordinateSystem(coord_names=('x',), name='', coord_dtype=float64)
  
      But of course 2D, N by 1 is OK
  
      >>> cs._checked_values(np.array([1,2,3]).reshape(3, 1))
      array([[1],
             [2],
             [3]])
      """
      arr = np.atleast_2d(arr)
      if arr.shape[-1] != self.ndim:
          raise CoordinateSystemError(
              f"Array shape[-1] ({arr.shape[-1]}) must match "
              f"CoordinateSystem ndim ({self.ndim}).\n  {self}"
          )
      if not np.can_cast(arr.dtype, self.coord_dtype):
          raise CoordinateSystemError(
              f"Cannot cast array dtype {arr.dtype} to "
              f"CoordinateSystem coord_dtype {self.coord_dtype}.\n  {self}"
          )
      return arr.reshape((-1, self.ndim))
  
imports: import numpy
label_desc: Use image node_id 8 for calling the CoordinateSystem obj's underlying member method code with example usage: obj._checked_values(arr) and returns: arr