TypeError: unsupported operand type(s) for -: 'str' and 'float'

27 views
Skip to first unread message

Alexander Kell

unread,
Mar 22, 2022, 7:55:04 AM3/22/22
to MUSE
I found the error pasted below. 



-- 2022-03-22 11:04:40 - muse.sectors.sector - INFO
Running ELC for year 2050

-- 2022-03-22 11:04:40 - muse.interactions - INFO
Net new_to_retro of 1 interactions interacting via transfer

-- 2022-03-22 11:04:40 - muse.hooks - INFO
Computing initial_asset_transform: default

-- 2022-03-22 11:04:40 - muse.hooks - INFO
Computing initial_asset_transform: clean

-- 2022-03-22 11:04:40 - muse.demand_share - INFO
Computing demand_share: default

-- 2022-03-22 11:04:40 - muse.production - INFO
Computing production: max

-- 2022-03-22 11:04:40 - muse.production - INFO
Computing production: max

-- 2022-03-22 11:04:40 - muse.filters - INFO
Computing initial search-space: from_techs

-- 2022-03-22 11:04:40 - muse.filters - INFO
Computing filter: all

-- 2022-03-22 11:04:40 - muse.filters - INFO
Computing filter: with_asset_technology

-- 2022-03-22 11:04:40 - muse.filters - INFO
Computing filter: compress

-- 2022-03-22 11:04:40 - muse.objectives - INFO
Computing objective: LCOE

-- 2022-03-22 11:04:40 - muse.objectives - INFO
Computing objective: capacity

-- 2022-03-22 11:04:40 - muse.decisions - INFO
Computing decision: single

Traceback (most recent call last):
  File "/opt/anaconda3/envs/muse-os/lib/python3.8/runpy.py", line 194, in _run_module_as_main
    return _run_code(code, main_globals, None,
  File "/opt/anaconda3/envs/muse-os/lib/python3.8/runpy.py", line 87, in _run_code
    exec(code, run_globals)
  File "/Users/alexanderkell/GitHub/SGI/7-MUSE_OS/src/muse/__main__.py", line 55, in <module>
    muse_main()
  File "/Users/alexanderkell/.local/lib/python3.8/site-packages/click/core.py", line 1128, in __call__
    return self.main(*args, **kwargs)
  File "/Users/alexanderkell/.local/lib/python3.8/site-packages/click/core.py", line 1053, in main
    rv = self.invoke(ctx)
  File "/Users/alexanderkell/.local/lib/python3.8/site-packages/click/core.py", line 1395, in invoke
    return ctx.invoke(self.callback, **ctx.params)
  File "/Users/alexanderkell/.local/lib/python3.8/site-packages/click/core.py", line 754, in invoke
    return __callback(*args, **kwargs)
  File "/Users/alexanderkell/GitHub/SGI/7-MUSE_OS/src/muse/__main__.py", line 52, in muse_main
    MCA.factory(settings).run()
  File "/Users/alexanderkell/GitHub/SGI/7-MUSE_OS/src/muse/mca.py", line 342, in run
    _, new_market, self.sectors = self.find_equilibrium(new_market)
  File "/Users/alexanderkell/GitHub/SGI/7-MUSE_OS/src/muse/mca.py", line 204, in find_equilibrium
    return find_equilibrium(
  File "/Users/alexanderkell/GitHub/SGI/7-MUSE_OS/src/muse/mca.py", line 554, in find_equilibrium
    market, equilibrium_sectors = single_year_iteration(market, sectors)
  File "/Users/alexanderkell/GitHub/SGI/7-MUSE_OS/src/muse/mca.py", line 461, in single_year_iteration
    sector_market = sector.next(
  File "/Users/alexanderkell/GitHub/SGI/7-MUSE_OS/src/muse/sectors/sector.py", line 232, in next
    subsector.invest(
  File "/Users/alexanderkell/GitHub/SGI/7-MUSE_OS/src/muse/sectors/subsector.py", line 74, in invest
    lp_problem = self.aggregate_lp(
  File "/Users/alexanderkell/GitHub/SGI/7-MUSE_OS/src/muse/sectors/subsector.py", line 147, in aggregate_lp
    result = agent.next(
  File "/Users/alexanderkell/GitHub/SGI/7-MUSE_OS/src/muse/agents/agent.py", line 412, in next
    constraints = self.constraints(
  File "/Users/alexanderkell/GitHub/SGI/7-MUSE_OS/src/muse/constraints.py", line 258, in constraints
    constraints = [
  File "/Users/alexanderkell/GitHub/SGI/7-MUSE_OS/src/muse/constraints.py", line 259, in <listcomp>
    function(demand, assets, search_space, market, technologies, year=year)
  File "/Users/alexanderkell/GitHub/SGI/7-MUSE_OS/src/muse/registration.py", line 172, in decorated
    result = inner_decorated(*args, **kwargs)
  File "/Users/alexanderkell/GitHub/SGI/7-MUSE_OS/src/muse/constraints.py", line 186, in decorated
    constraint = function(  # type: ignore
  File "/Users/alexanderkell/GitHub/SGI/7-MUSE_OS/src/muse/constraints.py", line 368, in max_capacity_expansion
    total_cap = (limit - forecasted).clip(min=0).rename("total_cap")
  File "/Users/alexanderkell/.local/lib/python3.8/site-packages/xarray/core/_typed_ops.py", line 209, in __sub__
    return self._binary_op(other, operator.sub)
  File "/Users/alexanderkell/.local/lib/python3.8/site-packages/xarray/core/dataarray.py", line 3098, in _binary_op
    f(self.variable, other_variable)
  File "/Users/alexanderkell/.local/lib/python3.8/site-packages/xarray/core/_typed_ops.py", line 399, in __sub__
    return self._binary_op(other, operator.sub)
  File "/Users/alexanderkell/.local/lib/python3.8/site-packages/xarray/core/variable.py", line 2467, in _binary_op
    f(self_data, other_data) if not reflexive else f(other_data, self_data)
TypeError: unsupported operand type(s) for -: 'str' and 'float'

Alexander Kell

unread,
Mar 22, 2022, 7:57:26 AM3/22/22
to MUSE
I found that this was because there was a comma in theMaxCapacityAddition number. This led to the number being presented as a string (str) and not a number (float) as per the error message, such as this: "40,000". The number should be entered as 40000 without the comma and quotation marks. This can be put in automatically by the text editor you use, such as excel. It is best to use textedit, notepad or something similar to see how the data are presented.
Reply all
Reply to author
Forward
0 new messages