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

Issues displaying a crystal structure - related to site occupancies? #207

Closed
ayushsgupta opened this issue Jul 23, 2021 · 3 comments
Closed
Labels

Comments

@ayushsgupta
Copy link

I'm having some trouble displaying one particular structure (Fe5GeTe2.zip) in Jupyter Lab using crystal toolkit. Normally I can run a cell with just the pymatgen structure object, and crystal toolkit will automatically render the structure below the cell. However, with this specific structure all I receive is a printout of the structure object and the following error:

---------------------------------------------------------------------------
KeyError                                  Traceback (most recent call last)
~/miniconda3/envs/scan/lib/python3.8/site-packages/IPython/core/formatters.py in __call__(self, obj, include, exclude)
    968 
    969             if method is not None:
--> 970                 return method(include=include, exclude=exclude)
    971             return None
    972         else:

~/miniconda3/envs/scan/lib/python3.8/site-packages/crystal_toolkit/__init__.py in _repr_mimebundle_(self, include, exclude)
     56     if hasattr(self, "get_scene"):
     57         return {
---> 58             "application/vnd.mp.ctk+json": self.get_scene().to_json(),
     59             "text/plain": help_text_ct + self.__repr__(),
     60         }

~/miniconda3/envs/scan/lib/python3.8/site-packages/crystal_toolkit/renderables/structure.py in get_structure_scene(self, origin, legend, draw_image_atoms)
     97             )
     98 
---> 99         site_scene = site.get_scene(legend=legend,)
    100         for scene in site_scene.contents:
    101             primitives[scene.name] += scene.contents

~/miniconda3/envs/scan/lib/python3.8/site-packages/crystal_toolkit/renderables/site.py in get_site_scene(self, connected_sites, connected_sites_not_drawn, hide_incomplete_edges, incomplete_edge_length_scale, connected_sites_colors, connected_sites_not_drawn_colors, origin, draw_polyhedra, explicitly_calculate_polyhedra_hull, bond_radius, legend)
    105             positions=[position],
    106             color="#ffffff",
--> 107             radius=self.properties["display_radius"][0],
    108             phiStart=phiEnd,
    109             phiEnd=np.pi * 2,

KeyError: 'display_radius'

I've tried to trace back the error through the crystal toolkit source code, but unfortunately it's a bit beyond me. The problem appears to be that a site object in crystal toolkit lacks the "display_radius" property, but I'm not sure how this happens. Does it have to do with certain sites having occupancies of less than 1? I can load a different structure in the same notebook and it renders perfectly fine. I'm working with crystal toolkit version 2021.4.2, and JupyterLab version 3.1.0.

Even though other structures were rendering fine, I decided to update crystal toolkit to see if that solved the problem. I updated to version 2021.4.29 fine, but when I went to run jupyter labextension install crystaltoolkit-extension, I got the following error:

An error occured.
ValueError: The extension "crystaltoolkit-extension" does not yet support the current version of JupyterLab.


Conflicting Dependencies:
JupyterLab                        Extension              Package
>=3.1.0-alpha.4 <3.2.0            >=2.0.0 <3.0.0         @jupyterlab/rendermime-interfaces
See the log file for details:  /tmp/jupyterlab-debug-dad5s_b7.log

Any advice would be appreciated!

@mkhorton
Copy link
Member

Hi @ayushsgupta. Ok, two separate issues here.

  1. The current version of crystal toolkit only explicitly supports JupyterLab 3.x or above -- the extension installation is much simpler now, so you just have to pip install ... and jupyter labextension install ... is not required.

  2. It likely is a bug related to the partial occupancies, I will have to investigate.

@ayushsgupta
Copy link
Author

@mkhorton Okay, thanks for looking into it!

@mkhorton mkhorton added the bug label Jul 18, 2022
@mkhorton
Copy link
Member

Believe this was closed (see #234) but please re-open if not the case.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants