Skip to content

Commit

Permalink
flake8 remaining fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
nulinspiratie committed Dec 9, 2024
1 parent 5d7d9aa commit 3376191
Show file tree
Hide file tree
Showing 7 changed files with 43 additions and 37 deletions.
38 changes: 22 additions & 16 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,34 +4,29 @@ version = "v0.18.1"
description = "The qualang_tools package includes various tools related to QUA programs in Python"
authors = ["Quantum Machines <info@quantum-machines.co>"]
license = "BSD-3-Clause"
packages = [
{ include = "qualang_tools" }
]
include = [
]
exclude = [
"**/tests/**",
]
packages = [{ include = "qualang_tools" }]
include = []
exclude = ["**/tests/**"]
readme = "README.md"
homepage = "https://github.com/qua-platform/py-qua-tools"

[tool.poetry.dependencies]
python = ">=3.8, <3.13"
matplotlib = "^3.4.2"
numpy = [
{version = ">=1.17.0, <2", python = ">=3.8,<3.12"},
{version = ">=1.26.0, <2", python = ">=3.12"}
{ version = ">=1.17.0, <2", python = ">=3.8,<3.12" },
{ version = ">=1.26.0, <2", python = ">=3.12" },
]
qm-qua = {version = ">=1.1.7", python = ">=3.8,<3.13"}
qm-qua = { version = ">=1.1.7", python = ">=3.8,<3.13" }
scipy = [
{version = ">=1.7.1, <1.10.0", python = ">=3.8,<3.12"},
{version = ">=1.11.0", python = ">=3.12"}
{ version = ">=1.7.1, <1.10.0", python = ">=3.8,<3.12" },
{ version = ">=1.11.0", python = ">=3.12" },
]
pandas = { version = ">=1.2.4", optional = true }
dash = { version = "^2.0.0", optional = true }
dash-html-components = { version = "^2.0.0", optional = true }
dash-core-components = { version = "^2.0.0", optional = true }
dash-bootstrap-components = { version = "^1.6.0", optional = true, python = ">=3.8,<4"}
dash-bootstrap-components = { version = "^1.6.0", optional = true, python = ">=3.8,<4" }
dash-cytoscape = { version = "^0.3.0", optional = true }
dash-table = { version = "^5.0.0", optional = true }
dash-dangerously-set-inner-html = { version = "^0.0.2", optional = true }
Expand All @@ -48,12 +43,23 @@ grpclib = "0.4.5"
pytest = "^6.2.5"
black = "^24.3"
poethepoet = "^0.18.0"
flake8 = "^5.0.4"
flake8 = "^7.1.1"
setuptools = "^69.0.2"

[tool.poetry.extras]
interplot = ["dill", "pypiwin32", "ipython"]
configbuilder = ["pandas", "dash", "dash-html-components", "dash-core-components", "dash-bootstrap-components", "dash-cytoscape", "dash-table", "dash-dangerously-set-inner-html", "docutils", "waitress"]
configbuilder = [
"pandas",
"dash",
"dash-html-components",
"dash-core-components",
"dash-bootstrap-components",
"dash-cytoscape",
"dash-table",
"dash-dangerously-set-inner-html",
"docutils",
"waitress",
]
datahandler = ["xarray", "netcdf4"]

[tool.black]
Expand Down
8 changes: 4 additions & 4 deletions qualang_tools/addons/InteractivePlotLib.py
Original file line number Diff line number Diff line change
Expand Up @@ -1876,7 +1876,7 @@ def __init__(self, fit_type=1, ax=[], options={}):
ax = plt.gca()
self.ax = ax
lines = self.ax.get_lines()
if type(fit_type) == int:
if type(fit_type) is int:
self.res = {
"fit_type": [],
"fit_func": [],
Expand Down Expand Up @@ -1935,7 +1935,7 @@ def __init__(self, fit_type=1, ax=[], options={}):
self.res["x"].append(single_fit.x)
self.res["y"].append(single_fit.y)
self.res["yf"].append(single_fit.yf)
if type(fit_type) == int:
if type(fit_type) is int:
self.res["p"].append(single_fit.p)
self.res["y0"].append(single_fit.y0)
self.res["x0"].append(single_fit.x0)
Expand Down Expand Up @@ -2005,7 +2005,7 @@ def __init__(self, line, fit_type=1, ax=[], options={}):
y_data / y_scale,
options["initial_guess"],
)
print(f"func = { options ['func'] }, a = {popt}")
print(f"func = {options['func']}, a = {popt}")
self.fit_func = lambda x: fit_type(x / x_scale, popt) * y_scale
(l,) = plt.plot(x_data, self.fit_func(x_data), "m", linewidth=2)
self.fit_line_obj = l
Expand All @@ -2023,7 +2023,7 @@ def __init__(self, line, fit_type=1, ax=[], options={}):
else:
pass

elif type(fit_type) == int:
elif type(fit_type) is int:
self.ok = self.fit_polygon(line, options)

else:
Expand Down
24 changes: 12 additions & 12 deletions qualang_tools/bakery/bakery.py
Original file line number Diff line number Diff line change
Expand Up @@ -676,7 +676,7 @@ def add_op(
elif "singleInput" in self._local_config["elements"][qe]:
for i in range(len(samples)):
assert (
type(samples[i]) == float or type(samples[i]) == int
type(samples[i]) is float or type(samples[i]) is int
), f"{qe} is a singleInput element, list of numbers (int or float) should be provided "

pulse = {
Expand Down Expand Up @@ -740,10 +740,10 @@ def play(self, Op: str, qe: str, amp: Union[float, Tuple[float]] = 1.0) -> None:
Q3 = [None] * len(Q)

for i in range(len(I)):
if type(amp) == float or type(amp) == int:
if type(amp) is float or type(amp) is int:
I2[i] = amp * I[i]
Q2[i] = amp * Q[i]
elif len(amp) != 4 or type(amp) != tuple:
elif len(amp) != 4 or type(amp) is not tuple:
raise IndexError("Amplitudes provided must be stored in a tuple (v00, v01, v10, v11)")
else:
I2[i] = amp[0] * I[i] + amp[1] * Q[i]
Expand All @@ -757,7 +757,7 @@ def play(self, Op: str, qe: str, amp: Union[float, Tuple[float]] = 1.0) -> None:
elif "singleInput" in self._local_config["elements"][qe]:
for i in range(len(samples)):
assert (
type(samples[i]) == float or type(samples[i]) == int
type(samples[i]) is float or type(samples[i]) is int
), f"{qe} is a singleInput element, list of numbers (int or float) should be provided "
self._samples_dict[qe]["single"].append(amp * np.cos(freq * i * 1e-9 + phi) * samples[i])
self._update_qe_time(qe, len(samples))
Expand Down Expand Up @@ -793,8 +793,8 @@ def play_at(self, Op: str, qe: str, t: int, amp: Union[float, Tuple[float]] = 1.
"""
freq = self._qe_dict[qe]["freq"]
phi = self._qe_dict[qe]["phase"]
if type(t) != int:
if type(t) == float:
if type(t) is not int:
if type(t) is float:
t = int(t)
else:
raise TypeError("Provided time is not an integer")
Expand Down Expand Up @@ -830,11 +830,11 @@ def play_at(self, Op: str, qe: str, t: int, amp: Union[float, Tuple[float]] = 1.
[None] * len(I),
)
for i in range(len(I)):
if type(amp) == float or type(amp) == int:
if type(amp) is float or type(amp) is int:
I2[i] = amp * I[i]
Q2[i] = amp * Q[i]
else:
if len(amp) != 4 or type(amp) != tuple:
if len(amp) != 4 or type(amp) is not tuple:
raise IndexError("Amplitudes provided must be stored in a tuple (v00, v01, v10, v11)")
else:
I2[i] = amp[0] * I[i] + amp[1] * Q[i]
Expand All @@ -860,12 +860,12 @@ def play_at(self, Op: str, qe: str, t: int, amp: Union[float, Tuple[float]] = 1.
new_samples += 1

elif "singleInput" in self._local_config["elements"][qe]:
if type(amp) != float and type(amp) != int:
if type(amp) is not float and type(amp) is not int:
raise IndexError("Amplitude must be a number")

for i in range(len(samples)):
assert (
type(samples[i]) == float or type(samples[i]) == int
type(samples[i]) is float or type(samples[i]) is int
), f"{qe} is a singleInput element, list of numbers (int or float) should be provided "
if t + i < len(self._samples_dict[qe]["single"]):
self._samples_dict[qe]["single"][t + i] += (
Expand Down Expand Up @@ -1053,7 +1053,7 @@ def run(
else:
index2 = list(zip(*amp_array))[0].index(qe)
amp = list(zip(*amp_array))[1][index2]
if type(amp) == list:
if type(amp) is list:
raise TypeError("Amplitude can only be a number (either Python or QUA variable)")
qua.play(f"baked_Op_{self._ctr}" * qua.amp(amp), qe)

Expand All @@ -1073,7 +1073,7 @@ def run(
else:
index2 = list(zip(*amp_array))[0].index(qe)
amp = list(zip(*amp_array))[1][index2]
if type(amp) == list:
if type(amp) is list:
raise TypeError("Amplitude can only be a number (either Python or QUA variable)")
qua.play(f"baked_Op_{self._ctr}" * qua.amp(amp), qe, truncate=trunc)

Expand Down
2 changes: 1 addition & 1 deletion qualang_tools/config/primitive_components.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ def info(self):
return self.controller, self.port_id

def __eq__(self, other) -> bool:
return self.info == other.info and type(self) == type(other)
return self.info == other.info and type(self) is type(other)

def __str__(self):
cont, port_id = self.info
Expand Down
4 changes: 2 additions & 2 deletions qualang_tools/results/results.py
Original file line number Diff line number Diff line change
Expand Up @@ -59,8 +59,8 @@ def is_processing(self):
return self._b_cont or self._b_last

def _format(self, data):
if type(data) == np.ndarray:
if type(data[0]) == np.void:
if type(data) is np.ndarray:
if type(data[0]) is np.void:
if len(data.dtype) == 1:
data = data["value"]
return data
Expand Down
2 changes: 1 addition & 1 deletion qualang_tools/wirer/connectivity/channel_spec.py
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ def apply_constraints(self, constraints: "ChannelSpec") -> bool:
if template in constrained_templates:
# can't constrain already constrained spec
continue
if type(template) != type(constraint):
if type(template) is not type(constraint):
# can't constrain a spec of a different type
continue
else:
Expand Down
2 changes: 1 addition & 1 deletion qualang_tools/wirer/instruments/instrument_channels.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ def check_if_already_occupied(self, channel: AnyInstrumentChannel):
and channel.signal_type == existing_channel.signal_type
):
if channel.slot is None:
if type(channel) != type(existing_channel):
if type(channel) is not type(existing_channel):
pass
else:
raise ValueError(
Expand Down

0 comments on commit 3376191

Please sign in to comment.