Skip to content

Commit

Permalink
remove NDArray.apply because it is really confusing
Browse files Browse the repository at this point in the history
  • Loading branch information
yzhliu committed Dec 21, 2015
1 parent 8fe6905 commit c14ed50
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions scala-package/core/src/main/scala/ml/dmlc/mxnet/NDArray.scala
Original file line number Diff line number Diff line change
Expand Up @@ -322,12 +322,16 @@ class NDArray(val handle: NDArrayHandle, val writable: Boolean = true) {
*
* @return a sliced NDArray that shares memory with current one.
*/
private def _slice(start: Int, stop: Int): NDArray = {
def slice(start: Int, stop: Int): NDArray = {
val sliceHandle = new NDArrayHandle()
checkCall(_LIB.mxNDArraySlice(handle, start, stop, sliceHandle))
new NDArray(handle = sliceHandle, writable = this.writable)
}

def slice(start: Int): NDArray = {
slice(start, shape(0))
}

/**
* Block until all pending writes operations on current NDArray are finished.
* This function will return when all the pending writes to the current
Expand All @@ -336,8 +340,6 @@ class NDArray(val handle: NDArrayHandle, val writable: Boolean = true) {
*/
def waitToRead(): Unit = ???

def apply(sliceStart: Int, sliceEnd: Int): NDArray = _slice(sliceStart, sliceEnd)

/**
* Get context of current NDArray.
* @return The context of current NDArray.
Expand Down

0 comments on commit c14ed50

Please sign in to comment.