Unverified Commit 68d3a5ff authored by Akke Viitanen's avatar Akke Viitanen
Browse files

add an example notebook

parent 64018491
Loading
Loading
Loading
Loading
+2 −1
Original line number Diff line number Diff line
@@ -97,7 +97,8 @@ repos:
            "-d", # Flag for cached environment and doctrees
            "./docs/_build/doctrees", # Directory
            "-D", # Flag to override settings in conf.py
            "exclude_patterns=notebooks/*,_build", # Exclude notebooks and build dir from pre-commit
            #"exclude_patterns=notebooks/*,_build", # Exclude notebooks and build dir from pre-commit
            "exclude_patterns=_build", # Exclude notebooks and build dir from pre-commit
          ]
    # Run unit tests, verify that they pass. Note that coverage is run against
    # the ./src directory here because that is what will be committed. In the
+5 −5
Original line number Diff line number Diff line
@@ -9,14 +9,14 @@ Welcome to lsst_inaf_agile's documentation!
Dev Guide - Getting Started
---------------------------

Before installing any dependencies or writing code, it's a great idea to create a
virtual environment. LINCC-Frameworks engineers primarily use `conda` to manage virtual
environments. If you have conda installed locally, you can run the following to
create and activate a new environment.
Before installing any dependencies or writing code, it's a great idea to create
a virtual environment. LINCC-Frameworks engineers primarily use `conda` to
manage virtual environments. If you have conda installed locally, you can run
the following to create and activate a new environment.

.. code-block:: console

   >> conda create env -n <env_name> python=3.11
   >> conda create env -n <env_name> python=3.12
   >> conda activate <env_name>


+1 −2
Original line number Diff line number Diff line
@@ -2,5 +2,4 @@ Notebooks
========================================================================================

.. toctree::

    Introducing Jupyter Notebooks <notebooks/intro_notebook>
    Example truth catalog generation <notebooks/create_truth_catalog>
+0 −42
Original line number Diff line number Diff line
%% Cell type:markdown id:textblock1 tags:

# Introducing Jupyter Notebooks in Sphinx

This notebook showcases very basic functionality of rendering your jupyter notebooks as tutorials inside your sphinx documentation.

As part of the LINCC Frameworks python project template, your notebooks will be executed AND rendered at document build time.

You can read more about Sphinx, ReadTheDocs, and building notebooks in [LINCC's documentation](https://lincc-ppt.readthedocs.io/en/latest/practices/sphinx.html)

%% Cell type:code id:codeblock1 tags:

``` python
def sierpinsky(order):
    """Define a method that will create a Sierpinsky triangle of given order,
    and will print it out."""
    triangles = ["*"]
    for i in range(order):
        spaces = " " * (2**i)
        triangles = [spaces + triangle + spaces for triangle in triangles] + [
            triangle + " " + triangle for triangle in triangles
        ]
    print(f"Printing order {order} triangle")
    print("\n".join(triangles))
```

%% Cell type:markdown id:textblock2 tags:

Then, call our method a few times. This will happen on the fly during notebook rendering.

%% Cell type:code id:codeblock2 tags:

``` python
for order in range(3):
    sierpinsky(order)
```

%% Cell type:code id:codeblock3 tags:

``` python
sierpinsky(4)
```
+0 −2
Original line number Diff line number Diff line
@@ -77,9 +77,7 @@ class Egg:
        if not overwrite and os.path.exists(filename):
            logger.info("Not overwriting existing file...")
            return 0

        util.create_directory(filename)

        return os.system(cmd)

    def get_sed(self, i):