default format for Table is ASCII

hence, renamed load_ASCII/save_ASCII to load/save
This commit is contained in:
Martin Diehl 2020-09-20 20:45:06 +02:00
parent 5895e74029
commit 6ab88aad2b
29 changed files with 59 additions and 59 deletions

@ -1 +1 @@
Subproject commit 576f3af61c3d893b608809cc91e46647809010f1 Subproject commit 7c543a98e89840f1f1540c7af8c62a19084dab6e

View File

@ -42,10 +42,10 @@ rot_to_TSL = damask.Rotation.from_axis_angle([-1,0,0,.75*np.pi])
for name in filenames: for name in filenames:
damask.util.report(scriptName,name) damask.util.report(scriptName,name)
table = damask.Table.load_ASCII(StringIO(''.join(sys.stdin.read())) if name is None else name) table = damask.Table.load(StringIO(''.join(sys.stdin.read())) if name is None else name)
coord = - table.get(options.frame) coord = - table.get(options.frame)
coord[:,2] += table.get(options.depth)[:,0] coord[:,2] += table.get(options.depth)[:,0]
table.add('coord',rot_to_TSL.broadcast_to(coord.shape[0]) @ coord,scriptID+' '+' '.join(sys.argv[1:]))\ table.add('coord',rot_to_TSL.broadcast_to(coord.shape[0]) @ coord,scriptID+' '+' '.join(sys.argv[1:]))\
.save_ASCII((sys.stdout if name is None else name),legacy=True) .save((sys.stdout if name is None else name),legacy=True)

View File

@ -39,10 +39,10 @@ if options.labels is None:
for name in filenames: for name in filenames:
damask.util.report(scriptName,name) damask.util.report(scriptName,name)
table = damask.Table.load_ASCII(StringIO(''.join(sys.stdin.read())) if name is None else name) table = damask.Table.load(StringIO(''.join(sys.stdin.read())) if name is None else name)
for label in options.labels: for label in options.labels:
table = table.add('cum_{}({})'.format('prod' if options.product else 'sum',label), table = table.add('cum_{}({})'.format('prod' if options.product else 'sum',label),
np.cumprod(table.get(label),0) if options.product else np.cumsum(table.get(label),0), np.cumprod(table.get(label),0) if options.product else np.cumsum(table.get(label),0),
scriptID+' '+' '.join(sys.argv[1:])) scriptID+' '+' '.join(sys.argv[1:]))
table.save_ASCII((sys.stdout if name is None else name),legacy=True) table.save((sys.stdout if name is None else name),legacy=True)

View File

@ -60,4 +60,4 @@ for filename in options.filenames:
os.mkdir(dirname,0o755) os.mkdir(dirname,0o755)
file_out = '{}_inc{}.txt'.format(os.path.splitext(os.path.split(filename)[-1])[0], file_out = '{}_inc{}.txt'.format(os.path.splitext(os.path.split(filename)[-1])[0],
inc[3:].zfill(N_digits)) inc[3:].zfill(N_digits))
table.save_ASCII(os.path.join(dirname,file_out),legacy=True) table.save(os.path.join(dirname,file_out),legacy=True)

View File

@ -172,7 +172,7 @@ if filenames == []: filenames = [None]
for name in filenames: for name in filenames:
damask.util.report(scriptName,name) damask.util.report(scriptName,name)
table = damask.Table.load_ASCII(StringIO(''.join(sys.stdin.read())) if name is None else name) table = damask.Table.load(StringIO(''.join(sys.stdin.read())) if name is None else name)
grid,size,origin = damask.grid_filters.cell_coord0_gridSizeOrigin(table.get(options.pos)) grid,size,origin = damask.grid_filters.cell_coord0_gridSizeOrigin(table.get(options.pos))
F = table.get(options.defgrad).reshape(tuple(grid)+(-1,),order='F').reshape(tuple(grid)+(3,3)) F = table.get(options.defgrad).reshape(tuple(grid)+(-1,),order='F').reshape(tuple(grid)+(3,3))
@ -191,4 +191,4 @@ for name in filenames:
volumeMismatch.reshape(-1,1,order='F'), volumeMismatch.reshape(-1,1,order='F'),
scriptID+' '+' '.join(sys.argv[1:])) scriptID+' '+' '.join(sys.argv[1:]))
table.save_ASCII((sys.stdout if name is None else name), legacy=True) table.save((sys.stdout if name is None else name), legacy=True)

View File

@ -43,7 +43,7 @@ if options.labels is None: parser.error('no data column specified.')
for name in filenames: for name in filenames:
damask.util.report(scriptName,name) damask.util.report(scriptName,name)
table = damask.Table.load_ASCII(StringIO(''.join(sys.stdin.read())) if name is None else name) table = damask.Table.load(StringIO(''.join(sys.stdin.read())) if name is None else name)
grid,size,origin = damask.grid_filters.cell_coord0_gridSizeOrigin(table.get(options.pos)) grid,size,origin = damask.grid_filters.cell_coord0_gridSizeOrigin(table.get(options.pos))
for label in options.labels: for label in options.labels:
@ -55,4 +55,4 @@ for name in filenames:
curl.reshape(tuple(grid)+(-1,)).reshape(-1,np.prod(shape),order='F'), curl.reshape(tuple(grid)+(-1,)).reshape(-1,np.prod(shape),order='F'),
scriptID+' '+' '.join(sys.argv[1:])) scriptID+' '+' '.join(sys.argv[1:]))
table.save_ASCII((sys.stdout if name is None else name), legacy=True) table.save((sys.stdout if name is None else name), legacy=True)

View File

@ -65,10 +65,10 @@ if options.labels is None:
for name in filenames: for name in filenames:
damask.util.report(scriptName,name) damask.util.report(scriptName,name)
table = damask.Table.load_ASCII(StringIO(''.join(sys.stdin.read())) if name is None else name) table = damask.Table.load(StringIO(''.join(sys.stdin.read())) if name is None else name)
for label in options.labels: for label in options.labels:
table = table.add('d({})/d({})'.format(label,options.coordinates), table = table.add('d({})/d({})'.format(label,options.coordinates),
derivative(table.get(options.coordinates),table.get(label)), derivative(table.get(options.coordinates),table.get(label)),
scriptID+' '+' '.join(sys.argv[1:])) scriptID+' '+' '.join(sys.argv[1:]))
table.save_ASCII((sys.stdout if name is None else name), legacy=True) table.save((sys.stdout if name is None else name), legacy=True)

View File

@ -47,7 +47,7 @@ parser.set_defaults(f = 'f',
for name in filenames: for name in filenames:
damask.util.report(scriptName,name) damask.util.report(scriptName,name)
table = damask.Table.load_ASCII(StringIO(''.join(sys.stdin.read())) if name is None else name) table = damask.Table.load(StringIO(''.join(sys.stdin.read())) if name is None else name)
grid,size,origin = damask.grid_filters.cell_coord0_gridSizeOrigin(table.get(options.pos)) grid,size,origin = damask.grid_filters.cell_coord0_gridSizeOrigin(table.get(options.pos))
F = table.get(options.f).reshape(tuple(grid)+(-1,),order='F').reshape(tuple(grid)+(3,3)) F = table.get(options.f).reshape(tuple(grid)+(-1,),order='F').reshape(tuple(grid)+(3,3))
@ -60,7 +60,7 @@ for name in filenames:
.add('fluct({}).{}'.format(options.f,options.pos), .add('fluct({}).{}'.format(options.f,options.pos),
damask.grid_filters.node_displacement_fluct(size,F).reshape(-1,3,order='F'), damask.grid_filters.node_displacement_fluct(size,F).reshape(-1,3,order='F'),
scriptID+' '+' '.join(sys.argv[1:]))\ scriptID+' '+' '.join(sys.argv[1:]))\
.save_ASCII((sys.stdout if name is None else os.path.splitext(name)[0]+'_nodal.txt'), legacy=True) .save((sys.stdout if name is None else os.path.splitext(name)[0]+'_nodal.txt'), legacy=True)
else: else:
table.add('avg({}).{}'.format(options.f,options.pos), table.add('avg({}).{}'.format(options.f,options.pos),
damask.grid_filters.cell_displacement_avg(size,F).reshape(-1,3,order='F'), damask.grid_filters.cell_displacement_avg(size,F).reshape(-1,3,order='F'),
@ -68,4 +68,4 @@ for name in filenames:
.add('fluct({}).{}'.format(options.f,options.pos), .add('fluct({}).{}'.format(options.f,options.pos),
damask.grid_filters.cell_displacement_fluct(size,F).reshape(-1,3,order='F'), damask.grid_filters.cell_displacement_fluct(size,F).reshape(-1,3,order='F'),
scriptID+' '+' '.join(sys.argv[1:]))\ scriptID+' '+' '.join(sys.argv[1:]))\
.save_ASCII((sys.stdout if name is None else name), legacy=True) .save((sys.stdout if name is None else name), legacy=True)

View File

@ -43,7 +43,7 @@ if options.labels is None: parser.error('no data column specified.')
for name in filenames: for name in filenames:
damask.util.report(scriptName,name) damask.util.report(scriptName,name)
table = damask.Table.load_ASCII(StringIO(''.join(sys.stdin.read())) if name is None else name) table = damask.Table.load(StringIO(''.join(sys.stdin.read())) if name is None else name)
grid,size,origin = damask.grid_filters.cell_coord0_gridSizeOrigin(table.get(options.pos)) grid,size,origin = damask.grid_filters.cell_coord0_gridSizeOrigin(table.get(options.pos))
for label in options.labels: for label in options.labels:
@ -55,4 +55,4 @@ for name in filenames:
div.reshape(tuple(grid)+(-1,)).reshape(-1,np.prod(shape)//3,order='F'), div.reshape(tuple(grid)+(-1,)).reshape(-1,np.prod(shape)//3,order='F'),
scriptID+' '+' '.join(sys.argv[1:])) scriptID+' '+' '.join(sys.argv[1:]))
table.save_ASCII((sys.stdout if name is None else name), legacy=True) table.save((sys.stdout if name is None else name), legacy=True)

View File

@ -142,7 +142,7 @@ for i,feature in enumerate(features):
for name in filenames: for name in filenames:
damask.util.report(scriptName,name) damask.util.report(scriptName,name)
table = damask.Table.load_ASCII(StringIO(''.join(sys.stdin.read())) if name is None else name) table = damask.Table.load(StringIO(''.join(sys.stdin.read())) if name is None else name)
grid,size,origin = damask.grid_filters.cell_coord0_gridSizeOrigin(table.get(options.pos)) grid,size,origin = damask.grid_filters.cell_coord0_gridSizeOrigin(table.get(options.pos))
neighborhood = neighborhoods[options.neighborhood] neighborhood = neighborhoods[options.neighborhood]
@ -184,4 +184,4 @@ for name in filenames:
distance[i,:], distance[i,:],
scriptID+' '+' '.join(sys.argv[1:])) scriptID+' '+' '.join(sys.argv[1:]))
table.save_ASCII((sys.stdout if name is None else name), legacy=True) table.save((sys.stdout if name is None else name), legacy=True)

View File

@ -63,7 +63,7 @@ if options.labels is None: parser.error('no data column specified.')
for name in filenames: for name in filenames:
damask.util.report(scriptName,name) damask.util.report(scriptName,name)
table = damask.Table.load_ASCII(StringIO(''.join(sys.stdin.read())) if name is None else name) table = damask.Table.load(StringIO(''.join(sys.stdin.read())) if name is None else name)
damask.grid_filters.coord0_check(table.get(options.pos)) damask.grid_filters.coord0_check(table.get(options.pos))
for label in options.labels: for label in options.labels:
@ -73,4 +73,4 @@ for name in filenames:
mode = 'wrap' if options.periodic else 'nearest'), mode = 'wrap' if options.periodic else 'nearest'),
scriptID+' '+' '.join(sys.argv[1:])) scriptID+' '+' '.join(sys.argv[1:]))
table.save_ASCII((sys.stdout if name is None else name), legacy=True) table.save((sys.stdout if name is None else name), legacy=True)

View File

@ -43,7 +43,7 @@ if options.labels is None: parser.error('no data column specified.')
for name in filenames: for name in filenames:
damask.util.report(scriptName,name) damask.util.report(scriptName,name)
table = damask.Table.load_ASCII(StringIO(''.join(sys.stdin.read())) if name is None else name) table = damask.Table.load(StringIO(''.join(sys.stdin.read())) if name is None else name)
grid,size,origin = damask.grid_filters.cell_coord0_gridSizeOrigin(table.get(options.pos)) grid,size,origin = damask.grid_filters.cell_coord0_gridSizeOrigin(table.get(options.pos))
for label in options.labels: for label in options.labels:
@ -55,4 +55,4 @@ for name in filenames:
grad.reshape(tuple(grid)+(-1,)).reshape(-1,np.prod(shape)*3,order='F'), grad.reshape(tuple(grid)+(-1,)).reshape(-1,np.prod(shape)*3,order='F'),
scriptID+' '+' '.join(sys.argv[1:])) scriptID+' '+' '.join(sys.argv[1:]))
table.save_ASCII((sys.stdout if name is None else name), legacy=True) table.save((sys.stdout if name is None else name), legacy=True)

View File

@ -110,7 +110,7 @@ R = damask.Rotation.from_axis_angle(np.array(options.labrotation),options.degree
for name in filenames: for name in filenames:
damask.util.report(scriptName,name) damask.util.report(scriptName,name)
table = damask.Table.load_ASCII(StringIO(''.join(sys.stdin.read())) if name is None else name) table = damask.Table.load(StringIO(''.join(sys.stdin.read())) if name is None else name)
if options.eulers is not None: if options.eulers is not None:
label = options.eulers label = options.eulers
@ -147,4 +147,4 @@ for name in filenames:
if 'axisangle' in options.output: if 'axisangle' in options.output:
table = table.add('om({})'.format(label),o.as_axisangle(options.degrees), scriptID+' '+' '.join(sys.argv[1:])) table = table.add('om({})'.format(label),o.as_axisangle(options.degrees), scriptID+' '+' '.join(sys.argv[1:]))
table.save_ASCII((sys.stdout if name is None else name), legacy=True) table.save((sys.stdout if name is None else name), legacy=True)

View File

@ -175,7 +175,7 @@ labels = ['S[{direction[0]:.1g}_{direction[1]:.1g}_{direction[2]:.1g}]'
for name in filenames: for name in filenames:
damask.util.report(scriptName,name) damask.util.report(scriptName,name)
table = damask.Table.load_ASCII(StringIO(''.join(sys.stdin.read())) if name is None else name) table = damask.Table.load(StringIO(''.join(sys.stdin.read())) if name is None else name)
o = damask.Rotation.from_quaternion(table.get(options.quaternion)) o = damask.Rotation.from_quaternion(table.get(options.quaternion))
@ -189,4 +189,4 @@ for name in filenames:
for i,label in enumerate(labels): for i,label in enumerate(labels):
table = table.add(label,S[:,i],scriptID+' '+' '.join(sys.argv[1:])) table = table.add(label,S[:,i],scriptID+' '+' '.join(sys.argv[1:]))
table.save_ASCII((sys.stdout if name is None else name), legacy=True) table.save((sys.stdout if name is None else name), legacy=True)

View File

@ -47,7 +47,7 @@ if filenames == []: filenames = [None]
for name in filenames: for name in filenames:
damask.util.report(scriptName,name) damask.util.report(scriptName,name)
table = damask.Table.load_ASCII(StringIO(''.join(sys.stdin.read())) if name is None else name) table = damask.Table.load(StringIO(''.join(sys.stdin.read())) if name is None else name)
randomSeed = int(os.urandom(4).hex(), 16) if options.randomSeed is None else options.randomSeed # random seed per file randomSeed = int(os.urandom(4).hex(), 16) if options.randomSeed is None else options.randomSeed # random seed per file
rng = np.random.default_rng(randomSeed) rng = np.random.default_rng(randomSeed)
@ -58,4 +58,4 @@ for name in filenames:
rng.shuffle(uniques) rng.shuffle(uniques)
table = table.set(label,uniques[inverse], scriptID+' '+' '.join(sys.argv[1:])) table = table.set(label,uniques[inverse], scriptID+' '+' '.join(sys.argv[1:]))
table.save_ASCII((sys.stdout if name is None else name), legacy=True) table.save((sys.stdout if name is None else name), legacy=True)

View File

@ -154,4 +154,4 @@ for name in filenames:
homogenization=options.homogenization,comments=header) homogenization=options.homogenization,comments=header)
damask.util.croak(geom) damask.util.croak(geom)
geom.save_ASCII(os.path.splitext(name)[0]+'.geom',pack=False) geom.save_ASCII(os.path.splitext(name)[0]+'.geom',compress=False)

View File

@ -68,7 +68,7 @@ if options.axes is not None and not set(options.axes).issubset(set(['x','+x','-x
for name in filenames: for name in filenames:
damask.util.report(scriptName,name) damask.util.report(scriptName,name)
table = damask.Table.load_ASCII(StringIO(''.join(sys.stdin.read())) if name is None else name) table = damask.Table.load(StringIO(''.join(sys.stdin.read())) if name is None else name)
table.sort_by(['{}_{}'.format(i,options.pos) for i in range(3,0,-1)]) # x fast, y slow table.sort_by(['{}_{}'.format(i,options.pos) for i in range(3,0,-1)]) # x fast, y slow
grid,size,origin = damask.grid_filters.cell_coord0_gridSizeOrigin(table.get(options.pos)) grid,size,origin = damask.grid_filters.cell_coord0_gridSizeOrigin(table.get(options.pos))

View File

@ -171,7 +171,7 @@ if filenames == []: filenames = [None]
for name in filenames: for name in filenames:
damask.util.report(scriptName,name) damask.util.report(scriptName,name)
table = damask.Table.load_ASCII(StringIO(''.join(sys.stdin.read())) if name is None else name) table = damask.Table.load(StringIO(''.join(sys.stdin.read())) if name is None else name)
size = np.ones(3) size = np.ones(3)
origin = np.zeros(3) origin = np.zeros(3)
@ -228,4 +228,4 @@ for name in filenames:
homogenization=options.homogenization,comments=header) homogenization=options.homogenization,comments=header)
damask.util.croak(geom) damask.util.croak(geom)
geom.save_ASCII(sys.stdout if name is None else os.path.splitext(name)[0]+'.geom',pack=False) geom.save_ASCII(sys.stdout if name is None else os.path.splitext(name)[0]+'.geom',compress=False)

View File

@ -172,4 +172,4 @@ for name in filenames:
geom = geom.duplicate(microstructure[0:grid_original[0],0:grid_original[1],0:grid_original[2]]) geom = geom.duplicate(microstructure[0:grid_original[0],0:grid_original[1],0:grid_original[2]])
geom.add_comments(scriptID + ' ' + ' '.join(sys.argv[1:])) geom.add_comments(scriptID + ' ' + ' '.join(sys.argv[1:]))
geom.save_ASCII(sys.stdout if name is None else name,pack=False) geom.save_ASCII(sys.stdout if name is None else name,compress=False)

View File

@ -234,7 +234,7 @@ if filenames == []: filenames = [None]
for name in filenames: for name in filenames:
damask.util.report(scriptName,name) damask.util.report(scriptName,name)
table = damask.Table.load_ASCII(StringIO(''.join(sys.stdin.read())) if name is None else name) table = damask.Table.load(StringIO(''.join(sys.stdin.read())) if name is None else name)
randomSeed = int(os.urandom(4).hex(),16) if options.randomSeed is None else options.randomSeed # random seed per file randomSeed = int(os.urandom(4).hex(),16) if options.randomSeed is None else options.randomSeed # random seed per file
random.seed(randomSeed) random.seed(randomSeed)

View File

@ -78,7 +78,7 @@ class myThread (threading.Thread):
perturbedSeedsVFile = StringIO() perturbedSeedsVFile = StringIO()
myBestSeedsVFile.seek(0) myBestSeedsVFile.seek(0)
perturbedSeedsTable = damask.Table.load_ASCII(myBestSeedsVFile) perturbedSeedsTable = damask.Table.load(myBestSeedsVFile)
coords = perturbedSeedsTable.get('pos') coords = perturbedSeedsTable.get('pos')
i = 0 i = 0
for ms,coord in enumerate(coords): for ms,coord in enumerate(coords):
@ -89,7 +89,7 @@ class myThread (threading.Thread):
coords[i]=newCoords coords[i]=newCoords
direction[i]*=2. direction[i]*=2.
i+= 1 i+= 1
perturbedSeedsTable.set('pos',coords).save_ASCII(perturbedSeedsVFile,legacy=True) perturbedSeedsTable.set('pos',coords).save(perturbedSeedsVFile,legacy=True)
#--- do tesselation with perturbed seed file ------------------------------------------------------ #--- do tesselation with perturbed seed file ------------------------------------------------------
perturbedGeomVFile.close() perturbedGeomVFile.close()

View File

@ -65,4 +65,4 @@ for name in filenames:
damask.Table(seeds[mask],{'pos':(3,)},comments)\ damask.Table(seeds[mask],{'pos':(3,)},comments)\
.add('microstructure',microstructure[mask].astype(int))\ .add('microstructure',microstructure[mask].astype(int))\
.save_ASCII(sys.stdout if name is None else os.path.splitext(name)[0]+'.seeds',legacy=True) .save(sys.stdout if name is None else os.path.splitext(name)[0]+'.seeds',legacy=True)

View File

@ -92,5 +92,5 @@ for name in filenames:
table = damask.Table(seeds,{'pos':(3,),'microstructure':(1,)},comments) table = damask.Table(seeds,{'pos':(3,),'microstructure':(1,)},comments)
table.set('microstructure',table.get('microstructure').astype(np.int))\ table.set('microstructure',table.get('microstructure').astype(np.int))\
.save_ASCII(sys.stdout if name is None else \ .save(sys.stdout if name is None else \
os.path.splitext(name)[0]+f'_poked_{options.N}.seeds',legacy=True) os.path.splitext(name)[0]+f'_poked_{options.N}.seeds',legacy=True)

View File

@ -162,4 +162,4 @@ for name in filenames:
else np.random.normal(loc = options.mean, scale = options.sigma, size = options.N) else np.random.normal(loc = options.mean, scale = options.sigma, size = options.N)
table = table.add('weight',weights) table = table.add('weight',weights)
table.save_ASCII(sys.stdout if name is None else name,legacy=True) table.save(sys.stdout if name is None else name,legacy=True)

View File

@ -297,9 +297,9 @@ class Colormap(mpl.colors.ListedColormap):
if fhandle is None: if fhandle is None:
with open(self.name.replace(' ','_')+'.txt', 'w') as f: with open(self.name.replace(' ','_')+'.txt', 'w') as f:
t.save_ASCII(f) t.save(f)
else: else:
t.save_ASCII(fhandle) t.save(fhandle)
def save_GOM(self,fname=None): def save_GOM(self,fname=None):

View File

@ -67,7 +67,7 @@ class Table:
@staticmethod @staticmethod
def load_ASCII(fname): def load(fname):
""" """
Load ASCII table file. Load ASCII table file.
@ -344,7 +344,7 @@ class Table:
return dup return dup
def save_ASCII(self,fname,legacy=False): def save(self,fname,legacy=False):
""" """
Save as plain text file. Save as plain text file.

View File

@ -287,9 +287,9 @@ class Test:
import numpy as np import numpy as np
logging.info('\n '.join(['comparing',File1,File2])) logging.info('\n '.join(['comparing',File1,File2]))
table = damask.Table.load_ASCII(File1) table = damask.Table.load(File1)
len1 = len(table.comments)+2 len1 = len(table.comments)+2
table = damask.Table.load_ASCII(File2) table = damask.Table.load(File2)
len2 = len(table.comments)+2 len2 = len(table.comments)+2
refArray = np.nan_to_num(np.genfromtxt(File1,missing_values='n/a',skip_header = len1,autostrip=True)) refArray = np.nan_to_num(np.genfromtxt(File1,missing_values='n/a',skip_header = len1,autostrip=True))
@ -436,7 +436,7 @@ class Test:
if not (isinstance(files, Iterable) and not isinstance(files, str)): # check whether list of files is requested if not (isinstance(files, Iterable) and not isinstance(files, str)): # check whether list of files is requested
files = [str(files)] files = [str(files)]
tables = [damask.Table.load_ASCII(filename) for filename in files] tables = [damask.Table.load(filename) for filename in files]
for table in tables: for table in tables:
table._label_discrete() table._label_discrete()
@ -486,7 +486,7 @@ class Test:
if len(files) < 2: return True # single table is always close to itself... if len(files) < 2: return True # single table is always close to itself...
tables = [damask.Table.load_ASCII(filename) for filename in files] tables = [damask.Table.load(filename) for filename in files]
columns += [columns[0]]*(len(files)-len(columns)) # extend to same length as files columns += [columns[0]]*(len(files)-len(columns)) # extend to same length as files
columns = columns[:len(files)] # truncate to same length as files columns = columns[:len(files)] # truncate to same length as files

View File

@ -106,8 +106,8 @@ class TestOrientation:
coords = np.array([(1,i+1) for i,x in enumerate(eu)]) coords = np.array([(1,i+1) for i,x in enumerate(eu)])
table = Table(eu,{'Eulers':(3,)}) table = Table(eu,{'Eulers':(3,)})
table = table.add('pos',coords) table = table.add('pos',coords)
table.save_ASCII(reference) table.save(reference)
assert np.allclose(eu,Table.load_ASCII(reference).get('Eulers')) assert np.allclose(eu,Table.load(reference).get('Eulers'))
@pytest.mark.parametrize('lattice',Lattice.lattices) @pytest.mark.parametrize('lattice',Lattice.lattices)
def test_disorientation360(self,lattice): def test_disorientation360(self,lattice):

View File

@ -35,30 +35,30 @@ class TestTable:
@pytest.mark.parametrize('mode',['str','path']) @pytest.mark.parametrize('mode',['str','path'])
def test_write_read(self,default,tmpdir,mode): def test_write_read(self,default,tmpdir,mode):
default.save_ASCII(tmpdir/'default.txt') default.save(tmpdir/'default.txt')
if mode == 'path': if mode == 'path':
new = Table.load_ASCII(tmpdir/'default.txt') new = Table.load(tmpdir/'default.txt')
elif mode == 'str': elif mode == 'str':
new = Table.load_ASCII(str(tmpdir/'default.txt')) new = Table.load(str(tmpdir/'default.txt'))
assert all(default.data==new.data) and default.shapes == new.shapes assert all(default.data==new.data) and default.shapes == new.shapes
def test_write_read_file(self,default,tmpdir): def test_write_read_file(self,default,tmpdir):
with open(tmpdir/'default.txt','w') as f: with open(tmpdir/'default.txt','w') as f:
default.save_ASCII(f) default.save(f)
with open(tmpdir/'default.txt') as f: with open(tmpdir/'default.txt') as f:
new = Table.load_ASCII(f) new = Table.load(f)
assert all(default.data==new.data) and default.shapes == new.shapes assert all(default.data==new.data) and default.shapes == new.shapes
def test_write_read_legacy_style(self,default,tmpdir): def test_write_read_legacy_style(self,default,tmpdir):
with open(tmpdir/'legacy.txt','w') as f: with open(tmpdir/'legacy.txt','w') as f:
default.save_ASCII(f,legacy=True) default.save(f,legacy=True)
with open(tmpdir/'legacy.txt') as f: with open(tmpdir/'legacy.txt') as f:
new = Table.load_ASCII(f) new = Table.load(f)
assert all(default.data==new.data) and default.shapes == new.shapes assert all(default.data==new.data) and default.shapes == new.shapes
def test_write_invalid_format(self,default,tmpdir): def test_write_invalid_format(self,default,tmpdir):
with pytest.raises(TypeError): with pytest.raises(TypeError):
default.save_ASCII(tmpdir/'shouldnotbethere.txt',format='invalid') default.save(tmpdir/'shouldnotbethere.txt',format='invalid')
@pytest.mark.parametrize('mode',['str','path']) @pytest.mark.parametrize('mode',['str','path'])
def test_read_ang(self,reference_dir,mode): def test_read_ang(self,reference_dir,mode):
@ -78,7 +78,7 @@ class TestTable:
@pytest.mark.parametrize('fname',['datatype-mix.txt','whitespace-mix.txt']) @pytest.mark.parametrize('fname',['datatype-mix.txt','whitespace-mix.txt'])
def test_read_strange(self,reference_dir,fname): def test_read_strange(self,reference_dir,fname):
with open(reference_dir/fname) as f: with open(reference_dir/fname) as f:
Table.load_ASCII(f) Table.load(f)
def test_set(self,default): def test_set(self,default):
d = default.set('F',np.zeros((5,3,3)),'set to zero').get('F') d = default.set('F',np.zeros((5,3,3)),'set to zero').get('F')