Пример #1
0
 def test_resize_frame_grayscale(self, size):
     random_state.seed(160290)
     frame = random_state.randint(0,
                                  255,
                                  size=size + (3, ),
                                  dtype=numpy.uint8)
     resized = resize_frame(frame, size[1], size[0], "L")
     assert size == resized.shape
Пример #2
0
 def test_resize_frame_rgb(self, size):
     random_state.seed(160290)
     frame = random_state.randint(0, 255, size=size, dtype=numpy.uint8)
     resized = resize_frame(frame,
                            width=size[1],
                            height=size[0],
                            mode="RGB")
     assert size == resized.shape
Пример #3
0
 def _add_best_to_exported(self,
                           walkers: ExportedWalkers) -> ExportedWalkers:
     """Override randomly one walker of the target :class:`ExportedWalkers` \
     with the best walker found."""
     index = random_state.randint(0, len(walkers))
     walkers.rewards[index] = self.best.rewards
     walkers.id_walkers[index] = self.best.id_walkers
     walkers.observs[index] = self.best.observs
     walkers.states[index] = self.best.states
     return walkers
Пример #4
0
    def export_walkers(self) -> ExportedWalkers:
        """
        Return a :class`ExportedWalkers` sampled randomly from the internal \
        buffer.

        If ``self.add_global_best`` is ``True`` the best walker found will be \
        included in the returned :class:`ExportedWalkers`.
        """

        index = random_state.randint(0, len(self))
        walkers = self.buffer[index]
        if self.add_global_best:
            walkers = self._add_best_to_exported(walkers)
        return walkers