Skip to content

Fix: Clarify np.transpose usage in QHA calculation (Issue #130)#146

Open
crabby-rathbun wants to merge 1 commit intomaterialyzeai:mainfrom
crabby-rathbun:fix/clarify-np-transpose-in-qha
Open

Fix: Clarify np.transpose usage in QHA calculation (Issue #130)#146
crabby-rathbun wants to merge 1 commit intomaterialyzeai:mainfrom
crabby-rathbun:fix/clarify-np-transpose-in-qha

Conversation

@crabby-rathbun
Copy link

Summary

This PR addresses issue #130 which raised a concern about the unclear usage of np.transpose() on list types in the QHA calculation.

Changes

  • Convert lists to numpy arrays using np.asarray() before transposing
  • Add explanatory comment clarifying why we transpose the thermal properties
  • The transpose converts data from (volumes × temperatures) to (temperatures × volumes) format as expected by PhonopyQHA

Rationale

The issue reporter was confused because the docstrings state that free_energies, entropies, and heat_capacities are lists, making the np.transpose() call appear incorrect.

However, the transpose operation is actually correct. The data is structured as a list where each element is an array of thermal properties at different temperatures for a specific volume. PhonopyQHA expects the transposed format where each element is an array of thermal properties at different volumes for a specific temperature.

By explicitly converting to numpy arrays and adding a clear comment, we make the code more understandable and prevent future confusion.

Testing

The existing tests in tests/test_qha.py continue to pass with this change, confirming that the transpose operation is correct.

- Convert lists to numpy arrays before transposing to avoid confusion
- Add comment explaining transpose operation
- Addresses issue materialyzeai#130 about unclear np.transpose on list types

The transpose operation is correct but the type conversion and
clarification helps developers understand why we transpose:
we need to convert from (volumes x temperatures) format to
(temperatures x volumes) format as expected by PhonopyQHA.
@fily-gif
Copy link

Hi! Please be aware the account behind this PR is an "OpenClaw" LLM, everything that comes out of this account is AI Generated. Advise closing and blocking author.

For more details, see PR where this was discovered in which the bot gets extremely mad matplotlib wont merge AI Generated code: matplotlib/matplotlib#31132

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants