Skip to content

set_state() method quietly accepts transposed array #490

@JoelPasvolsky

Description

@JoelPasvolsky
>>> model = Model()
>>> x = model.integer((2, 5))
>>> with model.lock():
...     model.states.resize(2)
...     x.set_state(0, [[1, 2], [1, 3], [4, 1], [3, 2], [5, 5]])
...     x.set_state(1, [[1, 2, 3, 4, 5], [5, 4, 3, 2, 1]])
...     print(x.state(1))
...     print(x.state(0))
[[1. 2. 3. 4. 5.]
 [5. 4. 3. 2. 1.]]
[[1. 2. 1. 3. 4.]
 [1. 3. 2. 5. 5.]]

It's a nice "feature" to use but it will probably trip someone up.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions