From 471c4ef7bfb9c5239b3a325dbee8cef7ddfe5925 Mon Sep 17 00:00:00 2001 From: Josh Ayers Date: Tue, 1 Sep 2026 19:53:01 -0700 Subject: [PATCH 1/2] Fixed warnings under NumPy 2.5. --- pyyeti/nastran/bulk.py | 7 +++---- pyyeti/nastran/op2.py | 11 +++++------ pyyeti/nastran/op4.py | 19 +++++++++---------- 3 files changed, 17 insertions(+), 20 deletions(-) diff --git a/pyyeti/nastran/bulk.py b/pyyeti/nastran/bulk.py index 18b8d1bc..843d30b5 100644 --- a/pyyeti/nastran/bulk.py +++ b/pyyeti/nastran/bulk.py @@ -1,4 +1,3 @@ -# -*- coding: utf-8 -*- """ Collection of tools for reading/writing Nastran bulk data. @@ -444,7 +443,7 @@ def _check_for_symbols(rel_path, symbols): """ index = rel_path.find(":") # if a colon is found in position 1, assume this is a Windows absolute path - if index >= 2: # + if index >= 2: symbol = rel_path[0:index].lower() rel_path = rel_path[index + 1 :] try: @@ -777,7 +776,7 @@ def rdcards( for symbol in include_symbols: if not len(symbol) > 2: raise ValueError(f"Symbols must have a length >1, got {symbol}") - + kwargsReturnType = "list" if return_var == "list" else "array" kwargs = { # save args for use in _rdinclude "name": name, @@ -1402,7 +1401,7 @@ def _recs_to_df(recs): dof = rec[j + 1] j += 2 val = rec[j : j + ints_per_number] - val.dtype = dtype + val = val.view(dtype) j += ints_per_number ri = np.searchsorted(r_id_dof, nid * 10 + dof) mat[ri, ci] = val[0] diff --git a/pyyeti/nastran/op2.py b/pyyeti/nastran/op2.py index eb6090ee..089ae79b 100644 --- a/pyyeti/nastran/op2.py +++ b/pyyeti/nastran/op2.py @@ -1,4 +1,3 @@ -# -*- coding: utf-8 -*- """ Some Python tools for reading select data from Nastran .op2 files. Converted from the Yeti version. @@ -1177,7 +1176,7 @@ def rdop2opg(self, name="OPG1"): loadset_id = ident[4] n_grids = data.shape[0] // numwde grid_ids = np.frombuffer(data, self._endian + "i4")[::numwde] // 10 - data.shape = (n_grids, numwde) + data = data.reshape((n_grids, numwde), copy=False) forces = data[:, 2:] output[loadset_id] = pd.DataFrame( forces, index=grid_ids, columns=[1, 2, 3, 4, 5, 6] @@ -1313,7 +1312,7 @@ def _rdop2oug(self, name): # id*10, type, x, y, z, rx, ry, rz # - type == 1 for grids; those have all 6 dof id_dof = data.reshape(-1, 8)[:, :2] - id_dof.dtype = np.int32 + id_dof = id_dof.view(np.int32) pvgrids = id_dof[:, 1] == 1 full_dof = _expanddof(id_dof[:, 0] // 10, pvgrids) indexm = pd.MultiIndex.from_tuples( @@ -1329,7 +1328,7 @@ def _rdop2oug(self, name): eigenval = np.empty(ncols, np.float32) oug[:, col] = data[V] - ident.dtype = np.float32 + ident = ident.view(np.float32) eigenval[col] = ident[5] col += 1 @@ -1718,7 +1717,7 @@ def _rdop2ougv1(self, name): V[pvgrids, 3:] = True # only grids have all 6 V = V.ravel() # initialize ougv1 with first mode shape: - data.dtype = np.float32 # reinterpret as floats + data = data.view(np.float32) # reinterpret as floats ougv1 = data[V].reshape(-1, 1) else: data = self.rdop2record("single", V.shape[0]) @@ -3026,7 +3025,7 @@ def _getdrm(pos, e, s, eids, etypes, ibytes): if drm is None: drm, elem_info = _getdrm(pos, e, s, eids, etypes, self._ibytes) drm[:, mode - 1] = column - drm.dtype = np.float32 if self._ibytes == 4 else np.float64 + drm = drm.view(np.float32) if self._ibytes == 4 else drm.view(np.float64) if oldstyle: return drm, elem_info diff --git a/pyyeti/nastran/op4.py b/pyyeti/nastran/op4.py index 266f095d..c305d630 100644 --- a/pyyeti/nastran/op4.py +++ b/pyyeti/nastran/op4.py @@ -1,4 +1,3 @@ -# -*- coding: utf-8 -*- """ Python tools for reading/writing Nastran .op4 files. Can read and write all formats (as far as I know) with the restrictions that the @@ -765,7 +764,7 @@ def _put_binary_values_c(X, r, c, Y): if not isinstance(Y, np.ndarray): Y = np.array(Y) Y = Y.astype("float", copy=False) - Y.dtype = complex + Y = Y.view(complex) X[r : r + len(Y), c] = Y @staticmethod @@ -1265,7 +1264,7 @@ def _write_col_data(f, v, c, s, elems, perline, numform): e = pv[-1] elems = (e - s + 1) * multiplier v = np.asarray(v[s : e + 1]).ravel() - v.dtype = float + v = v.view(float) _write_col_data(f, v, c, s, elems, perline, numform) else: # sparse matrix: @@ -1279,7 +1278,7 @@ def _write_col_data(f, v, c, s, elems, perline, numform): vec = np.zeros(elems, dt) vec[rs[pv] - s] = vs[pv] elems *= multiplier - vec.dtype = float + vec = vec.view(float) _write_col_data(f, vec, c, s, elems, perline, numform) f.write(f"{cols + 1:8}{1:8}{1:8}\n") f.write(numform % 2**0.5) @@ -1305,7 +1304,7 @@ def _write_ascii_sparse( _write_col_header(f, ind, c, multiplier) for r0, r1 in ind: string = v[r0 : r0 + r1] - string.dtype = float + string = string.view(float) _write_data_string( f, string, r0, r1, multiplier, perline, numform ) @@ -1321,7 +1320,7 @@ def _write_ascii_sparse( for r0, r1 in ind: string = coldata[j : j + r1] j += r1 - string.dtype = float + string = string.view(float) _write_data_string(f, string, r0, r1, multiplier, perline, numform) f.write(f"{cols + 1:8}{1:8}{1:8}\n") f.write(numform % 2**0.5) @@ -1523,7 +1522,7 @@ def _write_col_data(f, v, c, s, elems, endian, colHeader, colTrailer): e = pv[-1] elems = (e - s + 1) * multiplier v = np.asarray(v[s : e + 1]).ravel() - v.dtype = float + v = v.view(float) _write_col_data(f, v, c, s, elems, endian, colHeader, colTrailer) else: # sparse matrix: @@ -1537,7 +1536,7 @@ def _write_col_data(f, v, c, s, elems, endian, colHeader, colTrailer): vec = np.zeros(elems, dt) vec[rs[pv] - s] = vs[pv] elems *= multiplier - vec.dtype = float + vec = vec.view(float) _write_col_data(f, vec, c, s, elems, endian, colHeader, colTrailer) reclen = 3 * 4 + 8 f.write(colHeader.pack(reclen, cols + 1, 1, 2)) @@ -1566,7 +1565,7 @@ def _write_binary_sparse( reclen = _write_col_header(f, ind, c, multiplier, colHeader) for r0, r1 in ind: string = v[r0 : r0 + r1] - string.dtype = float + string = string.view(float) _write_data_string( f, string, r0, r1, multiplier, LrStruct, endian ) @@ -1583,7 +1582,7 @@ def _write_binary_sparse( for r0, r1 in ind: string = coldata[j : j + r1] j += r1 - string.dtype = float + string = string.view(float) _write_data_string(f, string, r0, r1, multiplier, LrStruct, endian) f.write(colTrailer.pack(reclen)) reclen = 3 * 4 + 8 From 57b147e2149b4dee48421b02c90017241f594d74 Mon Sep 17 00:00:00 2001 From: Josh Ayers Date: Tue, 1 Sep 2026 20:17:35 -0700 Subject: [PATCH 2/2] Replaced encoding statements from each module that were inadvertently deleted. --- pyyeti/nastran/bulk.py | 1 + pyyeti/nastran/op2.py | 1 + pyyeti/nastran/op4.py | 1 + 3 files changed, 3 insertions(+) diff --git a/pyyeti/nastran/bulk.py b/pyyeti/nastran/bulk.py index 843d30b5..4e42b573 100644 --- a/pyyeti/nastran/bulk.py +++ b/pyyeti/nastran/bulk.py @@ -1,3 +1,4 @@ +# -*- coding: utf-8 -*- """ Collection of tools for reading/writing Nastran bulk data. diff --git a/pyyeti/nastran/op2.py b/pyyeti/nastran/op2.py index 089ae79b..bf0477ab 100644 --- a/pyyeti/nastran/op2.py +++ b/pyyeti/nastran/op2.py @@ -1,3 +1,4 @@ +# -*- coding: utf-8 -*- """ Some Python tools for reading select data from Nastran .op2 files. Converted from the Yeti version. diff --git a/pyyeti/nastran/op4.py b/pyyeti/nastran/op4.py index c305d630..c81aa538 100644 --- a/pyyeti/nastran/op4.py +++ b/pyyeti/nastran/op4.py @@ -1,3 +1,4 @@ +# -*- coding: utf-8 -*- """ Python tools for reading/writing Nastran .op4 files. Can read and write all formats (as far as I know) with the restrictions that the