Skip to content

Commit

Permalink
changed example names, added source links
Browse files Browse the repository at this point in the history
  • Loading branch information
fra-pcmgf committed Aug 13, 2024
1 parent 59437f5 commit 7590596
Show file tree
Hide file tree
Showing 8 changed files with 46 additions and 21 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/documentation.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ name: documentation
on:
push:
tags:
- '*'
- 'v*'
workflow_dispatch:

permissions:
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/publish_release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ name: Publish Python 🐍 distribution 📦 to PyPI and Github
on:
push:
tags:
- '*'
- 'v*'
workflow_dispatch:

jobs:
Expand Down
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,10 @@ pip install git+https://github.com/Klugerlab/DysonEqualizer.git
To import the package and apply the Dyson Equalizer to a test matrix

```python
from dyson_equalizer.examples import generate_Y_with_correlated_noise
from dyson_equalizer.examples import generate_Y_with_heteroskedastic_noise
from dyson_equalizer.dyson_equalizer import DysonEqualizer

Y = generate_Y_with_correlated_noise()
Y = generate_Y_with_heteroskedastic_noise()
de = DysonEqualizer(Y).compute()

```
Expand Down
31 changes: 25 additions & 6 deletions docs/source/conf.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import numpy
import os
import sys
from importlib.metadata import version
from importlib.metadata import version, PackageNotFoundError
import warnings

sys.path.insert(0, os.path.abspath('..'))
sys.path.insert(0, os.path.abspath('../..'))
Expand All @@ -17,11 +17,18 @@
project = 'Dyson Equalizer'
copyright = '2024, Boris Landa, Francesco Strino, Yuval Kluger'
author = 'Boris Landa, Francesco Strino, Yuval Kluger'

# scm version (https://pypi.org/project/setuptools-scm/7.0.5/)
release_scm = version('dyson-equalizer')
github_url = "https://github.com/KlugerLab/DysonEqualizer"

# Get the version using scm (https://pypi.org/project/setuptools-scm/7.0.5/)
try:
release_scm = version('dyson-equalizer')
except PackageNotFoundError:
warnings.warn('The package "dyson-equalizer" is not installed. '
'Run e.g. "pip install -e ." to make the SCM version available')
release_scm = '0.0.0-dev'
release = '.'.join(release_scm.split('.')[:3])
version = release
branch = 'main' if 'dev' in release_scm else f'v{version}'

# -- General configuration ---------------------------------------------------
# https://www.sphinx-doc.org/en/master/usage/configuration.html#general-configuration
Expand All @@ -34,6 +41,7 @@
'sphinx.ext.intersphinx',
'sphinx.ext.coverage',
'sphinx.ext.doctest',
'sphinx.ext.linkcode',
'sphinx.ext.autosummary',
'matplotlib.sphinxext.plot_directive',
]
Expand Down Expand Up @@ -64,7 +72,7 @@
"icon_links": [
{
"name": "GitHub",
"url": "https://github.com/KlugerLab/DysonEqualizer",
"url": github_url,
"icon": "fa-brands fa-square-github",
"type": "fontawesome",
},
Expand All @@ -78,3 +86,14 @@
}

plot_include_source = True


def linkcode_resolve(domain, info):
"""
Called by sphinx.ext.linkcode to add a link
See https://www.sphinx-doc.org/en/master/usage/extensions/linkcode.html
"""
if domain == 'py' and info['module']:
filename = info['module'].replace('.', '/')
return f"{github_url}/tree/{branch}/{filename}.py"
8 changes: 4 additions & 4 deletions docs/source/examples.rst
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,9 @@ added to create the data matrix ``Y = X + E``. The noise ``E`` was homoskedastic
import matplotlib.pyplot as plt
import numpy as np
from dyson_equalizer.dyson_equalizer import DysonEqualizer
from dyson_equalizer.examples import generate_Y_almost_homoskedastic
from dyson_equalizer.examples import generate_Y_with_almost_homoskedastic_noise

Y = generate_Y_almost_homoskedastic()
Y = generate_Y_with_almost_homoskedastic_noise()
de = DysonEqualizer(Y).compute()
de.plot_mp_eigenvalues_and_densities(show_only_significant=1)

Expand Down Expand Up @@ -55,9 +55,9 @@ Next, we compute the Dyson Equalizer and plot the eigenvalues distributions by
import matplotlib.pyplot as plt
import numpy as np
from dyson_equalizer.dyson_equalizer import DysonEqualizer
from dyson_equalizer.examples import generate_Y_with_correlated_noise
from dyson_equalizer.examples import generate_Y_with_heteroskedastic_noise

Y = generate_Y_with_correlated_noise()
Y = generate_Y_with_heteroskedastic_noise()
de = DysonEqualizer(Y).compute()
de.plot_mp_eigenvalues_and_densities(show_only_significant=1)

Expand Down
8 changes: 7 additions & 1 deletion dyson_equalizer/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,4 +15,10 @@
.. [1] Landa B., Kluger Y., "The Dyson Equalizer: Adaptive Noise Stabilization for Low-Rank Signal
Detection and Recovery," arXiv, https://arxiv.org/abs/2306.11263
"""
"""

# Get the version from _version.py (added when building using scm)
try:
from .version import __version__ # noqa
except ModuleNotFoundError as e:
__version__ = '0.0.0-dev'
4 changes: 2 additions & 2 deletions dyson_equalizer/examples.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ def generate_X(
return X_20


def generate_Y_almost_homoskedastic(
def generate_Y_with_almost_homoskedastic_noise(
m: int = 1000,
n: int = 2000,

Expand Down Expand Up @@ -82,7 +82,7 @@ def generate_Y_almost_homoskedastic(
return X + E


def generate_Y_with_correlated_noise(
def generate_Y_with_heteroskedastic_noise(
m: int = 1000,
n: int = 2000,
noise_dimensions: int = 10,
Expand Down
8 changes: 4 additions & 4 deletions tests/test_dyson_equalizer.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,26 +3,26 @@
import numpy as np

from dyson_equalizer.dyson_equalizer import DysonEqualizer
from dyson_equalizer.examples import generate_Y_with_correlated_noise, generate_Y_almost_homoskedastic
from dyson_equalizer.examples import generate_Y_with_heteroskedastic_noise, generate_Y_with_almost_homoskedastic_noise


class DysonEqualizerTestCase(unittest.TestCase):
def test_fig_1(self):
Y = generate_Y_almost_homoskedastic()
Y = generate_Y_with_almost_homoskedastic_noise()
de = DysonEqualizer(Y)
de.compute()

self.assertEqual(20, de.r_hat)

def test_fig_2(self):
Y = generate_Y_with_correlated_noise()
Y = generate_Y_with_heteroskedastic_noise()
de = DysonEqualizer(Y)
de.compute()

self.assertEqual(20, de.r_hat)

def test_transpose(self):
Y = generate_Y_with_correlated_noise()
Y = generate_Y_with_heteroskedastic_noise()

de = DysonEqualizer(Y)
de.compute()
Expand Down

0 comments on commit 7590596

Please sign in to comment.