Skip to content

Commit 4a4ba29

Browse files
authored
Make a proper package out of pyfftlog (#1)
- Converted to package - Test and CI with Travis - PEP8 with flake8
1 parent 94707c3 commit 4a4ba29

20 files changed

+275
-924
lines changed

.gitattributes

Lines changed: 0 additions & 2 deletions
This file was deleted.

.gitignore

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
# Directories
2+
__pycache__/
3+
4+
# Cython
5+
*.so
6+
fftlog/_fftlogmodule.c
7+
8+
# Pytest
9+
.pytest_cache/
10+
11+
# setuptools_scm
12+
fftlog/version.py
13+
14+
# Build related
15+
.eggs/
16+
build/
17+
dist/
18+
fftlog.egg-info/
19+
MANIFEST

.travis.yml

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
language: python
2+
3+
addons:
4+
apt:
5+
- gfortran
6+
7+
# Note: the `python: X.Y` is not actually used, as internally conda is used,
8+
# which follows the `PYTHON=X.Y` var.
9+
matrix:
10+
include:
11+
- python: 3.6
12+
env: PYTHON=3.6
13+
- python: 3.7
14+
env: PYTHON=3.7 DEPLOY_PYPI=true
15+
- python: 3.8
16+
env: PYTHON=3.8
17+
18+
install:
19+
- sudo apt-get update
20+
# We do this conditionally because it saves us some downloading if the
21+
# version is the same.
22+
- wget https://repo.continuum.io/miniconda/Miniconda3-latest-Linux-x86_64.sh -O miniconda.sh;
23+
- bash miniconda.sh -b -p $HOME/miniconda
24+
- export PATH="$HOME/miniconda/bin:$PATH"
25+
- hash -r
26+
- conda config --set always_yes yes --set changeps1 no
27+
- conda update --all
28+
# Useful for debugging any issues with conda
29+
- conda info -a
30+
31+
# Install and activate environment, install packages
32+
- conda create -q -n test-environment python=$PYTHON $PCKGS scipy pytest pytest-cov
33+
- source activate test-environment
34+
- pip install setuptools_scm pytest-flake8 $INST
35+
- pip install -e .
36+
37+
script:
38+
- pytest --cov=fftlog --flake8 $TEST
39+
40+
deploy:
41+
provider: pypi
42+
user: "__token__"
43+
password:
44+
secure: BHN9rI3Ckz5aofGqhdpcNq9JQwqLrWQX64xlXsflY46ROQi3+jii0bbRyZgMbv3MMzkjJBOlS/L4GH1dd3da56vYBrDr4n4zCRjMRdoaFLkJRPZttNs5Il1cO2wY7yn0et8Guq7JCNivNJGppAzj5vvaJu50YfW7izaRRlMEDc8KgN5CIKaD5HOGC4AkRCwLWKOf16ly5uhOMFcVrDd/c4UvZMTxByePls2NExZzrrVxndfZZklHOIeVI0QUjuD5fc8MKxO+Lx3S01LHgFdM4xfilQPtPajAg/C6iXavcrrXk62mit0/T53reEoDBbuyQ7rtKwbJm+iN3R+qpiYjegrSpdc9l1FU2rCO3T3R7a3nNF3PzfCm6IZcgkIXjg8melUlaLROL1A7yj/DMh/ASjUPILTV2hedC5bJ/aEVsuBgjDhq7d7wH+RDuswx8vZOHkt9aKtTgLZJdvCUg0QMe0dkkmsTXq0YkLZLXcD3mEOV5lNnu50us9JEDhzunX37p1S+RhBVCWa16rptnWlfEo0W8rk42lmTywu3f6mLmsfKWFJ3zQQOo62zNya11ff1KLwdUGK9QfLw8y7wnrpVrwYU/6PU7d82gWphy2GqB50BjmpPk1lX75rkywRySHpBZug03dlMmUwzWbm9L6VTlA0RepNT3PXCS8rXBBJMzSU=
45+
on:
46+
branch: master
47+
tags: true
48+
condition: '$DEPLOY_PYPI = "true"'
49+
distributions: "sdist"

CHANGELOG.rst

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
Changelog
2+
#########
3+
4+
5+
v0.2.0 : First packaged release
6+
-------------------------------
7+
8+
**2020-05-16**
9+
10+
First packaged release on PyPi and conda-forge. This includes:
11+
12+
- Re-structuring the repo.
13+
- Link to proper documentation, https://pyfftlog.readthedocs.io
14+
(which is for pyfftlog), which contains as well the example.
15+
- Add tests and CI on Travis, https://travis-ci.org/github/prisae/pyfftlog.
16+
- Link to Zenodo, https://zenodo.org/record/3830366.
17+
- PEP8 checking.
18+
- Add the relevant badges to README.
19+
20+
21+
v0.1.0 : Initial upload to GitHub
22+
---------------------------------
23+
24+
**2016-12-05**
25+
26+
- Initially working version uploaded to GitHub.

MANIFEST.in

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
prune tests
2+
exclude requirements.txt
3+
exclude requirements-dev.txt
4+
exclude .gitignore
5+
exclude .travis.yml

README.rst

Lines changed: 54 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,37 @@
1-
`fftlog` - python wrapper FFTLog
2-
================================
1+
.. image:: https://travis-ci.org/prisae/fftlog.svg?branch=master
2+
:target: https://travis-ci.org/prisae/fftlog
3+
:alt: Travis-CI
4+
.. image:: https://zenodo.org/badge/DOI/10.5281/zenodo.3830534.svg
5+
:target: https://doi.org/10.5281/zenodo.3830534
6+
:alt: Zenodo DOI
7+
8+
9+
`fftlog` - A python wrapper for FFTLog
10+
======================================
311

412
This is a simple `f2py`-wrapper for the logarithmic FFT code *FFTLog* as
5-
presented in Appendix B of [Hamilton_2000]_ and published at
13+
presented in Appendix B of [Hami00]_ and published at
614
`casa.colorado.edu/~ajsh/FFTLog <http://casa.colorado.edu/~ajsh/FFTLog>`_.
715

8-
A pure python version (`pyfftlog`) can be found on
9-
`github.com/prisae/pyfftlog <https://github.com/prisae/pyfftlog>`_.
10-
Tests have shown that `fftlog` is a bit faster than `pyfftlog`, but `pyfftlog`
11-
is easier to implement, as you only need `NumPy` and `SciPy`, without the
12-
need to compile anything.
16+
A pure python version (`pyfftlog`) can be found on `github.com/prisae/pyfftlog
17+
<https://github.com/prisae/pyfftlog>`_. Tests have shown that `fftlog` is a bit
18+
faster than `pyfftlog`, but `pyfftlog` is easier to implement, as you only need
19+
`NumPy` and `SciPy`, without the need to compile anything.
1320

1421
I hope that `FFTLog` will make it into `SciPy` in the future, which will make
15-
this project redundant.
22+
this project redundant. (If you have the bandwidth and are willing to chip in
23+
have a look at `SciPy PR #7310 <https://github.com/scipy/scipy/pull/7310>`_.)
24+
25+
Be aware that `pyfftlog` has not been tested extensively. It works fine for the
26+
test from the original code, and my use case, which is `pyfftlog.fftl` with
27+
`mu=0.5` (sine-transform), `q=0` (unbiased), `k=1`, `kropt=1`, and `tdir=1`
28+
(forward). Please let me know if you encounter any issues.
1629

17-
Be aware that `pyfftlog` has not been tested extensively. It works fine
18-
for the attached test, which is the test from the original code, and my use
19-
case, which is `pyfftlog.fftl` with `mu=0.5` (sine-transform), `q=0`
20-
(unbiased), `k=1`, `kropt=1`, and `tdir=` (forward). Please let me know if you
21-
encounter any issues.
30+
- **Documentation**: https://pyfftlog.readthedocs.io
31+
- **Source Code**: https://github.com/prisae/fftlog
2232

33+
**Note** that the documentation is for the pure python version `pyfftlog`, but
34+
equally applies to `fftlog`.
2335

2436
Description of FFTLog from the FFTLog-Website
2537
---------------------------------------------
@@ -39,32 +51,26 @@ steps) and aliasing (periodic folding of frequencies), but under appropriate
3951
circumstances FFTLog may approximate the results of a continuous Fourier or
4052
Hankel transform.
4153

42-
The FFTLog algorithm was originally proposed by [Talman_1978]_.
54+
The FFTLog algorithm was originally proposed by [Talm78]_.
4355

44-
*For the full documentation, see*
45-
`casa.colorado.edu/~ajsh/FFTLog <http://casa.colorado.edu/~ajsh/FFTLog>`_.
56+
*For the full documentation, see* `casa.colorado.edu/~ajsh/FFTLog
57+
<http://casa.colorado.edu/~ajsh/FFTLog>`_.
4658

4759

4860
Installation
4961
------------
5062

51-
To install it in your python distribution:
63+
You can install fftlog either via **conda**:
5264

53-
.. code:: bash
65+
.. code-block:: console
5466
55-
python setup.py install
67+
conda install -c conda-forge fftlog
5668
69+
or via **pip**:
5770

58-
To just create the module that you can import locally:
71+
.. code-block:: console
5972
60-
.. code:: bash
61-
62-
f2py -c fftlog.pyf src/*
63-
64-
You need a fortran compiler for this to work.
65-
66-
Check out the Jupyter Notebook `fftlogtest.ipynb` in the root directory. It is
67-
a translation of the test-function `fftlogtest.f`, and should get you started.
73+
pip install fftlog
6874
6975
7076
Creation
@@ -89,39 +95,42 @@ command, generating only hooks for the functions `fhti`, `fttl`, `fht`, and
8995
9096
f2py src/* -m fftlog -h fftlog.pyf only: fhti fftl fht fhtq :
9197
92-
Lastly I amended the `pyf`-instructions, mainly with some :code:`intent` and
93-
:code:`optional` statements as well as the corresponding default values.
98+
Lastly I amended the `pyf`-instructions, mainly with some `intent` and
99+
`optional` statements as well as the corresponding default values.
94100

95101

96102
Notes
97-
-----
98-
1. :code:`kropt = 3` (interactive adjusting) is not possible with `fftlog`
99-
2. :code:`wsave`-dimension is set to :code:`2*n+3*(n/2)+19`, the biggest of the
100-
four minimum sizes described in `fftlog.f`.
103+
'''''
104+
1. `kropt=3` (interactive adjusting) is not possible with `fftlog`
105+
2. `wsave`-dimension is set to `2*n+3*(n/2)+19`, the biggest of the four
106+
minimum sizes described in `fftlog.f`.
101107

102108

103109
References
104110
----------
105111

106-
.. [Hamilton_2000] Hamilton, A. J. S., 2000, Uncorrelated modes of the
107-
non-linear power spectrum: Monthly Notices of the Royal Astronomical
108-
Society, 312, pages 257-284; DOI: `10.1046/j.1365-8711.2000.03071.x
112+
.. [Hami00] Hamilton, A. J. S., 2000, Uncorrelated modes of the non-linear
113+
power spectrum: Monthly Notices of the Royal Astronomical Society, 312,
114+
pages 257-284; DOI: `10.1046/j.1365-8711.2000.03071.x
109115
<http://dx.doi.org/10.1046/j.1365-8711.2000.03071.x>`_; Website of FFTLog:
110116
`casa.colorado.edu/~ajsh/FFTLog <http://casa.colorado.edu/~ajsh/FFTLog>`_.
111117
112-
.. [Talman_1978] Talman, J. D., 1978, Numerical Fourier and Bessel transforms
113-
in logarithmic variables: Journal of Computational Physics, 29, pages
114-
35-48; DOI: `10.1016/0021-9991(78)90107-9
118+
.. [Talm78] Talman, J. D., 1978, Numerical Fourier and Bessel transforms in
119+
logarithmic variables: Journal of Computational Physics, 29, pages 35-48;
120+
DOI: `10.1016/0021-9991(78)90107-9
115121
<http://dx.doi.org/10.1016/0021-9991(78)90107-9>`_.
116122
117123
118-
License and Credits
119-
-------------------
124+
License, Citation, and Credits
125+
------------------------------
120126

121127
These additions to the original FFTLog-code are released to the public domain
122128
under the `CC0 1.0 License
123129
<http://creativecommons.org/publicdomain/zero/1.0>`_.
124130

131+
All releases have a Zenodo-DOI, which can be found on `10.5281/zenodo.3830364
132+
<https://doi.org/10.5281/zenodo.3830534>`_.
133+
125134
Permission to distribute the original Fortran `FFTLog` code with this Python
126135
`fftlog` package has been granted (email from Andrew Hamilton to Dieter
127136
Werthmüller dated 28 September 2016).
@@ -141,3 +150,5 @@ The original gamerf copyright statement states::
141150
Permission to distribute the modified gamma function code with the FFTLog
142151
package has been granted (email from Takuya Ooura to Andrew Hamilton dated 16
143152
March 1999).
153+
154+
Be kind and give credits by citing Hamilton (2000).

fftlog/__init__.py

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
from datetime import datetime
2+
from fftlog._fftlog import fhti, fftl, fht, fhtq
3+
4+
__all__ = ['fhti', 'fftl', 'fht', 'fhtq']
5+
6+
# Version
7+
try:
8+
# - Released versions just tags: 1.10.0
9+
# - GitHub commits add .dev#+hash: 1.10.1.dev3+g973038c
10+
# - Uncommitted changes add timestamp: 1.10.1.dev3+g973038c.d20191022
11+
from .version import version as __version__
12+
except ImportError:
13+
# If it was not installed, then we don't know the version. We could throw a
14+
# warning here, but this case *should* be rare. fftlog should be installed
15+
# properly!
16+
__version__ = 'unknown-'+datetime.today().strftime('%Y%m%d')

fftlog.pyf renamed to fftlog/fftlog.pyf

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,9 @@
1010
!
1111
! For f2py see http://cens.ioc.ee/projects/f2py2e/
1212

13-
python module fftlog ! in
13+
python module _fftlog ! in
1414
interface ! in :fftlog
15-
subroutine fhti(n,mu,q,dlnr,kr,kropt,wsave,ok) ! in :fftlog:fftlog.f
15+
subroutine fhti(n,mu,q,dlnr,kr,kropt,wsave,ok) ! in :fftlog:src/fftlog.f
1616
integer intent(int) :: n
1717
real*8 intent(in) :: mu
1818
real*8 optional, intent(in) :: q=0
@@ -22,24 +22,24 @@ python module fftlog ! in
2222
real*8 dimension(2*n+3*(n/2)+19), intent(out) :: wsave
2323
logical intent(out) :: ok
2424
end subroutine fhti
25-
subroutine fftl(n,a,rk,dir,wsave) ! in :fftlog:fftlog.f
25+
subroutine fftl(n,a,rk,dir,wsave) ! in :fftlog:src/fftlog.f
2626
integer, optional, intent(hide), depend(a) :: n=len(a)
2727
real*8 dimension(n), intent(in, out) :: a
2828
real*8 optional, intent(in) :: rk=1
2929
integer optional, intent(in) :: dir=1
3030
real*8 dimension(2*n+3*(n/2)+19), intent(in) :: wsave
3131
end subroutine fftl
32-
subroutine fht(n,a,dir,wsave) ! in :fftlog:fftlog.f
32+
subroutine fht(n,a,dir,wsave) ! in :fftlog:src/fftlog.f
3333
integer, optional, intent(hide), depend(a) :: n=len(a)
3434
real*8 dimension(n), intent(in, out) :: a
3535
integer optional, intent(in) :: dir=1
3636
real*8 dimension(2*n+3*(n/2)+19), intent(in) :: wsave
3737
end subroutine fht
38-
subroutine fhtq(n,a,dir,wsave) ! in :fftlog:fftlog.f
38+
subroutine fhtq(n,a,dir,wsave) ! in :fftlog:src/fftlog.f
3939
integer, optional, intent(hide), depend(a) :: n=len(a)
4040
real*8 dimension(n), intent(in, out) :: a
4141
integer optional, intent(in) :: dir=1
4242
real*8 dimension(2*n+3*(n/2)+19), intent(in) :: wsave
4343
end subroutine fhtq
44-
end interface
45-
end python module fftlog
44+
end interface
45+
end python module _fftlog
File renamed without changes.
File renamed without changes.

0 commit comments

Comments
 (0)