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

Merged
merged 22 commits into from
Jan 24, 2025

Conversation

a-bouth
Copy link
Contributor

@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

All modified and coverable lines are covered by tests ✅

Project coverage is 88.60%. Comparing base (3e08d26) to head (a2bb52e).
Report is 1 commits behind head on master.

Additional details and impacted files
@@            Coverage Diff             @@
##           master    #1965      +/-   ##
==========================================
+ Coverage   87.56%   88.60%   +1.04%     
==========================================
  Files          90       90              
  Lines       10254    10271      +17     
==========================================
+ Hits         8979     9101     +122     
+ Misses       1275     1170     -105     

@@ -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?

@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
@a-bouth a-bouth merged commit 4f18158 into master Jan 24, 2025
45 of 46 checks passed
@a-bouth a-bouth deleted the feat/exposing_quantity_types branch January 24, 2025 09:22
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