fatiando / boule

Reference ellipsoids for geodesy and geophysics
https://www.fatiando.org/boule
BSD 3-Clause "New" or "Revised" License
38 stars 17 forks source link

Check if normal gravity is computed on internal point #83

Closed MGomezN closed 2 years ago

MGomezN commented 3 years ago

Fixes #44

Reminders

MGomezN commented 3 years ago

Hi! I am back. I just wanted to make a pull request for my last commit, but I couldn't erase the past commits. This time I tried to follow more carefully the Contributing Guidelines. I ran checks format, check, lint and test. All of them appear successful. However, I am dubious about the solution I implemented using the norm. Maybe is a condition that is always true by definition of "norm"... so, I'll wait for your review. Thank you!

santisoler commented 3 years ago

HI @MGomezN! Thanks again for your contributions.

I just wanted to make a pull request for my last commit, but I couldn't erase the past commits.

I'm not sure if I'm following you here. Have you tried to commit to your internal_point branch? In git we don't erase previous commits (unless it's strictly necessary) because that could potentially create a lot of troubles. Instead you can always add a new commit making changes that fixes the problems introduced by any previous commit. This not only makes version control easier, but also helps us to keep track of the changes and decisions we made in the past.

However, I am dubious about the solution I implemented using the norm. Maybe is a condition that is always true by definition of "norm"... so, I'll wait for your review.

I'm not entirely sure why are you checking if the norm of the height is greater than zero. Raising the warning if height < 0 should be enough, right?

On #66 you also added the same check for the Sphere class. Would you like to add it here if you want to continue the development of this feature on this PR?

MGomezN commented 3 years ago

HI @MGomezN! Thanks again for your contributions.

Thank you @santisoler

I'm not sure if I'm following you here. Have you tried to commit to your internal_point branch? In git, we don't erase previous commits (unless it's strictly necessary) because that could potentially create a lot of troubles. Instead you can always add a new commit making changes that fixes the problems introduced by any previous commit. This not only makes version control easier, but also helps us to keep track of the changes and decisions we made in the past.

No. I didn't try to commit to my internal_point branch. I worked with internal_point branch almost six months ago, and by that time, I had a lot of trouble with the environment, and also I made a reset of my PC. Therefore It seemed easier to start everything from zero last week when I resume my work on this issue. So, I closed my pull request related to the internal_point branch, and actually, I erased my fork of the Boule repository, and I started everything from the beginning: clone, fork, Install environment, and so on. I incorporated comments from Leonardo made on the internal_point branch, and as a result, I created commit 9b71364.

But… I forgot to run make format, make check, make linnet, so I did it. I discovered one error, I repaired that error, and then I created commit bd0dcd7.

I'm not entirely sure why are you checking if the norm of the height is greater than zero. Raising the warning if height < 0 should be enough, right?

Again, I forgot to ran the make test, I did it, and there was a new error saying height <0 is not ok because height could be an array, not just a scalar, so I tried to use the norm of the array “height,” and that was mi final commit a0a2239

So, I wanted to erase commits 9b71364 and bd0dcd7 because I know (now) they were incomplete. The most complete is commit a0a2239. Jeje It seems I still don't get a good understanding of Git, but for me, it is unnecessary to leave 9b71364 and bd0dcd7 in the track of changes. That is why I said I wanted to delete them.

On #66 you also added the same check for the Sphere class. Would you like to add it here if you want to continue the development of this feature on this PR?

Ups, see? Not too much focus in my head. Yes, I want to change the Sphere class also.

santisoler commented 3 years ago

No. I didn't try to commit to my internal_point branch. I worked with internal_point branch almost six months ago, and by that time, I had a lot of trouble with the environment, and also I made a reset of my PC. Therefore It seemed easier to start everything from zero last week when I resume my work on this issue. So, I closed my pull request related to the internal_point branch, and actually, I erased my fork of the Boule repository, and I started everything from the beginning: clone, fork, Install environment, and so on. I incorporated comments from Leonardo made on the internal_point branch, and as a result, I created commit 9b71364. But… I forgot to run make format, make check, make linnet, so I did it. I discovered one error, I repaired that error, and then I created commit bd0dcd7.

No big deal then! Just wanted to know if you were experiencing technical issues or if you willingly started again from scratch.

Again, I forgot to ran the make test, I did it, and there was a new error saying height <0 is not ok because height could be an array, not just a scalar, so I tried to use the norm of the array “height,” and that was mi final commit a0a2239

You are absolutely right! We cannot use height < 0 because height can be an array and it would return a boolean array, so the statement height < 0 cannot be evaluated as a single bool. Nevertheless, using np.linalg.norm would create always positive values, so it won't work for our purposes. What we need to check if any value of height is negative, so give np.any() a try.

So, I wanted to erase commits 9b71364 and bd0dcd7 because I know (now) they were incomplete. The most complete is commit a0a2239. Jeje It seems I still don't get a good understanding of Git, but for me, it is unnecessary to leave 9b71364 and bd0dcd7 in the track of changes. That is why I said I wanted to delete them.

We virtually never delete a commit, as I said before, the best practice is to add a new commit that fixes the mistakes of the previous ones. Think of git as a journey: you know where you started and you know where you are right now, but you cannot erase all the points in the middle, because they took you where you are right now. That being said, when we merge this branch into master we do a Squash and Merge: we squash every commit from this PR into a single one. So feel free to add as many commits as you want, they will not end up in the history of Boule's master branch. Using Squash and Merge generates a way cleaner log history on master and makes the development of new features much easier by allowing us to break stuff on any other branch, we just need to be very careful what we merge to master and that's why we have all the CIs automatically checking stuff for us.

Ups, see? Not too much focus in my head. Yes, I want to change the Sphere class also.

No problem! Feel free to finish the warning on Ellipsoid and once you got it right, you can start adding it to Sphere.

MGomezN commented 3 years ago

You are absolutely right! We cannot use height < 0 because height can be an array and it would return a boolean array, so the statement height < 0 cannot be evaluated as a single bool. Nevertheless, using np.linalg.norm would create always positive values, so it won't work for our purposes. What we need to check if any value of height is negative, so give np.any() a try.

Hello @santisoler. I tried your suggestion in commit 8b48925 We virtually never delete a commit, as I said before, the best practice is to add a new commit that fixes the mistakes of the previous ones. Think of git as a journey: you know where you started and you know where you are right now, but you cannot erase all the points in the middle, because they took you where you are right now. That being said, when we merge this branch into master we do a Squash and Merge: we squash every commit from this PR into a single one. So feel free to add as many commits as you want, they will not end up in the history of Boule's master branch. Using Squash and Merge generates a way cleaner log history on master and makes the development of new features much easier by allowing us to break stuff on any other branch, we just need to be very careful what we merge to master and that's why we have all the CIs automatically checking stuff for us.

I understand. Looking forward to squash and merge all my mistakes jeje

No problem! Feel free to finish the warning on Ellipsoid and once you got it right, you can start adding it to Sphere.

I think it works now. I only feel insecure about the place where I wrote the warning (under de def of normal_gravity). I don't know if it must be written before, for example, after line 97, where are those bunch of checks e.g. @flattening.validator.

santisoler commented 3 years ago

I understand. Looking forward to squash and merge all my mistakes jeje

😂

I think it works now. I only feel insecure about the place where I wrote the warning (under de def of normal_gravity). I don't know if it must be written before, for example, after line 97, where are those bunch of checks e.g. @flattening.validator.

The warning is coded in the perfect spot. The requirement of height being positive or zero only applies to the normal_gravity method, so there's no point in creating a separate private method (like _check_flattening) for raising this particular warning: no other method will use it, and because the warning only takes ~3 lines, we are not cluttering the code.

Would you like to start writing a test function that checks if the warning is raised after passing a negative height? If so, please create a new function in tests/test_ellipsoid.py. You can catch warnings in test functions with warnings.catch_warnings(record=True), like this: https://github.com/fatiando/boule/blob/145384d87a68569dc4ede3acd2a39bbffe16c6b5/boule/tests/test_ellipsoid.py#L59-L67

If you need any help, please feel free to ask!

MGomezN commented 3 years ago

Would you like to start writing a test function that checks if the warning is raised after passing a negative height? If so, please create a new function in tests/test_ellipsoid.py. You can catch warnings in test functions with warnings.catch_warnings(record=True), like this: https://github.com/fatiando/boule/blob/145384d87a68569dc4ede3acd2a39bbffe16c6b5/boule/tests/test_ellipsoid.py#L59-L67

Thank you @santisoler . I added the test and the warning for boule.Sphere.normal_gravity() in commit 1f6f555. Fingers cross!

leouieda commented 2 years ago

And a big thank you to @santisoler for providing brilliant guidance here (as always) 🎉

welcome[bot] commented 2 years ago

🎉🎉🎉 Congrats on merging your first pull request and welcome to the team! 🎉🎉🎉

If you would like to be added as a author on the Zenodo archive of the next release, make sure that you have added your full name, affiliation, and ORCID (optional) to the AUTHORS.md file of this repository.

We hope that this was a good experience for you. Let us know if there is any way that the contributing process could be improved.

MGomezN commented 2 years ago

Thanks, @santisoler @leouieda, for such an amazing demonstration of patience with me. I can't believe this pull request has been approved...

leouieda commented 2 years ago

Thank you for the patience with us (me mostly) 🙂 Again, I'm really sorry for letting this stall for so long.