diff --git a/.github/workflows/actions.yml b/.github/workflows/actions.yml index 7ef8ee2c..244a3890 100644 --- a/.github/workflows/actions.yml +++ b/.github/workflows/actions.yml @@ -19,7 +19,7 @@ jobs: strategy: max-parallel: 5 matrix: - python-version: ['3.8', '3.9', '3.10'] + python-version: ['3.8', '3.9', '3.10', '3.11'] steps: - uses: actions/checkout@v3 diff --git a/pyTEMlib/crystal_tools.py b/pyTEMlib/crystal_tools.py index a4c1bfc1..9bf47ff4 100644 --- a/pyTEMlib/crystal_tools.py +++ b/pyTEMlib/crystal_tools.py @@ -137,26 +137,26 @@ def get_projection(crystal, layers=1): for pro in projected: atomic_numbers.append(projected_crystal.get_atomic_numbers()[pro].sum()) - projected_crystal.rotate(np.degrees(angle)%360, 'z', rotate_cell=True) + projected_crystal.rotate(np.degrees(angle) % 360, 'z', rotate_cell=True) - near_base = np.array([projected_crystal.cell[0,:2], -projected_crystal.cell[0,:2], - projected_crystal.cell[1,:2], -projected_crystal.cell[1,:2], - projected_crystal.cell[0,:2] + projected_crystal.cell[1,:2], - -(projected_crystal.cell[0,:2] + projected_crystal.cell[1,:2])]) - lines = np.array( [[[0, near_base[0,0]],[0, near_base[0,1]]], - [[0, near_base[2,0]],[0, near_base[2,1]]], - [[near_base[0,0], near_base[4,0]],[near_base[0,1], near_base[4,1]]], - [[near_base[2,0], near_base[4,0]],[near_base[2,1], near_base[4,1]]]]) + near_base = np.array([projected_crystal.cell[0, :2], -projected_crystal.cell[0, :2], + projected_crystal.cell[1, :2], -projected_crystal.cell[1, :2], + projected_crystal.cell[0, :2] + projected_crystal.cell[1, :2], + -(projected_crystal.cell[0, :2] + projected_crystal.cell[1, :2])]) + lines = np.array([[[0, near_base[0, 0]], [0, near_base[0, 1]]], + [[0, near_base[2, 0]], [0, near_base[2, 1]]], + [[near_base[0, 0], near_base[4, 0]], [near_base[0, 1], near_base[4, 1]]], + [[near_base[2, 0], near_base[4, 0]], [near_base[2, 1], near_base[4, 1]]]]) projected_atoms = [] for index in projected: - projected_atoms.append(index[0]) + projected_atoms.append(index[0]) - projected_crystal.info['projection']={'indices': projected, - 'projected': projected_atoms, - 'projected_Z': atomic_numbers, - 'angle': np.degrees(angle)+180%360, - 'near_base': near_base, - 'lines': lines} + projected_crystal.info['projection'] = {'indices': projected, + 'projected': projected_atoms, + 'projected_Z': atomic_numbers, + 'angle': np.degrees(angle)+180 % 360, + 'near_base': near_base, + 'lines': lines} return projected_crystal @@ -287,7 +287,8 @@ def ball_and_stick(atoms, extend=1, max_bond_length=0.): for (k, s) in bond_matrix.keys(): if k > s: del_double.append((k, s)) - for key in del_double[::-1]: + del_double.sort(reverse=False) + for key in del_double: bond_matrix.pop(key) if super_cell.info is None: @@ -298,7 +299,7 @@ def ball_and_stick(atoms, extend=1, max_bond_length=0.): return super_cell -def plot_unit_cell(atoms, extend=1, max_bond_length=1.0, ax = None): +def plot_unit_cell(atoms, extend=1, max_bond_length=1.0, ax=None): """ Simple plot of unit cell """ @@ -309,8 +310,8 @@ def plot_unit_cell(atoms, extend=1, max_bond_length=1.0, ax = None): positions = super_cell.positions - super_cell.cell.lengths()/2 if ax is None: - fig = plt.figure() - ax = fig.add_subplot(111, projection='3d') + fig = plt.figure() + ax = fig.add_subplot(111, projection='3d') # draw unit_cell for line in super_cell.info['plot_cell']['corner_matrix'].keys():