Skip to content

Commit 41cfb8d

Browse files
ShigekiKarita9il
authored andcommitted
fix PythonBufferErrorCode issue (#159)
1 parent a6fb479 commit 41cfb8d

File tree

1 file changed

+7
-4
lines changed

1 file changed

+7
-4
lines changed

source/mir/ndslice/connect/cpython.d

+7-4
Original file line numberDiff line numberDiff line change
@@ -160,7 +160,7 @@ PythonBufferErrorCode toPythonBuffer(T, size_t N, SliceKind kind)(Slice!(T*, N,
160160
import mir.ndslice.dynamic: everted;
161161
import mir.ndslice.topology: iota;
162162
if (slice.everted.shape.iota.everted.strides != slice.strides)
163-
return cannot_create_f_contiguous_buffer;
163+
return typeof(return).cannot_create_f_contiguous_buffer;
164164
}
165165
}
166166
}
@@ -208,15 +208,15 @@ PythonBufferErrorCode toPythonBuffer(T, size_t N, SliceKind kind)(Slice!(T*, N,
208208
}
209209
else
210210
view.format = null;
211-
211+
212212
return typeof(return).success;
213213
}
214214

215215
///
216216
version(mir_test) unittest
217217
{
218-
import mir.ndslice.slice : Slice, Structure, Universal;
219-
Py_buffer bar(Slice!(double*, 2, Universal) slice)
218+
import mir.ndslice.slice : Slice, Structure, Universal, Contiguous;
219+
Py_buffer bar(SliceKind kind)(Slice!(double*, 2, kind) slice)
220220
{
221221
import core.stdc.stdlib;
222222
enum N = 2;
@@ -239,6 +239,9 @@ version(mir_test) unittest
239239

240240
return view;
241241
}
242+
243+
alias barUni = bar!Universal;
244+
alias barCon = bar!Contiguous;
242245
}
243246

244247
/// Python $(LINK2 https://docs.python.org/3/c-api/buffer.html#buffer-structure, Buffer structure).

0 commit comments

Comments
 (0)