Skip to content

Commit

Permalink
Pipupdate and adjust to new python versions
Browse files Browse the repository at this point in the history
* includes a manual squeeze of the first dimension as np.squeeze changed its behavior (2f44aeb).
* adjustment to change of behavior in numexpr (2d20484).
  • Loading branch information
skuschel authored Nov 24, 2023
2 parents 8081d29 + b95c315 commit de60a34
Show file tree
Hide file tree
Showing 15 changed files with 1,134 additions and 472 deletions.
38 changes: 28 additions & 10 deletions .github/workflows/run-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,42 +6,60 @@ jobs:
latest:
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
python-version: [3.6, 3.7, 3.8, 3.9]
python-version: ["3.9", "3.10", "3.11", "3.12"]

steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v4
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v1
uses: actions/setup-python@v4
with:
python-version: ${{ matrix.python-version }}
- name: Install dependencies
run: |
python -m venv --system-site-packages env
source env/bin/activate
python -m pip install --upgrade pip
pip install -r pip-requirements.txt
python -m pip install -r pip-requirements.txt
python --version
python -c 'import numpy; print(numpy.__version__)'
python -c 'import cython; print(cython.__version__)'
python ./setup.py develop
# python -m pip -vvv install -e .
# fails with "ModuleNotFoundError: No module named 'Cython'"
# running setup.py directly is just a workaround.
- name: run tests
run: |
./run-tests.py
source env/bin/activate
python run-tests.py --skip-setup
other-os:
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [macos-latest, windows-latest]
python-version: [3.8]
python-version: [3.12]

# have to copy steps from above, as anchors are currently
# not supported by github workflow (Jan 2020).
steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v4
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v1
uses: actions/setup-python@v4
with:
python-version: ${{ matrix.python-version }}
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install -r pip-requirements.txt
python -m pip install -r pip-requirements.txt
python --version
python -c 'import numpy; print(numpy.__version__)'
python -c 'import cython; print(cython.__version__)'
python ./setup.py develop
# python -m pip -vvv install -e .
# fails with "ModuleNotFoundError: No module named 'Cython'"
# running setup.py directly is just a workaround.
- name: run tests
run: |
./run-tests.py
python run-tests.py --skip-setup
19 changes: 12 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,26 +26,31 @@ Additionally postpic can plot and label your plot automatically. This makes it e
Installation
------------

Postpic can be used with `python2` and `python3`. However the usage of `python3` is recommended.
Postpic can be used with Python 3 or higher. The use of Python 2 is deprecated and will be removed in the future.

**Users** should install the latest version directly from github using `pip` (python package manager):
1) Always install in a virtualenv. You can create a new virtualenv with:

`pip install --user git+https://github.com/skuschel/postpic.git`
`python -m venv --system-site-packages ~/.venv/defaultpyvenv`

2) activate the environment using `source ~/.venv/defaultpyvenv/bin/activate`.

3) Install into the venv
```
pip install git+https://github.com/skuschel/postpic.git
```

Please note that, depending on your system python setup, `pip` may default to `python2`.
In that case you will need use `pip3` instead to make sure that postpic is installed for `python3`:

`pip3 install --user git+https://github.com/skuschel/postpic.git`
`pip3 install git+https://github.com/skuschel/postpic.git`

The latest *release* is also available in the python package index [pypi](https://pypi.python.org/pypi/postpic/), thus it can be installed by using the python package manager pip:

`pip install --user postpic`

In both cases the `--user` option makes sure that the package can be installed without `root` privileges by installing it into your user profile.

**Developers** should clone the git repository (or their fork of it) and install it using

`pip install --user -e .`
`pip install -e .`

This command will link the current folder to global python scope, such that changing the code will immediately update the installed package.

Expand Down
4 changes: 2 additions & 2 deletions pip-requirements.txt
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
--index-url https://pypi.python.org/simple/

pycodestyle
nose
cython>=0.18
nose2
Cython>=0.18
numpy>=1.8

# required for building the docs
Expand Down
1 change: 1 addition & 0 deletions postpic/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -79,3 +79,4 @@
if __version__ == '0+unknown':
__version__ = __git_version__
del get_versions

6 changes: 3 additions & 3 deletions postpic/_compat/__init__.py
Original file line number Diff line number Diff line change
@@ -1,18 +1,18 @@

from .functions import replacements
import pkg_resources as pr
from packaging.version import parse as parse_version
import numpy

__all__ = []
for repl in replacements:
if pr.parse_version(repl.lib.__version__) < pr.parse_version(repl.minver):
if parse_version(repl.lib.__version__) < parse_version(repl.minver):
vars()[repl.name] = repl.replacement
else:
vars()[repl.name] = getattr(repl.originalmodule, repl.name)

__all__.append(repl.name)

if pr.parse_version(numpy.__version__) < pr.parse_version('1.13'):
if parse_version(numpy.__version__) < parse_version('1.13'):
from .mixins import NDArrayOperatorsMixin
else:
from numpy.lib.mixins import NDArrayOperatorsMixin
Expand Down
3 changes: 1 addition & 2 deletions postpic/_field_calc.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
from __future__ import absolute_import, division, print_function, unicode_literals

import numpy as np
from packaging.version import parse as parse_version
from .helper import PhysicalConstants as pc
from . import helper
from .datahandling import *
Expand Down Expand Up @@ -344,7 +345,6 @@ def _divE1d(self, **kwargs):
return np.gradient(self._Ex(**kwargs))

def _divE2d(self, **kwargs):
from pkg_resources import parse_version
if parse_version(np.__version__) < parse_version('1.11'):
warnings.warn('''
The support for numpy < "1.11" will be dropped in the future. Upgrade!
Expand All @@ -355,7 +355,6 @@ def _divE2d(self, **kwargs):
+ np.gradient(self._Ey(**kwargs), axis=1)

def _divE3d(self, **kwargs):
from pkg_resources import parse_version
if parse_version(np.__version__) < parse_version('1.11'):
warnings.warn('''
The support for numpy < "1.11" will be dropped in the future. Upgrade!
Expand Down
Loading

0 comments on commit de60a34

Please sign in to comment.