From 1b258f5f76be2d8e05eb08689bfbb48ee0f4ce7c Mon Sep 17 00:00:00 2001 From: Johannes Mueller Date: Mon, 11 Nov 2024 14:57:21 +0100 Subject: [PATCH] Transfer the connectivity information from as list of ints Fix #126 Signed-off-by: Johannes Mueller --- CHANGELOG.md | 7 +++++++ tools/odbclient/src/odbclient/odbclient.py | 2 +- tools/odbclient/tests/test_odbclient.py | 1 + tools/odbserver/odbserver/interface.py | 4 ++-- 4 files changed, 11 insertions(+), 3 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 875f51c9..df352dcf 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -3,6 +3,13 @@ In this file noteworthy changes of new releases of pyLife are documented since 2.0.0. +## Unreleased + +### Minor improvments + +* Connectivity information is now transfered from odbserver to odbclient as + ints. + ## pylife-2.1.3 diff --git a/tools/odbclient/src/odbclient/odbclient.py b/tools/odbclient/src/odbclient/odbclient.py index 5efa2f14..7a142665 100644 --- a/tools/odbclient/src/odbclient/odbclient.py +++ b/tools/odbclient/src/odbclient/odbclient.py @@ -226,7 +226,7 @@ def element_connectivity(self, instance_name, elset_name=''): return pd.DataFrame( { 'connectivity': [ - conn[conn >= -0].astype(np.int64).tolist() for conn in connectivity + conn[conn >= -0].tolist() for conn in connectivity ] }, index=pd.Index(index, name='element_id', dtype=np.int64), diff --git a/tools/odbclient/tests/test_odbclient.py b/tools/odbclient/tests/test_odbclient.py index 21665af4..edd5a775 100644 --- a/tools/odbclient/tests/test_odbclient.py +++ b/tools/odbclient/tests/test_odbclient.py @@ -113,6 +113,7 @@ def test_element_connectivity(client): expected.index.names = ["element_id"] result = client.element_connectivity('PART-1-1') + assert isinstance(result.loc[1, "connectivity"][0], int) pd.testing.assert_frame_equal(result, expected) diff --git a/tools/odbserver/odbserver/interface.py b/tools/odbserver/odbserver/interface.py index b8a45702..074b958e 100644 --- a/tools/odbserver/odbserver/interface.py +++ b/tools/odbserver/odbserver/interface.py @@ -76,8 +76,8 @@ def connectivity(self, instance_name, element_set_name): else: raise KeyError(element_set_name) - index = np.empty(len(elements), dtype=np.int) - connectivity = -np.ones((len(elements), 20)) + index = np.empty(len(elements), dtype=np.int64) + connectivity = -np.ones((len(elements), 20), dtype=np.int64) for i, el in enumerate(elements): index[i] = el.label conns = list(el.connectivity)