@@ -648,7 +648,7 @@ def from_Voronoi_tessellation(cells: IntSequence,
648648 """
649649 coords = grid_filters .coordinates0_point (cells ,size ).reshape (- 1 ,3 )
650650 tree = spatial .KDTree (seeds ,boxsize = np .asarray (size ) if periodic else None )
651- material_ = tree .query (coords , workers = int (os .environ .get ('OMP_NUM_THREADS' ,4 )))[1 ]
651+ material_ = np . asarray ( tree .query (coords , workers = int (os .environ .get ('OMP_NUM_THREADS' ,4 )))[1 ])
652652
653653 return GeomGrid (material = (material_ if material is None else np .array (material )[material_ ]).reshape (cells ),
654654 size = size ,
@@ -1003,14 +1003,11 @@ def flip(self,
10031003 if not set (directions ).issubset (valid ):
10041004 raise ValueError (f'invalid direction "{ set (directions ).difference (valid )} " specified' )
10051005
1006- mat = np .flip (self .material , [valid .index (d ) for d in directions if d in valid ])
1007- ic = {}
1008- for label in self .initial_conditions :
1009- ic [label ] = np .flip (self .initial_conditions [label ],[valid .index (d ) for d in directions if d in valid ])
1010- return GeomGrid (material = mat ,
1006+ directions_ = tuple ([valid .index (d ) for d in directions if d in valid ])
1007+ return GeomGrid (material = np .flip (self .material , directions_ ),
10111008 size = self .size ,
10121009 origin = self .origin ,
1013- initial_conditions = ic ,
1010+ initial_conditions = { label : np . flip ( ic , directions_ ) for label , ic in self . initial_conditions . items ()} ,
10141011 comments = self .comments + [util .execution_stamp ('GeomGrid' ,'flip' )],
10151012 )
10161013
@@ -1056,10 +1053,12 @@ def rotate(self,
10561053 material = self .material
10571054 # These rotations are always applied in the reference coordinate system, i.e. (z,x,z) not (z,x',z'')
10581055 # see https://www.cs.utexas.edu/~theshark/courses/cs354/lectures/cs354-14.pdf
1059- for angle ,axes in zip (R .as_Euler_angles (degrees = True )[:: - 1 ] , [(0 ,1 ),(1 ,2 ),(0 ,1 )]):
1060- material_temp = ndimage .rotate (material ,angle ,axes ,order = 0 , prefilter = False ,
1056+ for angle ,axes in zip (np . flip ( R .as_Euler_angles (degrees = True )) , [(0 ,1 ),(1 ,2 ),(0 ,1 )]):
1057+ material_temp = ndimage .rotate (material ,angle ,axes ,
10611058 output = self .material .dtype ,
1062- cval = np .nanmax (self .material ) + 1 if fill is None else fill )
1059+ order = 0 ,
1060+ cval = np .nanmax (self .material ) + 1 if fill is None else fill ,
1061+ prefilter = False ) # type: ignore[call-overload]
10631062 # avoid scipy interpolation errors for rotations close to multiples of 90°
10641063 material = material_temp if np .prod (material_temp .shape ) != np .prod (material .shape ) else \
10651064 np .rot90 (material ,k = np .rint (angle / 90. ).astype (np .int64 ),axes = axes )
0 commit comments