Skip to content

Commit

Permalink
resolve unit tests failing after recent changes
Browse files Browse the repository at this point in the history
  • Loading branch information
tkchafin committed May 12, 2024
1 parent 3fd3378 commit 9c11814
Show file tree
Hide file tree
Showing 5 changed files with 3 additions and 40 deletions.
24 changes: 1 addition & 23 deletions scripts/runResistnet.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
from resistnet.params import parseArgs
from resistnet.resistance_network import ResistanceNetwork
from resistnet.model_optimisation import ModelRunner
# from resistnet.samc_network import ResistanceNetworkSAMC


def main():
Expand All @@ -21,27 +20,7 @@ def main():
params.seed = datetime.now().timestamp()
random.seed(params.seed)

# Step 1: Initialise network data
# network = ResistanceNetworkSAMC(
# network=params.network,
# shapefile=params.shapefile,
# sizes=params.sizefile,
# coords=params.coords,
# variables=params.variables,
# agg_opts=params.agg_opts,
# pop_agg=params.pop_agg,
# inmat=params.inmat,
# reachid_col=params.reachid_col,
# length_col=params.length_col,
# infer_origin=params.infer_origin,
# origin=params.origin,
# rtol=params.rtol,
# solver=params.solver,
# max_iter=params.max_iter,
# max_fail=params.max_fail,
# out=params.out,
# verbose=True
# )
# Step 1: Initialise network
network = ResistanceNetwork(
network=params.network,
shapefile=params.shapefile,
Expand Down Expand Up @@ -105,7 +84,6 @@ def main():
verbose=True
)


# Call main function
if __name__ == '__main__':
os.environ['USE_PYGEOS'] = '0'
Expand Down
3 changes: 0 additions & 3 deletions src/resistnet/params.py
Original file line number Diff line number Diff line change
Expand Up @@ -366,9 +366,6 @@ def display_help(self, message=None):
" -b, --burn: Number of generations for pre-burnin [def.=0]\n"
" --max_hof_size: Maximum models retained [default=100]\n\n"

"SAMC options:\n"
"Not currently implemented\n\n"

"Multi-model inference options:\n"
" -a, --awsum: Cumulative Akaike weight threshold [def.=0.95]\n"
" --use_full: Use full rather than natural model averaging\n"
Expand Down
4 changes: 0 additions & 4 deletions tests/resistnet/test_model_optimisation.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,8 @@ def ga_parameters_fixture():
'indpb': 0.05,
'popsize': 10,
'maxpopsize': 10,
'posWeight': True,
'fixWeight': False,
'fixShape': True,
'allShapes': False,
'min_weight': 0.5,
'max_shape': 2.0,
'max_hof_size': 100,
Expand Down Expand Up @@ -119,10 +117,8 @@ def test_model_runner_initialization(resistance_network_fixture):
assert model_runner.indpb is None
assert model_runner.popsize is None
assert model_runner.maxpopsize is None
assert model_runner.posWeight is None
assert model_runner.fixWeight is None
assert model_runner.fixShape is None
assert model_runner.allShapes is None
assert model_runner.min_weight is None
assert model_runner.max_shape is None
assert model_runner.max_hof_size is None
Expand Down
8 changes: 2 additions & 6 deletions tests/resistnet/test_params.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ def test_display_help_called():
def test_parse_args_conflicting_weight_options():
test_args = [
"script_name", "-o", "my_prefix", "-g", "genmat_file",
"--shp", "shapefile.shp", "--posWeight", "--fixWeight",
"--shp", "shapefile.shp", "--fixWeight",
"-v", "example1,example2,example3"]
sys.argv = test_args

Expand Down Expand Up @@ -92,9 +92,7 @@ def test_parse_args_defaults():
assert args.modavg is True
assert args.report_all is False
assert args.plot is True
assert args.posWeight is False
assert args.fixWeight is False
assert args.allShapes is False
assert args.fixShape is False
assert args.max_shape == 100
assert args.min_weight == 0.0
Expand All @@ -106,7 +104,7 @@ def test_parse_args_nondefaults():
"--shp", "shapefile.shp", "-v", "example1", "-P", "123",
"-G", "123", "--threads", "4", "-d", "0.001", "-D", "0.01",
"-F", "42", "-T", "42", "--cxpb", "0.42", "--indpb", "0.42",
"--mutpb", "0.42", "--burn", "2", "--posWeight", "--report_all",
"--mutpb", "0.42", "--burn", "2", "--report_all",
"-o", "example", "--awsum", "0.42", "--max_hof_size", "123",
"--min_weight", "0.042", "--max_shape", "42"
]
Expand All @@ -133,9 +131,7 @@ def test_parse_args_nondefaults():
assert args.modavg is True
assert args.report_all is True
assert args.plot is True
assert args.posWeight is True
assert args.fixWeight is False
assert args.allShapes is False
assert args.fixShape is False
assert args.max_shape == 42
assert args.min_weight == 0.042
4 changes: 0 additions & 4 deletions tests/resistnet/test_resistance_network.py
Original file line number Diff line number Diff line change
Expand Up @@ -207,9 +207,7 @@ def test_resistance_network_worker_creation(resistance_network_fixture):
'gendist': resistance_network_fixture._gendist,
# Use defaults or specific values for the additional attributes
'fitmetric': 'aic',
'posWeight': False,
'fixWeight': False,
'allShapes': False,
'fixShape': False,
'min_weight': 0.0,
'max_shape': 100.0
Expand All @@ -227,9 +225,7 @@ def test_resistance_network_worker_creation(resistance_network_fixture):

# Validate unique attributes for ResistanceNetworkWorker
assert worker.fitmetric == 'aic'
assert worker.posWeight is False
assert worker.fixWeight is False
assert worker.allShapes is False
assert worker.fixShape is False
assert worker.min_weight == 0.0
assert worker.max_shape == 100.0
Expand Down

0 comments on commit 9c11814

Please sign in to comment.