• Virgile Andreani's avatar
    Changes for numpy 2.0 deprecations · ca089790
    Virgile Andreani 提交于
    - Replace np.cast with np.asarray: in numpy 2.0,
      `np.cast[new_dtype](arr)` is deprecated.
      The literal replacement is `np.asarray(arr, dtype=new_dtype)`.
    
    - Replace np.sctype2char and np.obj2sctype.
      Added try/except to handle change in behavior
      of `np.dtype`
    
    - Replace np.find_common_type with np.result_type
    
    Further changes to `TensorType`:
    
    TensorType.dtype must be a string, so the code
    has been changed from `self.dtype = np.dtype(dtype).type`,
    where the right-hand side is of type `np.generic`, to
    `self.dtype = str(np.dtype(dtype))`, where the right-hand
    side is a string that satisfies:
    
    `self.dtype == str(np.dtype(self.dtype))`
    
    This doesn't change the behavior of `np.array(..., dtype=self.dtype)`
    etc.
    ca089790
test_gradient.py 34.0 KB