示例#1
0
    def add_standard_parameters(self):
        """
        Function to automatically generate the CC-Light specific functions
        from the qcodes parameters. The function uses the add_parameter
        function internally.
        """
        self.parameter_list = self._read_parameters()

        for parameter in self.parameter_list:
            name = parameter["name"]
            del parameter["name"]

            if ("vals" in parameter):
                validator = parameter["vals"]
                try:
                    val_type = validator["type"]

                    if (val_type == "Bool"):
                        parameter["vals"] = vals.Ints(0, 1)
                        parameter['get_parser'] = int

                    elif (val_type == "Non_Neg_Number"):
                        if ("range" in validator):
                            val_min = validator["range"][0]
                            val_max = validator["range"][1]
                        else:
                            val_min = 0
                            val_max = INT32_MAX

                        parameter["vals"] = vals.PermissiveInts(
                            val_min, val_max)
                        parameter['get_parser'] = int
                        parameter['set_parser'] = int

                    else:
                        log.warning("Failed to set the validator for the" +
                                    " parameter " + name + ", because of a" +
                                    " unknown validator type: '" + val_type +
                                    "'")

                except Exception as e:
                    log.warning(
                        "Failed to set the validator for the parameter " +
                        name + ".(%s)", str(e))

            try:
                log.info("Adding parameter:")
                for key, value in parameter.items():
                    log.info("\t", key, value)
                log.info("\n")

                self.add_parameter(name, **parameter)

            except Exception as e:
                log.warning(
                    "Failed to create the parameter " + name +
                    ", because of a unknown keyword in this" +
                    " parameter.(%s)", str(e))
示例#2
0
    def add_standard_parameters(self):
        """
        Function to automatically generate the QCC specific functions
        from the qcodes parameters. The function uses the add_parameter
        function internally.
        """
        self.parameter_list = self._read_parameters()

        for parameter in self.parameter_list:
            name = parameter["name"]
            del parameter["name"]

            if ("vals" in parameter):
                validator = parameter["vals"]
                try:
                    val_type = validator["type"]

                    if (val_type == "Bool"):
                        parameter["vals"] = vals.Ints(0, 1)
                        parameter['get_parser'] = int

                    elif (val_type == "IntArray"):
                        parameter["vals"] = vals.Arrays()
                        parameter['get_parser'] = lambda v: np.array(
                            v.split(','), dtype=int)
                    elif (val_type == "QECDataType"):
                        # The QECDataType assumes a long array of ints in which groups of 6 datapoints are returned.
                        # In this datatype every row corresponds to a timeslot
                        # every column corresponds to a qubit index.
                        parameter["vals"] = vals.Anything()

                    elif (val_type == "Non_Neg_Number"):
                        if ("range" in validator):
                            val_min = validator["range"][0]
                            val_max = validator["range"][1]
                        else:
                            val_min = 0
                            val_max = INT32_MAX

                        parameter["vals"] = vals.PermissiveInts(
                            val_min, val_max)
                        parameter['get_parser'] = int
                        parameter['set_parser'] = int

                    else:
                        log.warning("Failed to set the validator for the" +
                                    " parameter " + name + ", because of a" +
                                    " unknown validator type: '" + val_type +
                                    "'")

                except Exception as e:
                    log.warning(
                        "Failed to set the validator for the parameter " +
                        name + ".(%s)", str(e))

            try:
                log.info("Adding parameter:")
                for key, value in parameter.items():
                    log.info("\t", key, value)
                log.info("\n")

                self.add_parameter(name, **parameter)

            except Exception as e:
                log.warning(
                    "Failed to create the parameter " + name +
                    ", because of a unknown keyword in this" +
                    " parameter.(%s)", str(e))