Commit a7b0ee56 authored by Florent Jaillet's avatar Florent Jaillet

Omptimize performance in Waveform.astype()

parent 5a2688df
Pipeline #470 passed with stage
in 29 seconds
......@@ -736,7 +736,7 @@ class Waveform(MadArray):
if (np.issubdtype(dtype, np.floating) or
np.issubdtype(dtype, np.complexfloating)):
y.clip(min_value=-1, max_value=(1 - np.finfo(dtype).eps))
y = np.array(y).astype(dtype)
y = np.asarray(y, dtype=dtype)
elif np.issubdtype(dtype, np.integer):
target_type_info = np.iinfo(dtype)
......@@ -745,7 +745,7 @@ class Waveform(MadArray):
target_type_info.min)
y.clip(min_value=np.iinfo(dtype).min,
max_value=np.iinfo(dtype).max)
y = np.array(y).astype(dtype)
y = np.asarray(y, dtype=dtype)
else:
errmsg = 'Unsupported target type {}.'
......@@ -760,16 +760,16 @@ class Waveform(MadArray):
y = ((super(type(y), y).astype(dtype) - zero)
/ (int_range // 2))
y.clip(min_value=-1, max_value=1-np.finfo(dtype).eps)
y = np.array(y).astype(dtype)
y = np.asarray(y, dtype=dtype)
elif np.issubdtype(dtype, np.integer):
y = y.astype(dtype=np.float64)
y = y.astype(dtype=dtype)
y = np.array(y)
y = np.asarray(y)
elif np.issubdtype(dtype, np.complexfloating):
y = y.astype(dtype=np.float64)
y = np.array(y).astype(dtype=dtype)
y = np.asarray(y, dtype=dtype)
else:
errmsg = 'Unsupported target type {}.'
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment