modusa 0.4.28__py3-none-any.whl → 0.4.30__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 +9 -8
  2. modusa/tools/__init__.py +7 -2
  3. modusa/tools/ann_saver.py +30 -0
  4. modusa/tools/audio_recorder.py +0 -1
  5. modusa/tools/synth.py +2 -0
  6. modusa/tools/youtube_downloader.py +1 -4
  7. {modusa-0.4.28.dist-info → modusa-0.4.30.dist-info}/METADATA +2 -2
  8. modusa-0.4.30.dist-info/RECORD +21 -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.28.dist-info/RECORD +0 -65
  56. {modusa-0.4.28.dist-info → modusa-0.4.30.dist-info}/WHEEL +0 -0
  57. {modusa-0.4.28.dist-info → modusa-0.4.30.dist-info}/entry_points.txt +0 -0
  58. {modusa-0.4.28.dist-info → modusa-0.4.30.dist-info}/licenses/LICENSE.md +0 -0
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
modusa/generators/t_ax.py DELETED
@@ -1,64 +0,0 @@
1
- #!/usr/bin/env python3
2
-
3
-
4
- from modusa import excp
5
- from modusa.decorators import validate_args_type
6
- from modusa.generators.base import ModusaGenerator
7
- from modusa.models.t_ax import TAx
8
- import numpy as np
9
-
10
- class TAxGen(ModusaGenerator):
11
- """
12
- Provides user friendly APIs to generate time
13
- axis for signals (instances of `TAx`).
14
- """
15
-
16
- #--------Meta Information----------
17
- _name = "TimeAxisGenerator"
18
- _description = "APIs to generate time axis for signals."
19
- _author_name = "Ankit Anand"
20
- _author_email = "ankit0.anand0@gmail.com"
21
- _created_at = "2025-07-26"
22
- #----------------------------------
23
-
24
- @classmethod
25
- def linear(cls, n_points: int, sr: int | float = 1.0, t0: int | float = 0.0, label: str = "Time (sec)") -> TAx:
26
- """
27
- Create a linearly spaced time axis.
28
-
29
- .. code-block:: python
30
-
31
- import modusa as ms
32
- t = ms.tax.linear(n_points=100, sr=2, start=10, label="Time (sec)")
33
- print(t)
34
- t.print_info()
35
-
36
- Parameters
37
- ----------
38
- n_points: int
39
- - Number of data points for the time axis.
40
- sr: int | float
41
- - Sampling rate for the time axis.
42
- start: int | float
43
- - Start value.
44
- label: str
45
- - Label for the time axis.
46
-
47
- Returns
48
- -------
49
- TAx
50
- An instance of TAx.
51
- """
52
-
53
- assert isinstance(n_points, int)
54
- assert isinstance(sr, (int, float))
55
- assert isinstance(t0, (int, float))
56
- assert isinstance(label, str)
57
-
58
- sr = float(sr)
59
- t0 = float(t0)
60
-
61
- time_ax = TAx(n_points=n_points, sr=sr, t0=t0, label=label)
62
-
63
- return time_ax
64
-
modusa/generators/tds.py DELETED
@@ -1,267 +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.tds import TDS
8
- from modusa.models.t_ax import TAx
9
- from modusa.models.data import Data
10
- import numpy as np
11
-
12
- class TDSGen(ModusaGenerator):
13
- """
14
- Provides user friendly APIs to generate instances of different
15
- `TDS` instances.
16
- """
17
-
18
- #--------Meta Information----------
19
- _name = "TDSGenerator"
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: np.ndarray | list | float | int | np.generic,
29
- sr: float | int = 1.0,
30
- t0: float | int = 0.0,
31
- y_label: str = "Y",
32
- t_label: str = "Time (sec)",
33
- title: str = "Time Domain Signal"
34
- ) -> TDS:
35
- """
36
- Create `TDS` instance from basic data structures.
37
-
38
- .. code-block:: python
39
-
40
- import modusa as ms
41
- t = ms.tds.from_array([1, 2, 3])
42
- print(t)
43
- t.print_info()
44
-
45
- Parameters
46
- ----------
47
- y: np.ndarray | list | float | int | np.generic
48
- - Data values.
49
- sr: float | int
50
- - Sampling rate.
51
- t0: float | int
52
- - Start timestamp.
53
- y_label: str
54
- - Y label for the signal.
55
- - Default: "Y"
56
- t_label: str
57
- - T label for the signal.
58
- - Default: "Time (sec)"
59
- title: str
60
- - Title for the signal.
61
- - Default: "1D Signal"
62
- Returns
63
- -------
64
- TDS
65
- An instance of TDS.
66
- """
67
- assert isinstance(y, (np.ndarray, list, float, int, np.generic))
68
- assert isinstance(sr, (int, float)) and isinstance(t0, (int, float))
69
- assert isinstance(y_label, str) and isinstance(t_label, str) and isinstance(title, str)
70
-
71
- if isinstance(y, (float, int, np.generic)): y = [y] # Convert to list of 1 element
72
- y = np.asarray(y)
73
- assert y.ndim == 1
74
-
75
- sr = float(sr)
76
- t0 = float(t0)
77
-
78
- y = Data(values=y, label=y_label)
79
- t = TAx(n_points=y.shape[0], sr=sr, t0=t0, label=t_label) # Creating a signal axis instance
80
-
81
- return TDS(y=y, t=t, title=title)
82
-
83
- @classmethod
84
- def zeros(cls, shape, sr=1.0, t0=0.0) -> TDS:
85
- """
86
- Create `TDS` instance with all zeros.
87
-
88
- .. code-block:: python
89
-
90
- import modusa as ms
91
- y = ms.tds.zeros(10, sr=10)
92
- print(y)
93
- y.print_info()
94
-
95
- Parameters
96
- ----------
97
- shape: int | tuple[int]
98
- - Shape of the signal with zeros.
99
- - Must be 1 dimensional
100
- - E.g. 10 or (10, )
101
- sr: float | int
102
- - Sampling rate.
103
- t0: float | int
104
- - Start timestamp.
105
- Returns
106
- -------
107
- TDS
108
- An instance of TDS.
109
- """
110
- assert isinstance(shape, (int, tuple))
111
- y = np.zeros(shape)
112
-
113
- return cls.from_array(y=y, sr=sr, t0=t0, title="Zeros")
114
-
115
- @classmethod
116
- def zeros_like(cls, signal, shape=None) -> TDS:
117
- """
118
- Create `TDS` instance similar to `signal`
119
- but with all entries being zeros.
120
-
121
- .. code-block:: python
122
-
123
- import modusa as ms
124
- signal = ms.tds.from_array([1, 2, 3])
125
- y = ms.tds.zeros_like(signal)
126
- print(y)
127
- x.print_info()
128
-
129
- Parameters
130
- ----------
131
- signal: TDS
132
- - Reference signal to create zeros like that.
133
- Returns
134
- -------
135
- TDS
136
- An instance of TDS.
137
- """
138
-
139
- assert isinstance(signal, TDS)
140
-
141
- shape = signal.shape if shape is None else shape
142
-
143
- return cls.from_array(y=np.zeros(shape), sr=signal.t.sr, t0=signal.t.t0, y_label=signal.y.label, t_label=signal.t.label, title=signal.title)
144
-
145
-
146
- @classmethod
147
- def ones(cls, shape, sr=1.0, t0=0.0) -> TDS:
148
- """
149
- Create `TDS` instance with all ones.
150
-
151
- .. code-block:: python
152
-
153
- import modusa as ms
154
- y = ms.tds.ones(10)
155
- print(y)
156
- y.print_info()
157
-
158
- Parameters
159
- ----------
160
- shape: int | tuple[int]
161
- - Shape of the signal with ones.
162
- - Must be 1 dimensional
163
- - E.g. 10 or (10, )
164
- sr: float | int
165
- - Sampling rate.
166
- t0: float | int
167
- - Start timestamp.
168
- Returns
169
- -------
170
- TDS
171
- An instance of TDS.
172
- """
173
- assert isinstance(shape, (int, tuple))
174
- y = np.ones(shape)
175
-
176
- return cls.from_array(y=y, sr=sr, t0=t0, title="Ones")
177
-
178
- @classmethod
179
- def ones_like(cls, signal, shape=None) -> TDS:
180
- """
181
- Create `TDS` instance similar to `signal`
182
- but with all entries being ones.
183
-
184
- .. code-block:: python
185
-
186
- import modusa as ms
187
- signal = ms.tds.from_array([1, 2, 3])
188
- y = ms.tds.ones_like(signal)
189
- print(y)
190
- y.print_info()
191
-
192
- Parameters
193
- ----------
194
- signal: TDS
195
- - Reference signal to create ones like that.
196
- Returns
197
- -------
198
- TDS
199
- An instance of TDS.
200
- """
201
- assert isinstance(signal, TDS)
202
-
203
- shape = signal.shape if shape is None else shape
204
-
205
- return cls.from_array(y=np.ones(shape), sr=signal.t.sr, t0=signal.t.t0, y_label=signal.y.label, t_label=signal.t.label, title=signal.title)
206
-
207
- @classmethod
208
- def random(cls, shape, sr=1.0, t0=0.0) -> TDS:
209
- """
210
- Create `TDS` instance with random entries.
211
-
212
- .. code-block:: python
213
-
214
- import modusa as ms
215
- x = ms.tds.random(10)
216
- print(x)
217
- x.print_info()
218
-
219
- Parameters
220
- ----------
221
- shape: int | tuple[int]
222
- - Shape of the signal.
223
- - Must be 1 dimensional
224
- - E.g. 10 or (10, )
225
- sr: float | int
226
- - Sampling rate.
227
- t0: float | int
228
- - Start timestamp.
229
- Returns
230
- -------
231
- TDS
232
- An instance of TDS with random values.
233
- """
234
- assert isinstance(shape, (int, tuple))
235
- y = np.random.random(shape)
236
-
237
- return cls.from_array(y=y, sr=sr, t0=t0, title="Random")
238
-
239
- @classmethod
240
- def random_like(cls, signal, shape=None) -> TDS:
241
- """
242
- Create `TDS` instance similar to `signal`
243
- but with all entries being ones.
244
-
245
- .. code-block:: python
246
-
247
- import modusa as ms
248
- signal = ms.tds.from_array([1, 2, 3])
249
- y = ms.tds.random_like(signal)
250
- print(y)
251
- y.print_info()
252
-
253
- Parameters
254
- ----------
255
- signal: TDS
256
- - Reference signal to create one with random entries.
257
- Returns
258
- -------
259
- TDS
260
- An instance of TDS with random values.
261
- """
262
- assert isinstance(signal, TDS)
263
-
264
- shape = signal.shape if shape is None else shape
265
-
266
- return cls.from_array(y=np.random.random(shape), sr=signal.t.sr, t0=signal.t.t0, y_label=signal.y.label, t_label=signal.t.label, title=signal.title)
267
-