Commit a40aa55b authored by J. Fernando Sánchez's avatar J. Fernando Sánchez
Browse files

Release 0.20.7

parent 50cba751
Pipeline #3698 failed with stages
in 0 seconds
......@@ -4,6 +4,11 @@ All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
## [UNRELEASED]
## [0.20.7]
### Changed
* Creating a `time.When` from another `time.When` does not nest them anymore (it returns the argument)
### Fixed
* Bug with time.NEVER/time.INFINITY
## [0.20.6]
### Fixed
* Agents now return `time.INFINITY` when dead, instead of 'inf'
......
0.20.5
\ No newline at end of file
0.20.7
\ No newline at end of file
......@@ -145,7 +145,7 @@ class BaseAgent(Agent):
self.alive = False
if remove:
self.remove_node(self.id)
return time.INFINITY
return time.NEVER
def step(self):
if not self.alive:
......
......@@ -10,6 +10,8 @@ INFINITY = float('inf')
class When:
def __init__(self, time):
if isinstance(time, When):
return time
self._time = time
def abs(self, time):
......@@ -18,7 +20,7 @@ class When:
NEVER = When(INFINITY)
class Delta:
class Delta(When):
def __init__(self, delta):
self._delta = delta
......@@ -60,7 +62,8 @@ class TimedActivation(BaseScheduler):
(when, agent_id) = heappop(self._queue)
logger.debug(f'Stepping agent {agent_id}')
when = (self._agents[agent_id].step() or Delta(1)).abs(self.time)
returned = self._agents[agent_id].step()
when = (returned or Delta(1)).abs(self.time)
if when < self.time:
raise Exception("Cannot schedule an agent for a time in the past ({} < {})".format(when, self.time))
......
......@@ -16,9 +16,7 @@ class TestMain(TestCase):
d.step()
with pytest.raises(agents.DeadAgent):
d.step()
def test_die_returns_infinity(self):
d = Dead(unique_id=0, model=environment.Environment())
assert d.step().abs(0) == stime.INFINITY
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment