diff --git a/docs/lowercase_filter.py b/docs/lowercase_filter.py index e7b3d2f28..142ed1f35 100644 --- a/docs/lowercase_filter.py +++ b/docs/lowercase_filter.py @@ -10,7 +10,7 @@ # copyright notice, and modified files need to carry a notice indicating # that they have been altered from the originals. -""" Implements a Lower Case Filter for Sphinx spelling """ +"""Implements a Lower Case Filter for Sphinx spelling""" from enchant import tokenize diff --git a/qiskit_machine_learning/algorithms/classifiers/__init__.py b/qiskit_machine_learning/algorithms/classifiers/__init__.py index 06fd4f890..0367c179b 100644 --- a/qiskit_machine_learning/algorithms/classifiers/__init__.py +++ b/qiskit_machine_learning/algorithms/classifiers/__init__.py @@ -10,7 +10,7 @@ # copyright notice, and modified files need to carry a notice indicating # that they have been altered from the originals. -""" Classifiers Package """ +"""Classifiers Package""" from .neural_network_classifier import NeuralNetworkClassifier from .qsvc import QSVC diff --git a/qiskit_machine_learning/algorithms/inference/__init__.py b/qiskit_machine_learning/algorithms/inference/__init__.py index 322bb8f1c..8809d6965 100644 --- a/qiskit_machine_learning/algorithms/inference/__init__.py +++ b/qiskit_machine_learning/algorithms/inference/__init__.py @@ -10,7 +10,7 @@ # copyright notice, and modified files need to carry a notice indicating # that they have been altered from the originals. -""" Inference Package """ +"""Inference Package""" from .qbayesian import QBayesian diff --git a/qiskit_machine_learning/algorithms/regressors/__init__.py b/qiskit_machine_learning/algorithms/regressors/__init__.py index 123556e67..3805b09a6 100644 --- a/qiskit_machine_learning/algorithms/regressors/__init__.py +++ b/qiskit_machine_learning/algorithms/regressors/__init__.py @@ -10,7 +10,7 @@ # copyright notice, and modified files need to carry a notice indicating # that they have been altered from the originals. -""" Regressors Package""" +"""Regressors Package""" from .qsvr import QSVR from .neural_network_regressor import NeuralNetworkRegressor diff --git a/qiskit_machine_learning/algorithms/trainable_model.py b/qiskit_machine_learning/algorithms/trainable_model.py index 3b2bace9b..75ee67711 100644 --- a/qiskit_machine_learning/algorithms/trainable_model.py +++ b/qiskit_machine_learning/algorithms/trainable_model.py @@ -1,6 +1,6 @@ # This code is part of a Qiskit project. # -# (C) Copyright IBM 2021, 2024. +# (C) Copyright IBM 2021, 2025. # # This code is licensed under the Apache License, Version 2.0. You may # obtain a copy of this license in the LICENSE.txt file in the root directory @@ -117,7 +117,7 @@ def optimizer(self) -> Optimizer | Minimizer: def optimizer(self, optimizer: Optimizer | Minimizer | None = None): """Sets the optimizer to use in training process.""" if optimizer is None: - optimizer = SLSQP() + optimizer = SLSQP(maxiter=1000) self._optimizer = optimizer @property diff --git a/qiskit_machine_learning/exceptions.py b/qiskit_machine_learning/exceptions.py index ac2befee7..483b00f67 100644 --- a/qiskit_machine_learning/exceptions.py +++ b/qiskit_machine_learning/exceptions.py @@ -10,7 +10,7 @@ # copyright notice, and modified files need to carry a notice indicating # that they have been altered from the originals. -""" Machine Learning Exception """ +"""Machine Learning Exception""" from qiskit.exceptions import QiskitError diff --git a/qiskit_machine_learning/optimizers/optimizer_utils/__init__.py b/qiskit_machine_learning/optimizers/optimizer_utils/__init__.py index 7304b2e3f..58a419370 100644 --- a/qiskit_machine_learning/optimizers/optimizer_utils/__init__.py +++ b/qiskit_machine_learning/optimizers/optimizer_utils/__init__.py @@ -9,7 +9,7 @@ # Any modifications or derivative works of this code must retain this # copyright notice, and modified files need to carry a notice indicating # that they have been altered from the originals. -""" Supplementary tools for optimizers. """ +"""Supplementary tools for optimizers.""" from .learning_rate import LearningRate diff --git a/qiskit_machine_learning/utils/loss_functions/kernel_loss_functions.py b/qiskit_machine_learning/utils/loss_functions/kernel_loss_functions.py index e17b962dd..d1396c00e 100644 --- a/qiskit_machine_learning/utils/loss_functions/kernel_loss_functions.py +++ b/qiskit_machine_learning/utils/loss_functions/kernel_loss_functions.py @@ -10,7 +10,7 @@ # copyright notice, and modified files need to carry a notice indicating # that they have been altered from the originals. -""" Kernel Loss utilities """ +"""Kernel Loss utilities""" from abc import ABC, abstractmethod from typing import Sequence diff --git a/qiskit_machine_learning/utils/loss_functions/loss_functions.py b/qiskit_machine_learning/utils/loss_functions/loss_functions.py index 2d6a8ef1f..159b03db8 100644 --- a/qiskit_machine_learning/utils/loss_functions/loss_functions.py +++ b/qiskit_machine_learning/utils/loss_functions/loss_functions.py @@ -10,7 +10,7 @@ # copyright notice, and modified files need to carry a notice indicating # that they have been altered from the originals. -""" Loss utilities """ +"""Loss utilities""" from abc import ABC, abstractmethod diff --git a/requirements.txt b/requirements.txt index a7e580480..eae5a4de8 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,6 +1,6 @@ qiskit>=1.0,<2.0 numpy>=2.0 -scipy>=1.4,<1.16 +scipy>=1.16 scikit-learn>=1.2 setuptools>=40.1 dill>=0.3.4 diff --git a/test/__init__.py b/test/__init__.py index 3d89bce89..a6da34c1f 100644 --- a/test/__init__.py +++ b/test/__init__.py @@ -10,7 +10,7 @@ # copyright notice, and modified files need to carry a notice indicating # that they have been altered from the originals. -""" ML test packages """ +"""ML test packages""" from .machine_learning_test_case import QiskitMachineLearningTestCase, gpu from .algorithms_test_case import QiskitAlgorithmsTestCase diff --git a/test/algorithms/classifiers/test_fidelity_quantum_kernel_pegasos_qsvc.py b/test/algorithms/classifiers/test_fidelity_quantum_kernel_pegasos_qsvc.py index 5de951b31..9d5112b62 100644 --- a/test/algorithms/classifiers/test_fidelity_quantum_kernel_pegasos_qsvc.py +++ b/test/algorithms/classifiers/test_fidelity_quantum_kernel_pegasos_qsvc.py @@ -10,7 +10,7 @@ # copyright notice, and modified files need to carry a notice indicating # that they have been altered from the originals. -""" Test Pegasos QSVC """ +"""Test Pegasos QSVC""" import os import tempfile import unittest diff --git a/test/algorithms/classifiers/test_neural_network_classifier.py b/test/algorithms/classifiers/test_neural_network_classifier.py index 06062cb19..13417d3c5 100644 --- a/test/algorithms/classifiers/test_neural_network_classifier.py +++ b/test/algorithms/classifiers/test_neural_network_classifier.py @@ -9,7 +9,7 @@ # Any modifications or derivative works of this code must retain this # copyright notice, and modified files need to carry a notice indicating # that they have been altered from the originals. -""" Test Neural Network Classifier """ +"""Test Neural Network Classifier""" from __future__ import annotations import itertools @@ -379,7 +379,7 @@ def test_save_load(self, qnn_type): raise ValueError(f"Unsupported QNN type: {qnn_type}") classifier = self._create_classifier( - qnn, num_parameters=num_parameters, optimizer=COBYLA(), loss="squared_error" + qnn, num_parameters=num_parameters, optimizer=COBYLA(maxiter=25), loss="squared_error" ) classifier.fit(features, labels) diff --git a/test/algorithms/classifiers/test_pegasos_qsvc.py b/test/algorithms/classifiers/test_pegasos_qsvc.py index 7d8e02756..1764e0aae 100644 --- a/test/algorithms/classifiers/test_pegasos_qsvc.py +++ b/test/algorithms/classifiers/test_pegasos_qsvc.py @@ -10,7 +10,7 @@ # copyright notice, and modified files need to carry a notice indicating # that they have been altered from the originals. -""" Test Pegasos QSVC """ +"""Test Pegasos QSVC""" import os import tempfile import unittest diff --git a/test/algorithms/classifiers/test_qsvc.py b/test/algorithms/classifiers/test_qsvc.py index ecbc2abb2..926d28c34 100644 --- a/test/algorithms/classifiers/test_qsvc.py +++ b/test/algorithms/classifiers/test_qsvc.py @@ -10,7 +10,7 @@ # copyright notice, and modified files need to carry a notice indicating # that they have been altered from the originals. -""" Test QSVC """ +"""Test QSVC""" import os import tempfile import unittest diff --git a/test/algorithms/classifiers/test_vqc.py b/test/algorithms/classifiers/test_vqc.py index 5f8c63445..d93ccb518 100644 --- a/test/algorithms/classifiers/test_vqc.py +++ b/test/algorithms/classifiers/test_vqc.py @@ -10,7 +10,7 @@ # copyright notice, and modified files need to carry a notice indicating # that they have been altered from the originals. -""" Test Neural Network Classifier """ +"""Test Neural Network Classifier""" from __future__ import annotations diff --git a/test/algorithms/inference/test_qbayesian.py b/test/algorithms/inference/test_qbayesian.py index 7409d857e..5c874c832 100644 --- a/test/algorithms/inference/test_qbayesian.py +++ b/test/algorithms/inference/test_qbayesian.py @@ -10,7 +10,7 @@ # copyright notice, and modified files need to carry a notice indicating # that they have been altered from the originals. -""" Test Quantum Bayesian Inference """ +"""Test Quantum Bayesian Inference""" import unittest from test import QiskitMachineLearningTestCase diff --git a/test/algorithms/regressors/test_neural_network_regressor.py b/test/algorithms/regressors/test_neural_network_regressor.py index 8e71203eb..62cfdffe5 100644 --- a/test/algorithms/regressors/test_neural_network_regressor.py +++ b/test/algorithms/regressors/test_neural_network_regressor.py @@ -9,7 +9,7 @@ # Any modifications or derivative works of this code must retain this # copyright notice, and modified files need to carry a notice indicating # that they have been altered from the originals. -""" Test Neural Network Regressor """ +"""Test Neural Network Regressor""" from __future__ import annotations import itertools @@ -179,7 +179,7 @@ def test_save_load(self): input_params=feature_map.parameters, weight_params=ansatz.parameters, ) - regressor = NeuralNetworkRegressor(qnn, optimizer=COBYLA()) + regressor = NeuralNetworkRegressor(qnn, optimizer=COBYLA(maxiter=25)) regressor.fit(features, labels) # predicted labels from the newly trained model diff --git a/test/algorithms/regressors/test_vqr.py b/test/algorithms/regressors/test_vqr.py index 6c66fba44..5c87d0bb3 100644 --- a/test/algorithms/regressors/test_vqr.py +++ b/test/algorithms/regressors/test_vqr.py @@ -9,7 +9,7 @@ # Any modifications or derivative works of this code must retain this # copyright notice, and modified files need to carry a notice indicating # that they have been altered from the originals. -""" Test Neural Network Regressor with EstimatorQNN.""" +"""Test Neural Network Regressor with EstimatorQNN.""" import unittest from test import QiskitMachineLearningTestCase diff --git a/test/datasets/__init__.py b/test/datasets/__init__.py index aa2f128b2..5c8a5f732 100644 --- a/test/datasets/__init__.py +++ b/test/datasets/__init__.py @@ -10,4 +10,4 @@ # copyright notice, and modified files need to carry a notice indicating # that they have been altered from the originals. -""" Test datasets module """ +"""Test datasets module""" diff --git a/test/datasets/test_ad_hoc_data.py b/test/datasets/test_ad_hoc_data.py index 448984726..4dcfcb462 100644 --- a/test/datasets/test_ad_hoc_data.py +++ b/test/datasets/test_ad_hoc_data.py @@ -10,7 +10,7 @@ # copyright notice, and modified files need to carry a notice indicating # that they have been altered from the originals. -""" Test Ad Hoc Data """ +"""Test Ad Hoc Data""" from test import QiskitMachineLearningTestCase diff --git a/test/gradients/test_estimator_gradient.py b/test/gradients/test_estimator_gradient.py index a36e39de7..54d6581bd 100644 --- a/test/gradients/test_estimator_gradient.py +++ b/test/gradients/test_estimator_gradient.py @@ -31,13 +31,14 @@ from qiskit_ibm_runtime import Session, EstimatorV2 from qiskit_ibm_runtime.options import EstimatorOptions, SimulatorOptions +from logging_primitives import LoggingEstimator + from qiskit_machine_learning.gradients import ( LinCombEstimatorGradient, ParamShiftEstimatorGradient, SPSAEstimatorGradient, ) -from .logging_primitives import LoggingEstimator gradient_factories = [ ParamShiftEstimatorGradient, diff --git a/test/gradients/test_sampler_gradient.py b/test/gradients/test_sampler_gradient.py index f5149b0eb..61d0b5d0b 100644 --- a/test/gradients/test_sampler_gradient.py +++ b/test/gradients/test_sampler_gradient.py @@ -30,13 +30,14 @@ from qiskit_ibm_runtime import Session, SamplerV2 +from logging_primitives import LoggingSampler + from qiskit_machine_learning.gradients import ( LinCombSamplerGradient, ParamShiftSamplerGradient, SPSASamplerGradient, ) -from .logging_primitives import LoggingSampler gradient_factories = [ ParamShiftSamplerGradient, diff --git a/test/kernels/algorithms/test_fidelity_qkernel_trainer.py b/test/kernels/algorithms/test_fidelity_qkernel_trainer.py index 9243d351d..2d3f0aecd 100644 --- a/test/kernels/algorithms/test_fidelity_qkernel_trainer.py +++ b/test/kernels/algorithms/test_fidelity_qkernel_trainer.py @@ -10,7 +10,7 @@ # copyright notice, and modified files need to carry a notice indicating # that they have been altered from the originals. -""" Test QuantumKernelTrainer """ +"""Test QuantumKernelTrainer""" from __future__ import annotations import unittest diff --git a/test/kernels/test_trainable_fidelity_qkernel.py b/test/kernels/test_trainable_fidelity_qkernel.py index 516270e02..b1eb92f0a 100644 --- a/test/kernels/test_trainable_fidelity_qkernel.py +++ b/test/kernels/test_trainable_fidelity_qkernel.py @@ -9,7 +9,7 @@ # Any modifications or derivative works of this code must retain this # copyright notice, and modified files need to carry a notice indicating # that they have been altered from the originals. -""" Test trainable quantum kernels using primitives """ +"""Test trainable quantum kernels using primitives""" import itertools import unittest diff --git a/test/neural_networks/test_effective_dimension.py b/test/neural_networks/test_effective_dimension.py index 6d61f74d5..7971ab995 100644 --- a/test/neural_networks/test_effective_dimension.py +++ b/test/neural_networks/test_effective_dimension.py @@ -9,7 +9,7 @@ # Any modifications or derivative works of this code must retain this # copyright notice, and modified files need to carry a notice indicating # that they have been altered from the originals. -""" Unit Tests for Effective Dimension Algorithm """ +"""Unit Tests for Effective Dimension Algorithm""" import unittest diff --git a/test/neural_networks/test_estimator_qnn_v1.py b/test/neural_networks/test_estimator_qnn_v1.py index ff6853cde..f6baaa4a3 100644 --- a/test/neural_networks/test_estimator_qnn_v1.py +++ b/test/neural_networks/test_estimator_qnn_v1.py @@ -10,7 +10,7 @@ # copyright notice, and modified files need to carry a notice indicating # that they have been altered from the originals. -""" Test EstimatorQNN """ +"""Test EstimatorQNN""" import unittest diff --git a/test/neural_networks/test_estimator_qnn_v2.py b/test/neural_networks/test_estimator_qnn_v2.py index 646db1ea1..5d81b41be 100644 --- a/test/neural_networks/test_estimator_qnn_v2.py +++ b/test/neural_networks/test_estimator_qnn_v2.py @@ -10,7 +10,7 @@ # copyright notice, and modified files need to carry a notice indicating # that they have been altered from the originals. -""" Test EstimatorQNN """ +"""Test EstimatorQNN""" import unittest diff --git a/test/optimizers/test_optimizers.py b/test/optimizers/test_optimizers.py index df253cd5d..023338edd 100644 --- a/test/optimizers/test_optimizers.py +++ b/test/optimizers/test_optimizers.py @@ -72,7 +72,7 @@ def run_optimizer( grad: Whether to pass the gradient function as input. bounds: Optimizer bounds. """ - x_0 = np.asarray([1.3, 0.7, 0.8, 1.9, 1.2]) + x_0 = np.asarray([1.13, 0.7, 0.8, 1.9, 1.2]) jac = rosen_der if grad else None res = optimizer.minimize(rosen, x_0, jac, bounds) diff --git a/tools/check_copyright.py b/tools/check_copyright.py index 6085e0a17..919d68acf 100644 --- a/tools/check_copyright.py +++ b/tools/check_copyright.py @@ -10,7 +10,7 @@ # copyright notice, and modified files need to carry a notice indicating # that they have been altered from the originals. -""" Fix copyright year in header """ +"""Fix copyright year in header""" from typing import Tuple, Union, List import builtins diff --git a/tools/extract_deprecation.py b/tools/extract_deprecation.py index 5a61d982b..ac902c309 100644 --- a/tools/extract_deprecation.py +++ b/tools/extract_deprecation.py @@ -10,7 +10,7 @@ # copyright notice, and modified files need to carry a notice indicating # that they have been altered from the originals. -""" Extract deprecation messages from input """ +"""Extract deprecation messages from input""" from typing import List import sys diff --git a/tools/generate_spell_dict.py b/tools/generate_spell_dict.py index e20d1eec2..dc484e918 100644 --- a/tools/generate_spell_dict.py +++ b/tools/generate_spell_dict.py @@ -10,7 +10,7 @@ # copyright notice, and modified files need to carry a notice indicating # that they have been altered from the originals. -""" Generates spelling dictionaries for Sphinx and Pylint and combine them. """ +"""Generates spelling dictionaries for Sphinx and Pylint and combine them.""" from typing import Set, List import sys