Thanks to visit codestin.com
Credit goes to github.com

Skip to content

BUG: Numpy: 2.3.0 - loadtxt cannot read complex numbers written by savetxt #29236

Closed as not planned
@Ion-e

Description

@Ion-e

Describe the issue:

Exported complex numbers in CSV RAW format can't be imported back in.

Reproduce the code example:

import numpy as np

real = np.ones((2,2))

imag = np.ones((2,2))

comp = real + (imag * 1j)

np.savetxt("file.csv", comp, delimiter=', ')

data = np.loadtxt("file.csv", dtype=complex)

Error message:

ValueError: could not convert string '(1.000000000000000000e+00+1.000000000000000000e+00j),' to complex128 at row 0, column 1.

Python and NumPy Versions:

python: 3.13.2
Numpy: 2.3.0

Runtime Environment:

No response

Context for the issue:

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    33 - QuestionQuestion about NumPy usage or development

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions