From a201a6dce18e307a0ef7507c9486b72a693a16ae Mon Sep 17 00:00:00 2001 From: carlosuc3m <100329787@alumnos.uc3m.es> Date: Fri, 18 Oct 2024 20:23:09 +0200 Subject: [PATCH] correct the same error --- .../tensor/shm/SharedMemoryArrayMacOS.java | 22 +++++++++---------- .../tensor/shm/SharedMemoryArrayWin.java | 22 +++++++++---------- 2 files changed, 22 insertions(+), 22 deletions(-) diff --git a/src/main/java/io/bioimage/modelrunner/tensor/shm/SharedMemoryArrayMacOS.java b/src/main/java/io/bioimage/modelrunner/tensor/shm/SharedMemoryArrayMacOS.java index 07a3a149..f050d1db 100644 --- a/src/main/java/io/bioimage/modelrunner/tensor/shm/SharedMemoryArrayMacOS.java +++ b/src/main/java/io/bioimage/modelrunner/tensor/shm/SharedMemoryArrayMacOS.java @@ -431,7 +431,7 @@ private void addByteArray(byte[] arr) { private void buildInt8(RandomAccessibleInterval tensor, boolean isFortranOrder, boolean isNumpy) { byte[] header = new byte[0]; - if (isNumpy) header = getNpyHeader(tensor); + if (isNumpy) header = getNpyHeader(tensor, isFortranOrder); long offset = 0; for (byte b : header) { this.pSharedMemory.setByte(offset, b); @@ -449,7 +449,7 @@ private void buildInt8(RandomAccessibleInterval tensor, boolean isFort private void buildUint8(RandomAccessibleInterval tensor, boolean isFortranOrder, boolean isNumpy) { byte[] header = new byte[0]; - if (isNumpy) header = getNpyHeader(tensor); + if (isNumpy) header = getNpyHeader(tensor, isFortranOrder); long offset = 0; for (byte b : header) { this.pSharedMemory.setByte(offset, b); @@ -467,7 +467,7 @@ private void buildUint8(RandomAccessibleInterval tensor, boole private void buildInt16(RandomAccessibleInterval tensor, boolean isFortranOrder, boolean isNumpy) { byte[] header = new byte[0]; - if (isNumpy) header = getNpyHeader(tensor); + if (isNumpy) header = getNpyHeader(tensor, isFortranOrder); long offset = 0; for (byte b : header) { this.pSharedMemory.setByte(offset, b); @@ -486,7 +486,7 @@ private void buildInt16(RandomAccessibleInterval tensor, boolean isFo private void buildUint16(RandomAccessibleInterval tensor, boolean isFortranOrder, boolean isNumpy) { byte[] header = new byte[0]; - if (isNumpy) header = getNpyHeader(tensor); + if (isNumpy) header = getNpyHeader(tensor, isFortranOrder); long offset = 0; for (byte b : header) { this.pSharedMemory.setByte(offset, b); @@ -505,7 +505,7 @@ private void buildUint16(RandomAccessibleInterval tensor, boo private void buildInt32(RandomAccessibleInterval tensor, boolean isFortranOrder, boolean isNumpy) { byte[] header = new byte[0]; - if (isNumpy) header = getNpyHeader(tensor); + if (isNumpy) header = getNpyHeader(tensor, isFortranOrder); long offset = 0; for (byte b : header) { this.pSharedMemory.setByte(offset, b); @@ -524,7 +524,7 @@ private void buildInt32(RandomAccessibleInterval tensor, boolean isFort private void buildUint32(RandomAccessibleInterval tensor, boolean isFortranOrder, boolean isNumpy) { byte[] header = new byte[0]; - if (isNumpy) header = getNpyHeader(tensor); + if (isNumpy) header = getNpyHeader(tensor, isFortranOrder); long offset = 0; for (byte b : header) { this.pSharedMemory.setByte(offset, b); @@ -543,7 +543,7 @@ private void buildUint32(RandomAccessibleInterval tensor, boole private void buildInt64(RandomAccessibleInterval tensor, boolean isFortranOrder, boolean isNumpy) { byte[] header = new byte[0]; - if (isNumpy) header = getNpyHeader(tensor); + if (isNumpy) header = getNpyHeader(tensor, isFortranOrder); long offset = 0; for (byte b : header) { this.pSharedMemory.setByte(offset, b); @@ -562,7 +562,7 @@ private void buildInt64(RandomAccessibleInterval tensor, boolean isFor private void buildFloat32(RandomAccessibleInterval tensor, boolean isFortranOrder, boolean isNumpy) { byte[] header = new byte[0]; - if (isNumpy) header = getNpyHeader(tensor); + if (isNumpy) header = getNpyHeader(tensor, isFortranOrder); long offset = 0; for (byte b : header) { this.pSharedMemory.setByte(offset, b); @@ -581,7 +581,7 @@ private void buildFloat32(RandomAccessibleInterval tensor, boolean is private void buildFloat64(RandomAccessibleInterval tensor, boolean isFortranOrder, boolean isNumpy) { byte[] header = new byte[0]; - if (isNumpy) header = getNpyHeader(tensor); + if (isNumpy) header = getNpyHeader(tensor, isFortranOrder); long offset = 0; for (byte b : header) { this.pSharedMemory.setByte(offset, b); @@ -598,10 +598,10 @@ private void buildFloat64(RandomAccessibleInterval tensor, boolean i } private static & NativeType> - byte[] getNpyHeader(RandomAccessibleInterval tensor) { + byte[] getNpyHeader(RandomAccessibleInterval tensor, boolean isFortran) { String strHeader = "{'descr': '<"; strHeader += DecodeNumpy.getDataType(tensor.getAt(tensor.minAsLongArray())); - strHeader += "', 'fortran_order': False, 'shape': ("; + strHeader += "', 'fortran_order': " + (isFortran ? "True" : "False") + ", 'shape': ("; for (long ll : tensor.dimensionsAsLongArray()) strHeader += ll + ", "; strHeader = strHeader.substring(0, strHeader.length() - 2); strHeader += "), }" + System.lineSeparator(); diff --git a/src/main/java/io/bioimage/modelrunner/tensor/shm/SharedMemoryArrayWin.java b/src/main/java/io/bioimage/modelrunner/tensor/shm/SharedMemoryArrayWin.java index 2bd83787..328b8aa1 100644 --- a/src/main/java/io/bioimage/modelrunner/tensor/shm/SharedMemoryArrayWin.java +++ b/src/main/java/io/bioimage/modelrunner/tensor/shm/SharedMemoryArrayWin.java @@ -487,10 +487,10 @@ private void addByteArray(byte[] arr) { } private static & NativeType> - byte[] getNpyHeader(RandomAccessibleInterval tensor) { + byte[] getNpyHeader(RandomAccessibleInterval tensor, boolean isFortran) { String strHeader = "{'descr': '<"; strHeader += DecodeNumpy.getDataType(tensor.getAt(tensor.minAsLongArray())); - strHeader += "', 'fortran_order': False, 'shape': ("; + strHeader += "', 'fortran_order': " + (isFortran ? "True" : "False") + ", 'shape': ("; for (long ll : tensor.dimensionsAsLongArray()) strHeader += ll + ", "; strHeader = strHeader.substring(0, strHeader.length() - 2); strHeader += "), }" + System.lineSeparator(); @@ -517,7 +517,7 @@ byte[] getNpyHeader(RandomAccessibleInterval tensor) { private void buildInt8(RandomAccessibleInterval tensor, boolean isFortranOrder, boolean isNumpy) { byte[] header = new byte[0]; - if (isNumpy) header = getNpyHeader(tensor); + if (isNumpy) header = getNpyHeader(tensor, isFortranOrder); long offset = 0; for (byte b : header) { this.mappedPointer.setByte(offset, b); @@ -535,7 +535,7 @@ private void buildInt8(RandomAccessibleInterval tensor, boolean isFort private void buildUint8(RandomAccessibleInterval tensor, boolean isFortranOrder, boolean isNumpy) { byte[] header = new byte[0]; - if (isNumpy) header = getNpyHeader(tensor); + if (isNumpy) header = getNpyHeader(tensor, isFortranOrder); long offset = 0; for (byte b : header) { this.mappedPointer.setByte(offset, b); @@ -553,7 +553,7 @@ private void buildUint8(RandomAccessibleInterval tensor, boole private void buildInt16(RandomAccessibleInterval tensor, boolean isFortranOrder, boolean isNumpy) { byte[] header = new byte[0]; - if (isNumpy) header = getNpyHeader(tensor); + if (isNumpy) header = getNpyHeader(tensor, isFortranOrder); long offset = 0; for (byte b : header) { this.mappedPointer.setByte(offset, b); @@ -572,7 +572,7 @@ private void buildInt16(RandomAccessibleInterval tensor, boolean isFo private void buildUint16(RandomAccessibleInterval tensor, boolean isFortranOrder, boolean isNumpy) { byte[] header = new byte[0]; - if (isNumpy) header = getNpyHeader(tensor); + if (isNumpy) header = getNpyHeader(tensor, isFortranOrder); long offset = 0; for (byte b : header) { this.mappedPointer.setByte(offset, b); @@ -591,7 +591,7 @@ private void buildUint16(RandomAccessibleInterval tensor, boo private void buildInt32(RandomAccessibleInterval tensor, boolean isFortranOrder, boolean isNumpy) { byte[] header = new byte[0]; - if (isNumpy) header = getNpyHeader(tensor); + if (isNumpy) header = getNpyHeader(tensor, isFortranOrder); long offset = 0; for (byte b : header) { this.mappedPointer.setByte(offset, b); @@ -610,7 +610,7 @@ private void buildInt32(RandomAccessibleInterval tensor, boolean isFort private void buildUint32(RandomAccessibleInterval tensor, boolean isFortranOrder, boolean isNumpy) { byte[] header = new byte[0]; - if (isNumpy) header = getNpyHeader(tensor); + if (isNumpy) header = getNpyHeader(tensor, isFortranOrder); long offset = 0; for (byte b : header) { this.mappedPointer.setByte(offset, b); @@ -629,7 +629,7 @@ private void buildUint32(RandomAccessibleInterval tensor, boole private void buildInt64(RandomAccessibleInterval tensor, boolean isFortranOrder, boolean isNumpy) { byte[] header = new byte[0]; - if (isNumpy) header = getNpyHeader(tensor); + if (isNumpy) header = getNpyHeader(tensor, isFortranOrder); long offset = 0; for (byte b : header) { this.mappedPointer.setByte(offset, b); @@ -648,7 +648,7 @@ private void buildInt64(RandomAccessibleInterval tensor, boolean isFor private void buildFloat32(RandomAccessibleInterval tensor, boolean isFortranOrder, boolean isNumpy) { byte[] header = new byte[0]; - if (isNumpy) header = getNpyHeader(tensor); + if (isNumpy) header = getNpyHeader(tensor, isFortranOrder); long offset = 0; for (byte b : header) { this.mappedPointer.setByte(offset, b); @@ -667,7 +667,7 @@ private void buildFloat32(RandomAccessibleInterval tensor, boolean is private void buildFloat64(RandomAccessibleInterval tensor, boolean isFortranOrder, boolean isNumpy) { byte[] header = new byte[0]; - if (isNumpy) header = getNpyHeader(tensor); + if (isNumpy) header = getNpyHeader(tensor, isFortranOrder); long offset = 0; for (byte b : header) { this.mappedPointer.setByte(offset, b);