Ejemplo n.º 1
0
    def test_instructions_hash(self):
        """Test hashing for acquire instruction."""
        kernel_opts = {
            'start_window': 0,
            'stop_window': 10
        }
        kernel = configuration.Kernel(name='boxcar', **kernel_opts)

        discriminator_opts = {
            'neighborhoods': [{'qubits': 1, 'channels': 1}],
            'cal': 'coloring',
            'resample': False
        }
        discriminator = configuration.Discriminator(
            name='linear_discriminator', **discriminator_opts)
        acq_1 = instructions.Acquire(10,
                                     channels.AcquireChannel(0),
                                     channels.MemorySlot(0),
                                     kernel=kernel,
                                     discriminator=discriminator,
                                     name='acquire')
        acq_2 = instructions.Acquire(10,
                                     channels.AcquireChannel(0),
                                     channels.MemorySlot(0),
                                     kernel=kernel,
                                     discriminator=discriminator,
                                     name='acquire')

        hash_1 = hash(acq_1)
        hash_2 = hash(acq_2)

        self.assertEqual(hash_1, hash_2)
    def test_can_construct_valid_acquire_command(self):
        """Test if valid acquire command can be constructed."""
        kernel_opts = {"start_window": 0, "stop_window": 10}
        kernel = configuration.Kernel(name="boxcar", **kernel_opts)

        discriminator_opts = {
            "neighborhoods": [{
                "qubits": 1,
                "channels": 1
            }],
            "cal": "coloring",
            "resample": False,
        }
        discriminator = configuration.Discriminator(
            name="linear_discriminator", **discriminator_opts)

        acq = instructions.Acquire(
            10,
            channels.AcquireChannel(0),
            channels.MemorySlot(0),
            kernel=kernel,
            discriminator=discriminator,
            name="acquire",
        )

        self.assertEqual(acq.duration, 10)
        self.assertEqual(acq.discriminator.name, "linear_discriminator")
        self.assertEqual(acq.discriminator.params, discriminator_opts)
        self.assertEqual(acq.kernel.name, "boxcar")
        self.assertEqual(acq.kernel.params, kernel_opts)
        self.assertIsInstance(acq.id, int)
        self.assertEqual(acq.name, "acquire")
        self.assertEqual(
            acq.operands,
            (10, channels.AcquireChannel(0), channels.MemorySlot(0), None))
Ejemplo n.º 3
0
    def test_can_construct_valid_acquire_command(self):
        """Test if valid acquire command can be constructed."""
        kernel_opts = {
            'start_window': 0,
            'stop_window': 10
        }
        kernel = configuration.Kernel(name='boxcar', **kernel_opts)

        discriminator_opts = {
            'neighborhoods': [{'qubits': 1, 'channels': 1}],
            'cal': 'coloring',
            'resample': False
        }
        discriminator = configuration.Discriminator(name='linear_discriminator',
                                                    **discriminator_opts)

        acq = instructions.Acquire(10,
                                   channels.AcquireChannel(0),
                                   channels.MemorySlot(0),
                                   kernel=kernel,
                                   discriminator=discriminator,
                                   name='acquire')

        self.assertEqual(acq.duration, 10)
        self.assertEqual(acq.discriminator.name, 'linear_discriminator')
        self.assertEqual(acq.discriminator.params, discriminator_opts)
        self.assertEqual(acq.kernel.name, 'boxcar')
        self.assertEqual(acq.kernel.params, kernel_opts)
        self.assertIsInstance(acq.id, int)
        self.assertEqual(acq.name, 'acquire')
        self.assertEqual(acq.operands, (10,
                                        channels.AcquireChannel(0),
                                        channels.MemorySlot(0), None))
    def test_instructions_hash(self):
        """Test hashing for acquire instruction."""
        kernel_opts = {"start_window": 0, "stop_window": 10}
        kernel = configuration.Kernel(name="boxcar", **kernel_opts)

        discriminator_opts = {
            "neighborhoods": [{
                "qubits": 1,
                "channels": 1
            }],
            "cal": "coloring",
            "resample": False,
        }
        discriminator = configuration.Discriminator(
            name="linear_discriminator", **discriminator_opts)
        acq_1 = instructions.Acquire(
            10,
            channels.AcquireChannel(0),
            channels.MemorySlot(0),
            kernel=kernel,
            discriminator=discriminator,
            name="acquire",
        )
        acq_2 = instructions.Acquire(
            10,
            channels.AcquireChannel(0),
            channels.MemorySlot(0),
            kernel=kernel,
            discriminator=discriminator,
            name="acquire",
        )

        hash_1 = hash(acq_1)
        hash_2 = hash(acq_2)

        self.assertEqual(hash_1, hash_2)