diff --git a/tools/odbclient/src/odbclient/odbclient.py b/tools/odbclient/src/odbclient/odbclient.py index 0215fdca..42dce924 100644 --- a/tools/odbclient/src/odbclient/odbclient.py +++ b/tools/odbclient/src/odbclient/odbclient.py @@ -221,7 +221,7 @@ def element_connectivity(self, instance_name, elset_name=''): """ index, connectivity = self._query('get_connectivity', (instance_name, elset_name)) return pd.DataFrame({'connectivity': connectivity}, - index=pd.Int64Index(index, name='element_id')) + index=pd.Index(index, name='element_id', dtype=np.int64)) def nset_names(self, instance_name=''): """Query the available node set names. @@ -257,7 +257,7 @@ def node_ids(self, nset_name, instance_name=''): The node ids as :class:`pandas.Index` """ node_ids = self._query('get_node_set', (instance_name, nset_name)) - return pd.Index(node_ids, name='node_id') + return pd.Index(node_ids, name='node_id', dtype=np.int64) def elset_names(self, instance_name=''): """Query the available element set names. @@ -293,7 +293,7 @@ def element_ids(self, elset_name, instance_name=''): The element ids as :class:`pandas.Index` """ element_ids = self._query('get_element_set', (instance_name, elset_name)) - return pd.Int64Index(element_ids, name='element_id') + return pd.Index(element_ids, name='element_id', dtype=np.int64) def step_names(self): """Query the step names from the odb file. @@ -367,9 +367,9 @@ def variable(self, variable_name, instance_name, step_name, frame_id, nset_name= index_labels = _ascii(_decode, index_labels) if len(index_labels) > 1: - index = pd.DataFrame(index_data, columns=index_labels).set_index(index_labels).index + index = pd.DataFrame(index_data, columns=index_labels, dtype=np.int64).set_index(index_labels).index else: - index = pd.Int64Index(index_data[:, 0], name=index_labels[0]) + index = pd.Index(index_data[:, 0], name=index_labels[0], dtype=np.int64) column_names = _ascii(_decode, labels) return pd.DataFrame(values, index=index, columns=column_names) diff --git a/tools/odbclient/tests/test_odbclient.py b/tools/odbclient/tests/test_odbclient.py index 03adff71..0eda5392 100644 --- a/tools/odbclient/tests/test_odbclient.py +++ b/tools/odbclient/tests/test_odbclient.py @@ -54,6 +54,20 @@ def test_odbclient_node_coordinates(client): pd.testing.assert_frame_equal(client.node_coordinates('PART-1-1'), expected) +def test_odbclient_node_ids(client): + result = client.node_ids('FIX', 'PART-1-1') + expected = pd.Index([1, 2, 3, 4, 22, 27, 31, 32], dtype='int64', name='node_id') + + pd.testing.assert_index_equal(result, expected) + + +def test_odbclient_element_ids(client): + result = client.element_ids('FIX', 'PART-1-1') + expected = pd.Index([1], dtype='int64', name='element_id') + + pd.testing.assert_index_equal(result, expected) + + def test_odbclient_node_coordinates_invalid_instance_name(client): with pytest.raises(KeyError, match="Invalid instance name 'nonexistent'."): client.node_coordinates('nonexistent') @@ -120,13 +134,19 @@ def test_variable_names(client): def test_variable_stress_element_nodal(client): - expected = pd.read_csv('tests/stress_element_nodal.csv', - index_col=['node_id', 'element_id']) + expected = pd.read_csv('tests/stress_element_nodal.csv', index_col=['node_id', 'element_id']) result = client.variable('S', 'PART-1-1', 'Load', 1) pd.testing.assert_frame_equal(result, expected) +def test_variable_evol(client): + result = client.variable('EVOL', 'PART-1-1', 'Load', 1) + expected = pd.DataFrame({'EVOL': [1000.]}, index=pd.Index([1, 2, 3, 4], name='element_id')) + + pd.testing.assert_frame_equal(result, expected) + + def test_variable_invalid_instance_name(client): with pytest.raises(KeyError, match="nonexistent"): client.variable('S', 'nonexistent', 'Load', 1)