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 5 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 ?)

Copy link

codecov bot commented Dec 12, 2024

Codecov Report

Attention: Patch coverage is 30.76923% with 9 lines in your changes missing coverage. Please review.

Project coverage is 50.56%. Comparing base (60140b1) to head (d1a7e88).

Additional details and impacted files
@@             Coverage Diff             @@
##           master    #1965       +/-   ##
===========================================
- Coverage   88.35%   50.56%   -37.80%     
===========================================
  Files          89       89               
  Lines       10242    10255       +13     
===========================================
- Hits         9049     5185     -3864     
- Misses       1193     5070     +3877     

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

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