Skip to content
This repository has been archived by the owner on Jun 14, 2024. It is now read-only.

Update Docstrings & Create Jupyter_book Directory in docs #25

Closed
wants to merge 57 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
57 commits
Select commit Hold shift + click to select a range
1d79bd8
edit the name of python-app.yml
Nov 13, 2023
0be46cd
add get_start.ipynb (from basic introduction)
Nov 13, 2023
fba0954
setup jupyter book
Nov 16, 2023
5304bfc
update to docsting for utils.py
Nov 20, 2023
db7dc43
change to numpy docstring for parametrized.py
Nov 20, 2023
d71221d
changes to numpy docstring
Nov 20, 2023
c218ad3
change to numpy docstings for sims
Nov 20, 2023
7c3905f
change to numpy docstring for data dir
Nov 20, 2023
d79e9f4
change to numpy doc string for base,py in lensors
Nov 20, 2023
cfca1ac
change to numpy docstring for files in lenses
Nov 20, 2023
19cc3c1
update epl.py
Nov 20, 2023
a5bb4d3
update sie.py
Nov 20, 2023
a84a799
update tnfw.py
Nov 20, 2023
be03b43
update pseudo_jaffe.py
Nov 20, 2023
2a501f3
update nfw.py
Nov 20, 2023
2397ad1
change to numpy docstring for pixelated.py
Nov 20, 2023
023b6af
modify the config.yml and toc.yml
Nov 21, 2023
ed3153e
modify ci.yml, _toc.yml
Nov 21, 2023
20cd4ed
update table of content
Nov 22, 2023
f3a6ee2
add basic table
Nov 22, 2023
c2a1f35
change the path of jupyter book
Nov 22, 2023
ac023ce
feat: Setup packaging and Github Codespaces dev environment (#26)
lsetiawan Nov 27, 2023
e60390b
build: remove dir sources (#27)
lsetiawan Nov 27, 2023
de64cb3
fix: Add project urls to empty slots
lsetiawan Nov 27, 2023
a230dd7
ci: update yaml configuration for CI (#28)
lsetiawan Nov 27, 2023
68d5248
add get_start.ipynb (from basic introduction)
Nov 13, 2023
62e3036
setup jupyter book
Nov 16, 2023
195b841
update to docsting for utils.py
Nov 20, 2023
c277258
change to numpy docstring for parametrized.py
Nov 20, 2023
a0cee3b
changes to numpy docstring
Nov 20, 2023
a5bc43a
change to numpy docstings for sims
Nov 20, 2023
694c1f4
change to numpy docstring for data dir
Nov 20, 2023
7a308db
change to numpy doc string for base,py in lensors
Nov 20, 2023
5605553
change to numpy docstring for files in lenses
Nov 20, 2023
65fb9aa
update epl.py
Nov 20, 2023
eb9a697
update sie.py
Nov 20, 2023
06557cb
update tnfw.py
Nov 20, 2023
d00b9dd
update pseudo_jaffe.py
Nov 20, 2023
087ce12
update nfw.py
Nov 20, 2023
2e1e655
change to numpy docstring for pixelated.py
Nov 20, 2023
02c5231
modify the config.yml and toc.yml
Nov 21, 2023
2d578a3
modify ci.yml, _toc.yml
Nov 21, 2023
411226d
update table of content
Nov 22, 2023
45faef8
add basic table
Nov 22, 2023
6c9f90b
change the path of jupyter book
Nov 22, 2023
5c70383
style: pre-commit fixes
pre-commit-ci[bot] Nov 28, 2023
50a25dc
fix: Fix some leftover merge conflicts
lsetiawan Nov 28, 2023
c961662
style: pre-commit fixes
pre-commit-ci[bot] Nov 28, 2023
4bfd736
create a book directory
Nov 28, 2023
5decf61
Merge branch 'sophie-test
Nov 28, 2023
15aae0c
style: pre-commit fixes
pre-commit-ci[bot] Nov 28, 2023
526432d
delete origin book
Nov 28, 2023
edc5068
fix: Cleanup HEAD merge conflicts
lsetiawan Nov 29, 2023
239a94c
edit book
Nov 29, 2023
25a9e46
Merge branch 'sophie-test' of https://github.com/sophietao127/caustic…
Nov 29, 2023
5a61a74
change tutorials
Nov 29, 2023
ece705d
add pre_build
Dec 5, 2023
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions .devcontainer/apt.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
git
ncdu
wget
curl
21 changes: 21 additions & 0 deletions .devcontainer/devcontainer.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
// For format details, see https://aka.ms/devcontainer.json. For config options, see the
{
"image": "quay.io/pangeo/pytorch-notebook:latest",

"customizations": {
"vscode": {
"extensions": [
"ms-toolsai.jupyter",
"ms-python.python",
"ms-vsliveshare.vsliveshare",
"DavidAnson.vscode-markdownlint",
"GitHub.copilot"
]
}
},
"postCreateCommand": "sh .devcontainer/postBuild.sh",
"features": {
"ghcr.io/devcontainers-contrib/features/black:2": {},
"ghcr.io/devcontainers-contrib/features/pylint:2": {}
}
}
15 changes: 15 additions & 0 deletions .devcontainer/environment.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
channels:
- conda-forge
dependencies:
- python>=3.10
- astropy
- jupyterlab
- matplotlib
- numpy
- pandas
- scipy
- h5py
- sphinx
- myst-parser
- jupyter-book
- pip
4 changes: 4 additions & 0 deletions .devcontainer/postBuild.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
# For writing commands that will be executed after the container is created

# Installs `caustic` as local library without resolving dependencies (--no-deps)
python3 -m pip install -e /workspaces/caustics --no-deps
12 changes: 12 additions & 0 deletions .devcontainer/start
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
#!/bin/bash -l

# ==== ONLY EDIT WITHIN THIS BLOCK =====

export CAUSTICS_ENV="caustics"
if ! [[ -z "${CAUSTICS_SCRATCH_PREFIX}" ]] && ! [[ -z "${JUPYTERHUB_USER}" ]]; then
export CAUSTICS_SCRATCH="${CAUSTICS_SCRATCH_PREFIX}/${JUPYTERHUB_USER}/"
fi

# ==== ONLY EDIT WITHIN THIS BLOCK =====

exec "$@"
4 changes: 4 additions & 0 deletions .git_archival.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
node: $Format:%H$
node-date: $Format:%cI$
describe-name: $Format:%(describe:tags=true,match=*[0-9]*)$
ref-names: $Format:%D$
1 change: 1 addition & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
.git_archival.txt export-subst
101 changes: 101 additions & 0 deletions .github/CONTRIBUTING.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,101 @@
See the [Scientific Python Developer Guide][spc-dev-intro] for a detailed
description of best practices for developing scientific packages.

[spc-dev-intro]: https://scientific-python-cookie.readthedocs.io/guide/intro

# Quick development

The fastest way to start with development is to use nox. If you don't have nox,
you can use `pipx run nox` to run it without installing, or `pipx install nox`.
If you don't have pipx (pip for applications), then you can install with with
`pip install pipx` (the only case were installing an application with regular
pip is reasonable). If you use macOS, then pipx and nox are both in brew, use
`brew install pipx nox`.

To use, run `nox`. This will lint and test using every installed version of
Python on your system, skipping ones that are not installed. You can also run
specific jobs:

```console
$ nox -s lint # Lint only
$ nox -s tests # Python tests
$ nox -s docs -- serve # Build and serve the docs
$ nox -s build # Make an SDist and wheel
```

Nox handles everything for you, including setting up an temporary virtual
environment for each run.

# Setting up a development environment manually

You can set up a development environment by running:

```bash
python3 -m venv .venv
source ./.venv/bin/activate
pip install -v -e .[dev]
```

If you have the
[Python Launcher for Unix](https://github.com/brettcannon/python-launcher), you
can instead do:

```bash
py -m venv .venv
py -m install -v -e .[dev]
```

# Post setup

You should prepare pre-commit, which will help you by checking that commits pass
required checks:

```bash
pip install pre-commit # or brew install pre-commit on macOS
pre-commit install # Will install a pre-commit hook into the git repo
```

You can also/alternatively run `pre-commit run` (changes only) or
`pre-commit run --all-files` to check even without installing the hook.

# Testing

Use pytest to run the unit checks:

```bash
pytest
```

# Coverage

Use pytest-cov to generate coverage reports:

```bash
pytest --cov=caustics
```

# Building docs

You can build the docs using:

```bash
nox -s docs
```

You can see a preview with:

```bash
nox -s docs -- serve
```

# Pre-commit

This project uses pre-commit for all style checking. While you can run it with
nox, this is such an important tool that it deserves to be installed on its own.
Install pre-commit and run:

```bash
pre-commit run -a
```

to check all files.
7 changes: 7 additions & 0 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
version: 2
updates:
# Maintain dependencies for GitHub Actions
- package-ecosystem: "github-actions"
directory: "/"
schedule:
interval: "weekly"
32 changes: 32 additions & 0 deletions .github/matchers/pylint.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
{
"problemMatcher": [
{
"severity": "warning",
"pattern": [
{
"regexp": "^([^:]+):(\\d+):(\\d+): ([A-DF-Z]\\d+): \\033\\[[\\d;]+m([^\\033]+).*$",
"file": 1,
"line": 2,
"column": 3,
"code": 4,
"message": 5
}
],
"owner": "pylint-warning"
},
{
"severity": "error",
"pattern": [
{
"regexp": "^([^:]+):(\\d+):(\\d+): (E\\d+): \\033\\[[\\d;]+m([^\\033]+).*$",
"file": 1,
"line": 2,
"column": 3,
"code": 4,
"message": 5
}
],
"owner": "pylint-error"
}
]
}
99 changes: 99 additions & 0 deletions .github/workflows/cd.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,99 @@
name: CD

on:
workflow_dispatch:
push:
branches:
- main
- dev
release:
types:
- published

concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true

env:
FORCE_COLOR: 3

jobs:
dist:
name: Distribution build
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0

- name: Build sdist and wheel
run: pipx run build

- uses: actions/upload-artifact@v3
with:
path: dist

- name: Check products
run: pipx run twine check dist/*

test-built-dist:
needs: [dist]
name: Test built distribution
runs-on: ubuntu-latest
permissions:
id-token: write
steps:
- uses: actions/[email protected]
name: Install Python
with:
python-version: "3.10"
- uses: actions/download-artifact@v3
with:
name: artifact
path: dist
- name: List contents of built dist
run: |
ls -ltrh
ls -ltrh dist
- name: Publish to Test PyPI
uses: pypa/[email protected]
with:
repository-url: https://test.pypi.org/legacy/
verbose: true
skip-existing: true
- name: Check pypi packages
run: |
sleep 3
python -m pip install --upgrade pip

echo "=== Testing wheel file ==="
# Install wheel to get dependencies and check import
python -m pip install --extra-index-url https://test.pypi.org/simple --upgrade --pre caustic
python -c "import caustic; print(caustics.__version__)"
echo "=== Done testing wheel file ==="

echo "=== Testing source tar file ==="
# Install tar gz and check import
python -m pip uninstall --yes caustic
python -m pip install --extra-index-url https://test.pypi.org/simple --upgrade --pre --no-binary=:all: caustic
python -c "import caustic; print(caustics.__version__)"
echo "=== Done testing source tar file ==="

publish:
needs: [dist, test-built-dist]
name: Publish to PyPI
environment: pypi
permissions:
id-token: write
runs-on: ubuntu-latest
if: github.event_name == 'release' && github.event.action == 'published'

steps:
- uses: actions/download-artifact@v3
with:
name: artifact
path: dist

- uses: pypa/[email protected]
if: startsWith(github.ref, 'refs/tags')
74 changes: 74 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
# This workflow will install Python dependencies, run tests and lint with a single version of Python
# For more information see: https://docs.github.com/en/actions/automating-builds-and-tests/building-and-testing-python

name: CI

on:
workflow_dispatch:
pull_request:
push:
branches:
- main
- dev

concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true

env:
FORCE_COLOR: 3
PROJECT_NAME: "caustics"

jobs:
build:
runs-on: ${{matrix.os}}
strategy:
fail-fast: false
matrix:
python-version: ["3.9", "3.10", "3.11"]
os: [ubuntu-latest, windows-latest, macOS-latest]

steps:
- name: Checkout caustics
uses: actions/checkout@v3
with:
fetch-depth: 0

- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v4
with:
python-version: ${{ matrix.python-version }}
allow-prereleases: true

- name: Record State
run: |
pwd
echo github.ref is: ${{ github.ref }}
echo GITHUB_SHA is: $GITHUB_SHA
echo github.event_name is: ${{ github.event_name }}
echo github workspace: ${{ github.workspace }}
pip --version

- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install pytest pytest-cov torch wheel

# We only want to install this on one run, because otherwise we'll have
# duplicate annotations.
- name: Install error reporter
if: ${{ matrix.python-version == '3.10' }}
run: |
python -m pip install pytest-github-actions-annotate-failures

- name: Install Caustics
run: |
pip install -e ".[dev]"
pip show ${{ env.PROJECT_NAME }}

- name: Test with pytest
run: |
pytest -vvv --cov=${{ env.PROJECT_NAME }} --cov-report=xml --cov-report=term tests/

- name: Upload coverage reports to Codecov with GitHub Action
uses: codecov/codecov-action@v3
Loading