JSON serialization error

オープン
#240 コメント 2 件 リアクション 2 件 担当者 1 名 GitHub で見る

@ayjayt がすでに取り組んでいます。

2025年1月10日 から。

評価

この issue はまだ評価されていません。

説明

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)
主要言語
Python
スター
504
フォーク
65
平均マージ
6日 9時間
マージ済み PR(30日)
2

環境構築

このプロジェクトには開発コンテナ、Dockerfile、コントリビューションガイドがありません。まず README を読み、一般的な手順ははじめてのコントリビューションガイドを参照してください。

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

plotly/kaleido のほかの issue

plotly/kaleido の issue をすべて見る

似ている issue

Python の issue をもっと見る

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。