def iterator(self):
        for i in range_(self.num):
            p = Point()
            p.positions[self.names[0]], p.positions[self.names[1]] = self._calc(i)
            p.lower[self.names[0]], p.lower[self.names[1]] = self._calc(i - 0.5)
            p.upper[self.names[0]], p.upper[self.names[1]] = self._calc(i + 0.5)
            p.indexes = [i]

            yield p
    def iterator(self):
        for i in range_(self.num):
            p = Point()
            p.positions[self.names[0]], p.positions[
                self.names[1]] = self._calc(i)
            p.lower[self.names[0]], p.lower[self.names[1]] = self._calc(i -
                                                                        0.5)
            p.upper[self.names[0]], p.upper[self.names[1]] = self._calc(i +
                                                                        0.5)
            p.indexes = [i]

            yield p
    def iterator(self):

        for i in range_(self.num):
            point = Point()

            for axis_index in range_(self.num_axes):
                point.positions[self.name[axis_index]] = self._calc(i, axis_index)
                point.lower[self.name[axis_index]] = self._calc(i - 0.5, axis_index)
                point.upper[self.name[axis_index]] = self._calc(i + 0.5, axis_index)

            point.indexes = [i]
            yield point
    def iterator(self):
        for i in range_(0, self._end_point(self.radius) + 1):
            p = Point()
            p.indexes = [i]

            i += 0.5  # Offset so lower bound of first point is not less than 0

            p.positions[self.names[0]], p.positions[self.names[1]] = self._calc(i)
            p.upper[self.names[0]], p.upper[self.names[1]] = self._calc(i + 0.5)
            p.lower[self.names[0]], p.lower[self.names[1]] = self._calc(i - 0.5)

            yield p
Exemple #5
0
    def iterator(self):
        for i in range_(0, self._end_point(self.radius) + 1):
            p = Point()
            p.indexes = [i]

            i += 0.5  # Offset so lower bound of first point is not less than 0

            p.positions[self.names[0]], p.positions[
                self.names[1]] = self._calc(i)
            p.upper[self.names[0]], p.upper[self.names[1]] = self._calc(i +
                                                                        0.5)
            p.lower[self.names[0]], p.lower[self.names[1]] = self._calc(i -
                                                                        0.5)

            yield p
    def iterator(self):

        for i in range_(self.num):
            point = Point()

            for axis_index in range_(self.num_axes):
                axis_name = self.name[axis_index]
                start = self.start[axis_index]
                step = self.step[axis_index]

                point.positions[axis_name] = start + i * step
                point.lower[axis_name] = start + (i - 0.5) * step
                point.upper[axis_name] = start + (i + 0.5) * step

            point.indexes = [i]
            yield point
Exemple #7
0
    def test_stationary_profile_is_two_points(self):
        # Create the two points the same as each other
        position = {"sample_y": 1.0, "sample_x": 1.5}
        point = Point()
        point.lower = position
        point.positions = position
        point.upper = position
        point.duration = 0.1

        # Turnaround interval on P99
        min_turnaround = 0.002
        min_interval = 0.002

        time_arrays, velocity_arrays = profile_between_points(
            self.axis_mapping,
            point,
            point,
            min_time=min_turnaround,
            min_interval=min_interval,
        )

        expected_time_arrays = {
            "sample_x": [0.0, 0.002],
            "sample_y": [0.0, 0.002],
        }
        expected_velocity_arrays = {
            "sample_x": [0.0, 0.0],
            "sample_y": [0.0, 0.0],
        }
        self.assertEqual(time_arrays, expected_time_arrays)
        self.assertEqual(velocity_arrays, expected_velocity_arrays)
Exemple #8
0
    def _base_iterator(self):
        """
        Iterator to generate points by nesting each generator in self.generators

        Yields:
            Point: Base points
        """

        for point_num in range_(self.num):

            point = Point()
            for gen_index, points in enumerate(self.point_sets):
                axis_period = self.periods[gen_index]
                axis_length = len(points)
                # Can't use index_dims in case they have been flattened
                # by an excluder

                point_index = \
                    (point_num / (axis_period / axis_length)) % axis_length
                loop_number = point_num / axis_period

                # Floor floats to ints for indexing
                point_index = int(point_index)
                loop_number = int(loop_number)
                if self.alternate_direction[gen_index] and loop_number % 2:
                    point_index = (axis_length - 1) - point_index
                    reverse = True
                else:
                    reverse = False

                current_point = points[point_index]

                # If innermost generator, use bounds
                if gen_index == len(self.point_sets) - 1:
                    point.positions.update(current_point.positions)
                    if reverse:  # Swap bounds if reversing
                        point.upper.update(current_point.lower)
                        point.lower.update(current_point.upper)
                    else:
                        point.upper.update(current_point.upper)
                        point.lower.update(current_point.lower)
                else:
                    point.positions.update(current_point.positions)
                    point.upper.update(current_point.positions)
                    point.lower.update(current_point.positions)

                point.indexes += current_point.indexes

                logging.debug("Current point positions and indexes")
                logging.debug([current_point.positions, current_point.indexes])

            yield point
    def iterator(self):

        for i in range_(self.num):

            point = Point()
            for axis, coordinate in enumerate(self.points[i]):
                point.positions[self.name[axis]] = coordinate

                if self.upper_bounds is None:
                    upper = self._calculate_upper_bound(i, axis, coordinate)
                else:
                    upper = self.upper_bounds[i][axis]
                point.upper[self.name[axis]] = upper

                if self.lower_bounds is None:
                    lower = self._calculate_lower_bound(i, axis, coordinate)
                else:
                    lower = self.lower_bounds[i][axis]
                point.lower[self.name[axis]] = lower

            point.indexes = [i]
            yield point
Exemple #10
0
    def iterator(self):

        for i in range_(self.num):

            point = Point()
            for axis, coordinate in enumerate(self.points[i]):
                point.positions[self.name[axis]] = coordinate

                if self.upper_bounds is None:
                    upper = self._calculate_upper_bound(i, axis, coordinate)
                else:
                    upper = self.upper_bounds[i][axis]
                point.upper[self.name[axis]] = upper

                if self.lower_bounds is None:
                    lower = self._calculate_lower_bound(i, axis, coordinate)
                else:
                    lower = self.lower_bounds[i][axis]
                point.lower[self.name[axis]] = lower

            point.indexes = [i]
            yield point
Exemple #11
0
 def point_gen():
     for n in range_(10):
         p = Point()
         p.indexes = [n]
         p.positions = {"x": n / 10.}
         p.lower = {"x": (n - 0.5) / 10.}
         p.upper = {"x": (n + 0.5) / 10.}
         yield p
Exemple #12
0
 def test_consistent_python_jython(self):
     p = Point()
     p.indexes = [0]
     p.positions = {"x": 1, "y": 2}
     p.lower = {"x": 0.5, "y": 1.75}
     p.upper = {"x": 1.5, "y": 2.25}
     m = RandomOffsetMutator(1, ["y"], [0.01])
     q = m.mutate(p, 0)
     # Generated with Python 3.7.3, but should be consistent with all Python/Jython
     self.assertAlmostEqual(2.00454337, q.positions["y"])
     self.assertAlmostEqual(2.25045721, q.upper["y"])
     self.assertAlmostEqual(1.74735178, q.lower["y"])
Exemple #13
0
    def iterator(self):

        for i in range_(self.num):
            point = Point()

            for axis_index in range_(self.num_axes):
                axis_name = self.name[axis_index]
                start = self.start[axis_index]
                step = self.step[axis_index]

                point.positions[axis_name] = start + i * step
                point.lower[axis_name] = start + (i - 0.5) * step
                point.upper[axis_name] = start + (i + 0.5) * step

            point.indexes = [i]
            yield point
Exemple #14
0
    def test_approximately_stationary_axis_results_in_2_profile_points(self):
        # The stationary point which causes a problem on P99 testing
        position = {"sample_y": 1.0000000000000888, "sample_x": 1.5}
        point = Point()
        point.lower = position
        point.positions = position
        point.upper = position
        point.duration = 0.1

        next_position = {"sample_y": 1.0000000000000666, "sample_x": 1.0}
        next_point = Point()
        next_point.lower = next_position
        next_point.positions = next_position
        next_point.upper = next_position
        next_point.duration = 0.1

        # Turnaround interval on P99
        min_turnaround = 0.002
        min_interval = 0.002

        time_arrays, velocity_arrays = profile_between_points(
            self.axis_mapping,
            point,
            next_point,
            min_time=min_turnaround,
            min_interval=min_interval,
        )

        expected_time_arrays = {
            "sample_x": [0.0, 0.1, 0.284, 0.384],
            "sample_y": [0.0, 0.384],
        }
        expected_velocity_arrays = {
            "sample_x": [0.0, -1.760563380282, -1.760563380282, 0.0],
            "sample_y": [0, 0],
        }
        self.assertEqual(time_arrays, expected_time_arrays)
        self.assertEqual(velocity_arrays, expected_velocity_arrays)