Add copy method to mesher classes#301
Conversation
|
Thank you for doing this! The code and tests are looking pretty good! I don't think there is much else to do but a few minor changes and documentation. The reason Travis CI is failing is because of the style check (PEP8). See here for the error log. You just have one too many lines after the copy method. You can run One other thing I would ask is that you rename your test file to |
|
|
||
| def test_square_copy(): | ||
| orig = Square([0, 1, 2, 4], {'density': 750}) | ||
| cp = orig.copy() |
There was a problem hiding this comment.
Another check you do is to check is an object is the same reference as another using the is comparison: cp is not orig.
Two objects might be equal but not be the same object.
|
@PiotrKurnik let me know when you make some of these changes so that I can take a look. No pressure and no hurry 😄 One things I forgot to mention is that the |
|
@leouieda I have added |
|
@PiotrKurnik OK! Let me know when you're finished and I'll review the code to see if there is anything else needed. Great job on this! |
|
|
||
| def test_prism_mesh_copy(): | ||
| p1 = PrismMesh((0, 1, 0, 2, 0, 3), (1, 2, 2)) | ||
| p1.addprop('density', 3200) |
There was a problem hiding this comment.
For the mesh classes in Fatiando, the physical properties are arrays of values (one for each cell in the mesh). Could you test this using arrays? You can create the array with something like p1.addprop('density', 3200 + np.zeros(p1.size))
|
@PiotrKurnik one thing I just remembered, all basic geometric types ( |
|
@leouieda Good spot! I have pushed the code. Let's see if it's any closer now. |
| def copy(self): | ||
| """ Return a deep copy of the current instance.""" | ||
| return cp.deepcopy(self) | ||
|
|
There was a problem hiding this comment.
You can remove this one since Polygon will inherit it from GeometricElement.
|
@PiotrKurnik all looks good! Just made a few minor comments. Once those are done let me know and I'll hapilly merge this. Thank you for putting time into this! |
|
Thanks @leouieda. I am sorry it took so long. |
| * `Martin Bentley`_ - Nelson Mandela Metropolitan University, South Africa and AEON, South Africa | ||
| * `Victor Almeida`_ - UERJ, Brazil. | ||
| * `M. Andy Kass`_ - United States Geological Survey, USA | ||
| * `Piotr Kurnik`_ - United Kingdom |
There was a problem hiding this comment.
Do you want to link your name to some page (a personal page, github profile, etc)? If so, add the link to the lines below like the other contributors. If not, you can remove the back tics and the underline.
Sorry that I didn't see this before.
There was a problem hiding this comment.
I removed the back ticks.
|
@PiotrKurnik no problem! We're all busy with other work and I'm the last one that can complain. |
| the `Python Packaging User Guide <https://packaging.python.org/>`__. | ||
| (`PR 294 <https://github.com/fatiando/fatiando/pull/294>`__) | ||
| * Enable ``fatiando.mesher.PointGrid`` to have points at different depths by | ||
| * Enable ``fatiando.mesher.PointGrid`a` to have points at different depths by |
There was a problem hiding this comment.
Looks like an a was inserted here by mistake. Could you please delete it?
There was a problem hiding this comment.
no idea where it came from ....
|
@PiotrKurnik everything builds properly on my machine and we're ready to merge! |
|
@PiotrKurnik merged! Congratulations on your first contribution (of many I hope)! |
Fixes #284
I added copy method to Square. Also I wrote some tests. This is for a try, if OK I will make further changes.
Checklist:
doc/install.rst,requirements.txt,environment.yml,ci/requirements-conda.txtandci/requirements-pip.txt.cd doc; makelocally)doc/contributors.rst(leave for last to avoid conflicts)