SciSharp / NumSharp

High Performance Computation for N-D Tensors in .NET, similar API to NumPy.
https://github.com/SciSharp
Apache License 2.0
1.38k stars 192 forks source link

Slice assign #486

Open burungiu opened 1 year ago

burungiu commented 1 year ago

Hello everyone, there is a way to do assigment as in python? Example: preds[:, :, 0] = preds[:, :, 0] % heatmapWidth

Thank you

bojake commented 1 year ago

There is an issue with auto-broadening of scalar operands in the framework.

For instance:

var foo = (array > 12f); // fails var foo = np.full(12f, array.shape); var result = (array > foo); // successful

In your "heatmapWidth" operand just create an "np.full(heatmapWidth, preds.shape)" NDArray and use that as the operand. I bet that will work for you.