increasing test coverage
This commit is contained in:
parent
9eb4e2d0de
commit
764aacf2a1
|
@ -9,8 +9,6 @@ class Environment:
|
|||
|
||||
@property
|
||||
def screen_size(self):
|
||||
width = 1024
|
||||
height = 768
|
||||
try:
|
||||
import wx
|
||||
_ = wx.App(False) # noqa
|
||||
|
@ -23,7 +21,9 @@ class Environment:
|
|||
height = tk.winfo_screenheight()
|
||||
tk.destroy()
|
||||
except Exception as e:
|
||||
pass
|
||||
width = 1024
|
||||
height = 768
|
||||
|
||||
return (width,height)
|
||||
|
||||
|
||||
|
|
|
@ -2,6 +2,7 @@ import copy
|
|||
import multiprocessing as mp
|
||||
from functools import partial
|
||||
from os import path
|
||||
import warnings
|
||||
|
||||
import numpy as np
|
||||
import pandas as pd
|
||||
|
@ -188,12 +189,16 @@ class Geom:
|
|||
"""
|
||||
Read a geom file.
|
||||
|
||||
Storing geometry files in ASCII format is deprecated.
|
||||
This function will be removed in a future version of DAMASK.
|
||||
|
||||
Parameters
|
||||
----------
|
||||
fname : str, pathlib.Path, or file handle
|
||||
Geometry file to read.
|
||||
|
||||
"""
|
||||
warnings.warn('Support for ASCII-based geom format will be removed in DAMASK 3.1.0', DeprecationWarning)
|
||||
try:
|
||||
f = open(fname)
|
||||
except TypeError:
|
||||
|
@ -247,7 +252,6 @@ class Geom:
|
|||
return Geom(material.reshape(grid,order='F'),size,origin,comments)
|
||||
|
||||
|
||||
|
||||
@staticmethod
|
||||
def load_DREAM3D(fname,base_group,point_data=None,material='FeatureIds'):
|
||||
"""
|
||||
|
@ -523,6 +527,9 @@ class Geom:
|
|||
"""
|
||||
Write a geom file.
|
||||
|
||||
Storing geometry files in ASCII format is deprecated.
|
||||
This function will be removed in a future version of DAMASK.
|
||||
|
||||
Parameters
|
||||
----------
|
||||
fname : str or file handle
|
||||
|
@ -531,6 +538,7 @@ class Geom:
|
|||
Compress geometry with 'x of y' and 'a to b'.
|
||||
|
||||
"""
|
||||
warnings.warn('Support for ASCII-based geom format will be removed in DAMASK 3.1.0', DeprecationWarning)
|
||||
header = [f'{len(self.comments)+4} header'] + self.comments \
|
||||
+ ['grid a {} b {} c {}'.format(*self.grid),
|
||||
'size x {} y {} z {}'.format(*self.size),
|
||||
|
|
|
@ -45,6 +45,8 @@ class TestGeom:
|
|||
new = Geom(default.material[1:,1:,1:]+1,default.size*.9,np.ones(3)-default.origin,comments=['modified'])
|
||||
assert str(default.diff(new)) != ''
|
||||
|
||||
def test_repr(self,default):
|
||||
print(default)
|
||||
|
||||
def test_read_write_vtr(self,default,tmp_path):
|
||||
default.save(tmp_path/'default')
|
||||
|
@ -70,6 +72,9 @@ class TestGeom:
|
|||
Geom(default.material[1:,1:,1:],
|
||||
size=np.ones(2))
|
||||
|
||||
def test_save_load_ASCII(self,default,tmp_path):
|
||||
default.save_ASCII(tmp_path/'ASCII')
|
||||
assert geom_equal(Geom.load_ASCII(tmp_path/'ASCII'),default)
|
||||
|
||||
def test_invalid_origin(self,default):
|
||||
with pytest.raises(ValueError):
|
||||
|
|
|
@ -84,6 +84,15 @@ class TestVTK:
|
|||
time.sleep(.5)
|
||||
assert(False)
|
||||
|
||||
def test_compress(self,tmp_path):
|
||||
points = np.random.rand(102,3)
|
||||
v = VTK.from_poly_data(points)
|
||||
fname_c = tmp_path/'compreesed.vtp'
|
||||
fname_p = tmp_path/'plain.vtp'
|
||||
v.save(fname_c,parallel=False,compress=False)
|
||||
v.save(fname_p,parallel=False,compress=True)
|
||||
assert(VTK.load(fname_c).__repr__() == VTK.load(fname_p).__repr__())
|
||||
|
||||
|
||||
@pytest.mark.parametrize('fname',['a','a.vtp','a.b','a.b.vtp'])
|
||||
def test_filename_variations(self,tmp_path,fname):
|
||||
|
|
Loading…
Reference in New Issue