Skip to content

Commit

Permalink
Try Jupylite.
Browse files Browse the repository at this point in the history
  • Loading branch information
vnmabus committed Oct 18, 2023
1 parent 92339e7 commit 833356e
Show file tree
Hide file tree
Showing 20 changed files with 423 additions and 0 deletions.
Binary file added docs/auto_examples/auto_examples_jupyter.zip
Binary file not shown.
Binary file added docs/auto_examples/auto_examples_python.zip
Binary file not shown.
3 changes: 3 additions & 0 deletions docs/auto_examples/images/jupyterlite_badge_logo.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
60 changes: 60 additions & 0 deletions docs/auto_examples/index.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
:orphan:

Examples
========

Examples of the package functionality.



.. raw:: html

<div class="sphx-glr-thumbnails">


.. raw:: html

<div class="sphx-glr-thumbcontainer" tooltip="Shows how to load R packages.">

.. only:: html

.. image:: /auto_examples/images/thumb/sphx_glr_plot_example_thumb.png
:alt:

:ref:`sphx_glr_auto_examples_plot_example.py`

.. raw:: html

<div class="sphx-glr-thumbnail-title">R data loading</div>
</div>


.. raw:: html

</div>


.. toctree::
:hidden:

/auto_examples/plot_example


.. only:: html

.. container:: sphx-glr-footer sphx-glr-footer-gallery

.. container:: sphx-glr-download sphx-glr-download-python

:download:`Download all examples in Python source code: auto_examples_python.zip </auto_examples/auto_examples_python.zip>`

.. container:: sphx-glr-download sphx-glr-download-jupyter

:download:`Download all examples in Jupyter notebooks: auto_examples_jupyter.zip </auto_examples/auto_examples_jupyter.zip>`


.. only:: html

.. rst-class:: sphx-glr-signature

`Gallery generated by Sphinx-Gallery <https://sphinx-gallery.github.io>`_
72 changes: 72 additions & 0 deletions docs/auto_examples/plot_example.ipynb
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
{
"cells": [
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"collapsed": false
},
"outputs": [],
"source": [
"# %%\n# If we are in a Pyodide kernel, we need to install the packages first.\n#\n\n%pip install lzma\n%pip install rdata\n%pip install ipywidgets"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"\n# R data loading\n\nShows how to load R packages.\n"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"collapsed": false
},
"outputs": [],
"source": [
"# Author: Carlos Ramos Carre\u00f1o\n# License: MIT"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"Use the file uploader to convert files to Python.\n\n\n"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"collapsed": false
},
"outputs": [],
"source": [
"import rdata\nfrom ipywidgets import FileUpload, interact\n\n@interact(files=FileUpload(accept=\"*.rd*\", multiple=True))\ndef convert_from_file(files):\n for f in files:\n parsed = rdata.parser.parse_data(f.content)\n converted = rdata.conversion.convert(parsed)\n for key, value in converted.items():\n print(f\"{key}:\")\n print(value)"
]
}
],
"metadata": {
"kernelspec": {
"display_name": "Python 3",
"language": "python",
"name": "python3"
},
"language_info": {
"codemirror_mode": {
"name": "ipython",
"version": 3
},
"file_extension": ".py",
"mimetype": "text/x-python",
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.11.5"
}
},
"nbformat": 4,
"nbformat_minor": 0
}
25 changes: 25 additions & 0 deletions docs/auto_examples/plot_example.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
# fmt: off
"""
R data loading
==============
Shows how to load R packages.
"""

# Author: Carlos Ramos Carreño
# License: MIT

# %%
# Use the file uploader to convert files to Python.
#
import rdata
from ipywidgets import FileUpload, interact

@interact(files=FileUpload(accept="*.rd*", multiple=True))
def convert_from_file(files):
for f in files:
parsed = rdata.parser.parse_data(f.content)
converted = rdata.conversion.convert(parsed)
for key, value in converted.items():
print(f"{key}:")
print(value)
1 change: 1 addition & 0 deletions docs/auto_examples/plot_example.py.md5
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
a1050de4f5519fc0d67bed3e8c4b53ae
109 changes: 109 additions & 0 deletions docs/auto_examples/plot_example.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,109 @@

.. DO NOT EDIT.
.. THIS FILE WAS AUTOMATICALLY GENERATED BY SPHINX-GALLERY.
.. TO MAKE CHANGES, EDIT THE SOURCE PYTHON FILE:
.. "auto_examples/plot_example.py"
.. LINE NUMBERS ARE GIVEN BELOW.
.. only:: html

.. note::
:class: sphx-glr-download-link-note

:ref:`Go to the end <sphx_glr_download_auto_examples_plot_example.py>`
to download the full example code or to run this example in your browser via JupyterLite

.. rst-class:: sphx-glr-example-title

.. _sphx_glr_auto_examples_plot_example.py:


R data loading
==============

Shows how to load R packages.

.. GENERATED FROM PYTHON SOURCE LINES 8-12
.. code-block:: default
# Author: Carlos Ramos Carreño
# License: MIT
.. GENERATED FROM PYTHON SOURCE LINES 13-15
Use the file uploader to convert files to Python.


.. GENERATED FROM PYTHON SOURCE LINES 15-26
.. code-block:: default
import rdata
from ipywidgets import FileUpload, interact
@interact(files=FileUpload(accept="*.rd*", multiple=True))
def convert_from_file(files):
for f in files:
parsed = rdata.parser.parse_data(f.content)
converted = rdata.conversion.convert(parsed)
for key, value in converted.items():
print(f"{key}:")
print(value)
.. rst-class:: sphx-glr-script-out

.. code-block:: none
interactive(children=(FileUpload(value=(), accept='*.rd*', description='Upload', multiple=True), Output()), _dom_classes=('widget-interact',))





.. rst-class:: sphx-glr-timing

**Total running time of the script:** (0 minutes 0.622 seconds)


.. _sphx_glr_download_auto_examples_plot_example.py:

.. only:: html

.. container:: sphx-glr-footer sphx-glr-footer-example




.. container:: lite-badge

.. image:: images/jupyterlite_badge_logo.svg
:target: ../lite/lab/?path=auto_examples/plot_example.ipynb
:alt: Launch JupyterLite
:width: 150 px

.. container:: sphx-glr-download sphx-glr-download-python

:download:`Download Python source code: plot_example.py <plot_example.py>`

.. container:: sphx-glr-download sphx-glr-download-jupyter

:download:`Download Jupyter notebook: plot_example.ipynb <plot_example.ipynb>`


.. only:: html

.. rst-class:: sphx-glr-signature

`Gallery generated by Sphinx-Gallery <https://sphinx-gallery.github.io>`_
Expand Down
Binary file added docs/auto_examples/plot_example_codeobj.pickle
Binary file not shown.
Binary file added docs/auto_examples/searchindex.dat
Binary file not shown.
3 changes: 3 additions & 0 deletions docs/auto_examples/searchindex.dir
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
'/home/carlos/git/rdata/docs/_build/html/index.html', (0, 21128)
'/home/carlos/git/rdata/docs/_build/html/_static/documentation_options.js', (21504, 343)
'/home/carlos/git/rdata/docs/_build/html/searchindex.js', (22016, 9119)
13 changes: 13 additions & 0 deletions docs/auto_examples/sg_execution_times.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@

:orphan:

.. _sphx_glr_auto_examples_sg_execution_times:


Computation times
=================
**00:00.622** total execution time for **auto_examples** files:

+---------------------------------------------------------------------+-----------+--------+
| :ref:`sphx_glr_auto_examples_plot_example.py` (``plot_example.py``) | 00:00.622 | 0.0 MB |
+---------------------------------------------------------------------+-----------+--------+
31 changes: 31 additions & 0 deletions docs/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,11 @@
#
import os
import sys
import warnings

import pkg_resources
import rdata
import textwrap

# General information about the project.
project = "rdata"
Expand Down Expand Up @@ -64,13 +66,15 @@
# extensions coming with Sphinx (named 'sphinx.ext.*') or your custom
# ones.
extensions = [
"jupyterlite_sphinx",
"sphinx.ext.autodoc",
"sphinx.ext.autosummary",
"sphinx.ext.intersphinx",
"sphinx.ext.mathjax",
"sphinx.ext.napoleon",
"sphinx.ext.todo",
"sphinx.ext.viewcode",
"sphinx_gallery.gen_gallery",
]

# Add any paths that contain templates here, relative to this directory.
Expand Down Expand Up @@ -129,6 +133,9 @@
"type": "url",
},
],
"logo": {
"text": "🗃 rdata",
},
}

html_context = {
Expand Down Expand Up @@ -223,3 +230,27 @@
# -- Options for "sphinx.ext.todo" --

todo_include_todos = True


# -- Options for "sphinx_gallery.gen_gallery" --

sphinx_gallery_conf = {
"examples_dirs": ["../examples"],
"gallery_dirs": ["auto_examples"],
"reference_url": {
"rdata": None,
},
"doc_module": "rdata",
"jupyterlite": {
"use_jupyter_lab": True,
},
"first_notebook_cell": textwrap.dedent("""\
# %%
# If we are in a Pyodide kernel, we need to install the packages first.
#
%pip install lzma
%pip install rdata
%pip install ipywidgets
"""),
}
1 change: 1 addition & 0 deletions docs/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ Open :code:`.rda` R data files containing datasets and convert them to the appro
installation
simpleusage
apilist
Try online! <https://rdata.readthedocs.io/en/latest/lite/lab/?path=auto_examples/plot_example.ipynb>

rdata is developed `on Github <http://github.com/vnmabus/rdata>`_. Please
report `issues <https://github.com/vnmabus/rdata/issues>`_ there as well.
Expand Down
Loading

0 comments on commit 833356e

Please sign in to comment.