Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

allow merge_section to merge children classes #143

Open
wants to merge 4 commits into
base: main
Choose a base branch
from
Open
Changes from 1 commit
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
16 changes: 8 additions & 8 deletions src/nomad_measurements/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -100,19 +100,19 @@ def merge_sections( # noqa: PLR0912
logger.warning(warning)
else:
print(warning)
for name, sub_section_def in update.m_def.all_sub_sections.items():
count = section.m_sub_section_count(sub_section_def)
for name, _ in update.m_def.all_sub_sections.items():
count = section.m_sub_section_count(name)
if count == 0:
for update_sub_section in update.m_get_sub_sections(sub_section_def):
section.m_add_sub_section(sub_section_def, update_sub_section)
elif count == update.m_sub_section_count(sub_section_def):
for update_sub_section in update.m_get_sub_sections(name):
section.m_add_sub_section(name, update_sub_section)
elif count == update.m_sub_section_count(name):
for i in range(count):
merge_sections(
section.m_get_sub_section(sub_section_def, i),
update.m_get_sub_section(sub_section_def, i),
section.m_get_sub_section(name, i),
update.m_get_sub_section(name, i),
logger,
)
elif update.m_sub_section_count(sub_section_def) > 0:
elif update.m_sub_section_count(name) > 0:
warning = (
f'Merging sections with different number of "{name}" sub sections.'
)
Expand Down
Loading