Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

MAINT: warning evaluation #93

Merged
merged 3 commits into from
Aug 5, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ This project adheres to [Semantic Versioning](https://semver.org/).
## [0.3.2] - 2022-08-01
* Make OMMBV an optional install
* Access logger directly from pysat
* Use pysat deprecation tests

## [0.3.1] - 2022-05-18
* Include license in package manifest
Expand Down
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ Python 3.8+.
| -------------- | ----------------- |
| numpy | aacgmv2 |
| pandas | apexpy |
| pyEphem | pysat>=3.0 |
| pyEphem | pysat>=3.0.2 |
| sgp4>=2.7 | |


Expand All @@ -63,7 +63,7 @@ python setup.py install

Note: pre-1.0.0 version
-----------------------
pysatMissions is currently in an initial development phase and requires pysat 3.0.0.
pysatMissions is currently in an initial development phase and requires pysat 3.0.2.

# Using with pysat

Expand Down
41 changes: 1 addition & 40 deletions pysatMissions/tests/test_deprecation.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
"""Unit tests for deprecated methods and objects in pysatMissions."""

import numpy as np
import warnings

import pysat
Expand All @@ -20,41 +19,6 @@ def teardown(self):
"""Clean up test environment after each method."""
return

def eval_deprecation(self, warns, check_msgs, warn_type=DeprecationWarning):
"""Evaluate whether message is contained in DeprecationWarning.

Parameters
----------
warns : list
List of warnings.WarningMessage objects
check_msgs : list
List of strings containing the expected warning messages
warn_type : type
Type for the warning messages (default=DeprecationWarning)

"""

# TODO(#82): Remove when pysat 3.0.2 is released. Replace with
# pysat.utils.testing.eval_warnings

# Ensure the minimum number of warnings were raised
assert len(warns) >= len(check_msgs)

# Initialize the output
found_msgs = [False for msg in check_msgs]

# Test the warning messages, ensuring each attribute is present
for iwar in warns:
for i, msg in enumerate(check_msgs):
if str(iwar.message).find(msg) >= 0:
assert iwar.category == warn_type, \
"bad warning type for message: {:}".format(msg)
found_msgs[i] = True

assert np.all(found_msgs), "did not find {:d} expected {:}".format(
len(found_msgs) - np.sum(found_msgs), repr(warn_type))
return

def test_ephem_deprecation(self):
"""Test that instatiating missions_ephem will give DeprecationWarning."""

Expand All @@ -63,8 +27,5 @@ def test_ephem_deprecation(self):

warn_msgs = ["`missions_ephem` has been deprecated"]

# TODO(#82): Replace with pysat.utils.testing.eval_warnings when pysat
# 3.0.2 is released.

self.eval_deprecation(war, warn_msgs)
pysat.utils.testing.eval_warnings(war, warn_msgs)
return
2 changes: 1 addition & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,6 @@ apexpy
geospacepy
numpy
pandas
pysat>=3.0
pysat>=3.0.2
pyEphem
sgp4>=2.7
2 changes: 1 addition & 1 deletion setup.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ install_requires =
numpy
OMMBV
pandas
pysat>=3.0
pysat
pyEphem
sgp4

Expand Down