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

QAOA compatibility with no dependencies from qiskit-algortithms #634

Open
wants to merge 39 commits into
base: main
Choose a base branch
from
Open
Changes from 1 commit
Commits
Show all changes
39 commits
Select commit Hold shift + click to select a range
d1a232d
Add dependencies from qiskit_algorithms to a separate folder
TolisChal Aug 23, 2024
21f9a23
Add compatibility layer for qaoa
TolisChal Aug 23, 2024
5e08503
Add utils from qiskit-algorithms for qaoa compatibility
TolisChal Aug 23, 2024
b2fd5f6
replace qiskit-algorithm dependencies with internal imports in minimu…
TolisChal Aug 23, 2024
a551027
add and integrate the test of qaoa from qiskit-algorithms
TolisChal Aug 23, 2024
583f111
add rustworkx package in requirements-dev.txt
TolisChal Aug 23, 2024
1251e10
integrate modules from qiskit-algorithms using qiskit-machine_learnin…
TolisChal Aug 27, 2024
ae73011
delete folders algorithms_backend and compat
TolisChal Aug 27, 2024
feef111
remove any reference to backend_algorithms
TolisChal Aug 27, 2024
b3c8c14
fix copyright issues with makefile
TolisChal Sep 2, 2024
ebc88b1
fix mypy errors
TolisChal Sep 2, 2024
19168f5
fix pylint errors
TolisChal Sep 2, 2024
7c87955
add tests from qiskit-qlgorithms for the newly added code
TolisChal Sep 3, 2024
5562a85
fix code style
TolisChal Sep 3, 2024
8f29b25
remove test function test_nlopt
TolisChal Sep 4, 2024
05f1018
remove unused imports
TolisChal Sep 4, 2024
d4055db
fix copyrights in files
TolisChal Sep 4, 2024
0fcd251
remove unused code from exceptions
TolisChal Sep 4, 2024
ed0fb3e
test validation functions properly
TolisChal Sep 4, 2024
665599f
add tests for sampling_vqe
TolisChal Sep 4, 2024
3bfe24b
implement unit-tests for AlgorithmResult class
TolisChal Sep 26, 2024
39a758f
fix errors in unit-tests for AlgorithmResult class
TolisChal Sep 26, 2024
860d774
fix errors in unit-tests for AlgorithmResult class
TolisChal Sep 26, 2024
aaa9da0
fix pylint errors
TolisChal Sep 26, 2024
df5497f
delete unused file
TolisChal Sep 26, 2024
457b46e
fix style and copyright errors
TolisChal Sep 26, 2024
a473905
fix lint errors for the tests that (too-many-positional-arguments) is…
TolisChal Sep 26, 2024
afe5f15
write unit tests for the set_default_batchsize() function
TolisChal Sep 26, 2024
9a20df2
add unit test forObservables Evaluators
TolisChal Sep 26, 2024
38b6ea0
fix errors in observables evaluator unit test
TolisChal Sep 26, 2024
9ca18f6
add new unit tests for member functions of Optimizer class
TolisChal Sep 26, 2024
adaf925
fix spelling errors
TolisChal Sep 26, 2024
31b89db
resolve PR comments
TolisChal Sep 30, 2024
2ecaaae
fix code style
TolisChal Sep 30, 2024
7554c15
disable pylint too-many-positional-arguments error for the lines it p…
TolisChal Oct 23, 2024
b006edc
ignore pylint unknown-option-value message
TolisChal Oct 23, 2024
06d64a9
fix coding style
TolisChal Oct 23, 2024
b7abcbe
Merge branch 'main' into Fix_code_style
TolisChal Oct 25, 2024
4f786d5
Merge branch 'main' into Fix_code_style
t-imamichi Nov 25, 2024
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
65 changes: 65 additions & 0 deletions test/test_algorithm_result.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
# This code is part of a Qiskit project.
#
# (C) Copyright IBM 2019, 2024.
#
# 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
# of this source tree or at http://www.apache.org/licenses/LICENSE-2.0.
#
# 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 AlgorithmResult"""

from test import QiskitAlgorithmsTestCase

from qiskit_optimization.algorithm_result import AlgorithmResult


class TestAlgorithmResult(AlgorithmResult):
"""Concrete subclass for testing purposes"""

def __init__(self, data):
self.data = data
self.name = "Test Result"


class TestAlgorithmResultMethods(QiskitAlgorithmsTestCase):
"""AlgorithmResult tests."""

def setUp(self):
"""Setting up initial test objects"""
self.result1 = TestAlgorithmResult({"value1": 10, "value2": 20})
self.result2 = TestAlgorithmResult({"value1": 100, "value2": 200})
self.result3 = TestAlgorithmResult({"value3": 300})

def test_str_method(self):
"""Test the __str__ method"""
expected_str = "{'data': {'value1': 100, 'value2': 200}, 'name': 'Test Result'}"
self.assertEqual(
self.result1.__str__(), expected_str # pylint: disable=unnecessary-dunder-call
TolisChal marked this conversation as resolved.
Show resolved Hide resolved
)

def test_combine_with_another_result(self):
"""Test the combine method with another result"""
self.result1.combine(self.result2)
self.assertEqual(self.result1.data, {"value1": 100, "value2": 200})
self.assertEqual(self.result1.name, "Test Result")

def test_combine_with_new_property(self):
"""Test combining with a result that has a new property"""
self.result1.combine(self.result3)
self.assertEqual(self.result1.data, {"value3": 300})
self.assertEqual(self.result1.name, "Test Result")

def test_combine_with_none_raises_error(self):
"""Test that passing None to combine raises TypeError"""
with self.assertRaises(TypeError):
self.result1.combine(None)

def test_combine_with_self_does_nothing(self):
"""Test that combining with self doesn't change anything"""
original_data = self.result1.data.copy()
self.result1.combine(self.result1)
self.assertEqual(self.result1.data, original_data)
Loading