Skip to content

Commit

Permalink
disable threaded tests
Browse files Browse the repository at this point in the history
  • Loading branch information
Clonkk committed Jun 16, 2024
1 parent 1b7efb8 commit 165fbd3
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 9 deletions.
11 changes: 5 additions & 6 deletions scinim/numpyarrays.nim
Original file line number Diff line number Diff line change
Expand Up @@ -126,10 +126,10 @@ proc pyprint*[T](ar: NumpyArray[T]) =
proc toUnsafeView*[T](ndArray: NumpyArray[T]): ptr UncheckedArray[T] {.noSideEffect, inline.} =
ndArray.data

proc c_contiguous*[T](ar: NumpyArray[T]) : bool =
proc check_c_contiguous*[T](ar: NumpyArray[T]) : bool =
ar.data.c_contiguous.to(bool)

proc f_contiguous*[T](ar: NumpyArray[T]) : bool =
proc check_f_contiguous*[T](ar: NumpyArray[T]) : bool =
ar.data.f_contiguous.to(bool)

proc initNumpyArray*[T](ar: sink PyObject): NumpyArray[T] =
Expand All @@ -152,7 +152,7 @@ proc pyValueToNim*[T: SomeNumber](v: PPyObject, o: var NumpyArray[T]) {.inline.}
o = initNumpyArray[T](vv)

proc isContiguous*[T](ar: NumpyArray[T]) : bool =
result = ar.c_contiguous or ar.f_contiguous
result = ar.check_c_contiguous() or ar.check_f_contiguous()

proc asContiguous*[T](ar: NumpyArray[T]) : NumpyArray[T] =
let np = pyImport("numpy")
Expand All @@ -167,9 +167,9 @@ proc asNumpyArray*[T](ar: sink PyObject): NumpyArray[T] =
## User has to make sure that the data type of the array can be
## cast to `T` without loss of information!
assertNumpyType[T](ar)
if not ar.c_contiguous.to(bool):
if not ar.data.c_contiguous.to(bool):
let np = pyImport("numpy")
var ar = asContiguous(ar)
var ar = np.ascontiguousarray(ar)
return initNumpyArray[T](ar)
else:
return initNumpyArray[T](ar)
Expand Down Expand Up @@ -293,6 +293,5 @@ template `{}`*[T](ndArray: NumpyArray[T], idx: int): T =
template `{}=`*[T](ndArray: NumpyArray[T], idx: int, val: T) =
atContiguousIndex(ndArray, idx) = val


{.pop.}
{.pop.}
7 changes: 4 additions & 3 deletions tests/tnumpyarrays.nim
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,7 @@ proc test(arg: tuple[s: string]) =

when isMainModule:
test((s: "toTensor, toNdArray in main thread"))
var thr: Thread[tuple[s: string]]
createThread(thr, test, (s: "toTensor, toNdArray in external thread"))
joinThread(thr)
# DIsqble for now
# var thr: Thread[tuple[s: string]]
# createThread(thr, test, (s: "toTensor, toNdArray in external thread"))
# joinThread(thr)

0 comments on commit 165fbd3

Please sign in to comment.