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

enforce consistent API #1971

Merged
merged 3 commits into from Jan 1, 2022
Merged

enforce consistent API #1971

merged 3 commits into from Jan 1, 2022

Conversation

akaszynski
Copy link
Member

Overview

In keeping with our goal to be consistent with numpy, this PR changes the behavior for several methods to return tuple rather than lists or numpy.ndarray. This includes:

  • pyvista.DataSet.bounds list -> tuple
  • pyvista.DataSet.extent list -> tuple
  • pyvista.DataSet.cell_bounds list -> tuple
  • pyvista.Grid.dimensions list -> tuple
  • pyvista.UniformGrid.origin list -> tuple
  • pyvista.UniformGrid.spacing list -> tuple
  • pyvista.ExplicitStructuredGrid.spacing np.ndarray -> tuple
  • pyvista.ExplicitStructuredGrid.visible_bounds list -> tuple

Why?

There's no reason for returning a list, which are more flexible than tuples and imply that there's a reason to append or manipulate the data. Rather, the immutability of the tuple implies that the data returned is "read only". And because VTK already returns tuples as the default datatype for GetBounds and other class methods, this actually simplifies our code. Plus, this matches numpy's shape, ndim and other properties.

Other Changes

@codecov
Copy link

codecov bot commented Dec 29, 2021

Codecov Report

Merging #1971 (99cbd51) into main (e56db11) will decrease coverage by 0.00%.
The diff coverage is 100.00%.

@@            Coverage Diff             @@
##             main    #1971      +/-   ##
==========================================
- Coverage   92.99%   92.99%   -0.01%     
==========================================
  Files          74       74              
  Lines       15484    15482       -2     
==========================================
- Hits        14400    14398       -2     
  Misses       1084     1084              

@tkoyama010 tkoyama010 added the enhancement Changes that enhance the library label Jan 1, 2022
@akaszynski akaszynski merged commit 5828416 into main Jan 1, 2022
@akaszynski akaszynski deleted the fix/no_negative_spacing branch January 1, 2022 18:19
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement Changes that enhance the library
Projects
None yet
Development

Successfully merging this pull request may close these issues.

UniformGrid with negative spacing results in wrong subset when using extract_subset
2 participants