Skip to content

Commit

Permalink
Merge pull request #2 from mhogan-nwra/develop
Browse files Browse the repository at this point in the history
Bump to Version 0.3.1 (Redo)
  • Loading branch information
mhogan-nwra authored Sep 11, 2024
2 parents b083a01 + e532421 commit 189c311
Show file tree
Hide file tree
Showing 10 changed files with 784 additions and 168 deletions.
10 changes: 10 additions & 0 deletions CHANGELOG.rst
Original file line number Diff line number Diff line change
Expand Up @@ -23,3 +23,13 @@ Matt Hogan (4)
* Add testing using GitHub Action. Windows, MacOS, and Linux (Ubuntu) is tested using 3.9 - 3.12, inclusive.
* Added local testing support using nox.
* Remove numpydoc from the documentation requirements as it is not used.

Version 0.3.1, September 11, 2024
=================================
Matt Hogan (6)
* Embraced 3.9+ support with more descriptive static typing.
* Expanded or added docstrings.
* Fixed some pytest failures associated with matplotlib opening multiple figures simultaneously.
* Added missing figures to the documentation.
* Updated the noxfile to support multiple virtual environment backends.
* Expand documentation on the reasons for the existence of envector.
18 changes: 13 additions & 5 deletions README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ envector


The envector library is a suite of tools written in Python to solve geographical position calculations. This is
an open-source fork of the original nvector_ Python package based on the MATLAB nvector toolbox_.
an open-source fork of the original nvector_ Python package based on the MATLAB nvector `MATLAB n-vector toolbox`_.

Currently the following operations are implemented:

Expand Down Expand Up @@ -39,20 +39,27 @@ If you are coming from the nvector_ package, these Q-and-A can quickly explain t
* If your Python software worked with nvector_, then there is a good chance envector_ will also work. The caveats
are that this package abandons Python2 and extends to Python3.9+ support.

2. *Why did you fork nvector*?
2. *Why did you call this package "envector"*?

* The name honors the original nvector_ Python package and the progenitor `MATLAB n-vector toolbox`_. There are
adaptations in other languages as noted in the `nvector downloads`_ page.
* The names nvector_ and envector_ are homophones (pronounced the same), so the name invokes the original n-vector
origin.

3. *Why did you fork nvector*?

* Primarily because the nvector_ Python package is broken with NumPy version 2.
* There is no indication that the situation will change.

3. *What changes are there with from nvector*?
4. *What changes are there with from nvector*?

* Any place there is a `import nvector` or `from nvector` statement, replace it with `import envector` or
`from envector`, respectively.
* The envector_ package is a Python3-only package as it embraces type-hints in most cases.
* Documentation is expanded in some cases.
* The docstrings have been refactored to utilize the Napoleon docstring style.

4. *When is the appropriate to switch to envector*?
5. *When is the appropriate to switch to envector*?

* If your Python software must support NumPy version 2,
* If your Python software also stops supporting Python versions after its end-of-life cycle.
Expand Down Expand Up @@ -619,7 +626,8 @@ to do the calculations.

.. _nvector: https://github.com/pbrod/nvector
.. _envector: https://github.com/mhogan-nwra/envector
.. _toolbox: http://www.navlab.net/nvector/#download>
.. _nvector downloads: https://www.ffi.no/en/research/n-vector/n-vector-downloads
.. _MATLAB n-vector toolbox: https://github.com/FFI-no/n-vector
.. |pkg_img| image:: https://badge.fury.io/py/envector.svg
:target: https://pypi.python.org/pypi/envector/
.. |docs_img| image:: https://readthedocs.org/projects/pip/badge/?version=stable
Expand Down
16 changes: 12 additions & 4 deletions docs/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -26,20 +26,27 @@ If you are coming from the nvector_ package, these Q-and-A can quickly explain t
* If your Python software worked with nvector_, then there is a good chance envector_ will also work. The caveats
are that this package abandons Python2 and extends to Python3.9+ support.

2. *Why did you fork nvector*?
2. *Why did you call this package "envector"*?

* The name honors the original nvector_ Python package and the progenitor `MATLAB n-vector toolbox`_. There are
adaptations in other languages as noted in the `nvector downloads`_ page.
* The names nvector_ and envector_ are homophones (pronounced the same), so the name invokes the original n-vector
origin.

3. *Why did you fork nvector*?

* Primarily because the nvector_ Python package is broken with NumPy version 2.
* There is no indication that the situation will change.

3. *What changes are there with from nvector*?
4. *What changes are there with from nvector*?

* Any place there is a `import nvector` or `from nvector` statement, replace it with `import envector` or
`from envector`, respectively.
* The envector_ package is a Python3-only package as it embraces type-hints in most cases.
* Documentation is expanded in some cases.
* The docstrings have been refactored to utilize the Napoleon docstring style.

4. *When is the appropriate to switch to envector*?
5. *When is the appropriate to switch to envector*?

* If your Python software must support NumPy version 2,
* If your Python software also stops supporting Python versions after its end-of-life cycle.
Expand Down Expand Up @@ -80,4 +87,5 @@ If you are coming from the nvector_ package, these Q-and-A can quickly explain t

.. _envector: https://github.com/mhogan-nwra/envector
.. _nvector: https://github.com/pbrod/nvector
.. _toolbox: http://www.navlab.net/nvector/#download>
.. _nvector downloads: https://www.ffi.no/en/research/n-vector/n-vector-downloads
.. _MATLAB n-vector toolbox: https://github.com/FFI-no/n-vector
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/topics/images/Mathabd.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
95 changes: 91 additions & 4 deletions noxfile.py
Original file line number Diff line number Diff line change
@@ -1,12 +1,99 @@
"""Run tests using Nox"""
"""Run tests using Nox
Quick Usage
-----------
```
pdm run nox -s <SESSION_NAME>-<VERSION>
```
Description
-----------
You have options on how to use Nox depending on which applications are on your platform. If you have all supported
Python versions installed and in your $PATH, then you can use the `noxfile.test` method like so
```
pdm run nox -s tests_venv # Or
pdm run nox -s tests_virtualenv
```
If you have a limited installation set, you can install the Anaconda, Mamba, or micromamba and run
```
pdm run nox -s tests_conda # Or
pdm run nox -s tests_mamba # Or
pdm run nox -s tests_micromamba
```
"""
from pathlib import Path

import nox
import os

os.environ.update({"PDM_IGNORE_SAVED_PYTHON": "1"})
supported_pythons = ["3.9", "3.10", "3.11", "3.12"]


@nox.session(
python=supported_pythons,
venv_backend="venv"
)
def tests_venv(session: nox.Session) -> None:
"""Test environment the venv venv_backend"""
_pdm_install_test_group(session)
_unifed_test(session)


@nox.session(
python=["3.9", "3.10", "3.11", "3.12"],
python=supported_pythons,
venv_backend="virtualenv"
)
def tests(session: nox.Session) -> None:
session.run_always("pdm", "install", "-G", "test", external=True)
def tests_virtualenv(session: nox.Session) -> None:
"""Test environment the virtualenv venv_backend"""
_pdm_install_test_group(session)
_unifed_test(session)


@nox.session(
python=supported_pythons,
venv_backend="conda",
)
def tests_conda(session: nox.Session) -> None:
"""Test environment with the conda venv_backend"""
_tests_conda_like(session)


@nox.session(
python=supported_pythons,
venv_backend="micromamba",
)
def tests_micromamba(session: nox.Session) -> None:
"""Test environment with the micromamba venv_backend"""
_tests_conda_like(session)


@nox.session(
python=supported_pythons,
venv_backend="mamba",
)
def tests_mamba(session: nox.Session) -> None:
"""Test environment with the mamba venv_backend"""
_tests_conda_like(session)


def _pdm_install_test_group(session: nox.Session) -> None:
session.run_always("pdm", "install", "-dG", "test", external=True)


def _tests_conda_like(session: nox.Session) -> None:
session.run_always("pdm", "build", external=True)
session.install("--upgrade", "pip")
session.run_always("pip", "install", "-f", os.fspath(Path.cwd() / "dist"), "envector")
session.install("pytest", "pytest-cov", "pytest-pep8", "hypothesis")
_unifed_test(session)

def _unifed_test(session: nox.Session) -> None:
"""The unified command to run the test suite"""
session.run("pytest", "-rxsXf", "--doctest-modules", "src", "tests")
2 changes: 1 addition & 1 deletion src/envector/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
from .objects import *


__version__ = "0.3.0"
__version__ = "0.3.1"


def test(*options):
Expand Down
41 changes: 26 additions & 15 deletions src/envector/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -702,6 +702,7 @@ def interp_nvectors(
Examples
--------
>>> from tkinter import TclError # This exception is raised with matplotlib and pytest
>>> import matplotlib.pyplot as plt
>>> import envector as nv
>>> lat, lon = nv.rad(np.arange(0, 10)), np.sin(nv.rad(np.linspace(-90, 70, 10)))
Expand All @@ -710,8 +711,11 @@ def interp_nvectors(
>>> nvectors = nv.lat_lon2n_E(lat, lon)
>>> nvectors_i = nv.interp_nvectors(t_i, t, nvectors, kind='cubic')
>>> lati, loni = nv.deg(*nv.n_E2lat_lon(nvectors_i))
>>> h = plt.plot(nv.deg(lon), nv.deg(lat), 'o', loni, lati, '-')
>>> plt.show() # doctest: +SKIP
>>> try:
... h = plt.plot(nv.deg(lon), nv.deg(lat), 'o', loni, lati, '-')
... plt.show() # doctest: +SKIP
... except TclError:
... pass
>>> plt.close()
Interpolate noisy data
Expand All @@ -723,8 +727,11 @@ def interp_nvectors(
>>> nvectors = nv.lat_lon2n_E(lat, lon)
>>> nvectors_i = nv.interp_nvectors(t_i, t, nvectors, 'cubic', 31)
>>> [lati, loni] = nv.n_E2lat_lon(nvectors_i)
>>> h = plt.plot(nv.deg(lon), nv.deg(lat), 'o', nv.deg(loni), nv.deg(lati), '-')
>>> plt.show() # doctest: +SKIP
>>> try:
... h = plt.plot(nv.deg(lon), nv.deg(lat), 'o', nv.deg(loni), nv.deg(lati), '-')
... plt.show() # doctest: +SKIP
... except TclError:
... pass
>>> plt.close()
Expand Down Expand Up @@ -893,6 +900,7 @@ def course_over_ground(
Examples
--------
>>> from tkinter import TclError # This exception is raised with matplotlib and pytest
>>> import matplotlib.pyplot as plt
>>> import envector as nv
>>> lats = nv.rad(59.381509, 59.387647)
Expand All @@ -902,17 +910,20 @@ def course_over_ground(
>>> dx, dy = np.sin(COG_rad[0]), np.cos(COG_rad[0])
>>> COG = nv.deg(COG_rad)
>>> p_AB_N = np.asarray(n_EA_E_and_n_EB_E2p_AB_N(nvec[:, :1], nvec[:, 1:])).ravel()
>>> ax = plt.figure().gca()
>>> _ = ax.plot(0, 0, 'bo', label='A')
>>> _ = ax.arrow(0,0, dx*300, dy*300, head_width=20, label='COG')
>>> _ = ax.plot(p_AB_N[1], p_AB_N[0], 'go', label='B')
>>> _ = ax.set_title('COG={} degrees'.format(COG))
>>> _ = ax.set_xlabel('East [m]')
>>> _ = ax.set_ylabel('North [m]')
>>> _ = ax.set_xlim(-500, 200)
>>> _ = ax.set_aspect('equal', adjustable='box')
>>> _ = ax.legend()
>>> plt.show() # doctest: +SKIP
>>> try:
... ax = plt.figure().gca()
... _ = ax.plot(0, 0, 'bo', label='A')
... _ = ax.arrow(0,0, dx*300, dy*300, head_width=20, label='COG')
... _ = ax.plot(p_AB_N[1], p_AB_N[0], 'go', label='B')
... _ = ax.set_title('COG={} degrees'.format(COG))
... _ = ax.set_xlabel('East [m]')
... _ = ax.set_ylabel('North [m]')
... _ = ax.set_xlim(-500, 200)
... _ = ax.set_aspect('equal', adjustable='box')
... _ = ax.legend()
... plt.show() # doctest: +SKIP
... except TclError:
... pass
>>> plt.close()
See also
Expand Down
Loading

0 comments on commit 189c311

Please sign in to comment.