Skip to content

It is hard to merge two LocalConfigurationLists #52

Description

@xivh

LocalConfigurationList.from_dict makes a new OccEventSymInfo, so it is not possible to directly check or insert new local configurations into the list.

The equality check between the two objects fails, but they can be compared with to_data.

if value.event_info is not self.event_info:

This is an example of how I merge an old enumeration with a new one

# merge local_config_list.json
local_config_list_file = enum_data.enum_dir / 'local_config_list.json'
local_config_list = localconf.LocalConfigurationList(
    event_info=event_info_dict[event_name]
)
if local_config_list_file.exists():
    orig_local_config_list = localconf.LocalConfigurationList.from_dict(
        data=json_io.read_required(local_config_list_file),
        prim=project.prim,
        system=occ_system,
        supercells=supercell_set
    )
    assert orig_local_config_list.event_info.to_data() == new_event_info.to_data()
    for local_config in orig_local_config_list:
        local_config = localconf.LocalConfiguration.from_dict(
            data=local_config.to_dict(),
            supercells=supercell_set,
            event_info=new_event_info
        )
        local_config_list.append(local_config)
initial_local_configs = len(local_config_list)
for local_config in new_local_config_list:
    if local_config not in local_config_list:
        local_config_list.append(local_config)
print(f'Found {len(local_config_list)} ({len(local_config_list) - initial_local_configs} new) configurations')
json_io.safe_dump(
    data=local_config_list.to_dict(),
    path=local_config_list_file,
    force=True
)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions