code-loader 1.0.200__tar.gz → 1.0.201.dev0__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {code_loader-1.0.200 → code_loader-1.0.201.dev0}/PKG-INFO +1 -1
- {code_loader-1.0.200 → code_loader-1.0.201.dev0}/code_loader/contract/visualizer_classes.py +3 -10
- {code_loader-1.0.200 → code_loader-1.0.201.dev0}/code_loader/visualizers/default_visualizers.py +21 -28
- {code_loader-1.0.200 → code_loader-1.0.201.dev0}/pyproject.toml +1 -1
- code_loader-1.0.200/code_loader/contract/__pycache__/__init__.cpython-39.pyc +0 -0
- code_loader-1.0.200/code_loader/contract/__pycache__/datasetclasses.cpython-39.pyc +0 -0
- code_loader-1.0.200/code_loader/contract/__pycache__/enums.cpython-39.pyc +0 -0
- code_loader-1.0.200/code_loader/contract/__pycache__/exceptions.cpython-39.pyc +0 -0
- code_loader-1.0.200/code_loader/contract/__pycache__/mapping.cpython-39.pyc +0 -0
- code_loader-1.0.200/code_loader/contract/__pycache__/responsedataclasses.cpython-39.pyc +0 -0
- code_loader-1.0.200/code_loader/contract/__pycache__/sim_config.cpython-39.pyc +0 -0
- code_loader-1.0.200/code_loader/contract/__pycache__/visualizer_classes.cpython-39.pyc +0 -0
- code_loader-1.0.200/code_loader/experiment_api/__pycache__/__init__.cpython-39.pyc +0 -0
- code_loader-1.0.200/code_loader/experiment_api/__pycache__/api.cpython-39.pyc +0 -0
- code_loader-1.0.200/code_loader/experiment_api/__pycache__/cli_config_utils.cpython-39.pyc +0 -0
- code_loader-1.0.200/code_loader/experiment_api/__pycache__/client.cpython-39.pyc +0 -0
- code_loader-1.0.200/code_loader/experiment_api/__pycache__/epoch.cpython-39.pyc +0 -0
- code_loader-1.0.200/code_loader/experiment_api/__pycache__/experiment.cpython-39.pyc +0 -0
- code_loader-1.0.200/code_loader/experiment_api/__pycache__/experiment_context.cpython-39.pyc +0 -0
- code_loader-1.0.200/code_loader/experiment_api/__pycache__/types.cpython-39.pyc +0 -0
- code_loader-1.0.200/code_loader/experiment_api/__pycache__/utils.cpython-39.pyc +0 -0
- code_loader-1.0.200/code_loader/experiment_api/__pycache__/workingspace_config_utils.cpython-39.pyc +0 -0
- code_loader-1.0.200/code_loader/inner_leap_binder/__pycache__/__init__.cpython-39.pyc +0 -0
- code_loader-1.0.200/code_loader/inner_leap_binder/__pycache__/leapbinder.cpython-39.pyc +0 -0
- code_loader-1.0.200/code_loader/inner_leap_binder/__pycache__/leapbinder_decorators.cpython-39.pyc +0 -0
- code_loader-1.0.200/code_loader/visualizers/__pycache__/__init__.cpython-39.pyc +0 -0
- code_loader-1.0.200/code_loader/visualizers/__pycache__/default_visualizers.cpython-39.pyc +0 -0
- {code_loader-1.0.200 → code_loader-1.0.201.dev0}/LICENSE +0 -0
- {code_loader-1.0.200 → code_loader-1.0.201.dev0}/README.md +0 -0
- {code_loader-1.0.200 → code_loader-1.0.201.dev0}/code_loader/__init__.py +0 -0
- {code_loader-1.0.200 → code_loader-1.0.201.dev0}/code_loader/contract/__init__.py +0 -0
- {code_loader-1.0.200 → code_loader-1.0.201.dev0}/code_loader/contract/datasetclasses.py +0 -0
- {code_loader-1.0.200 → code_loader-1.0.201.dev0}/code_loader/contract/enums.py +0 -0
- {code_loader-1.0.200 → code_loader-1.0.201.dev0}/code_loader/contract/exceptions.py +0 -0
- {code_loader-1.0.200 → code_loader-1.0.201.dev0}/code_loader/contract/mapping.py +0 -0
- {code_loader-1.0.200 → code_loader-1.0.201.dev0}/code_loader/contract/responsedataclasses.py +0 -0
- {code_loader-1.0.200 → code_loader-1.0.201.dev0}/code_loader/contract/sim_config.py +0 -0
- {code_loader-1.0.200 → code_loader-1.0.201.dev0}/code_loader/default_losses.py +0 -0
- {code_loader-1.0.200 → code_loader-1.0.201.dev0}/code_loader/default_metrics.py +0 -0
- {code_loader-1.0.200 → code_loader-1.0.201.dev0}/code_loader/experiment_api/__init__.py +0 -0
- {code_loader-1.0.200 → code_loader-1.0.201.dev0}/code_loader/experiment_api/api.py +0 -0
- {code_loader-1.0.200 → code_loader-1.0.201.dev0}/code_loader/experiment_api/cli_config_utils.py +0 -0
- {code_loader-1.0.200 → code_loader-1.0.201.dev0}/code_loader/experiment_api/client.py +0 -0
- {code_loader-1.0.200 → code_loader-1.0.201.dev0}/code_loader/experiment_api/epoch.py +0 -0
- {code_loader-1.0.200 → code_loader-1.0.201.dev0}/code_loader/experiment_api/experiment.py +0 -0
- {code_loader-1.0.200 → code_loader-1.0.201.dev0}/code_loader/experiment_api/experiment_context.py +0 -0
- {code_loader-1.0.200 → code_loader-1.0.201.dev0}/code_loader/experiment_api/types.py +0 -0
- {code_loader-1.0.200 → code_loader-1.0.201.dev0}/code_loader/experiment_api/utils.py +0 -0
- {code_loader-1.0.200 → code_loader-1.0.201.dev0}/code_loader/experiment_api/workingspace_config_utils.py +0 -0
- {code_loader-1.0.200 → code_loader-1.0.201.dev0}/code_loader/inner_leap_binder/__init__.py +0 -0
- {code_loader-1.0.200 → code_loader-1.0.201.dev0}/code_loader/inner_leap_binder/leapbinder.py +0 -0
- {code_loader-1.0.200 → code_loader-1.0.201.dev0}/code_loader/inner_leap_binder/leapbinder_decorators.py +0 -0
- {code_loader-1.0.200 → code_loader-1.0.201.dev0}/code_loader/leaploader.py +0 -0
- {code_loader-1.0.200 → code_loader-1.0.201.dev0}/code_loader/leaploaderbase.py +0 -0
- {code_loader-1.0.200 → code_loader-1.0.201.dev0}/code_loader/mixpanel_tracker.py +0 -0
- {code_loader-1.0.200 → code_loader-1.0.201.dev0}/code_loader/plot_functions/__init__.py +0 -0
- {code_loader-1.0.200 → code_loader-1.0.201.dev0}/code_loader/plot_functions/plot_functions.py +0 -0
- {code_loader-1.0.200 → code_loader-1.0.201.dev0}/code_loader/plot_functions/visualize.py +0 -0
- {code_loader-1.0.200 → code_loader-1.0.201.dev0}/code_loader/utils.py +0 -0
- {code_loader-1.0.200 → code_loader-1.0.201.dev0}/code_loader/visualizers/__init__.py +0 -0
|
@@ -357,16 +357,14 @@ class LeapAudio:
|
|
|
357
357
|
should be mixed down before constructing LeapAudio.
|
|
358
358
|
sample_rate (int): Samples per second — needed to encode the clip and to map
|
|
359
359
|
the playhead position to time.
|
|
360
|
-
visual (Union[LeapImage, LeapGraph]): The thing you look at.
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
(0, N / sample_rate).
|
|
360
|
+
visual (Union[LeapImage, LeapGraph]): The thing you look at. For a waveform
|
|
361
|
+
the nested LeapGraph carries its own x_range (time span); the playhead is
|
|
362
|
+
driven by the audio element's currentTime, so no time range is needed here.
|
|
364
363
|
type (LeapDataType): The data type, default is LeapDataType.Audio.
|
|
365
364
|
"""
|
|
366
365
|
audio: npt.NDArray
|
|
367
366
|
sample_rate: int
|
|
368
367
|
visual: Union[LeapImage, LeapGraph]
|
|
369
|
-
x_range: Optional[Tuple[float, float]] = None
|
|
370
368
|
type: LeapDataType = LeapDataType.Audio
|
|
371
369
|
|
|
372
370
|
def __post_init__(self) -> None:
|
|
@@ -377,11 +375,6 @@ class LeapAudio:
|
|
|
377
375
|
'Audio visual must be a LeapImage (spectrogram) or LeapGraph (waveform)')
|
|
378
376
|
if not isinstance(self.sample_rate, int) or self.sample_rate <= 0:
|
|
379
377
|
raise LeapValidationError(f'sample_rate must be a positive int, got {self.sample_rate}')
|
|
380
|
-
if self.x_range is not None:
|
|
381
|
-
if len(self.x_range) != 2:
|
|
382
|
-
raise LeapValidationError('x_range must be a tuple of length 2')
|
|
383
|
-
validate_type(type(self.x_range[0]), [float, int], 'x_range must be a tuple of floats or integers')
|
|
384
|
-
validate_type(type(self.x_range[1]), [float, int], 'x_range must be a tuple of floats or integers')
|
|
385
378
|
|
|
386
379
|
|
|
387
380
|
map_leap_data_type_to_visualizer_class = {
|
{code_loader-1.0.200 → code_loader-1.0.201.dev0}/code_loader/visualizers/default_visualizers.py
RENAMED
|
@@ -31,7 +31,6 @@ def default_video_visualizer(data: npt.NDArray[np.float32]) -> LeapVideo:
|
|
|
31
31
|
|
|
32
32
|
|
|
33
33
|
_MAX_WAVEFORM_POINTS = 2000
|
|
34
|
-
_VISUAL_KINDS = ('waveform', 'spectrogram', 'image')
|
|
35
34
|
|
|
36
35
|
|
|
37
36
|
def _to_mono(audio: npt.NDArray) -> npt.NDArray:
|
|
@@ -54,49 +53,43 @@ def _waveform_graph(series: npt.NDArray, duration: float) -> LeapGraph:
|
|
|
54
53
|
def default_audio_visualizer(audio: npt.NDArray,
|
|
55
54
|
sample_rate: int,
|
|
56
55
|
visual: Optional[npt.NDArray] = None,
|
|
57
|
-
visual_kind: Optional[str] = None,
|
|
58
56
|
time_axis_index: int = -1) -> LeapAudio:
|
|
59
57
|
"""Package a playable audio sample plus the visual a playhead runs through.
|
|
60
58
|
|
|
61
59
|
audio: waveform samples (mono [N], or multi-channel that is mixed down).
|
|
62
60
|
sample_rate: samples per second.
|
|
63
|
-
visual: the array to display
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
61
|
+
visual: the array to display; its kind is deduced from its shape.
|
|
62
|
+
1-D [N] -> waveform graph of the samples.
|
|
63
|
+
2-D [H, W] -> spectrogram, rendered grayscale.
|
|
64
|
+
3-D [H, W, C] -> already-rendered image; C must be 3 (rgb) or 1 (grayscale).
|
|
67
65
|
If omitted, a waveform graph is built from `audio` itself.
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
Required when `visual` is given; ignored when `visual` is omitted.
|
|
71
|
-
time_axis_index: for 'spectrogram', which axis of `visual` is time (moved to columns).
|
|
72
|
-
Unused for 'waveform'/'image'.
|
|
66
|
+
time_axis_index: for a spectrogram, which axis of `visual` is time (moved to columns).
|
|
67
|
+
Unused otherwise.
|
|
73
68
|
"""
|
|
74
69
|
mono = _to_mono(audio)
|
|
75
70
|
duration = mono.shape[0] / float(sample_rate)
|
|
76
|
-
x_range = (0.0, duration)
|
|
77
71
|
|
|
78
72
|
if visual is None: # no visual given: show the raw signal as a waveform
|
|
79
|
-
return LeapAudio(mono, sample_rate, _waveform_graph(mono, duration)
|
|
80
|
-
|
|
81
|
-
if visual_kind not in _VISUAL_KINDS:
|
|
82
|
-
raise ValueError(f"visual_kind must be one of {_VISUAL_KINDS}, got {visual_kind!r}")
|
|
73
|
+
return LeapAudio(mono, sample_rate, _waveform_graph(mono, duration))
|
|
83
74
|
|
|
84
75
|
v = np.asarray(visual)
|
|
85
76
|
|
|
86
|
-
if
|
|
87
|
-
return LeapAudio(mono, sample_rate, _waveform_graph(v, duration)
|
|
77
|
+
if v.ndim == 1: # waveform
|
|
78
|
+
return LeapAudio(mono, sample_rate, _waveform_graph(v, duration))
|
|
79
|
+
|
|
80
|
+
if v.ndim == 3: # already-rendered image
|
|
81
|
+
if v.shape[-1] not in (1, 3):
|
|
82
|
+
raise ValueError(f'image visual must have 1 (grayscale) or 3 (rgb) channels, got shape {v.shape}')
|
|
83
|
+
return LeapAudio(mono, sample_rate, LeapImage(v))
|
|
88
84
|
|
|
89
|
-
if
|
|
90
|
-
|
|
85
|
+
if v.ndim == 2: # spectrogram
|
|
86
|
+
spec = v
|
|
87
|
+
if time_axis_index % 2 == 0: # move time onto the horizontal axis (columns)
|
|
88
|
+
spec = spec.T
|
|
89
|
+
img = rescale_min_max(spec.astype(np.float32))[..., None] # [freq, time, 1]
|
|
90
|
+
return LeapAudio(mono, sample_rate, LeapImage(img))
|
|
91
91
|
|
|
92
|
-
|
|
93
|
-
spec = np.squeeze(v)
|
|
94
|
-
if spec.ndim != 2:
|
|
95
|
-
raise ValueError(f'spectrogram visual must be 2-D (freq x time), got shape {v.shape}')
|
|
96
|
-
if time_axis_index % spec.ndim == 0: # move time onto the horizontal axis (columns)
|
|
97
|
-
spec = spec.T
|
|
98
|
-
img = rescale_min_max(spec.astype(np.float32))[..., None] # [freq, time, 1]
|
|
99
|
-
return LeapAudio(mono, sample_rate, LeapImage(img), x_range)
|
|
92
|
+
raise ValueError(f'visual must be 1-D, 2-D, or 3-D, got shape {v.shape}')
|
|
100
93
|
|
|
101
94
|
|
|
102
95
|
def default_graph_visualizer(data: npt.NDArray[np.float32]) -> LeapGraph:
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
code_loader-1.0.200/code_loader/experiment_api/__pycache__/experiment_context.cpython-39.pyc
DELETED
|
Binary file
|
|
Binary file
|
|
Binary file
|
code_loader-1.0.200/code_loader/experiment_api/__pycache__/workingspace_config_utils.cpython-39.pyc
DELETED
|
Binary file
|
|
Binary file
|
|
Binary file
|
code_loader-1.0.200/code_loader/inner_leap_binder/__pycache__/leapbinder_decorators.cpython-39.pyc
DELETED
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{code_loader-1.0.200 → code_loader-1.0.201.dev0}/code_loader/contract/responsedataclasses.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{code_loader-1.0.200 → code_loader-1.0.201.dev0}/code_loader/experiment_api/cli_config_utils.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{code_loader-1.0.200 → code_loader-1.0.201.dev0}/code_loader/experiment_api/experiment_context.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{code_loader-1.0.200 → code_loader-1.0.201.dev0}/code_loader/inner_leap_binder/leapbinder.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{code_loader-1.0.200 → code_loader-1.0.201.dev0}/code_loader/plot_functions/plot_functions.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|