JSON serialization error

Ouverte
#240 2 commentaires 2 réactions 1 personne assignée Voir sur GitHub

@ayjayt y travaille déjà.

Depuis le 10/1/2025.

Évaluation

Cette issue n'a pas encore été évaluée.

Description

P1

With Kaleido 1.0.0rc0, running the skimage gallery example below, I see the following error:

  File "/home/stefan/envs/py313/lib64/python3.13/site-packages/kaleido/__init__.py", line 129, in to_image
    response = await tab.send_command("Runtime.callFunctionOn", params=params)
               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/lib64/python3.13/concurrent/futures/thread.py", line 59, in run
    result = self.fn(*self.args, **self.kwargs)
  File "/home/stefan/envs/py313/lib64/python3.13/site-packages/choreographer/pipe.py", line 56, in write_json
    message = simplejson.dumps(obj, ensure_ascii=False, ignore_nan=True, cls=self.json_encoder)
  File "/home/stefan/envs/py313/lib64/python3.13/site-packages/simplejson/__init__.py", line 395, in dumps
    **kw).encode(obj)
          ~~~~~~^^^^^
  File "/home/stefan/envs/py313/lib64/python3.13/site-packages/simplejson/encoder.py", line 298, in encode
    chunks = self.iterencode(o)
  File "/home/stefan/envs/py313/lib64/python3.13/site-packages/simplejson/encoder.py", line 379, in iterencode
    return _iterencode(o, 0)
  File "/home/stefan/envs/py313/lib64/python3.13/site-packages/choreographer/pipe.py", line 34, in default
    return simplejson.JSONEncoder.default(self, obj)
           ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^^^^^^^^^^^
  File "/home/stefan/envs/py313/lib64/python3.13/site-packages/simplejson/encoder.py", line 274, in default
    raise TypeError('Object of type %s is not JSON serializable' %
                    o.__class__.__name__)
TypeError: Object of type uint16 is not JSON serializable

I first picked this up on CI, where the same thing happened.

import plotly.express as px
import plotly.io

plotly.io.renderers.default = "sphinx_gallery_png"

import skimage as ski

data = ski.data.kidney()

n_plane, n_row, n_col, n_chan = data.shape
v_min, v_max = data[:, :, :, 1].min(), data[:, :, :, 1].max()
print(f'range: ({v_min}, {v_max})')

fig1 = px.imshow(
    data[n_plane // 2, :, :, 1],
    zmin=v_min,
    zmax=v_max,
    labels={'x': 'col', 'y': 'row', 'color': 'intensity'},
)

plotly.io.show(fig1)
Langage dominant
Python
Étoiles
504
Forks
65
Merge moyen
6 j 9 h
PR mergées (30 j)
2

Préparer son environnement

Ce projet ne fournit ni conteneur de développement, ni Dockerfile, ni guide de contribution : l'installation est à votre charge. Commencez par son README, et consultez notre guide de la première contribution pour les étapes générales.

Par où commencer

  1. Lisez l'issue en entier, puis le guide de contribution du projet.
  2. Signalez en commentaire que vous la prenez — cela évite que deux personnes fassent le même travail.
  3. Forkez le dépôt et travaillez sur une branche.
  4. Ouvrez une pull request qui référence le numéro de l'issue.

Autres issues de plotly/kaleido

Toutes les issues de plotly/kaleido

Issues similaires

Plus d'issues Python

Recevez les nouvelles issues par e-mail

Un résumé court des issues GitHub adaptées aux débutants.