本文整理匯總了Python中thunder.ThunderContext.export方法的典型用法代碼示例。如果您正苦於以下問題:Python ThunderContext.export方法的具體用法?Python ThunderContext.export怎麽用?Python ThunderContext.export使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類thunder.ThunderContext
的用法示例。
在下文中一共展示了ThunderContext.export方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: TestContextWriting
# 需要導入模塊: from thunder import ThunderContext [as 別名]
# 或者: from thunder.ThunderContext import export [as 別名]
class TestContextWriting(PySparkTestCaseWithOutputDir):
def setUp(self):
super(TestContextWriting, self).setUp()
self.tsc = ThunderContext(self.sc)
def test_export_npy(self):
from numpy import load
a = array([[1, 2], [2, 3]])
filename = self.outputdir + "/test.npy"
self.tsc.export(a, filename)
aa = load(filename)
assert(array_equal(aa, a))
filename = self.outputdir + "/test"
self.tsc.export(a, filename, outputFormat="npy", overwrite=True)
aa = load(filename + ".npy")
assert(array_equal(aa, a))
def test_export_mat(self):
from scipy.io import loadmat
a = array([[1, 2], [2, 3]])
filename = self.outputdir + "/test.mat"
self.tsc.export(a, filename)
aa = loadmat(filename)
assert(array_equal(aa['test'], a))
filename = self.outputdir + "/test"
self.tsc.export(a, filename, outputFormat="mat", overwrite=True)
aa = loadmat(filename + ".mat")
assert(array_equal(aa['test'], a))
filename = self.outputdir + "/test"
self.tsc.export(a, filename, outputFormat="mat", varname="tmp", overwrite=True)
aa = loadmat(filename + ".mat")
assert(array_equal(aa['tmp'], a))
def test_export_txt(self):
from numpy import loadtxt
a = array([[1, 2], [2, 3]])
filename = self.outputdir + "/test.txt"
self.tsc.export(a, filename)
aa = loadtxt(filename)
assert(array_equal(aa, a))
filename = self.outputdir + "/test"
self.tsc.export(a, filename, outputFormat="txt", overwrite=True)
aa = loadtxt(filename + ".txt")
assert(array_equal(aa, a))