Skip to content

Commit

Permalink
Upgrade black version to 24.3.0 to fix vulnerability (#662)
Browse files Browse the repository at this point in the history
* Upgrade black version

* upgrade version to v0.17.4

* Run black 24.3.0

* Fix import version
  • Loading branch information
a-corni authored Mar 25, 2024
1 parent c8dcef0 commit 85615c5
Show file tree
Hide file tree
Showing 10 changed files with 46 additions and 30 deletions.
2 changes: 1 addition & 1 deletion dev_requirements.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# tests
black[jupyter] ~= 23.1
black[jupyter] ~= 24.3
flake8
flake8-docstrings
isort
Expand Down
23 changes: 14 additions & 9 deletions pulser-core/pulser/devices/_device_datacls.py
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,7 @@ class BaseDevice(ABC):
max_runs: The maximum number of runs allowed on the device. Only used
for backend execution.
"""

name: str
dimensions: DIMENSIONS
rydberg_level: int
Expand Down Expand Up @@ -508,6 +509,7 @@ class Device(BaseDevice):
pre_calibrated_layouts: RegisterLayout instances that are already
available on the Device.
"""

max_atom_num: int
max_radial_distance: int
pre_calibrated_layouts: tuple[RegisterLayout, ...] = field(
Expand Down Expand Up @@ -630,15 +632,17 @@ def _specs(self, for_docs: bool = False) -> str:
+ f" {ch.max_amp:.4g} rad/µs"
),
(
"\t"
+ r"- Maximum :math:`|\delta|`:"
+ f" {ch.max_abs_detuning:.4g} rad/µs"
)
if not isinstance(ch, DMM)
else (
"\t"
+ r"- Bottom :math:`|\delta|`:"
+ f" {ch.bottom_detuning:.4g} rad/µs"
(
"\t"
+ r"- Maximum :math:`|\delta|`:"
+ f" {ch.max_abs_detuning:.4g} rad/µs"
)
if not isinstance(ch, DMM)
else (
"\t"
+ r"- Bottom :math:`|\delta|`:"
+ f" {ch.bottom_detuning:.4g} rad/µs"
)
),
f"\t- Minimum average amplitude: {ch.min_avg_amp} rad/µs",
]
Expand Down Expand Up @@ -703,6 +707,7 @@ class VirtualDevice(BaseDevice):
reusable_channels: Whether each channel can be declared multiple times
on the same pulse sequence.
"""

min_atom_distance: float = 0
max_atom_num: int | None = None
max_radial_distance: int | None = None
Expand Down
1 change: 1 addition & 0 deletions pulser-core/pulser/register/_coordinates.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""Defines a collection of coordinates."""

from __future__ import annotations

import hashlib
Expand Down
8 changes: 5 additions & 3 deletions pulser-core/pulser/register/_patterns.py
Original file line number Diff line number Diff line change
Expand Up @@ -118,9 +118,11 @@ def triangular_hex(n_points: int) -> np.ndarray:
for side in range(6)
for atom in range(
1,
min_atoms_per_side + 2
if points_left > sides_order[side]
else min_atoms_per_side + 1,
(
min_atoms_per_side + 2
if points_left > sides_order[side]
else min_atoms_per_side + 1
),
)
],
dtype=float,
Expand Down
1 change: 1 addition & 0 deletions pulser-core/pulser/sampler/sampler.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""The main function for sequence sampling."""

from __future__ import annotations

from typing import TYPE_CHECKING, Any, Optional
Expand Down
1 change: 1 addition & 0 deletions pulser-core/pulser/sampler/samples.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""Dataclasses for storing and processing the samples."""

from __future__ import annotations

import itertools
Expand Down
18 changes: 11 additions & 7 deletions pulser-core/pulser/sequence/_seq_drawer.py
Original file line number Diff line number Diff line change
Expand Up @@ -325,9 +325,11 @@ def gather_qubit_data(
if sub_target != set():
pad_times = (
0 if times == "initial" else target[0],
0
if times == "initial"
else total_duration - target[1],
(
0
if times == "initial"
else total_duration - target[1]
),
)
qubit_data[i][tuple(sub_target)] = (
w
Expand Down Expand Up @@ -935,11 +937,13 @@ def _draw_qubit_content(
draw_data = {"input": draw_input, "modulated": draw_modulation}
n_data = sum(list(draw_data.values()))
qubit_data = [
gather_qubit_data(
sampled_seq, data, register, (data_name == "modulated")
(
gather_qubit_data(
sampled_seq, data, register, (data_name == "modulated")
)
if to_draw
else None
)
if to_draw
else None
for data_name, to_draw in draw_data.items()
]
# Figure composed of 2 subplots (input, modulated) each composed
Expand Down
10 changes: 6 additions & 4 deletions pulser-core/pulser/sequence/_seq_str.py
Original file line number Diff line number Diff line change
Expand Up @@ -63,10 +63,12 @@ def seq_to_str(sequence: Sequence) -> str:
full += dmm_det_line.format(
ts.ti,
ts.tf,
ts.type.detuning
if not seq.is_detuned_delay(ts.type)
else "{:.3g} rad/µs".format(
cast(float, ts.type.detuning[0])
(
ts.type.detuning
if not seq.is_detuned_delay(ts.type)
else "{:.3g} rad/µs".format(
cast(float, ts.type.detuning[0])
)
),
tgt_txt,
)
Expand Down
8 changes: 5 additions & 3 deletions pulser-core/pulser/sequence/sequence.py
Original file line number Diff line number Diff line change
Expand Up @@ -318,9 +318,11 @@ def available_channels(self) -> dict[str, Channel]:
return all_channels
else:
occupied_ch_ids = [
self._schedule[ch_name].channel_id
if ch_name in self._schedule
else _dmm_id_from_name(ch_name)
(
self._schedule[ch_name].channel_id
if ch_name in self._schedule
else _dmm_id_from_name(ch_name)
)
for ch_name in self.declared_channels.keys()
]
return {
Expand Down
4 changes: 1 addition & 3 deletions tests/test_simulation.py
Original file line number Diff line number Diff line change
Expand Up @@ -490,9 +490,7 @@ def test_run(seq, patch_plt_show):
good_initial_qobj = qutip.tensor(
[qutip.basis(sim.dim, 0) for _ in range(sim._hamiltonian._size)]
)
good_initial_qobj_no_dims = qutip.basis(
sim.dim**sim._hamiltonian._size, 2
)
good_initial_qobj_no_dims = qutip.basis(sim.dim**sim._hamiltonian._size, 2)

with pytest.raises(
ValueError, match="Incompatible shape of initial state"
Expand Down

0 comments on commit 85615c5

Please sign in to comment.