harbor run -t openthoughts/tasktrove-exp-flat25-pseudocode-v2-5k-pseudocode-3053harbor download openthoughts/tasktrove-exp-flat25-pseudocode-v2-5k-pseudocode-3053PSEUDOCODE TASK (MODALITY: pseudocode only)
MODULE: wavy.py
DEFINE CLASS WaveValueError EXTENDS Exception
DEFINE CLASS Tags // placeholder; no required behavior END CLASS
DEFINE CLASS WaveFile METHOD init(self, sample_width: int, framerate: int, data: numpy.ndarray, tags=None) // Validation: type IF NOT isinstance(data, numpy.ndarray) THEN RAISE WaveValueError("Argument 'data' must be of type numpy.ndarray.") ENDIF
// Validation: non-empty
IF data.size == 0 THEN
RAISE WaveValueError("Data array cannot be empty.")
ENDIF
// Normalize 24-bit handling (store as 32-bit for dtype compatibility)
// Note: allowed sample_width values: 8, 16, 24, 32, 64
// Dtype compatibility per sample_width
IF sample_width == 8 THEN
IF data.dtype != numpy.uint8 THEN
RAISE WaveValueError(f"Data array dtype '{data.dtype}' is not supported.")
ENDIF
ENDIF
IF sample_width == 16 THEN
IF data.dtype == numpy.uint8 THEN
RAISE WaveValueError("Sample width of '16' is not supported for dtype 'uint8'.")
ELSE IF data.dtype != numpy.int16 THEN
RAISE WaveValueError(f"Data array dtype '{data.dtype}' is not supported.")
ENDIF
ENDIF
IF sample_width == 24 THEN
// Interpret 24-bit as 32-bit storage
IF data.dtype != numpy.int32 THEN
RAISE WaveValueError(f"Data array dtype '{data.dtype}' is not supported.")
ENDIF
ENDIF
IF sample_width == 32 THEN
IF NOT (data.dtype == numpy.int32 OR data.dtype == numpy.float32) THEN
RAISE WaveValueError(f"Data array dtype '{data.dtype}' is not supported.")
ENDIF
ENDIF
IF sample_width == 64 THEN
IF data.dtype != numpy.float64 THEN
RAISE WaveValueError(f"Data array dtype '{data.dtype}' is not supported.")
ENDIF
ENDIF
// Tags validation
IF tags IS NOT None AND NOT isinstance(tags, Tags) THEN
RAISE WaveValueError("Argument 'tags' must be of type 'wavy.Tags'.")
ENDIF
// Data shape and channel interpretation
IF data.ndim == 1 THEN
n_frames = data.shape[0]
n_channels = 1
ELSE IF data.ndim == 2 THEN
n_frames = data.shape[0]
n_channels = data.shape[1]
ELSE
RAISE WaveValueError("Data array must be 1D or 2D array.")
ENDIF
// Successful storage
self.sample_width = sample_width
self.framerate = framerate
self.n_frames = n_frames
self.n_channels = n_channels
self.data = data
self.tags = tags
END METHOD END CLASS
END MODULE