Skip to content

Commit

Permalink
fix: Install custom equality for array dependent envelopes
Browse files Browse the repository at this point in the history
  • Loading branch information
alecandido committed Mar 27, 2024
1 parent fb1548b commit 1372d33
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 7 deletions.
21 changes: 15 additions & 6 deletions src/qibolab/pulses/envelope.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
from scipy.signal import lfilter
from scipy.signal.windows import gaussian

from qibolab.serialize_ import Model, NdArray
from qibolab.serialize_ import Model, NdArray, eq

__all__ = [
"Waveform",
Expand Down Expand Up @@ -71,7 +71,7 @@ class Exponential(BaseEnvelope):
.. math::
A\frac{\exp\left(-\frac{x}{\text{upsilon}}\right) + g \exp\left(-\frac{x}{\text{tau}}\right)}{1 + g}
\frac{\exp\left(-\frac{x}{\text{upsilon}}\right) + g \exp\left(-\frac{x}{\text{tau}}\right)}{1 + g}
"""

kind: Literal["exponential"] = "exponential"
Expand All @@ -85,8 +85,8 @@ class Exponential(BaseEnvelope):

def i(self, samples: int) -> Waveform:
"""Generate a combination of two exponential decays."""
ts = self.window(samples)
return (np.exp(-ts / self.upsilon) + self.g * np.exp(-ts / self.tau)) / (
x = np.arange(samples)
return (np.exp(-x / self.upsilon) + self.g * np.exp(-x / self.tau)) / (
1 + self.g
)

Expand Down Expand Up @@ -225,6 +225,10 @@ def q(self, samples: int) -> Waveform:
""".. todo::"""
return self._data(self.target.q(samples))

def __eq__(self, other) -> bool:
""".. todo::"""
return eq(self, other)


class Snz(BaseEnvelope):
"""Sudden variant Net Zero.
Expand Down Expand Up @@ -277,9 +281,10 @@ class ECap(BaseEnvelope):

def i(self, samples: int) -> Waveform:
""".. todo::"""
x = self.window(samples) / samples
ss = np.arange(samples)
x = ss / samples
return (
(1 + np.tanh(self.alpha * self.window(samples)))
(1 + np.tanh(self.alpha * ss))
* (1 + np.tanh(self.alpha * (1 - x)))
/ (1 + np.tanh(self.alpha / 2)) ** 2
)
Expand Down Expand Up @@ -313,6 +318,10 @@ def q(self, samples: int) -> Waveform:

return self.q_

def __eq__(self, other) -> bool:
""".. todo::"""
return eq(self, other)


Envelope = Annotated[
Union[
Expand Down
2 changes: 1 addition & 1 deletion src/qibolab/pulses/pulse.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ class Pulse(Model):
Pulse amplitudes are normalised between -1 and 1.
"""
frequency: int
frequency: float
"""Pulse Intermediate Frequency in Hz.
The value has to be in the range [10e6 to 300e6].
Expand Down

0 comments on commit 1372d33

Please sign in to comment.