Skip to content

Commit 8aee6cd

Browse files
Revert to just pyproject.toml changes (no zoneinfo changes)
1 parent 9b3dbf4 commit 8aee6cd

17 files changed

+109
-329
lines changed

ci/requirements-py3.10.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ dependencies:
1919
- pytest-rerunfailures
2020
- conda-forge::pytest-remotedata # version in default channel is old
2121
- python=3.10
22-
# - pytz
22+
- pytz
2323
- requests
2424
- scipy >= 1.6.0
2525
- statsmodels

ci/requirements-py3.11.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ dependencies:
1919
- pytest-rerunfailures
2020
- conda-forge::pytest-remotedata # version in default channel is old
2121
- python=3.11
22-
# - pytz
22+
- pytz
2323
- requests
2424
- scipy >= 1.6.0
2525
- statsmodels

ci/requirements-py3.12.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ dependencies:
1919
- pytest-rerunfailures
2020
- conda-forge::pytest-remotedata # version in default channel is old
2121
- python=3.12
22-
# - pytz
22+
- pytz
2323
- requests
2424
- scipy >= 1.6.0
2525
- statsmodels

ci/requirements-py3.9-min.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ dependencies:
99
- pytest-mock
1010
- pytest-timeout
1111
- python=3.9
12-
# - pytz
12+
- pytz
1313
- requests
1414
- pip:
1515
- h5py==3.0.0

ci/requirements-py3.9.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ dependencies:
1919
- pytest-rerunfailures
2020
- conda-forge::pytest-remotedata # version in default channel is old
2121
- python=3.9
22-
# - pytz
22+
- pytz
2323
- requests
2424
- scipy >= 1.6.0
2525
- statsmodels

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

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

1919
Testing
2020
~~~~~~~
21-
* Add tests for time conversions in tools package. (:issue:`2340`, :pull:`2341`)
2221

2322

2423
Requirements
@@ -27,4 +26,5 @@ Requirements
2726

2827
Contributors
2928
~~~~~~~~~~~~
30-
* Mark Campanellli (:ghuser:`markcampanelli`)
29+
30+

docs/tutorials/solarposition.ipynb

Lines changed: 16 additions & 16 deletions
Large diffs are not rendered by default.

pvlib/iotools/pvgis.py

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -17,12 +17,10 @@
1717
import io
1818
import json
1919
from pathlib import Path
20-
from zoneinfo import ZoneInfo
21-
2220
import requests
2321
import numpy as np
2422
import pandas as pd
25-
23+
import pytz
2624
from pvlib.iotools import read_epw, parse_epw
2725

2826
URL = 'https://re.jrc.ec.europa.eu/api/'
@@ -400,10 +398,10 @@ def _coerce_and_roll_tmy(tmy_data, tz, year):
400398
re-interpreted as zero / UTC.
401399
"""
402400
if tz:
403-
tzname = ZoneInfo(f'Etc/GMT{-tz:+d}')
401+
tzname = pytz.timezone(f'Etc/GMT{-tz:+d}')
404402
else:
405403
tz = 0
406-
tzname = ZoneInfo('UTC')
404+
tzname = pytz.timezone('UTC')
407405
new_index = pd.DatetimeIndex([
408406
timestamp.replace(year=year, tzinfo=tzname)
409407
for timestamp in tmy_data.index],

pvlib/location.py

Lines changed: 31 additions & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -4,16 +4,14 @@
44

55
# Will Holmgren, University of Arizona, 2014-2016.
66

7-
import datetime
87
import pathlib
9-
from zoneinfo import ZoneInfo
8+
import datetime
109

11-
import h5py
1210
import pandas as pd
13-
# import pytz
11+
import pytz
12+
import h5py
1413

15-
from pvlib import atmosphere, clearsky, irradiance, solarposition
16-
# from pvlib._deprecation import warn_deprecated
14+
from pvlib import solarposition, clearsky, atmosphere, irradiance
1715
from pvlib.tools import _degrees_to_index
1816

1917

@@ -23,12 +21,10 @@ class Location:
2321
timezone, and altitude data associated with a particular
2422
geographic location. You can also assign a name to a location object.
2523
26-
Location objects have one timezone attribute:
27-
28-
* ``tz`` is a IANA-compatible standard-library zoneinfo.ZoneInfo.
24+
Location objects have two timezone attributes:
2925
30-
Thus, the passed timezone must be representable by one of the values in
31-
zoneinfo.available_timezones().
26+
* ``tz`` is a IANA timezone string.
27+
* ``pytz`` is a pytz timezone object.
3228
3329
Location objects support the print method.
3430
@@ -42,13 +38,12 @@ class Location:
4238
Positive is east of the prime meridian.
4339
Use decimal degrees notation.
4440
45-
tz : str, int, float, zoneinfo.ZoneInfo, datetime.timezone, or pytz
46-
timezone (deprecated), default 'UTC'.
47-
See http://en.wikipedia.org/wiki/List_of_tz_database_time_zones for a
48-
list of valid time zone strings, or use the function
49-
zoneinfo.available_timezones().
50-
ints and floats must be in hours N from UTC, and are converted to the
51-
Etc/GMT+N or Etc/GMT-N format depending on the sign of N.
41+
tz : str, int, float, or pytz.timezone, default 'UTC'.
42+
See
43+
http://en.wikipedia.org/wiki/List_of_tz_database_time_zones
44+
for a list of valid time zones.
45+
pytz.timezone objects will be converted to strings.
46+
ints and floats must be in hours from UTC.
5247
5348
altitude : float, optional
5449
Altitude from sea level in meters.
@@ -64,43 +59,33 @@ class Location:
6459
pvlib.pvsystem.PVSystem
6560
"""
6661

67-
def __init__(
68-
self, latitude, longitude, tz='UTC', altitude=None, name=None
69-
):
70-
71-
if name is None:
72-
name = ""
73-
74-
self.name = name
62+
def __init__(self, latitude, longitude, tz='UTC', altitude=None,
63+
name=None):
7564

7665
self.latitude = latitude
7766
self.longitude = longitude
7867

68+
if isinstance(tz, str):
69+
self.tz = tz
70+
self.pytz = pytz.timezone(tz)
71+
elif isinstance(tz, datetime.timezone):
72+
self.tz = 'UTC'
73+
self.pytz = pytz.UTC
74+
elif isinstance(tz, datetime.tzinfo):
75+
self.tz = tz.zone
76+
self.pytz = tz
77+
elif isinstance(tz, (int, float)):
78+
self.tz = tz
79+
self.pytz = pytz.FixedOffset(tz*60)
80+
else:
81+
raise TypeError('Invalid tz specification')
82+
7983
if altitude is None:
8084
altitude = lookup_altitude(latitude, longitude)
8185

8286
self.altitude = altitude
8387

84-
if isinstance(tz, str):
85-
self.tz = ZoneInfo(tz)
86-
elif isinstance(tz, int):
87-
self.tz = ZoneInfo(f"Etc/GMT{-tz:+d}")
88-
elif isinstance(tz, float):
89-
self.tz = ZoneInfo(f"Etc/GMT{int(-tz):+d}")
90-
elif isinstance(tz, ZoneInfo):
91-
self.tz = tz
92-
elif isinstance(tz, datetime.timezone):
93-
self.tz = ZoneInfo(str(tz))
94-
# elif isinstance(tz, pytz.BaseTzInfo):
95-
# warn_deprecated(
96-
# "0.11.3",
97-
# message='pytz-based timezones are deprecated for locations',
98-
# alternative='use zoneinfo.ZoneInfo from standard library',
99-
# obj_type='function argument type',
100-
# )
101-
# self.tz = ZoneInfo(tz.zone)
102-
else:
103-
raise TypeError(f'Invalid tz specification: {tz}')
88+
self.name = name
10489

10590
def __repr__(self):
10691
attrs = ['name', 'latitude', 'longitude', 'altitude', 'tz']

pvlib/temperature.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
import numpy as np
77
import pandas as pd
88
from pvlib.tools import sind
9+
from pvlib._deprecation import warn_deprecated
910
from pvlib.tools import _get_sample_intervals
1011
import scipy
1112
import scipy.constants

0 commit comments

Comments
 (0)