Skip to content

Commit

Permalink
Merge pull request #16 from mancusolab/develop
Browse files Browse the repository at this point in the history
The most updated version SuSiE PCA
  • Loading branch information
Dong555 authored Nov 7, 2023
2 parents fbdb625 + 80f84b1 commit f8f4f3c
Show file tree
Hide file tree
Showing 19 changed files with 2,053 additions and 350 deletions.
26 changes: 10 additions & 16 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ exclude: '^(docs/conf.py|tests/testdata/.*)'

repos:
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.0.1
rev: v4.4.0
hooks:
- id: trailing-whitespace
- id: check-added-large-files
Expand All @@ -17,26 +17,20 @@ repos:
- id: mixed-line-ending
args: ['--fix=auto'] # replace 'auto' with 'lf' to enforce Linux/Mac line endings or 'crlf' for Windows

- repo: https://github.com/pycqa/isort
rev: 5.10.1
hooks:
- id: isort

- repo: https://github.com/psf/black
rev: 21.11b1
rev: 23.3.0
hooks:
- id: black
language_version: python3
additional_dependencies: ['click==8.0.4']

- repo: https://github.com/PyCQA/flake8
rev: 4.0.1
- repo: https://github.com/charliermarsh/ruff-pre-commit
rev: 'v0.0.277'
hooks:
- id: flake8
## You can add flake8 plugins via `additional_dependencies`:
# additional_dependencies: [flake8-bugbear]
- id: ruff
args: [--fix]

- repo: https://github.com/pre-commit/mirrors-mypy
rev: 'v0.971' # Use the sha / tag you want to point at
hooks:
- id: mypy
#- repo: https://github.com/pre-commit/mirrors-mypy
# rev: 'v1.4.1' # Use the sha / tag you want to point at
# hooks:
# - id: mypy
23 changes: 17 additions & 6 deletions docs/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,9 @@
# serve to show the default.

import os
import shutil
import sys


# -- Path setup --------------------------------------------------------------
# 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
Expand Down Expand Up @@ -132,9 +132,14 @@
]

object_description_options = [
("py.*", dict(include_in_toc=False,
include_fields_in_toc=False,
wrap_signatures_with_css=True)),
(
"py.*",
dict(
include_in_toc=False,
include_fields_in_toc=False,
wrap_signatures_with_css=True,
),
),
("py.class", dict(include_in_toc=True)),
("py.function", dict(include_in_toc=True)),
]
Expand Down Expand Up @@ -278,22 +283,28 @@

# -- Post process ------------------------------------------------------------
import collections


def remove_namedtuple_attrib_docstring(app, what, name, obj, skip, options):
if type(obj) is collections._tuplegetter:
return True
return skip

def autodoc_process_signature(app, what, name, obj, options, signature, return_annotation):

def autodoc_process_signature(
app, what, name, obj, options, signature, return_annotation
):
signature = modify_type_hints(signature)
return_annotation = modify_type_hints(return_annotation)
return signature, return_annotation


def modify_type_hints(signature):
if signature:
signature = signature.replace("jnp", "~jax.numpy")
return signature


def setup(app):
app.connect('autodoc-skip-member', remove_namedtuple_attrib_docstring)
app.connect("autodoc-skip-member", remove_namedtuple_attrib_docstring)
app.connect("autodoc-process-signature", autodoc_process_signature)
3 changes: 2 additions & 1 deletion examples/spca_simulation.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,18 +2,19 @@
# -*- coding: utf-8 -*-
import argparse as ap
import sys

from csv import writer
from time import time

import numpy as np
import procrustes

from sklearn.decomposition import SparsePCA

import susiepca


def mySparsePCA(X, n_components, seed):

spca = SparsePCA(n_components=n_components, random_state=seed)
spca_z = spca.fit_transform(X)
spca_weights = spca.components_
Expand Down
2 changes: 2 additions & 0 deletions examples/susie_pca_simulation.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,13 @@
# -*- coding: utf-8 -*-
import argparse as ap
import sys

from csv import writer
from time import time

import numpy as np
import procrustes

from jax.config import config

import susiepca as sp
Expand Down
17 changes: 17 additions & 0 deletions ruff.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
line-length = 120
select = ["E", "F", "I001"]
ignore = ["E402", "E721", "E731", "E741", "F722", "F811"]
ignore-init-module-imports = true

[isort]
combine-as-imports = true
lines-after-imports = 2
lines-between-types = 1
known-local-folder = ["src"]
known-first-party = ["susiepca"]
section-order = ["future", "standard-library", "third-party", "jax-ecosystem", "first-party", "local-folder"]
extra-standard-library = ["typing_extensions"]
order-by-type = false

[isort.sections]
jax-ecosystem = ["equinox", "jax", "jaxtyping", "lineax", "optax"]
12 changes: 0 additions & 12 deletions setup.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -81,18 +81,6 @@ testpaths = tests
no_vcs = 1
formats = bdist_wheel

[flake8]
# Some sane defaults for the code style checker flake8
max_line_length = 88
extend_ignore = E203, W503
# ^ Black-compatible
# E203 and W503 have edge cases handled by black
exclude =
.tox
build
dist
.eggs
docs/conf.py

[pyscaffold]
# PyScaffold's parameters when the project was created.
Expand Down
1 change: 1 addition & 0 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
"""
from setuptools import setup


if __name__ == "__main__":
try:
setup(use_scm_version={"version_scheme": "no-guess-dev"})
Expand Down
6 changes: 4 additions & 2 deletions susiepca/__init__.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
from importlib.metadata import PackageNotFoundError, version # pragma: no cover


# flat api; unfortunate but can work with autodoc
"""
from infer import *
Expand All @@ -9,9 +10,10 @@
from utils import *
from io import *
"""
from susiepca import infer, io, metrics, sim, utils
from susiepca import infer, infer_design_matrix, io, metrics, sim, utils


__all__ = ["infer", "metrics", "sim", "utils", "io"]
__all__ = ["common", "infer", "infer_design_matrix", "metrics", "sim", "utils", "io"]

try:
# Change here if project is renamed and does not equal the package name
Expand Down
Loading

0 comments on commit f8f4f3c

Please sign in to comment.