Skip to content
This repository has been archived by the owner on Dec 7, 2021. It is now read-only.

Commit

Permalink
Merge branch 'master' into move_dds_to_rfcs
Browse files Browse the repository at this point in the history
  • Loading branch information
manoelmarques authored Jan 23, 2020
2 parents 6bff10b + 2cccdd9 commit 872d366
Show file tree
Hide file tree
Showing 11 changed files with 303 additions and 202 deletions.
90 changes: 67 additions & 23 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ os: linux
dist: xenial

language: python
python: 3.6
python: 3.7

env:
global:
Expand All @@ -30,7 +30,8 @@ env:

stage_dependencies: &stage_dependencies
before_install:
- pip install -U pip setuptools wheel
- pip install -U 'pip<20.0.0'
- pip install -U setuptools wheel
- |
if [ -f $INIT_FILE ]; then
# stops travis if __init__.py exists under qiskit
Expand Down Expand Up @@ -66,21 +67,16 @@ stage_dependencies: &stage_dependencies
# back to current repo directory
cd $TRAVIS_BUILD_DIR
fi
# install Aqua and Aqua dev. requirements
- pip install -e $TRAVIS_BUILD_DIR --progress-bar off
- pip install -U -c constraints.txt -r requirements-dev.txt --progress-bar off

stage_test: &stage_test
<<: *stage_dependencies
before_script:
- |
if [ ! "$(ls -A .stestr)" ]; then
rm -rf .stestr
fi
- export PYTHON="coverage run --source qiskit/aqua,qiskit/chemistry,qiskit/finance,qiskit/ml,qiskit/optimization --omit */gauopen/* --parallel-mode"
# install Aqua and Aqua dev. requirements
- pip install -e $TRAVIS_BUILD_DIR --progress-bar off
- pip install -U -c constraints.txt -r requirements-dev.txt --progress-bar off

stage_test_aqua: &stage_test_aqua
<<: *stage_test
<<: *stage_dependencies
install:
- |
cat > selection.txt <<EOF
Expand Down Expand Up @@ -119,31 +115,44 @@ jobs:
<<: *stage_dependencies
name: "Spell, Style, Lint, Docs check"
if: tag IS blank
python: 3.7
install:
# install spell check libraries
- sudo apt-get -y install python3-enchant
- sudo apt-get -y install hunspell-en-us
- pip install pyenchant
script: make spell && make style && make lint && make html SPHINXOPTS=-W
- name: "Test Aqua 1"
- name: "Test Aqua 1 Python 3.7"
<<: *stage_test_aqua
if: tag IS blank
workspaces:
create:
name: aqua1
paths: aqua1.dat
before_script:
- export PYTHON="coverage run --source qiskit/aqua,qiskit/chemistry,qiskit/finance,qiskit/ml,qiskit/optimization --omit */gauopen/* --parallel-mode"
script: stestr --test-path test/aqua run --blacklist-file selection.txt && coverage combine && mv .coverage aqua1.dat
- name: "Test Aqua 2"
- name: "Test Aqua 1 Python 3.8"
<<: *stage_test_aqua
if: tag IS blank
python: 3.8
script: stestr --test-path test/aqua run --blacklist-file selection.txt
- name: "Test Aqua 2 Python 3.7"
<<: *stage_test_aqua
if: tag IS blank
workspaces:
create:
name: aqua2
paths: aqua2.dat
before_script:
- export PYTHON="coverage run --source qiskit/aqua,qiskit/chemistry,qiskit/finance,qiskit/ml,qiskit/optimization --omit */gauopen/* --parallel-mode"
script: stestr --test-path test/aqua run --whitelist-file selection.txt && coverage combine && mv .coverage aqua2.dat
- name: "Test Chemistry"
<<: *stage_test
- name: "Test Aqua 2 Python 3.8"
<<: *stage_test_aqua
if: tag IS blank
python: 3.8
script: stestr --test-path test/aqua run --whitelist-file selection.txt
- name: "Test Chemistry Python 3.7"
<<: *stage_dependencies
if: tag IS blank
env: OPENBLAS_NUM_THREADS=1
workspaces:
Expand All @@ -156,33 +165,68 @@ jobs:
- unzip /tmp/pyquante2.zip -d /tmp/
# Install local PyQuante
- pip install -e /tmp/pyquante2-master --progress-bar off
before_script:
- export PYTHON="coverage run --source qiskit/aqua,qiskit/chemistry,qiskit/finance,qiskit/ml,qiskit/optimization --omit */gauopen/* --parallel-mode"
script: stestr --test-path test/chemistry run && coverage combine && mv .coverage chemistry.dat
- name: "Test Finance"
<<: *stage_test
- name: "Test Chemistry Python 3.8"
<<: *stage_dependencies
if: tag IS blank
python: 3.8
env: OPENBLAS_NUM_THREADS=1
install:
# download PyQuante master and unzip it
- wget https://codeload.github.com/rpmuller/pyquante2/zip/master -O /tmp/pyquante2.zip
- unzip /tmp/pyquante2.zip -d /tmp/
# Install local PyQuante
- pip install -e /tmp/pyquante2-master --progress-bar off
script: stestr --test-path test/chemistry run
- name: "Test Finance Python 3.7"
<<: *stage_dependencies
if: tag IS blank
workspaces:
create:
name: finance
paths: finance.dat
before_script:
- export PYTHON="coverage run --source qiskit/aqua,qiskit/chemistry,qiskit/finance,qiskit/ml,qiskit/optimization --omit */gauopen/* --parallel-mode"
script: stestr --test-path test/finance run && coverage combine && mv .coverage finance.dat
- name: "Test Machine Learning"
<<: *stage_test
- name: "Test Finance Python 3.8"
<<: *stage_dependencies
if: tag IS blank
python: 3.8
script: stestr --test-path test/finance run
- name: "Test Machine Learning Python 3.7"
<<: *stage_dependencies
if: tag IS blank
workspaces:
create:
name: ml
paths: ml.dat
before_script:
- export PYTHON="coverage run --source qiskit/aqua,qiskit/chemistry,qiskit/finance,qiskit/ml,qiskit/optimization --omit */gauopen/* --parallel-mode"
script: stestr --test-path test/ml run && coverage combine && mv .coverage ml.dat
- name: "Test Optimization"
<<: *stage_test
- name: "Test Machine Learning Python 3.8"
<<: *stage_dependencies
if: tag IS blank
python: 3.8
script: stestr --test-path test/ml run
- name: "Test Optimization Python 3.7"
<<: *stage_dependencies
if: tag IS blank
workspaces:
create:
name: optimization
paths: optimization.dat
before_script:
- export PYTHON="coverage run --source qiskit/aqua,qiskit/chemistry,qiskit/finance,qiskit/ml,qiskit/optimization --omit */gauopen/* --parallel-mode"
script: stestr --test-path test/optimization run && coverage combine && mv .coverage optimization.dat
- name: "Test Optimization Python 3.8"
<<: *stage_dependencies
if: tag IS blank
python: 3.8
script: stestr --test-path test/optimization run
- stage: Coverage
name: "Combine all coverages and report"
name: "Combine all coverages and upload to Coveralls"
if: tag IS blank
workspaces:
use:
Expand Down
8 changes: 8 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,13 @@ Changed

- Remove declarative api (#758) (#759) (#760) (#762) (#763)

Deprecated
----------

- Python 3.5 support in qiskit-aqua is deprecated. Support will be
removed on the upstream python community's end of life date for the version,
which is 09/13/2020.

[0.6.2](https://github.com/Qiskit/qiskit-aqua/compare/0.6.1...0.6.2) - 2019-12-17
=================================================================================

Expand Down Expand Up @@ -70,6 +77,7 @@ Removed

- The `CircuitCache` class is removed, use parameterized circuits as an alternative. (#693)


[0.6.1](https://github.com/Qiskit/qiskit-aqua/compare/0.6.0...0.6.1) - 2019-10-16
=================================================================================

Expand Down
41 changes: 28 additions & 13 deletions qiskit/aqua/utils/qp_solver.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

# This code is part of Qiskit.
#
# (C) Copyright IBM 2018, 2019.
# (C) Copyright IBM 2018, 2020.
#
# 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
Expand All @@ -14,35 +14,50 @@

""" qp solver """

from typing import Optional, Tuple
import logging

import numpy as np
from cvxopt import matrix, solvers

logger = logging.getLogger(__name__)

_HAS_CVXOPT = False
try:
from cvxopt import matrix, solvers
_HAS_CVXOPT = True
except ImportError:
logger.info('CVXOPT is not installed. See http://cvxopt.org/install/index.html')


def optimize_svm(kernel_matrix, y, scaling=None, max_iters=500, show_progress=False):
def optimize_svm(kernel_matrix: np.ndarray,
y: np.ndarray,
scaling: Optional[float] = None,
max_iters: int = 500,
show_progress: bool = False) -> Tuple[np.ndarray, np.ndarray, np.ndarray]:
"""
Solving quadratic programming problem for SVM; thus, some constraints are fixed.
The notation is follows the equation here:
http://cvxopt.org/userguide/coneprog.html#quadratic-programming
Args:
kernel_matrix (numpy.ndarray): NxN array
y (numpy.ndarray): Nx1 array
scaling (float): the scaling factor to renormalize the `y`, if it is None,
use L2-norm of `y` for normalization
max_iters (int): number of iterations for QP solver
show_progress (bool): showing the progress of QP solver
kernel_matrix: NxN array
y: Nx1 array
scaling: the scaling factor to renormalize the `y`, if it is None,
use L2-norm of `y` for normalization
max_iters: number of iterations for QP solver
show_progress: showing the progress of QP solver
Returns:
numpy.ndarray: Sx1 array, where S is the number of supports
numpy.ndarray: Sx1 array, where S is the number of supports
numpy.ndarray: Sx1 array, where S is the number of supports
np.ndarray: Sx1 array, where S is the number of supports
np.ndarray: Sx1 array, where S is the number of supports
np.ndarray: Sx1 array, where S is the number of supports
Raises:
NameError: CVXOPT not installed.
"""
# pylint: disable=invalid-name
if not _HAS_CVXOPT:
raise NameError('CVXOPT is not installed. See http://cvxopt.org/install/index.html')
if y.ndim == 1:
y = y[:, np.newaxis]
H = np.outer(y, y) * kernel_matrix
Expand Down
2 changes: 1 addition & 1 deletion requirements-dev.txt
Original file line number Diff line number Diff line change
Expand Up @@ -13,4 +13,4 @@ reno>=2.11.0
matplotlib>=2.1
stestr>=2.5.0
coverage>=4.4.0
torch; sys_platform != 'win32'
torch; sys_platform == 'linux' or (python_version < '3.8' and sys_platform != 'win32')
4 changes: 2 additions & 2 deletions requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,12 @@ sympy>=1.3
numpy>=1.13
psutil>=5
scikit-learn>=0.20.0
cvxopt
cvxopt; python_version < '3.8' or sys_platform != 'win32'
dlx
docplex
fastdtw
quandl
setuptools>=40.1.0
h5py
networkx>=2.2
pyscf; sys_platform != 'win32'
pyscf; sys_platform == 'linux' or (python_version < '3.8' and sys_platform != 'win32')
10 changes: 6 additions & 4 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

# This code is part of Qiskit.
#
# (C) Copyright IBM 2018, 2019.
# (C) Copyright IBM 2018, 2020.
#
# 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
Expand Down Expand Up @@ -32,15 +32,15 @@
"numpy>=1.13",
"psutil>=5",
"scikit-learn>=0.20.0",
"cvxopt",
"cvxopt; python_version < '3.8' or sys_platform != 'win32'",
"dlx",
"docplex",
"fastdtw",
"quandl",
"setuptools>=40.1.0",
"h5py",
"networkx>=2.2",
"pyscf; sys_platform != 'win32'",
"pyscf; sys_platform == 'linux' or (python_version < '3.8' and sys_platform != 'win32')",
]

if not hasattr(setuptools, 'find_namespace_packages') or not inspect.ismethod(setuptools.find_namespace_packages):
Expand Down Expand Up @@ -70,9 +70,11 @@
"Operating System :: Microsoft :: Windows",
"Operating System :: MacOS",
"Operating System :: POSIX :: Linux",
"Programming Language :: Python :: 3 :: Only",
"Programming Language :: Python :: 3.5",
"Programming Language :: Python :: 3.6",
"Programming Language :: Python :: 3.7",
"Programming Language :: Python :: 3.8",
"Topic :: Scientific/Engineering"
),
keywords='qiskit sdk quantum aqua',
Expand All @@ -81,7 +83,7 @@
include_package_data=True,
python_requires=">=3.5",
extras_require={
'torch': ["torch; sys_platform != 'win32'"],
'torch': ["torch; sys_platform == 'linux' or (python_version < '3.8' and sys_platform != 'win32')"],
},
zip_safe=False
)
Loading

0 comments on commit 872d366

Please sign in to comment.