Skip to content

Commit

Permalink
updated the rest of the imports after module renames
Browse files Browse the repository at this point in the history
  • Loading branch information
deeenes committed Jun 25, 2024
1 parent 6ef2c52 commit e1bdea9
Show file tree
Hide file tree
Showing 4 changed files with 31 additions and 31 deletions.
2 changes: 1 addition & 1 deletion networkcommons/_data/omics/_moon.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@

import pandas as pd

from . import _common
from . import common

__all__ = ['moon']

Expand Down
6 changes: 3 additions & 3 deletions networkcommons/_methods/moon.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
import decoupler as dc
import numpy as np

from networkcommons._methods import graph
from networkcommons._methods import graph as _graph
from networkcommons._session import _log

__all__ = [
Expand Down Expand Up @@ -233,7 +233,7 @@ def keep_controllable_neighbours(source_dict, graph):
- A dictionary of source nodes that are observable from the graph.
"""

return graph.run_reachability_filter(graph, source_dict)
return _graph.run_reachability_filter(graph, source_dict)


def keep_observable_neighbours(target_dict, graph):
Expand All @@ -249,7 +249,7 @@ def keep_observable_neighbours(target_dict, graph):
- A dictionary of target nodes that are observable from the graph.
"""

subnetwork = graph.run_reachability_filter(graph.reverse(), target_dict)
subnetwork = _graph.run_reachability_filter(graph.reverse(), target_dict)

return subnetwork.reverse()

Expand Down
30 changes: 15 additions & 15 deletions tests/test_eval_graph.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
import networkx as nx
import pandas as pd

import networkcommons._eval.metrics as metrics
import networkcommons._eval.metrics as _metrics


@pytest.fixture
Expand All @@ -23,40 +23,40 @@ def network():

def test_get_number_nodes():

assert metrics.get_number_nodes(nx.Graph()) == 0
assert metrics.get_number_nodes(nx.Graph([(1, 2)])) == 2
assert metrics.get_number_nodes(nx.Graph([(1, 2), (2, 3)])) == 3
assert _metrics.get_number_nodes(nx.Graph()) == 0
assert _metrics.get_number_nodes(nx.Graph([(1, 2)])) == 2
assert _metrics.get_number_nodes(nx.Graph([(1, 2), (2, 3)])) == 3


def test_get_number_edges():

assert metrics.get_number_edges(nx.Graph()) == 0
assert metrics.get_number_edges(nx.Graph([(1, 2)])) == 1
assert metrics.get_number_edges(nx.Graph([(1, 2), (2, 3)])) == 2
assert _metrics.get_number_edges(nx.Graph()) == 0
assert _metrics.get_number_edges(nx.Graph([(1, 2)])) == 1
assert _metrics.get_number_edges(nx.Graph([(1, 2), (2, 3)])) == 2


def test_get_mean_degree(network):

assert metrics.get_mean_degree(network) == 7/3
assert _metrics.get_mean_degree(network) == 7/3


def test_get_mean_betweenness(network):

assert metrics.get_mean_betweenness(network) == 0.05833333333333334
assert _metrics.get_mean_betweenness(network) == 0.05833333333333334


def test_get_mean_closeness(network):

assert metrics.get_mean_closeness(network) == 0.29444444444444445
assert _metrics.get_mean_closeness(network) == 0.29444444444444445


def test_get_connected_targets(network):

target_dict = {'D': 1, 'F': 1, 'W': 1}

assert metrics.get_connected_targets(network, target_dict) == 2
assert _metrics.get_connected_targets(network, target_dict) == 2
assert (
metrics.get_connected_targets(network, target_dict, percent=True) ==
_metrics.get_connected_targets(network, target_dict, percent=True) ==
2 / 3 * 100
)

Expand All @@ -65,9 +65,9 @@ def test_get_recovered_offtargets(network):

offtargets = ['B', 'D', 'W']

assert metrics.get_recovered_offtargets(network, offtargets) == 2
assert _metrics.get_recovered_offtargets(network, offtargets) == 2
assert (
metrics.get_recovered_offtargets(network, offtargets, percent=True) ==
_metrics.get_recovered_offtargets(network, offtargets, percent=True) ==
2 / 3 * 100
)# noqa: E501

Expand All @@ -85,4 +85,4 @@ def test_get_graph_metrics(network):
'Connected targets': 2
}, index=[0])

assert metrics.get_graph_metrics(network, target_dict).equals(metrics)
assert _metrics.get_graph_metrics(network, target_dict).equals(metrics)
24 changes: 12 additions & 12 deletions tests/test_omics.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

def test_datasets():

dsets = omics._common._datasets()
dsets = omics.common._datasets()

assert 'baseurl' in dsets
assert isinstance(dsets['datasets'], dict)
Expand All @@ -16,23 +16,23 @@ def test_datasets():

def test_datasets_2():

dsets = omics._common.datasets()
dsets = omics.common.datasets()

assert 'decryptm' in dsets


def test_commons_url():

url = omics._common._commons_url('test', table = 'meta')
url = omics.common._commons_url('test', table = 'meta')

assert 'metadata' in url


def test_download(tmp_path):

url = omics._common._commons_url('test', table = 'meta')
url = omics.common._commons_url('test', table = 'meta')
path = tmp_path / 'test_download.tsv'
omics._common._download(url, path)
omics.common._download(url, path)

assert path.exists()

Expand All @@ -45,9 +45,9 @@ def test_download(tmp_path):

def test_open():

url = omics._common._commons_url('test', table = 'meta')
url = omics.common._commons_url('test', table = 'meta')

with omics._common._open(url) as fp:
with omics.common._open(url) as fp:

line = next(fp)

Expand All @@ -56,8 +56,8 @@ def test_open():

def test_open_df():

url = omics._common._commons_url('test', table = 'meta')
df = omics._common._open(url, df = {'sep': '\t'})
url = omics.common._commons_url('test', table = 'meta')
df = omics.common._open(url, df = {'sep': '\t'})

assert isinstance(df, pd.DataFrame)
assert df.shape == (4, 2)
Expand All @@ -78,9 +78,9 @@ def decryptm_args():
return 'KDAC_Inhibitors', 'Acetylome', 'curves_CUDC101.txt'


def test_decryptm(decryptm_args):
def test_decryptm_table(decryptm_args):

df = omics.decryptm.decryptm(*decryptm_args)
df = omics.decryptm.decryptm_table(*decryptm_args)

assert isinstance(df, pd.DataFrame)
assert df.shape == (18007, 65)
Expand All @@ -100,7 +100,7 @@ def test_decryptm_experiment(decryptm_args):

def test_panacea():

dfs = omics.panacea.panacea()
dfs = omics.panacea()

assert isinstance(dfs, tuple)
assert len(dfs) == 2
Expand Down

0 comments on commit e1bdea9

Please sign in to comment.