Beispiel #1
0
 def test_get_targets_as_dict_with_indexes_list(self):
     req_idx = [0, 3]
     exp_targets = self._create_targets(req_idx)
     holder = targ.TargetsHolder()
     holder.extend(self._create_targets(slice(None)))
     self._assertTargetsDictEqual(holder.get_targets_as_dict(req_idx),
                                  exp_targets)
Beispiel #2
0
 def test_get_targets_as_dict_with_range(self):
     req_range = range(1, 3)
     exp_targets = self._create_targets(req_range)
     holder = targ.TargetsHolder()
     holder.extend(self._create_targets(slice(None)))
     self._assertTargetsDictEqual(holder.get_targets_as_dict(req_range),
                                  exp_targets)
Beispiel #3
0
 def test_get_targets_as_arraylike_with_indexes_list(self):
     req_idx = [0, 2]
     targets_dict = self._create_targets(req_idx)
     exp_targets = (targets_dict['classification'], )
     holder = targ.TargetsHolder()
     holder.extend(self._create_targets(slice(None)))
     self._assertTargetsArraylikeEqual(
         holder.get_targets_as_arraylike(req_idx), exp_targets)
Beispiel #4
0
 def test_get_targets_as_arraylike_with_range(self):
     req_range = range(1, 3)
     targets_dict = self._create_targets(req_range)
     exp_targets = (targets_dict['classification'], )
     holder = targ.TargetsHolder()
     holder.extend(self._create_targets(slice(None)))
     self._assertTargetsArraylikeEqual(
         holder.get_targets_as_arraylike(req_range), exp_targets)
Beispiel #5
0
 def test_get_targets_as_arraylike_with_slice(self):
     req_slice = slice(0, 2)
     targets = self._create_targets(req_slice)
     exp_targets = (targets['classification'], )
     holder = targ.TargetsHolder()
     holder.extend(self._create_targets(slice(None)))
     self._assertTargetsArraylikeEqual(
         holder.get_targets_as_arraylike(req_slice), exp_targets)
Beispiel #6
0
 def __init__(self, name, packet_shape, resizable=True, dtype=np.uint8,
              item_types={'raw': True, 'yx': False, 'gtux': False,
                          'gtuy': False}):
     self._data = dat.DataHolder(packet_shape, item_types=item_types,
                                 dtype=dtype)
     self._targ = targ.TargetsHolder()
     self._meta = meta.MetadataHolder()
     self._num_data = 0
     self.resizable = True
     self.name = name
Beispiel #7
0
 def test_shuffle(self):
     holder = targ.TargetsHolder()
     targets = {'classification': [[0, 0], [0, 1], [1, 0], [1, 1]]}
     holder.extend(targets)
     exp_targets = targets.copy()
     def shuffler(seq):
         temp = seq[0]
         seq[0] = seq[1]
         seq[1] = temp
     shuffler(exp_targets['classification'])
     holder.shuffle(shuffler, lambda: None)
     self._assertTargetsDictEqual(holder.get_targets_as_dict(), exp_targets)
Beispiel #8
0
 def test_get_targets_as_arraylike_empty(self):
     holder = targ.TargetsHolder()
     self._assertTargetsArraylikeEqual(holder.get_targets_as_arraylike(),
                                       ([], ))
Beispiel #9
0
 def test_get_targets_as_dict_empty(self):
     holder = targ.TargetsHolder()
     self._assertTargetsDictEqual(holder.get_targets_as_dict(),
                                  {'classification': [], })
Beispiel #10
0
 def test_length_with_items(self):
     holder = targ.TargetsHolder()
     targets = self._create_targets(slice(1, 4))
     holder.extend(targets)
     self.assertEqual(len(holder), 3)
Beispiel #11
0
 def test_length_empty(self):
     holder = targ.TargetsHolder()
     self.assertEqual(len(holder), 0)
Beispiel #12
0
 def test_append(self):
     target = self._create_targets(0)
     exp_target = {'classification': [target['classification']]}
     holder = targ.TargetsHolder()
     holder.append(target)
     self._assertTargetsDictEqual(holder.get_targets_as_dict(), exp_target)
Beispiel #13
0
 def test_extend(self):
     targets = self._create_targets(slice(None))
     exp_targets = {'classification': targets['classification']}
     holder = targ.TargetsHolder()
     holder.extend(targets)
     self._assertTargetsDictEqual(holder.get_targets_as_dict(), exp_targets)