Skip to content

Commit

Permalink
renamed utils module due to inconsistent behaviour in docs
Browse files Browse the repository at this point in the history
  • Loading branch information
vicpaton committed Aug 14, 2024
1 parent 389a196 commit 867daed
Show file tree
Hide file tree
Showing 10 changed files with 20 additions and 20 deletions.
2 changes: 1 addition & 1 deletion docs/src/vignettes/1_simple_example.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -525,7 +525,7 @@
"metadata": {},
"outputs": [],
"source": [
"decoupler_input = nc._utils.decoupler_formatter(results, 'stat')\n",
"decoupler_input = nc.utils.decoupler_formatter(results, 'stat')\n",
"collectri_net = dc.get_collectri()\n",
"dc_estimates, dc_pvals = dc.run_ulm(decoupler_input, collectri_net)"
]
Expand Down
2 changes: 1 addition & 1 deletion networkcommons/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@
from ._session import log, _log, session
from ._conf import config, setup

from . import _utils as utils
from . import utils as utils


_MODULES = [
Expand Down
2 changes: 1 addition & 1 deletion networkcommons/data/network/_moon.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
import numpy as np
import pandas as pd

from networkcommons import _utils
from networkcommons import utils
from . import _omnipath
from . import _liana

Expand Down
2 changes: 1 addition & 1 deletion networkcommons/eval/_metrics.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@
import decoupler as dc
import numpy as np

import networkcommons._utils as utils
import networkcommons.utils as utils

import random

Expand Down
6 changes: 3 additions & 3 deletions networkcommons/methods/_causal.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
import corneto as cn
import corneto.contrib.networkx as cn_nx

from .. import _utils
from .. import utils


def run_corneto_carnival(network,
Expand All @@ -53,7 +53,7 @@ def run_corneto_carnival(network,
nx.Graph: The subnetwork containing the paths found by CARNIVAL.
list: A list containing the paths found by CARNIVAL.
"""
corneto_net = _utils.to_cornetograph(network)
corneto_net = utils.to_cornetograph(network)

problem, graph = cn.methods.runVanillaCarnival(
perturbations=source_dict,
Expand All @@ -68,7 +68,7 @@ def run_corneto_carnival(network,
cn.methods.carnival.get_selected_edges(problem, graph),
)

network_nx = _utils.to_networkx(network_sol, skip_unsupported_edges=True)
network_nx = utils.to_networkx(network_sol, skip_unsupported_edges=True)

network_nx.remove_nodes_from(['_s', '_pert_c0', '_meas_c0'])

Expand Down
8 changes: 4 additions & 4 deletions networkcommons/methods/_graph.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
import networkx as nx
import numpy as np

from networkcommons import _utils
from networkcommons import utils
from networkcommons._session import session as _session

from collections import defaultdict, Counter
Expand Down Expand Up @@ -75,7 +75,7 @@ def run_shortest_paths(network, source_dict, target_dict, verbose=False):
# _session.log_traceback(console = verbose)
pass

subnetwork = _utils.get_subnetwork(network, shortest_paths_res)
subnetwork = utils.get_subnetwork(network, shortest_paths_res)

return subnetwork, shortest_paths_res

Expand Down Expand Up @@ -148,7 +148,7 @@ def run_sign_consistency(network, paths, source_dict, target_dict=None):
if np.sign(source_sign * product_sign) == np.sign(target_sign):
sign_consistency_res.append(path)

subnetwork = _utils.get_subnetwork(network, sign_consistency_res)
subnetwork = utils.get_subnetwork(network, sign_consistency_res)

if not target_dict:
return subnetwork, sign_consistency_res, inferred_target_sign
Expand Down Expand Up @@ -215,7 +215,7 @@ def run_all_paths(network,
# _session.log_traceback(console = verbose)
pass

subnetwork = _utils.get_subnetwork(network, all_paths_res)
subnetwork = utils.get_subnetwork(network, all_paths_res)

return subnetwork, all_paths_res

Expand Down
12 changes: 6 additions & 6 deletions networkcommons/network/_network.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
from networkcommons.data import _network as _universe
from networkcommons.noi._noi import Noi

from networkcommons import _utils
from networkcommons import utils


class Network:
Expand Down Expand Up @@ -92,21 +92,21 @@ def _from_corneto(self):

def _from_networkx(self):

self._co = _utils.to_cornetograph(self.universe)
self._co = utils.to_cornetograph(self.universe)
self._attrs_from_corneto()


def _from_pandas(self):

nxgraph = _utils.network_from_df(self.universe)
self._co = _utils.to_cornetograph(nxgraph)
nxgraph = utils.network_from_df(self.universe)
self._co = utils.to_cornetograph(nxgraph)
self._attrs_from_corneto()


def _attrs_from_corneto(self):

self._nodes = _utils.node_attrs_from_corneto(self._co)
self._edges = _utils.edge_attrs_from_corneto(self._co)
self._nodes = utils.node_attrs_from_corneto(self._co)
self._edges = utils.edge_attrs_from_corneto(self._co)


def as_igraph(self, attrs: str | list[str]) -> "igraph.Graph":
Expand Down
File renamed without changes.
2 changes: 1 addition & 1 deletion networkcommons/visual/_rnaseq.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@
import matplotlib.pyplot as plt
import seaborn as sns
from sklearn import decomposition as sklearn_decomp
from networkcommons._utils import handle_missing_values
from networkcommons.utils import handle_missing_values


def plot_density(df,
Expand Down
4 changes: 2 additions & 2 deletions tests/test_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
import corneto as cn
from unittest.mock import patch
import pytest
import networkcommons._utils as utils
import networkcommons.utils as utils
import pygraphviz as pgv


Expand Down Expand Up @@ -107,7 +107,7 @@ def test_to_networkx_when_not_supported():


def test_read_network_from_file():
with patch('pandas.read_csv') as mock_read_csv, patch('networkcommons._utils.network_from_df') as mock_network_from_df:
with patch('pandas.read_csv') as mock_read_csv, patch('networkcommons.utils.network_from_df') as mock_network_from_df:
mock_read_csv.return_value = pd.DataFrame({'source': ['a'], 'target': ['b']})
utils.read_network_from_file('dummy_path')
mock_network_from_df.assert_called_once()
Expand Down

0 comments on commit 867daed

Please sign in to comment.