本文整理汇总了Python中splearn.utils.testing.assert_array_equal函数的典型用法代码示例。如果您正苦于以下问题:Python assert_array_equal函数的具体用法?Python assert_array_equal怎么用?Python assert_array_equal使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了assert_array_equal函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_fmod
def test_fmod(self):
A, A_rdd = self.make_dense_rdd((8, 3))
B, B_rdd = self.make_dense_rdd((1, 3))
np_res = np.fmod(A, B)
assert_array_equal(
A_rdd.fmod(B).toarray(), np_res
)
示例2: test_remainder
def test_remainder(self):
A, A_rdd = self.make_dense_rdd((8, 3))
B, B_rdd = self.make_dense_rdd((1, 3))
np_res = np.remainder(A, B)
assert_array_equal(
A_rdd.remainder(B).toarray(), np_res
)
示例3: test_unblocking_rdd
def test_unblocking_rdd(self):
data = np.arange(400)
rdd = self.sc.parallelize(data, 4)
X = ArrayRDD(rdd, 5)
X_unblocked = X.unblock()
assert_is_instance(X_unblocked, RDD)
assert_array_equal(X_unblocked.take(12), np.arange(12).tolist())
示例4: test_same_fit_transform
def test_same_fit_transform(self):
Y, Y_rdd = self.make_dense_randint_rdd(low=0, high=10, shape=(1000,))
local = LabelEncoder()
dist = SparkLabelEncoder()
assert_array_equal(local.fit_transform(Y), dist.fit_transform(Y_rdd).toarray())
示例5: test_same_classes
def test_same_classes(self):
Y, Y_rdd = self.make_dense_randint_rdd(low=0, high=10, shape=(1000,))
local = LabelEncoder().fit(Y)
dist = SparkLabelEncoder().fit(Y_rdd)
assert_array_equal(local.classes_, dist.classes_)
示例6: test_true_divide
def test_true_divide(self):
A, A_rdd = self.make_dense_rdd((8, 3))
B, B_rdd = self.make_dense_rdd((1, 3))
np_res = A / B
assert_array_equal(
A_rdd.true_divide(B).toarray(), np_res
)
示例7: test_same_output
def test_same_output(self):
X, X_rdd = self.make_text_rdd()
local = HashingVectorizer()
dist = SparkHashingVectorizer()
result_local = local.transform(X)
result_dist = sp.vstack(dist.transform(X_rdd).collect())
assert_array_equal(result_local.toarray(), result_dist.toarray())
示例8: test_transform
def test_transform(self):
X, X_rdd = self.make_dense_rdd((100, 4))
fn = lambda x: x ** 2
X1 = list(map(fn, X_rdd.collect()))
X2 = X_rdd.transform(fn).collect()
assert_array_equal(X1, X2)
示例9: test_same_output
def test_same_output(self):
X, X_rdd = self.make_dict_dataset()
local = DictVectorizer()
dist = SparkDictVectorizer()
result_local = local.fit_transform(X)
result_dist = sp.vstack(dist.fit_transform(X_rdd).collect())
assert_equal(local.vocabulary_, dist.vocabulary_)
assert_array_equal(result_local.toarray(), result_dist.toarray())
示例10: test_same_output
def test_same_output(self):
X, X_rdd = self.make_text_rdd()
local = CountVectorizer()
dist = SparkCountVectorizer()
result_local = local.fit_transform(X).toarray()
result_dist = dist.fit_transform(X_rdd).toarray()
assert_equal(local.vocabulary_, dist.vocabulary_)
assert_array_equal(result_local, result_dist)
示例11: test_transform
def test_transform(self):
data = np.arange(400).reshape((100, 4))
rdd = self.sc.parallelize(data, 4)
X = ArrayRDD(rdd, 5)
fn = lambda x: x ** 2
X1 = map(fn, X.collect())
X2 = X.transform(fn).collect()
assert_array_equal(X1, X2)
示例12: test_same_inverse_transform
def test_same_inverse_transform(self):
Y, Y_rdd = self.make_dense_randint_rdd((1000,), low_high=(0, 10))
local = LabelEncoder().fit(Y)
dist = SparkLabelEncoder().fit(Y_rdd)
assert_array_equal(
local.inverse_transform(Y),
dist.inverse_transform(Y_rdd).toarray()
)
示例13: test_same_output_sparse
def test_same_output_sparse(self):
X, X_rdd = self.make_dict_dataset()
local = DictVectorizer(sparse=True)
dist = SparkDictVectorizer(sparse=True)
result_local = local.fit_transform(X)
result_dist = dist.fit_transform(X_rdd)
assert_true(check_rdd_dtype(result_dist, (sp.spmatrix,)))
assert_equal(local.vocabulary_, dist.vocabulary_)
assert_array_equal(result_local.toarray(), result_dist.toarray())
示例14: test_convert_toarray
def test_convert_toarray(self):
data = np.arange(400)
rdd = self.sc.parallelize(data, 4)
X = ArrayRDD(rdd, 5)
X_array = X.toarray()
assert_array_equal(X_array, data)
data = [2, 3, 5, 1, 6, 7, 9, 9]
rdd = self.sc.parallelize(data, 2)
X = ArrayRDD(rdd)
X_array = X.toarray()
assert_array_equal(X_array, np.array(data))
示例15: test_sum
def test_sum(self):
data = np.arange(400).reshape((100, 4))
rdd = self.sc.parallelize(data)
assert_equal(ArrayRDD(rdd).sum(), data.sum())
assert_array_equal(ArrayRDD(rdd).sum(axis=0), data.sum(axis=0))
assert_array_equal(ArrayRDD(rdd).sum(axis=1), data.sum(axis=1))
data = np.arange(600).reshape((100, 3, 2))
rdd = self.sc.parallelize(data)
assert_equal(ArrayRDD(rdd).sum(), data.sum())
assert_array_equal(ArrayRDD(rdd).sum(axis=0), data.sum(axis=0))
assert_array_equal(ArrayRDD(rdd).sum(axis=1), data.sum(axis=1))
assert_array_equal(ArrayRDD(rdd).sum(axis=2), data.sum(axis=2))