Skip to content

Commit

Permalink
Fix pypi (#21)
Browse files Browse the repository at this point in the history
* fix_pypi

* pypi workflow update

* documentation fixes

* elliptics documentation

* fix link in Readme
  • Loading branch information
dgarnier committed Jun 30, 2023
1 parent c84e9c2 commit fadc0b9
Show file tree
Hide file tree
Showing 6 changed files with 73 additions and 28 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ jobs:
- name: Check if there is a parent commit
id: check-parent-commit
run: |
echo "{sha}={$(git rev-parse --verify --quiet HEAD^)}" >> $GITHUB_OUTPUT
echo "sha=$(git rev-parse --verify --quiet HEAD^)" >> "$GITHUB_OUTPUT"
- name: Detect and tag new version
id: check-version
Expand Down
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -37,9 +37,9 @@ You can install _inductance_ via [pip] from [PyPI]:
$ pip install inductance
```

## Usage
## Reference

Please see the [Command-line Reference] for details.
Please see the [reference] for details.

## Contributing

Expand Down Expand Up @@ -70,4 +70,4 @@ This project was generated from [@cjolowicz]'s [Hypermodern Python Cookiecutter]

[license]: https://github.com/dgarnier/inductance/blob/main/LICENSE
[contributor guide]: https://github.com/dgarnier/inductance/blob/main/CONTRIBUTING.md
[command-line reference]: https://inductance.readthedocs.io/en/latest/usage.html
[reference]: https://inductance.readthedocs.io/en/latest/reference.html
21 changes: 21 additions & 0 deletions docs/reference.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,3 +9,24 @@
.. automodule:: inductance
:members:
```

### inductance

```{eval-rst}
.. automodule:: inductance.inductance
:members:
```

### elliptics

```{eval-rst}
.. automodule:: inductance.elliptics
:members:
```

### filaments

```{eval-rst}
.. automodule:: inductance.filaments
:members:
```
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
[tool.poetry]
name = "inductance"
# version set in git tag
version = "0.0.0"
version = "0.1.0a1.post4.dev0+6b6695f.dev.1688154083"
description = "Code for 2D inductance calculations"
authors = ["Darren Garnier <[email protected]>"]
license = "MIT"
Expand Down
2 changes: 2 additions & 0 deletions src/inductance/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,5 @@

# this gets replaced with the package version during the build process
__version__ = "0.0.0"

# from . import elliptics, filaments, inductance
68 changes: 45 additions & 23 deletions src/inductance/elliptics.py
Original file line number Diff line number Diff line change
@@ -1,16 +1,21 @@
# Follow Toshio Fukushima, "Precise and fast computation of a general incomplete
# elliptic integral of second kind by half and double argument transformations"
# Journal of Computational and Applied Mathematics 235 (2011) 4140–4148
# DOI: https://doi.org/10.1090/S0025-5718-2011-02455-5
#
# with numba, this runs ~10x faster than scipy.special if you need both k and e
# so.. don't need numba_scipy which lags numba and scipy often
"""Precise and fast elliptic integrals.
Author: Fukushima, T. <[email protected]>
Reference: Toshio Fukushima, "Precise and fast computation of a general incomplete
elliptic integral of second kind by half and double argument transformations"
Journal of Computational and Applied Mathematics 235 (2011) 4140–4148
DOI: https://doi.org/10.1090/S0025-5718-2011-02455-5
With Numba, this runs ~10x faster than scipy.special if you need both k and e
so.. don't need numba_scipy which lags numba and scipy often.
"""

from math import log

# use numba if its installed
try:
from numba import jit_module, vectorize
from numba import jit_module

except ImportError:
from warnings import warn_explicit
Expand All @@ -21,20 +26,14 @@

# fmt: off
def celbd(mc):
'''
!---------------------------------------------------------------------------
subroutine celbd(mc,elb,eld)
!
! Simultaneous computation of associate complete elliptic integrals
! of second kind, B(m) and D(m)
!
! Reference: Fukushima, T (2011) Math. Comp., 80, 1725-1743
! Precise and fast computation of general complete elliptic integral
! of second kind
!
! Author: Fukushima, T. <[email protected]>
!
'''
"""Complete elliptic integrals of second kind, B(m) and D(m).
Args:
mc (float): mc = 1-k^2, where k is the elliptic modulus.
Returns:
(B(m), D(m)), the associate complete elliptic integrals of second kind
"""
PIQ = 0.78539816339744830961566084581988
PIHALF = 1.5707963267948966192313216916398

Expand Down Expand Up @@ -506,18 +505,41 @@ def celbd(mc):


def ellipke(k2):
# return both the first and second legendre complete eliptic integrals
"""Complete elliptic integrals of first and second kind.
Args:
k2 (float): K^2 the square of the elliptic modulus.
Returns:
(float, float): Elliptic integrals K(k^2) and E(k^2).
"""
mc = 1.0 - k2
elb, eld = celbd(mc)
return (elb + eld, elb + mc * eld)


def ellipk(k2):
"""Complete elliptic integral of the first kind.
Args:
k2 (float): K^2 the square of the elliptic modulus.
Returns:
(float): Elliptic integral K(k^2).
"""
k, _e = ellipke(k2)
return k


def ellipe(k2):
"""Complete elliptic integral of the second kind.
Args:
k2 (float): K^2 the square of the elliptic modulus.
Returns:
(float): Elliptic integral E(k^2).
"""
_k, e = ellipke(k2)
return e

Expand Down

0 comments on commit fadc0b9

Please sign in to comment.