Giter VIP home page Giter VIP logo

pyscript_test's Introduction

My Pyscript playground

What does work here

Pandas dataframe input and display

  • In October 2022 (& later updated bokeh and panel tabulator use in early 2024) I added examples using Pandas' read_csv() to get and render dataframes (also using panel for rendering) based on updated pyscript using py-config now. See pandastest.html (working on web here) and csv_read_display_df_with_panel.html (working on web here; stylistically it is most like the rendering of a Pandas dataframe in Jupyter) and csv_read_test.html (working on web here) and csv_read_from_same_location.html (working on web here). In March 2024, I added a very streamlined version to demonstrate getting the CSV file using the [files] key use as described here and here. code. Demo link. I also added a streamlined version using the [[fetch]] feature that removes the need to rely on open_url directly and adds the from key to specify location for fetching, see here. That is csv_Mar_2024_fetch_test.html (working on web here). These two approaches, with [files] and [[fetch]], (with the [files] method currently favored going forward) are meant to supercede the open_url method, which is illustated in the April 2023 streamlined demonstration getting the CSV file that uses open_url (which curiously the current demos still seem to use), see csv_apr_2023_test.html (working on web here). For a dataframe being printed to a terminal as well as on the page, see below under 'REPL executing code / and Terminals'.

  • I added the CSV retrieval example based on [files] key use as described here and here and here. code . Demo link. The ones in the current (July 2024) OFFICIAL EXAMPLES (example here) don't seem to use this and still use the older open_url approach, despite what was said here in May 2023 about [[fetch]] that pre-dates [files].

Matplotlib plot examples

  • In April 2023, I added Matplotlib example from https://pyscript.net/examples/matplotlib.html in start of effort to update plots to current ways. See matplotlib.html) (working on web here). This was updated in June 2024 to add more current ways, based on the current example now here, adapted to be single-page, and this includes a ...loading screen that I left off many (all?) of my updates earlier this year in 2024 so far, see the section 'Pandas dataframe input and display'.
  • Based on the April 2023 update of the Matplotlib and the old version, I updated the plot_example.html (working on web here with specifically the '23 version) and then updated to 2024 approaches, too (working on web here.
  • Based on the April 2023 update of the Matplotlib and my reply to a Stackoverflow post, I added another matplotlib example, another_plot_example.html (working on web here with specifically the '23 version) and then updated to 2024 approaches, too (working on web here.

Markdown cells from notebook do work.

  • Example with only markdown cells in a notebook based on the example of Eduardo Bonet

    see here to see proof using Eduoardo Bonet's approach at least for now it renders markdown from notebooks just fine (I had to remove the pyscript stuff because something was causing it to error out and not show markdown.)

REPL executing code / and Terminals


Related

If you like Pyscript, you may also be interested in Py.cafe.
My Py.cafe gallery.


What sort of works here

  • Code in Eduoardo's example notebook runs to generate a plot

eduardo_sample_example.html works to show plot being made from the code when you click the green arrow. However, it is supposed to also be showing markdown from the notebook being rendered and that is why same example is also udner 'What doesn't work here' (Note: it looks like the posted example though and so Eduardo Bonet who posted this example was also not seeing markdown rendered even though he tried to have the javascript handle that.). Eduoardo Bonet's approach.
Demonstrates numpy and matplotlib directly in a browser from static site.

  • Plotly example makes a plot using Plotly graph objects

Based on update that doesn't allow print(), see here, and my reply to a Stackoverflow post. The line plot, actually scatter, using Plotly graph objects works and displays but nothing happens if you click on it, which was what the OP at Stackoverflow was seeking. OP was using Plotly Express which I' not sure even works with Plotly's .on_click() method.


What doesn't work here

  • 'open_cv_demo.html' Got stuck on getting an image from URL so that I could use openCV / CV2 to manipulate it. This was starting point of an attempt to extend what I was able to do with Pyodide in JupyterLite to pyscript, see here. (This may have helped but I didn't note consulting it in code and near the end I thought I was using some of it but still no luck.) I got stuck on trying to read in the image from URL. I need to locate an example that is current and working.
    I think once I got image read in I could pass the contents to numpy as an array and then cv2 can use it. I'll keep my eyes open for a modern example.
    See the history for the many things I tried.

  • Full example notebook of Eduardo Bonet with both code and markdown

eduardo_sample_example.html works to show plot being made from the code when you click the green arrow. However, it is supposed to also be showing markdown from the notebook being rendered. It displays and works like from his site though!! Go see it at https://eduardobonet.gitlab.io/nblite And so it isn't particular to GitHub and means he was seeing it have issues though. (By stripping out the pyscript stuff, I got the same approach to render markdown, see section 'Markdown cells from notebook do work.' and so it wasn't like it totally wasn't working. And in fact when it was failing to make markdown render fully, I'd see it render the markdown for an instant on hard refresh. And so this is probably a minor hurdle for those that know what they are doing and will get worked out soon. Note sometimes quickly entering inspection mode when trying to see what is messing up markdown rendering I'd note is showing inIt's showing in the 'Inspect' console that it is out of memory, specifically gives "WebAssembly module validated with warning: failed to allocate executable memory for module". But that didn't really seem to stop it from running the code other times when I gave it time.

pyscript_test's People

Contributors

fomightez avatar

Stargazers

Roman avatar

Watchers

James Cloos avatar  avatar

Forkers

svein-tore

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.