diff --git a/musicflower/plotting.py b/musicflower/plotting.py index e5ee724..b50c066 100644 --- a/musicflower/plotting.py +++ b/musicflower/plotting.py @@ -25,9 +25,9 @@ def rgba(*args): if len(args) == 1: - rgba = np.asfarray(args[0]) + rgba = np.asarray(args[0], dtype=float) else: - rgba = np.asfarray(args) + rgba = np.asarray(args, dtype=float) if len(rgba) not in [3, 4]: raise ValueError("rgba values have to be specified as (an array of) 3 or 4 values") if np.any(rgba > 1) or np.any(rgba < 0): @@ -40,8 +40,8 @@ def rgba(*args): def rgba_mix(colors, weights, normalise=True): - colors = np.asfarray(colors) - weights = np.asfarray(weights) + colors = np.asarray(colors, dtype=float) + weights = np.asarray(weights, dtype=float) if np.any(weights < 0): raise ValueError("'weights' must be positive") if normalise: @@ -447,7 +447,7 @@ def make_parallels(n_levels=5, def plot_pcd_marker(pcd, labels, name=None, groupname=None, group=None, r=None, parallels_kwargs=(), meridians_kwargs=(), label_kwargs=()): - pcd = np.asfarray(pcd) + pcd = np.asarray(pcd, dtype=float) amplitude, phase = get_fourier_component(pcds=pcd[None], fourier_component=5) x, y, z = remap_to_xyz(amplitude=amplitude, phase=phase) altitude = np.arctan2(z, np.sqrt(x ** 2 + y ** 2))[0] @@ -491,10 +491,10 @@ def add_key_markers(fig, **kwargs): def ellipse_coords(r1, r2, centre=(0, 0, 0), n=100, plane=None): - centre = np.asfarray(centre) + centre = np.asarray(centre, dtype=float) if plane is None: - r1 = np.asfarray(r1) - r2 = np.asfarray(r2) + r1 = np.asarray(r1, dtype=float) + r2 = np.asarray(r2, dtype=float) elif plane == 'xy': r1 = r1 * np.array([1, 0, 0]) r2 = r2 * np.array([0, 1, 0]) diff --git a/musicflower/util.py b/musicflower/util.py index a6e9db2..02ff5a3 100644 --- a/musicflower/util.py +++ b/musicflower/util.py @@ -25,7 +25,7 @@ def get_fourier_component(pcds: np.ndarray, fourier_component: int = None) -> np :return: array of shape (2, ..., n//2 + 1) with amplitude and phase along the first dimension and the different Fourier components along the last dimension """ - pcds = np.asfarray(pcds) + pcds = np.asarray(pcds, dtype=float) pcds /= pcds.sum(axis=-1, keepdims=True) ft = np.fft.rfft(pcds, axis=-1) if fourier_component is not None: diff --git a/musicflower/webapp.py b/musicflower/webapp.py index 877ed14..99e036a 100644 --- a/musicflower/webapp.py +++ b/musicflower/webapp.py @@ -109,7 +109,7 @@ def check_features(cls, features, n=1, asfarray=True): if len(features) != n: raise ValueError(f"expected {n} features but got {len(features)}") if asfarray: - features = [np.asfarray(f) for f in features] + features = [np.asarray(f, dtype=float) for f in features] if n == 1: features = features[0] return features