Skip to content

setu does not perform any sizecheck #82

Open
@hexaeder

Description

@hexaeder

Describe the bug 🐞

setu does not perform sizecheck between the new values and the number of indexed elements.

Expected behavior

I would expect it to either error or implicitly broadcast, but it only overwrites a single value. The expectation comes especially when using the setindex! interface, because then it feels like array indexing

a = zeros(2)
a[[1,2]] = 1 # errors
a[[1,2]] .= 1 # overwrites both elements
a[[1,2]] = [1,2] # overwrites both elements

Minimal Reproducible Example 👇

inpr = SymbolCache([:x, :y])
ps = ProblemState(;u=zeros(2))
    
getu(inpr, [:x,:y])(ps) == zeros(2) # as expected
setu(inpr, [:x,:y])(ps, 1) # does not error, only overwrites first element
getu(inpr, [:x,:y])(ps) == [1,0] # strange?

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