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

refactor(get_lrc, get_node): use numpy methods, add examples #1591

Merged
merged 1 commit into from
Oct 19, 2022

Conversation

mwtoews
Copy link
Contributor

@mwtoews mwtoews commented Oct 16, 2022

This PR replaces internal processing of get_lrc and get_node to use NumPy's unravel_index and ravel_multi_index. There is a minor speed bump, and the methods also check the bounds of the inputs, raising ValueError if they are outside the L/R/C/node range.

Also add docstring examples and minor formatting to adhere to the numpydoc style guide.

@codecov
Copy link

codecov bot commented Oct 16, 2022

Codecov Report

Merging #1591 (3b53949) into develop (2eeefd4) will decrease coverage by 0.0%.
The diff coverage is 100.0%.

@@            Coverage Diff            @@
##           develop   #1591     +/-   ##
=========================================
- Coverage     72.6%   72.6%   -0.1%     
=========================================
  Files          251     251             
  Lines        54419   54413      -6     
=========================================
- Hits         39553   39547      -6     
  Misses       14866   14866             
Impacted Files Coverage Δ
flopy/discretization/structuredgrid.py 46.8% <100.0%> (-0.4%) ⬇️

@mwtoews mwtoews force-pushed the ref-get-lrc-get-node branch from ace860c to 3b53949 Compare October 17, 2022 00:09
Copy link

@christianlangevin christianlangevin left a comment

Choose a reason for hiding this comment

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

This is nice, @mwtoews. Great to use numpy routines directly. Thanks.

I wonder if we should move away from get_lrc() and call it get_cellid() instead (or maybe have both for now), where cellid is (layer, row, column) for a structured grid, (layer, cellnumber) for a vertex grid, and (nodenumber) for an unstructured grid? The reverse can be implemented for get_node().

@wpbonelli
Copy link
Member

@langevin-usgs with this plan I think get_cellid would then be equivalent to get_lni for vertex grids — noting here to remind myself to add a test case if this change is made, to make sure calling them on a vertex grid returns the same thing

@christianlangevin christianlangevin merged commit 02749f0 into modflowpy:develop Oct 19, 2022
@mwtoews mwtoews deleted the ref-get-lrc-get-node branch October 19, 2022 22:26
wpbonelli pushed a commit to wpbonelli/flopy that referenced this pull request Dec 14, 2022
wpbonelli pushed a commit to wpbonelli/flopy that referenced this pull request Dec 14, 2022
wpbonelli pushed a commit to wpbonelli/flopy that referenced this pull request Dec 14, 2022
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.

3 participants