Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
43 changes: 43 additions & 0 deletions .github/workflows/gh-pages.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
name: Publish Documentation

on:
push:
branches:
- main
- '*'
pull_request:
branches: [main]
release:
types:
- published

jobs:
docs:
name: Build and publish documentation
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v2.3.1
- name: Install dependencies 🔧
run: |
curl -LsSf https://astral.sh/uv/install.sh | sh
uv python install 3.11
uv venv --python 3.11
source .venv/bin/activate
uv pip install -e .[docs]

- name: Install pandoc
run: |
sudo apt-get update
sudo apt-get install -y pandoc

- name: Sphinx build
run: |
uv run sphinx-build docs docs/_build
- name: Deploy
uses: peaceiris/actions-gh-pages@v4
with:
publish_branch: gh-pages
github_token: ${{ secrets.GH_ACTION_PAT }}
publish_dir: docs/_build/
force_orphan: true
57 changes: 57 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
name: test workflow

on:
push:
branches:
- main
- '*'
pull_request:
branches: [main]
release:
types:
- published

jobs:
tests:
name: "py${{ matrix.python-version }} / ${{ matrix.os }}"
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
python-version: ["3.11", "3.12", "3.13"]
os: [ubuntu-latest, macos-latest, windows-latest]
steps:
- name: Clone the repository
uses: actions/checkout@v4
- name: Install dependencies
shell: bash {0}
run: |
if [ "${{ matrix.os }}" = "windows-latest" ]; then
powershell -ExecutionPolicy ByPass -c "irm https://astral.sh/uv/install.ps1 | iex"
export PATH="/c/Users/runneradmin/.local/bin:$PATH"
else
curl -LsSf https://astral.sh/uv/install.sh | sh
fi
uv python install ${{ matrix.python-version }}
uv venv --python ${{ matrix.python-version }}
if [ "${{ matrix.os }}" = "windows-latest" ]; then
.venv\\Scripts\\activate
else
source .venv/bin/activate
fi
uv pip install -e .[tests]
- name: Test with pytest
shell: bash {0}
run: |
uv run pytest --cov=skpcp --cov-branch --cov-report=term-missing --cov-report=xml:coverage.xml -vv test
- name: Upload coverage to Codecov
uses: codecov/codecov-action@v3
with:
token: ${{ secrets.CODECOV_TOKEN }}
directory: .
env_vars: OS,PYTHON
fail_ci_if_error: true
files: coverage.xml
flags: unittests
name: codecov-umbrella
verbose: true
223 changes: 54 additions & 169 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,171 +1,56 @@
# Byte-compiled / optimized / DLL files
__pycache__/
*.py[cod]
*$py.class

# C extensions
*/build/*
*.o
*.so

# Distribution / packaging
.Python
build/
develop-eggs/
dist/
downloads/
eggs/
.eggs/
lib/
lib64/
parts/
sdist/
var/
wheels/
share/python-wheels/
*.egg-info/
.installed.cfg
*.egg
MANIFEST

# 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/
.nox/
.coverage
.coverage.*
.cache
nosetests.xml
coverage.xml
*.cover
*.py,cover
.hypothesis/
.pytest_cache/
cover/

# Translations
*.mo
*.pot

# Django stuff:
*.d
*.a
*.exe
*.out
*.app
*.class
*.jar
*.war
*.ear
*.dll
*.dylib
*.pdb
*.idb
*.ilk
*.log
local_settings.py
db.sqlite3
db.sqlite3-journal

# Flask stuff:
instance/
.webassets-cache

# Scrapy stuff:
.scrapy

# Sphinx documentation
docs/_build/

# PyBuilder
.pybuilder/
target/

# Jupyter Notebook
.ipynb_checkpoints

# IPython
profile_default/
ipython_config.py

# pyenv
# For a library or package, you might want to ignore these files since the code is
# intended to run in multiple environments; otherwise, check them in:
# .python-version

# pipenv
# According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control.
# However, in case of collaboration, if having platform-specific dependencies or dependencies
# having no cross-platform support, pipenv may install dependencies that don't work, or not
# install all needed dependencies.
#Pipfile.lock

# poetry
# Similar to Pipfile.lock, it is generally recommended to include poetry.lock in version control.
# This is especially recommended for binary packages to ensure reproducibility, and is more
# commonly ignored for libraries.
# https://python-poetry.org/docs/basic-usage/#commit-your-poetrylock-file-to-version-control
#poetry.lock

# pdm
# Similar to Pipfile.lock, it is generally recommended to include pdm.lock in version control.
#pdm.lock
# pdm stores project-wide configurations in .pdm.toml, but it is recommended to not include it
# in version control.
# https://pdm.fming.dev/latest/usage/project/#working-with-version-control
.pdm.toml
.pdm-python
.pdm-build/

# PEP 582; used by e.g. github.com/David-OConnor/pyflow and github.com/pdm-project/pdm
__pypackages__/

# Celery stuff
celerybeat-schedule
celerybeat.pid

# SageMath parsed files
*.sage.py

# Environments
.env
.venv
env/
venv/
ENV/
env.bak/
venv.bak/

# Spyder project settings
.spyderproject
.spyproject

# Rope project settings
.ropeproject

# mkdocs documentation
/site

# mypy
.mypy_cache/
.dmypy.json
dmypy.json

# Pyre type checker
.pyre/

# pytype static type analyzer
.pytype/

# Cython debug symbols
cython_debug/

# PyCharm
# JetBrains specific template is maintained in a separate JetBrains.gitignore that can
# be found at https://github.com/github/gitignore/blob/main/Global/JetBrains.gitignore
# and can be added to the global gitignore or merged into this file. For a more nuclear
# option (not recommended) you can uncomment the following to ignore the entire idea folder.
#.idea/

.DS_Store
poetry.lock
_autoapi_root
_autoapi_root/*
_autosummary
settings.json

quantfinlib/datasets/resources/*.csv
*.tmp
*.temp
*.cache
*.swp
*.swo
*.DS_Store
*.vscode/*
*.idea/*
*.history/*
*.coverage
*.pyc
*.pyo
*.pyd
__pycache__/*
*venv/*
*.mypy_cache/*
*.pytest_cache/*
*.ruff_cache/*
*.tox/*
*.dist-info/*
*.egg-info/*
*.egg
*.whl
.python-version
.git/*
*.ipynb_checkpoints/*
*.coverage.*
dev/*
uv.lock
docs/index.md
docs/_build/*
skpcp.egg-info/*
dist/*
skpcp/__pycache__/*
test/__pycache__/*
tests/__pycache__/*
.pytest_cache
.pytest_cache/*
2 changes: 1 addition & 1 deletion LICENSE
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
MIT License

Copyright (c) 2024 QuantFinLib
Copyright (c) 2025 Mohammadjavad Vakili

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
Expand Down
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,2 +1,4 @@
## skpcp

Robust principal component analysis via Principal Component Pursuit (PCP)

19 changes: 19 additions & 0 deletions docs/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
### Documentation

The documentation is supported by [Sphinx](https://www.sphinx-doc.org/en/master/).

To build the HTML pages locally, first make sure you have installed the package with its documentation dependencies:

```bash
uv pip install -e .[docs]
```

then run the following:

```bash
sphinx-build docs docs/_build
```

from the package root directory. The documentation can then be viewed by opening `./docs/_build/html/index.html``.

Github Actions is used for continuous integration, and the tests will fail if the documentation does not build.
13 changes: 13 additions & 0 deletions docs/_static/style.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
@import url("theme.css");

/* Clearer distinction between each class. */
dl.py.class {
border-left: 3px solid #008080;
padding: 10px;
}

/* Remove unnecessary scroll bar https://github.com/executablebooks/sphinx-book-theme/issues/732 */
#rtd-footer-container {
margin-top: 0px !important;
margin-bottom: 0px !important;
}
12 changes: 12 additions & 0 deletions docs/api/pcp.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
PCP
==========================
This module implements Principal Component Pursuit (PCP) for robustly decomposing a data
matrix into low-rank and sparse components.

API Reference
-----------------

.. automodule:: skpcp.pcp
:members:
:show-inheritance:
:member-order: groupwise
Loading
Loading