| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -58,7 +58,22 @@ public void TestBufferRead() | |||
| 58 | 58 | } | |
| 59 | 59 | ||
| 60 | 60 | string result = new UTF8Encoding().GetString(managedArray); | |
| 61 | - Assert.That(result == " " + bufferTestString.Substring(1), Is.True); | ||
| 61 | + Assert.That(result, Is.EqualTo($" {bufferTestString.Substring(1)}")); | ||
| 62 | + } | ||
| 63 | + | ||
| 64 | + [Test] | ||
| 65 | + public void GetPointer() | ||
| 66 | + { | ||
| 67 | + // create 3D NumPy array | ||
| 68 | + int[] shape = [10, 10, 10]; | ||
| 69 | + using PyObject ndArray = np.zeros(shape); | ||
| 70 | + | ||
| 71 | + using PyBuffer buf = ndArray.GetBuffer(PyBUF.STRIDES); | ||
| 72 | + | ||
| 73 | + // this throws System.ExecutionEngineException | ||
| 74 | + var ptr = buf.GetPointer([0, 0, 0]); | ||
| 75 | + | ||
| 76 | + Assert.That(ptr, Is.Not.EqualTo(IntPtr.Zero)); | ||
| 62 | 77 | } | |
| 63 | 78 | ||
| 64 | 79 | [Test] | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -1018,6 +1018,12 @@ internal static nint PyBuffer_SizeFromFormat(string format) | |||
| 1018 | 1018 | ||
| 1019 | 1019 | ||
| 1020 | 1020 | internal static IntPtr PyBuffer_GetPointer(ref Py_buffer view, nint[] indices) => Delegates.PyBuffer_GetPointer(ref view, indices); | |
| 1021 | + // { | ||
| 1022 | + // fixed (nint* indicesPtr = indices) | ||
| 1023 | + // { | ||
| 1024 | + // return Delegates.PyBuffer_GetPointer(ref view, indicesPtr); | ||
| 1025 | + // } | ||
| 1026 | + // } | ||
| 1021 | 1027 | ||
| 1022 | 1028 | ||
| 1023 | 1029 | internal static int PyBuffer_FromContiguous(ref Py_buffer view, IntPtr buf, IntPtr len, char fort) => Delegates.PyBuffer_FromContiguous(ref view, buf, len, fort); | |
| Back | FazBrowse Home | New Git URL |
0 commit comments