Skip to content

Commit

Permalink
download combined gradients
Browse files Browse the repository at this point in the history
  • Loading branch information
rugeli committed Jul 16, 2024
1 parent 167b702 commit f3e7108
Showing 1 changed file with 14 additions and 4 deletions.
18 changes: 14 additions & 4 deletions cellpack/autopack/DBRecipeHandler.py
Original file line number Diff line number Diff line change
Expand Up @@ -713,10 +713,20 @@ def _get_grad_and_obj(obj_data, obj_dict, grad_dict):
obj_name = obj_data["name"]
for key, target_dict in CompositionDoc.KEY_TO_DICT_MAPPING.items():
if key in obj_data:
item_name = obj_data[key]["name"]
target_dict = grad_dict if key == "gradient" else obj_dict
target_dict[item_name] = obj_data[key]
obj_dict[obj_name][key] = item_name
# single gradient and inherited object
if isinstance(obj_data[key], dict):
item_name = obj_data[key]["name"]
target_dict = grad_dict if key == "gradient" else obj_dict
target_dict[item_name] = obj_data[key]
obj_dict[obj_name][key] = item_name
# combined gradients
elif key == "gradient" and isinstance(obj_data[key], list):
new_grad_list = []
for grad in obj_data[key]:
for name in grad:
grad_dict[name] = grad[name]
new_grad_list.append(name)
obj_dict[obj_name][key] = new_grad_list
return obj_dict, grad_dict

@staticmethod
Expand Down

0 comments on commit f3e7108

Please sign in to comment.