Skip to content

Commit b816317

Browse files
committed
refactor: deprecate dead code
1 parent 6fd4b07 commit b816317

11 files changed

Lines changed: 87 additions & 13 deletions

File tree

docs/sphinx/source/whatsnew/v0.15.2.rst

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,15 @@ Breaking Changes
1010

1111
Deprecations
1212
~~~~~~~~~~~~
13+
* The function :py:func:`pvlib.clearsky._is_leap_year` is deprecated and will be
14+
removed in v0.17.0. Use :py:func:`pandas.Timestamp.is_leap_year` instead.
15+
(:issue: `2764`, :pull:`XXXX`)
16+
* The function :py:func:`pvlib.irradiance._liujordan` is deprecated and will be
17+
removed in v0.17.0. (:issue: `2764`, :pull:`XXXX`)
18+
* The function :py:func:`pvlib.modelchain.get_orientation` is deprecated and will
19+
be removed in v0.17.0. (:issue: `2764`, :pull:`XXXX`)
20+
* The method :py:meth:`pvlib.modelchain.ModelChain._prep_inputs_tracking` is
21+
deprecated and will be removed in v0.17.0. (:issue: `2764`, :pull:`XXXX`)
1322

1423

1524
Bug fixes

pvlib/clearsky.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414

1515
from pvlib import atmosphere, tools
1616
from pvlib.tools import _degrees_to_index
17+
from pvlib._deprecation import deprecated
1718

1819

1920
def ineichen(apparent_zenith, airmass_absolute, linke_turbidity,
@@ -220,6 +221,13 @@ def lookup_linke_turbidity(time, latitude, longitude, filepath=None,
220221
return linke_turbidity
221222

222223

224+
@deprecated(
225+
since="0.15.2",
226+
removal="0.17.0",
227+
name="_is_leap_year",
228+
alternative=None,
229+
addendum=None,
230+
)
223231
def _is_leap_year(year):
224232
"""Determine if a year is leap year.
225233

pvlib/iotools/bsrn.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -465,5 +465,5 @@ def read_bsrn(filename, logical_records=('0100',)):
465465
return content
466466

467467

468-
parse_bsrn = deprecated(since="0.13.0", name="parse_bsrn",
468+
parse_bsrn = deprecated(since="0.13.0", removal="0.17.0", name="parse_bsrn",
469469
alternative="read_bsrn")(read_bsrn)

pvlib/iotools/epw.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -311,5 +311,5 @@ def _parse_epw(csvdata, coerce_year=None):
311311
return data, meta
312312

313313

314-
parse_epw = deprecated(since="0.13.0", name="parse_epw",
314+
parse_epw = deprecated(since="0.13.0", removal="0.17.0", name="parse_epw",
315315
alternative="read_epw")(read_epw)

pvlib/iotools/sodapro.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -359,5 +359,5 @@ def read_cams(filename, integrated=False, label=None, map_variables=True):
359359
return data, metadata
360360

361361

362-
parse_cams = deprecated(since="0.13.0", name="parse_cams",
362+
parse_cams = deprecated(since="0.13.0", removal="0.17.0", name="parse_cams",
363363
alternative="read_cams")(read_cams)

pvlib/irradiance.py

Lines changed: 15 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818

1919
from pvlib._deprecation import pvlibDeprecationWarning
2020
import warnings
21+
from pvlib._deprecation import deprecated
2122

2223

2324
# Deprecation warning based on https://peps.python.org/pep-0562/
@@ -3086,8 +3087,13 @@ def campbell_norman(zenith, transmittance, pressure=101325.0,
30863087

30873088
return irrads
30883089

3089-
3090-
def _liujordan(zenith, transmittance, airmass, dni_extra=1367.0):
3090+
@deprecated(
3091+
since="0.15.2",
3092+
removal="0.17.0",
3093+
name="_liujordan",
3094+
addendum=None,
3095+
)
3096+
def _liujordan(zenith: pd.Series, transmittance: float, airmass: float, dni_extra=1367.0) -> pd.DataFrame:
30913097
'''
30923098
Determine DNI, DHI, GHI from extraterrestrial flux, transmittance,
30933099
and optical air mass number.
@@ -3106,11 +3112,11 @@ def _liujordan(zenith, transmittance, airmass, dni_extra=1367.0):
31063112
transmittance: float
31073113
Atmospheric transmittance between 0 and 1.
31083114
3109-
pressure: float, default 101325.0
3110-
Air pressure
3115+
airmass: float
3116+
Absolute airmass.
31113117
31123118
dni_extra: float, default 1367.0
3113-
Direct irradiance incident at the top of the atmosphere.
3119+
Direct irradiance incident at the top of the atmosphere. [W/m²]
31143120
31153121
Returns
31163122
-------
@@ -3126,6 +3132,10 @@ def _liujordan(zenith, transmittance, airmass, dni_extra=1367.0):
31263132
.. [2] Liu, B. Y., R. C. Jordan, (1960). "The interrelationship and
31273133
characteristic distribution of direct, diffuse, and total solar
31283134
radiation". Solar Energy 4:1-19
3135+
3136+
.. deprecated:: 0.15.2
3137+
The ``_liujordan`` function is deprecated and will be removed in 0.17.0.
3138+
Use the ``liujordan`` function instead.
31293139
'''
31303140

31313141
tau = transmittance

pvlib/modelchain.py

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@
6363

6464
@deprecated(
6565
since="0.13.1",
66-
removal="",
66+
removal="0.17.0",
6767
name="pvlib.modelchain.get_orientation",
6868
alternative=None,
6969
addendum=None,
@@ -84,6 +84,9 @@ def get_orientation(strategy, **kwargs):
8484
Returns
8585
-------
8686
surface_tilt, surface_azimuth
87+
88+
.. deprecated:: 0.15.2
89+
The ``get_orientation`` function is deprecated and will be removed in 0.17.0.
8790
"""
8891
if strategy == 'south_at_latitude_tilt':
8992
surface_azimuth = 180
@@ -1248,6 +1251,13 @@ def _prep_inputs_airmass(self):
12481251
model=self.airmass_model)
12491252
return self
12501253

1254+
@deprecated(
1255+
since="0.15.2",
1256+
removal="0.17.0",
1257+
name="Modelchain._prep_inputs_tracking",
1258+
alternative=None,
1259+
addendum=None,
1260+
)
12511261
def _prep_inputs_tracking(self):
12521262
"""
12531263
Calculate tracker position and AOI

pvlib/tracking.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import numpy as np
22
import pandas as pd
33

4-
from pvlib.tools import cosd, sind, tand, acosd, asind
4+
from pvlib.tools import cosd, sind, tand, acosd
55
from pvlib import irradiance
66
from pvlib import shading
77
from pvlib._deprecation import renamed_kwarg_warning

tests/test_clearsky.py

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,13 +8,14 @@
88

99
import pytest
1010
from numpy.testing import assert_allclose
11-
from .conftest import assert_frame_equal, assert_series_equal
11+
from .conftest import assert_frame_equal, assert_series_equal, fail_on_pvlib_version
1212

1313
from pvlib.location import Location
1414
from pvlib import clearsky
1515
from pvlib import solarposition
1616
from pvlib import atmosphere
1717
from pvlib import irradiance
18+
from pvlib._deprecation import pvlibDeprecationWarning
1819

1920
from .conftest import TESTS_DATA_DIR
2021

@@ -894,3 +895,10 @@ def test_bird():
894895
[Eb3, Ebh3, Gh3, Dh3],
895896
testdata2[['Direct Beam', 'Direct Hz', 'Global Hz', 'Dif Hz']].iloc[11],
896897
rtol=1e-3)
898+
899+
900+
@fail_on_pvlib_version('0.17.0')
901+
def test_is_leap_year_deprecation():
902+
with pytest.warns(pvlibDeprecationWarning, match='will be removed in 0.17.0.'):
903+
clearsky._is_leap_year(2020)
904+

tests/test_irradiance.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
from .conftest import (
1515
assert_frame_equal,
1616
assert_series_equal,
17+
fail_on_pvlib_version,
1718
requires_ephem,
1819
requires_numba,
1920
)
@@ -1454,3 +1455,9 @@ def test_diffuse_par_spitters():
14541455
0.99591, 0.99576, 0.99472, 0.99270, 0.99283, 0.99406, 0.99581, 0.99591,
14551456
]) # fmt: skip
14561457
assert_allclose(result, expected, atol=1e-5)
1458+
1459+
@fail_on_pvlib_version('0.17.0')
1460+
def test_liujordan_deprecation():
1461+
zenith = pd.Series([45.0, 50.0, 55.0])
1462+
with pytest.warns(pvlibDeprecationWarning, match='will be removed in 0.17.0.'):
1463+
irradiance._liujordan(zenith, transmittance=0.7, airmass=1.5)

0 commit comments

Comments
 (0)