From 601c14bd449e3b3820e835f4324cd0fd42f527e0 Mon Sep 17 00:00:00 2001 From: RAMSEY YUNIS Date: Fri, 24 Jul 2026 01:52:26 -0700 Subject: [PATCH 1/2] Short-circuit getcoordinates() in simple cases. Significantly faster for large usets and large number of gid. --- pyyeti/nastran/n2p.py | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/pyyeti/nastran/n2p.py b/pyyeti/nastran/n2p.py index 0c181d5..89b1a70 100644 --- a/pyyeti/nastran/n2p.py +++ b/pyyeti/nastran/n2p.py @@ -2370,6 +2370,12 @@ def getcoordinates(uset, gid, csys, coordref=None): else: # user passed in a higher dimension array raise ValueError(f"`gid` is more than 2d (it has {gid.ndim} dimensions)") + # Faster vectorized lookup for simple requests + if isgrid and np.size(csys) == 1 and csys == 0: + idx = [(g, 1) for g in gid] + result = uset.loc[idx, "x":"z"].values + return result + result = [] T = None for igid in gid: From 1ffdd4844b16b21a08e6433c4a47dcde82babfd6 Mon Sep 17 00:00:00 2001 From: RAMSEY YUNIS Date: Fri, 24 Jul 2026 02:03:40 -0700 Subject: [PATCH 2/2] correct dimensions for returned array if one gid --- pyyeti/nastran/n2p.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pyyeti/nastran/n2p.py b/pyyeti/nastran/n2p.py index 89b1a70..64fb0fe 100644 --- a/pyyeti/nastran/n2p.py +++ b/pyyeti/nastran/n2p.py @@ -2374,7 +2374,7 @@ def getcoordinates(uset, gid, csys, coordref=None): if isgrid and np.size(csys) == 1 and csys == 0: idx = [(g, 1) for g in gid] result = uset.loc[idx, "x":"z"].values - return result + return result if len(gid) > 1 else result[0] result = [] T = None