mirror of
https://github.com/illiumst/marl-factory-grid.git
synced 2025-12-10 17:40:37 +01:00
Resolved some warnings and style issues
This commit is contained in:
@@ -1,15 +1,15 @@
|
||||
from collections import defaultdict
|
||||
from typing import List
|
||||
from typing import List, Iterator, Union
|
||||
|
||||
import numpy as np
|
||||
|
||||
from marl_factory_grid.environment.entity.object import _Object
|
||||
from marl_factory_grid.environment.entity.object import Object
|
||||
import marl_factory_grid.environment.constants as c
|
||||
from marl_factory_grid.utils import helpers as h
|
||||
|
||||
|
||||
class _Objects:
|
||||
_entity = _Object
|
||||
class Objects:
|
||||
_entity = Object
|
||||
|
||||
@property
|
||||
def var_can_be_bound(self):
|
||||
@@ -50,7 +50,7 @@ class _Objects:
|
||||
def __len__(self):
|
||||
return len(self._data)
|
||||
|
||||
def __iter__(self):
|
||||
def __iter__(self) -> Iterator[Union[Object, None]]:
|
||||
return iter(self.values())
|
||||
|
||||
def add_item(self, item: _entity):
|
||||
@@ -130,13 +130,14 @@ class _Objects:
|
||||
repr_dict = {key: val for key, val in self._data.items() if key not in [c.WALLS]}
|
||||
return f'{self.__class__.__name__}[{repr_dict}]'
|
||||
|
||||
def notify_del_entity(self, entity: _Object):
|
||||
def notify_del_entity(self, entity: Object):
|
||||
try:
|
||||
# noinspection PyUnresolvedReferences
|
||||
self.pos_dict[entity.pos].remove(entity)
|
||||
except (AttributeError, ValueError, IndexError):
|
||||
pass
|
||||
|
||||
def notify_add_entity(self, entity: _Object):
|
||||
def notify_add_entity(self, entity: Object):
|
||||
try:
|
||||
if self not in entity.observers:
|
||||
entity.add_observer(self)
|
||||
|
||||
Reference in New Issue
Block a user