Skip to content

Commit f726b12

Browse files
committed
Merge branch 'topic/default/fluidfft-get-methods' into 'branch/default'
Topic/default/fluidfft get methods See merge request fluiddyn/fluidfft!71
2 parents 3a80a4e + d39b2da commit f726b12

File tree

7 files changed

+82
-5
lines changed

7 files changed

+82
-5
lines changed

Makefile

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,9 @@ cleanall: clean cleanso cleanpythran
3535
black:
3636
pdm run black
3737

38+
format:
39+
pdm run black
40+
3841
tests:
3942
pytest -s tests
4043

noxfile.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@
2424
import nox
2525

2626
os.environ.update({"PDM_IGNORE_SAVED_PYTHON": "1"})
27-
nox.options.reuse_existing_virtualenvs = 1
27+
nox.options.reuse_existing_virtualenvs = True
2828
nox.options.sessions = ["tests"]
2929

3030
no_venv_session = partial(nox.session, venv_backend="none")

plugins/README.md

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# Fluidfft plugins
1+
# Fluidfft plugins and methods
22

33
The main Fluidfft package only contains pure Python FFT classes using other
44
packages to perform the transforms.
@@ -18,6 +18,13 @@ in its `pyproject.toml` file like this:
1818
"fft3d.with_fftw3d" = "fluidfft_fftw.fft3d.with_fftw3d"
1919
```
2020

21+
The method strings (for example `"fft3d.with_fftw3d"`) can be given to
22+
{func}`fluidfft.import_fft_class` and Operator classes (like
23+
{class}`fluidfft.fft3d.operators.OperatorsPseudoSpectral3D`).
24+
25+
The methods available can be obtained with the command line `fluidfft-get-methods`
26+
and the function {func}`fluidfft.get_methods`.
27+
2128
The following plugins are implemented in Fluidfft repository:
2229

2330
- `fluidfft-fftw`
@@ -31,9 +38,9 @@ We plan to soon also have:
3138

3239
- `fluidfft-pyvkfft` (<https://pyvkfft.readthedocs.io>)
3340

34-
Currently, the plugins can be installed from the repository (see
35-
[](#build-from-source)) but the corresponding library has to be installed
36-
first.
41+
There are few plugins available on PyPI (see <https://pypi.org/search/?q=fluidfft>).
42+
Note that their installation can trigger compilation (see [](#build-from-source))
43+
and that the corresponding library has to be installed first.
3744

3845
## Install FFT libraries
3946

pyproject.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,7 @@ p3dfft = ["fluidfft-p3dfft"]
5555
[project.scripts]
5656
fluidfft-bench = "fluidfft.bench:run"
5757
fluidfft-bench-analysis = "fluidfft.bench_analysis:run"
58+
fluidfft-get-methods = "fluidfft.cli_get_methods:main"
5859

5960
[project.entry-points."fluidfft.plugins"]
6061
"fft2d.with_pyfftw" = "fluidfft.fft2d.with_pyfftw"

src/fluidfft/cli_get_methods.py

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
import argparse
2+
3+
from fluidfft import get_methods, __version__
4+
5+
from pprint import pprint
6+
7+
8+
def main():
9+
10+
parser = argparse.ArgumentParser(
11+
prog="fluidfft-get-methods",
12+
description="Print available FFT methods.",
13+
)
14+
15+
parser.add_argument("-V", "--version", action="version", version=__version__)
16+
17+
parser.add_argument("-d", "--dim", default=None)
18+
19+
parser.add_argument("-s", "--sequential", action="store_true")
20+
parser.add_argument("-p", "--parallel", action="store_true")
21+
22+
args = parser.parse_args()
23+
24+
dim = args.dim
25+
if dim is not None:
26+
dim = int(dim)
27+
28+
if args.sequential and args.parallel:
29+
raise ValueError("--sequential and --parallel are incompatible options")
30+
elif args.sequential:
31+
sequential = True
32+
elif args.parallel:
33+
sequential = False
34+
else:
35+
sequential = None
36+
37+
methods = get_methods(dim, sequential)
38+
39+
pprint(sorted(methods))

src/fluidfft/meson.build

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ python_sources = [
44
'base.py',
55
'bench.py',
66
'bench_analysis.py',
7+
'cli_get_methods.py',
78
'util.py',
89
'build_conf.txt',
910
]

tests/test_cli_get_methods.py

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
import sys
2+
3+
from unittest.mock import patch
4+
5+
from fluidfft.cli_get_methods import main
6+
7+
8+
def test_get_methods():
9+
10+
with patch.object(sys, "argv", []):
11+
main()
12+
13+
with patch.object(sys, "argv", ["fluidfft-get-methods", "-d", "2"]):
14+
main()
15+
16+
with patch.object(sys, "argv", ["fluidfft-get-methods", "-d", "3"]):
17+
main()
18+
19+
with patch.object(sys, "argv", ["fluidfft-get-methods", "-s"]):
20+
main()
21+
22+
with patch.object(sys, "argv", ["fluidfft-get-methods", "-p"]):
23+
main()
24+
25+
with patch.object(sys, "argv", ["fluidfft-get-methods", "-d", "3", "-s"]):
26+
main()

0 commit comments

Comments
 (0)