You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The current code for simulating a random walk cannot handle data type np.array as the states vector, given that numpy arrays do not have index attribute.
Steps/Code to Reproduce
With the current code base, the issue can be reproduced using the following:
frompyrandwalkimport*importnumpyasnp# Using the same examples given in README for transition matrixtrans=np.array([[1, 0, 0, 0, 0], [0.25, 0, 0.75, 0, 0],[0, 0.25, 0, 0.75, 0], [0, 0, 0.25, 0, 0.75], [0, 0, 0, 1, 0]])
# The only change here is to switch `states` from a List to np.arraystates=np.array([0,1,2,3,4])
# This is the check that is run using a utility to ensure the correct data types are used for statesprint(isinstance(states, (list, np.ndarray)))
# >>> Truerw=RandomWalk(states, trans)
states, probs=rw.run()
# Error: `AttributeError: 'numpy.ndarray' object has no attribute 'index'`
Operating System
Linux
Python Version
Python 3.9.12
pyrandwalk Version
1.1
I will try to do a PR later to handle this issue by using np.where when we have a numpy array.
The text was updated successfully, but these errors were encountered:
Description
The current code for simulating a random walk cannot handle data type
np.array
as the states vector, given that numpy arrays do not haveindex
attribute.Steps/Code to Reproduce
With the current code base, the issue can be reproduced using the following:
Operating System
Linux
Python Version
Python 3.9.12
pyrandwalk Version
1.1
I will try to do a PR later to handle this issue by using
np.where
when we have a numpy array.The text was updated successfully, but these errors were encountered: