iqm-pulse 9.13.0__py3-none-any.whl → 9.15.0__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.
@@ -22,6 +22,7 @@ import html
22
22
  import io
23
23
  import json
24
24
  from pathlib import Path
25
+ from typing import Any
25
26
 
26
27
  from iqm.models.playlist.waveforms import Waveform
27
28
  from jinja2 import Environment, FileSystemLoader
@@ -30,6 +31,29 @@ import numpy as np
30
31
  from iqm.pulse.playlist.playlist import Playlist
31
32
 
32
33
 
34
+ def _numpy_to_builtin_types(data: list[tuple[str, Any]]):
35
+ """Convert selected ``numpy`` types to Python's built-in types.
36
+
37
+ This helper function is to be used for converting dataclasses into
38
+ dictionaries with ``asdict``.
39
+
40
+ For example, ``Playlist`` dataclasses can get converted to dictionaries to
41
+ be rendered as HTML/JavaScript in "playlist inspector". If such classes
42
+ were to contain ``numpy`` types they could not be handled by JavaScript.
43
+ """
44
+ converted_data = {}
45
+
46
+ for key, value in data:
47
+ if isinstance(value, np.float64):
48
+ converted_data[key] = float(value)
49
+ elif isinstance(value, np.ndarray):
50
+ converted_data[key] = value.tolist()
51
+ else:
52
+ converted_data[key] = value
53
+
54
+ return converted_data
55
+
56
+
33
57
  def _get_waveform(wave: Waveform, scale: float, wave_q: Waveform | None = None, scale_q: float | None = None) -> str:
34
58
  import matplotlib.pyplot as plt
35
59
 
@@ -74,7 +98,7 @@ def _playlist_as_a_dict(playlist: Playlist, segment_indices: Sequence[int]) -> d
74
98
  instruction = channel_desc.instruction_table[instruction_idx]
75
99
  instruction_dict = {}
76
100
  instruction_dict["name"] = instruction.operation.__class__.__name__
77
- params = asdict(instruction.operation)
101
+ params = asdict(instruction.operation, dict_factory=_numpy_to_builtin_types)
78
102
  if instruction.operation.__class__.__name__ == "RealPulse":
79
103
  instruction_dict["wave_img_idx"] = instruction_idx
80
104
  if str(instruction_idx) not in waveform_dict[channel]:
@@ -119,7 +119,7 @@
119
119
  var fullscreen_state = false;
120
120
 
121
121
  // The schedules to render
122
- var schedules = {{jsonobj.playlists | replace("array", "Array")}}
122
+ var schedules = {{jsonobj.playlists}}
123
123
  var waveforms = {{jsonobj.waveforms}}
124
124
  var segment_indices = {{segment_indices}}
125
125
 
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: iqm-pulse
3
- Version: 9.13.0
3
+ Version: 9.15.0
4
4
  Summary: A Python-based project for providing interface and implementations for control pulses.
5
5
  Author-email: IQM Finland Oy <info@meetiqm.com>
6
6
  License: Apache License
@@ -214,7 +214,7 @@ Requires-Python: >=3.11
214
214
  Description-Content-Type: text/x-rst
215
215
  License-File: LICENSE.txt
216
216
  Requires-Dist: iqm-exa-common <27,>=26
217
- Requires-Dist: iqm-data-definitions <3.0,>=2.6
217
+ Requires-Dist: iqm-data-definitions <3.0,>=2.13
218
218
  Requires-Dist: python-rapidjson ==1.20
219
219
  Requires-Dist: jinja2 ==3.0.3
220
220
  Requires-Dist: numpy <3.0,>=1.26.4
@@ -32,14 +32,14 @@ iqm/pulse/playlist/playlist.py,sha256=7MIX4iRfh2Nit8AnpNyqv5A5ZmK7JR-v201DXVL6kU
32
32
  iqm/pulse/playlist/schedule.py,sha256=VYrVyPlB04Rm8iOYBXu2uOpsLBqczJRx3L2VU53CxVU,17989
33
33
  iqm/pulse/playlist/waveforms.py,sha256=Xa7P3V0rRIn7sQIoLKqXaWwtAbyQWjdVGW6bKOGNcOQ,17898
34
34
  iqm/pulse/playlist/visualisation/__init__.py,sha256=wCNfJHIR_bqG3ZBlgm55v90Rih7VCpfctoIMfwRMgjk,567
35
- iqm/pulse/playlist/visualisation/base.py,sha256=owECDA8rgWtNWncu7_QLAyEm7K2GrXaE1e1VfPEYkNg,7882
36
- iqm/pulse/playlist/visualisation/templates/playlist_inspection.jinja2,sha256=DrGHv4LLPZ2jyirin0CrGBRkpbs3oZVCeMLQrdfwUcI,11539
35
+ iqm/pulse/playlist/visualisation/base.py,sha256=5RkwfZw-5bMVsZSTx6gbw1DAEz2B9HA5kuAKuzUQoME,8734
36
+ iqm/pulse/playlist/visualisation/templates/playlist_inspection.jinja2,sha256=4XPmpISH5LLOf3YjmK3OKfvkAWj4TlzD2K4ClFTvZhI,11511
37
37
  iqm/pulse/playlist/visualisation/templates/static/logo.png,sha256=rbfQZ6_UEaztpY2uoYBuVypEwQVQTFB61oHzDzNRFJ0,94565
38
38
  iqm/pulse/playlist/visualisation/templates/static/moment.min.js,sha256=4iQZ6BVL4qNKlQ27TExEhBN1HFPvAvAMbFavKKosSWQ,53324
39
39
  iqm/pulse/playlist/visualisation/templates/static/vis-timeline-graph2d.min.css,sha256=svzNasPg1yR5gvEaRei2jg-n4Pc3sVyMUWeS6xRAh6U,19837
40
40
  iqm/pulse/playlist/visualisation/templates/static/vis-timeline-graph2d.min.js,sha256=OqCqCyA6JnxPz3PGXq_P_9VuSqWptgNt5Ev3T-xjefQ,570288
41
- iqm_pulse-9.13.0.dist-info/LICENSE.txt,sha256=R6Q7eUrLyoCQgWYorQ8WJmVmWKYU3dxA3jYUp0wwQAw,11332
42
- iqm_pulse-9.13.0.dist-info/METADATA,sha256=jXCyUY1rU23z8fTDdYqs5r9Fe8iQgpepR0NvAlEVnwg,14523
43
- iqm_pulse-9.13.0.dist-info/WHEEL,sha256=y4mX-SOX4fYIkonsAGA5N0Oy-8_gI4FXw5HNI1xqvWg,91
44
- iqm_pulse-9.13.0.dist-info/top_level.txt,sha256=NB4XRfyDS6_wG9gMsyX-9LTU7kWnTQxNvkbzIxGv3-c,4
45
- iqm_pulse-9.13.0.dist-info/RECORD,,
41
+ iqm_pulse-9.15.0.dist-info/LICENSE.txt,sha256=R6Q7eUrLyoCQgWYorQ8WJmVmWKYU3dxA3jYUp0wwQAw,11332
42
+ iqm_pulse-9.15.0.dist-info/METADATA,sha256=dNNLT5dwUSsLxRAL-34VOwLm2TiYYSBdWwK8D4IGn1Q,14524
43
+ iqm_pulse-9.15.0.dist-info/WHEEL,sha256=y4mX-SOX4fYIkonsAGA5N0Oy-8_gI4FXw5HNI1xqvWg,91
44
+ iqm_pulse-9.15.0.dist-info/top_level.txt,sha256=NB4XRfyDS6_wG9gMsyX-9LTU7kWnTQxNvkbzIxGv3-c,4
45
+ iqm_pulse-9.15.0.dist-info/RECORD,,