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

Structure.merge_sites fails when selective_dynamics is property present #4197

Open
yantar92 opened this issue Nov 25, 2024 · 1 comment · May be fixed by #4198
Open

Structure.merge_sites fails when selective_dynamics is property present #4197

yantar92 opened this issue Nov 25, 2024 · 1 comment · May be fixed by #4198
Labels

Comments

@yantar92
Copy link
Contributor

Python version

Python 3.12.7

Pymatgen version

Version: 2024.10.22

Operating system version

No response

Current behavior

Error is thrown when I try to run merge_sites.

Traceback (most recent call last):
File "", line 1, in
File "/home/yantar92/.venv/lib/python3.12/site-packages/pymatgen/core/structure.py", line 4604, in merge_sites
if props[key] is not None and self[i].properties[key] != props[key]:
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
ValueError: The truth value of an array with more than one element is ambiguous. Use a.any() or a.all()

Expected Behavior

merge_sites works without errors :)

Minimal example

import pymatgen.core as pmg
str1 = pmg.Structure.from_file('POSCAR1')
str2 = pmg.Structure.from_file('POSCAR2')
merge = str1.copy()
for site in str2:
    merge.append(site.species, site.frac_coords, properties=site.properties)
merge.merge_sites(mode='average')

Relevant files to reproduce this bug

POSCAR2.gz
POSCAR1.gz

@yantar92 yantar92 added the bug label Nov 25, 2024
@DanielYang59
Copy link
Contributor

Thanks for reporting and for including a code snippet again, I would take care of this

@DanielYang59 DanielYang59 linked a pull request Nov 25, 2024 that will close this issue
2 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants