ezmsg-sigproc 1.8.1__py3-none-any.whl → 1.8.2__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.
@@ -17,5 +17,5 @@ __version__: str
17
17
  __version_tuple__: VERSION_TUPLE
18
18
  version_tuple: VERSION_TUPLE
19
19
 
20
- __version__ = version = '1.8.1'
21
- __version_tuple__ = version_tuple = (1, 8, 1)
20
+ __version__ = version = '1.8.2'
21
+ __version_tuple__ = version_tuple = (1, 8, 2)
@@ -14,7 +14,7 @@ from .base import GenAxisArray
14
14
 
15
15
  @consumer
16
16
  def downsample(
17
- axis: str | None = None, target_rate: float | None = None
17
+ axis: str | None = None, target_rate: float | None = None, factor: int | None = None
18
18
  ) -> typing.Generator[AxisArray, AxisArray, None]:
19
19
  """
20
20
  Construct a generator that yields a downsampled version of the data .send() to it.
@@ -28,6 +28,7 @@ def downsample(
28
28
  Note: The axis must exist in the message .axes and be of type AxisArray.LinearAxis.
29
29
  target_rate: Desired rate after downsampling. The actual rate will be the nearest integer factor of the
30
30
  input rate that is the same or higher than the target rate.
31
+ factor: Explicitly specify downsample factor. If specified, target_rate is ignored.
31
32
 
32
33
  Returns:
33
34
  A primed generator object ready to receive an :obj:`AxisArray` via `.send(axis_array)`
@@ -39,7 +40,7 @@ def downsample(
39
40
  msg_out = AxisArray(np.array([]), dims=[""])
40
41
 
41
42
  # state variables
42
- factor: int = 0 # The integer downsampling factor. It will be determined based on the target rate.
43
+ q: int = 0 # The integer downsampling factor. It will be determined based on the target rate.
43
44
  s_idx: int = 0 # Index of the next msg's first sample into the virtual rotating ds_factor counter.
44
45
 
45
46
  check_input = {"gain": None, "key": None}
@@ -61,19 +62,21 @@ def downsample(
61
62
  check_input["key"] = msg_in.key
62
63
  # Reset state variables
63
64
  s_idx = 0
64
- if target_rate is None:
65
- factor = 1
65
+ if factor is not None:
66
+ q = factor
67
+ elif target_rate is None:
68
+ q = 1
66
69
  else:
67
- factor = int(1 / (axis_info.gain * target_rate))
68
- if factor < 1:
70
+ q = int(1 / (axis_info.gain * target_rate))
71
+ if q < 1:
69
72
  ez.logger.warning(
70
73
  f"Target rate {target_rate} cannot be achieved with input rate of {1/axis_info.gain}."
71
74
  "Setting factor to 1."
72
75
  )
73
- factor = 1
76
+ q = 1
74
77
 
75
78
  n_samples = msg_in.data.shape[axis_idx]
76
- samples = np.arange(s_idx, s_idx + n_samples) % factor
79
+ samples = np.arange(s_idx, s_idx + n_samples) % q
77
80
  if n_samples > 0:
78
81
  # Update state for next iteration.
79
82
  s_idx = samples[-1] + 1
@@ -92,7 +95,7 @@ def downsample(
92
95
  **msg_in.axes,
93
96
  axis: replace(
94
97
  axis_info,
95
- gain=axis_info.gain * factor,
98
+ gain=axis_info.gain * q,
96
99
  offset=axis_info.offset + axis_info.gain * n_step,
97
100
  ),
98
101
  },
@@ -107,6 +110,7 @@ class DownsampleSettings(ez.Settings):
107
110
 
108
111
  axis: str | None = None
109
112
  target_rate: float | None = None
113
+ factor: int | None = None
110
114
 
111
115
 
112
116
  class Downsample(GenAxisArray):
@@ -116,5 +120,7 @@ class Downsample(GenAxisArray):
116
120
 
117
121
  def construct_generator(self):
118
122
  self.STATE.gen = downsample(
119
- axis=self.SETTINGS.axis, target_rate=self.SETTINGS.target_rate
123
+ axis=self.SETTINGS.axis,
124
+ target_rate=self.SETTINGS.target_rate,
125
+ factor=self.SETTINGS.factor,
120
126
  )
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: ezmsg-sigproc
3
- Version: 1.8.1
3
+ Version: 1.8.2
4
4
  Summary: Timeseries signal processing implementations in ezmsg
5
5
  Author-email: Griffin Milsap <griffin.milsap@gmail.com>, Preston Peranich <pperanich@gmail.com>, Chadwick Boulay <chadwick.boulay@gmail.com>
6
6
  License-Expression: MIT
@@ -1,5 +1,5 @@
1
1
  ezmsg/sigproc/__init__.py,sha256=8K4IcOA3-pfzadoM6s2Sfg5460KlJUocGgyTJTJl96U,52
2
- ezmsg/sigproc/__version__.py,sha256=8ety3-vW-PuHKrxUFSl1a0H98STtZwISOYo9asXn_xo,511
2
+ ezmsg/sigproc/__version__.py,sha256=zaeoU7Eq6PaWD3xKg_JynFq8PW2k7pyoCPnWj8bsvOI,511
3
3
  ezmsg/sigproc/activation.py,sha256=LM-MtaNvFvmBZ1_EPNu--4K3-wIzsb7CUQ00fvMM69g,2642
4
4
  ezmsg/sigproc/affinetransform.py,sha256=R2P1f5JdNSpr30x8Pxoqv-J-nAasGl_UZR8o7sVqlaQ,8740
5
5
  ezmsg/sigproc/aggregate.py,sha256=6BqAujWe7_zzGPDJz7yh4ofPzJTU5z2lrclX-IuqXDU,6235
@@ -8,7 +8,7 @@ ezmsg/sigproc/base.py,sha256=1I0Dr8jz5u5mcdQu2SdrKAjujx2DQl05u9h0MO8yay0,1330
8
8
  ezmsg/sigproc/butterworthfilter.py,sha256=vZTY37FfLwa24bRZmeZGyO5323824wJosUrrZarb0_o,5402
9
9
  ezmsg/sigproc/cheby.py,sha256=yds5y1fOeBE1ljyH_EreBLxqFX4UetxB_3rwz3omHyc,3394
10
10
  ezmsg/sigproc/decimate.py,sha256=qxZoGmriviTNIUvTOA--U65CPWD1uTvQ9pij79-u00Q,2044
11
- ezmsg/sigproc/downsample.py,sha256=PYdrp7p6subP_qbGB2-3C14bd8W4tvC5oMKEmERQZmk,4049
11
+ ezmsg/sigproc/downsample.py,sha256=qBv4WKRdFs_SRsG6aiL98tQ-XEVOtdAgfvhdLQx7szk,4282
12
12
  ezmsg/sigproc/ewmfilter.py,sha256=EPlocRdKORj575VV1YUzcNsVcq-pYgdEJ7_m9WfpVnY,4795
13
13
  ezmsg/sigproc/filter.py,sha256=n3_gColSPXe4pI-A2VDKfrdFHZgC-k4kqB8H6tnGIws,6969
14
14
  ezmsg/sigproc/filterbank.py,sha256=HqyVrvpnp2ZhzYE3BNBXC0IWStKq4nFC9F9-Mj8nxCQ,12562
@@ -33,7 +33,7 @@ ezmsg/sigproc/math/scale.py,sha256=lQKF02Mv9nTWfgc4OcMpQMCx993p57GSN-AADeO2fjY,1
33
33
  ezmsg/sigproc/util/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
34
34
  ezmsg/sigproc/util/profile.py,sha256=EZZ-GsvcgJEt1zP6bM26GfdKu7vhaqFtqFFGsM_AeC8,4670
35
35
  ezmsg/sigproc/util/sparse.py,sha256=8Ke0jh3jRPi_TwIdLTwLdojQiaqPs6QV-Edqpx81VoI,1036
36
- ezmsg_sigproc-1.8.1.dist-info/METADATA,sha256=BVy8Q7ckNa9Zh5U7fknMltU9MlAXKDMseHkp3j3xjiM,2439
37
- ezmsg_sigproc-1.8.1.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
38
- ezmsg_sigproc-1.8.1.dist-info/licenses/LICENSE.txt,sha256=seu0tKhhAMPCUgc1XpXGGaCxY1YaYvFJwqFuQZAl2go,1100
39
- ezmsg_sigproc-1.8.1.dist-info/RECORD,,
36
+ ezmsg_sigproc-1.8.2.dist-info/METADATA,sha256=uKEwp3mpeCvfC38hBDZ9JZB4ikAViYc7qnO7RSaFVqs,2439
37
+ ezmsg_sigproc-1.8.2.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
38
+ ezmsg_sigproc-1.8.2.dist-info/licenses/LICENSE.txt,sha256=seu0tKhhAMPCUgc1XpXGGaCxY1YaYvFJwqFuQZAl2go,1100
39
+ ezmsg_sigproc-1.8.2.dist-info/RECORD,,