Skip to content

Commit

Permalink
correct dictionary format for normalizing
Browse files Browse the repository at this point in the history
These changes allow an archetype to pass a dictionary as
simple as {'commodity_name1':Resource1} as the
request portfolio, and it can be normalized as needed to
interact with the DRE properly
  • Loading branch information
abachma2 committed Jan 23, 2024
1 parent 711e2d3 commit afee0f8
Showing 1 changed file with 6 additions and 5 deletions.
11 changes: 6 additions & 5 deletions cyclus/lib.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -1837,7 +1837,7 @@ cpdef dict normalize_request_portfolio(object inp):
constrs = inp.get('constraints', [])
else:
commods = []
for name, reqs in inp:
for name, reqs in inp.items():
if name == 'preference' or name == 'exclusive':
continue
commods.append({name:reqs})
Expand All @@ -1855,10 +1855,11 @@ cpdef dict normalize_request_portfolio(object inp):
if isinstance(val, ts.Resource):
req = default_req.copy()
req['target'] = val
if 'preference' in inp['commodities'][index]:
req['preference'] = inp['commodities'][index]['preference']
if 'exclusive' in inp['commodities'][index]:
req['exclusive'] = inp['commodities'][index]['exclusive']
if 'commodities' in inp:
if 'preference' in inp['commodities'][index]:
req['preference'] = inp['commodities'][index]['preference']
if 'exclusive' in inp['commodities'][index]:
req['exclusive'] = inp['commodities'][index]['exclusive']
commods[index][key] = [req]

elif isinstance(val, Mapping):
Expand Down

0 comments on commit afee0f8

Please sign in to comment.