Skip to content

Commit

Permalink
Flatten q-point indices for compatibility with Numpy 2.0
Browse files Browse the repository at this point in the history
With Numpy 2.0, np.unique returns a 2-D array when applied to
q-points. This in turn gets broadcast and adds an extra dimension to
the frequency/mode arrays, causing all kinds of chaos.

Flattening the array here should be a no-op for Numpy <2 and fixes the
issue.
  • Loading branch information
ajjackson committed Jul 2, 2024
1 parent be51d81 commit 5c3b356
Showing 1 changed file with 2 additions and 0 deletions.
2 changes: 2 additions & 0 deletions euphonic/force_constants.py
Original file line number Diff line number Diff line change
Expand Up @@ -508,6 +508,8 @@ def _calculate_phonons_at_qpts(
norm_qpts[gamma_i] = 0.
reduced_qpts, qpts_i = np.unique(norm_qpts, return_inverse=True,
axis=0)
qpts_i = qpts_i.flatten()

Check notice on line 512 in euphonic/force_constants.py

View check run for this annotation

Codacy Production / Codacy Static Code Analysis

euphonic/force_constants.py#L512

Trailing whitespace
n_rqpts = len(reduced_qpts)
# Special handling of gamma points - don't reduce gamma
# points if LO-TO splitting
Expand Down

0 comments on commit 5c3b356

Please sign in to comment.