aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/argaze.test/AreaOfInterest/AOIFeatures.py1
-rw-r--r--src/argaze/AreaOfInterest/AOIFeatures.py22
2 files changed, 14 insertions, 9 deletions
diff --git a/src/argaze.test/AreaOfInterest/AOIFeatures.py b/src/argaze.test/AreaOfInterest/AOIFeatures.py
index f894eb8..4313500 100644
--- a/src/argaze.test/AreaOfInterest/AOIFeatures.py
+++ b/src/argaze.test/AreaOfInterest/AOIFeatures.py
@@ -140,6 +140,7 @@ class TestAOISceneClass(unittest.TestCase):
self.assertEqual(aoi_2d_scene.dimension, 2)
self.assertEqual(len(aoi_2d_scene.items()), 1)
self.assertEqual(list(aoi_2d_scene.keys()), ["A"])
+ self.assertEqual(len(vars(aoi_2d_scene)), 3)
def test___set_item__(self):
"""Test AOIScene __set_item__ method."""
diff --git a/src/argaze/AreaOfInterest/AOIFeatures.py b/src/argaze/AreaOfInterest/AOIFeatures.py
index 583c755..ce132b3 100644
--- a/src/argaze/AreaOfInterest/AOIFeatures.py
+++ b/src/argaze/AreaOfInterest/AOIFeatures.py
@@ -208,30 +208,37 @@ class AOIScene():
assert(dimension > 0)
self.__dimension = dimension
+ self.__areas = {}
# NEVER USE {} as default function argument
- if areas == None:
- self.__areas = {}
- else:
- self.__areas = areas
+ if areas is not None:
+
+ for name, area in areas.items():
+ self[name] = area
def __getitem__(self, name) -> AreaOfInterest:
"""Get an AOI from the scene."""
- return AreaOfInterest(self.__areas[name]) #.astype(numpy.float32).view(AreaOfInterest)
+ return AreaOfInterest(self.__areas[name])
def __setitem__(self, name, aoi: AreaOfInterest):
"""Add an AOI to the scene."""
assert(aoi.dimension == self.__dimension)
- self.__areas[name] = AreaOfInterest(aoi) #.tolist()
+ self.__areas[name] = AreaOfInterest(aoi)
+
+ # Expose area as an attribute of the class
+ setattr(self, name, self.__areas[name])
def __delitem__(self, key):
"""Remove an AOI from the scene."""
del self.__areas[key]
+ # Stop area exposition as an attribute of the class
+ delattr(self, key)
+
def __len__(self):
"""Get number of AOI into scene."""
return len(self.__areas)
@@ -271,9 +278,6 @@ class AOIScene():
return self.__areas.items()
- #for name, area in self.__areas.items():
- #yield name, AreaOfInterest(area) #.astype(numpy.float32).view(AreaOfInterest)
-
def keys(self) -> list[str]:
"""Get areas name."""