modusa 0.4.29__py3-none-any.whl → 0.4.31__py3-none-any.whl

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.
Files changed (58) hide show
  1. modusa/__init__.py +12 -8
  2. modusa/tools/__init__.py +11 -3
  3. modusa/tools/ann_saver.py +30 -0
  4. modusa/tools/audio_recorder.py +0 -1
  5. modusa/tools/audio_stft.py +72 -0
  6. modusa/tools/youtube_downloader.py +1 -4
  7. {modusa-0.4.29.dist-info → modusa-0.4.31.dist-info}/METADATA +2 -2
  8. modusa-0.4.31.dist-info/RECORD +22 -0
  9. pyproject.toml +2 -2
  10. modusa/config.py +0 -18
  11. modusa/decorators.py +0 -176
  12. modusa/devtools/generate_docs_source.py +0 -92
  13. modusa/devtools/generate_template.py +0 -144
  14. modusa/devtools/list_authors.py +0 -2
  15. modusa/devtools/list_plugins.py +0 -60
  16. modusa/devtools/main.py +0 -45
  17. modusa/devtools/templates/generator.py +0 -24
  18. modusa/devtools/templates/io.py +0 -24
  19. modusa/devtools/templates/model.py +0 -47
  20. modusa/devtools/templates/plugin.py +0 -41
  21. modusa/devtools/templates/test.py +0 -10
  22. modusa/devtools/templates/tool.py +0 -24
  23. modusa/generators/__init__.py +0 -13
  24. modusa/generators/audio.py +0 -188
  25. modusa/generators/audio_waveforms.py +0 -236
  26. modusa/generators/base.py +0 -29
  27. modusa/generators/ftds.py +0 -298
  28. modusa/generators/s1d.py +0 -270
  29. modusa/generators/s2d.py +0 -300
  30. modusa/generators/s_ax.py +0 -102
  31. modusa/generators/t_ax.py +0 -64
  32. modusa/generators/tds.py +0 -267
  33. modusa/models/__init__.py +0 -14
  34. modusa/models/audio.py +0 -90
  35. modusa/models/base.py +0 -70
  36. modusa/models/data.py +0 -457
  37. modusa/models/ftds.py +0 -584
  38. modusa/models/s1d.py +0 -578
  39. modusa/models/s2d.py +0 -619
  40. modusa/models/s_ax.py +0 -448
  41. modusa/models/t_ax.py +0 -335
  42. modusa/models/tds.py +0 -465
  43. modusa/plugins/__init__.py +0 -3
  44. modusa/plugins/base.py +0 -100
  45. modusa/tools/_plotter_old.py +0 -629
  46. modusa/tools/audio_saver.py +0 -30
  47. modusa/tools/base.py +0 -43
  48. modusa/tools/math_ops.py +0 -335
  49. modusa/utils/__init__.py +0 -1
  50. modusa/utils/config.py +0 -25
  51. modusa/utils/excp.py +0 -49
  52. modusa/utils/logger.py +0 -18
  53. modusa/utils/np_func_cat.py +0 -44
  54. modusa/utils/plot.py +0 -142
  55. modusa-0.4.29.dist-info/RECORD +0 -65
  56. {modusa-0.4.29.dist-info → modusa-0.4.31.dist-info}/WHEEL +0 -0
  57. {modusa-0.4.29.dist-info → modusa-0.4.31.dist-info}/entry_points.txt +0 -0
  58. {modusa-0.4.29.dist-info → modusa-0.4.31.dist-info}/licenses/LICENSE.md +0 -0
modusa/generators/s1d.py DELETED
@@ -1,270 +0,0 @@
1
- #!/usr/bin/env python3
2
-
3
-
4
- from modusa import excp
5
- from modusa.decorators import validate_args_type
6
- from .base import ModusaGenerator
7
- from modusa.models.s1d import S1D
8
- from modusa.models.s_ax import SAx
9
- from modusa.models.data import Data
10
- import numpy as np
11
-
12
- class S1DGen(ModusaGenerator):
13
- """
14
- Provides user friendly APIs to generate instances of different `S1D`
15
- instances.
16
- """
17
-
18
- #--------Meta Information----------
19
- _name = ""
20
- _description = ""
21
- _author_name = "Ankit Anand"
22
- _author_email = "ankit0.anand0@gmail.com"
23
- _created_at = "2025-07-27"
24
- #----------------------------------
25
-
26
- @staticmethod
27
- def from_array(
28
- y,
29
- x = None,
30
- y_label: str = "Y",
31
- x_label: str = "X",
32
- title: str = "1D Signal"
33
- ) -> S1D:
34
- """
35
- Create `S1D` instance from basic data structures.
36
-
37
- .. code-block:: python
38
-
39
- import modusa as ms
40
- x = ms.s1d.from_array([1, 2, 3])
41
- print(x)
42
- x.print_info()
43
-
44
- Parameters
45
- ----------
46
- y: array-like
47
- - Data values.
48
- x: array-like | None
49
- - Corresponding axis values.
50
- - Default: None → Creates an integer indexing.
51
- y_label: str
52
- - Y label for the signal.
53
- - Default: "Y"
54
- x_label: str
55
- - X label for the signal.
56
- - Default: "X"
57
- title: str
58
- - Title for the signal.
59
- - Default: "1D Signal"
60
- Returns
61
- -------
62
- S1D
63
- An instance of S1D.
64
- """
65
- assert isinstance(y, (np.ndarray, list, float, int, np.generic))
66
- assert isinstance(x, (np.ndarray, list, float, int, np.generic)) or x is None
67
- assert isinstance(y_label, str) and isinstance(x_label, str) and isinstance(title, str)
68
-
69
- if isinstance(y, (float, int, np.generic)): y = [y] # Convert to list of 1 element
70
- if isinstance(x, (float, int, np.generic)): x = [x] # Convert to list of 1 element
71
-
72
- y = np.asarray(y)
73
- if x is None: x = np.arange(y.shape[0])
74
- else: x = np.asarray(x)
75
-
76
- assert y.ndim ==1 and x.ndim == 1, "S1D must have only one dimension"
77
- assert y.shape == x.shape, "Shape mismatch"
78
-
79
- y = Data(values=y, label=y_label)
80
- x = SAx(values=x, label=x_label) # Creating a signal axis instance
81
-
82
- return S1D(y=y, x=x, title=title)
83
-
84
- @classmethod
85
- def zeros(cls, shape) -> S1D:
86
- """
87
- Create `S1D` instance with all zeros.
88
-
89
- .. code-block:: python
90
-
91
- import modusa as ms
92
- y = ms.s1d.zeros(10)
93
- print(y)
94
- y.print_info()
95
-
96
- Parameters
97
- ----------
98
- shape: int | tuple[int]
99
- - Shape of the signal with zeros.
100
- - Must be 1 dimensional
101
- - E.g. 10 or (10, )
102
- Returns
103
- -------
104
- S1D
105
- An instance of S1D.
106
- """
107
- assert isinstance(shape, (int, tuple))
108
- y = np.zeros(shape)
109
-
110
- return cls.from_array(y=y, title="Zeros")
111
-
112
- @classmethod
113
- def zeros_like(cls, signal: S1D) -> S1D:
114
- """
115
- Create `S1D` instance similar to `signal`
116
- but with all entries being zeros.
117
-
118
- .. code-block:: python
119
-
120
- import modusa as ms
121
- signal = ms.s1d.from_array([1, 2, 3])
122
- y = ms.s1d.zeros_like(signal)
123
- print(y)
124
- x.print_info()
125
-
126
- Parameters
127
- ----------
128
- signal: S1D
129
- - Reference signal to create zeros like that.
130
- Returns
131
- -------
132
- S1D
133
- An instance of S1D.
134
- """
135
-
136
- assert signal.__class__ in [S1D]
137
-
138
- y = np.zeros(signal.shape)
139
- y_label = signal._y_label
140
- x = signal._x
141
- x_label = signal._x_label
142
- title = signal._title
143
-
144
- return cls.from_array(y=y, x=x, y_label=y_label, x_label=x_label, title=title)
145
-
146
-
147
- @classmethod
148
- def ones(cls, shape: int | tuple[int, int]) -> S1D:
149
- """
150
- Create `S1D` instance with all ones.
151
-
152
- .. code-block:: python
153
-
154
- import modusa as ms
155
- y = ms.s1d.ones(10)
156
- print(y)
157
- y.print_info()
158
-
159
- Parameters
160
- ----------
161
- shape: int | tuple[int]
162
- - Shape of the signal with ones.
163
- - Must be 1 dimensional
164
- - E.g. 10 or (10, )
165
- Returns
166
- -------
167
- S1D
168
- An instance of S1D.
169
- """
170
- assert isinstance(shape, (int, tuple))
171
- y = np.ones(shape)
172
-
173
- return cls.from_array(y=y, title="Ones")
174
-
175
- @classmethod
176
- def ones_like(cls, signal: S1D) -> S1D:
177
- """
178
- Create `S1D` instance similar to `signal`
179
- but with all entries being ones.
180
-
181
- .. code-block:: python
182
-
183
- import modusa as ms
184
- signal = ms.s1d.from_array([1, 2, 3])
185
- y = ms.s1d.ones_like(signal)
186
- print(y)
187
- y.print_info()
188
-
189
- Parameters
190
- ----------
191
- signal: S1D
192
- - Reference signal to create ones like that.
193
- Returns
194
- -------
195
- S1D
196
- An instance of S1D.
197
- """
198
-
199
- assert signal.__class__ in [S1D]
200
-
201
- y = np.ones(signal.shape)
202
- y_label = signal._y_label
203
- x = signal._x
204
- x_label = signal._x_label
205
- title = signal._title
206
-
207
- return cls.from_array(y=y, x=x, y_label=y_label, x_label=x_label, title=title)
208
-
209
- @classmethod
210
- def random(cls, shape: int) -> S1D:
211
- """
212
- Create `S1D` instance with random entries.
213
-
214
- .. code-block:: python
215
-
216
- import modusa as ms
217
- y = ms.s1d.random(10)
218
- print(y)
219
- y.print_info()
220
-
221
- Parameters
222
- ----------
223
- shape: int | tuple[int]
224
- - Shape of the signal.
225
- - Must be 1 dimensional
226
- - E.g. 10 or (10, )
227
- Returns
228
- -------
229
- S1D
230
- An instance of S1D with random values.
231
- """
232
- assert isinstance(shape, (int, tuple))
233
- y = np.random.random(shape)
234
-
235
- return cls.from_array(y=y, title="Random")
236
-
237
- @classmethod
238
- def random_like(cls, signal: S1D) -> S1D:
239
- """
240
- Create `S1D` instance similar to `signal`
241
- but with all entries being ones.
242
-
243
- .. code-block:: python
244
-
245
- import modusa as ms
246
- signal = ms.s1d.from_array([1, 2, 3])
247
- y = ms.s1d.random_like(signal)
248
- print(y)
249
- y.print_info()
250
-
251
- Parameters
252
- ----------
253
- signal: S1D
254
- - Reference signal to create one with random entries.
255
- Returns
256
- -------
257
- S1D
258
- An instance of S1D with random values.
259
- """
260
-
261
- assert signal.__class__ in [S1D]
262
-
263
- y = np.random.random(signal.shape)
264
- y_label = signal._y_label
265
- x = signal._x
266
- x_label = signal._x_label
267
- title = signal._title
268
-
269
- return cls.from_array(y=y, x=x, y_label=y_label, x_label=x_label, title=title)
270
-
modusa/generators/s2d.py DELETED
@@ -1,300 +0,0 @@
1
- #!/usr/bin/env python3
2
-
3
-
4
- from modusa import excp
5
- from modusa.decorators import validate_args_type
6
- from .base import ModusaGenerator
7
- from modusa.models.s2d import S2D
8
- from modusa.models.s_ax import SAx
9
- from modusa.models.data import Data
10
- import numpy as np
11
-
12
- class S2DGen(ModusaGenerator):
13
- """
14
- Provides user friendly APIs to generate instances of different `S2D`
15
- instances.
16
- """
17
-
18
- #--------Meta Information----------
19
- _name = "S2DGeneratator"
20
- _description = "APIs to generate instances of different `S2D` instances"
21
- _author_name = "Ankit Anand"
22
- _author_email = "ankit0.anand0@gmail.com"
23
- _created_at = "2025-07-27"
24
- #----------------------------------
25
-
26
- @staticmethod
27
- def from_array(
28
- M: np.ndarray | list | float | int | np.generic,
29
- y: np.ndarray | list | float | int | np.generic | None = None,
30
- x: np.ndarray | list | float | int | np.generic | None = None,
31
- M_label: str = "M",
32
- y_label: str = "Y",
33
- x_label: str = "X",
34
- title: str = "2D Signal"
35
- ) -> S2D:
36
- """
37
- Create `S2D` instance from basic data structures.
38
-
39
- .. code-block:: python
40
-
41
- import modusa as ms
42
- M = ms.s1d.from_array([1, 2, 3])
43
- print(M)
44
- M.print_info()
45
-
46
- Parameters
47
- ----------
48
- M: np.ndarray | list | float | int | np.generic
49
- - Data values.
50
- y: np.ndarray | list | float | int | np.generic
51
- - y axis values.
52
- - Default: None → Creates an integer indexing.
53
- x: np.ndarray | list | float | int | np.generic | None
54
- - x axis values.
55
- - Default: None → Creates an integer indexing.
56
- M_label: str
57
- - Label for the data.
58
- - Default: "M"
59
- y_label: str
60
- - Y label for the signal.
61
- - Default: "Y"
62
- x_label: str
63
- - X label for the signal.
64
- - Default: "X"
65
- title: str
66
- - Title for the signal.
67
- - Default: "2D Signal"
68
- Returns
69
- -------
70
- S2D
71
- An instance of S2D.
72
- """
73
- assert isinstance(M, (np.ndarray, list, float, int, np.generic))
74
- assert isinstance(x, (np.ndarray, list, float, int, np.generic)) or x is None
75
- assert isinstance(y, (np.ndarray, list, float, int, np.generic)) or y is None
76
- assert isinstance(M_label, str) and isinstance(y_label, str) and isinstance(x_label, str) and isinstance(title, str)
77
-
78
- if isinstance(M, (float, int, np.generic)): M = [[M]] # Convert to list of 1 element
79
- if isinstance(y, (float, int, np.generic)): y = [y] # Convert to list of 1 element
80
- if isinstance(x, (float, int, np.generic)): x = [x] # Convert to list of 1 element
81
-
82
- M = np.asarray(M)
83
- assert M.ndim == 2
84
-
85
- if y is None: y = np.arange(M.shape[0])
86
- else: y = np.asarray(y)
87
- assert y.ndim == 1
88
-
89
- if x is None: x = np.arange(M.shape[1])
90
- else: x = np.asarray(x)
91
- assert x.ndim == 1
92
-
93
- assert y.shape[0] == M.shape[0], "Shape mismatch"
94
- assert x.shape[0] == M.shape[1], "Shape mismatch"
95
-
96
- y_sax = SAx(values=y, label=y_label) # Creating a signal axis instance
97
- x_sax = SAx(values=x, label=x_label) # Creating a signal axis instance
98
-
99
- M = Data(values=M, label=M_label)
100
-
101
- return S2D(M=M, y=y_sax, x=x_sax, title=title)
102
-
103
- @classmethod
104
- def zeros(cls, shape: tuple[int, int]) -> S2D:
105
- """
106
- Create `S2D` instance with all zeros.
107
-
108
- .. code-block:: python
109
-
110
- import modusa as ms
111
- M = ms.s2d.zeros((10, 5))
112
- print(M)
113
- M.print_info()
114
-
115
- Parameters
116
- ----------
117
- shape: tuple[int, int]
118
- - Shape of the signal with zeros.
119
- - Must be 1 dimensional
120
- - E.g. (10, 5)
121
- Returns
122
- -------
123
- S2D
124
- An instance of S2D.
125
- """
126
- assert isinstance(shape, tuple)
127
- M = np.zeros(shape)
128
-
129
- return cls.from_array(M=M, title="Zeros")
130
-
131
- @classmethod
132
- def zeros_like(cls, signal: S2D) -> S2D:
133
- """
134
- Create `S2D` instance similar to `signal`
135
- but with all entries being zeros.
136
-
137
- .. code-block:: python
138
-
139
- import modusa as ms
140
- signal = ms.s2d.from_array([[1, 2, 3], [4, 5, 6]])
141
- M = ms.s2d.zeros_like(signal)
142
- print(M)
143
- M.print_info()
144
-
145
- Parameters
146
- ----------
147
- signal: S2D
148
- - Reference signal to create zeros like that.
149
- Returns
150
- -------
151
- S2D
152
- An instance of S2D.
153
- """
154
-
155
- assert signal.__class__ in [S2D]
156
-
157
- M = np.zeros(signal.shape)
158
- y = signal._y
159
- x = signal._x
160
-
161
- M_label = signal._M_label
162
- y_label = signal._y_label
163
- x_label = signal._x_label
164
- title = signal._title
165
-
166
- return cls.from_array(M=M, y=y, x=x, M_label=M_label, y_label=y_label, x_label=x_label, title=title)
167
-
168
-
169
- @classmethod
170
- def ones(cls, shape: tuple[int, int]) -> S2D:
171
- """
172
- Create `S2D` instance with all ones.
173
-
174
- .. code-block:: python
175
-
176
- import modusa as ms
177
- M = ms.s2d.ones((10, 5))
178
- print(M)
179
- M.print_info()
180
-
181
- Parameters
182
- ----------
183
- shape: tuple[int, int]
184
- - Shape of the signal with ones.
185
- - Must be 1 dimensional
186
- - E.g. (10, 5)
187
- Returns
188
- -------
189
- S2D
190
- An instance of S2D.
191
- """
192
- assert isinstance(shape, tuple)
193
- M = np.ones(shape)
194
-
195
- return cls.from_array(M=M, title="Ones")
196
-
197
- @classmethod
198
- def ones_like(cls, signal: S2D) -> S2D:
199
- """
200
- Create `S2D` instance similar to `signal`
201
- but with all entries being ones.
202
-
203
- .. code-block:: python
204
-
205
- import modusa as ms
206
- signal = ms.s2d.from_array([[1, 2, 3], [4, 5, 6]])
207
- M = ms.s2d.ones_like(signal)
208
- print(M)
209
- M.print_info()
210
-
211
- Parameters
212
- ----------
213
- signal: S2D
214
- - Reference signal to create ones like that.
215
- Returns
216
- -------
217
- S2D
218
- An instance of S2D.
219
- """
220
-
221
- assert signal.__class__ in [S2D]
222
-
223
- M = np.ones(signal.shape)
224
- y = signal._y
225
- x = signal._x
226
-
227
- M_label = signal._M_label
228
- y_label = signal._y_label
229
- x_label = signal._x_label
230
- title = signal._title
231
-
232
- return cls.from_array(M=M, y=y, x=x, M_label=M_label, y_label=y_label, x_label=x_label, title=title)
233
-
234
- @classmethod
235
- def random(cls, shape: tuple[int, int]) -> S2D:
236
- """
237
- Create `S2D` instance with random entries.
238
-
239
- .. code-block:: python
240
-
241
- import modusa as ms
242
- y = ms.s2d.random((10, 5))
243
- print(y)
244
- y.print_info()
245
-
246
- Parameters
247
- ----------
248
- shape: tuple[int, int]
249
- - Shape of the signal.
250
- - Must be 1 dimensional
251
- - E.g. (10, 5)
252
- Returns
253
- -------
254
- S2D
255
- An instance of S2D with random values.
256
- """
257
- assert isinstance(shape, tuple)
258
- M = np.random.random(shape)
259
-
260
- return cls.from_array(M=M, title="Random")
261
-
262
- @classmethod
263
- def random_like(cls, signal: S2D) -> S2D:
264
- """
265
- Create `S2D` instance similar to `signal`
266
- but with all entries being ones.
267
-
268
- .. code-block:: python
269
-
270
- import modusa as ms
271
- signal = ms.s2d.from_array([[1, 2, 3], [4, 5, 6]])
272
- M = ms.s2d.random_like(signal)
273
- print(M)
274
- M.print_info()
275
-
276
- Parameters
277
- ----------
278
- signal: S2D
279
- - Reference signal.
280
- Returns
281
- -------
282
- S2D
283
- An instance of S2D with random values.
284
- """
285
-
286
- assert signal.__class__ in [S2D]
287
-
288
- M = np.random.random(signal.shape)
289
- y = signal._y
290
- x = signal._x
291
-
292
- M_label = signal._M_label
293
- y_label = signal._y_label
294
- x_label = signal._x_label
295
- title = signal._title
296
-
297
- return cls.from_array(M=M, y=y, x=x, M_label=M_label, y_label=y_label, x_label=x_label, title=title)
298
-
299
-
300
-
modusa/generators/s_ax.py DELETED
@@ -1,102 +0,0 @@
1
- #!/usr/bin/env python3
2
-
3
-
4
- from modusa import excp
5
- from modusa.decorators import validate_args_type
6
- from .base import ModusaGenerator
7
- from modusa.models.s_ax import SAx
8
- import numpy as np
9
-
10
- class SAxGen(ModusaGenerator):
11
- """
12
- Provides user friendly APIs to generate axis for
13
- signals (instances of `SAx`).
14
- """
15
-
16
- #--------Meta Information----------
17
- _name = "SignalAxisGenerator"
18
- _description = "APIs to generate axis for signals."
19
- _author_name = "Ankit Anand"
20
- _author_email = "ankit0.anand0@gmail.com"
21
- _created_at = "2025-07-25"
22
- #----------------------------------
23
-
24
-
25
- @classmethod
26
- @validate_args_type()
27
- def from_array(
28
- cls,
29
- values: np.ndarray | list | float | int | np.generic,
30
- label: str = "SAx"
31
- ) -> SAx:
32
- """
33
- Create `SAx` instance from basic data structures.
34
-
35
- .. code-block:: python
36
-
37
- import modusa as ms
38
- x = ms.sax.from_array([1, 2, 3])
39
- print(x)
40
- time_sax.print_info()
41
-
42
- Parameters
43
- ----------
44
- values: np.ndarray | list | float | int | np.generic
45
- - The values for the axis.
46
- label: str
47
- - Label for the axis.
48
-
49
- Returns
50
- -------
51
- SAx
52
- An instance of SAx.
53
- """
54
-
55
- if isinstance(values, (int, float, np.generic)): values = [values] # Scalar to 1D
56
- values = np.asarray(values)
57
-
58
- return SAx(values=values, label=label)
59
-
60
-
61
- @classmethod
62
- def linear(cls, n_points: int, sr: int | float = 1.0, start: int | float = 0.0, label: str = "Linear Axis") -> SAx:
63
- """
64
- Create a linearly spaced axis.
65
-
66
- .. code-block:: python
67
-
68
- import modusa as ms
69
- x = ms.sax.linear(n_points=100, sr=2, start=10, label="Time (sec)")
70
- print(x)
71
- x.print_info()
72
-
73
- Parameters
74
- ----------
75
- n_points: int
76
- - Number of data points for the axis.
77
- sr: int | float
78
- - Sampling rate of the axis.
79
- start: int | float
80
- - Start value.
81
- label: str
82
- - Label for the axis.
83
-
84
- Returns
85
- -------
86
- SAx
87
- An instance of SAx.
88
- """
89
-
90
- assert isinstance(n_points, int)
91
- assert isinstance(sr, (int, float))
92
- assert isinstance(start, (int, float))
93
- assert isinstance(label, str)
94
-
95
- sr = float(sr)
96
- start = float(start)
97
-
98
- values = start + np.arange(n_points) / sr # ensures exact number of points
99
- time_ax = SAx(values=values, label=label)
100
- time_ax.sr = sr
101
-
102
- return time_ax