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/refine tree #141

Merged
merged 37 commits into from
Apr 22, 2019
Merged

Feat/refine tree #141

merged 37 commits into from
Apr 22, 2019

Conversation

fourndo
Copy link
Member

@fourndo fourndo commented Mar 19, 2019

  • Add functionality for TreeMesh creation
  • General bug fix on refine function

@jcapriot
Copy link
Member

This should address issues #139 & #109 on my end

Copy link
Member

@prisae prisae left a comment

Choose a reason for hiding this comment

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

I just left a few comments with regards to meshBuilderXYZ, as I looked at it with regards to #144 .

I think the comments I made is along discussions I had in another thread with @lheagy. PeP8-conventions that were not followed in SimPEG originally, but should be followed for new code.

As I am not familiar with the TreeMesh implementiation I won't do a full review.

'are implemented')

assert verticalAlignment in ['center', 'top'], ("verticalAlignment must be 'center' | 'top'")

Copy link
Member

@prisae prisae Mar 23, 2019

Choose a reason for hiding this comment

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

Replace assert with an if-statement and raise. assert should only be used for testing with unittest/pytest in test_xyz.py-files, as certain flags will remove or ignore assert statements.

expFact=1.3,
meshType='TENSOR',
verticalAlignment='top'
):
Copy link
Member

@prisae prisae Mar 23, 2019

Choose a reason for hiding this comment

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

The naming convention states CapsWords for classes, but lower_case_with_underscores for functions and variables (https://www.python.org/dev/peps/pep-0008/#function-and-variable-names). Even though SimPEG is not strict in this, I think it would be preferred that new code follows it. Hence def mesh_builder_xyz, and pad_x, exp_fact, mesh_type, vertical_alignment etc.

return nC

# Figure number of padding cells required to fill the space
npadEast = expand(h[0], padX[0])
Copy link
Member

Choose a reason for hiding this comment

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

Naming again here and in many other places, e.g., npad_east, pad_x, exp_fact, ....

@codecov
Copy link

codecov bot commented Mar 25, 2019

Codecov Report

Merging #141 into master will decrease coverage by 0.48%.
The diff coverage is 67.22%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master     #141      +/-   ##
==========================================
- Coverage   82.74%   82.26%   -0.49%     
==========================================
  Files          22       22              
  Lines        4556     4725     +169     
==========================================
+ Hits         3770     3887     +117     
- Misses        786      838      +52
Impacted Files Coverage Δ
discretize/TreeMesh.py 47.41% <0%> (-4.33%) ⬇️
discretize/utils/meshutils.py 84.92% <80.66%> (-5.4%) ⬇️
discretize/View.py 73.4% <0%> (-0.27%) ⬇️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 0824f7f...70261c9. Read the comment docs.

@fourndo
Copy link
Member Author

fourndo commented Apr 4, 2019

@lheagy Can you give me a hand with this? Can't figure out where the error come from, and the plot doesn't seem to show...
image

@lheagy
Copy link
Member

lheagy commented Apr 4, 2019

@dom, for sure. Can you give me a bit more context? is this plot in the test?

@fourndo
Copy link
Member Author

fourndo commented Apr 4, 2019

Plot is in utils.meshutils.mesh_builder_xyz. I would like to show in the doc, and planning on adding the same for the refine function. But the doc builder on my PC is giving huge issues.

@fourndo fourndo requested a review from jcapriot April 4, 2019 20:17
Copy link
Member

@jcapriot jcapriot left a comment

Choose a reason for hiding this comment

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

Looks pretty good to me. Can't really see anymore issues.

mesh_type='TENSOR'
):
"""
Function to quickly generate a Tensor of Tree mesh
Copy link
Member

Choose a reason for hiding this comment

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

"or"


"""
if mesh_type not in ['TENSOR', 'TREE']:
raise Exception(
Copy link
Member

Choose a reason for hiding this comment

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

I think raising a ValueError is the more appropriate exception here, instead of just throwing a general exception.

if octree_levels_padding is not None:

if len(octree_levels_padding) != len(octree_levels):
raise Exception(
Copy link
Member

Choose a reason for hiding this comment

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

Again ValueError is probably more appropriate.


return mesh.max_level-ii

return 0
Copy link
Member

Choose a reason for hiding this comment

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

could it be good to add a min_level parameter? so that you'll always get cells at least at that level? Maybe something that gets called first before any of these three get evaluated? A simple mesh.refine(min_level) should work.

@fourndo
Copy link
Member Author

fourndo commented Apr 6, 2019

@jcapriot Just need to add an example, but all systems green on my end.

@fourndo
Copy link
Member Author

fourndo commented Apr 9, 2019

Copy link
Member

@lheagy lheagy 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 looking good! Sorry it took me so long to take a look. I made a few minor suggestions. When I built the docs locally, the image showed up, so I am not entirely sure where the problem is happening on the windows side @fourndo - we can follow up in slack.

discretize/utils/meshutils.py Outdated Show resolved Hide resolved
discretize/utils/meshutils.py Outdated Show resolved Hide resolved
discretize/utils/meshutils.py Outdated Show resolved Hide resolved
discretize/utils/meshutils.py Outdated Show resolved Hide resolved
discretize/utils/meshutils.py Outdated Show resolved Hide resolved
discretize/utils/meshutils.py Outdated Show resolved Hide resolved
discretize/utils/meshutils.py Outdated Show resolved Hide resolved
discretize/utils/meshutils.py Outdated Show resolved Hide resolved
discretize/utils/meshutils.py Show resolved Hide resolved
lheagy and others added 10 commits April 9, 2019 16:29
@fourndo fourndo requested a review from lheagy April 18, 2019 17:55
@fourndo
Copy link
Member Author

fourndo commented Apr 19, 2019

@lheagy We get a little drop in coverage because of the plotting function, but good to go whenever you are.

Copy link
Member

@lheagy lheagy left a comment

Choose a reason for hiding this comment

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

This looks good! Just one request - can we move the docs over to numpy-style?

on the underlaying mesh to reduce interpolation errors.
The core extent is set by the bounding box of the xyz location.

:param numpy.ndarray xyz: Location points [n x dim]
Copy link
Member

Choose a reason for hiding this comment

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

For future docs, can we stick with the numpy-style?

If it is helpful, I can reformat this and push it back, just let me know :)

@lheagy lheagy merged commit e53b518 into master Apr 22, 2019
@lheagy lheagy deleted the feat/refineTree branch April 22, 2019 22:01
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.

4 participants