本文整理汇总了Python中scipy.io.mmio.mmwrite函数的典型用法代码示例。如果您正苦于以下问题:Python mmwrite函数的具体用法?Python mmwrite怎么用?Python mmwrite使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了mmwrite函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。
示例1: test_simple_rectangular_real
def test_simple_rectangular_real(self):
a = [[1, 2], [3.5, 4], [5, 6]]
fn = self.fn
mmwrite(fn, a)
assert_equal(mminfo(fn), (3, 2, 6, "array", "real", "general"))
b = mmread(fn)
assert_array_almost_equal(a, b)
开发者ID:hainm,项目名称:scipy,代码行数:7,代码来源:test_mmio.py
示例2: test_simple_rectangular
def test_simple_rectangular(self):
a = [[1, 2, 3], [4, 5, 6]]
fn = self.fn
mmwrite(fn, a)
assert_equal(mminfo(fn), (2, 3, 6, "array", "integer", "general"))
b = mmread(fn)
assert_array_almost_equal(a, b)
开发者ID:hainm,项目名称:scipy,代码行数:7,代码来源:test_mmio.py
示例3: test_simple_skew_symmetric
def test_simple_skew_symmetric(self):
a = [[1,2],[-2,4]]
fn = mktemp()
mmwrite(fn,a)
assert_equal(mminfo(fn),(2,2,4,'array','integer','skew-symmetric'))
b = mmread(fn)
assert_array_almost_equal(a,b)
开发者ID:AndreI11,项目名称:SatStressGui,代码行数:7,代码来源:test_mmio.py
示例4: matrixFactorization_graphlab
def matrixFactorization_graphlab(self,rows,cols,r,c,algo):
if platform.system() == 'Windows':
base_dir = 'D:'
elif platform.system() == 'Linux':
base_dir = '/workspace'
# Pull out the sparse sub-matrix for current co-cluster
#print r,c
Y_sparse = self.coo_submatrix_pull(rows,cols)
# Convert Data into Matrix Market format and write the Training data to file
Y_mm_file_name = base_dir + '/sdap/data/temp/mf'
# Remove the current files in .../data/temp/
#cmd = "rm -f" + base_dir + "/sdap/data/temp/*"
#os.system(cmd)
if os.path.isdir(base_dir + "/sdap/data/temp/"):
shutil.rmtree(base_dir + "/sdap/data/temp/")
os.mkdir(base_dir + "/sdap/data/temp/")
Y_mm_file = open(Y_mm_file_name,'w')
mm.mmwrite(Y_mm_file,Y_sparse,comment="")
# Call Matrix Factorization code
cmd = "~/graphlabapi/release/demoapps/pmf/pmf "+ Y_mm_file_name +" --matrixmarket=true --D="+str(self.D)+" --lambda="+str(self.lambda_reg)+" --minval=0.5 --maxval=5.0 --ncpus=16 --max_iter=50 --threshold=1e-6"
subprocess.call(cmd,shell=True)#,stdout=subprocess.PIPE,stderr=subprocess.STDOUT) #TO DO replace
#os.system(cmd)
# Read all the files for the output Latent Factors and return Us and Vs
U,V = self.readLatentFactors(base_dir)
#print U.shape, len(rows)
#print V.shape, len(cols)
#import sys
#sys.exit()
return U,V
开发者ID:neerajg,项目名称:sdap,代码行数:33,代码来源:MFModel.py
示例5: test_simple_skew_symmetric_float
def test_simple_skew_symmetric_float(self):
a = array([[1, 2], [-2.0, 4]], "f")
fn = self.fn
mmwrite(fn, a)
assert_equal(mminfo(fn), (2, 2, 4, "array", "real", "skew-symmetric"))
b = mmread(fn)
assert_array_almost_equal(a, b)
开发者ID:hainm,项目名称:scipy,代码行数:7,代码来源:test_mmio.py
示例6: test_simple_hermitian
def test_simple_hermitian(self):
a = [[1, 2 + 3j], [2 - 3j, 4]]
fn = self.fn
mmwrite(fn, a)
assert_equal(mminfo(fn), (2, 2, 4, "array", "complex", "hermitian"))
b = mmread(fn)
assert_array_almost_equal(a, b)
开发者ID:hainm,项目名称:scipy,代码行数:7,代码来源:test_mmio.py
示例7: test_simple_skew_symmetric
def test_simple_skew_symmetric(self):
a = [[1, 2], [-2, 4]]
fn = self.fn
mmwrite(fn, a)
assert_equal(mminfo(fn), (2, 2, 4, "array", "integer", "skew-symmetric"))
b = mmread(fn)
assert_array_almost_equal(a, b)
开发者ID:hainm,项目名称:scipy,代码行数:7,代码来源:test_mmio.py
示例8: test_simple_complex
def test_simple_complex(self):
a = [[1,2],[3,4j]]
fn = mktemp()
mmwrite(fn,a)
assert_equal(mminfo(fn),(2,2,4,'array','complex','general'))
b = mmread(fn)
assert_array_almost_equal(a,b)
开发者ID:AndreI11,项目名称:SatStressGui,代码行数:7,代码来源:test_mmio.py
示例9: test_simple_hermitian
def test_simple_hermitian(self):
a = [[1,2+3j],[2-3j,4]]
fn = mktemp()
mmwrite(fn,a)
assert_equal(mminfo(fn),(2,2,4,'array','complex','hermitian'))
b = mmread(fn)
assert_array_almost_equal(a,b)
开发者ID:AndreI11,项目名称:SatStressGui,代码行数:7,代码来源:test_mmio.py
示例10: test_simple_skew_symmetric_float
def test_simple_skew_symmetric_float(self):
a = array([[1,2],[-2.0,4]],'f')
fn = mktemp()
mmwrite(fn,a)
assert_equal(mminfo(fn),(2,2,4,'array','real','skew-symmetric'))
b = mmread(fn)
assert_array_almost_equal(a,b)
开发者ID:AndreI11,项目名称:SatStressGui,代码行数:7,代码来源:test_mmio.py
示例11: test_simple_complex
def test_simple_complex(self):
a = [[1, 2], [3, 4j]]
fn = self.fn
mmwrite(fn, a)
assert_equal(mminfo(fn), (2, 2, 4, "array", "complex", "general"))
b = mmread(fn)
assert_array_almost_equal(a, b)
开发者ID:hainm,项目名称:scipy,代码行数:7,代码来源:test_mmio.py
示例12: test_simple_rectangular_real
def test_simple_rectangular_real(self):
a = [[1,2],[3.5,4],[5,6]]
fn = mktemp()
mmwrite(fn,a)
assert_equal(mminfo(fn),(3,2,6,'array','real','general'))
b = mmread(fn)
assert_array_almost_equal(a,b)
开发者ID:AndreI11,项目名称:SatStressGui,代码行数:7,代码来源:test_mmio.py
示例13: test_simple_rectangular
def test_simple_rectangular(self):
a = [[1,2,3],[4,5,6]]
fn = mktemp()
mmwrite(fn,a)
assert_equal(mminfo(fn),(2,3,6,'array','integer','general'))
b = mmread(fn)
assert_array_almost_equal(a,b)
开发者ID:AndreI11,项目名称:SatStressGui,代码行数:7,代码来源:test_mmio.py
示例14: test_simple_real
def test_simple_real(self):
a = [[1,2],[3,4.0]]
fn = self.fn
mmwrite(fn,a)
assert_equal(mminfo(fn),(2,2,4,'array','real','general'))
b = mmread(fn)
assert_array_almost_equal(a,b)
开发者ID:hitej,项目名称:meta-core,代码行数:7,代码来源:test_mmio.py
示例15: test_random_rect_real
def test_random_rect_real(self):
sz = (20,15)
a = rand(*sz)
fn = mktemp()
mmwrite(fn,a)
assert_equal(mminfo(fn),(20,15,300,'array','real','general'))
b = mmread(fn)
assert_array_almost_equal(a,b)
开发者ID:AndreI11,项目名称:SatStressGui,代码行数:8,代码来源:test_mmio.py
示例16: test_random_rect_real
def test_random_rect_real(self):
sz = (20, 15)
a = rand(*sz)
fn = self.fn
mmwrite(fn, a)
assert_equal(mminfo(fn), (20, 15, 300, "array", "real", "general"))
b = mmread(fn)
assert_array_almost_equal(a, b)
开发者ID:hainm,项目名称:scipy,代码行数:8,代码来源:test_mmio.py
示例17: test_simple_pattern
def test_simple_pattern(self):
a = scipy.sparse.csr_matrix([[0, 1.5], [3.0, 2.5]])
p = np.zeros_like(a.todense())
p[a.todense() > 0] = 1
info = (2, 2, 3, 'coordinate', 'pattern', 'general')
mmwrite(self.fn, a, field='pattern')
assert_equal(mminfo(self.fn), info)
b = mmread(self.fn)
assert_array_almost_equal(p, b.todense())
开发者ID:Kitchi,项目名称:scipy,代码行数:9,代码来源:test_mmio.py
示例18: test_random_symmetric_real
def test_random_symmetric_real(self):
sz = (20,20)
a = rand(*sz)
a = a + transpose(a)
fn = mktemp()
mmwrite(fn,a)
assert_equal(mminfo(fn),(20,20,400,'array','real','symmetric'))
b = mmread(fn)
assert_array_almost_equal(a,b)
开发者ID:AndreI11,项目名称:SatStressGui,代码行数:9,代码来源:test_mmio.py
示例19: test_random_symmetric_real
def test_random_symmetric_real(self):
sz = (20, 20)
a = rand(*sz)
a = a + transpose(a)
fn = self.fn
mmwrite(fn, a)
assert_equal(mminfo(fn), (20, 20, 400, "array", "real", "symmetric"))
b = mmread(fn)
assert_array_almost_equal(a, b)
开发者ID:hainm,项目名称:scipy,代码行数:9,代码来源:test_mmio.py
示例20: test_empty_write_read
def test_empty_write_read(self):
# https://github.com/scipy/scipy/issues/1410 (Trac #883)
b = scipy.sparse.coo_matrix((10, 10))
mmwrite(self.fn, b)
assert_equal(mminfo(self.fn),
(10, 10, 0, 'coordinate', 'real', 'symmetric'))
a = b.todense()
b = mmread(self.fn).todense()
assert_array_almost_equal(a, b)
开发者ID:Kitchi,项目名称:scipy,代码行数:11,代码来源:test_mmio.py
注:本文中的scipy.io.mmio.mmwrite函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论