Skip to content

Commit

Permalink
Renew CI and update to python3.10
Browse files Browse the repository at this point in the history
  • Loading branch information
gefux committed Jun 21, 2024
1 parent d0116b8 commit 7a49701
Show file tree
Hide file tree
Showing 17 changed files with 124 additions and 180 deletions.
20 changes: 0 additions & 20 deletions .circleci/config.yml

This file was deleted.

49 changes: 49 additions & 0 deletions .github/workflows/python-package-pypi.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
name: PyPI

on:
release:
types: [published]

permissions:
contents: read

jobs:

release-build:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v4

- uses: actions/setup-python@v5
with:
python-version: "3.10"

- name: install packages
run: pip install build twine
- name: build release package
run: python -m build

- name: upload windows dists
uses: actions/upload-artifact@v4
with:
name: release-dists
path: dist/

pypi-publish:
environment: publish
runs-on: ubuntu-latest
needs:
- release-build
permissions:
id-token: write

steps:
- name: Retrieve release distributions
uses: actions/download-artifact@v4
with:
name: release-dists
path: dist/

- name: Publish release distributions to PyPI
uses: pypa/gh-action-pypi-publish@release/v1
26 changes: 26 additions & 0 deletions .github/workflows/python-package-tests.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
name: tests

on: [push, workflow_dispatch]

jobs:
tests:

runs-on: ubuntu-latest
strategy:
matrix:
python: ["3.10"]

steps:
- uses: actions/checkout@v4
- name: Setup Python
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python }}
- name: Install tox
run: pip install tox
- name: Run tox
run: tox
- name: Upload coverage reports to Codecov
uses: codecov/codecov-action@v4.0.1
with:
token: ${{ secrets.CODECOV_TOKEN }}
26 changes: 0 additions & 26 deletions .github/workflows/pythonpublish.yml

This file was deleted.

2 changes: 1 addition & 1 deletion .readthedocs.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,6 @@ sphinx:
configuration: docs/conf.py

python:
version: 3.6
version: 3.10
install:
- requirements: requirements_ci.txt
12 changes: 0 additions & 12 deletions .travis.yml

This file was deleted.

31 changes: 14 additions & 17 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -103,8 +103,6 @@ resource. After initialising a new repository in an empty directory with `git in
```bash
$ #if you use ssh:
$ git remote add upstream git@github.com:tempoCollaboration/OQuPy.git
$ #if you use https
$ git remote add upstream https://github.com/tempoCollaboration/OQuPy.git

$ git fetch upstream
$ git checkout main
Expand All @@ -121,7 +119,7 @@ $ git push origin main
```

### 4. Setup your local environment
As a development environment you will need `git`, `python3.6`, `pip3` and `tox`
As a development environment you will need `git`, `python3.10`, `pip3` and `tox`
installed.

You need `git` to
Expand All @@ -130,7 +128,7 @@ changes to the repository, while `tox` allows you to run tests on the package
in an virtual environment (to avoid that the result of the tests depends on the
local setup). If you are unfamiliar with `git`,
[this](https://swcarpentry.github.io/git-novice/) is a good place to start
learning about it. Currently the code is tested against `python3.6`, which makes it
learning about it. Currently the code is tested against `python3.10`, which makes it
necessary to have this version of the python interpreter installed in the
development environment.

Expand Down Expand Up @@ -176,8 +174,6 @@ added to the project, namely:

* execute the tests that check the functionality of the package (with `pytest`)
* test the coding style (with `pylint`)
* check that the documentation can be generated (with `sphinx`)


#### 7.1 test all
You can run all three tests by simply running `tox` in your local clone of the repository:
Expand All @@ -187,20 +183,19 @@ $ tox
This performs a bunch of tests. If they all pass, it will finish with something
like:
```bash
py36: commands succeeded
style: commands succeeded
docs: commands succeeded
congratulations :)
pytest: OK (136.95=setup[30.37]+cmd[106.58] seconds)
pylint: OK (51.52=setup[25.93]+cmd[25.59] seconds)
congratulations :) (188.56 seconds)
```

#### 7.2 test pytest only
You can run the pytests on python3.6 with:
You can run the pytests on python3.10 with:
```bash
$ tox -e py36
$ tox -e pytest
```
or you can pick a specific test in `./tests` to run with:
```bash
$ tox -e py36 coverage/api_test.py
$ tox -e pytest coverage/api_test.py
```
Here `coverage/api_test.py` is the path of the test file *relative to the tests
directory* and the command must be run from the *base directory of the repository.*
Expand All @@ -209,18 +204,20 @@ directory* and the command must be run from the *base directory of the repositor
This checks the code [code style](https://www.python.org/dev/peps/pep-0008/)
with pylint:
```bash
$ tox -e style
$ tox -e pylint
```
or you can check the style of a specific file in `./oqupy` with:
```bash
$ tox -e style base_api.py
$ tox -e pylint base_api.py
```
where `base_api.py` is the path of the file *relative to the oqupy
directory* and again this command must be run from the base directory
of the repository.
[comment]: # (The reason for this is that tox prepends the path you pass as an argument with './oqupy/' when using the style command, and './tests/' when using the py36 command)
[comment]: # (The reason for this is that tox prepends the path you pass as an
argument with './oqupy/' when using the style command, and './tests/' when
using the py36 command)

#### 7.4 test sphinx only
#### 7.4 build the documentation
This invokes a sphinx-build to build the HTML documentation
```bash
$ tox -e docs
Expand Down
9 changes: 3 additions & 6 deletions PULL_REQUEST_TEMPLATE.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

This checklist serves as a guide for contributors and maintainers to assess
whether a contribution can be merged into the main branch and thus serves
to guarantee the quality of the package. Please also read the
to guarantee the quality of the package. Please read the
[contribution guideline](https://github.com/tempoCollaboration/OQuPy/blob/main/CONTRIBUTING.md).

Before you submit a pull request, please go through this checklist once
Expand All @@ -18,13 +18,10 @@ type of your contribution.
* [ ] The automated test are all positive:
- [ ] `tox -e py36` (to run `pytest`) the code tests.
- [ ] `tox -e style` (to run `pylint`) the [code style](https://www.python.org/dev/peps/pep-0008/) tests.
- [ ] `tox -e docs` (to run `sphinx`) generate the documentation.
* [ ] Added test for changed/added code.
* [ ] API code contributions include input checks (defensive code).
* [ ] API code contributions include helpful error messages.
* [ ] The documentation has been updated:
- [ ] docstring for all new functions/methods/classes/modules.
- [ ] consistent style of all docstrings.
- [ ] for new modules: `/docs/pages/modules.rst` has been updated.
- [ ] for api contributions: `/docs/pages/api.rst` has been updated.
- [ ] for api contributions: tutorials and examples have been updated.
- [ ] for new functionality: `/docs/pages/api.rst` has been updated.
- [ ] for new functionality: tutorials and examples have been updated.
2 changes: 1 addition & 1 deletion oqupy/backends/node_array.py
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ def __str__(self) -> Text:

def get_verbose_string(self):
"""Returns a verbose desciption of the NodeArray. """
ret = [self.__str__()]
ret = [str(self)]
ret.append("\n")
ret.append(f" rank = {self.rank}\n")
ret.append(f" len = {len(self)}\n")
Expand Down
2 changes: 1 addition & 1 deletion oqupy/helpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ def plot_correlations_with_parameters(
if parameters.add_correlation_time is None:
add_time = 0.0
infinity = False
elif parameters.add_correlation_time == np.infty:
elif parameters.add_correlation_time == np.inf:
add_time = 0.0
infinity = True
else:
Expand Down
7 changes: 4 additions & 3 deletions oqupy/system_dynamics.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
"""

from typing import List, Optional, Text, Tuple, Union
import warnings

from itertools import product
import numpy as np
Expand Down Expand Up @@ -862,12 +863,12 @@ def compute_correlations_nt(
dt_ = process_tensor.dt
else:
if (process_tensor.dt is not None) and (process_tensor.dt != dt):
UserWarning("Specified time step `dt` does not match `dt` " \
warnings.warn("Specified time step `dt` does not match `dt` " \
+ "stored in the given process tensor " \
+ f"({dt}!={process_tensor.dt}). " \
+ "Using specified `dt`. " \
+ "Don't specify `dt` to use the time step stored in the " \
+ "process tensor.")
+ "process tensor.", UserWarning)
dt_ = dt

#Check that lengths of the ops_order, ops_times and dip_ops lists are equal
Expand All @@ -892,7 +893,7 @@ def compute_correlations_nt(

ret_correlations = np.empty(times_length, dtype=NpDtype)
#This array will contain all correlations
ret_correlations[:] = np.NaN + 1.0j*np.NaN
ret_correlations[:] = np.nan + 1.0j*np.nan


parameters = {
Expand Down
Loading

0 comments on commit 7a49701

Please sign in to comment.