Skip to content

Scalar v.s. array input to openmc.data.Tabulated1D gives different results. #4041

Description

@OceanNuclear

Bug Description

When supplied with an input that lies outside of the defined x ranges, openmc.data.Tabulated1D returns 0 if the input is wrapped as an Iterable; meanwhile if the input is a scalar value, then it returns the lowest-x/highest-x point's y-value (depending on which side it is on).

Explanation

The code inside openmc.data.Tabulated1D.call (which handles vector inputs) first initialize an array of zeros, then populates only points within range. Meanwhile, the code inside openmc.data.Tabulated1D._interpolate_scalar returns the nearest y values to the input if the input is outside of the valid x range.

Steps to Reproduce

import openmc
tab = openmc.data.Tabulated1D([1,2,3], [4,5,6], [], [2],)
print(tab([0])) # array([0])
print(tab(0)) # 4

Environment

latest/stable/v0.15.3

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions