1
0
mirror of https://github.com/gsi-upm/soil synced 2025-08-23 19:52:19 +00:00

Fix incompatibility and bug in get_agents

This commit is contained in:
J. Fernando Sánchez
2019-05-16 19:59:46 +02:00
parent 97835b3d10
commit 6690b6ee5f
7 changed files with 27 additions and 16 deletions

View File

@@ -1 +1 @@
0.14.2
0.14.4

View File

@@ -171,7 +171,7 @@ class BaseAgent(nxsim.BaseAgent):
def info(self, *args, **kwargs):
return self.log(*args, level=logging.INFO, **kwargs)
def __getstate__(self):
'''
Serializing an agent will lose all its running information (you cannot
@@ -476,11 +476,8 @@ class Geo(NetworkAgent):
def select(agents, state_id=None, agent_type=None, ignore=None, iterator=False, **kwargs):
if state_id is not None:
try:
state_id = tuple(state_id)
except TypeError:
state_id = tuple([state_id])
if state_id is not None and not isinstance(state_id, (tuple, list)):
state_id = tuple([state_id])
if agent_type is not None:
try:
agent_type = tuple(agent_type)

View File

@@ -186,7 +186,7 @@ def deserializer(type_, known_modules=[]):
module = importlib.import_module(modname)
cls = getattr(module, tname)
return getattr(cls, 'deserialize', cls)
except (ModuleNotFoundError, AttributeError) as ex:
except (ImportError, AttributeError) as ex:
errors.append((modname, tname, ex))
raise Exception('Could not find type {}. Tried: {}'.format(type_, errors))

View File

@@ -46,5 +46,5 @@ def safe_open(path, mode='r', backup=True, **kwargs):
def open_or_reuse(f, *args, **kwargs):
try:
return safe_open(f, *args, **kwargs)
except TypeError:
except (AttributeError, TypeError):
return f