Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion python/quantum-pecos/pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,6 @@ dependencies = [
"numpy>=1.15.0",
"scipy>=1.1.0",
"networkx>=2.1.0",
"matplotlib>=2.2.0",
]
classifiers = [
"Development Status :: 4 - Beta",
Expand Down Expand Up @@ -61,6 +60,7 @@ guppy = [
"selene-sim~=0.2.0", # Then selene-sim (dependency of guppylang)
]
visualization = [
"matplotlib>=2.2.0",
"plotly~=5.9.0",
]
all = [
Expand Down
6 changes: 5 additions & 1 deletion python/quantum-pecos/src/pecos/qeccs/plot.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,9 @@
from typing import TYPE_CHECKING, TypeVar

import networkx as nx
from matplotlib import pyplot as plt

if TYPE_CHECKING:

from pecos.protocols import LogicalInstructionProtocol, QECCProtocol

T = TypeVar("T")
Expand Down Expand Up @@ -54,6 +54,8 @@ def plot_qecc(
**kwargs: Additional keyword arguments (will raise exception if any are provided).

"""
from matplotlib import pyplot as plt

if kwargs:
msg = f"keys {kwargs.keys()} not recognized!"
raise Exception(msg)
Expand Down Expand Up @@ -166,6 +168,8 @@ def plot_instr(
**kwargs: Additional keyword arguments (will raise exception if any are provided)

"""
from matplotlib import pyplot as plt

if kwargs:
msg = f"keys {kwargs.keys()} not recognized!"
raise Exception(msg)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,11 @@

from typing import TYPE_CHECKING

import matplotlib.pyplot as plt
import networkx as nx
from matplotlib import pyplot as plt

if TYPE_CHECKING:

from pecos.qeclib.color488 import Color488


Expand All @@ -36,6 +37,8 @@ def plot_layout(
Returns:
The matplotlib pyplot module with the plot rendered.
"""
import matplotlib.pyplot as plt

positions, polygons = color488.get_layout()

# Calculate the mid-point for each polygon
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,12 @@
from dataclasses import dataclass
from typing import TYPE_CHECKING

import matplotlib.pyplot as plt
import numpy as np
from matplotlib.patches import Circle, PathPatch
from matplotlib.path import Path

if TYPE_CHECKING:
from matplotlib import pyplot as plt
from matplotlib.path import Path

from pecos.qeclib.surface.patches.patch_base import SurfacePatch


Expand Down Expand Up @@ -75,6 +75,9 @@ def plot_colored_polygons(
polygon_colors (dict[int, int]): List of indices into `colors` for each polygon.
config (Lattice2DConfig | None): Optional Lattice2DConfig object.
"""
import matplotlib.pyplot as plt
from matplotlib.patches import Circle, PathPatch

c = config

# Plot setup
Expand Down Expand Up @@ -208,6 +211,8 @@ def create_cup_path(
Returns:
Path: A matplotlib path representing the cup shape.
"""
from matplotlib.path import Path

# Calculate midpoint of the base
mid_base = ((base1[0] + base2[0]) / 2, (base1[1] + base2[1]) / 2)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@

from typing import TYPE_CHECKING

import matplotlib.pyplot as plt
import numpy as np
from scipy.optimize import brentq, curve_fit, newton

Expand Down Expand Up @@ -324,6 +323,8 @@ def plot(
p_start(float): Starting point for the plot axes. If None, automatically determined.
p_end(float): Ending point for the plot axes. If None, automatically determined.
"""
import matplotlib.pyplot as plt

if p_start is None:
p_start = min(plog) * 0.9

Expand Down
10 changes: 7 additions & 3 deletions python/quantum-pecos/tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,15 @@

"""Test configuration and shared fixtures."""

# Configure matplotlib to use non-interactive backend for tests
# Configure matplotlib to use non-interactive backend for tests (if available)
# This must be done before importing matplotlib.pyplot to avoid GUI backend issues on Windows
import matplotlib as mpl
try:
import matplotlib as mpl

mpl.use("Agg")
mpl.use("Agg")
except ImportError:
# matplotlib is optional - only needed for visualization tests
pass

# Note: llvmlite functionality is now always available via Rust (pecos_rslib.ir and pecos_rslib.binding)
# No need for conditional test skipping
4 changes: 4 additions & 0 deletions ruff.toml
Original file line number Diff line number Diff line change
Expand Up @@ -200,6 +200,10 @@ ignore = [
"python/quantum-pecos/src/pecos/frontends/*.py" = ["PLC0415"] # All frontends have optional dependencies
"python/quantum-pecos/src/pecos/frontends/guppy_frontend.py" = ["PLC0415", "S603", "S607"] # Also uses subprocess for external tools
"python/quantum-pecos/src/pecos/frontends/selene_native_backend.py" = ["S311"] # Uses random for test placeholders
"python/quantum-pecos/src/pecos/qeccs/plot.py" = ["PLC0415"] # matplotlib: optional visualization dependency
"python/quantum-pecos/src/pecos/qeclib/color488/plot_layout.py" = ["PLC0415"] # matplotlib: optional visualization dependency
"python/quantum-pecos/src/pecos/qeclib/surface/visualization/lattice_2d.py" = ["PLC0415"] # matplotlib: optional visualization dependency
"python/quantum-pecos/src/pecos/tools/pseudo_threshold_tools.py" = ["PLC0415"] # matplotlib: optional visualization dependency

# Examples - relaxed rules for demonstration code
"python/pecos-rslib/examples/*.py" = ["PLC0415", "INP001"] # Lazy imports, no __init__.py needed
Expand Down
5 changes: 3 additions & 2 deletions uv.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading