diff --git a/.cruft.json b/.cruft.json new file mode 100644 index 0000000..797351b --- /dev/null +++ b/.cruft.json @@ -0,0 +1,21 @@ +{ + "template": "https://github.com/ianhi/pyrepo-cookiecutter", + "commit": "91e48fd8a99de0221b538be1781630e323d38f87", + "checkout": null, + "context": { + "cookiecutter": { + "full_name": "Ian Hunt-Isaak", + "email": "ianhuntisaak@gmail.com", + "github_username": "ianhi", + "project_name": "raman-analysis", + "project_slug": "raman_analysis", + "project_short_description": "Analysis of raman spectra", + "pypi_username": "ianhi", + "_copy_without_render": [ + ".github/workflows/*" + ], + "_template": "https://github.com/ianhi/pyrepo-cookiecutter" + } + }, + "directory": null +} diff --git a/.github/ISSUE_TEMPLATE.md b/.github/ISSUE_TEMPLATE.md new file mode 100644 index 0000000..184d8a2 --- /dev/null +++ b/.github/ISSUE_TEMPLATE.md @@ -0,0 +1,15 @@ +* raman-analysis version: +* Python version: +* Operating System: + +### Description + +Describe what you were trying to get done. +Tell us what happened, what went wrong, and what you expected to happen. + +### What I Did + +``` +Paste the command(s) you ran and the output. +If there was a crash, please include the traceback here. +``` diff --git a/.github/TEST_FAIL_TEMPLATE.md b/.github/TEST_FAIL_TEMPLATE.md new file mode 100644 index 0000000..3512972 --- /dev/null +++ b/.github/TEST_FAIL_TEMPLATE.md @@ -0,0 +1,12 @@ +--- +title: "{{ env.TITLE }}" +labels: [bug] +--- +The {{ workflow }} workflow failed on {{ date | date("YYYY-MM-DD HH:mm") }} UTC + +The most recent failing test was on {{ env.PLATFORM }} py{{ env.PYTHON }} +with commit: {{ sha }} + +Full run: https://github.com/{{ repo }}/actions/runs/{{ env.RUN_ID }} + +(This post will be updated if another test fails, as long as this issue remains open.) diff --git a/.github/dependabot.yml b/.github/dependabot.yml new file mode 100644 index 0000000..96505a9 --- /dev/null +++ b/.github/dependabot.yml @@ -0,0 +1,10 @@ +# https://docs.github.com/github/administering-a-repository/configuration-options-for-dependency-updates + +version: 2 +updates: + - package-ecosystem: "github-actions" + directory: "/" + schedule: + interval: "weekly" + commit-message: + prefix: "ci(dependabot):" diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml new file mode 100644 index 0000000..cdd6baf --- /dev/null +++ b/.github/workflows/ci.yml @@ -0,0 +1,108 @@ +name: CI + +on: + push: + branches: + - main + tags: + - "v*" + pull_request: {} + workflow_dispatch: + +jobs: + check-manifest: + name: Check Manifest + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v3 + - uses: actions/setup-python@v4 + with: + python-version: "3.x" + - run: pip install check-manifest && check-manifest + + test: + name: ${{ matrix.platform }} (${{ matrix.python-version }}) + runs-on: ${{ matrix.platform }} + strategy: + fail-fast: false + matrix: + python-version: ['3.8', '3.9', '3.10'] + platform: [ubuntu-latest, macos-latest, windows-latest] + + steps: + - name: Cancel Previous Runs + uses: styfle/cancel-workflow-action@0.9.1 + with: + access_token: ${{ github.token }} + + - uses: actions/checkout@v3 + + - name: Set up Python ${{ matrix.python-version }} + uses: actions/setup-python@v4 + with: + python-version: ${{ matrix.python-version }} + cache: 'pip' + + - name: Install dependencies + run: | + python -m pip install -U pip + python -m pip install tox tox-gh-actions + + - name: Test with tox + run: python -m tox + env: + PLATFORM: ${{ matrix.platform }} + + - name: Coverage + uses: codecov/codecov-action@v2 + + deploy: + name: Deploy + needs: test + if: "success() && startsWith(github.ref, 'refs/tags/')" + runs-on: ubuntu-latest + + steps: + - uses: actions/checkout@v3 + + - name: Set up Python + uses: actions/setup-python@v4 + with: + python-version: "3.x" + + - name: install + run: | + git tag + pip install -U pip + pip install -U build twine + python -m build + twine check dist/* + ls -lh dist + + - name: Build and publish + run: twine upload dist/* + env: + TWINE_USERNAME: __token__ + TWINE_PASSWORD: ${{ secrets.TWINE_API_KEY }} + + - uses: softprops/action-gh-release@v1 + with: + generate_release_notes: true + + # [WIP] + # https://python-semantic-release.readthedocs.io/en/latest/automatic-releases/github-actions.html + # release: + # runs-on: ubuntu-latest + # concurrency: release + + # steps: + # - uses: actions/checkout@v3 + # with: + # fetch-depth: 0 + + # - name: Python Semantic Release + # uses: relekang/python-semantic-release@master + # with: + # github_token: ${{ secrets.GITHUB_TOKEN }} + # repository_username: __token__ + # repository_password: ${{ secrets.TWINE_API_KEY }} diff --git a/.github/workflows/cron.yml b/.github/workflows/cron.yml new file mode 100644 index 0000000..773fb4c --- /dev/null +++ b/.github/workflows/cron.yml @@ -0,0 +1,52 @@ +name: --pre Test +# An "early warning" cron job that will install dependencies +# with `pip install --pre` periodically to test for breakage +# (and open an issue if a test fails) + +on: + schedule: + - cron: '0 */12 * * *' # every 12 hours + workflow_dispatch: + +jobs: + + test: + name: ${{ matrix.platform }} (${{ matrix.python-version }}) + runs-on: ${{ matrix.platform }} + strategy: + fail-fast: false + matrix: + python-version: ['3.8', '3.9', '3.10'] + platform: [ubuntu-latest, macos-latest, windows-latest] + + steps: + - uses: actions/checkout@v3 + + - name: Set up Python ${{ matrix.python-version }} + uses: actions/setup-python@v4 + with: + python-version: ${{ matrix.python-version }} + + - name: Install dependencies + run: | + python -m pip install -U pip + python -m pip install tox tox-gh-actions + + - name: Test with tox + run: python -m tox -v --pre + env: + PLATFORM: ${{ matrix.platform }} + + # If something goes wrong, we can open an issue in the repo + - name: Report Failures + if: ${{ failure() }} + uses: JasonEtco/create-an-issue@v2 + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + PLATFORM: ${{ matrix.platform }} + PYTHON: ${{ matrix.python }} + RUN_ID: ${{ github.run_id }} + TITLE: '[test-bot] pip install --pre is failing' + with: + filename: .github/TEST_FAIL_TEMPLATE.md + update_existing: true diff --git a/.github_changelog_generator b/.github_changelog_generator new file mode 100644 index 0000000..d7e42ae --- /dev/null +++ b/.github_changelog_generator @@ -0,0 +1,6 @@ +user=ianhi +project=raman-analysis +issues=false +exclude-labels=duplicate,question,invalid,wontfix,hide +add-sections={"tests":{"prefix":"**Tests & CI:**","labels":["tests"]}, "documentation":{"prefix":"**Documentation:**", "labels":["documentation"]}} +exclude-tags-regex=.*rc diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..28fca7e --- /dev/null +++ b/.gitignore @@ -0,0 +1,108 @@ +# Byte-compiled / optimized / DLL files +__pycache__/ +*.py[cod] +*$py.class + +# C extensions +*.so + +# Distribution / packaging +.Python +env/ +build/ +develop-eggs/ +dist/ +downloads/ +eggs/ +.eggs/ +lib/ +lib64/ +parts/ +sdist/ +var/ +wheels/ +*.egg-info/ +.installed.cfg +*.egg + +# PyInstaller +# Usually these files are written by a python script from a template +# before PyInstaller builds the exe, so as to inject date/other infos into it. +*.manifest +*.spec + +# Installer logs +pip-log.txt +pip-delete-this-directory.txt + +# Unit test / coverage reports +htmlcov/ +.tox/ +.coverage +.coverage.* +.cache +nosetests.xml +coverage.xml +*.cover +.hypothesis/ +.pytest_cache/ + +# Translations +*.mo +*.pot + +# Django stuff: +*.log +local_settings.py + +# Flask stuff: +instance/ +.webassets-cache + +# Scrapy stuff: +.scrapy + +# Sphinx documentation +docs/_build/ + +# PyBuilder +target/ + +# Jupyter Notebook +.ipynb_checkpoints + +# pyenv +.python-version + +# celery beat schedule file +celerybeat-schedule + +# SageMath parsed files +*.sage.py + +# dotenv +.env + +# virtualenv +.venv +venv/ +ENV/ + +# Spyder project settings +.spyderproject +.spyproject + +# Rope project settings +.ropeproject + +# mkdocs documentation +/site + +# mypy +.mypy_cache/ + +# IDE settings +.vscode/ + +raman_analysis/_version.py +src/raman_analysis/_version.py diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml new file mode 100644 index 0000000..432bc33 --- /dev/null +++ b/.pre-commit-config.yaml @@ -0,0 +1,42 @@ +ci: + autoupdate_schedule: monthly + autofix_commit_msg: "style(pre-commit.ci): auto fixes [...]" + autoupdate_commit_msg: "ci(pre-commit.ci): autoupdate" + +default_install_hook_types: [pre-commit, commit-msg] + +repos: + - repo: https://github.com/compilerla/conventional-pre-commit + rev: v2.1.1 + hooks: + - id: conventional-pre-commit + stages: [commit-msg] + + - repo: https://github.com/pre-commit/pre-commit-hooks + rev: v4.4.0 + hooks: + - id: check-docstring-first + - id: end-of-file-fixer + - id: trailing-whitespace + + - repo: https://github.com/charliermarsh/ruff-pre-commit + rev: v0.0.149 + hooks: + - id: ruff + args: [--fix] + + - repo: https://github.com/psf/black + rev: 22.10.0 + hooks: + - id: black + + - repo: https://github.com/abravalheri/validate-pyproject + rev: v0.10.1 + hooks: + - id: validate-pyproject + + - repo: https://github.com/pre-commit/mirrors-mypy + rev: v0.991 + hooks: + - id: mypy + files: "^src/" diff --git a/LICENSE b/LICENSE new file mode 100644 index 0000000..d1f8e79 --- /dev/null +++ b/LICENSE @@ -0,0 +1,29 @@ +BSD License + +Copyright (c) 2022, Ian Hunt-Isaak +All rights reserved. + +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions are met: + +1. Redistributions of source code must retain the above copyright notice, this + list of conditions and the following disclaimer. + +2. Redistributions in binary form must reproduce the above copyright notice, + this list of conditions and the following disclaimer in the documentation + and/or other materials provided with the distribution. + +3. Neither the name of the copyright holder nor the names of its + contributors may be used to endorse or promote products derived from + this software without specific prior written permission. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" +AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE +FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL +DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR +SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER +CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, +OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. diff --git a/README.md b/README.md new file mode 100644 index 0000000..fc3a3c4 --- /dev/null +++ b/README.md @@ -0,0 +1,9 @@ +# raman-analysis + +[![License](https://img.shields.io/pypi/l/raman-analysis.svg?color=green)](https://github.com/ianhi/raman-analysis/raw/main/LICENSE) +[![PyPI](https://img.shields.io/pypi/v/raman-analysis.svg?color=green)](https://pypi.org/project/raman-analysis) +[![Python Version](https://img.shields.io/pypi/pyversions/raman-analysis.svg?color=green)](https://python.org) +[![CI](https://github.com/ianhi/raman-analysis/actions/workflows/ci.yml/badge.svg)](https://github.com/ianhi/raman-analysis/actions/workflows/ci.yml) +[![codecov](https://codecov.io/gh/ianhi/raman-analysis/branch/main/graph/badge.svg)](https://codecov.io/gh/ianhi/raman-analysis) + +Analysis of raman spectra diff --git a/docs/Makefile b/docs/Makefile new file mode 100644 index 0000000..6ff62d7 --- /dev/null +++ b/docs/Makefile @@ -0,0 +1,23 @@ +# Minimal makefile for Sphinx documentation +# + +# You can set these variables from the command line, and also +# from the environment for the first two. +SPHINXOPTS ?= -T --color +SPHINXBUILD ?= sphinx-build +SOURCEDIR = . +BUILDDIR = _build + +# Put it first so that "make" without argument is like "make help". +help: + @$(SPHINXBUILD) -M help "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O) + +.PHONY: help Makefile + +# Catch-all target: route all unknown targets to Sphinx using the new +# "make mode" option. $(O) is meant as a shortcut for $(SPHINXOPTS). +%: Makefile + @$(SPHINXBUILD) -M $@ "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O) + +watch: + sphinx-autobuild . _build/html --open-browser --watch examples diff --git a/docs/_static/custom.css b/docs/_static/custom.css new file mode 100644 index 0000000..4ded217 --- /dev/null +++ b/docs/_static/custom.css @@ -0,0 +1,12 @@ +/* Fix numpydoc format delimiters */ +.classifier:before { + font-style: normal; + margin: 0.5em; + content: ":"; +} + +/* override table no-wrap */ +.wy-table-responsive table td, +.wy-table-responsive table th { + white-space: normal; +} diff --git a/docs/conf.py b/docs/conf.py new file mode 100644 index 0000000..05f3068 --- /dev/null +++ b/docs/conf.py @@ -0,0 +1,228 @@ +# Configuration file for the Sphinx documentation builder. +# +# This file only contains a selection of the most common options. For a full +# list see the documentation: +# https://www.sphinx-doc.org/en/master/usage/configuration.html + +# -- Path setup -------------------------------------------------------------- + +import inspect + +# If extensions (or modules to document with autodoc) are in another directory, +# add these directories to sys.path here. If the directory is relative to the +# documentation root, use os.path.abspath to make it absolute, like shown here. +# +import os +import shutil +import subprocess +import sys + +try: + from raman_analysis import __version__ as release +except ImportError: + release = "unknown" + + +# -- Project information ----------------------------------------------------- + +project = "raman_analysis" +copyright = "2022, Ian Hunt-Isaak" +author = "Ian Hunt-Isaak" + + +# -- Generate API ------------------------------------------------------------ +api_folder_name = "api" +shutil.rmtree(api_folder_name, ignore_errors=True) # in case of new or renamed modules +subprocess.call( + " ".join( + [ + "sphinx-apidoc", + f"-o {api_folder_name}/", + "--force", + "--no-toc", + "--templatedir _templates", + "--separate", + "../raman_analysis/", + # excluded modules + # nothing here for cookiecutter + ] + ), + shell=True, +) + + +# -- General configuration --------------------------------------------------- + +# Add any Sphinx extension module names here, as strings. They can be +# extensions coming with Sphinx (named 'sphinx.ext.*') or your custom +# ones. +extensions = [ + "jupyter_sphinx", + "myst_nb", + "numpydoc", + "sphinx.ext.autodoc", + "sphinx.ext.intersphinx", + "sphinx.ext.linkcode", + "sphinx.ext.mathjax", + "sphinx.ext.napoleon", + "sphinx_copybutton", + "sphinx_panels", + "sphinx_thebe", + "sphinx_togglebutton", +] + + +# API settings +autodoc_default_options = { + "members": True, + "show-inheritance": True, + "undoc-members": True, +} +add_module_names = False +napoleon_google_docstring = False +napoleon_include_private_with_doc = False +napoleon_include_special_with_doc = False +napoleon_numpy_docstring = True +napoleon_use_admonition_for_examples = False +napoleon_use_admonition_for_notes = False +napoleon_use_admonition_for_references = False +napoleon_use_ivar = False +napoleon_use_param = False +napoleon_use_rtype = False +numpydoc_show_class_members = False + +# Cross-referencing configuration +default_role = "py:obj" +primary_domain = "py" +nitpicky = True # warn if cross-references are missing + +# Intersphinx settings +intersphinx_mapping = { + "ipywidgets": ("https://ipywidgets.readthedocs.io/en/stable", None), + "matplotlib": ("https://matplotlib.org/stable", None), + "numpy": ("https://numpy.org/doc/stable", None), + "python": ("https://docs.python.org/3", None), +} + +# remove panels css to get wider main content +panels_add_bootstrap_css = False + +# Settings for copybutton +copybutton_prompt_is_regexp = True +copybutton_prompt_text = r">>> |\.\.\. " # doctest + +# Settings for linkcheck +linkcheck_anchors = False +linkcheck_ignore = [] # type: ignore + +execution_timeout = -1 +jupyter_execute_notebooks = "off" +if "EXECUTE_NB" in os.environ: + print("\033[93;1mWill run Jupyter notebooks!\033[0m") + jupyter_execute_notebooks = "force" + +# Settings for myst-parser +myst_enable_extensions = [ + "amsmath", + "colon_fence", + "dollarmath", + "smartquotes", + "substitution", +] +suppress_warnings = [ + "myst.header", +] + +# Add any paths that contain templates here, relative to this directory. +templates_path = ["_templates"] + +# List of patterns, relative to source directory, that match files and +# directories to ignore when looking for source files. +# This pattern also affects html_static_path and html_extra_path. +exclude_patterns = [ + "**ipynb_checkpoints", + ".DS_Store", + "Thumbs.db", + "_build", +] + + +# -- Options for HTML output ------------------------------------------------- + +# The theme to use for HTML and HTML Help pages. See the documentation for +# a list of builtin themes. +# +html_copy_source = True # needed for download notebook button +html_css_files = [ + "custom.css", +] +html_sourcelink_suffix = "" +html_static_path = ["_static"] +html_theme = "sphinx_book_theme" +html_theme_options = { + "launch_buttons": { + "binderhub_url": "https://mybinder.org", + "colab_url": "https://colab.research.google.com", + "notebook_interface": "jupyterlab", + "thebe": True, + "thebelab": True, + }, + "path_to_docs": "docs", + "repository_branch": "main", + "repository_url": "https://github.com/ianhi/raman-analysis", + "use_download_button": True, + "use_edit_page_button": True, + "use_issues_button": True, + "use_repository_button": True, +} +html_title = "raman-analysis" + +master_doc = "index" +thebe_config = { + "repository_url": html_theme_options["repository_url"], + "repository_branch": html_theme_options["repository_branch"], +} + + +# based on pandas/doc/source/conf.py +def linkcode_resolve(domain, info): + """ + Determine the URL corresponding to Python object + """ + if domain != "py": + return None + + modname = info["module"] + fullname = info["fullname"] + + submod = sys.modules.get(modname) + if submod is None: + return None + + obj = submod + for part in fullname.split("."): + try: + obj = getattr(obj, part) + except AttributeError: + return None + + try: + fn = inspect.getsourcefile(inspect.unwrap(obj)) + except TypeError: + fn = None + if not fn: + return None + + try: + source, lineno = inspect.getsourcelines(obj) + except OSError: + lineno = None + + if lineno: + linespec = f"#L{lineno}-L{lineno + len(source) - 1}" + else: + linespec = "" + + fn = os.path.relpath(fn, start=os.path.dirname("../raman_analysis")) + + return f"https://github.com/ianhi/raman-analysis/blob/main/raman_analysis/{fn}{linespec}" # noqa diff --git a/docs/contributing.md b/docs/contributing.md new file mode 100644 index 0000000..a674863 --- /dev/null +++ b/docs/contributing.md @@ -0,0 +1,67 @@ +# Contributing + +Thanks for thinking of a way to help improve this library! Remember that contributions come in all shapes and sizes beyond writing bug fixes. Contributing to [documentation](#documentation), opening new [issues](https://github.com/ianhi/raman-analysis/issues) for bugs, asking for clarification on things you find unclear, and requesting new features, are all super valuable contributions. + +## Code Improvements + +All development for this library happens on GitHub [here](https://github.com/ianhi/raman-analysis). We recommend you work with a [Conda](https://www.anaconda.com/products/individual) environment (or an alternative virtual environment like [`venv`](https://docs.python.org/3/library/venv.html)). + +The below instructions also use [Mamba](https://github.com/mamba-org/mamba#the-fast-cross-platform-package-manager) which is a very fast implementation of `conda`. + +```bash +git clone +cd raman-analysis +mamba env create +conda activate raman-analysis-dev +pre-commit install +``` + +The `mamba env create` command installs all Python packages that are useful when working on the source code of `raman_analysis` and its documentation. You can also install these packages separately: + +```bash +pip install -e ".[dev, doc]" +``` + +The {command}`-e .` flag installs the `raman_analysis` folder in ["editable" mode](https://pip.pypa.io/en/stable/cli/pip_install/#editable-installs) and {command}`[dev]` installs the [optional dependencies](https://setuptools.readthedocs.io/en/latest/userguide/dependency_management.html#optional-dependencies) you need for developing `raman_analysis`. + +### Seeing your changes + +If you are working in a Jupyter Notebook, then in order to see your code changes you will need to either: + +- Restart the Kernel every time you make a change to the code. +- Make the function reload from the source file every time you run it by using [autoreload](https://ipython.readthedocs.io/en/stable/config/extensions/autoreload.html), e.g.: + + ```python + %load_ext autoreload + %autoreload 2 + + from raman_analysis import .... + ``` + +### Working with Git + +Using Git/GitHub can confusing (), so if you're new to Git, you may find it helpful to use a program like [GitHub Desktop](https://desktop.github.com) and to follow a [guide](https://github.com/firstcontributions/first-contributions#first-contributions). + +Also feel free to ask for help/advice on the relevant GitHub [issue](https://github.com/ianhi/raman-analysis/issues). + +## Documentation + +Our documentation on Read the Docs ([raman-analysis.rtfd.io](https://raman-analysis.readthedocs.io)) is built with [Sphinx](https://www.sphinx-doc.org) from the notebooks in the `docs` folder. It contains both Markdown files and Jupyter notebooks. + +Examples are best written as Jupyter notebooks. To write a new example, create in a notebook in the `docs/examples` directory and list its path under one of the [`toctree`s](https://www.sphinx-doc.org/en/master/usage/restructuredtext/directives.html#directive-toctree) in the `index.md` file. When the docs are generated, they will be rendered as static html pages by [myst-nb](https://myst-nb.readthedocs.io). + +If you have installed all developer dependencies (see [above](#contributing)), you can view recent modifications to the source files with the following simple tox command: + +```bash +tox -e doc +``` + +If you open the `_build/index.html` file in your browser you should now be able to see the rendered documentation. + +Alternatively, you can use [sphinx-autobuild](https://github.com/executablebooks/sphinx-autobuild) to continuously watch source files for changes and rebuild the documentation for you. Sphinx-autobuild will be installed automatically by the above `pip` command, so all you need to do is run: + +```bash +tox -e doclive +``` + +In a few seconds your web browser should open up the documentation. Now whenever you save a file the documentation will automatically regenerate and the webpage will refresh for you! diff --git a/docs/examples/basic-example.ipynb b/docs/examples/basic-example.ipynb new file mode 100644 index 0000000..a116cb2 --- /dev/null +++ b/docs/examples/basic-example.ipynb @@ -0,0 +1,56 @@ +{ + "cells": [ + { + "cell_type": "markdown", + "id": "cdf469e7-0110-4b75-97d5-69c25aa290f5", + "metadata": {}, + "source": [ + "# Basic Example\n", + "\n", + "\n", + "You can do normal things like use latex math:\n", + "$\\frac{\\pi}{2}$\n", + "\n", + "## This was a markdown cell!" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "4a694f4d-ba0d-4ea4-b15e-db17a2fa8e61", + "metadata": {}, + "outputs": [], + "source": [ + "print('beep boop\")" + ] + } + ], + "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.8.6" + }, + "widgets": { + "application/vnd.jupyter.widget-state+json": { + "state": {}, + "version_major": 2, + "version_minor": 0 + } + } + }, + "nbformat": 4, + "nbformat_minor": 5 +} diff --git a/docs/index.md b/docs/index.md new file mode 100644 index 0000000..3b88924 --- /dev/null +++ b/docs/index.md @@ -0,0 +1,33 @@ + +# raman-analysis's Documentation + +Analysis of raman spectra + + +## Basic Usage + +```python +# a basic usage example can go here +print(1+1) +``` + +## Install +```bash +pip install raman-analysis +``` + + + +```{toctree} +:maxdepth: 2 + +API +contributing +``` + +```{toctree} +:caption: Examples +:maxdepth: 1 + +examples/basic-example.ipynb +``` diff --git a/docs/make.bat b/docs/make.bat new file mode 100644 index 0000000..922152e --- /dev/null +++ b/docs/make.bat @@ -0,0 +1,35 @@ +@ECHO OFF + +pushd %~dp0 + +REM Command file for Sphinx documentation + +if "%SPHINXBUILD%" == "" ( + set SPHINXBUILD=sphinx-build +) +set SOURCEDIR=. +set BUILDDIR=_build + +if "%1" == "" goto help + +%SPHINXBUILD% >NUL 2>NUL +if errorlevel 9009 ( + echo. + echo.The 'sphinx-build' command was not found. Make sure you have Sphinx + echo.installed, then set the SPHINXBUILD environment variable to point + echo.to the full path of the 'sphinx-build' executable. Alternatively you + echo.may add the Sphinx directory to PATH. + echo. + echo.If you don't have Sphinx installed, grab it from + echo.http://sphinx-doc.org/ + exit /b 1 +) + +%SPHINXBUILD% -M %1 %SOURCEDIR% %BUILDDIR% %SPHINXOPTS% %O% +goto end + +:help +%SPHINXBUILD% -M help %SOURCEDIR% %BUILDDIR% %SPHINXOPTS% %O% + +:end +popd diff --git a/pyproject.toml b/pyproject.toml new file mode 100644 index 0000000..050acc9 --- /dev/null +++ b/pyproject.toml @@ -0,0 +1,149 @@ +# https://peps.python.org/pep-0517/ +[build-system] +requires = ["hatchling", "hatch-vcs"] +build-backend = "hatchling.build" + +# https://peps.python.org/pep-0621/ +[project] +name = "raman-analysis" +description = "Analysis of raman spectra" +readme = "README.md" +requires-python = ">=3.8" +license = {text = "BSD 3-Clause License"} +authors = [ + {email = "ianhuntisaak@gmail.com"}, + {name = "Ian Hunt-Isaak"}, +] +classifiers = [ + "Development Status :: 3 - Alpha", + "License :: OSI Approved :: BSD License", + "Programming Language :: Python :: 3", + "Programming Language :: Python :: 3.8", + "Programming Language :: Python :: 3.9", + "Programming Language :: Python :: 3.10", +] +dynamic = ["version"] +dependencies = [] + +# extras +# https://peps.python.org/pep-0621/#dependencies-optional-dependencies +[project.optional-dependencies] +test = ["pytest>=6.0", "pytest-cov"] +dev = [ + "black", + "ipython", + "mypy", + "pdbpp", + "pre-commit", + "pytest-cov", + "pytest", + "rich", + "ruff", +] + +[project.urls] +homepage = "https://github.com/ianhi/raman-analysis" +repository = "https://github.com/ianhi/raman-analysis" + +# same as console_scripts entry point +# [project.scripts] +# spam-cli = "spam:main_cli" + +# Entry points +# https://peps.python.org/pep-0621/#entry-points +# [project.entry-points."spam.magical"] +# tomatoes = "spam:main_tomatoes" + +# https://hatch.pypa.io/latest/config/metadata/ +[tool.hatch.version] +source = "vcs" + +# https://hatch.pypa.io/latest/config/build/#file-selection +# [tool.hatch.build.targets.sdist] +# include = ["/src", "/tests"] + + +# https://github.com/charliermarsh/ruff +[tool.ruff] +line-length = 88 +target-version = "py38" +extend-select = [ + "E", # style errors + "F", # flakes + "D", # pydocstyle + "I001", # isort + "U", # pyupgrade + # "N", # pep8-naming + # "S", # bandit + "C", # flake8-comprehensions + "B", # flake8-bugbear + "A001", # flake8-builtins + "RUF", # ruff-specific rules + "M001", # Unused noqa directive +] +extend-ignore = [ + "D100", # Missing docstring in public module + "D107", # Missing docstring in __init__ + "D203", # 1 blank line required before class docstring + "D212", # Multi-line docstring summary should start at the first line + "D213", # Multi-line docstring summary should start at the second line + "D413", # Missing blank line after last section + "D416", # Section name should end with a colon +] + + +[tool.ruff.per-file-ignores] +"tests/*.py" = ["D"] +"__init__.py" = ["E402"] +"conf.py" = [ + "A001", + "C901", + "D200", + "D400", + "D415", +] + +# https://docs.pytest.org/en/6.2.x/customize.html +[tool.pytest.ini_options] +minversion = "6.0" +testpaths = ["tests"] +filterwarnings = [ + "error", +] + +# https://mypy.readthedocs.io/en/stable/config_file.html +[tool.mypy] +files = "src/**/" +strict = true +disallow_any_generics = false +disallow_subclassing_any = false +show_error_codes = true +pretty = true + + +# https://coverage.readthedocs.io/en/6.4/config.html +[tool.coverage.report] +exclude_lines = [ + "pragma: no cover", + "if TYPE_CHECKING:", + "@overload", + "except ImportError", +] + +# https://github.com/mgedmin/check-manifest#configuration +[tool.check-manifest] +ignore = [ + ".github_changelog_generator", + ".pre-commit-config.yaml", + ".ruff_cache/**/*", + "tests/**/*", + "tox.ini", +] + +# https://python-semantic-release.readthedocs.io/en/latest/configuration.html +[tool.semantic_release] +version_source = "tag_only" +branch = "main" +changelog_sections="feature,fix,breaking,documentation,performance,chore,:boom:,:sparkles:,:children_crossing:,:lipstick:,:iphone:,:egg:,:chart_with_upwards_trend:,:ambulance:,:lock:,:bug:,:zap:,:goal_net:,:alien:,:wheelchair:,:speech_balloon:,:mag:,:apple:,:penguin:,:checkered_flag:,:robot:,:green_apple:,Other" +# commit_parser=semantic_release.history.angular_parser +build_command = "pip install build && python -m build" diff --git a/setup.py b/setup.py new file mode 100644 index 0000000..1e26c0a --- /dev/null +++ b/setup.py @@ -0,0 +1,24 @@ +import sys + +sys.stderr.write( + """ +=============================== +Unsupported installation method +=============================== +raman-analysis does not support installation with `python setup.py install`. +Please use `python -m pip install .` instead. +""" +) +sys.exit(1) + + +# The below code will never execute, however GitHub is particularly +# picky about where it finds Python packaging metadata. +# See: https://github.com/github/feedback/discussions/6456 +# +# To be removed once GitHub catches up. + +setup( # noqa + name="raman-analysis", + install_requires=[], +) diff --git a/src/raman_analysis/__init__.py b/src/raman_analysis/__init__.py new file mode 100644 index 0000000..e7506f6 --- /dev/null +++ b/src/raman_analysis/__init__.py @@ -0,0 +1,10 @@ +"""Analysis of raman spectra from MIT scope.""" +from importlib.metadata import PackageNotFoundError, version + +try: + __version__ = version("raman-analysis") +except PackageNotFoundError: + __version__ = "uninstalled" + +__author__ = "Ian Hunt-Isaak" +__email__ = "ianhuntisaak@gmail.com" diff --git a/src/raman_analysis/py.typed b/src/raman_analysis/py.typed new file mode 100644 index 0000000..e69de29 diff --git a/tests/test_raman_analysis.py b/tests/test_raman_analysis.py new file mode 100644 index 0000000..363b3e2 --- /dev/null +++ b/tests/test_raman_analysis.py @@ -0,0 +1,2 @@ +def test_something(): + pass diff --git a/tox.ini b/tox.ini new file mode 100644 index 0000000..73c0d77 --- /dev/null +++ b/tox.ini @@ -0,0 +1,29 @@ +[tox] +envlist = py{38,39,310}-{linux,macos,windows} +isolated_build = true +toxworkdir=/tmp/.tox + +[gh-actions] +python = + 3.8: py38 + 3.9: py39 + 3.10: py310 + +[gh-actions:env] +PLATFORM = + ubuntu-latest: linux + macos-latest: macos + windows-latest: windows + +[testenv] +platform = + macos: darwin + linux: linux + windows: win32 +passenv = CI GITHUB_ACTIONS DISPLAY XAUTHORITY +setenv = + PYTHONPATH = {toxinidir} +extras = + test +commands = + pytest -v --cov=raman_analysis --cov-report=xml --color=yes --basetemp={envtmpdir} {posargs}