GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — sphinx gallery by clewis7 · Pull Request #509 · fastplotlib/fastplotlib

Conversation

@clewis7

@clewis7 clewis7 commented May 29, 2024 •
edited
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown
Member

start #486 for hopefully the last time :)

According to @almarklein, should just be able to directly use pygfx image scraper

Initially, I am just trying to get it to work with one set of the desktop examples.

Current issues:

  1. Offscreen rendering is being ignored even if it is in os.environ keys, should have maybe been fixed by Improvements to GUI selection and Qt support #431
  2. When using gflw WgpuCanvas, the pygfx scraper is looking for the canvas or renderer and then attempting to call canvas.draw() but the desired method is canvas.draw_frame()
  3. Beyond this, if I in-place change the source code of the pygfx scraper to use the correct draw method, an issue arises with trying to write a frame:
    Traceback (most recent call last):
      File "/home/caitlin/venvs/fpl/lib/python3.12/site-packages/sphinx_gallery/scrapers.py", line 341, in save_figures
        rst = scraper(block, block_vars, gallery_conf)
              ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
      File "/home/caitlin/venvs/fpl/lib/python3.12/site-packages/pygfx/utils/gallery_scraper.py", line 136, in pygfx_scraper
        render_screenshot(canvas, namespace, img_filename, **config)
      File "/home/caitlin/venvs/fpl/lib/python3.12/site-packages/pygfx/utils/gallery_scraper.py", line 209, in render_screenshot
        iio.imwrite(
      File "/home/caitlin/venvs/fpl/lib/python3.12/site-packages/imageio/v3.py", line 147, in imwrite
        encoded = img_file.write(image, **kwargs)
                  ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
      File "/home/caitlin/venvs/fpl/lib/python3.12/site-packages/imageio/plugins/pillow.py", line 443, in write
        for frame in ndimage:
    TypeError: iteration over a 0-d array

@kushalkolar @almarklein thoughts?

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

kushalkolar reacted with rocket emoji
All reactions
  • 🚀 1 reaction
@clewis7
start sphinx gallery
22e1c85
@clewis7
clewis7 requested a review from kushalkolar as a code owner May 29, 2024 21:32
@clewis7
clewis7 marked this pull request as draft May 29, 2024 21:32
@clewis7
relevant file changes
71c1eaf
clewis7
clewis7 commented May 29, 2024
View reviewed changes
Comment thread examples/desktop/gridplot/gridplot.py Resolved

Uh oh!

There was an error while loading. Please reload this page.

@clewis7
progress
c8eb15d
@clewis7

clewis7 commented May 30, 2024

Copy link
Copy Markdown
Member Author

Can now force offscreen rendering, so the gallery is being generated.

Current issue is figuring out how to format the index.rst and conf.py in order to properly display the gallery.

  1. For some reason the dropdown for all the examples only gets placed on the last one
    image
  2. The thumbnails are being displayed weird
    image
All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

clewis7 added 4 commits May 30, 2024 16:05
@clewis7
edit setup.py to include missing dependencies
e97f37b
@clewis7
attempt to fix rtd
5e0d08c
@clewis7
remove large heatmap example that breaks rtd
1acbbfb
@clewis7
fix linter, attempt to fix quickstart bug
372e466
kushalkolar
kushalkolar reviewed May 30, 2024
View reviewed changes
Comment thread docs/source/quickstart.ipynb Resolved

Uh oh!

There was an error while loading. Please reload this page.

@clewis7
fix gridplot examples and gallery structure
b4dbc94
@clewis7

clewis7 commented Jun 4, 2024

Copy link
Copy Markdown
Member Author

@BalzaniEdoardo

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@BalzaniEdoardo

BalzaniEdoardo commented Jun 4, 2024

Copy link
Copy Markdown
Collaborator

@clewis7 remove the "nbsphinx", it seems to create some conflicts

sphinx-gallery/sphinx-gallery#1195

kushalkolar reacted with heart emoji
All reactions
  • ❤️ 1 reaction

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

BalzaniEdoardo
BalzaniEdoardo reviewed Jun 4, 2024
View reviewed changes

@BalzaniEdoardo BalzaniEdoardo left a comment

Copy link
Copy Markdown
Collaborator

There was a problem hiding this comment.

Choose a reason for hiding this comment

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

this solves the refs not being generated

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
Comment thread docs/source/conf.py Resolved

Uh oh!

There was an error while loading. Please reload this page.

@clewis7

clewis7 commented Jun 4, 2024

Copy link
Copy Markdown
Member Author

@kushalkolar Like Edo said, in order to use sphinx-gallery we would need to remove nbsphinx. Pitfall of this is that then the quickstart.ipynb will not render...

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@clewis7
remove nbsphinx
0fc05dd
@kushalkolar

kushalkolar commented Jun 4, 2024

Copy link
Copy Markdown
Member

That's ok, specific examples are more important.

clewis7 reacted with thumbs up emoji
All reactions
  • 👍 1 reaction

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

clewis7 added 2 commits June 4, 2024 13:02
@clewis7
remove nbsphinx and quickstart.ipynb from docs
2856365
@clewis7
remove init files from examples
dacc382
@clewis7
clewis7 marked this pull request as ready for review June 4, 2024 18:01
@kushalkolar

kushalkolar commented Jun 5, 2024

Copy link
Copy Markdown
Member

This is great 😄 !

Some things:

Can you pre-download the images in conf.py so we dont get this:

image

Also need to figure out how to properly set the canvas size so that when the screenshots are taken we don't have that huge blank space.

Can you check how we can have animated examples, like pygfx: https://pygfx.com/stable/_gallery/introductory/cube.html#sphx-glr-gallery-introductory-cube-py

We can show some of the animations from quickstart, and I guess if you tag it with "test_examples = false" it will generate sphinx gallery docs with that example but not use it for the test suite? Since we don't want animation examples to run with screenshot tests (at least not yet, maybe later 😄 )

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

kushalkolar
kushalkolar requested changes Jun 5, 2024
View reviewed changes

@kushalkolar kushalkolar left a comment

Copy link
Copy Markdown
Member

There was a problem hiding this comment.

Choose a reason for hiding this comment

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

More:

For each example, specify that the if __name__ == "__main__" is NOT how it's supposed to be done for interactive use. We should make a doc page on interactive use in ipython and jupyter using this: https://wgpu-py.readthedocs.io/en/stable/gui.html#using-wgpu-interactively

Users should never call fpl.run() for interactive use.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

clewis7 reacted with thumbs up emoji
All reactions
  • 👍 1 reaction
Comment thread docs/source/conf.py Resolved

Uh oh!

There was an error while loading. Please reload this page.

Comment thread docs/source/conf.py Resolved

Uh oh!

There was an error while loading. Please reload this page.

Comment thread examples/desktop/gridplot/gridplot.py Outdated
fig[1, 0].add_image(data=im3)
fig[1, 1].add_image(data=im4)

# set canvas variable for sphinx_gallery to properly generate examples

@kushalkolar kushalkolar Jun 5, 2024

Copy link
Copy Markdown
Member

There was a problem hiding this comment.

Choose a reason for hiding this comment

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

specifiy that this line isn't required for users, or see if there's a way for the pygfx scraper to look for fig.canvas instead of canvas?

in all examples

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions

@clewis7 clewis7 Jun 5, 2024

Copy link
Copy Markdown
Member Author

There was a problem hiding this comment.

Choose a reason for hiding this comment

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

I think perhaps we can use figure instead...

pygfx scraper looks for one of ["renderer", "canvas"] to be defined, but will also look through proxy objects such as "figure", "display", "disp", "plot"

So I will try that

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions

@clewis7 clewis7 Jun 5, 2024

Copy link
Copy Markdown
Member Author

There was a problem hiding this comment.

Choose a reason for hiding this comment

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

I tried changing fig to figure so then the scraper would look for figure.canvas...but then writing the thumbnails failed

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions

@clewis7 clewis7 Jun 5, 2024

Copy link
Copy Markdown
Member Author

There was a problem hiding this comment.

Choose a reason for hiding this comment

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

I think for now, we should just to canvas = fig.canvas and have a note saying that it is not required for users and after FENS I can look into fixing them

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
Comment thread examples/desktop/heatmap/heatmap.py Resolved

Uh oh!

There was an error while loading. Please reload this page.

Comment thread examples/desktop/heatmap/heatmap_cmap.py Resolved

Uh oh!

There was an error while loading. Please reload this page.

Comment thread fastplotlib/layouts/_figure.py Resolved

Uh oh!

There was an error while loading. Please reload this page.

Comment thread setup.py Resolved

Uh oh!

There was an error while loading. Please reload this page.

@clewis7
update examples and conf.py
985eb2e
@clewis7
clewis7 marked this pull request as draft June 5, 2024 15:26
@clewis7

clewis7 commented Jun 5, 2024

Copy link
Copy Markdown
Member Author

NOTE:
sphinx-gallery doesn't have the namespace __file__, so in the scatter/ examples will need to change how the path to the iris.npy data is loaded so that gallery can be generated properly and tests will still run without using __file__ or os.getcwd()

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@clewis7
add animation examples, edit conf.py, fix scatter examples
79b6e7f
@clewis7

clewis7 commented Jun 5, 2024 •
edited
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown
Member Author

TODO:

  • fix canvas size so thumbnails/images don't have large white space
  • add more animation examples
All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@clewis7
add sklearn to docs, example needs it
9c447de
@clewis7
add more animation examples, add to tests
7efad6b
@kushalkolar

kushalkolar commented Jun 5, 2024

Copy link
Copy Markdown
Member

After this I propose:

  1. get rid of quickstart.ipynb, replace with a guide in the docs
  2. get rid of any example nbs that are in the examples gallery, except for the selector tools?
  3. what about moving all example nbs to the examples gallery and having just a few example nbs? Like ImageWidget, selector tools, and maybe one simple one that shows layouting with VBox/HBox and a few graphics?
All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@clewis7
add simple multigraphic gridplot example
16c712c
@clewis7

clewis7 commented Jun 5, 2024

Copy link
Copy Markdown
Member Author

After this I propose:

  1. get rid of quickstart.ipynb, replace with a guide in the docs
  2. get rid of any example nbs that are in the examples gallery, except for the selector tools?
  3. what about moving all example nbs to the examples gallery and having just a few example nbs? Like ImageWidget, selector tools, and maybe one simple one that shows layouting with VBox/HBox and a few graphics?

This sounds good to me, and doable before FENS

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@kushalkolar

kushalkolar commented Jun 5, 2024

Copy link
Copy Markdown
Member

A few event examples too, click event that changes colors of closest circle, and another example where changing a feature prints the event attributes and event.info.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

kushalkolar
kushalkolar reviewed Jun 5, 2024
View reviewed changes
Comment thread examples/desktop/gridplot/multigraphic_gridplot.py Resolved

Uh oh!

There was an error while loading. Please reload this page.

@clewis7
add simple event, fix multigraphic gridplot
98d5280
@clewis7

clewis7 commented Jun 6, 2024

Copy link
Copy Markdown
Member Author

I added a simple event example but I am going to hold off adding any more examples until we merge this with graphic features PR

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

clewis7 and others added 2 commits June 6, 2024 10:14
@clewis7
Update line3d_animation.py
ff3f429
@clewis7
add simple event example
1fba2c4
@clewis7 clewis7 mentioned this pull request Jun 7, 2024
TODO before FENS #512
Closed
9 tasks done
@clewis7 clewis7 mentioned this pull request Jun 16, 2024
Fpl demos flatironinstitute/ccn-software-fens-2024#11
Closed
5 tasks
@clewis7
resolve merge conflicts, change fig to figure for gallery
3ff1982
@clewis7

clewis7 commented Jun 17, 2024

Copy link
Copy Markdown
Member Author

@kushalkolar merged main and updated...should be ready for review :D

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@kushalkolar
kushalkolar marked this pull request as ready for review June 17, 2024 23:49
kushalkolar
kushalkolar requested changes Jun 18, 2024
View reviewed changes
Comment thread examples/desktop/gridplot/multigraphic_gridplot.py
figure.canvas.set_logical_size(700, 560)

# NOTE: `if __name__ == "__main__"` is NOT how to use fastplotlib interactively
# please see our docs for using fastplotlib interactively in ipython and jupyter

@kushalkolar kushalkolar Jun 17, 2024

Copy link
Copy Markdown
Member

There was a problem hiding this comment.

Choose a reason for hiding this comment

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

make a section, perhaps in the guide, on using fpl interactively in jupyter lab and ipython, the wgpu docs might provide some inspiration: https://wgpu-py.readthedocs.io/en/stable/gui.html#using-wgpu-interactively

but basically, there is %gui qt and in jupyterlab or ipython they can also do fig = fpl.Figure(canvas="glfw") to use glfw

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions

@clewis7 clewis7 Jun 18, 2024

Copy link
Copy Markdown
Member Author

There was a problem hiding this comment.

Choose a reason for hiding this comment

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

#510

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
Comment thread examples/desktop/screenshots/heatmap.png Resolved

Uh oh!

There was an error while loading. Please reload this page.

Comment thread fastplotlib/layouts/_figure.py Resolved

Uh oh!

There was an error while loading. Please reload this page.

Comment thread examples/desktop/scatter/scatter_iris.py Resolved

Uh oh!

There was an error while loading. Please reload this page.

Comment thread examples/desktop/scatter/scatter_dataslice.py Resolved

Uh oh!

There was an error while loading. Please reload this page.

Comment thread examples/desktop/misc/simple_event.py Resolved

Uh oh!

There was an error while loading. Please reload this page.

@kushalkolar

kushalkolar commented Jun 18, 2024

Copy link
Copy Markdown
Member

This example seems like it's missing from the gallery 🤔 https://github.com/fastplotlib/fastplotlib/blob/main/examples/desktop/line_collection/line_stack_3d.py

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@clewis7

clewis7 commented Jun 18, 2024

Copy link
Copy Markdown
Member Author

This example seems like it's missing from the gallery 🤔 https://github.com/fastplotlib/fastplotlib/blob/main/examples/desktop/line_collection/line_stack_3d.py

ahhh, wasn't rendering properly because of the canvas size

I found that the canvas size needs to be (700, 560)...sphinx-gallery likes that best

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

clewis7 added 4 commits June 18, 2024 10:31
@clewis7
minor changes
26d85e4
@clewis7
replace screenshots and fix small bug
ea298dc
@clewis7
fix scatter examples for CI build
950d4b4
@clewis7
fix screenshots
64aaca7
@clewis7

clewis7 commented Jun 18, 2024

Copy link
Copy Markdown
Member Author

yayyyy! @kushalkolar

kushalkolar and ivoflipse reacted with hooray emoji
All reactions
  • 🎉 2 reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

kushalkolar
kushalkolar reviewed Jun 18, 2024
View reviewed changes
Comment thread examples/desktop/misc/simple_event.py Resolved

Uh oh!

There was an error while loading. Please reload this page.

Comment thread examples/desktop/scatter/scatter_cmap_iris.py Resolved

Uh oh!

There was an error while loading. Please reload this page.

Comment thread examples/desktop/scatter/scatter_cmap_iris.py Resolved

Uh oh!

There was an error while loading. Please reload this page.

Comment thread examples/desktop/scatter/scatter_cmap_iris.py Resolved

Uh oh!

There was an error while loading. Please reload this page.

Comment thread examples/desktop/scatter/scatter_cmap_iris.py Resolved

Uh oh!

There was an error while loading. Please reload this page.

clewis7 and others added 3 commits June 18, 2024 16:18
@clewis7
add sklearn as docs dependency, include iris scatter examples in gallery
27c90aa
@clewis7 @kushalkolar
Update examples/desktop/misc/simple_event.py
ee2d8f1
Co-authored-by: Kushal Kolar <[email protected]>
@clewis7
update screenshots
0e199ea
kushalkolar
kushalkolar approved these changes Jun 18, 2024
View reviewed changes
@kushalkolar
kushalkolar merged commit bb0bb27 into main Jun 18, 2024
@kushalkolar
kushalkolar deleted the sphinx-gal branch June 18, 2024 20:48
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Reviewers

@BalzaniEdoardo BalzaniEdoardo BalzaniEdoardo left review comments
@kushalkolar kushalkolar kushalkolar approved these changes

Uh oh!

There was an error while loading. Please reload this page.

Assignees

No one assigned

Labels

None yet

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

Uh oh!

There was an error while loading. Please reload this page.

3 participants

@clewis7 @BalzaniEdoardo @kushalkolar
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
You are visitor 01402503 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.