Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix isort config #647

Merged
merged 19 commits into from
Mar 21, 2024
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
3 changes: 3 additions & 0 deletions .github/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,9 @@

### Bug fixes

* Specify `isort` `--py` (Python version) and `-l` (max line length) to stabilize `isort` across Python versions and environments.
maliasadi marked this conversation as resolved.
Show resolved Hide resolved
[(#647)](https://github.com/PennyLaneAI/pennylane-lightning/pull/647)

* Fix random `coverage xml` CI issues.
[(#635)](https://github.com/PennyLaneAI/pennylane-lightning/pull/635)

Expand Down
9 changes: 3 additions & 6 deletions .github/workflows/format.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,11 +26,8 @@ jobs:
- name: Checkout PennyLane-Lightning
uses: actions/checkout@v3

- name: Run isort
run: python -m isort --profile black ./pennylane_lightning/ ./mpitests ./tests --check --diff

- name: Run Black
run: python -m black -l 100 pennylane_lightning/ tests/ --check --verbose
- name: Run isort & black --check
run: make format-python check=1 verbose=1

format-cpp:
name: Format (C++)
Expand Down Expand Up @@ -62,7 +59,7 @@ jobs:
- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: '3.9'
python-version: '3.11'

- name: Install dependencies
run: sudo apt update && sudo apt -y install cmake gcc-11 g++-11 ninja-build libomp-14-dev && python -m pip install -r requirements-dev.txt
Expand Down
8 changes: 5 additions & 3 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,11 @@ TESTRUNNER := -m pytest tests --tb=short
PL_BACKEND ?= "$(if $(backend:-=),$(backend),lightning_qubit)"

ifdef check
CHECK := --check
CHECK := --check --diff
ICHECK := --check
else
CHECK :=
ICHECK :=
endif

ifdef build_options
Expand Down Expand Up @@ -113,8 +115,8 @@ format-cpp:
./bin/format $(CHECK) ./pennylane_lightning

format-python:
isort --profile black ./pennylane_lightning/ ./mpitests ./tests $(CHECK)
black -l 100 ./pennylane_lightning/ ./mpitests ./tests $(CHECK)
isort --py 311 --profile black -l 100 -p pennylane_lightning ./pennylane_lightning/ ./mpitests ./tests $(ICHECK) $(VERBOSE)
maliasadi marked this conversation as resolved.
Show resolved Hide resolved
black -l 100 ./pennylane_lightning/ ./mpitests ./tests $(CHECK) $(VERBOSE)

.PHONY: check-tidy
check-tidy:
Expand Down
2 changes: 1 addition & 1 deletion pennylane_lightning/core/_version.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,4 +16,4 @@
Version number (major.minor.patch[-label])
"""

__version__ = "0.36.0-dev14"
__version__ = "0.36.0-dev15"
11 changes: 4 additions & 7 deletions pennylane_lightning/lightning_gpu/lightning_gpu.py
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,10 @@
from pennylane.ops.op_math import Adjoint
from pennylane.wires import Wires

# pylint: disable=import-error, no-name-in-module, ungrouped-imports
from pennylane_lightning.core._serialize import QuantumScriptSerializer, global_phase_diagonal
from pennylane_lightning.core._version import __version__

# pylint: disable=no-name-in-module, ungrouped-imports
from pennylane_lightning.lightning_gpu_ops.algorithms import (
AdjointJacobianC64,
Expand All @@ -99,13 +103,6 @@
create_ops_listC128,
)

# pylint: disable=import-error, no-name-in-module, ungrouped-imports
from pennylane_lightning.core._serialize import (
QuantumScriptSerializer,
global_phase_diagonal,
)
from pennylane_lightning.core._version import __version__

if MPI_SUPPORT:
from pennylane_lightning.lightning_gpu_ops.algorithmsMPI import (
AdjointJacobianMPIC64,
Expand Down
11 changes: 4 additions & 7 deletions pennylane_lightning/lightning_kokkos/lightning_kokkos.py
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,10 @@
from pennylane.ops.op_math import Adjoint
from pennylane.wires import Wires

# pylint: disable=import-error, no-name-in-module, ungrouped-imports
from pennylane_lightning.core._serialize import QuantumScriptSerializer, global_phase_diagonal
from pennylane_lightning.core._version import __version__

# pylint: disable=import-error, no-name-in-module, ungrouped-imports
from pennylane_lightning.lightning_kokkos_ops.algorithms import (
AdjointJacobianC64,
Expand All @@ -72,13 +76,6 @@
create_ops_listC128,
)

# pylint: disable=import-error, no-name-in-module, ungrouped-imports
from pennylane_lightning.core._serialize import (
QuantumScriptSerializer,
global_phase_diagonal,
)
from pennylane_lightning.core._version import __version__

def _kokkos_dtype(dtype):
if dtype not in [np.complex128, np.complex64]: # pragma: no cover
raise ValueError(f"Data type is not supported for state-vector computation: {dtype}")
Expand Down
5 changes: 1 addition & 4 deletions pennylane_lightning/lightning_qubit/_measurements.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,7 @@

# pylint: disable=import-error, no-name-in-module, ungrouped-imports
try:
from pennylane_lightning.lightning_qubit_ops import (
MeasurementsC64,
MeasurementsC128,
)
from pennylane_lightning.lightning_qubit_ops import MeasurementsC64, MeasurementsC128
except ImportError:
pass

Expand Down
4 changes: 1 addition & 3 deletions tests/lightning_qubit/test_adjoint_jacobian_class.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,7 @@
from pennylane.tape import QuantumScript
from scipy.stats import unitary_group

from pennylane_lightning.lightning_qubit._adjoint_jacobian import (
LightningAdjointJacobian,
)
from pennylane_lightning.lightning_qubit._adjoint_jacobian import LightningAdjointJacobian
from pennylane_lightning.lightning_qubit._state_vector import LightningStateVector

if not LightningDevice._new_API:
Expand Down
5 changes: 1 addition & 4 deletions tests/lightning_qubit/test_measurements_class.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,10 +26,7 @@
from scipy.sparse import csr_matrix, random_array

try:
from pennylane_lightning.lightning_qubit_ops import (
MeasurementsC64,
MeasurementsC128,
)
from pennylane_lightning.lightning_qubit_ops import MeasurementsC64, MeasurementsC128
except ImportError:
pass

Expand Down
5 changes: 1 addition & 4 deletions tests/test_serialize.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,7 @@
import pytest
from conftest import LightningDevice, device_name

from pennylane_lightning.core._serialize import (
QuantumScriptSerializer,
global_phase_diagonal,
)
from pennylane_lightning.core._serialize import QuantumScriptSerializer, global_phase_diagonal

if not LightningDevice._CPP_BINARY_AVAILABLE:
pytest.skip("No binary module found. Skipping.", allow_module_level=True)
Expand Down
Loading