modusa 0.3.64__tar.gz → 0.3.66__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.
- {modusa-0.3.64 → modusa-0.3.66}/PKG-INFO +1 -1
- {modusa-0.3.64 → modusa-0.3.66}/pyproject.toml +1 -1
- {modusa-0.3.64 → modusa-0.3.66}/src/modusa/tools/plotter.py +83 -10
- {modusa-0.3.64 → modusa-0.3.66}/LICENSE.md +0 -0
- {modusa-0.3.64 → modusa-0.3.66}/README.md +0 -0
- {modusa-0.3.64 → modusa-0.3.66}/src/modusa/.DS_Store +0 -0
- {modusa-0.3.64 → modusa-0.3.66}/src/modusa/__init__.py +0 -0
- {modusa-0.3.64 → modusa-0.3.66}/src/modusa/config.py +0 -0
- {modusa-0.3.64 → modusa-0.3.66}/src/modusa/decorators.py +0 -0
- {modusa-0.3.64 → modusa-0.3.66}/src/modusa/devtools/generate_docs_source.py +0 -0
- {modusa-0.3.64 → modusa-0.3.66}/src/modusa/devtools/generate_template.py +0 -0
- {modusa-0.3.64 → modusa-0.3.66}/src/modusa/devtools/list_authors.py +0 -0
- {modusa-0.3.64 → modusa-0.3.66}/src/modusa/devtools/list_plugins.py +0 -0
- {modusa-0.3.64 → modusa-0.3.66}/src/modusa/devtools/main.py +0 -0
- {modusa-0.3.64 → modusa-0.3.66}/src/modusa/devtools/templates/generator.py +0 -0
- {modusa-0.3.64 → modusa-0.3.66}/src/modusa/devtools/templates/io.py +0 -0
- {modusa-0.3.64 → modusa-0.3.66}/src/modusa/devtools/templates/model.py +0 -0
- {modusa-0.3.64 → modusa-0.3.66}/src/modusa/devtools/templates/plugin.py +0 -0
- {modusa-0.3.64 → modusa-0.3.66}/src/modusa/devtools/templates/test.py +0 -0
- {modusa-0.3.64 → modusa-0.3.66}/src/modusa/devtools/templates/tool.py +0 -0
- {modusa-0.3.64 → modusa-0.3.66}/src/modusa/fonts/NotoSansDevanagari-Regular.ttf +0 -0
- {modusa-0.3.64 → modusa-0.3.66}/src/modusa/generators/__init__.py +0 -0
- {modusa-0.3.64 → modusa-0.3.66}/src/modusa/generators/audio.py +0 -0
- {modusa-0.3.64 → modusa-0.3.66}/src/modusa/generators/audio_waveforms.py +0 -0
- {modusa-0.3.64 → modusa-0.3.66}/src/modusa/generators/base.py +0 -0
- {modusa-0.3.64 → modusa-0.3.66}/src/modusa/generators/ftds.py +0 -0
- {modusa-0.3.64 → modusa-0.3.66}/src/modusa/generators/s1d.py +0 -0
- {modusa-0.3.64 → modusa-0.3.66}/src/modusa/generators/s2d.py +0 -0
- {modusa-0.3.64 → modusa-0.3.66}/src/modusa/generators/s_ax.py +0 -0
- {modusa-0.3.64 → modusa-0.3.66}/src/modusa/generators/t_ax.py +0 -0
- {modusa-0.3.64 → modusa-0.3.66}/src/modusa/generators/tds.py +0 -0
- {modusa-0.3.64 → modusa-0.3.66}/src/modusa/models/__init__.py +0 -0
- {modusa-0.3.64 → modusa-0.3.66}/src/modusa/models/__pycache__/signal1D.cpython-312.pyc.4443461152 +0 -0
- {modusa-0.3.64 → modusa-0.3.66}/src/modusa/models/audio.py +0 -0
- {modusa-0.3.64 → modusa-0.3.66}/src/modusa/models/base.py +0 -0
- {modusa-0.3.64 → modusa-0.3.66}/src/modusa/models/data.py +0 -0
- {modusa-0.3.64 → modusa-0.3.66}/src/modusa/models/ftds.py +0 -0
- {modusa-0.3.64 → modusa-0.3.66}/src/modusa/models/s1d.py +0 -0
- {modusa-0.3.64 → modusa-0.3.66}/src/modusa/models/s2d.py +0 -0
- {modusa-0.3.64 → modusa-0.3.66}/src/modusa/models/s_ax.py +0 -0
- {modusa-0.3.64 → modusa-0.3.66}/src/modusa/models/t_ax.py +0 -0
- {modusa-0.3.64 → modusa-0.3.66}/src/modusa/models/tds.py +0 -0
- {modusa-0.3.64 → modusa-0.3.66}/src/modusa/plugins/__init__.py +0 -0
- {modusa-0.3.64 → modusa-0.3.66}/src/modusa/plugins/base.py +0 -0
- {modusa-0.3.64 → modusa-0.3.66}/src/modusa/tools/__init__.py +0 -0
- {modusa-0.3.64 → modusa-0.3.66}/src/modusa/tools/_plotter_old.py +0 -0
- {modusa-0.3.64 → modusa-0.3.66}/src/modusa/tools/ann_loader.py +0 -0
- {modusa-0.3.64 → modusa-0.3.66}/src/modusa/tools/audio_converter.py +0 -0
- {modusa-0.3.64 → modusa-0.3.66}/src/modusa/tools/audio_loader.py +0 -0
- {modusa-0.3.64 → modusa-0.3.66}/src/modusa/tools/audio_player.py +0 -0
- {modusa-0.3.64 → modusa-0.3.66}/src/modusa/tools/audio_recorder.py +0 -0
- {modusa-0.3.64 → modusa-0.3.66}/src/modusa/tools/base.py +0 -0
- {modusa-0.3.64 → modusa-0.3.66}/src/modusa/tools/math_ops.py +0 -0
- {modusa-0.3.64 → modusa-0.3.66}/src/modusa/tools/youtube_downloader.py +0 -0
- {modusa-0.3.64 → modusa-0.3.66}/src/modusa/utils/.DS_Store +0 -0
- {modusa-0.3.64 → modusa-0.3.66}/src/modusa/utils/__init__.py +0 -0
- {modusa-0.3.64 → modusa-0.3.66}/src/modusa/utils/config.py +0 -0
- {modusa-0.3.64 → modusa-0.3.66}/src/modusa/utils/excp.py +0 -0
- {modusa-0.3.64 → modusa-0.3.66}/src/modusa/utils/logger.py +0 -0
- {modusa-0.3.64 → modusa-0.3.66}/src/modusa/utils/np_func_cat.py +0 -0
- {modusa-0.3.64 → modusa-0.3.66}/src/modusa/utils/plot.py +0 -0
- {modusa-0.3.64 → modusa-0.3.66}/tests/__init__.py +0 -0
- {modusa-0.3.64 → modusa-0.3.66}/tests/data/song1.mp3 +0 -0
- {modusa-0.3.64 → modusa-0.3.66}/tests/data/song1.wav +0 -0
- {modusa-0.3.64 → modusa-0.3.66}/tests/test_generators/audio_waveform.py +0 -0
- {modusa-0.3.64 → modusa-0.3.66}/tests/test_generators/test_audio.py +0 -0
- {modusa-0.3.64 → modusa-0.3.66}/tests/test_generators/test_ftds.py +0 -0
- {modusa-0.3.64 → modusa-0.3.66}/tests/test_generators/test_s1d.py +0 -0
- {modusa-0.3.64 → modusa-0.3.66}/tests/test_generators/test_s2d.py +0 -0
- {modusa-0.3.64 → modusa-0.3.66}/tests/test_generators/test_s_ax.py +0 -0
- {modusa-0.3.64 → modusa-0.3.66}/tests/test_generators/test_signal.py +0 -0
- {modusa-0.3.64 → modusa-0.3.66}/tests/test_generators/test_signal_generator.py +0 -0
- {modusa-0.3.64 → modusa-0.3.66}/tests/test_generators/test_t_ax.py +0 -0
- {modusa-0.3.64 → modusa-0.3.66}/tests/test_generators/test_tds.py +0 -0
- {modusa-0.3.64 → modusa-0.3.66}/tests/test_io/audio_player.py +0 -0
- {modusa-0.3.64 → modusa-0.3.66}/tests/test_io/plotter.py +0 -0
- {modusa-0.3.64 → modusa-0.3.66}/tests/test_models/test_data.py +0 -0
- {modusa-0.3.64 → modusa-0.3.66}/tests/test_models/test_t_ax.py +0 -0
- {modusa-0.3.64 → modusa-0.3.66}/tests/test_plugins/youtube_audio_loader.py +0 -0
- {modusa-0.3.64 → modusa-0.3.66}/tests/test_signals/frequency_domain_signal.py +0 -0
- {modusa-0.3.64 → modusa-0.3.66}/tests/test_signals/spectrogram.py +0 -0
- {modusa-0.3.64 → modusa-0.3.66}/tests/test_signals/test_axis.py +0 -0
- {modusa-0.3.64 → modusa-0.3.66}/tests/test_signals/test_feature_time_domain_signal.py +0 -0
- {modusa-0.3.64 → modusa-0.3.66}/tests/test_signals/test_frequency_time_domain_signal.py +0 -0
- {modusa-0.3.64 → modusa-0.3.66}/tests/test_signals/test_signal1D.py +0 -0
- {modusa-0.3.64 → modusa-0.3.66}/tests/test_signals/test_signal2D.py +0 -0
- {modusa-0.3.64 → modusa-0.3.66}/tests/test_signals/test_time_domain_signal.py +0 -0
- {modusa-0.3.64 → modusa-0.3.66}/tests/test_signals/test_u_ax.py +0 -0
- {modusa-0.3.64 → modusa-0.3.66}/tests/test_signals/test_window_signal.py +0 -0
- {modusa-0.3.64 → modusa-0.3.66}/tests/test_signals/time_domain_signal.py +0 -0
- {modusa-0.3.64 → modusa-0.3.66}/tests/test_tools/test_audio_converter.py +0 -0
- {modusa-0.3.64 → modusa-0.3.66}/tests/test_tools/test_fourier_tranform.py +0 -0
- {modusa-0.3.64 → modusa-0.3.66}/tests/test_tools/test_math_ops.py +0 -0
|
@@ -41,16 +41,47 @@ class Fig:
|
|
|
41
41
|
A utility class that provides easy-to-use API for
|
|
42
42
|
plotting 1D/2D signals along with clean representations
|
|
43
43
|
of annotations, events.
|
|
44
|
+
|
|
45
|
+
Parameters
|
|
46
|
+
----------
|
|
47
|
+
arrangement: str
|
|
48
|
+
- Arrangement of the subplots you want in the figure.
|
|
49
|
+
- "a" for aux plot which is good for adding annotations and events onto.
|
|
50
|
+
- "s" for signal plot which is good for 1D array.
|
|
51
|
+
- "m" for matrix plot which is good for 2D array.
|
|
52
|
+
- E.g., "asm" or "aasm" or "saams", ...
|
|
53
|
+
- Default: "asm"
|
|
54
|
+
xlim: tuple[number, number] | None
|
|
55
|
+
- Since all the subplots share x-axis, we set the x limit while creating the figure.
|
|
56
|
+
- Default: None
|
|
57
|
+
width: number
|
|
58
|
+
- Width of the figure
|
|
59
|
+
- Default: 16
|
|
60
|
+
dark_mode: bool
|
|
61
|
+
- Do you want dark mode?
|
|
62
|
+
- Default: True
|
|
44
63
|
"""
|
|
45
64
|
|
|
46
|
-
def __init__(self, arrangement="asm", xlim=None):
|
|
65
|
+
def __init__(self, arrangement="asm", xlim=None, width=16, dark_mode=True):
|
|
66
|
+
|
|
67
|
+
if dark_mode:
|
|
68
|
+
plt.style.use("dark_background")
|
|
69
|
+
else: # We do not reset to default as it changes other params leading to unexpected behaviour
|
|
70
|
+
color_keys = [
|
|
71
|
+
"axes.facecolor", "axes.edgecolor", "axes.labelcolor",
|
|
72
|
+
"xtick.color", "ytick.color", "text.color",
|
|
73
|
+
"figure.facecolor", "figure.edgecolor",
|
|
74
|
+
"legend.facecolor", "legend.edgecolor"
|
|
75
|
+
]
|
|
76
|
+
for k in color_keys:
|
|
77
|
+
mpl.rcParams[k] = mpl.rcParamsDefault[k]
|
|
47
78
|
|
|
48
79
|
self._xlim = xlim
|
|
49
80
|
self._curr_row_idx = 1 # Starting from 1 because row 0 is reserved for reference subplot
|
|
50
81
|
self._curr_color_idx = 0 # So that we have different color across all the subplots to avoid legend confusion
|
|
51
82
|
|
|
52
83
|
# Subplot setup
|
|
53
|
-
self._fig, self._axs = self._generate_subplots(arrangement) # This will fill in the all the above variables
|
|
84
|
+
self._fig, self._axs = self._generate_subplots(arrangement, width) # This will fill in the all the above variables
|
|
54
85
|
|
|
55
86
|
|
|
56
87
|
def _get_curr_row(self):
|
|
@@ -96,12 +127,13 @@ class Fig:
|
|
|
96
127
|
return [x[0] - dx / 2, x[-1] + dx / 2, y[-1] + dy / 2, y[0] - dy / 2]
|
|
97
128
|
|
|
98
129
|
|
|
99
|
-
def _generate_subplots(self, arrangement):
|
|
130
|
+
def _generate_subplots(self, arrangement, width):
|
|
100
131
|
"""
|
|
101
132
|
Generate subplots based on the configuration.
|
|
102
133
|
"""
|
|
103
134
|
|
|
104
135
|
xlim = self._xlim
|
|
136
|
+
fig_width = width
|
|
105
137
|
|
|
106
138
|
n_aux_sp = arrangement.count("a")
|
|
107
139
|
n_signal_sp = arrangement.count("s")
|
|
@@ -126,7 +158,7 @@ class Fig:
|
|
|
126
158
|
fig_height = height["r"] + (n_aux_sp * height["a"]) + (n_signal_sp * height["s"]) + (n_matrix_sp * height["m"])
|
|
127
159
|
|
|
128
160
|
# Create figure and axs
|
|
129
|
-
fig, axs = plt.subplots(n_sp, 2, figsize=(
|
|
161
|
+
fig, axs = plt.subplots(n_sp, 2, figsize=(fig_width, fig_height), height_ratios=height_ratios, width_ratios=[1, cbar_width])
|
|
130
162
|
|
|
131
163
|
for i, char in enumerate(arrangement): # For each of the subplots, we modify the layout accordingly
|
|
132
164
|
if char == "r":
|
|
@@ -156,7 +188,7 @@ class Fig:
|
|
|
156
188
|
|
|
157
189
|
return fig, axs
|
|
158
190
|
|
|
159
|
-
def add_signal(self, y, x=None, c=None, ls=None, lw=None, m=None, ms=3, label=None, ylabel=None, ylim=None, ax=None):
|
|
191
|
+
def add_signal(self, y, x=None, c=None, ls=None, lw=None, m=None, ms=3, label=None, ylabel=None, ylim=None, yticks=None, yticklabels=None, xticks=None, xticklabels=None, ax=None):
|
|
160
192
|
"""
|
|
161
193
|
Add signal to the figure.
|
|
162
194
|
|
|
@@ -192,6 +224,14 @@ class Fig:
|
|
|
192
224
|
ylim: tuple
|
|
193
225
|
- y-lim for the plot.
|
|
194
226
|
- Default: None
|
|
227
|
+
yticks: Arraylike
|
|
228
|
+
- Positions at which to place y-axis ticks.
|
|
229
|
+
yticklabels : list of str, optional
|
|
230
|
+
- Labels corresponding to `yticks`. Must be the same length as `yticks`.
|
|
231
|
+
xticks: Arraylike
|
|
232
|
+
- Positions at which to place x-axis ticks.
|
|
233
|
+
xticklabels : list of str, optional
|
|
234
|
+
- Labels corresponding to `xticks`. Must be the same length as `xticks`.
|
|
195
235
|
ax: int
|
|
196
236
|
- Which specific axis to plot (1, 2, 3, ...)
|
|
197
237
|
- None
|
|
@@ -203,17 +243,32 @@ class Fig:
|
|
|
203
243
|
|
|
204
244
|
curr_row = self._get_curr_row() if ax is None else self._axs[ax]
|
|
205
245
|
|
|
206
|
-
if x is None:
|
|
246
|
+
if x is None:
|
|
247
|
+
x = np.arange(y.size)
|
|
207
248
|
|
|
208
|
-
if c is None:
|
|
249
|
+
if c is None:
|
|
250
|
+
c = self._get_new_color()
|
|
209
251
|
|
|
210
252
|
curr_row[0].plot(x, y, color=c, linestyle=ls, linewidth=lw, marker=m, markersize=ms, label=label)
|
|
211
253
|
|
|
212
|
-
if ylabel is not None:
|
|
254
|
+
if ylabel is not None:
|
|
255
|
+
curr_row[0].set_ylabel(ylabel)
|
|
256
|
+
|
|
257
|
+
if ylim is not None:
|
|
258
|
+
curr_row[0].set_ylim(ylim)
|
|
213
259
|
|
|
214
|
-
if
|
|
260
|
+
if yticks is not None:
|
|
261
|
+
curr_row[0].set_yticks(yticks)
|
|
262
|
+
if yticklabels is not None:
|
|
263
|
+
curr_row[0].set_yticklabels(yticklabels)
|
|
264
|
+
|
|
265
|
+
if xticks is not None:
|
|
266
|
+
curr_row[0].set_xticks(xticks)
|
|
267
|
+
if xticklabels is not None:
|
|
268
|
+
curr_row[0].set_xticklabels(xticklabels)
|
|
269
|
+
|
|
215
270
|
|
|
216
|
-
def add_matrix(self, M, y=None, x=None, c="gray_r", o="upper", label=None, ylabel=None, ylim=None, cbar=True, ax=None):
|
|
271
|
+
def add_matrix(self, M, y=None, x=None, c="gray_r", o="upper", label=None, ylabel=None, ylim=None, yticks=None, yticklabels=None, xticks=None, xticklabels=None, cbar=True, ax=None):
|
|
217
272
|
"""
|
|
218
273
|
Add matrix to the figure.
|
|
219
274
|
|
|
@@ -242,6 +297,14 @@ class Fig:
|
|
|
242
297
|
ylim: tuple
|
|
243
298
|
- y-lim for the plot.
|
|
244
299
|
- Default: None
|
|
300
|
+
yticks: Arraylike
|
|
301
|
+
- Positions at which to place y-axis ticks.
|
|
302
|
+
yticklabels : list of str, optional
|
|
303
|
+
- Labels corresponding to `yticks`. Must be the same length as `yticks`.
|
|
304
|
+
xticks: Arraylike
|
|
305
|
+
- Positions at which to place x-axis ticks.
|
|
306
|
+
xticklabels : list of str, optional
|
|
307
|
+
- Labels corresponding to `xticks`. Must be the same length as `xticks`.
|
|
245
308
|
cbar: bool
|
|
246
309
|
- Show colorbar
|
|
247
310
|
- Default: True
|
|
@@ -274,6 +337,16 @@ class Fig:
|
|
|
274
337
|
cbar = plt.colorbar(im, cax=curr_row[1])
|
|
275
338
|
if label is not None:
|
|
276
339
|
cbar.set_label(label, labelpad=5)
|
|
340
|
+
|
|
341
|
+
if yticks is not None:
|
|
342
|
+
curr_row[0].set_yticks(yticks)
|
|
343
|
+
if yticklabels is not None:
|
|
344
|
+
curr_row[0].set_yticklabels(yticklabels)
|
|
345
|
+
|
|
346
|
+
if xticks is not None:
|
|
347
|
+
curr_row[0].set_xticks(xticks)
|
|
348
|
+
if xticklabels is not None:
|
|
349
|
+
curr_row[0].set_xticklabels(xticklabels)
|
|
277
350
|
|
|
278
351
|
|
|
279
352
|
def add_events(self, events, c=None, ls=None, lw=None, label=None, ax=None):
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{modusa-0.3.64 → modusa-0.3.66}/src/modusa/models/__pycache__/signal1D.cpython-312.pyc.4443461152
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|