mirror of
				https://github.com/gsi-upm/soil
				synced 2025-10-31 15:48:16 +00:00 
			
		
		
		
	Release 0.20.7
This commit is contained in:
		| @@ -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). | 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] | ## [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] | ## [0.20.6] | ||||||
| ### Fixed | ### Fixed | ||||||
| * Agents now return `time.INFINITY` when dead, instead of 'inf' | * 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 |         self.alive = False | ||||||
|         if remove: |         if remove: | ||||||
|             self.remove_node(self.id) |             self.remove_node(self.id) | ||||||
|         return time.INFINITY |         return time.NEVER | ||||||
|  |  | ||||||
|     def step(self): |     def step(self): | ||||||
|         if not self.alive: |         if not self.alive: | ||||||
|   | |||||||
| @@ -10,6 +10,8 @@ INFINITY = float('inf') | |||||||
|  |  | ||||||
| class When: | class When: | ||||||
|     def __init__(self, time): |     def __init__(self, time): | ||||||
|  |         if isinstance(time, When): | ||||||
|  |             return time | ||||||
|         self._time = time |         self._time = time | ||||||
|  |  | ||||||
|     def abs(self, time): |     def abs(self, time): | ||||||
| @@ -18,7 +20,7 @@ class When: | |||||||
| NEVER = When(INFINITY) | NEVER = When(INFINITY) | ||||||
|  |  | ||||||
|  |  | ||||||
| class Delta: | class Delta(When): | ||||||
|     def __init__(self, delta): |     def __init__(self, delta): | ||||||
|         self._delta = delta |         self._delta = delta | ||||||
|  |  | ||||||
| @@ -60,7 +62,8 @@ class TimedActivation(BaseScheduler): | |||||||
|             (when, agent_id) = heappop(self._queue) |             (when, agent_id) = heappop(self._queue) | ||||||
|             logger.debug(f'Stepping agent {agent_id}') |             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: |             if when < self.time: | ||||||
|                 raise Exception("Cannot schedule an agent for a time in the past ({} < {})".format(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() |         d.step() | ||||||
|         with pytest.raises(agents.DeadAgent): |         with pytest.raises(agents.DeadAgent): | ||||||
|             d.step() |             d.step() | ||||||
|  |  | ||||||
|     def test_die_returns_infinity(self): |     def test_die_returns_infinity(self): | ||||||
|         d = Dead(unique_id=0, model=environment.Environment()) |         d = Dead(unique_id=0, model=environment.Environment()) | ||||||
|         assert d.step().abs(0) == stime.INFINITY |         assert d.step().abs(0) == stime.INFINITY | ||||||
|  |  | ||||||
|  |  | ||||||
|  |  | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user