Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: exposing quantity types in PyDPF Core #1965

Open
wants to merge 15 commits into
base: master
Choose a base branch
from

Conversation

a-bouth
Copy link

@a-bouth a-bouth commented Dec 12, 2024

Exposing the quantity_typefor FieldsDefinition

Main Changes

  • Added calls to the C API in field_definition_capi.py
  • Adding methods in field_definition.py
    • Note: I initially wanted to use a @property decorator for quantity_type, but it turns out that the getter needs an index, which we cannot specify with the @property decorator. I opted for defining explicits get_quantity_type(index) and set_quantity_type() methods. Please let me know if I should do it differently.
    • Also exposed is_of_quantity_type() and get_num_quantity_types_available()
  • Added corresponding test in test_field.py (I found other tests for FieldDefinition here, but maybe that's not the best place ?)

Side changes

Enabling the cast of FieldsContainer in the Any class

Copy link

codecov bot commented Dec 12, 2024

Codecov Report

Attention: Patch coverage is 94.11765% with 1 line in your changes missing coverage. Please review.

Project coverage is 86.10%. Comparing base (deb24c5) to head (4e147e3).

Additional details and impacted files
@@            Coverage Diff             @@
##           master    #1965      +/-   ##
==========================================
- Coverage   88.37%   86.10%   -2.28%     
==========================================
  Files          89       89              
  Lines       10265    10268       +3     
==========================================
- Hits         9072     8841     -231     
- Misses       1193     1427     +234     

src/ansys/dpf/gate/generated/field_definition_capi.py Outdated Show resolved Hide resolved
@@ -153,6 +153,61 @@ def dimensionality(self):
self._api.csfield_definition_fill_dimensionality(self, dim, nature, dim.internal_size)
return Dimensionality(dim.tolist(), natures(int(nature)))

def get_quantity_type(self, index=0):
Copy link
Contributor

Choose a reason for hiding this comment

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

Maybe having just one property which returns the quantity_types would be easier too use, what do you think?

tests/test_field.py Outdated Show resolved Hide resolved
src/ansys/dpf/core/field_definition.py Outdated Show resolved Hide resolved
@cbellot000
Copy link
Contributor

cbellot000 commented Dec 13, 2024 via email

@a-bouth a-bouth requested a review from a team as a code owner December 18, 2024 16:24
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