Skip to content

Commit 2d14082

Browse files
committed
add has_ephem, modify tests for min pandas compatibility
1 parent 6036106 commit 2d14082

File tree

3 files changed

+20
-9
lines changed

3 files changed

+20
-9
lines changed

ci/requirements-py27-min.yml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,5 @@ dependencies:
66
- pandas==0.13.1
77
- nose
88
- pytz
9-
- ephem
109
- pip:
1110
- coveralls

pvlib/test/__init__.py

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,15 @@
1818
def requires_scipy(test):
1919
return test if has_scipy else unittest.skip('requires scipy')(test)
2020

21+
try:
22+
import ephem
23+
has_ephem = True
24+
except ImportError:
25+
has_ephem = False
26+
27+
def requires_ephem(test):
28+
return test if has_ephem else unittest.skip('requires ephem')(test)
29+
2130
def incompatible_conda_linux_py3(test):
2231
"""
2332
Test won't work in Python 3.x due to Anaconda issue.

pvlib/test/test_solarposition.py

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
from pvlib.location import Location
1515
from pvlib import solarposition
1616

17+
from . import requires_ephem
1718

1819
# setup times and locations to be tested.
1920
times = pd.date_range(start=datetime.datetime(2014,6,24),
@@ -176,7 +177,7 @@ def test_get_sun_rise_set_transit():
176177
del result['transit']
177178
assert_frame_equal(frame, result)
178179

179-
180+
@requires_ephem
180181
def test_pyephem_physical():
181182
times = pd.date_range(datetime.datetime(2003,10,17,12,30,30),
182183
periods=1, freq='D', tz=golden_mst.tz)
@@ -188,7 +189,7 @@ def test_pyephem_physical():
188189
assert_frame_equal(this_expected.round(2),
189190
ephem_data[this_expected.columns].round(2))
190191

191-
192+
@requires_ephem
192193
def test_pyephem_physical_dst():
193194
times = pd.date_range(datetime.datetime(2003,10,17,13,30,30), periods=1,
194195
freq='D', tz=golden.tz)
@@ -200,7 +201,7 @@ def test_pyephem_physical_dst():
200201
assert_frame_equal(this_expected.round(2),
201202
ephem_data[this_expected.columns].round(2))
202203

203-
204+
@requires_ephem
204205
def test_calc_time():
205206
import pytz
206207
import math
@@ -225,7 +226,7 @@ def test_calc_time():
225226
assert_almost_equals((az.replace(second=0, microsecond=0) -
226227
epoch_dt).total_seconds(), actual_timestamp)
227228

228-
229+
@requires_ephem
229230
def test_earthsun_distance():
230231
times = pd.date_range(datetime.datetime(2003,10,17,13,30,30),
231232
periods=1, freq='D')
@@ -242,8 +243,9 @@ def test_ephemeris_physical():
242243
temperature=11)
243244
this_expected = expected.copy()
244245
this_expected.index = times
245-
assert_frame_equal(this_expected.round(2),
246-
ephem_data[this_expected.columns].round(2))
246+
this_expected = np.round(this_expected, 2)
247+
ephem_data = np.round(ephem_data, 2)
248+
assert_frame_equal(this_expected, ephem_data[this_expected.columns])
247249

248250

249251
def test_ephemeris_physical_dst():
@@ -254,5 +256,6 @@ def test_ephemeris_physical_dst():
254256
temperature=11)
255257
this_expected = expected.copy()
256258
this_expected.index = times
257-
assert_frame_equal(this_expected.round(2),
258-
ephem_data[this_expected.columns].round(2))
259+
this_expected = np.round(this_expected, 2)
260+
ephem_data = np.round(ephem_data, 2)
261+
assert_frame_equal(this_expected, ephem_data[this_expected.columns])

0 commit comments

Comments
 (0)