Esempio n. 1
0
    def delete_section_property(self, section_name, property_name):
        from qiskit_aqua.parser._inputparser import InputParser
        from qiskit_aqua.parser import JSONSchema
        if self._parser is None:
            raise Exception('Input not initialized.')

        self._parser.delete_section_property(section_name, property_name)
        if property_name == JSONSchema.NAME and \
                (InputParser.is_pluggable_section(section_name)):
            self._parser.delete_section_properties(section_name)
Esempio n. 2
0
    def set_section_property(self, section_name, property_name, value):
        from qiskit_aqua.parser._inputparser import InputParser
        from qiskit_aqua.parser import JSONSchema
        if self._parser is None:
            raise Exception('Input not initialized.')

        self._parser.set_section_property(section_name, property_name, value)
        if property_name == JSONSchema.NAME and \
                (InputParser.is_pluggable_section(section_name)):
            properties = self._parser.get_section_default_properties(
                section_name)
            if isinstance(properties, dict):
                properties[JSONSchema.NAME] = value
                self._parser.delete_section_properties(section_name)
                for property_name, property_value in properties.items():
                    self._parser.set_section_property(section_name,
                                                      property_name,
                                                      property_value)
Esempio n. 3
0
    def set_section_property(self, section_name, property_name, value):
        from qiskit_aqua.parser._inputparser import InputParser
        from qiskit_aqua.parser import JSONSchema
        from qiskit_aqua import get_backends_from_provider
        if self._parser is None:
            raise Exception('Input not initialized.')

        self._parser.set_section_property(section_name, property_name, value)
        if property_name == JSONSchema.NAME and InputParser.is_pluggable_section(section_name):
            properties = self._parser.get_section_default_properties(section_name)
            if isinstance(properties, dict):
                properties[JSONSchema.NAME] = value
                self._parser.delete_section_properties(section_name)
                for property_name, property_value in properties.items():
                    self._parser.set_section_property(section_name, property_name, property_value)
        elif section_name == JSONSchema.BACKEND and property_name == JSONSchema.PROVIDER:
            backends = get_backends_from_provider(value)
            if value not in self.providers:
                self._custom_providers[value] = backends

            backend = backends[0] if len(backends) > 0 else ''
            self._parser.set_section_property(section_name, JSONSchema.NAME, backend)
Esempio n. 4
0
 def is_pluggable_section(section_name):
     from qiskit_aqua.parser._inputparser import InputParser
     return InputParser.is_pluggable_section(section_name)