@@ -132,12 +132,12 @@ def material(self,
132
132
material : np .ndarray ):
133
133
if len (material .shape ) != 3 :
134
134
raise ValueError (f'invalid material shape { material .shape } ' )
135
- if material .dtype not in np .sctypes [ 'float' ] and material . dtype not in np .sctypes [ 'int' ]:
135
+ if material .dtype not in [ np .float32 , np . float64 , np .int32 , np . int64 ]:
136
136
raise TypeError (f'invalid material data type "{ material .dtype } "' )
137
137
138
138
self ._material = np .copy (material )
139
139
140
- if self .material .dtype in np .sctypes [ 'float' ] and \
140
+ if self .material .dtype in [ np .float32 , np . float64 ] and \
141
141
np .all (self .material == self .material .astype (np .int64 ).astype (float )):
142
142
self ._material = self .material .astype (np .int64 )
143
143
@@ -153,7 +153,7 @@ def size(self,
153
153
if len (size ) != 3 or any (np .array (size ) < 0 ):
154
154
raise ValueError (f'invalid size { size } ' )
155
155
156
- self ._size = np .array (size )
156
+ self ._size = np .array (size , np . float64 )
157
157
158
158
@property
159
159
def origin (self ) -> np .ndarray :
@@ -166,7 +166,7 @@ def origin(self,
166
166
if len (origin ) != 3 :
167
167
raise ValueError (f'invalid origin { origin } ' )
168
168
169
- self ._origin = np .array (origin )
169
+ self ._origin = np .array (origin , np . float64 )
170
170
171
171
@property
172
172
def initial_conditions (self ) -> Dict [str ,np .ndarray ]:
@@ -471,7 +471,7 @@ def load_DREAM3D(fname: Union[str, Path],
471
471
O = Rotation .from_Euler_angles (f ['/' .join ([b ,c ,Euler_angles ])]).as_quaternion ().reshape (- 1 ,4 ) # noqa
472
472
unique ,unique_inverse = np .unique (np .hstack ([O ,phase ]),return_inverse = True ,axis = 0 )
473
473
ma = np .arange (cells .prod ()) if len (unique ) == cells .prod () else \
474
- np .arange (unique .size )[np .argsort (pd .unique (unique_inverse ))][unique_inverse ]
474
+ np .arange (unique .size )[np .argsort (pd .unique (unique_inverse . squeeze () ))][unique_inverse ]
475
475
else :
476
476
ma = f ['/' .join ([b ,c ,feature_IDs ])][()].flatten ()
477
477
@@ -512,7 +512,7 @@ def from_table(table: Table,
512
512
unique ,unique_inverse = np .unique (np .hstack ([table .get (l ) for l in labels_ ]),return_inverse = True ,axis = 0 )
513
513
514
514
ma = np .arange (cells .prod ()) if len (unique ) == cells .prod () else \
515
- np .arange (unique .size )[np .argsort (pd .unique (unique_inverse ))][unique_inverse ]
515
+ np .arange (unique .size )[np .argsort (pd .unique (unique_inverse . squeeze () ))][unique_inverse ]
516
516
517
517
return GeomGrid (material = ma .reshape (cells ,order = 'F' ),
518
518
size = size ,
@@ -812,7 +812,7 @@ def save_ASCII(self,
812
812
'homogenization 1' ,
813
813
]
814
814
815
- format_string = '%g' if self .material .dtype in np .sctypes [ 'float' ] else \
815
+ format_string = '%g' if self .material .dtype in [ np .float32 , np . float64 ] else \
816
816
'%{}i' .format (1 + int (np .floor (np .log10 (np .nanmax (self .material )))))
817
817
np .savetxt (fname ,
818
818
self .material .reshape ([self .cells [0 ],np .prod (self .cells [1 :])],order = 'F' ).T ,
@@ -1347,14 +1347,14 @@ def add_primitive(self,
1347
1347
1348
1348
"""
1349
1349
# radius and center
1350
- r = np .array (dimension )/ 2.0 * self .size / self .cells if np .array (dimension ).dtype in np .sctypes [ 'int' ] else \
1350
+ r = np .array (dimension )/ 2.0 * self .size / self .cells if np .issubdtype ( np . array (dimension ).dtype , np .integer ) else \
1351
1351
np .array (dimension )/ 2.0
1352
- c = (np .array (center ) + .5 )* self .size / self .cells if np .array (center ).dtype in np .sctypes [ 'int' ] else \
1352
+ c = (np .array (center ) + .5 )* self .size / self .cells if np .issubdtype ( np . array (center ).dtype , np .integer ) else \
1353
1353
(np .array (center ) - self .origin )
1354
1354
1355
1355
coords = grid_filters .coordinates0_point (self .cells ,self .size ,
1356
1356
- (0.5 * (self .size + (self .size / self .cells
1357
- if np .array (center ).dtype in np .sctypes [ 'int' ] else
1357
+ if np .issubdtype ( np . array (center ).dtype , np .integer ) else
1358
1358
0 )) if periodic else c ))
1359
1359
coords_rot = R .broadcast_to (tuple (self .cells ))@coords
1360
1360
0 commit comments