aboutsummaryrefslogtreecommitdiff
path: root/python
diff options
context:
space:
mode:
authorTor Myklebust <tmyklebu@gmail.com>2013-12-20 01:48:44 -0500
committerTor Myklebust <tmyklebu@gmail.com>2013-12-20 01:48:44 -0500
commit319520b9bb0071527a0be1e0e545ca084ac090ee (patch)
treea2d1ff55192c2223c8b684c37b84435e377caabd /python
parent2940201ad86e5dee16cf7386b3c934fc75c15582 (diff)
downloadspark-319520b9bb0071527a0be1e0e545ca084ac090ee.tar.gz
spark-319520b9bb0071527a0be1e0e545ca084ac090ee.tar.bz2
spark-319520b9bb0071527a0be1e0e545ca084ac090ee.zip
Remove gigantic endian-specific test and exception tests.
Diffstat (limited to 'python')
-rw-r--r--python/pyspark/mllib.py41
1 files changed, 3 insertions, 38 deletions
diff --git a/python/pyspark/mllib.py b/python/pyspark/mllib.py
index aa9fc76c29..e7e22166b0 100644
--- a/python/pyspark/mllib.py
+++ b/python/pyspark/mllib.py
@@ -27,40 +27,7 @@ def _deserialize_byte_array(shape, ba, offset):
return ar.copy()
def _serialize_double_vector(v):
- """Serialize a double vector into a mutually understood format.
-
- >>> _serialize_double_vector(array([]))
- bytearray(b'\\x01\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00')
- >>> _serialize_double_vector(array([0.0, 1.0]))
- bytearray(b'\\x01\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x02\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\xf0?')
- >>> _serialize_double_vector("hello, world")
- Traceback (most recent call last):
- File "/usr/lib/python2.7/doctest.py", line 1289, in __run
- compileflags, 1) in test.globs
- File "<doctest __main__._serialize_double_vector[1]>", line 1, in <module>
- _serialize_double_vector("hello, world")
- File "python/pyspark/mllib.py", line 41, in _serialize_double_vector
- raise TypeError("_serialize_double_vector called on a %s; wanted ndarray" % type(v))
- TypeError: _serialize_double_vector called on a <type 'str'>; wanted ndarray
- >>> _serialize_double_vector(array([0, 1]))
- Traceback (most recent call last):
- File "/usr/lib/python2.7/doctest.py", line 1289, in __run
- compileflags, 1) in test.globs
- File "<doctest __main__._serialize_double_vector[2]>", line 1, in <module>
- _serialize_double_vector(array([0, 1]))
- File "python/pyspark/mllib.py", line 51, in _serialize_double_vector
- "wanted ndarray of float64" % v.dtype)
- TypeError: _serialize_double_vector called on an ndarray of int64; wanted ndarray of float64
- >>> _serialize_double_vector(array([0.0, 1.0, 2.0, 3.0]).reshape(2,2))
- Traceback (most recent call last):
- File "/usr/lib/python2.7/doctest.py", line 1289, in __run
- compileflags, 1) in test.globs
- File "<doctest __main__._serialize_double_vector[3]>", line 1, in <module>
- _serialize_double_vector(array([0.0, 1.0, 2.0, 3.0]).reshape(2,2))
- File "python/pyspark/mllib.py", line 62, in _serialize_double_vector
- "wanted a 1darray" % v.ndim)
- TypeError: _serialize_double_vector called on a 2darray; wanted a 1darray
- """
+ """Serialize a double vector into a mutually understood format."""
if type(v) != ndarray:
raise TypeError("_serialize_double_vector called on a %s; "
"wanted ndarray" % type(v))
@@ -106,8 +73,7 @@ def _deserialize_double_vector(ba):
return _deserialize_byte_array([length], ba, 16)
def _serialize_double_matrix(m):
- """Serialize a double matrix into a mutually understood format.
- """
+ """Serialize a double matrix into a mutually understood format."""
if (type(m) == ndarray and m.dtype == float64 and m.ndim == 2):
rows = m.shape[0]
cols = m.shape[1]
@@ -124,8 +90,7 @@ def _serialize_double_matrix(m):
"non-double-matrix")
def _deserialize_double_matrix(ba):
- """Deserialize a double matrix from a mutually understood format.
- """
+ """Deserialize a double matrix from a mutually understood format."""
if type(ba) != bytearray:
raise TypeError("_deserialize_double_matrix called on a %s; "
"wanted bytearray" % type(ba))