import os
import sys
+import numpy as np
from numpy import (asarray, real, imag, conj, zeros, ndarray, concatenate,
ones, can_cast)
else:
if issymm and aij != aji:
issymm = False
- if isskew and aij != -aji:
- isskew = False
+ with np.errstate(over="ignore"):
+ # This can give a warning for uint dtypes, so silence that
+ if isskew and aij != -aji:
+ isskew = False
if isherm and aij != conj(aji):
isherm = False
if not (issymm or isskew or isherm):
if np.issubdtype(b_dtype, np.complexfloating):
b = b0.copy().astype(b_dtype)
else:
- b = b0.real.copy().astype(b_dtype)
+ with np.errstate(invalid="ignore"):
+ # Casting a large value (2**32) to int8 causes a warning in
+ # numpy >1.23
+ b = b0.real.copy().astype(b_dtype)
if not (a_dtype == np.bool_ and b_dtype == np.bool_):
c = np.zeros((2,), dtype=np.bool_)
def _rand_split(arrays, weights, axis, split_per, seed=None):
+ # Coerce `arrays` to float64 if integer, to avoid nan-to-integer issues
+ arrays = [arr.astype(np.float64) if np.issubdtype(arr.dtype, np.integer)
+ else arr for arr in arrays]
+
# inverse operation for stats.collapse_weights
weights = np.array(weights, dtype=np.float64) # modified inplace; need a copy
seeded_rand = np.random.RandomState(seed)