Skip to content

Commit d6fd699

Browse files
authored
Replazing old numpy data types (#184)
1 parent 22a46dd commit d6fd699

File tree

8 files changed

+28
-28
lines changed

8 files changed

+28
-28
lines changed

ansys/mapdl/reader/archive.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -646,15 +646,15 @@ def save_as_archive(
646646
# write node components
647647
for node_key in grid.point_data:
648648
arr = grid.point_data[node_key]
649-
if arr.dtype in [np.uint8, np.bool]:
650-
items = nodenum[arr.view(np.bool)]
649+
if arr.dtype in [np.uint8, np.bool_]:
650+
items = nodenum[arr.view(np.bool_)]
651651
write_cmblock(fid, items, node_key, "NODE")
652652

653653
# write element components
654654
for node_key in grid.cell_data:
655655
arr = grid.cell_data[node_key]
656-
if arr.dtype in [np.uint8, np.bool]:
657-
items = enum[arr.view(np.bool)]
656+
if arr.dtype in [np.uint8, np.bool_]:
657+
items = enum[arr.view(np.bool_)]
658658
write_cmblock(fid, items, node_key, "ELEMENT")
659659

660660

ansys/mapdl/reader/cyclic_reader.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -124,7 +124,7 @@ def _add_cyclic_properties(self):
124124
self._is_repeated_mode = np.array([False])
125125
return
126126

127-
self._repeated_index = np.empty(self._is_repeated_mode.size, np.int)
127+
self._repeated_index = np.empty(self._is_repeated_mode.size, np.int_)
128128
self._repeated_index[:] = -1
129129
if np.any(self._is_repeated_mode):
130130
self._repeated_index[mask_a] = np.nonzero(mask_b)[0]

ansys/mapdl/reader/cython/_binary_reader.pyx

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1403,7 +1403,7 @@ def tensor_arbitrary(double [:, ::1] stress, double [:, :] trans):
14031403
stress[i, 4] = r5
14041404
stress[i, 5] = r6
14051405

1406-
return np.asarray(isnan, np.bool)
1406+
return np.asarray(isnan, np.bool_)
14071407

14081408

14091409
def tensor_strain_arbitrary(double [:, ::1] stress, double [:, :] trans):
@@ -1476,7 +1476,7 @@ def tensor_strain_arbitrary(double [:, ::1] stress, double [:, :] trans):
14761476
stress[i, 4] = r5*2
14771477
stress[i, 5] = r6*2
14781478

1479-
return np.asarray(isnan, np.bool)
1479+
return np.asarray(isnan, np.bool_)
14801480

14811481

14821482
def tensor_rotate_z(double [:, :] stress, float theta_z):
@@ -1518,7 +1518,7 @@ def tensor_rotate_z(double [:, :] stress, float theta_z):
15181518
stress[i, 4] = c*s_yz + s*s_xz
15191519
stress[i, 5] = c*s_xz - s*s_yz
15201520

1521-
return np.asarray(isnan, dtype=np.bool)
1521+
return np.asarray(isnan, dtype=np.bool_)
15221522

15231523

15241524
def compute_principal_stress(double [:, ::1] stress):
@@ -1615,7 +1615,7 @@ def compute_principal_stress(double [:, ::1] stress):
16151615

16161616
pstress[i, 4] = sqrt(0.5*(c1**2 + c2**2 + c3**2))
16171617

1618-
return np.asarray(pstress), np.asarray(isnan, np.bool)
1618+
return np.asarray(pstress), np.asarray(isnan, np.bool_)
16191619

16201620

16211621
def affline_transform(float_or_double [:, ::1] points, float_or_double [:, ::1] t):
@@ -1669,7 +1669,7 @@ def cells_with_all_nodes(index_type [::1] offset, index_type [::1] cells,
16691669
if point_mask[cells[j]] != 1:
16701670
cell_mask[i] = 0
16711671

1672-
return np.asarray(cell_mask, dtype=np.bool)
1672+
return np.asarray(cell_mask, dtype=np.bool_)
16731673

16741674

16751675
def cells_with_any_nodes(index_type [::1] offset, index_type [::1] cells,
@@ -1693,7 +1693,7 @@ def cells_with_any_nodes(index_type [::1] offset, index_type [::1] cells,
16931693
cell_mask[i] = 1
16941694
break
16951695

1696-
return np.asarray(cell_mask, dtype=np.bool)
1696+
return np.asarray(cell_mask, dtype=np.bool_)
16971697

16981698

16991699
def midside_mask(uint8 [::1] celltypes, index_type [::1] cells,
@@ -1746,7 +1746,7 @@ def midside_mask(uint8 [::1] celltypes, index_type [::1] cells,
17461746
mask[cells[j]] = 1
17471747

17481748
# return as a bool array without copying
1749-
return np.asarray(mask).view(np.bool)
1749+
return np.asarray(mask).view(np.bool_)
17501750

17511751

17521752
def euler_cart_to_cyl(double [:, ::1] stress, double [::1] angles):

ansys/mapdl/reader/cython/_cellqual.pyx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1057,7 +1057,7 @@ cdef inline double tet_quad_qual(int64_t [::1] cells, int c,
10571057
print '# Node {:d}'.format(j)
10581058
print 'for j in range(3):'
10591059
endtxt = ''
1060-
k = pre_j[4*j].astype(np.int)
1060+
k = pre_j[4*j].astype(np.int_)
10611061
for i in np.nonzero(k)[0].tolist():
10621062
if k[i] == -1:
10631063
endtxt += ' + pts[ind{:d}, j]'.format(i)
@@ -1071,7 +1071,7 @@ cdef inline double tet_quad_qual(int64_t [::1] cells, int c,
10711071
10721072
for m in range(1, 4):
10731073
txt = 'e{:d}[j] ='.format(m - 1)
1074-
k = pre_j[4*j + m].astype(np.int)
1074+
k = pre_j[4*j + m].astype(np.int_)
10751075
for i in np.nonzero(k)[0].tolist():
10761076
if k[i] == 1:
10771077
txt += ' + pts[ind{:d}, j]'.format(i)
@@ -2894,7 +2894,7 @@ cdef inline double hex_quad_qual(int64_t [::1] cells, int c,
28942894
[0, 4],# 16
28952895
[1, 5],# 17
28962896
[2, 6],# 18
2897-
[3, 7]], np.int)# 19
2897+
[3, 7]], np.int_)# 19
28982898
28992899
midpt = (edgept[idx[:, 0]] + edgept[idx[:, 1]])/2
29002900

ansys/mapdl/reader/full.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -296,10 +296,10 @@ def load_km(self, as_sparse=True, sort=False):
296296
Sort these values by node number and DOF by enabling the
297297
sort parameter.
298298
299-
k : (n x n) np.float or scipy.csc array
299+
k : (n x n) np.float_ or scipy.csc array
300300
Stiffness array
301301
302-
m : (n x n) np.float or scipy.csc array
302+
m : (n x n) np.float_ or scipy.csc array
303303
Mass array
304304
305305
Examples

ansys/mapdl/reader/rst.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -907,15 +907,15 @@ def _extract_node_components(self, node_components, sel_type_all=True, grid=None
907907
if isinstance(node_components, str):
908908
node_components = [node_components]
909909

910-
mask = np.zeros(grid.n_points, np.bool)
910+
mask = np.zeros(grid.n_points, np.bool_)
911911
for component in node_components:
912912
component = component.upper()
913913
if component not in grid.point_data:
914914
raise KeyError(
915915
"Result file does not contain node " + 'component "%s"' % component
916916
)
917917

918-
mask += grid.point_data[component].view(np.bool)
918+
mask += grid.point_data[component].view(np.bool_)
919919

920920
# need to extract the mesh
921921
cells, offset = vtk_cell_info(grid)
@@ -954,15 +954,15 @@ def _extract_element_components(self, element_components, grid=None):
954954
if isinstance(element_components, str):
955955
element_components = [element_components]
956956

957-
cell_mask = np.zeros(grid.n_cells, np.bool)
957+
cell_mask = np.zeros(grid.n_cells, np.bool_)
958958
for component in element_components:
959959
component = component.upper()
960960
if component not in grid.cell_data:
961961
raise KeyError(
962962
"Result file does not contain element "
963963
+ 'component "%s"' % component
964964
)
965-
cell_mask += grid.cell_data[component].view(np.bool)
965+
cell_mask += grid.cell_data[component].view(np.bool_)
966966

967967
if not cell_mask.any():
968968
raise RuntimeError("Empty component")

tests/test_binary_reader.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -182,7 +182,7 @@ def test_prnsol_u(mapdl, cyclic_modal, rset):
182182
mapdl.set(*rset)
183183
# verify cyclic displacements
184184
array = mapdl.prnsol("u").to_array()
185-
ansys_nnum = array[:, 0].astype(np.int)
185+
ansys_nnum = array[:, 0].astype(np.int_)
186186
ansys_disp = array[:, 1:-1]
187187

188188
nnum, disp = mapdl.result.nodal_solution(rset)
@@ -207,7 +207,7 @@ def test_presol_s(mapdl, cyclic_modal, rset):
207207

208208
# parse ansys result
209209
array = mapdl.presol("S").to_array()
210-
ansys_enode = array[:, 0].astype(np.int)
210+
ansys_enode = array[:, 0].astype(np.int_)
211211
ansys_element_stress = array[:, 1:]
212212

213213
arr_sz = element_stress.shape[0]
@@ -222,7 +222,7 @@ def test_prnsol_s(mapdl, cyclic_modal, rset):
222222

223223
# verify cyclic displacements
224224
array = mapdl.prnsol("s").to_array()
225-
ansys_nnum = array[:, 0].astype(np.int)
225+
ansys_nnum = array[:, 0].astype(np.int_)
226226
ansys_stress = array[:, 1:]
227227

228228
nnum, stress = mapdl.result.nodal_stress(rset)
@@ -244,7 +244,7 @@ def test_prnsol_prin(mapdl, cyclic_modal, rset):
244244

245245
# verify principal stress
246246
array = mapdl.prnsol("prin").to_array()
247-
ansys_nnum = array[:, 0].astype(np.int)
247+
ansys_nnum = array[:, 0].astype(np.int_)
248248
ansys_stress = array[:, 1:]
249249

250250
nnum, stress = mapdl.result.principal_nodal_stress(rset)

tests/test_cyclic.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,7 @@ def test_nodal_cyclic_modal(academic_rotor, load_step, sub_step, rtype):
9696

9797
# ANSYS will not average across geometric discontinuities, pymapdl_reader
9898
# always does. These 10 nodes are along the blade/sector interface
99-
dmask = np.ones(stress[0].shape[0], np.bool)
99+
dmask = np.ones(stress[0].shape[0], np.bool_)
100100
dmask[[99, 111, 115, 116, 117, 135, 142, 146, 147, 148]] = False
101101

102102
# large atol due to the float32 encoding of the stress
@@ -198,7 +198,7 @@ def test_element_stress_v182_non_cyclic():
198198
if len(line) == 201:
199199
ansys_element_stress.append(line)
200200
ansys_element_stress = np.genfromtxt(ansys_element_stress)
201-
ansys_enode = ansys_element_stress[:, 0].astype(np.int)
201+
ansys_enode = ansys_element_stress[:, 0].astype(np.int_)
202202
ansys_element_stress = ansys_element_stress[:, 1:]
203203
204204
"""
@@ -222,7 +222,7 @@ def test_nodal_stress_v182_non_cyclic():
222222
Generated with:
223223
msg = ansys.Prnsol('s').splitlines()
224224
array = np.genfromtxt(msg[9:])
225-
ansys_nnum = array[:, 0].astype(np.int)
225+
ansys_nnum = array[:, 0].astype(np.int_)
226226
ansys_stress = array[:, 1:]
227227
"""
228228
ansys_result_file = os.path.join(cyclic_testfiles_path, "cyclic_v182.rst")

0 commit comments

Comments
 (0)