NumSharp icon indicating copy to clipboard operation
NumSharp copied to clipboard

"System.NotImplementedException: '' --> someArray = np.frombuffer(byteBuffer.ToArray<byte>(), np.uint32);

Open mehmetcanbalci-Notrino opened this issue 5 years ago • 1 comments

Hello, i got this execption "System.NotImplementedException: ''" when i use this code ; someArray = np.frombuffer(byteBuffer.ToArray(), np.uint32);

if I will use np.int32, it is working as expected.

mehmetcanbalci-Notrino avatar Oct 09 '20 16:10 mehmetcanbalci-Notrino

Hello @mehmetcanbalci-Notrino ,

You got an exception because data type "uint32" is not yet being implemented, only "int32" and "byte".

      public static NDArray frombuffer(byte[] bytes, Type dtype)
      {

          //TODO! all types
          if (dtype.Name == "Int32")
          {
              var size = bytes.Length / InfoOf<int>.Size;
              var ints = new int[size];
              for (var index = 0; index < size; index++)
              {
                  ints[index] = BitConverter.ToInt32(bytes, index * InfoOf<int>.Size);
              }

              return new NDArray(ints);
          }
          else if (dtype.Name == "Byte")
          {
              var size = bytes.Length / InfoOf<byte>.Size;
              var ints = bytes;
              return new NDArray(bytes);
          }

          throw new NotImplementedException("");
      }

ghost avatar Oct 18 '20 22:10 ghost