Skip to content

Commit 4b49ab6

Browse files
authored
Merge pull request #10 from FESOM/fix-packaging
Fix packaging
2 parents aed5929 + a0496ff commit 4b49ab6

File tree

6 files changed

+75
-31
lines changed

6 files changed

+75
-31
lines changed

implicit_filter/jax_filter.py

+3-1
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
from ._jax_function import make_smooth, make_smat, make_smat_full, transform_veloctiy_to_nodes
88
from ._utils import VeryStupidIdeaError, SolverNotConvergedError
99
from implicit_filter.filter import Filter
10-
from scipy.sparse import csc_matrix, identity
10+
from scipy.sparse import csc_matrix, identity, spdiags
1111
from scipy.sparse.linalg import cg
1212

1313

@@ -97,6 +97,8 @@ def _compute(self, n, kl, ttu, tol=1e-6, maxiter=150000) -> np.ndarray:
9797
Smat1 = csc_matrix((self._ss * (1.0 / jnp.square(kl)), (self._ii, self._jj)), shape=(self._n2d, self._n2d))
9898
Smat = identity(self._n2d) + 0.5 * (Smat1 ** n)
9999

100+
# b = Smat.diagonal()
101+
# pre = csc_matrix((b, (np.arange(self._n2d), np.arange(self._n2d))), shape=(self._n2d, self._n2d))
100102
ttw = ttu - Smat @ ttu # Work with perturbations
101103

102104
tts, code = cg(Smat, ttw, tol=tol, maxiter=maxiter)

pyproject.toml

+39-1
Original file line numberDiff line numberDiff line change
@@ -3,4 +3,42 @@ requires = [
33
"setuptools>=42",
44
"wheel"
55
]
6-
build-backend = "setuptools.build_meta"
6+
build-backend = "setuptools.build_meta"
7+
8+
[project]
9+
name = "implicit_filter"
10+
version = "0.1.0"
11+
description = "Python package implementing implicit filtering method on any type of mesh."
12+
readme = "readme.md"
13+
authors = [{ name = "Kacper Nowak", email = "kacper.nowak@awi.de" }]
14+
15+
classifiers = [
16+
"Development Status :: 3 - Alpha",
17+
"Operating System :: OS Independent",
18+
"Programming Language :: Python :: 3",
19+
]
20+
21+
requires-python = ">=3.9,<3.11"
22+
23+
dynamic = ["dependencies"]
24+
[tool.setuptools.dynamic]
25+
dependencies = {file = ["requirements.txt"]}
26+
27+
[project.optional-dependencies]
28+
gpu = [
29+
"cupy"
30+
]
31+
32+
[project.urls]
33+
Homepage = "https://github.com/FESOM/implicit_filter"
34+
35+
[tool.setuptools]
36+
platforms = ["any"]
37+
zip-safe = false
38+
include-package-data = true
39+
40+
[tool.setuptools.packages.find]
41+
where = ["implicit_filter"]
42+
include = ["implicit_filter*"]
43+
44+

readme.md

+26
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,29 @@ For optimal performance usage of Nvidia GPU is highly recommended.
1919

2020
**IO:** Xarray
2121

22+
23+
## Installation
24+
Currently Python version 3.10 and 3.9 are supported. Using newer version can enabled
25+
```shell
26+
source ./path/to/enviroment/of/your/choice
27+
git clone https://github.com/FESOM/implicit_filter
28+
29+
cd implicit_filter
30+
# CPU only installation
31+
pip install -e .
32+
# GPU installation
33+
pip install -e .[gpu]
34+
```
35+
### Known issues
36+
Installing CuPy can cause an error, in case this happens try installing it manually:
37+
38+
```shell
39+
pip install cupy
40+
```
41+
42+
In case it also doesn't work, check your Nvidia driver version using `nvidia-smi` and install
43+
CuPy version matching your drivers.
44+
2245
# Tutorial
2346

2447
Lets start with loading FESOM mesh file and data that we want to filter
@@ -45,6 +68,9 @@ from implicit_filter import CuPyFilter
4568
flter = CuPyFilter()
4669
flter.prepare_from_file(path + "fesom.mesh.diag.nc")
4770
```
71+
JAX warning might appear about GPU not being available, but it should be ignored.
72+
73+
If you don't have GPU support enabled importing CuPyFilter will cause an import error.
4874

4975
Alternatively you can set arrays by yourself, but this is shown in notebooks in examples.
5076

requirements.txt

+3-4
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,8 @@ contourpy==1.0.5
55
cycler==0.11.0
66
fastrlock==0.8
77
fonttools==4.25.0
8-
jax==0.3.25
9-
jaxlib==0.3.25
8+
jax==0.4.25
9+
jaxlib==0.4.25
1010
kiwisolver==1.4.4
1111
matplotlib==3.7.1
1212
munkres==1.1.4
@@ -27,5 +27,4 @@ six==1.16.0
2727
tornado==6.3.2
2828
typing_extensions==4.7.1
2929
wheel==0.38.4
30-
xarray==2023.6.0
31-
cupy==12.1.0
30+
xarray==2023.6.0

setup.cfg

-25
This file was deleted.

setup.py

+4
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
from setuptools import setup
2+
3+
if __name__ == "__main__":
4+
setup()

0 commit comments

Comments
 (0)