Skip to content

Commit

Permalink
Cast boolean to int
Browse files Browse the repository at this point in the history
  • Loading branch information
MechCoder committed Apr 21, 2015
1 parent 151f3b6 commit 004a37f
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -988,6 +988,7 @@ private[spark] object SerDe extends Serializable {
val isTransposed = if (m.isTransposed) 1 else 0
ByteBuffer.wrap(bytes).order(order).asDoubleBuffer().put(m.values)

out.write(Opcodes.MARK)
out.write(Opcodes.BININT)
out.write(PickleUtils.integer_to_bytes(m.numRows))
out.write(Opcodes.BININT)
Expand All @@ -1008,7 +1009,7 @@ private[spark] object SerDe extends Serializable {
val n = bytes.length / 8
val values = new Array[Double](n)
val order = ByteOrder.nativeOrder()
val isTransposed = args(3).asInstanceOf[Boolean]
val isTransposed = if (args(3).asInstanceOf[Int] == 1) true else false
ByteBuffer.wrap(bytes).order(order).asDoubleBuffer().get(values)
new DenseMatrix(args(0).asInstanceOf[Int], args(1).asInstanceOf[Int], values, isTransposed)
}
Expand Down
3 changes: 2 additions & 1 deletion python/pyspark/mllib/linalg.py
Original file line number Diff line number Diff line change
Expand Up @@ -671,7 +671,8 @@ def __init__(self, numRows, numCols, values, isTransposed=False):

def __reduce__(self):
return DenseMatrix, (
self.numRows, self.numCols, self.values.tostring(), self.isTransposed)
self.numRows, self.numCols, self.values.tostring(),
int(self.isTransposed))

def toArray(self):
"""
Expand Down
2 changes: 1 addition & 1 deletion python/pyspark/mllib/tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ def test_serialize(self):
self._test_serialize(DenseVector(pyarray.array('d', range(10))))
self._test_serialize(SparseVector(4, {1: 1, 3: 2}))
self._test_serialize(SparseVector(3, {}))
# self._test_serialize(DenseMatrix(2, 3, range(6)))
self._test_serialize(DenseMatrix(2, 3, range(6)))

def test_dot(self):
sv = SparseVector(4, {1: 1, 3: 2})
Expand Down

0 comments on commit 004a37f

Please sign in to comment.