I have a problem running the package on the Windows system (on Mac and Linux it works like a charm).
from pyitlib import discrete_random_variable as drv
drv.entropy(np.array([1.5,1.4,0.2]))
throws
---------------------------------------------------------------------------
AssertionError Traceback (most recent call last)
Cell In[7], line 2
1 from pyitlib import discrete_random_variable as drv
----> 2 drv.entropy(np.array([1.5,1.4,0.2]))
File ~\Envs\multi-label-cs-group-fs\lib\site-packages\pyitlib\discrete_random_variable.py:3843, in entropy(X, base, fill_value, estimator, Alphabet_X, keep_dims)
3840 if not (np.isscalar(base) and np.isreal(base) and base > 0):
3841 raise ValueError("arg base not a positive real-valued scalar")
-> 3843 S, fill_value = _map_observations_to_integers((X, Alphabet_X),
3844 (fill_value_X,
3845 fill_value_Alphabet_X))
3846 X, Alphabet_X = S
3848 H = np.empty(X.shape[:-1])
File ~\Envs\multi-label-cs-group-fs\lib\site-packages\pyitlib\discrete_random_variable.py:4695, in _map_observations_to_integers(Symbol_matrices, Fill_values)
4692 assert(not np.any(A == FILL_VALUE))
4693 A[A == f] = FILL_VALUE
-> 4695 assert(np.all([A.dtype == 'int' for A in Symbol_matrices]))
4696 return Symbol_matrices, FILL_VALUE
AssertionError:
It seems that the default int on my machine is np.int32 not np.int64, because when I changed the assert in the source code of _map_observations_to_integers function
from assert(np.all([A.dtype == 'int' for A in Symbol_matrices]))
to assert(np.all([A.dtype in [np.dtype(np.intp), np.dtype(np.int32), np.dtype(np.int64)] for A in Symbol_matrices]))
it works.
Maybe You have a suggestion on how to cover this bug in my code?
I have a problem running the package on the Windows system (on Mac and Linux it works like a charm).
throws
It seems that the default
int
on my machine isnp.int32
notnp.int64
, because when I changed the assert in the source code of_map_observations_to_integers
functionassert(np.all([A.dtype == 'int' for A in Symbol_matrices]))
assert(np.all([A.dtype in [np.dtype(np.intp), np.dtype(np.int32), np.dtype(np.int64)] for A in Symbol_matrices]))
it works.Maybe You have a suggestion on how to cover this bug in my code?