Skip to content

Commit

Permalink
fixing more circular imports
Browse files Browse the repository at this point in the history
  • Loading branch information
chansigit committed Jul 3, 2024
1 parent 52f9542 commit 2fffc20
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 5 deletions.
4 changes: 3 additions & 1 deletion dynamo/prediction/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
from tqdm import tqdm

from ..dynamo_logger import main_warning
from ..tools.utils import log1p_, nearest_neighbors
from ..utils import isarray, normalize

# import scipy.sparse as sp
Expand Down Expand Up @@ -335,6 +334,8 @@ def estimate_sigma(
Returns:
The estimated diffusion matrix.
"""
from ..tools.utils import nearest_neighbors

if nbr_idx is None:
nbr_idx = nearest_neighbors(X, X, k=num_nbrs)

Expand Down Expand Up @@ -450,6 +451,7 @@ def fetch_exprs(
Returns:
The expression data for the given genes and time points.
"""
from ..tools.utils import log1p_
if type(genes) != list:
genes = list(genes)

Expand Down
4 changes: 1 addition & 3 deletions dynamo/simulation/evaluation.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
import numpy as np
from sklearn.metrics import mean_squared_error

from ..tools.utils import einsum_correlation


def evaluate(reference: np.ndarray, prediction: np.ndarray, metric: str = "cosine") -> float:
"""Function to evaluate the vector field related reference quantities vs. that from vector field prediction.
Expand All @@ -17,7 +15,7 @@ def evaluate(reference: np.ndarray, prediction: np.ndarray, metric: str = "cosin
Returns:
res: The score between the reference vs. reconstructed quantities based on the metric.
"""

from ..tools.utils import einsum_correlation
if metric == "cosine":
true_normalized = reference / (np.linalg.norm(reference, axis=1).reshape(-1, 1) + 1e-20)
predict_normalized = prediction / (np.linalg.norm(prediction, axis=1).reshape(-1, 1) + 1e-20)
Expand Down
4 changes: 3 additions & 1 deletion dynamo/vectorfield/stochastic_process.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
generate_neighbor_keys,
k_nearest_neighbors,
)
from ..tools.utils import log1p_

from .utils import VecFldDict, vecfld_from_adata, vector_field_function


Expand Down Expand Up @@ -47,6 +47,8 @@ def diffusionMatrix(
the diffusion matrix for each cell. A column `diffusion` corresponds to the square root of the sum of all
elements for each cell's diffusion matrix will also be added.
"""

from ..tools.utils import log1p_

if X_data is None or V_data is not None:
if genes is not None:
Expand Down

0 comments on commit 2fffc20

Please sign in to comment.