(context, data, dim)
| 5613 | this.registerFunction('numpy.std'); |
| 5614 | this.registerFunction('numpy.asarray', (a, dtype) => { |
| 5615 | const encode = (context, data, dim) => { |
| 5616 | const size = context.shape[dim]; |
| 5617 | const littleendian = context.littleendian; |
| 5618 | if (dim === context.shape.length - 1) { |
| 5619 | for (let i = 0; i < size; i++) { |
| 5620 | switch (context.dtype) { |
| 5621 | case 'f2': |
| 5622 | context.view.setFloat16(context.position, data[i], littleendian); |
| 5623 | break; |
| 5624 | case 'f4': |
| 5625 | context.view.setFloat32(context.position, data[i], littleendian); |
| 5626 | break; |
| 5627 | case 'f8': |
| 5628 | context.view.setFloat64(context.position, data[i], littleendian); |
| 5629 | break; |
| 5630 | case 'i1': |
| 5631 | context.view.setInt8(context.position, data[i], littleendian); |
| 5632 | break; |
| 5633 | case 'i2': |
| 5634 | context.view.setInt16(context.position, data[i], littleendian); |
| 5635 | break; |
| 5636 | case 'i4': |
| 5637 | context.view.setInt32(context.position, data[i], littleendian); |
| 5638 | break; |
| 5639 | case 'i8': |
| 5640 | context.view.setBigInt64(context.position, typeof data[i] === 'number' ? BigInt(data[i]) : data[i], littleendian); |
| 5641 | break; |
| 5642 | case 'u1': |
| 5643 | context.view.setUint8(context.position, data[i], littleendian); |
| 5644 | break; |
| 5645 | case 'u2': |
| 5646 | context.view.setUint16(context.position, data[i], littleendian); |
| 5647 | break; |
| 5648 | case 'u4': |
| 5649 | context.view.setUint32(context.position, data[i], littleendian); |
| 5650 | break; |
| 5651 | case 'u8': |
| 5652 | context.view.setComplexFloat16(context.position, data[i], littleendian); |
| 5653 | break; |
| 5654 | case 'c8': |
| 5655 | context.view.setComplexFloat32(context.position, data[i], littleendian); |
| 5656 | break; |
| 5657 | case 'c16': |
| 5658 | context.view.setComplexFloat64(context.position, data[i], littleendian); |
| 5659 | break; |
| 5660 | case 'b1': |
| 5661 | context.view.setInt8(context.position, data[i] ? 1 : 0); |
| 5662 | break; |
| 5663 | default: |
| 5664 | throw new python.Error(`Unsupported tensor data type '${context.dtype}'.`); |
| 5665 | } |
| 5666 | context.position += context.itemsize; |
| 5667 | } |
| 5668 | } else { |
| 5669 | for (let j = 0; j < size; j++) { |
| 5670 | encode(context, data[j], dim + 1); |
| 5671 | } |
| 5672 | } |
no outgoing calls
no test coverage detected