Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 5 additions & 2 deletions agrifoodpy/food/food.py
Original file line number Diff line number Diff line change
Expand Up @@ -71,13 +71,16 @@ def FoodSupply(
"Year": _years}

# find positions in output array to organize data
ii = [np.searchsorted(_items, items), np.searchsorted(_years, years)]
ii = [
np.atleast_1d(np.searchsorted(_items, items)),
np.atleast_1d(np.searchsorted(_years, years))
]
size = (len(_items), len(_years))

# If regions and are provided, add the coordinate information
if regions is not None:
_regions = np.unique(regions)
ii.append(np.searchsorted(_regions, regions))
ii.append(np.atleast_1d(np.searchsorted(_regions, regions)))
size = size + (len(_regions),)
coords["Region"] = _regions

Expand Down
14 changes: 9 additions & 5 deletions agrifoodpy/food/tests/test_food.py
Original file line number Diff line number Diff line change
Expand Up @@ -474,11 +474,15 @@ def test_plot_bars():

def test_plot_years():

da = xr.DataArray(np.arange(15).reshape(5,3),
coords=[('Year', [2010, 2011, 2012, 2013, 2014]),
('Region', ['A', 'B', 'C'])],
dims=['Year', 'Region'])

years = [2019, 2010, 2011, 2012, 2013, 2014]
regions = ['A', 'B', 'C']

da = xr.DataArray(
np.arange(len(years)*len(regions)).reshape(len(years), len(regions)),
coords=[('Year', years),
('Region', regions)],
dims=['Year', 'Region'])

fbs = FoodElementSheet(da)

# Test default call
Expand Down
4 changes: 2 additions & 2 deletions agrifoodpy/land/land.py
Original file line number Diff line number Diff line change
Expand Up @@ -277,8 +277,8 @@ def category_match(

shape = map_left.shape

left_match = np.in1d(map_left, values_left).reshape(shape)
right_match = np.in1d(map_right, values_right).reshape(shape)
left_match = np.isin(map_left, values_left).reshape(shape)
right_match = np.isin(map_right, values_right).reshape(shape)

category_match = map_left.where(left_match).where(right_match)

Expand Down
2 changes: 1 addition & 1 deletion tox.ini
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ requires =
tox-conda
setuptools
envlist =
py{39,310}-test{,-latest,-oldest}
py{39,310,311,312,313,314}
build_docs

[testenv]
Expand Down
Loading