Skip to content

printing MIME type is not handled correctly for graphs #205

Closed
@Roger-luo

Description

@Roger-luo

to reproduce

pip install bloqade

and run

In [2]: import bloqade

In [3]: bloqade.unit_disk_graph([1, 2, 3])
Out[3]: ---------------------------------------------------------------------------
JuliaError                                Traceback (most recent call last)
File ~/conda/lib/python3.9/site-packages/IPython/core/formatters.py:973, in MimeBundleFormatter.__call__(self, obj, include, exclude)
    970     method = get_real_method(obj, self.print_method)
    972     if method is not None:
--> 973         return method(include=include, exclude=exclude)
    974     return None
    975 else:

File ~/.julia/packages/PythonCall/d8Xcl/src/jlwrap/any.jl:302, in _repr_mimebundle_(self, include, exclude)
    300         return self._jl_callmethod($(pyjl_methodnum(pyjlany_help)), mime)
    301     def _repr_mimebundle_(self, include=None, exclude=None):
--> 302         return self._jl_callmethod($(pyjl_methodnum(pyjlany_mimebundle)), include, exclude)
    303 """, @__FILE__(), "exec"), jl.__dict__)
    304 pycopy!(pyjlanytype, jl.AnyValue)

JuliaError: type UnionAll has no field parameters
Stacktrace:
 [1] getproperty
   @ ./Base.jl:37 [inlined]
 [2] mimes_for(x::Any)
   @ PythonCall.Utils ~/.julia/packages/PythonCall/d8Xcl/src/utils.jl:93
 [3] pyjlany_mimebundle(self::Graphs.SimpleGraphs.SimpleGraph{Int64}, include::Py, exclude::Py)
   @ PythonCall ~/.julia/packages/PythonCall/d8Xcl/src/jlwrap/any.jl:152
 [4] _pyjl_callmethod(f::Any, self_::Ptr{PythonCall.C.PyObject}, args_::Ptr{PythonCall.C.PyObject}, nargs::Int64)
   @ PythonCall ~/.julia/packages/PythonCall/d8Xcl/src/jlwrap/base.jl:69
 [5] _pyjl_callmethod(o::Ptr{PythonCall.C.PyObject}, args::Ptr{PythonCall.C.PyObject})
   @ PythonCall.C ~/.julia/packages/PythonCall/d8Xcl/src/cpython/jlwrap.jl:47
<jl Graphs.SimpleGraphs.SimpleGraph{Int64}(2, [[2], [1, 3], [2]])>

This seems due to src/utils.jl:93 doesn't handle UnionAll, I'm not sure what would be the right way to fix it tho

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions