Skip to content

Commit

Permalink
Merge 141c946 into 33846d3
Browse files Browse the repository at this point in the history
  • Loading branch information
scottgigante committed Jun 21, 2022
2 parents 33846d3 + 141c946 commit 3aa545f
Show file tree
Hide file tree
Showing 3 changed files with 37 additions and 47 deletions.
22 changes: 13 additions & 9 deletions .github/workflows/run_tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,15 +28,16 @@ jobs:
- uses: actions/checkout@v2

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

- name: Install tools
run: |
python -m pip install --upgrade "pip<=21.0"
pip install --use-deprecated=legacy-resolver -U wheel setuptools
pip install --use-deprecated=legacy-resolver -U black flake8
python -m pip install --upgrade pip
pip install -U wheel setuptools
pip install -U black flake8
- name: Lint with Black
run: |
cd Python
Expand Down Expand Up @@ -79,19 +80,22 @@ jobs:
with:
python-version: ${{ matrix.config.python }}

- name: Install pip
run: |
python -m pip install --upgrade pip
pip install -U wheel setuptools
- name: Cache Python packages
uses: actions/cache@v2
with:
path: ${{ env.pythonLocation }}
key: ${{runner.os}}-pip-${{ env.pythonLocation }}-${{ hashFiles('setup.py') }}
restore-keys: ${{runner.os}}-pip-${{ env.pythonLocation }}-
key: ${{runner.os}}-${{ matrix.config.python }}-pip-${{ env.pythonLocation }}-${{ hashFiles('setup.py') }}
restore-keys: ${{runner.os}}-${{ matrix.config.python }}-pip-${{ env.pythonLocation }}-

- name: Install package & dependencies
run: |
cd Python
python -m pip install --upgrade "pip<=21.0"
pip install --use-deprecated=legacy-resolver -U wheel setuptools
pip install --use-deprecated=legacy-resolver -U .[test]
pip install -U .[test]
python -c "import phate"
- name: Run tests
Expand Down
2 changes: 1 addition & 1 deletion Python/phate/mds.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ def classic(D, n_components=2, random_state=None):
_logger.debug(
"Performing classic MDS on {} of shape {}...".format(type(D).__name__, D.shape)
)
D = D ** 2
D = D**2
D = D - D.mean(axis=0)[None, :]
D = D - D.mean(axis=1)[:, None]
pca = PCA(
Expand Down
60 changes: 23 additions & 37 deletions Python/phate/phate.py
Original file line number Diff line number Diff line change
Expand Up @@ -124,16 +124,6 @@ class PHATE(BaseEstimator):
Use `gamma=1` for log transformation and `gamma=0` for square root
transformation.
alpha_decay : deprecated.
Use `decay=None` to disable alpha decay
njobs : deprecated.
Use n_jobs to match `sklearn` standards
k : Deprecated for `knn`
a : Deprecated for `decay`
kwargs : additional arguments for `graphtools.Graph`
Attributes
Expand Down Expand Up @@ -190,17 +180,16 @@ def __init__(
n_jobs=1,
random_state=None,
verbose=1,
potential_method=None,
alpha_decay=None,
njobs=None,
k=None,
a=None,
**kwargs
):
if k is not None:
knn = k
if a is not None:
decay = a
if "k" in kwargs:
warnings.warn("k is deprecated. Please use knn in future.", FutureWarning)
knn = kwargs["k"]
del kwargs["k"]
if "a" in kwargs:
warnings.warn("a is deprecated. Please use decay in future.", FutureWarning)
decay = kwargs["a"]
del kwargs["a"]
self.n_components = n_components
self.decay = decay
self.knn = knn
Expand All @@ -221,40 +210,41 @@ def __init__(
self.X = None
self.optimal_t = None

if (alpha_decay is True and decay is None) or (
alpha_decay is False and decay is not None
):
if "alpha_decay" in kwargs:
warnings.warn(
"alpha_decay is deprecated. Use `decay=None`"
" to disable alpha decay in future.",
FutureWarning,
)
if not alpha_decay:
if not kwargs["alpha_decay"]:
self.decay = None
del kwargs["alpha_decay"]

if njobs is not None:
if "njobs" in kwargs:
warnings.warn(
"njobs is deprecated. Please use n_jobs in future.", FutureWarning
)
n_jobs = njobs
n_jobs = kwargs["njobs"]
del kwargs["njobs"]
self.n_jobs = n_jobs

if potential_method is not None:
if potential_method == "log":
if "potential_method" in kwargs:
if kwargs["potential_method"] == "log":
gamma = 1
elif potential_method == "sqrt":
elif kwargs["potential_method"] == "sqrt":
gamma = 0
else:
raise ValueError(
"potential_method {} not recognized. Please "
"use gamma between -1 and 1".format(potential_method)
"use gamma between -1 and 1".format(kwargs["potential_method"])
)
warnings.warn(
"potential_method is deprecated. "
"Setting gamma to {} to achieve"
" {} transformation.".format(gamma, potential_method),
" {} transformation.".format(gamma, kwargs["potential_method"]),
FutureWarning,
)
del kwargs["potential_method"]
elif gamma > 0.99 and gamma < 1:
warnings.warn(
"0.99 < gamma < 1 is numerically unstable. " "Setting gamma to 0.99",
Expand Down Expand Up @@ -499,10 +489,6 @@ def set_params(self, **params):
verbose : `int` or `boolean`, optional (default: 1)
If `True` or `> 0`, print status messages
k : Deprecated for `knn`
a : Deprecated for `decay`
Examples
--------
>>> import phate
Expand All @@ -511,14 +497,14 @@ def set_params(self, **params):
... branch_length=50)
>>> tree_data.shape
(250, 50)
>>> phate_operator = phate.PHATE(k=5, a=20, t=150)
>>> phate_operator = phate.PHATE(knn=5, decay=20, t=150)
>>> tree_phate = phate_operator.fit_transform(tree_data)
>>> tree_phate.shape
(250, 2)
>>> phate_operator.set_params(n_components=10)
PHATE(a=20, alpha_decay=None, k=5, knn_dist='euclidean', mds='metric',
PHATE(decay=20, knn=5, knn_dist='euclidean', mds='metric',
mds_dist='euclidean', n_components=10, n_jobs=1, n_landmark=2000,
n_pca=100, njobs=None, potential_method='log', random_state=None, t=150,
n_pca=100, potential_method='log', random_state=None, t=150,
verbose=1)
>>> tree_phate = phate_operator.transform()
>>> tree_phate.shape
Expand Down

0 comments on commit 3aa545f

Please sign in to comment.