Skip to content

fix XPM array dtype inference on Python 3 - #321

Open
chenyangsu wants to merge 1 commit into
Becksteinlab:mainfrom
chenyangsu:fix/xpm-array-dtype
Open

chenyangsu wants to merge 1 commit into
Becksteinlab:mainfrom
chenyangsu:fix/xpm-array-dtype

Conversation

@chenyangsu

Copy link
Copy Markdown

In Python 3, XPM.parse() passes the dict_values view from colors.values() directly to numpy.array(), which evaluates to a 0-D object array and forces XPM.array.dtype to object for every file (so np.isnan(xpm.array) and plt.imshow(xpm.array) raise TypeError on numeric matrices).

Materializing list(colors.values()) lets NumPy infer float64, bool, or Unicode string dtypes as documented. Happy to also add a CHANGES entry if you want one in the PR.

Testing: pytest tests/fileformats/test_xpm.py -> 8 passed (3 new dtype tests fail on main), black --check passed.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant