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

Fixed warnings in test_utils.py #394

Merged
merged 24 commits into from Apr 15, 2021
Merged

Fixed warnings in test_utils.py #394

merged 24 commits into from Apr 15, 2021

Conversation

Shadow2121
Copy link
Contributor

@Shadow2121 Shadow2121 commented Mar 17, 2021

fixed warning in test_utils.py.

warning was: #317

fury/tests/test_utils.py::test_trilinear_interp
fury/tests/test_utils.py::test_trilinear_interp
  D:\fury-master\fury\tests\test_utils.py:133: DeprecationWarning: Converting `np.integer` or `np.signedinteger` to a dtype is deprecated. The current result is `np.dtype(np.int_)` which is not strictly correct. Note that the result depends on the system. To ensure stable results use may want to use `np.int64` or `np.int32`.
    x0 = x_indices.astype(np.integer)

fury/tests/test_utils.py::test_trilinear_interp
fury/tests/test_utils.py::test_trilinear_interp
  D:\fury-master\fury\tests\test_utils.py:134: DeprecationWarning: Converting `np.integer` or `np.signedinteger` to a dtype is deprecated. The current result is `np.dtype(np.int_)` which is not strictly correct. Note that the result depends on the system. To ensure stable results use may want to use `np.int64` or `np.int32`.
    y0 = y_indices.astype(np.integer)

fury/tests/test_utils.py::test_trilinear_interp
fury/tests/test_utils.py::test_trilinear_interp
  D:\fury-master\fury\tests\test_utils.py:135: DeprecationWarning: Converting `np.integer` or `np.signedinteger` to a dtype is deprecated. The current result is `np.dtype(np.int_)` which is not strictly correct. Note that the result depends on the system. To ensure stable results use may want to use `np.int64` or `np.int32`.
    z0 = z_indices.astype(np.integer)

It is not much but I noticed it so I just changed it.

The equation looks like this in tutorial of solar system visualization,

temp

link - https://en.wikipedia.org/wiki/Orbital_period

It is not much but I noticed it so I just changed it.
@codecov
Copy link

codecov bot commented Mar 17, 2021

Codecov Report

Merging #394 (7e11233) into master (58dff3a) will decrease coverage by 0.20%.
The diff coverage is 100.00%.

❗ Current head 7e11233 differs from pull request most recent head 2fb518f. Consider uploading reports for the commit 2fb518f to get more accurate results
Impacted file tree graph

@@            Coverage Diff             @@
##           master     #394      +/-   ##
==========================================
- Coverage   89.08%   88.87%   -0.21%     
==========================================
  Files          23       23              
  Lines        5376     5393      +17     
  Branches      695      696       +1     
==========================================
+ Hits         4789     4793       +4     
- Misses        406      415       +9     
- Partials      181      185       +4     
Impacted Files Coverage Δ
fury/utils.py 86.54% <100.00%> (ø)
fury/__init__.py 65.71% <0.00%> (-11.43%) ⬇️
fury/ui.py 88.54% <0.00%> (-0.46%) ⬇️
fury/window.py 78.75% <0.00%> (ø)
fury/interactor.py 96.96% <0.00%> (+0.02%) ⬆️
fury/actor.py 92.95% <0.00%> (+0.04%) ⬆️
fury/primitive.py 91.78% <0.00%> (+0.23%) ⬆️
fury/convert.py 80.00% <0.00%> (+6.66%) ⬆️

fixed warring in test_utils.py
@Shadow2121 Shadow2121 changed the title Fixed equation for calculating orbital period Fixed warnnings in test_utils.py Mar 18, 2021
@Shadow2121 Shadow2121 changed the title Fixed warnnings in test_utils.py Fixed warnings in test_utils.py Mar 18, 2021
@Nibba2018
Copy link
Member

Hi @Shadow2121 , Thank you for creating this PR. Your changes look good to me. 👍

@skoudoro
Copy link
Contributor

Hi @Shadow2121,

Thanks for the update, I will test the tutorial today and come back to you. Thanks

@Shadow2121
Copy link
Contributor Author

Hi @skoudoro

If we change the equation in tutorial then we also need to update orbit_points = np.zeros((1000, 3), dtype='f8') to orbit_points = np.zeros((2000, 3), dtype='f8') because it will not cover entire orbit.

And also need to update:

def timer_callback(_obj, _event):
    cnt = next(counter)
    showm.render()

    global mercury_track, venus_track, earth_track, mars_track, jupiter_track
    global saturn_track, uranus_track, neptune_track

    update_planet_position(r_mercury, mercury_actor, mercury_track, cnt)

    update_planet_position(r_venus, venus_actor, venus_track, cnt)

    update_planet_position(r_earth, earth_actor, earth_track, cnt)

    update_planet_position(r_mars, mars_actor, mars_track, cnt)

    update_planet_position(r_jupiter, jupiter_actor, jupiter_track, cnt)

    pos_saturn = update_planet_position(r_saturn, saturn_actor, saturn_track,
                                        cnt)
    saturn_rings_actor.SetPosition(pos_saturn[0], 0, pos_saturn[1])

    update_planet_position(r_uranus, uranus_actor, uranus_track, cnt)

    update_planet_position(r_neptune, neptune_actor, neptune_track, cnt)

    if cnt == 999:
        update_track(positions_mercury, mercury_track, mercury_orbit_actor)

        update_track(positions_venus, venus_track, venus_orbit_actor)

        update_track(positions_earth, earth_track, earth_orbit_actor)

        update_track(positions_mars, mars_track, mars_orbit_actor)

        update_track(positions_jupiter, jupiter_track, jupiter_orbit_actor)

        update_track(positions_saturn, saturn_track, saturn_orbit_actor)

        update_track(positions_uranus, uranus_track, uranus_orbit_actor)

        update_track(positions_neptune, neptune_track, neptune_orbit_actor)

    if cnt == 1500:
        showm.exit()

in this increase cnt for if cnt == 999: to if cnt == 1999: and if cnt == 1500: to if cnt == 2500:

Updated some values because we changed equation.
Copy link
Contributor

@skoudoro skoudoro left a comment

Choose a reason for hiding this comment

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

Hi @Shadow2121,

Thank you for the update. See below for some comments.

fury/tests/test_utils.py Outdated Show resolved Hide resolved
docs/tutorials/01_introductory/viz_solar_system.py Outdated Show resolved Hide resolved
docs/tutorials/01_introductory/viz_solar_system.py Outdated Show resolved Hide resolved
As review suggested, changed some code.
Now, the path will update every call back.
@Shadow2121
Copy link
Contributor Author

Shadow2121 commented Mar 23, 2021

Hello @skoudoro,

In this last commit I changed the call-back function, now it will update path every call-back. So there no need to update (show) path after certain time.

DEMO.mp4

@skoudoro
Copy link
Contributor

Hi @Shadow2121,

Thank you for the update.

The creator of this tutorial chooses to update (show) path /orbit after a certain time for improving performance and saving memory at the beginning.
An alternative could be to draw the orbit from the beginning, using the line actor, and outside the callback function.

Could you look at this improvement?

Thank you

As suggested in review, now we are displaying the path/orbit before animation starts.
@pep8speaks
Copy link

pep8speaks commented Mar 23, 2021

Hello @Shadow2121! Thanks for updating this PR. We checked the lines you've touched for PEP 8 issues, and found:

There are currently no PEP 8 issues detected in this Pull Request. Cheers! 🍻

Comment last updated at 2021-04-15 03:54:54 UTC

@Shadow2121
Copy link
Contributor Author

Hi @skoudoro,

instead of using line actor I used update_track function to draw path/orbit.
How is it looking now?

@skoudoro
Copy link
Contributor

Hi @Shadow2121,

You can use update_track AND line_actor. I recommend that you look deeper into this. When we zoom on the scene, we see that each track is composed of multiple points and there is space between them. The goal is to avoid that effect to improve the demo.

Copy link
Contributor

@skoudoro skoudoro left a comment

Choose a reason for hiding this comment

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

2 more comments to improve the tutorial.

you are close to being done! thank you!

Comment on lines 253 to 278
for i in range(2200):
calculate_path(r_mercury, mercury_track, i)
calculate_path(r_venus, venus_track, i)
calculate_path(r_earth, earth_track, i)
calculate_path(r_mars, mars_track, i)
calculate_path(r_jupiter, jupiter_track, i)
calculate_path(r_saturn, saturn_track, i)
calculate_path(r_uranus, uranus_track, i)
calculate_path(r_neptune, neptune_track, i)

update_track(positions_mercury, mercury_track, mercury_orbit_actor)

update_track(positions_venus, venus_track, venus_orbit_actor)

update_track(positions_earth, earth_track, earth_orbit_actor)

update_track(positions_mars, mars_track, mars_orbit_actor)

update_track(positions_jupiter, jupiter_track, jupiter_orbit_actor)

update_track(positions_saturn, saturn_track, saturn_orbit_actor)

update_track(positions_uranus, uranus_track, uranus_orbit_actor)

update_track(positions_neptune, neptune_track, neptune_orbit_actor)

Copy link
Contributor

Choose a reason for hiding this comment

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

this block can be reduced with 3-4 lines of code which avoids duplication.

  • use zip
  • call calculate_path and update_track only once in your loop
  • pass 2200 in your calculate_path

Copy link
Contributor Author

Choose a reason for hiding this comment

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

If i use line actor then there is no need for update_track,

@@ -183,7 +183,7 @@ def get_orbit_actor(orbit_points):
# orbit actors into the scene. Also initialize the track variables for each
# planet.

orbit_points = np.zeros((2001, 3), dtype='f8')
orbit_points = np.zeros((2200, 3), dtype='f8')
Copy link
Contributor

Choose a reason for hiding this comment

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

Can you replace f8 by float? Thank you.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done, and sorry about that.

Copy link
Contributor

@skoudoro skoudoro left a comment

Choose a reason for hiding this comment

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

Hi @Shadow2121,

thanks for the update.

  • Some of my comments are not addressed
  • pep8 isssue are not addressed
  • the tutorial needs cleaning. many objects are not needed anymore like all orbital actors.

Some changes according reviews.
@Shadow2121
Copy link
Contributor Author

Hi @skoudoro,

Sorry about that, And

  • [ Done ] many objects are not needed anymore like all orbital actors.
  • [ Done ] pep8 isssue are not addressed
  • pass 2200 in your calculate_path -> For this I didn't get the point. If I pass 2200 to the function then it is not calculating for all points, it is doing calculation 2200 times for only one point.

Made some changes in documentation since changed so many code.
Copy link
Contributor

@skoudoro skoudoro left a comment

Choose a reason for hiding this comment

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

[ Done ] many objects are not needed anymore like all orbital actors.

There are still some useless text or functions like get_orbital_actor. Please, review completely the tutorial

[ Done ] pep8 isssue are not addressed

There is still some pep8 issue as you can see here.
Please, in general, try to pay more attention to details.

pass 2200 in your calculate_path -> For this I didn't get the point. If I pass 2200 to the function then it is not calculating for all points, it is doing calculation 2200 times for only one point.

Yes, this is why you will have to update calculate_path function

@Shadow2121
Copy link
Contributor Author

Shadow2121 commented Mar 28, 2021

Oh, that's my bad I really thought that PEP 8 comment will pop at the bottom of our conversation, I will keep that in mind.

  • [ Done ] Review completely the tutorial
  • [ Done ] pep8 issue
  • [ Done ] update calculate_path function
  • And changed some comments(documentation).

Thank you

@Shadow2121
Copy link
Contributor Author

On my system(windows 10 64-bit) for different versions of python (3.7.0, 3.7.9, 3.9.1), I always get 1073741824.
Which OS are you using? @guaje

@Nibba2018 @skoudoro, do you guys still have the visual bug?

@skoudoro
Copy link
Contributor

skoudoro commented Apr 8, 2021

@Nibba2018 @skoudoro, do you guys still have the visual bug?

I do not have any the bug.

There is still some work to do in this tutorial.

But ok, we can merge this second version as it is. We will need to create a third version to reduce code duplication.
let me know if it is ok with you @guaje, @Nibba2018 and @nasimanousheh

Thanks @Shadow2121

@Nibba2018
Copy link
Member

@Shadow2121 @skoudoro @guaje

I dont have that visual bug either 👍

@guaje
Copy link
Contributor

guaje commented Apr 8, 2021

On my system(windows 10 64-bit) for different versions of python (3.7.0, 3.7.9, 3.9.1), I always get 1073741824.
Which OS are you using? @guaje

I did try in multiple Linux distributions (Arch-based and Debian-based) with different python versions (3.7.3, Anaconda 3.7.7, and 3.7.8).

But ok, we can merge this second version as it is. We will need to create a third version to reduce code duplication.
let me know if it is ok with you @guaje, @Nibba2018 and @nasimanousheh

I don't think adjusting the code duplication will take too much time/effort, so, why not do it now?

@skoudoro
Copy link
Contributor

skoudoro commented Apr 8, 2021

I don't think adjusting the code duplication will take too much time/effort, so, why not do it now?

Good question and I will let @Shadow2121 answer it

@Shadow2121
Copy link
Contributor Author

Ok I will do it.

But till now are there any major mistakes that I made that need to be changed.

Reduced some repetitive code. and some more changes like list name changed.
If there is any changes please let me know.
@Shadow2121
Copy link
Contributor Author

@skoudoro @guaje @Nibba2018 can you guys help? Are there any more changes that need to be done?

Copy link
Contributor

@skoudoro skoudoro left a comment

Choose a reason for hiding this comment

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

Hi @Shadow2121,

Thank you for the update. See below for some ideas to improve your version.
you are closer to the end of this PR!

docs/tutorials/01_introductory/viz_solar_system.py Outdated Show resolved Hide resolved
docs/tutorials/01_introductory/viz_solar_system.py Outdated Show resolved Hide resolved
docs/tutorials/01_introductory/viz_solar_system.py Outdated Show resolved Hide resolved
docs/tutorials/01_introductory/viz_solar_system.py Outdated Show resolved Hide resolved
docs/tutorials/01_introductory/viz_solar_system.py Outdated Show resolved Hide resolved
Did some changes as per review.
@Shadow2121
Copy link
Contributor Author

@skoudoro,

Thank you very much for all your help. Done all the changes you mentioned.

It was raising the warning.
@Shadow2121
Copy link
Contributor Author

Changed data = np.array(data) to data = np.array(data, dtype=object).
Because It was raising the warning,

VisibleDeprecationWarning: Creating an ndarray from ragged nested sequences (which is a list-or-tuple of lists-or-tuples-or ndarrays with different lengths or shapes) is deprecated. If you meant to do this, you must specify 'dtype=object' when creating the ndarray
  data = np.array(data)

Copy link
Contributor

@guaje guaje left a comment

Choose a reason for hiding this comment

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

Thanks, @Shadow2121! The code looks way better. I just added a couple of suggestions to improve the readability of the tutorial.

docs/tutorials/01_introductory/viz_solar_system.py Outdated Show resolved Hide resolved
docs/tutorials/01_introductory/viz_solar_system.py Outdated Show resolved Hide resolved
docs/tutorials/01_introductory/viz_solar_system.py Outdated Show resolved Hide resolved
docs/tutorials/01_introductory/viz_solar_system.py Outdated Show resolved Hide resolved
docs/tutorials/01_introductory/viz_solar_system.py Outdated Show resolved Hide resolved
Some more changes according to review.
@Shadow2121
Copy link
Contributor Author

@guaje, Thank you very much.

Copy link
Contributor

@guaje guaje left a comment

Choose a reason for hiding this comment

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

These new changes look good to me! Thanks, @Shadow2121

Copy link
Contributor

@skoudoro skoudoro left a comment

Choose a reason for hiding this comment

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

Hi @Shadow2121,

Everything looks almost good. See below my comments. I think they are the last ones. When it is fixed, I can approve and merge this PR.

Thanks again!

docs/tutorials/01_introductory/viz_solar_system.py Outdated Show resolved Hide resolved
docs/tutorials/01_introductory/viz_solar_system.py Outdated Show resolved Hide resolved
docs/tutorials/01_introductory/viz_solar_system.py Outdated Show resolved Hide resolved
docs/tutorials/01_introductory/viz_solar_system.py Outdated Show resolved Hide resolved
Final touch to tutorial.
Copy link
Contributor

@skoudoro skoudoro left a comment

Choose a reason for hiding this comment

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

Good job on the hard work. merging

@skoudoro skoudoro merged commit b7f09ab into fury-gl:master Apr 15, 2021
@skoudoro skoudoro added this to the v0.8.0 milestone Apr 15, 2021
@Shadow2121
Copy link
Contributor Author

Thank you :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

6 participants