zotko/xyz2graph

ipython: Hang with 100% CPU on fig = to_plotly_figure(mg)

Closed this issue · 1 comments

ice1x commented
from xyz2graph import MolGraph, to_networkx_graph, to_plotly_figure
from plotly.offline import offline


mg = MolGraph()
mg.read_xyz("./xyz2graph/examples/dsgdb9nsd_030472.xyz")
fig = to_plotly_figure(mg)

Hang with 100% CPU consumption by Python 3.10 / 3.11 (macos 12.7.1 (21G920)).

KeyboardInterrupt                         Traceback (most recent call last)
Cell In[5], line 1
----> 1 fig = to_plotly_figure(mg)

File ~/miniconda3/envs/xyz2graph/lib/python3.11/site-packages/xyz2graph/helpers.py:165, in to_plotly_figure(graph)
     99     annotations_bonds.append(
    100         dict(
    101             text=round(length, 2),
   (...)
    108         )
    109     )
    111 updatemenus = list(
    112     [
    113         dict(
   (...)
    162     ]
    163 )
--> 165 data = [atom_trace(), bond_trace()]
    166 axis_params = dict(
    167     showgrid=False,
    168     showbackground=False,
   (...)
    171     titlefont=dict(color="white"),
    172 )
    173 layout = dict(
    174     scene=dict(
    175         xaxis=axis_params,
   (...)
    182     updatemenus=updatemenus,
    183 )

File ~/miniconda3/envs/xyz2graph/lib/python3.11/site-packages/xyz2graph/helpers.py:81, in to_plotly_figure.<locals>.bond_trace()
     79 for i, j in adjascent_atoms:
     80     trace["x"] += (graph.x[i], graph.x[j], None)
---> 81     trace["y"] += (graph.y[i], graph.y[j], None)
     82     trace["z"] += (graph.z[i], graph.z[j], None)
     83 return trace

File ~/miniconda3/envs/xyz2graph/lib/python3.11/site-packages/plotly/basedatatypes.py:4874, in BasePlotlyType.__setitem__(self, prop, value)
   4870         self._set_array_prop(prop, value)
   4872     # ### Handle simple property ###
   4873     else:
-> 4874         self._set_prop(prop, value)
   4875 else:
   4876     # Make sure properties dict is initialized
   4877     self._init_props()

File ~/miniconda3/envs/xyz2graph/lib/python3.11/site-packages/plotly/basedatatypes.py:5213, in BasePlotlyType._set_prop(self, prop, val)
   5210 validator = self._get_validator(prop)
   5212 try:
-> 5213     val = validator.validate_coerce(val)
   5214 except ValueError as err:
   5215     if self._skip_invalid:

File ~/miniconda3/envs/xyz2graph/lib/python3.11/site-packages/_plotly_utils/basevalidators.py:410, in DataArrayValidator.validate_coerce(self, v)
    408     v = copy_to_readonly_numpy_array(v)
    409 elif is_simple_array(v):
--> 410     v = to_scalar_or_list(v)
    411 else:
    412     self.raise_invalid_val(v)

File ~/miniconda3/envs/xyz2graph/lib/python3.11/site-packages/_plotly_utils/basevalidators.py:40, in to_scalar_or_list(v)
     38     return v.item()
     39 if isinstance(v, (list, tuple)):
---> 40     return [to_scalar_or_list(e) for e in v]
     41 elif np and isinstance(v, np.ndarray):
     42     if v.ndim == 0:

File ~/miniconda3/envs/xyz2graph/lib/python3.11/site-packages/_plotly_utils/basevalidators.py:40, in <listcomp>(.0)
     38     return v.item()
     39 if isinstance(v, (list, tuple)):
---> 40     return [to_scalar_or_list(e) for e in v]
     41 elif np and isinstance(v, np.ndarray):
     42     if v.ndim == 0:

File ~/miniconda3/envs/xyz2graph/lib/python3.11/site-packages/_plotly_utils/basevalidators.py:37, in to_scalar_or_list(v)
     35 np = get_module("numpy", should_load=False)
     36 pd = get_module("pandas", should_load=False)
---> 37 if np and np.isscalar(v) and hasattr(v, "item"):
     38     return v.item()
     39 if isinstance(v, (list, tuple)):

File ~/miniconda3/envs/xyz2graph/lib/python3.11/site-packages/numpy/core/numeric.py:1855, in isscalar(element)
   1851 def _frombuffer(buf, dtype, shape, order):
   1852     return frombuffer(buf, dtype=dtype).reshape(shape, order=order)
-> 1855 @set_module('numpy')
   1856 def isscalar(element):
   1857     """
   1858     Returns True if the type of `element` is a scalar type.
   1859 
   (...)
   1929 
   1930     """
   1931     return (isinstance(element, generic)
   1932             or type(element) in ScalarType
   1933             or isinstance(element, numbers.Number))

KeyboardInterrupt:```
zotko commented

@ice1x Could you please attach the .xyz file or a portion of it?