From a4b32afa2f1d5f2ba350bdaa6598ef2dfbf3ae65 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=2E=20Fernando=20S=C3=A1nchez?= Date: Thu, 19 Oct 2017 18:28:17 +0200 Subject: [PATCH] Fix py3.4 and pypi bugs --- requirements.txt | 1 + simulation.yml | 61 --------------------------------------------- soil/__init__.py | 2 +- soil/__main__.py | 34 +------------------------ soil/environment.py | 16 ++++++------ 5 files changed, 10 insertions(+), 104 deletions(-) delete mode 100644 simulation.yml diff --git a/requirements.txt b/requirements.txt index 1921c99..92f8443 100644 --- a/requirements.txt +++ b/requirements.txt @@ -4,3 +4,4 @@ networkx numpy matplotlib pyyaml +pandas diff --git a/simulation.yml b/simulation.yml deleted file mode 100644 index 37e3488..0000000 --- a/simulation.yml +++ /dev/null @@ -1,61 +0,0 @@ ---- -name: ControlModelM2_sim -max_time: 50 -num_trials: 1 -network_params: - generator: barabasi_albert_graph - n: 100 - m: 2 -network_agents: - - agent_type: ControlModelM2 - weight: 0.1 - state: - id: 1 - - agent_type: ControlModelM2 - weight: 0.9 - state: - id: 0 -environment_params: - prob_neutral_making_denier: 0.035 - prob_infect: 0.075 - prob_cured_healing_infected: 0.035 - prob_cured_vaccinate_neutral: 0.035 - prob_vaccinated_healing_infected: 0.035 - prob_vaccinated_vaccinate_neutral: 0.035 - prob_generate_anti_rumor: 0.035 - standard_variance: 0.055 ---- -name: SISA_sm -max_time: 50 -num_trials: 2 -network_params: - generator: erdos_renyi_graph - n: 1000 - p: 0.05 -#other_agents: -# - agent_type: DrawingAgent -network_agents: - - agent_type: SISaModel - weight: 1 - state: - id: content - - agent_type: SISaModel - weight: 1 - state: - id: neutral - - agent_type: SISaModel - weight: 1 - state: - id: discontent -environment_params: - neutral_discontent_spon_prob: 0.04 - neutral_discontent_infected_prob: 0.04 - neutral_content_spon_prob: 0.18 - neutral_content_infected_prob: 0.02 - discontent_neutral: 0.13 - discontent_content: 0.07 - variance_d_c: 0.02 - content_discontent: 0.009 - variance_c_d: 0.003 - content_neutral: 0.088 - standard_variance: 0.055 diff --git a/soil/__init__.py b/soil/__init__.py index ef3cf16..a0db181 100644 --- a/soil/__init__.py +++ b/soil/__init__.py @@ -4,7 +4,7 @@ import os import pdb import logging -__version__ = "0.10" +__version__ = "0.10.1" try: basestring diff --git a/soil/__main__.py b/soil/__main__.py index 7a5ff94..c7c70d0 100644 --- a/soil/__main__.py +++ b/soil/__main__.py @@ -1,36 +1,4 @@ -import importlib -import sys -import os -import argparse -import logging -from . import simulation - -logger = logging.getLogger(__name__) - - -def main(): - - parser = argparse.ArgumentParser(description='Run a SOIL simulation') - parser.add_argument('file', type=str, - nargs="?", - default='simulation.yml', - help='python module containing the simulation configuration.') - parser.add_argument('--module', '-m', type=str, - help='file containing the code of any custom agents.') - parser.add_argument('--dry-run', '--dry', action='store_true', - help='Do not store the results of the simulation.') - parser.add_argument('--output', '-o', type=str, - help='folder to write results to. It defaults to the current directory.') - - args = parser.parse_args() - - if args.module: - sys.path.append(os.getcwd()) - importlib.import_module(args.module) - - print('Loading config file: {}'.format(args.file, args.output)) - simulation.run_from_config(args.file, dump=not args.dry_run, results_dir=args.output) - +from . import main if __name__ == '__main__': main() diff --git a/soil/environment.py b/soil/environment.py index d7216cb..0a9e62b 100644 --- a/soil/environment.py +++ b/soil/environment.py @@ -145,15 +145,13 @@ class SoilEnvironment(nxsim.NetworkEnvironment): def __getitem__(self, key): if isinstance(key, tuple): - values = {"agent_id": key[0], - "t_step": key[1], - "key": key[2], - "value": None, - "value_type": None - } - - fields = list(k for k, v in values.items() if v is None) - conditions = " and ".join("{}='{}'".format(k, v) for k, v in values.items() if v is not None) + values = [("agent_id", key[0]), + ("t_step", key[1]), + ("key", key[2]), + ("value", None), + ("value_type", None)] + fields = list(k for k, v in values if v is None) + conditions = " and ".join("{}='{}'".format(k, v) for k, v in values if v is not None) query = """SELECT {fields} from history""".format(fields=",".join(fields)) if conditions: