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

jupyter chemiscope.show fails when mode="map" and not all atoms are included in environments #391

Open
bernstei opened this issue Nov 12, 2024 · 1 comment
Labels
component-jupyter Issues related to the Jupyter widget component-map Issues related to the map component

Comments

@bernstei
Copy link
Collaborator

bernstei commented Nov 12, 2024

[edited - simplified, no need for the subset of atoms part]

I have a setup that works fine in the default show() mode. However, when I add mode="map", I get 2 errors:

unsupported per-atom property in a map-only viewer
Error: could not find enough structure properties to display, but there are atom properties. Please provide the environment list to display them
import numpy as np
from ase.atoms import Atoms
from chemiscope import extract_properties, show

all_atoms = [Atoms('HHe') for _ in range(2)]
for at_i, atoms in enumerate(all_atoms):
    atoms.new_array("map", np.asarray([[at_i + 1, 0, 0], [at_i + 1, at_i + 1, at_i + 1]]))
    atoms.new_array("config_type", np.asarray([str(at_i)] * len(atoms)))

envs = []
for atoms_i, atoms in enumerate(all_atoms):
    envs.extend([(atoms_i, ind, 3.5) for ind in range(len(atoms))])
print("envs", envs)

property_names = ["config_type", "map"]
properties = extract_properties(all_atoms, only=property_names, environments=envs)
print(properties)

viz_map = {"x": {"property": "map" + "[1]"},
           "y": {"property": "map" + "[2]"},
           "z": {"property": "map" + "[3]"},
           "color": {"property": "config_type", "min": 0, "max": 10},
           # "palette": "tab10",
           "size": {"mode": "constant", "factor": 10},
           "symbol": "config_type"
          }

# works
show(all_atoms, properties=properties, environments=envs,
    settings={"structure": [{"supercell": [3, 3, 3]}], "map": viz_map})
print("OK so far")

# fails
show(all_atoms, properties=properties, environments=envs,
     settings={"structure": [{"supercell": [3, 3, 3]}], "map": viz_map},
     mode="map")
@bernstei
Copy link
Collaborator Author

The first error message seems to suggest that I can't have a per-atom property in a map-only viewer, and the second that the per-atom properties are OK, but that the environments are getting ignored (which in principle would make sense since there's no structure viewer, but doesn't make sense here since that's how the per-atom properties are linked to map points).

@Luthaf Luthaf added component-map Issues related to the map component component-jupyter Issues related to the Jupyter widget labels Nov 13, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
component-jupyter Issues related to the Jupyter widget component-map Issues related to the map component
Projects
None yet
Development

No branches or pull requests

2 participants