Skip to content

Commit

Permalink
Tweaks from review feedback
Browse files Browse the repository at this point in the history
- Update docs Numpy requirement

- Drop OrderedDict (standard dict works fine now, and the ordering is
  not _so_ important here that it is worth drawing extra attention.)
  • Loading branch information
ajjackson committed Jul 18, 2024
1 parent 406c483 commit 10bca0d
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 7 deletions.
2 changes: 1 addition & 1 deletion doc/requirements.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
numpy>=1.19.5
numpy>=1.21.3
sphinx==5.3.0
sphinx-argparse==0.3.2
sphinx-autodoc-typehints==1.19.5
Expand Down
10 changes: 4 additions & 6 deletions euphonic/util.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
from collections import OrderedDict
from functools import reduce
from importlib.resources import files
import itertools
Expand Down Expand Up @@ -445,15 +444,14 @@ def _cell_vectors_to_volume(cell_vectors: Quantity) -> Quantity:

def _get_unique_elems_and_idx(
all_elems: Sequence[tuple[int | str, ...]]
) -> 'OrderedDict[tuple[int | str, ...], np.ndarray]':
) -> dict[tuple[int | str, ...], np.ndarray]:
"""
Returns an ordered dictionary mapping the unique sequences of
elements to their indices
"""
# Abuse OrderedDict to get ordered set
unique_elems = OrderedDict(
zip(all_elems, itertools.cycle([None]))).keys()
return OrderedDict((
# Abuse dict keys to get an "ordered set" of elems for iteration
unique_elems = dict(zip(all_elems, itertools.cycle([None]))).keys()
return dict((
elem,
np.asarray([i for i, other_elem in enumerate(all_elems)
if elem == other_elem])
Expand Down

0 comments on commit 10bca0d

Please sign in to comment.