Skip to content

Commit

Permalink
Merge branch 'edsmall/no-data-error-message' into 'master'
Browse files Browse the repository at this point in the history
Edsmall/no data error message

See merge request bodc/owc-software-python!28
  • Loading branch information
edsmall-bodc committed May 12, 2020
2 parents 7a0ebbe + 96e1f26 commit bf75edc
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 12 deletions.
14 changes: 7 additions & 7 deletions ow_calibration/get_region/get_region_hist_locations.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
from ow_calibration.get_region.data_functions.get_data import get_data
from ow_calibration.get_region.data_functions.wrap_longitude import wrap_longitude


# pylint: disable=bare-except
def get_region_hist_locations(pa_wmo_numbers, pa_float_name, config):
"""
Expand Down Expand Up @@ -66,14 +67,13 @@ def get_region_hist_locations(pa_wmo_numbers, pa_float_name, config):

if grid_lat.__len__() == 0:

grid_lat = 999
grid_long = 999
grid_dates = 'NaN'
raise ValueError("get_region_hist_locations found no data for your specification. "
"Are your wmo_boxes files set up correctly?")


else:

grid_long = wrap_longitude(grid_long)
# decimalise dates
grid_dates = change_dates(grid_dates)
grid_long = wrap_longitude(grid_long)
# decimalise dates
grid_dates = change_dates(grid_dates)

return grid_lat, grid_long, grid_dates
10 changes: 5 additions & 5 deletions ow_calibration/get_region/get_region_hist_locations_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -84,12 +84,12 @@ def test_no_data(self):
print("Testing that get_region_hist_locations returns expected values for no data")

wmo_boxes_no_data = np.array([[3505, 0, 0, 0]])
lat_no_data, long_no_data, age_no_data = get_region_hist_locations(wmo_boxes_no_data,
'none',
self.config)

self.assertEqual(lat_no_data, long_no_data, "latitude and longitude should be equal (999)")
self.assertEqual(age_no_data, 'NaN', "age should be NaN")
with self.assertRaises(ValueError) as no_data:
get_region_hist_locations(wmo_boxes_no_data, 'none', self.config)

self.assertTrue('get_region_hist_locations found no data for your specification. '
'Are your wmo_boxes files set up correctly?' in str(no_data.exception))

def test_can_choose_data(self):
"""
Expand Down

0 comments on commit bf75edc

Please sign in to comment.