Exemplo n.º 1
0
    def test_EllipticalMask2DwithAnchorAndCenteredLayer(self):
        """Anchored elliptical mask contains correct node IDs when layer is not
        centered around origo"""

        cntr = [5.0, 5.0]

        layer = nest.Create('iaf_psc_alpha',
                            positions=nest.spatial.grid(shape=[5, 5],
                                                        extent=[5., 5.],
                                                        center=cntr))
        maskdict = {'major_axis': 3.0, 'minor_axis': 1.0}
        mask = nest.CreateMask('elliptical', maskdict)

        node_ids = nest.SelectNodesByMask(layer, cntr, mask)

        self.assertEqual(node_ids, nest.NodeCollection((
            8,
            13,
            18,
        )))

        maskdict = {'major_axis': 3.0, 'minor_axis': 1.0, 'anchor': [1., 1.]}
        mask = nest.CreateMask('elliptical', maskdict)

        node_ids = nest.SelectNodesByMask(layer, cntr, mask)

        self.assertEqual(node_ids, nest.NodeCollection((
            12,
            17,
            22,
        )))
Exemplo n.º 2
0
    def test_EllipticalMask2D(self):
        """Simple elliptical mask contains the correct node IDs"""

        layer = nest.Create('iaf_psc_alpha',
                            positions=nest.spatial.grid(shape=[11, 11],
                                                        extent=[11., 11.]))
        maskdict = {'major_axis': 2.0, 'minor_axis': 1.0}
        mask = nest.CreateMask('elliptical', maskdict)

        cntr = [0.0, 0.0]

        node_ids = nest.SelectNodesByMask(layer, cntr, mask)

        self.assertEqual(node_ids, nest.NodeCollection((
            50,
            61,
            72,
        )))

        maskdict = {'major_axis': 6.0, 'minor_axis': 3.0}
        mask = nest.CreateMask('elliptical', maskdict)

        node_ids = nest.SelectNodesByMask(layer, cntr, mask)

        self.assertEqual(
            node_ids,
            nest.NodeCollection([
                28, 38, 39, 40, 49, 50, 51, 60, 61, 62, 71, 72, 73, 82, 83, 84,
                94
            ]))
Exemplo n.º 3
0
    def test_RotatedBoxOutsideOrigin(self):
        """Test rotated box where the mask does not contain the origin."""

        pos = [[x * 1., y * 1., z * 1.] for x in range(-2, 3)
               for y in range(-2, 3) for z in range(-2, 3)]

        layer = nest.Create('iaf_psc_alpha', positions=nest.spatial.free(pos))

        # First test that we get the correct node IDs when our mask does not
        # contain the origin.
        maskdict = {
            'lower_left': [-2.0, -1.0, 0.5],
            'upper_right': [-0.5, -0.5, 2.0]
        }
        mask = nest.CreateMask('box', maskdict)
        cntr = [0., 0., 0.]
        node_ids = nest.SelectNodesByMask(layer, cntr, mask)

        self.assertEqual(node_ids, nest.NodeCollection((
            9,
            10,
            34,
            35,
        )))

        # Test that we get the correct node IDs with a azimuth rotation angle of 45
        # degrees when the mask does not contain the origin.
        maskdict = {
            'lower_left': [-2.5, -1.0, 0.5],
            'upper_right': [-0.5, -0.5, 2.5],
            'azimuth_angle': 45.0
        }
        mask = nest.CreateMask('box', maskdict)
        node_ids = nest.SelectNodesByMask(layer, cntr, mask)

        self.assertEqual(node_ids, nest.NodeCollection((
            9,
            10,
            39,
            40,
        )))

        # Test that we get the correct node IDs with a polar rotation angle of 45
        # degrees when the mask does not contain the origin.
        maskdict = {
            'lower_left': [-1.5, -2.5, 0.5],
            'upper_right': [-1.0, -0.5, 2.5],
            'polar_angle': 45.0
        }
        mask = nest.CreateMask('box', maskdict)
        node_ids = nest.SelectNodesByMask(layer, cntr, mask)

        self.assertEqual(node_ids, nest.NodeCollection((
            4,
            9,
            30,
            35,
        )))
Exemplo n.º 4
0
    def test_TiltedEllipticalMask2DWithAnchor(self):
        """Tilted and anchored elliptical mask contains the correct node IDs"""

        layer = nest.Create('iaf_psc_alpha',
                            positions=nest.spatial.grid(shape=[11, 11],
                                                        extent=[11., 11.]))
        maskdict = {
            'major_axis': 3.0,
            'minor_axis': 1.0,
            'anchor': [3., 3.],
            'azimuth_angle': 45.
        }
        mask = nest.CreateMask('elliptical', maskdict)

        cntr = [0.0, 0.0]

        node_ids = nest.SelectNodesByMask(layer, cntr, mask)

        self.assertEqual(node_ids, nest.NodeCollection((
            81,
            91,
            101,
        )))

        maskdict = {
            'major_axis': 6.0,
            'minor_axis': 3.0,
            'anchor': [-1.5, 1.],
            'azimuth_angle': 135.
        }
        mask = nest.CreateMask('elliptical', maskdict)

        node_ids = nest.SelectNodesByMask(layer, cntr, mask)

        self.assertEqual(
            node_ids,
            nest.NodeCollection(
                [25, 26, 27, 36, 37, 38, 39, 48, 49, 50, 51, 60, 61, 62]))

        maskdict = {
            'major_axis': 8.0,
            'minor_axis': 3.0,
            'anchor': [0., 1.],
            'azimuth_angle': 90.
        }
        mask = nest.CreateMask('elliptical', maskdict)

        node_ids = nest.SelectNodesByMask(layer, cntr, mask)

        self.assertEqual(
            node_ids,
            nest.NodeCollection([
                47, 48, 49, 50, 51, 56, 57, 58, 59, 60, 61, 62, 63, 64, 69, 70,
                71, 72, 73
            ]))
Exemplo n.º 5
0
    def test_SelectNodesByMaskIn3D(self):
        """Test SelectNodesByMask for rectangular mask in 3D layer"""

        pos = [[x * 1., y * 1., z * 1.] for x in range(-5, 6)
               for y in range(-5, 6) for z in range(-5, 6)]
        layer = nest.Create('iaf_psc_alpha', positions=nest.spatial.free(pos))

        maskdict = {
            'lower_left': [-6., -6., -6.],
            'upper_right': [-4., -4., -4.]
        }
        mask = nest.CreateMask('box', maskdict)

        cntr = [0., 0., 0.]

        node_ids = nest.SelectNodesByMask(layer, cntr, mask)

        self.assertEqual(
            node_ids, nest.NodeCollection((
                1,
                2,
                12,
                13,
                122,
                123,
                133,
                134,
            )))
Exemplo n.º 6
0
    def test_EllipticalMask2DWithAnchor(self):
        """Anchored elliptical mask contains the correct node IDs"""

        layer = nest.Create('iaf_psc_alpha',
                            positions=nest.spatial.grid(shape=[11, 11],
                                                        extent=[11., 11.]))
        maskdict = {'major_axis': 6.0, 'minor_axis': 3.0, 'anchor': [-2., -2.]}
        mask = nest.CreateMask('elliptical', maskdict)

        cntr = [0.0, 0.0]

        node_ids = nest.SelectNodesByMask(layer, cntr, mask)

        self.assertEqual(
            node_ids,
            nest.NodeCollection((
                8,
                18,
                19,
                20,
                29,
                30,
                31,
                40,
                41,
                42,
                51,
                52,
                53,
                62,
                63,
                64,
                74,
            )))
Exemplo n.º 7
0
    def test_TiltedEllipsoidalMask3DWithAnchor(self):
        """Tilted and anchored ellipsoidal mask contains the correct node IDs"""

        pos = [[x * 1., y * 1., z * 1.] for x in range(-5, 6)
               for y in range(-5, 6) for z in range(-5, 6)]
        layer = nest.Create('iaf_psc_alpha', positions=nest.spatial.free(pos))

        maskdict = {
            'major_axis': 4.0,
            'minor_axis': 1.0,
            'polar_axis': 1.0,
            'anchor': [-5., -5., -4.]
        }
        mask = nest.CreateMask('ellipsoidal', maskdict)

        cntr = [0., 0., 0.]

        node_ids = nest.SelectNodesByMask(layer, cntr, mask)

        self.assertEqual(node_ids, nest.NodeCollection((
            2,
            123,
            244,
        )))

        maskdict = {
            'major_axis': 4.,
            'minor_axis': 1.,
            'polar_axis': 1.,
            'anchor': [-4., -4., -4.],
            'azimuth_angle': 45.
        }
        mask = nest.CreateMask('ellipsoidal', maskdict)

        cntr = [0., 0., 0.]

        node_ids = nest.SelectNodesByMask(layer, cntr, mask)

        self.assertEqual(node_ids, nest.NodeCollection((
            2,
            134,
            266,
        )))
Exemplo n.º 8
0
    def test_SelectNodesByMaskIn2D(self):
        """Test SelectNodesByMask for rectangular mask in 2D layer"""

        layer = nest.Create('iaf_psc_alpha',
                            positions=nest.spatial.grid(shape=[11, 11],
                                                        extent=[11., 11.]))
        maskdict = {'lower_left': [-2., -1.], 'upper_right': [2., 1.]}
        mask = nest.CreateMask('rectangular', maskdict)

        cntr = [0.0, 0.0]

        node_ids = nest.SelectNodesByMask(layer, cntr, mask)

        self.assertEqual(
            node_ids,
            nest.NodeCollection(
                [38, 39, 40, 49, 50, 51, 60, 61, 62, 71, 72, 73, 82, 83, 84]))

        nest.ResetKernel()

        cntr = [3., 3.]

        layer = nest.Create('iaf_psc_alpha',
                            positions=nest.spatial.grid(shape=[5, 5],
                                                        extent=[11., 11.],
                                                        center=cntr))
        maskdict = {'lower_left': [1., 1.], 'upper_right': [5., 5.]}
        mask = nest.CreateMask('rectangular', maskdict)

        node_ids = nest.SelectNodesByMask(layer, cntr, mask)

        self.assertEqual(node_ids, nest.NodeCollection((
            16,
            17,
            21,
            22,
        )))
Exemplo n.º 9
0
    def test_EllipsoidalMask3D(self):
        """Simple ellipsoidal mask contains the correct node IDs"""

        pos = [[x * 1., y * 1., z * 1.] for x in range(-5, 6)
               for y in range(-5, 6) for z in range(-5, 6)]
        layer = nest.Create('iaf_psc_alpha', positions=nest.spatial.free(pos))

        maskdict = {'major_axis': 3.0, 'minor_axis': 1.0, 'polar_axis': 1.0}
        mask = nest.CreateMask('ellipsoidal', maskdict)

        cntr = [0., 0., 0.]

        node_ids = nest.SelectNodesByMask(layer, cntr, mask)

        self.assertEqual(node_ids, nest.NodeCollection((
            545,
            666,
            787,
        )))

        maskdict = {
            'major_axis': 3.0,
            'minor_axis': 1.0,
            'polar_axis': 1.0,
            'azimuth_angle': 90.
        }
        mask = nest.CreateMask('ellipsoidal', maskdict)

        cntr = [0., 0., 0.]

        node_ids = nest.SelectNodesByMask(layer, cntr, mask)

        self.assertEqual(node_ids, nest.NodeCollection((
            655,
            666,
            677,
        )))
Exemplo n.º 10
0
    def test_RotatedBoxMaskByAzimuthAndPolarAngle(self):
        """Test rotated box mask with azimuth and polar angle."""

        pos = [[x * 1., y * 1., z * 1.] for x in range(-2, 3)
               for y in range(-2, 3) for z in range(-2, 3)]

        layer = nest.Create('iaf_psc_alpha', positions=nest.spatial.free(pos))

        # Test with a azimuth angle and polar angle of 45 degrees.
        maskdict = {
            'lower_left': [-0.5, -1.5, -1.5],
            'upper_right': [0.5, 1.5, 1.5],
            'azimuth_angle': 45.,
            'polar_angle': 45.
        }
        mask = nest.CreateMask('box', maskdict)
        cntr = [0., 0., 0.]
        node_ids = nest.SelectNodesByMask(layer, cntr, mask)

        self.assertEqual(
            node_ids,
            nest.NodeCollection([37, 38, 43, 57, 58, 63, 68, 69, 83, 88, 89]))
Exemplo n.º 11
0
    def test_CreateEllipticalMask2D(self):
        """Creates simple elliptical mask"""
        mask_dict = {'major_axis': 6.0, 'minor_axis': 3.0}
        mask = nest.CreateMask('elliptical', mask_dict)

        self.assertTrue(mask.Inside([0.0, 0.0]))
Exemplo n.º 12
0
    def test_TiltedEllipsoidalMask(self):
        """Ellipsoidal mask contains correct node IDs when tilted with respect to
        x-axis and z-axis"""

        pos = [[x * 1., y * 1., z * 1.] for x in range(-2, 3)
               for y in range(-2, 3) for z in range(-2, 3)]

        layer = nest.Create('iaf_psc_alpha', positions=nest.spatial.free(pos))

        maskdict = {
            'major_axis': 3.0,
            'minor_axis': 1.0,
            'polar_axis': 1.0,
            'polar_angle': 90.
        }
        mask = nest.CreateMask('ellipsoidal', maskdict)

        cntr = [0., 0., 0.]

        node_ids = nest.SelectNodesByMask(layer, cntr, mask)

        self.assertEqual(node_ids, nest.NodeCollection((
            62,
            63,
            64,
        )))

        nest.ResetKernel()

        pos = [[x * 1., y * 1., z * 1.] for x in range(-2, 3)
               for y in range(-2, 3) for z in range(-2, 3)]

        layer = nest.Create('iaf_psc_alpha', positions=nest.spatial.free(pos))

        maskdict = {
            'major_axis': 4.0,
            'minor_axis': 1.,
            'polar_axis': 1.5,
            'azimuth_angle': 45.,
            'polar_angle': 45.
        }
        mask = nest.CreateMask('ellipsoidal', maskdict)

        cntr = [0., 0., 0.]

        node_ids = nest.SelectNodesByMask(layer, cntr, mask)

        self.assertEqual(node_ids, nest.NodeCollection([34, 63, 92]))

        nest.ResetKernel()

        layer = nest.Create('iaf_psc_alpha', positions=nest.spatial.free(pos))

        maskdict = {
            'major_axis': 3.0,
            'minor_axis': 2.,
            'polar_axis': 1.0,
            'polar_angle': 45.
        }
        mask = nest.CreateMask('ellipsoidal', maskdict)

        cntr = [0., 0., 0.]

        node_ids = nest.SelectNodesByMask(layer, cntr, mask)

        self.assertEqual(node_ids, nest.NodeCollection([39, 58, 63, 68, 87]))

        nest.ResetKernel()

        layer = nest.Create('iaf_psc_alpha', positions=nest.spatial.free(pos))

        maskdict = {
            'major_axis': 4.0,
            'minor_axis': 1.,
            'polar_axis': 1.5,
            'polar_angle': 30.
        }
        mask = nest.CreateMask('ellipsoidal', maskdict)

        cntr = [0., 0., 0.]

        node_ids = nest.SelectNodesByMask(layer, cntr, mask)

        self.assertEqual(node_ids, nest.NodeCollection([38, 39, 63, 87, 88]))

        nest.ResetKernel()

        layer = nest.Create('iaf_psc_alpha', positions=nest.spatial.free(pos))

        maskdict = {
            'major_axis': 4.0,
            'minor_axis': 2.5,
            'polar_axis': 1.0,
            'azimuth_angle': 45.,
            'polar_angle': 30.
        }
        mask = nest.CreateMask('ellipsoidal', maskdict)

        cntr = [0., 0., 0.]

        node_ids = nest.SelectNodesByMask(layer, cntr, mask)

        self.assertEqual(node_ids,
                         nest.NodeCollection([34, 38, 58, 63, 68, 88, 92]))
Exemplo n.º 13
0
    def test_RotatedRectangularMask(self):
        """Test rotated rectangular mask.

            We have:
                lower_left:  [-1., -0.5]
                upper_right: [ 1.,  0.5]

            So, if we have:

            layer:
            2  7  12  17  22
            3  8  13  18  23
            4  9  14  19  24
            5  10 15  20  25
            6  11 16  21  26

            and have azimuth_angle = 0, we should get node IDs 9, 14, 19 if we
            select node IDs by mask.
            If we have azimuth_angle = 90, we should get node IDs 13, 14, 15.
        """

        # Test 2D layer
        layer = nest.Create('iaf_psc_alpha',
                            positions=nest.spatial.grid(shape=[5, 5],
                                                        extent=[5., 5.]))

        # First test without rotation.
        maskdict = {'lower_left': [-1., -0.5], 'upper_right': [1., 0.5]}
        mask = nest.CreateMask('rectangular', maskdict)
        cntr = [0., 0.]
        node_ids = nest.SelectNodesByMask(layer, cntr, mask)

        self.assertEqual(node_ids, nest.NodeCollection((
            8,
            13,
            18,
        )))

        # Test if we get correct node IDs when rotating 90 degrees.
        maskdict = {
            'lower_left': [-1., -0.5],
            'upper_right': [1., 0.5],
            'azimuth_angle': 90.0
        }
        mask = nest.CreateMask('rectangular', maskdict)
        node_ids = nest.SelectNodesByMask(layer, cntr, mask)

        self.assertEqual(node_ids, nest.NodeCollection((
            12,
            13,
            14,
        )))

        # Test rotation with an azimuth angle of 45 degrees.
        maskdict = {
            'lower_left': [-1.5, -0.5],
            'upper_right': [1.5, 0.5],
            'azimuth_angle': 45.0
        }
        mask = nest.CreateMask('rectangular', maskdict)
        node_ids = nest.SelectNodesByMask(layer, cntr, mask)

        self.assertEqual(node_ids, nest.NodeCollection((
            9,
            13,
            17,
        )))

        # Test rotation with an azimuth angle of 135 degrees.
        maskdict = {
            'lower_left': [-1.5, -0.5],
            'upper_right': [1.5, 0.5],
            'azimuth_angle': 135.0
        }
        mask = nest.CreateMask('rectangular', maskdict)
        node_ids = nest.SelectNodesByMask(layer, cntr, mask)

        self.assertEqual(node_ids, nest.NodeCollection((
            7,
            13,
            19,
        )))

        # Test that an error is raised if we send in a polar angle to a 2D
        # mask.
        maskdict = {
            'lower_left': [-1.5, -0.5],
            'upper_right': [1.5, 0.5],
            'polar_angle': 45.0
        }
        with self.assertRaises(nest.kernel.NESTError):
            mask = nest.CreateMask('rectangular', maskdict)
Exemplo n.º 14
0
    def test_RotatedRectangleOutsideOrigin(self):
        """
        Test rotated rectangle where the mask does not contain the origin.
        """

        layer = nest.Create('iaf_psc_alpha',
                            positions=nest.spatial.grid(shape=[11, 11],
                                                        extent=[11., 11.]))

        # First test that we get the correct node IDs when our mask does not
        # contain the origin.
        maskdict = {'lower_left': [1., 1.], 'upper_right': [4., 2.]}
        mask = nest.CreateMask('rectangular', maskdict)
        cntr = [0., 0.]
        node_ids = nest.SelectNodesByMask(layer, cntr, mask)

        self.assertEqual(
            node_ids, nest.NodeCollection((
                70,
                71,
                81,
                82,
                92,
                93,
                103,
                104,
            )))

        # Then test that we get the correct node IDs with a azimuth rotation angle
        # of 45 degrees when the mask does not contain the origin.
        maskdict = {
            'lower_left': [0.5, 0.5],
            'upper_right': [4.5, 2.5],
            'azimuth_angle': 45.0
        }
        mask = nest.CreateMask('rectangular', maskdict)
        node_ids = nest.SelectNodesByMask(layer, cntr, mask)

        self.assertEqual(
            node_ids, nest.NodeCollection((
                71,
                81,
                82,
                83,
                91,
                92,
                93,
                103,
            )))

        # Test that we get the correct node IDs with a azimuth rotation angle
        # of 90 degrees when the mask does not contain the origin.
        maskdict = {
            'lower_left': [1.0, 1.0],
            'upper_right': [4.0, 2.0],
            'azimuth_angle': 90.0
        }
        mask = nest.CreateMask('rectangular', maskdict)
        node_ids = nest.SelectNodesByMask(layer, cntr, mask)

        self.assertEqual(
            node_ids, nest.NodeCollection((
                80,
                81,
                82,
                83,
                91,
                92,
                93,
                94,
            )))
Exemplo n.º 15
0
    def test_RotatedBoxMaskByPolarAngle(self):
        """Test rotated box mask with polar angle."""

        pos = [[x * 1., y * 1., z * 1.] for x in range(-2, 3)
               for y in range(-2, 3) for z in range(-2, 3)]

        layer = nest.Create('iaf_psc_alpha', positions=nest.spatial.free(pos))

        # First test without rotation
        maskdict = {
            'lower_left': [-0.5, -1.0, -1.0],
            'upper_right': [0.5, 1.0, 1.0]
        }
        mask = nest.CreateMask('box', maskdict)
        cntr = [0., 0., 0.]
        node_ids = nest.SelectNodesByMask(layer, cntr, mask)
        self.assertEqual(
            node_ids, nest.NodeCollection([57, 58, 59, 62, 63, 64, 67, 68,
                                           69]))

        # Test with a polar angle of 90 degrees.
        maskdict = {
            'lower_left': [-0.5, -1.0, -1.0],
            'upper_right': [0.5, 1.0, 1.0],
            'polar_angle': 90.
        }
        mask = nest.CreateMask('box', maskdict)
        node_ids = nest.SelectNodesByMask(layer, cntr, mask)
        self.assertEqual(
            node_ids, nest.NodeCollection([33, 38, 43, 58, 63, 68, 83, 88,
                                           93]))

        # Test with a polar angle of 180 degrees, should be the same as the
        # one without a polar angle.
        maskdict = {
            'lower_left': [-0.5, -1.0, -1.0],
            'upper_right': [0.5, 1.0, 1.0],
            'polar_angle': 180.
        }
        mask = nest.CreateMask('box', maskdict)
        node_ids = nest.SelectNodesByMask(layer, cntr, mask)
        self.assertEqual(
            node_ids, nest.NodeCollection([57, 58, 59, 62, 63, 64, 67, 68,
                                           69]))

        # Test with a polar angle of 45 degrees.
        maskdict = {
            'lower_left': [-0.5, -1.5, -1.5],
            'upper_right': [0.5, 1.5, 1.5],
            'polar_angle': 45.
        }
        mask = nest.CreateMask('box', maskdict)
        node_ids = nest.SelectNodesByMask(layer, cntr, mask)
        self.assertEqual(
            node_ids, nest.NodeCollection([32, 37, 42, 58, 63, 68, 84, 89,
                                           94]))

        # Test with a polar angle of 135 degrees. The node IDs should be
        # perpendicular to the ones obtained by a polar angle of 45 degrees.
        maskdict = {
            'lower_left': [-0.5, -1.5, -1.5],
            'upper_right': [0.5, 1.5, 1.5],
            'polar_angle': 135.
        }
        mask = nest.CreateMask('box', maskdict)
        node_ids = nest.SelectNodesByMask(layer, cntr, mask)

        self.assertEqual(
            node_ids, nest.NodeCollection([34, 39, 44, 58, 63, 68, 82, 87,
                                           92]))

        # Test two symmetric masks in x and z direction. One with no polar
        # angle and one with a polar angle of 90 degrees. As the masks are
        # symmetrical in  x and z, a polar angle of 90 degrees should give the
        # same node IDs as the one without a polar angle.
        maskdict = {
            'lower_left': [-1., -0.5, -1.],
            'upper_right': [1., 0.5, 1.]
        }
        mask = nest.CreateMask('box', maskdict)
        node_ids_2 = nest.SelectNodesByMask(layer, cntr, mask)

        self.assertEqual(
            node_ids_2,
            nest.NodeCollection([37, 38, 39, 62, 63, 64, 87, 88, 89]))

        maskdict = {
            'lower_left': [-1., -0.5, -1.],
            'upper_right': [1., 0.5, 1.],
            'polar_angle': 90.
        }
        mask = nest.CreateMask('box', maskdict)
        node_ids = nest.SelectNodesByMask(layer, cntr, mask)
        self.assertEqual(
            node_ids, nest.NodeCollection([37, 38, 39, 62, 63, 64, 87, 88,
                                           89]))

        self.assertEqual(node_ids_2, node_ids)
Exemplo n.º 16
0
    def test_RotatedBoxMaskByAzimuthAngle(self):
        """Test rotated box mask with azimuth angle."""
        # Test a 3D layer.
        pos = [[x * 1., y * 1., z * 1.] for x in range(-2, 3)
               for y in range(-2, 3) for z in range(-2, 3)]

        layer = nest.Create('iaf_psc_alpha', positions=nest.spatial.free(pos))

        # First test that we get correct node IDs with box mask that is not
        # rotated.
        maskdict = {
            'lower_left': [-1., -0.5, -0.5],
            'upper_right': [1., 0.5, 0.5]
        }
        mask = nest.CreateMask('box', maskdict)
        cntr = [0., 0., 0.]
        node_ids = nest.SelectNodesByMask(layer, cntr, mask)

        self.assertEqual(node_ids, nest.NodeCollection((
            38,
            63,
            88,
        )))

        # Test with a larger box mask.
        maskdict = {
            'lower_left': [-1., -0.5, -1.],
            'upper_right': [1., 0.5, 1.]
        }
        mask = nest.CreateMask('box', maskdict)
        node_ids = nest.SelectNodesByMask(layer, cntr, mask)
        self.assertEqual(
            node_ids, nest.NodeCollection([37, 38, 39, 62, 63, 64, 87, 88,
                                           89]))

        # Test the smaller box mask with a rotation of 90 degrees. Only test
        # the azimuth angle, not the polar angle.
        maskdict = {
            'lower_left': [-1., -0.5, -0.5],
            'upper_right': [1., 0.5, 0.5],
            'azimuth_angle': 90.
        }
        mask = nest.CreateMask('box', maskdict)
        node_ids = nest.SelectNodesByMask(layer, cntr, mask)

        self.assertEqual(node_ids, nest.NodeCollection((
            58,
            63,
            68,
        )))

        # Test rotation of the larger box with an azimuth angle of 90 degrees.
        maskdict = {
            'lower_left': [-1., -0.5, -1.],
            'upper_right': [1., 0.5, 1.],
            'azimuth_angle': 90.
        }
        mask = nest.CreateMask('box', maskdict)
        node_ids = nest.SelectNodesByMask(layer, cntr, mask)
        self.assertEqual(
            node_ids, nest.NodeCollection([57, 58, 59, 62, 63, 64, 67, 68,
                                           69]))