tests updated

This commit is contained in:
Sharan 2022-02-02 00:02:03 +01:00
parent 3e73d28631
commit 1bd654781b
7 changed files with 23 additions and 23 deletions

@ -1 +1 @@
Subproject commit 88023f5ff135b580c953e09c83e467dabba1bcd8
Subproject commit a498ed64ac5d98d95fc6ba14f87ca16fadbb892a

View File

@ -5,7 +5,7 @@ import os
import copy
import datetime
import warnings
import xml.etree.ElementTree as ET
import xml.etree.ElementTree as ET # noqa
import xml.dom.minidom
from pathlib import Path
from functools import partial

View File

@ -287,7 +287,7 @@ class TestOrientation:
@pytest.mark.parametrize('family',crystal_families)
@pytest.mark.parametrize('proper',[True,False])
def test_in_SST(self,family,proper):
assert Orientation(family=family).in_SST(np.zeros(3),proper)
assert Orientation(family=family).in_SST(np.zeros(3),proper) # noqa
@pytest.mark.parametrize('function',['in_SST','IPF_color'])
def test_invalid_argument(self,function):

View File

@ -367,7 +367,7 @@ class TestResult:
@pytest.mark.parametrize('mode',['cell','node'])
def test_coordinates(self,default,mode):
if mode == 'cell':
if mode == 'cell': # noqa
a = grid_filters.coordinates0_point(default.cells,default.size,default.origin)
b = default.coordinates0_point.reshape(tuple(default.cells)+(3,),order='F')
elif mode == 'node':
@ -421,7 +421,7 @@ class TestResult:
def test_XDMF_datatypes(self,tmp_path,single_phase,update,ref_path):
for shape in [('scalar',()),('vector',(3,)),('tensor',(3,3)),('matrix',(12,))]:
for dtype in ['f4','f8','i1','i2','i4','i8','u1','u2','u4','u8']:
single_phase.add_calculation(f"np.ones(np.shape(#F#)[0:1]+{shape[1]},'{dtype}')",f'{shape[0]}_{dtype}')
single_phase.add_calculation(f"np.ones(np.shape(#F#)[0:1]+{shape[1]},'{dtype}')",f'{shape[0]}_{dtype}') # noqa
fname = os.path.splitext(os.path.basename(single_phase.fname))[0]+'.xdmf'
os.chdir(tmp_path)
single_phase.export_XDMF()

View File

@ -1076,7 +1076,7 @@ class TestRotation:
def test_from_fiber_component(self,N,sigma):
p = []
for run in range(5):
alpha = np.random.random()*2*np.pi,np.arccos(np.random.random())
alpha = np.random.random()*2*np.pi,np.arccos(np.random.random()) # noqa
beta = np.random.random()*2*np.pi,np.arccos(np.random.random())
f_in_C = np.array([np.sin(alpha[0])*np.cos(alpha[1]), np.sin(alpha[0])*np.sin(alpha[1]), np.cos(alpha[0])])

View File

@ -173,9 +173,9 @@ class TestVTK:
polyData = VTK.from_poly_data(points)
polyData.add(points,'coordinates')
if update:
polyData.save(ref_path/'polyData')
polyData.save(ref_path/'polyData') # noqa
else:
reference = VTK.load(ref_path/'polyData.vtp')
reference = VTK.load(ref_path/'polyData.vtp') # noqa
assert polyData.__repr__() == reference.__repr__() and \
np.allclose(polyData.get('coordinates'),points)
@ -189,8 +189,8 @@ class TestVTK:
rectilinearGrid.add(np.ascontiguousarray(c),'cell')
rectilinearGrid.add(np.ascontiguousarray(n),'node')
if update:
rectilinearGrid.save(ref_path/'rectilinearGrid')
rectilinearGrid.save(ref_path/'rectilinearGrid') # noqa
else:
reference = VTK.load(ref_path/'rectilinearGrid.vtr')
reference = VTK.load(ref_path/'rectilinearGrid.vtr') # noqa
assert rectilinearGrid.__repr__() == reference.__repr__() and \
np.allclose(rectilinearGrid.get('cell'),c)

View File

@ -8,19 +8,19 @@ from damask import seeds
class TestGridFilters:
def test_coordinates0_point(self):
size = np.random.random(3)
size = np.random.random(3) # noqa
cells = np.random.randint(8,32,(3))
coord = grid_filters.coordinates0_point(cells,size)
assert np.allclose(coord[0,0,0],size/cells*.5) and coord.shape == tuple(cells) + (3,)
def test_coordinates0_node(self):
size = np.random.random(3)
size = np.random.random(3) # noqa
cells = np.random.randint(8,32,(3))
coord = grid_filters.coordinates0_node(cells,size)
assert np.allclose(coord[-1,-1,-1],size) and coord.shape == tuple(cells+1) + (3,)
def test_coord0(self):
size = np.random.random(3)
size = np.random.random(3) # noqa
cells = np.random.randint(8,32,(3))
c = grid_filters.coordinates0_point(cells+1,size+size/cells)
n = grid_filters.coordinates0_node(cells,size) + size/cells*.5
@ -28,16 +28,16 @@ class TestGridFilters:
@pytest.mark.parametrize('mode',['point','node'])
def test_grid_DNA(self,mode):
"""Ensure that cellsSizeOrigin_coordinates0_xx is the inverse of coordinates0_xx."""
"""Ensure that cellsSizeOrigin_coordinates0_xx is the inverse of coordinates0_xx.""" # noqa
cells = np.random.randint(8,32,(3))
size = np.random.random(3)
origin = np.random.random(3)
coord0 = eval(f'grid_filters.coordinates0_{mode}(cells,size,origin)') # noqa
coord0 = eval(f'grid_filters.coordinates0_{mode}(cells,size,origin)') # noqa
_cells,_size,_origin = eval(f'grid_filters.cellsSizeOrigin_coordinates0_{mode}(coord0.reshape(-1,3,order="F"))')
assert np.allclose(cells,_cells) and np.allclose(size,_size) and np.allclose(origin,_origin)
def test_displacement_fluct_equivalence(self):
"""Ensure that fluctuations are periodic."""
"""Ensure that fluctuations are periodic.""" # noqa
size = np.random.random(3)
cells = np.random.randint(8,32,(3))
F = np.random.random(tuple(cells)+(3,3))
@ -45,14 +45,14 @@ class TestGridFilters:
grid_filters.point_to_node(grid_filters.displacement_fluct_point(size,F)))
def test_interpolation_to_node(self):
size = np.random.random(3)
size = np.random.random(3) # noqa
cells = np.random.randint(8,32,(3))
F = np.random.random(tuple(cells)+(3,3))
assert np.allclose(grid_filters.coordinates_node(size,F) [1:-1,1:-1,1:-1],
grid_filters.point_to_node(grid_filters.coordinates_point(size,F))[1:-1,1:-1,1:-1])
def test_interpolation_to_cell(self):
cells = np.random.randint(1,30,(3))
cells = np.random.randint(1,30,(3)) # noqa
coordinates_node_x = np.linspace(0,np.pi*2,num=cells[0]+1)
node_field_x = np.cos(coordinates_node_x)
@ -66,7 +66,7 @@ class TestGridFilters:
@pytest.mark.parametrize('mode',['point','node'])
def test_coordinates0_origin(self,mode):
origin= np.random.random(3)
origin= np.random.random(3) # noqa
size = np.random.random(3) # noqa
cells = np.random.randint(8,32,(3))
shifted = eval(f'grid_filters.coordinates0_{mode}(cells,size,origin)')
@ -79,7 +79,7 @@ class TestGridFilters:
@pytest.mark.parametrize('function',[grid_filters.displacement_avg_point,
grid_filters.displacement_avg_node])
def test_displacement_avg_vanishes(self,function):
"""Ensure that random fluctuations in F do not result in average displacement."""
"""Ensure that random fluctuations in F do not result in average displacement.""" # noqa
size = np.random.random(3)
cells = np.random.randint(8,32,(3))
F = np.random.random(tuple(cells)+(3,3))
@ -89,7 +89,7 @@ class TestGridFilters:
@pytest.mark.parametrize('function',[grid_filters.displacement_fluct_point,
grid_filters.displacement_fluct_node])
def test_displacement_fluct_vanishes(self,function):
"""Ensure that constant F does not result in fluctuating displacement."""
"""Ensure that constant F does not result in fluctuating displacement.""" # noqa
size = np.random.random(3)
cells = np.random.randint(8,32,(3))
F = np.broadcast_to(np.random.random((3,3)), tuple(cells)+(3,3))
@ -142,13 +142,13 @@ class TestGridFilters:
function(unordered,mode)
def test_regrid_identity(self):
size = np.random.random(3)
size = np.random.random(3) # noqa
cells = np.random.randint(8,32,(3))
F = np.broadcast_to(np.eye(3), tuple(cells)+(3,3))
assert all(grid_filters.regrid(size,F,cells) == np.arange(cells.prod()))
def test_regrid_double_cells(self):
size = np.random.random(3)
size = np.random.random(3) # noqa
cells = np.random.randint(8,32,(3))
g = Grid.from_Voronoi_tessellation(cells,size,seeds.from_random(size,10))
F = np.broadcast_to(np.eye(3), tuple(cells)+(3,3))