本文整理汇总了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))