Skip to content

Commit fa58dbd

Browse files
author
Emlyn Price
authored
Merge branch 'master' into tidy_id_and_api_key
2 parents ac30272 + 0620481 commit fa58dbd

File tree

3 files changed

+8
-8
lines changed

3 files changed

+8
-8
lines changed

CHANGELOG.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,8 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/).
55
## [Unreleased]
66

77
+ Remove deprecated `new_old` and `future_old` functions.
8-
+ Add `__str__` functions to `Timestep`, `Element`, `Day`, `Site`.
8+
+ Add `__str__` functions to `Timestep`, `Element`, `Day`, `Site`
9+
+ Add element to `Forecast` to track if forecast is daily or 3 hourly
910
+ Change `id` variable in `Forecast`, `Observation`, `Site` to `location_id`.
1011
+ Change `id` variable in `Element` to `field_code`.
1112

datapoint/Manager.py

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -304,7 +304,7 @@ def get_nearest_forecast_site(self, latitude, longitude):
304304
float(longitude),
305305
float(latitude))
306306

307-
if ((distance == None) or (new_distance < distance)):
307+
if ((distance is None) or (new_distance < distance)):
308308
distance = new_distance
309309
nearest = site
310310

@@ -327,13 +327,13 @@ def get_forecast_for_site(self, site_id, frequency="daily"):
327327
"""
328328
data = self.__call_api(site_id, {"res": frequency})
329329
params = data['SiteRep']['Wx']['Param']
330-
forecast = Forecast()
330+
forecast = Forecast(frequency=frequency)
331331

332332
# If the 'Location' key is missing, there is no data for the site,
333333
# raise an error.
334334
if 'Location' not in data['SiteRep']['DV']:
335335
err_string = ('DataPoint has not returned any data for the'
336-
'requested site.' )
336+
'requested site.')
337337
raise APIException(err_string)
338338

339339
# Check if the other keys we need are in the data returned from the
@@ -456,7 +456,6 @@ def get_forecast_for_site(self, site_id, frequency="daily"):
456456

457457
return forecast
458458

459-
460459
def get_observation_sites(self):
461460
"""
462461
This function returns a list of Site objects for which observations are available.
@@ -528,7 +527,7 @@ def get_observations_for_site(self, site_id, frequency='hourly'):
528527
Returns hourly observations for the previous 24 hours
529528
"""
530529

531-
data = self.__call_api(site_id,{"res":frequency}, OBSERVATION_URL)
530+
data = self.__call_api(site_id,{"res": frequency}, OBSERVATION_URL)
532531

533532
params = data['SiteRep']['Wx']['Param']
534533
observation = Observation()

tests/unit/test_forecast.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
class TestForecast(unittest.TestCase):
77

88
def setUp(self):
9-
self.forecast_3hrly = datapoint.Forecast.Forecast()
9+
self.forecast_3hrly = datapoint.Forecast.Forecast(frequency='3hourly')
1010

1111
test_day_0 = datapoint.Day.Day()
1212
test_day_0.date = datetime.datetime(2020, 3, 3, tzinfo=datetime.timezone.utc)
@@ -47,7 +47,7 @@ def setUp(self):
4747
ts.date = datetime.datetime(2020, 3, 4, 2*i, tzinfo=datetime.timezone.utc)
4848
test_day_1.timesteps.append(ts)
4949

50-
self.forecast_daily = datapoint.Forecast.Forecast()
50+
self.forecast_daily = datapoint.Forecast.Forecast(frequency='daily')
5151

5252
self.forecast_daily.days.append(test_day_0)
5353
self.forecast_daily.days.append(test_day_1)

0 commit comments

Comments
 (0)