Skip to content

LUT1D block fails with len() of unsized object in PathSim 0.23.2 #331

Description

@protfor

Description

Environment

  • Python: 3.14
  • NumPy: 1.18.0
  • SciPy: 2.5.1
  • PathSim: 0.23.2
  • PathView: latest local version

Problem

I found a reproducible issue with the LUT1D block in PathSim 0.23.2.

When I run a model containing a LUT1D block, the simulation fails with:

TypeError: len() of unsized object

The failure occurs even when the LUT1D block has no input connection.

For example:

lut1d = LUT1D(
    points=[0, 100],
    values=[0, 100],
    fill_value="extrapolate"
)

Running a model containing only this block produces:

Streaming simulation failed: len() of unsized object

By comparison, a model containing only a Constant block runs successfully.

Investigation

I checked the installed PathSim source code.

PathSim reports:

0.23.2
<class 'pathsim.blocks.table.LUT1D'>
C:\...\site-packages\pathsim\blocks\table.py

The LUT1D implementation uses SciPy's interp1d:

self.inter = interp1d(
    self.points,
    self.values,
    fill_value=fill_value
)

and its function is:

def func(*x):
    return self.inter(x[0])

LUT1D inherits from Function, whose implementation evaluates the function using:

self.op_alg = Operator(func=lambda x: func(*x))

I also inspected the runtime input representation. The Function block's input array can be represented as a NumPy ndarray, for example:

<class 'numpy.ndarray'>
[0.]

The error message suggests that a scalar / 0-D NumPy value may be reaching interp1d in some execution path.

Reproduction

A minimal model containing only:

LUT1D

with:

points = [0, 100]
values = [0, 100]
fill_value = "extrapolate"

is sufficient to reproduce the error in my environment.

Adding a Constant and connecting:

Constant → LUT1D

also reproduces the same error.

Expected behavior

I would expect LUT1D to accept scalar input values and perform the interpolation without raising an exception.

Question

Could you please check whether this is a bug in the LUT1D / Function implementation in PathSim 0.23.2?

In particular, could the input passed to:

self.inter(x[0])

sometimes be a 0-D NumPy array or scalar?

If so, would explicit scalar/array handling before calling interp1d be an appropriate fix?

Thank you for your help.

Steps to Reproduce

  1. Open PathView with PathSim 0.23.2.
  2. Create a Constant block with value = 50.
  3. Create a LUT1D block with:
    points = [0, 100]
    values = [0, 100]
    fill_value = "extrapolate"
  4. Connect the Constant output to the LUT1D input.
  5. Run the simulation.
  6. The simulation fails immediately with:

TypeError: len() of unsized object

The simulation stops with:

FINISHED -> STREAMING (total steps: 0, successful: 0)

Expected Behavior

No response

Version

No response

Browser

No response

Additional Context

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions