Skip to content

Commit aae7eb7

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

11 files changed

Lines changed: 100 additions & 13 deletions

File tree

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

Lines changed: 10 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:`2766`)
16+
* The function :py:func:`pvlib.irradiance._liujordan` is deprecated and will be
17+
removed in v0.17.0. (:issue: `2764`, :pull:`2766`)
18+
* The function :py:func:`pvlib.modelchain.get_orientation` is deprecated and will
19+
be removed in v0.17.0. (:issue: `2764`, :pull:`2766`)
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:`2766`)
1322

1423

1524
Bug fixes
@@ -62,3 +71,4 @@ Contributors
6271
* Cliff Hansen (:ghuser:`cwhanse`)
6372
* Arthur Onno (:ghuser:`ArthurOnnoTerabase`)
6473
* Adam R. Jensen (:ghuser:`AdamRJensen`)
74+
* :ghuser:`JoLo90`

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: 17 additions & 4 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/
@@ -3087,7 +3088,14 @@ def campbell_norman(zenith, transmittance, pressure=101325.0,
30873088
return irrads
30883089

30893090

3090-
def _liujordan(zenith, transmittance, airmass, dni_extra=1367.0):
3091+
@deprecated(
3092+
since="0.15.2",
3093+
removal="0.17.0",
3094+
name="_liujordan",
3095+
addendum=None,
3096+
)
3097+
def _liujordan(zenith: pd.Series, transmittance: float,
3098+
airmass: float, dni_extra=1367.0) -> pd.DataFrame:
30913099
'''
30923100
Determine DNI, DHI, GHI from extraterrestrial flux, transmittance,
30933101
and optical air mass number.
@@ -3106,11 +3114,11 @@ def _liujordan(zenith, transmittance, airmass, dni_extra=1367.0):
31063114
transmittance: float
31073115
Atmospheric transmittance between 0 and 1.
31083116
3109-
pressure: float, default 101325.0
3110-
Air pressure
3117+
airmass: float
3118+
Absolute airmass.
31113119
31123120
dni_extra: float, default 1367.0
3113-
Direct irradiance incident at the top of the atmosphere.
3121+
Direct irradiance incident at the top of the atmosphere. [W/m²]
31143122
31153123
Returns
31163124
-------
@@ -3126,6 +3134,11 @@ def _liujordan(zenith, transmittance, airmass, dni_extra=1367.0):
31263134
.. [2] Liu, B. Y., R. C. Jordan, (1960). "The interrelationship and
31273135
characteristic distribution of direct, diffuse, and total solar
31283136
radiation". Solar Energy 4:1-19
3137+
3138+
.. deprecated:: 0.15.2
3139+
The ``_liujordan`` function is deprecated and will be
3140+
removed in 0.17.0.
3141+
Use the ``liujordan`` function instead.
31293142
'''
31303143

31313144
tau = transmittance

pvlib/modelchain.py

Lines changed: 12 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,10 @@ 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
90+
in 0.17.0.
8791
"""
8892
if strategy == 'south_at_latitude_tilt':
8993
surface_azimuth = 180
@@ -1248,6 +1252,13 @@ def _prep_inputs_airmass(self):
12481252
model=self.airmass_model)
12491253
return self
12501254

1255+
@deprecated(
1256+
since="0.15.2",
1257+
removal="0.17.0",
1258+
name="Modelchain._prep_inputs_tracking",
1259+
alternative=None,
1260+
addendum=None,
1261+
)
12511262
def _prep_inputs_tracking(self):
12521263
"""
12531264
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: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,13 +8,15 @@
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,
12+
fail_on_pvlib_version)
1213

1314
from pvlib.location import Location
1415
from pvlib import clearsky
1516
from pvlib import solarposition
1617
from pvlib import atmosphere
1718
from pvlib import irradiance
19+
from pvlib._deprecation import pvlibDeprecationWarning
1820

1921
from .conftest import TESTS_DATA_DIR
2022

@@ -892,5 +894,13 @@ def test_bird():
892894
# XXX: testdata starts at 1am so noon is at index = 11
893895
np.allclose(
894896
[Eb3, Ebh3, Gh3, Dh3],
895-
testdata2[['Direct Beam', 'Direct Hz', 'Global Hz', 'Dif Hz']].iloc[11],
897+
testdata2[['Direct Beam', 'Direct Hz',
898+
'Global Hz', 'Dif Hz']].iloc[11],
896899
rtol=1e-3)
900+
901+
902+
@fail_on_pvlib_version('0.17.0')
903+
def test_is_leap_year_deprecation():
904+
with pytest.warns(pvlibDeprecationWarning,
905+
match='will be removed in 0.17.0.'):
906+
clearsky._is_leap_year(2020)

tests/test_irradiance.py

Lines changed: 9 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,11 @@ 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+
1460+
@fail_on_pvlib_version('0.17.0')
1461+
def test_liujordan_deprecation():
1462+
zenith = pd.Series([45.0, 50.0, 55.0])
1463+
with pytest.warns(pvlibDeprecationWarning,
1464+
match='will be removed in 0.17.0.'):
1465+
irradiance._liujordan(zenith, transmittance=0.7, airmass=1.5)

0 commit comments

Comments
 (0)