From 6cdc0488971b6a61cc9ea3d5c67baa73924a46ee Mon Sep 17 00:00:00 2001 From: Gerd Duscher <50049264+gduscher@users.noreply.github.com> Date: Sat, 27 Jan 2024 17:55:50 -0500 Subject: [PATCH] crystal tool now compatible --- notebooks/0_pyTEMlib.ipynb | 7 ++++--- pyTEMlib/crystal_tools.py | 11 +---------- tests/test_crystal_tools.py | 2 +- 3 files changed, 6 insertions(+), 14 deletions(-) diff --git a/notebooks/0_pyTEMlib.ipynb b/notebooks/0_pyTEMlib.ipynb index b1db0d7b..45b69b36 100644 --- a/notebooks/0_pyTEMlib.ipynb +++ b/notebooks/0_pyTEMlib.ipynb @@ -36,10 +36,11 @@ }, { "cell_type": "code", - "execution_count": null, - "metadata": {}, "outputs": [], - "source": [] + "source": [], + "metadata": { + "collapsed": false + } } ], "metadata": { diff --git a/pyTEMlib/crystal_tools.py b/pyTEMlib/crystal_tools.py index 318aaedb..42303432 100644 --- a/pyTEMlib/crystal_tools.py +++ b/pyTEMlib/crystal_tools.py @@ -283,16 +283,7 @@ def ball_and_stick(atoms, extend=1, max_bond_length=0.): neighbor_list.update(super_cell) bond_matrix = neighbor_list.get_connectivity_matrix() - del_double = [] - for (k, s) in bond_matrix.keys(): - if k > s: - del_double.append((k, s)) - del_double.sort(reverse=False) - for key in del_double: - # Todo: why is ther a key error - # bond_matrix.pop(key) - pass - + bond_matrix = np.triu(bond_matrix.toarray()) if super_cell.info is None: super_cell.info = {} super_cell.info['plot_cell'] = {'bond_matrix': bond_matrix, 'corner_vectors': corner_vectors, diff --git a/tests/test_crystal_tools.py b/tests/test_crystal_tools.py index 2dcdd317..4a414c6a 100644 --- a/tests/test_crystal_tools.py +++ b/tests/test_crystal_tools.py @@ -43,7 +43,7 @@ def test_ball_and_stick(self): [0, 0, 0, 0, 0, 0, 0, 0, 1], [0, 0, 0, 0, 0, 0, 0, 0, 1], [0, 0, 0, 0, 0, 0, 0, 0, 0]] - # np.testing.assert_allclose(cell_2_plot.info['plot_cell']['bond_matrix'].toarray(), bonds_desired) + np.testing.assert_allclose(cell_2_plot.info['plot_cell']['bond_matrix'], bonds_desired) def test_from_dictionary(self): tags = {'unit_cell': np.array([[4.05, 0, 0], [0, 4.05, 0], [0, 0, 4.05]]),