NumSharp icon indicating copy to clipboard operation
NumSharp copied to clipboard

np.random.choice raised System.NotSupportedException

Open alvinfebriando opened this issue 2 years ago • 1 comments

error on np.random.choice, it said "Specified method isn not supported". Is my usage wrong?

var score = np.arange(1,6);
var p = new[] { 0.2, 0.2, 0.2, 0.2, 0.2 };
var result = np.random.choice(score, probabilities: p);

Stack trace

Unhandled exception. System.NotSupportedException: Specified method is not supported.
   at NumSharp.NPTypeCodeExtensions.GetAccumulatingType(NPTypeCode typeCode)
   at NumSharp.Backends.DefaultEngine.cumsum_elementwise(NDArray& arr, Nullable`1 typeCode)
   at NumSharp.Backends.DefaultEngine.ReduceCumAdd(NDArray& arr, Nullable`1 axis_, Nullable`1 typeCode)
   at NumSharp.np.cumsum(NDArray arr, Nullable`1 axis, Nullable`1 typeCode)
   at NumSharp.NumPyRandom.choice(Int32 a, Shape shape, Boolean replace, Double[] probabilities)
   at NumSharp.NumPyRandom.choice(NDArray arr, Shape shape, Boolean replace, Double[] probabilities)
   at Program.<Main>$(String[] args) 

alvinfebriando avatar Feb 15 '23 06:02 alvinfebriando

I created a test case with your exact code and ran it using my dev fork of NumSharp. No errors were produced. Are you using an out dated NumSharp?

bojake avatar Feb 27 '23 22:02 bojake