Skip to content

electricpy.latex.clatex() rejects NumPy complex scalars (raises ValueError("Invalid Input Type")) #132

@marcostfermin

Description

@marcostfermin

Describe the bug

clatex() only accepts:

list (converted to np.asarray),

np.ndarray,

or built-in complex.

A NumPy scalar like np.complex128(1+2j) is not an instance of built-in complex, so it falls through to raise ValueError("Invalid Input Type").

The type checks causing this are in the module code.
https://electricpy.readthedocs.io/en/latest/_modules/electricpy/latex.html

Reproduction Code

# Setup
import numpy as np
import electricpy as ep

# Code which causes failure
z = np.complex128(3 + 4j)  # common scalar type from numpy operations
ep.latex.clatex(z)

Expected behavior
Return a LaTeX string for the complex value (either polar or rectangular), same as for 3+4j.

Screenshots
If applicable, add screenshots to help explain your problem.

Desktop (please complete the following information):

  • OS: [e.g. Linux]
  • Python Version [e.g. 3.7]
  • Version [e.g. 0.4.0]

Additional context
clatex checks elif isinstance(val, complex): ... else: raise ValueError("Invalid Input Type"), which excludes NumPy complex scalar types.

Metadata

Metadata

Labels

bugSomething isn't working

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions