Skip to content

jdata.encode not working for np.complex64 scalar #2

@tyu-mit

Description

@tyu-mit

For scalar values of np.complex64 type, encoder does not process it correctly.

Example:

import numpy as np
import jdata as jd

x = {"a": np.complex64(1+1j)}
enc_x = jd.encode(x)
print(enc_x)

Expected behavior:

{'a': {'_ArrayType_': 'single',
  '_ArraySize_': 1,
  '_ArrayIsComplex_': True,
  '_ArrayData_': [1.0, 1.0]}}

Actual behavior:

{'a': (1+1j)}

Suggested change:

Add condition isinstance(d, np.complex64): to jdata.py

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