Skip to content

Commit

Permalink
Merge branch 'main' into validate-numpydoc
Browse files Browse the repository at this point in the history
  • Loading branch information
santisoler authored Nov 20, 2024
2 parents e7902f1 + e385811 commit 9574e64
Show file tree
Hide file tree
Showing 20 changed files with 2,903 additions and 1,444 deletions.
2 changes: 1 addition & 1 deletion .flake8
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

[flake8]
max-line-length = 88
max-doc-length = 79
max-doc-length = 88
ignore =
# Too many leading '#' for block comment
E266,
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/docs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ jobs:
- name: Get the pip cache folder
id: pip-cache
run: |
echo "::set-output name=dir::$(pip cache dir)"
echo "dir=$(pip cache dir)" >> $GITHUB_OUTPUT
- name: Setup caching for pip packages
uses: actions/cache@v4
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/pypi.yml
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ jobs:
- name: Publish to Test PyPI
# Only publish to TestPyPI when a PR is merged (pushed to main)
if: success() && github.event_name == 'push'
uses: pypa/gh-action-pypi-publish@v1.8.14
uses: pypa/gh-action-pypi-publish@v1.12.2
with:
repository_url: https://test.pypi.org/legacy/
# Allow existing releases on test PyPI without errors.
Expand All @@ -112,4 +112,4 @@ jobs:
- name: Publish to PyPI
# Only publish to PyPI when a release triggers the build
if: success() && github.event_name == 'release'
uses: pypa/gh-action-pypi-publish@v1.8.14
uses: pypa/gh-action-pypi-publish@v1.12.2
39 changes: 33 additions & 6 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ defaults:

jobs:
#############################################################################
# Run tests and upload to codecov
# Run tests
test:
name: ${{ matrix.os }} python=${{ matrix.python }} dependencies=${{ matrix.dependencies }}
runs-on: ${{ matrix.os }}
Expand Down Expand Up @@ -115,7 +115,7 @@ jobs:
- name: Get the pip cache folder
id: pip-cache
run: |
echo "::set-output name=dir::$(pip cache dir)"
echo "dir=$(pip cache dir)" >> $GITHUB_OUTPUT
- name: Setup caching for pip packages
uses: actions/cache@v4
Expand Down Expand Up @@ -146,11 +146,38 @@ jobs:
- name: Convert coverage report to XML for codecov
run: coverage xml

- name: Upload coverage to Codecov
uses: codecov/codecov-action@v4
- name: Upload coverage as artifact
uses: actions/upload-artifact@v4
with:
file: ./coverage.xml
env_vars: OS,PYTHON,DEPENDENCIES
name: coverage_${{ matrix.os }}_${{ matrix.dependencies }}
path: ./coverage.xml


#############################################################################
# Upload coverage report to codecov
codecov-upload:
runs-on: ubuntu-latest
needs: test

steps:

- name: Download coverage report artifacts
# Download coverage reports from every runner.
# Maximum coverage is achieved by combining reports from every runner.
# Each coverage file will live in its own folder with the same name as
# the artifact.
uses: actions/download-artifact@v4
with:
pattern: coverage_*

- name: List all downloaded artifacts
run: ls -l -R .

- name: Upload coverage reports to Codecov
uses: codecov/codecov-action@v5
with:
# Upload all coverage report files
files: ./coverage_*/coverage.xml
# Fail the job so we know coverage isn't being updated. Otherwise it
# can silently drop and we won't know.
fail_ci_if_error: true
Expand Down
122 changes: 34 additions & 88 deletions choclo/dipole/_forward.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,35 +37,20 @@ def magnetic_field(
Parameters
----------
easting_p : float
Easting coordinate of the observation point in meters.
northing_p : float
Northing coordinate of the observation point in meters.
upward_p : float
Upward coordinate of the observation point in meters.
easting_q : float
Easting coordinate of the dipole in meters.
northing_q : float
Northing coordinate of the dipole in meters.
upward_q : float
Upward coordinate of the dipole in meters.
magnetic_moment_east : float
The East component of the magnetic moment vector of the dipole. Must be
in :math:`A m^2`.
magnetic_moment_north : float
The North component of the magnetic moment vector of the dipole. Must
be in :math:`A m^2`.
magnetic_moment_up : float
The upward component of the magnetic moment vector of the dipole. Must
be in :math:`A m^2`.
easting_p, northing_p, upward_p : float
Easting, northing and upward coordinates of the observation point in
meters.
easting_q, northing_q, upward_q : float
Easting, northing and upward coordinates of the dipole in meters.
magnetic_moment_east, magnetic_moment_north, magnetic_moment_up : float
The east, north and upward component of the magnetic moment vector of
the dipole. Must be in :math:`A m^2`.
Returns
-------
b : array
Array containing the three components of the magnetic field generated
b_e, b_n, b_u : float
Easting, northing and upward components of the magnetic field generated
by the dipole on the observation point in :math:`\text{T}`.
The components are returned in the following order: ``b_e``, ``b_n``,
``b_u``.
Notes
-----
Expand Down Expand Up @@ -137,27 +122,14 @@ def magnetic_e(
Parameters
----------
easting_p : float
Easting coordinate of the observation point in meters.
northing_p : float
Northing coordinate of the observation point in meters.
upward_p : float
Upward coordinate of the observation point in meters.
easting_q : float
Easting coordinate of the dipole in meters.
northing_q : float
Northing coordinate of the dipole in meters.
upward_q : float
Upward coordinate of the dipole in meters.
magnetic_moment_east : float
The East component of the magnetic moment vector of the dipole. Must be
in :math:`A m^2`.
magnetic_moment_north : float
The North component of the magnetic moment vector of the dipole. Must
be in :math:`A m^2`.
magnetic_moment_up : float
The upward component of the magnetic moment vector of the dipole. Must
be in :math:`A m^2`.
easting_p, northing_p, upward_p : float
Easting, northing and upward coordinates of the observation point in
meters.
easting_q, northing_q, upward_q : float
Easting, northing and upward coordinates of the dipole in meters.
magnetic_moment_east, magnetic_moment_north, magnetic_moment_up : float
The east, north and upward component of the magnetic moment vector of
the dipole. Must be in :math:`A m^2`.
Returns
-------
Expand Down Expand Up @@ -228,27 +200,14 @@ def magnetic_n(
Parameters
----------
easting_p : float
Easting coordinate of the observation point in meters.
northing_p : float
Northing coordinate of the observation point in meters.
upward_p : float
Upward coordinate of the observation point in meters.
easting_q : float
Easting coordinate of the dipole in meters.
northing_q : float
Northing coordinate of the dipole in meters.
upward_q : float
Upward coordinate of the dipole in meters.
magnetic_moment_east : float
The East component of the magnetic moment vector of the dipole. Must be
in :math:`A m^2`.
magnetic_moment_north : float
The North component of the magnetic moment vector of the dipole. Must
be in :math:`A m^2`.
magnetic_moment_up : float
The upward component of the magnetic moment vector of the dipole. Must
be in :math:`A m^2`.
easting_p, northing_p, upward_p : float
Easting, northing and upward coordinates of the observation point in
meters.
easting_q, northing_q, upward_q : float
Easting, northing and upward coordinates of the dipole in meters.
magnetic_moment_east, magnetic_moment_north, magnetic_moment_up : float
The east, north and upward component of the magnetic moment vector of
the dipole. Must be in :math:`A m^2`.
Returns
-------
Expand Down Expand Up @@ -319,27 +278,14 @@ def magnetic_u(
Parameters
----------
easting_p : float
Easting coordinate of the observation point in meters.
northing_p : float
Northing coordinate of the observation point in meters.
upward_p : float
Upward coordinate of the observation point in meters.
easting_q : float
Easting coordinate of the dipole in meters.
northing_q : float
Northing coordinate of the dipole in meters.
upward_q : float
Upward coordinate of the dipole in meters.
magnetic_moment_east : float
The East component of the magnetic moment vector of the dipole. Must be
in :math:`A m^2`.
magnetic_moment_north : float
The North component of the magnetic moment vector of the dipole. Must
be in :math:`A m^2`.
magnetic_moment_up : float
The upward component of the magnetic moment vector of the dipole. Must
be in :math:`A m^2`.
easting_p, northing_p, upward_p : float
Easting, northing and upward coordinates of the observation point in
meters.
easting_q, northing_q, upward_q : float
Easting, northing and upward coordinates of the dipole in meters.
magnetic_moment_east, magnetic_moment_north, magnetic_moment_up : float
The east, north and upward component of the magnetic moment vector of
the dipole. Must be in :math:`A m^2`.
Returns
-------
Expand Down
Loading

0 comments on commit 9574e64

Please sign in to comment.