ansys / pydpf-post

Data Processing Framework - Post Processing Module
https://post.docs.pyansys.com
MIT License
43 stars 10 forks source link

Add get_data_by_id method in DataObject #230

Closed GuillemBarroso closed 1 year ago

GuillemBarroso commented 1 year ago

Fix #229.

This PR proposes the implementation of the get_data_by_id() method of DataObject.

@rlagha, I was also thinking to use the as_array() method here, instead of get_data_by_id(). I assume most users will want the data with its ID info when getting an array, so maybe we could just use as_array().

The output will be two ndarrays with the data and ids for all the fields in the DataObject. The first entry of each array is one field. For instance, to get the "Z" component of the displacement of the first field, the user would do:

data, ids = simulation.displacement().get_data_by_id()
z_disp_first_field = data[0][3]
codecov[bot] commented 1 year ago

Codecov Report

Merging #230 (c288d87) into post_refactor (89fdadf) will increase coverage by 3.01%. The diff coverage is 100.00%.

@@                Coverage Diff                @@
##           post_refactor     #230      +/-   ##
=================================================
+ Coverage          74.89%   77.90%   +3.01%     
=================================================
  Files                 30       30              
  Lines               1665     1684      +19     
=================================================
+ Hits                1247     1312      +65     
+ Misses               418      372      -46     
PProfizi commented 1 year ago

Closing PR for now