Skip to content

Commit

Permalink
Merge pull request #57 from aburrell/deprecation
Browse files Browse the repository at this point in the history
Un-deprecation of utilities
  • Loading branch information
aburrell committed Sep 4, 2020
2 parents 7d50433 + 89f50aa commit 7beab01
Show file tree
Hide file tree
Showing 16 changed files with 374 additions and 571 deletions.
45 changes: 31 additions & 14 deletions CHANGELOG.rst
Original file line number Diff line number Diff line change
@@ -1,16 +1,25 @@

Changelog
=========

2.6.1 (2020-09-XX)
------------------

* Moved formerly deprecated utilities from `deprecated.py` to `utils.py`
* Removed allowance for deprecated kwarg `code` from `convert_latlon` and
`convert_latlon_arr`, as scheduled
* Updated CI to include python 3.8 everywhere
* Moved all configuration information to setup.cfg
* Fixed coveralls implementation
* Fixed broken links in the documentation
* Removed unused code analysis tools
* Improved unit test coverage
* Make PEP8 changes


2.6.0 (2020-01-06)
------------------

* Updated AACGM-v2 coefficients derived using the IGRF13 model
* Updated IGRF and GUFM1 coefficients using the IGRF13 model
* Added additional checks to the C code for reading the IGRF13 coefficient file
Expand All @@ -23,7 +32,8 @@ Changelog


2.5.3 (2019-12-23)
-----------------------------------------
------------------

* Changed log warning about array functions to info
* Changed default method from `TRACE` to `ALLOWTRACE`
* Added C wrappers for list input, removing inefficient use of `np.vectorize`
Expand All @@ -36,7 +46,8 @@ Changelog


2.5.2 (2019-08-27)
-----------------------------------------
------------------

* Added FutureWarning to deprecated functions
* Updated names in licenses
* Moved module structure routine tests to their own class
Expand All @@ -49,14 +60,16 @@ Changelog


2.5.1 (2018-10-19)
-----------------------------------------
------------------

* Commented out debug statement in C code
* Updated environment variable warning to output to stderr instead of stdout
* Added templates for pull requests, issues, and a code of conduct


2.5.0 (2018-08-08)
-----------------------------------------
------------------

* Updated C code and coefficients to version 2.5. Changes in python
code reflect changes in C code (includes going back to using environment
variables instead of strings for coefficient file locations)
Expand All @@ -66,20 +79,23 @@ Changelog


2.4.2 (2018-05-21)
-----------------------------------------
------------------

* Fixed bug in convert_mlt that caused all time inputs to occur
at 00:00:00 UT
* Fixed year of last two updates in changelog


2.4.1 (2018-04-04)
-----------------------------------------
------------------

* Fix bug in installation that caused files to be placed in the wrong
directory
* Added DOI


2.4.0 (2018-03-21)
-----------------------------------------
------------------

* Update to use AACGM-v2.4, which includes changes to the inverse MLT and
dipole tilt functions and some minor bug fixes
Expand All @@ -89,40 +105,41 @@ Changelog
* Updated dependencies, removing support for python 3.3
* Tested on Mac OSX
* Updated comments to include units for input and output



2.0.0 (2016-11-03)
-----------------------------------------
------------------

* Change method of calculating MLT, see documentation of convert_mlt for details


1.0.13 (2015-10-30)
-----------------------------------------
-------------------

* Correctly convert output of subsol() to geodetic coordinates (the error in
MLT/mlon conversion was not large, typically two decimal places and below)


1.0.12 (2015-10-26)
-----------------------------------------
-------------------

* Return nan in forbidden region instead of throwing exception


1.0.11 (2015-10-26)
-----------------------------------------
-------------------

* Fix bug in subsolar/MLT conversion


1.0.10 (2015-10-08)
-----------------------------------------
-------------------

* No code changes, debugged automatic build/upload process and needed new
version numbers along the way


1.0.0 (2015-10-07)
-----------------------------------------
------------------

* Initial release
4 changes: 0 additions & 4 deletions README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -92,10 +92,6 @@ Badges
:alt: Coverage Status (Coveralls)
:target: https://coveralls.io/github/aburrell/aacgmv2

.. |codecov| image:: https://codecov.io/github/aburrell/aacgmv2/coverage.svg?branch=master
:alt: Coverage Status (CodeCov)
:target: https://codecov.io/github/aburrell/aacgmv2

.. |codacy| image:: https://api.codacy.com/project/badge/Grade/b64ee44194f148f5bdb0f00c7cf16ab8
:alt: Codacy Code Quality Status
:target: https://app.codacy.com/manual/aburrell/aacgmv2/dashboard
Expand Down
23 changes: 6 additions & 17 deletions aacgmv2/deprecated.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@

dep_str = "".join(["Routine no longer deprecated, and so has been moved to ",
"new utils module. Duplicate routine in deprecated module",
"will be removed in version 2.6.2"])
" will be removed in version 2.7.0"])


def subsol(year, doy, utime):
Expand All @@ -29,25 +29,14 @@ def subsol(year, doy, utime):


def gc2gd_lat(gc_lat):
"""Convert geocentric latitude to geodetic latitude using WGS84.
Move to aacgmv2.utils.gc2gd_lat
Parameters
-----------
gc_lat : (array_like or float)
Geocentric latitude in degrees N
Returns
---------
gd_lat : (same as input)
Geodetic latitude in degrees N
"""Deprecated call to aacgmv2.utils.gc2gd_lat
"""
warnings.warn(dep_str, category=FutureWarning)

wgs84_e2 = 0.006694379990141317 - 1.0
return np.rad2deg(-np.arctan(np.tan(np.deg2rad(gc_lat)) / wgs84_e2))

gd_lat = aacgmv2.utils.gc2gd_lat(gc_lat)

return gd_lat


def igrf_dipole_axis(date):
"""Deprecated call to aacgmv2.utils.igrf_dipole_axis
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,11 @@
from __future__ import division, absolute_import, unicode_literals

import os
import sys
import pytest


@pytest.mark.skip(reason='only works for first import')
@pytest.mark.xfail
class TestPyEnviron:
def setup(self):
self.igrf_path = os.path.join("aacgmv2", "aacgmv2",
Expand Down Expand Up @@ -42,6 +43,12 @@ def test_good_coeff(self, aacgm_test=None, igrf_test=None):
if igrf_test.find(self.igrf_path) < 0:
raise AssertionError('BAD IGRF PATH')

@pytest.mark.parametrize("coeff", [("aacgm_test"), ("igrf_test")])
def test_bad_coeff(self, coeff):
""" Test the failure of the class routine 'test_good_coeff'"""
with pytest.raises(AssertionError, match="BAD"):
self.test_good_coeff(**{coeff: "bad path"})

def test_top_parameters_default(self):
"""Test default module coefficients"""

Expand All @@ -52,45 +59,25 @@ def test_top_parameters_default(self):
self.test_good_coeff(aacgmv2.AACGM_v2_DAT_PREFIX, aacgmv2.IGRF_COEFFS)

assert not aacgmv2.__reset_warn__
del sys.modules["aacgmv2"]
del aacgmv2

def test_top_parameters_reset_aacgm(self):
"""Test module reset of AACGM coefficient path"""

self.reset_evar(evar=['AACGM_v2_DAT_PREFIX'])
os.environ['AACGM_v2_DAT_PREFIX'] = 'test_prefix'

import aacgmv2

self.test_good_coeff(aacgmv2.AACGM_v2_DAT_PREFIX, aacgmv2.IGRF_COEFFS)

assert aacgmv2.__reset_warn__
del aacgmv2

def test_top_parameters_reset_igrf(self):
"""Test module reset of IGRF coefficient path"""

self.reset_evar(evar=['IGRF_COEFFS'])
os.environ['IGRF_COEFFS'] = 'test_prefix'

import aacgmv2

self.test_good_coeff(aacgmv2.AACGM_v2_DAT_PREFIX, aacgmv2.IGRF_COEFFS)

assert aacgmv2.__reset_warn__
del aacgmv2

def test_top_parameters_reset_both(self):
"""Test module reset of both coefficient paths"""
@pytest.mark.parametrize("evars", [(["AACGM_v2_DAT_PREFIX"]),
(["AACGM_v2_DAT_PREFIX", "IGRF_COEFFS"]),
(["IGRF_COEFFS"])])
def test_top_parameters_reset_evar_to_specified(self, evars):
"""Test module reset of AACGM environment variables"""

os.environ['AACGM_v2_DAT_PREFIX'] = 'test_prefix1'
os.environ['IGRF_COEFFS'] = 'test_prefix2'
self.reset_evar(evar=evars)
for i, evar in enumerate(evars):
os.environ[evar] = 'test_prefix{:d}'.format(i)

import aacgmv2

self.test_good_coeff(aacgmv2.AACGM_v2_DAT_PREFIX, aacgmv2.IGRF_COEFFS)

assert aacgmv2.__reset_warn__
del sys.modules["aacgmv2"]
del aacgmv2

def test_top_parameters_set_same(self):
Expand All @@ -108,4 +95,5 @@ def test_top_parameters_set_same(self):
self.test_good_coeff(aacgmv2.AACGM_v2_DAT_PREFIX, aacgmv2.IGRF_COEFFS)

assert not aacgmv2.__reset_warn__
del sys.modules["aacgmv2"]
del aacgmv2
45 changes: 6 additions & 39 deletions aacgmv2/tests/test_dep_aacgmv2.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
from __future__ import division, absolute_import, unicode_literals

import datetime as dt
import numpy as np
import warnings

import aacgmv2
Expand Down Expand Up @@ -53,48 +52,16 @@ def test_igrf_dipole_axis_warning(self):
self.test_args = [self.dtime]
self.test_future_dep_warning()


class TestDepAACGMV2:
def setup(self):
"""Runs before every method to create a clean testing setup"""
self.dtime = dt.datetime(2015, 1, 1, 0, 0, 0)
self.lat = None
self.lon = None

def teardown(self):
"""Runs after every method to clean up previous testing"""
del self.dtime, self.lat, self.lon

def test_gc2gd_lat(self):
"""Test the geocentric to geodetic conversion"""
with warnings.catch_warnings():
warnings.simplefilter("ignore")
self.lat = aacgmv2.deprecated.gc2gd_lat(45.0)

np.testing.assert_almost_equal(self.lat, 45.1924, decimal=4)

def test_gc2gd_lat_list(self):
"""Test the geocentric to geodetic conversion"""
self.lat = [45.0, -45.0]
with warnings.catch_warnings():
warnings.simplefilter("ignore")
self.lat = aacgmv2.deprecated.gc2gd_lat(self.lat)

np.testing.assert_allclose(self.lat, [45.1924, -45.1924], rtol=1.0e-4)

def test_gc2gd_lat_arr(self):
"""Test the geocentric to geodetic conversion"""
self.lat = np.array([45.0, -45.0])
with warnings.catch_warnings():
warnings.simplefilter("ignore")
self.lat = aacgmv2.deprecated.gc2gd_lat(self.lat)

np.testing.assert_allclose(self.lat, [45.1924, -45.1924], rtol=1.0e-4)

def test_subsol_warning(self):
"""Test future deprecation warning for subsol"""

self.test_routine = aacgmv2.deprecated.subsol
self.test_args = [self.dtime.year, 1, 1.0]
self.test_future_dep_warning()

def test_gc2gd_lat(self):
"""Test future deprecation warning for gc2gd_lat"""

self.test_routine = aacgmv2.deprecated.gc2gd_lat
self.test_args = [45.0]
self.test_future_dep_warning()

0 comments on commit 7beab01

Please sign in to comment.