Skip to content

Conversation

@Muhammad-Rebaal
Copy link
Contributor

Hi @danielhollas !

I've implemented the fix for the issue #6375 with StructureData.cell_angles as you requested. The solution now:

  1. Raises a ValueError if all cell vectors have zero length
  2. Returns None for undefined angles when only some vectors have zero length
  3. Adds protection against numerical issues by clamping cosine values

The implementation does exactly what we discussed in the issue conversation. If there's anything else that should be changed or improved, please let me know.

Thank You!

@codecov
Copy link

codecov bot commented Apr 11, 2025

Codecov Report

❌ Patch coverage is 0% with 12 lines in your changes missing coverage. Please review.
✅ Project coverage is 79.02%. Comparing base (5e4da5b) to head (37670df).

Files with missing lines Patch % Lines
src/aiida/orm/nodes/data/structure.py 0.00% 12 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #6820      +/-   ##
==========================================
- Coverage   79.05%   79.02%   -0.02%     
==========================================
  Files         566      566              
  Lines       43649    43660      +11     
==========================================
- Hits        34501    34499       -2     
- Misses       9148     9161      +13     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

Copy link
Collaborator

@danielhollas danielhollas left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@Muhammad-Rebaal Thanks! I am currently on holiday so will do a more detailed review later, but this will need tests, both for the happy path and for the error conditions.

else:
dot_product = numpy.vdot(cell[i], cell[j])
cos_angle = dot_product / (lengths[i] * lengths[j])
# Handle numerical issues where |cos_angle| might slightly exceed 1
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would be good to have a test case for this. Have you encountered this yourself?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No didn't encountered that , but no worries. I'll write one .

@danielhollas danielhollas self-assigned this Aug 18, 2025
@GeigerJ2 GeigerJ2 force-pushed the Bug_fix_of_get_angle branch from 54cce4f to 37670df Compare August 19, 2025 08:37
@danielhollas
Copy link
Collaborator

If I have time during the coding days, my plan here is to revert unnecessary changes in this PR (e.g. focus only on the new error handling) and write tests.

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