Open JoelPasvolsky opened 4 months ago
Silent casting of int only when boundaries are defined:
Got what I expected:
>>> i = model.integer() >>> with model.lock(): model.states.resize(1) i.set_state(0, -2.5) print(i.state(0)) ValueError: Invalid data provided for node
Got surprised:
j = model.integer(lower_bound=-5, upper_bound=0) >>> with model.lock(): model.states.resize(1) j.set_state(0, -2.5) print(j.state(0)) -2.0
Also needs a better error message.
That said, I think we want to silent cast in both cases. To follow NumPy
In [11]: arr = np.zeros(1, dtype=int) In [12]: arr[0] = 2.5 In [13]: arr[0] Out[13]: 2
Silent casting of int only when boundaries are defined:
Got what I expected:
Got surprised: