Skip to content
Merged
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
Original file line number Diff line number Diff line change
Expand Up @@ -83,26 +83,11 @@
"outputs": [],
"source": [
"grouped_by = frame.groupby([\"year\", \"technology\", \"region\"]).sum().reset_index()\n",
"grouped_by\n",
"\n",
"g = sns.FacetGrid(data=grouped_by, row=\"region\")\n",
"g.map(sns.lineplot, \"year\", \"capacity\", \"technology\")\n",
"g.add_legend()"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": []
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": []
}
],
"metadata": {
Expand Down
3 changes: 1 addition & 2 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ classifiers = [
"License :: OSI Approved :: GNU General Public License v3 (GPLv3)"
]
dependencies = [
"numpy<2.0",
"numpy>=2.0",
"scipy>=1.13",
"pandas>=2.2",
"xarray>=2024.6",
Expand All @@ -47,7 +47,6 @@ dev = [
"nbconvert",
"nbformat",
"mypy",
"numpy>=1.17",
"pytest-xdist",
"bump2version",
"pyinstaller",
Expand Down
21 changes: 7 additions & 14 deletions src/muse/mca.py
Original file line number Diff line number Diff line change
Expand Up @@ -372,7 +372,7 @@ def calibrate_legacy_sectors(self):
from copy import deepcopy
from logging import getLogger

from numpy import clip, where
from numpy import where

hist_years = []
if len([s for s in self.sectors if "LegacySector" in str(type(s))]) == 0:
Expand Down Expand Up @@ -405,12 +405,9 @@ def calibrate_legacy_sectors(self):

dims = {i: sector_market[i] for i in sector_market.consumption.dims}

sector_market.consumption.loc[dims] = clip(
sector_market.consumption.loc[dims]
- sector_market.supply.loc[dims],
0.0,
None,
)
sector_market.consumption.loc[dims] = (
sector_market.consumption.loc[dims] - sector_market.supply.loc[dims]
).clip(min=0.0, max=None)
new_market.consumption.loc[dims] += sector_market.consumption

dims = {i: sector_market[i] for i in sector_market.supply.dims}
Expand Down Expand Up @@ -450,8 +447,6 @@ def single_year_iteration(
"""
from copy import deepcopy

from numpy import clip

from muse.commodities import is_enduse

sectors = deepcopy(sectors)
Expand All @@ -469,11 +464,9 @@ def single_year_iteration(

dims = {i: sector_market[i] for i in sector_market.consumption.dims}

sector_market.consumption.loc[dims] = clip(
sector_market.consumption.loc[dims] - sector_market.supply.loc[dims],
0.0,
None,
)
sector_market.consumption.loc[dims] = (
sector_market.consumption.loc[dims] - sector_market.supply.loc[dims]
).clip(min=0.0, max=None)

market.consumption.loc[dims] += sector_market.consumption

Expand Down
5 changes: 4 additions & 1 deletion tests/test_carbon_budget.py
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,10 @@ def test_refine_new_price(market):
price = market.prices.sel(year=future, commodity=commodities).mean(
["region", "commodity"]
)
sample = np.linspace(price, 4 * price, 4)

# ensure price is a scalar before using it in np.linspace
price_value = price.item() if isinstance(price, xr.DataArray) else price
sample = np.linspace(price_value, 4 * price_value, 4)

carbon_price = market.prices.sel(
year=market.year < future, commodity=commodities
Expand Down