Skip to content

Commit

Permalink
Initial setup of testing, requirements, and add JAX Array class (#10)
Browse files Browse the repository at this point in the history
Co-authored-by: Kento Ueda <38037695+to24toro@users.noreply.github.com>
  • Loading branch information
DanPuzzuoli and to24toro committed Mar 16, 2023
1 parent 2f0e1d2 commit 791d079
Show file tree
Hide file tree
Showing 8 changed files with 33 additions and 26 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/main.yml
Expand Up @@ -10,8 +10,8 @@ jobs:
runs-on: ${{ matrix.os }}
strategy:
matrix:
python-version: [3.8]
os: ["ubuntu-latest"]
python-version: ['3.8', '3.9', '3.10', '3.11']
os: ["ubuntu-latest", "macOS-latest", "windows-latest"]
steps:
- uses: actions/checkout@v2
- name: Set up Python ${{ matrix.python-version }}
Expand Down
2 changes: 1 addition & 1 deletion arraylias/alias.py
Expand Up @@ -44,7 +44,7 @@ def __init__(self):
# Set of registered library names for dispatching
# Note that we use a dict instead of a set so that the order backends
# are registered will be preserved.
self._libs = dict()
self._libs = {}

# Map of library types to library names for dispatching
self._types = {}
Expand Down
2 changes: 1 addition & 1 deletion arraylias/numpy_alias/register_jax.py
Expand Up @@ -26,7 +26,7 @@ def register_jax(alias):
lib = "jax"

# pylint: disable = invalid-name
JAX_TYPES = (DeviceArray, Tracer)
JAX_TYPES = (DeviceArray, Tracer, jax.Array)

# Register jax types
for atype in JAX_TYPES:
Expand Down
12 changes: 5 additions & 7 deletions arraylias/version.py
Expand Up @@ -25,19 +25,17 @@ def _minimal_ext_cmd(cmd):
env["LANGUAGE"] = "C"
env["LANG"] = "C"
env["LC_ALL"] = "C"
proc = subprocess.Popen(
with subprocess.Popen(
cmd,
stdout=subprocess.PIPE,
stderr=subprocess.PIPE,
env=env,
cwd=os.path.join(os.path.dirname(ROOT_DIR)),
)
stdout, stderr = proc.communicate()
) as proc:
stdout, stderr = proc.communicate()
if proc.returncode > 0:
raise OSError(
"Command {} exited with code {}: {}".format(
cmd, proc.returncode, stderr.strip().decode("ascii")
)
f"Command {cmd} exited with code {proc.returncode}: {stderr.strip().decode('ascii')}"
)
return stdout

Expand All @@ -54,7 +52,7 @@ def git_version():
return git_revision


with open(os.path.join(ROOT_DIR, "VERSION.txt"), "r") as version_file:
with open(os.path.join(ROOT_DIR, "VERSION.txt"), "r", encoding="utf-8") as version_file:
VERSION = version_file.read().strip()


Expand Down
Empty file added constraints.txt
Empty file.
16 changes: 10 additions & 6 deletions requirements-dev.txt
@@ -1,15 +1,19 @@
black~=22.0
stestr>=3.0.0
astroid==2.5
pylint==2.7.1
Sphinx>=3.0.0
astroid==2.9.3
pylint==2.12.2
qiskit-sphinx-theme>=1.6
sphinx-autodoc-typehints
jupyter-sphinx
pygments>=2.4
reno>=3.4.0
numpy
scipy
jax
jaxlib
tensorflow

# JAX not on Windows
jax; sys_platform == 'darwin' or sys_platform == 'linux'
jaxlib; sys_platform == 'darwin' or sys_platform == 'linux'

# Tensorflow does not yet have a 3.11 version
tensorflow; (sys_platform != 'darwin' or platform_machine != 'arm64') and python_version<'3.11'
tensorflow-macos; sys_platform == 'darwin' and platform_machine == 'arm64' and python_version<'3.11'
2 changes: 1 addition & 1 deletion setup.py
Expand Up @@ -48,10 +48,10 @@
"Operating System :: MacOS",
"Operating System :: POSIX :: Linux",
"Programming Language :: Python :: 3 :: Only",
"Programming Language :: Python :: 3.7",
"Programming Language :: Python :: 3.8",
"Programming Language :: Python :: 3.9",
"Programming Language :: Python :: 3.10",
"Programming Language :: Python :: 3.11",
"Topic :: Scientific/Engineering",
],
keywords="array dispatcher qiskit numpy jax tensorflow",
Expand Down
21 changes: 13 additions & 8 deletions tox.ini
@@ -1,27 +1,32 @@
[tox]
minversion = 2.1
envlist = py310,py39,py38,py37,py36,lint
skipsdist = True
minversion = 3.3.0
envlist = py38,py39,py310,py311,lint
isolated_build = true

[testenv]
usedevelop = True
install_command = pip install -U {opts} {packages}
install_command = pip install -c{toxinidir}/constraints.txt -U {opts} {packages}
setenv =
VIRTUAL_ENV={envdir}
deps =
-r{toxinidir}/requirements-dev.txt
QISKIT_SUPPRESS_PACKAGING_WARNINGS=Y
deps = -r{toxinidir}/requirements-dev.txt
commands = stestr run {posargs}

[testenv:lint]
envdir = .tox/lint
deps =
-r{toxinidir}/requirements-dev.txt
commands =
black --check {posargs} arraylias test
pylint -rn --rcfile={toxinidir}/.pylintrc arraylias/ test/
pylint -rn -j 0 --rcfile={toxinidir}/.pylintrc arraylias/ test/

[testenv:black]
deps = black
commands = black {posargs} arraylias test


[testenv:docs]
deps =
-r{toxinidir}/requirements-dev.txt
commands =
sphinx-build -b html -W {posargs} docs/ docs/_build/html

Expand Down

0 comments on commit 791d079

Please sign in to comment.