devjas1 commited on
Commit
b1b7e3c
·
1 Parent(s): d0109c7

(FIX): correct y array casting in '_ensure_1d_equal' to fix resampled plot

Browse files
Files changed (1) hide show
  1. utils/preprocessing.py +3 -3
utils/preprocessing.py CHANGED
@@ -12,16 +12,16 @@ from scipy.interpolate import interp1d
12
 
13
  TARGET_LENGTH = 500 # Frozen default per PREPROCESSING_BASELINE
14
 
15
- def __ensure_1d_equal(x: np.ndarray, y: np.ndarray) -> tuple[np.ndarray, np.ndarray]:
16
  x = np.asarray(x, dtype=float)
17
- y = np.asarray(x, dtype=float)
18
  if x.ndim != 1 or y.ndim != 1 or x.size != y.size or x.size < 2:
19
  raise ValueError("x and y must be 1D arrays of equal length >= 2")
20
  return x, y
21
 
22
  def resample_spectrum(x: np.ndarray, y: np.ndarray, target_len: int = TARGET_LENGTH) -> tuple[np.ndarray, np.ndarray]:
23
  """Linear re-sampling onto a uniform grid of length target_len."""
24
- x, y = __ensure_1d_equal(x, y)
25
  order = np.argsort(x)
26
  x_sorted, y_sorted = x[order], y[order]
27
  x_new = np.linspace(x_sorted[0], x_sorted[-1], int(target_len))
 
12
 
13
  TARGET_LENGTH = 500 # Frozen default per PREPROCESSING_BASELINE
14
 
15
+ def _ensure_1d_equal(x: np.ndarray, y: np.ndarray) -> tuple[np.ndarray, np.ndarray]:
16
  x = np.asarray(x, dtype=float)
17
+ y = np.asarray(y, dtype=float)
18
  if x.ndim != 1 or y.ndim != 1 or x.size != y.size or x.size < 2:
19
  raise ValueError("x and y must be 1D arrays of equal length >= 2")
20
  return x, y
21
 
22
  def resample_spectrum(x: np.ndarray, y: np.ndarray, target_len: int = TARGET_LENGTH) -> tuple[np.ndarray, np.ndarray]:
23
  """Linear re-sampling onto a uniform grid of length target_len."""
24
+ x, y = _ensure_1d_equal(x, y)
25
  order = np.argsort(x)
26
  x_sorted, y_sorted = x[order], y[order]
27
  x_new = np.linspace(x_sorted[0], x_sorted[-1], int(target_len))