mirror of
https://github.com/gsi-upm/soil
synced 2024-11-24 11:52:29 +00:00
Release 0.20.7
This commit is contained in:
parent
50cba751a6
commit
a40aa55b6a
@ -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'
|
||||
|
@ -1 +1 @@
|
||||
0.20.5
|
||||
0.20.7
|
@ -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
|
||||
|
||||
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user