Skip to content

community/py3-stochastic: fix tests with numpy 2.0

mio requested to merge mio/aports:py3-stochastic into master

Update numpy array references to fix failed tests. Resolves rebuild error due to failed tests on the 3.21 builders.

_______________ test_markov_chain_str_repr[transition0-initial0] _______________
[gw16] linux -- Python 3.12.7 /home/buildozer/aports/community/py3-stochastic/src/stochastic-0.7.0/.testenv/bin/python3

transition = [[0.25, 0.75], [0.4, 0.6]], initial = [0.25, 0.75]

    def test_markov_chain_str_repr(transition, initial):
>       instance = MarkovChain(transition, initial)

tests/processes/discrete/test_markov_chain.py:8:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
stochastic/processes/discrete/markov_chain.py:26: in __init__
    self.transition = transition or np.array([[0.5, 0.5], [0.5, 0.5]])
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

self = <[AttributeError("'MarkovChain' object has no attribute '_transition'") raised in repr()] MarkovChain object at 0x7fffa5de89b0>
values = [[0.25, 0.75], [0.4, 0.6]]

    @transition.setter
    def transition(self, values):
>       values = np.array(values, copy=False)
E       ValueError: Unable to avoid copy while creating an array as requested.
E       If using `np.array(obj, copy=False)` replace it with `np.asarray(obj)` to allow a copy when needed (no behavior change in NumPy 1.x).
E       For more details, see https://numpy.org/devdocs/numpy_2_0_migration_guide.html#adapting-to-changes-in-the-copy-keyword.

stochastic/processes/discrete/markov_chain.py:51: ValueError

Merge request reports

Loading