def process(self):
     self.outputs['data'] = self.update(self.inputs['data'])
     self.return_msg_ = 'Data updated!'
     if isinstance(self.outputs['data'], H5):
         return super().process(QuReturnCode('OK'))
     else:
         return super().process(QuReturnCode('UNKNOWN'))
Exemplo n.º 2
0
 def __init__(self):
     self.return_msg_ = "All is quiet..."
     self.inputs = {'condition': True}
     self.inflows = ['>>']
     self.outflows = {
         'true >>': QuReturnCode('UNKNOWN').returncode,
         'false >>': QuReturnCode('UNKNOWN').returncode
     }
Exemplo n.º 3
0
    def process(self):
        if self.inputs['condition']:
            self.outflows['true >>'] = QuReturnCode('OK').returncode
            self.outflows['false >>'] = QuReturnCode('UNKNOWN').returncode
        else:
            self.outflows['false >>'] = QuReturnCode('OK').returncode
            self.outflows['true >>'] = QuReturnCode('UNKNOWN').returncode

        return super().process()
Exemplo n.º 4
0
    def process(self):
        try:
            print(self.inputs['msg'])
            self.return_msg_ = 'Print execution done.'
        except:
            self.return_code = QuReturnCode('UNKNOWN')
            self.return_msg_ = 'Problem printing!'

        self.outflows['>>'] = QuReturnCode('OK').returncode
        return super().process(QuReturnCode('OK'))
Exemplo n.º 5
0
    def test_if(self):
        self.iffer.inputs['condition'] = True
        self.iffer.process()
        self.assertEqual(self.iffer.outflows['true >>'], QuReturnCode('OK'))
        self.assertEqual(self.iffer.outflows['false >>'],
                         QuReturnCode('UNKNOWN'))

        self.iffer.inputs['condition'] = False
        self.iffer.process()
        self.assertEqual(self.iffer.outflows['false >>'], QuReturnCode('OK'))
        self.assertEqual(self.iffer.outflows['true >>'],
                         QuReturnCode('UNKNOWN'))
Exemplo n.º 6
0
    def test_if_cell(self):
        self.iffer_cell.inputs['condition'] << False
        self.iffer_cell.process()
        result = []
        self.iffer_cell.outputs['true >>'] >> result
        self.assertEqual(result[-1], QuReturnCode('UNKNOWN'))
        self.iffer_cell.outputs['false >>'] >> result
        self.assertEqual(result[-1], QuReturnCode('OK'))

        self.iffer_cell.inputs['condition'] << True
        self.iffer_cell.process()
        self.iffer_cell.outputs['true >>'] >> result
        self.assertEqual(result[-1], QuReturnCode('OK'))
        self.iffer_cell.outputs['false >>'] >> result
        self.assertEqual(result[-1], QuReturnCode('UNKNOWN'))
Exemplo n.º 7
0
class Start(Custom):
    outflows = {'>>': QuReturnCode('OK').returncode}
    threadsafe = True

    def process(self):
        self.outflows['>>'] = QuReturnCode('OK').returncode
        return super().process(code=QuReturnCode('OK'))
Exemplo n.º 8
0
    def process(self, code=None):
        """
        Manages the return value that gets passed back to the C++ scheduler.
        Always call this function at the end of your process implementation
        and return its value. Your process function should never need to
        return a value to the scheduler. This function will manage that for
        you.

        :param code: You can pass a return code here which will get passed on
                     to the scheduler.
        :type code: :class:`~Quantum.QuReturnCode`
        """
        try:
            return code.returncode
        except AttributeError:
            return QuReturnCode('OK').returncode
Exemplo n.º 9
0
class Sleep(Custom):
    inputs = {'seconds': 0}
    inflows = ['>>']
    outputs = {'done': False}
    outflows = {'>>': QuReturnCode('UNKNOWN').returncode}
    required = ['>>', 'seconds']
    internal_use = ['>>']
    threadsafe = True

    def start(self):
        self.return_msg_ = "Everything looks good!"
        self.return_code = QuReturnCode('OK')

    def process(self):
        time.sleep(self.inputs['seconds'])
        print("I have awakened!")
        self.outputs['done'] = True
        self.outflows['>>'] = QuReturnCode('OK').returncode
        return super().process(self.return_code)

    def return_msg(self):
        return self.return_msg_
Exemplo n.º 10
0
class Print(Custom):
    inputs = {'msg': 'Hello World!'}
    inflows = ['>>']
    outflows = {'>>': QuReturnCode('UNKNOWN').returncode}
    required = ['>>', 'msg']
    internal_use = ['>>']
    always_reprocess = True
    threadsafe = True

    def start(self):
        self.return_msg_ = "Ready... to print money!"
        self.return_code = QuReturnCode('OK')

    def process(self):
        try:
            print(self.inputs['msg'])
            self.return_msg_ = 'Print execution done.'
        except:
            self.return_code = QuReturnCode('UNKNOWN')
            self.return_msg_ = 'Problem printing!'

        self.outflows['>>'] = QuReturnCode('OK').returncode
        return super().process(QuReturnCode('OK'))
Exemplo n.º 11
0
 def process(self):
     self.outflows['>>'] = QuReturnCode('OK').returncode
     return super().process(code=QuReturnCode('OK'))
Exemplo n.º 12
0
 def start(self):
     self.return_msg_ = "Ready... to print money!"
     self.return_code = QuReturnCode('OK')
Exemplo n.º 13
0
 def process(self):
     time.sleep(self.inputs['seconds'])
     print("I have awakened!")
     self.outputs['done'] = True
     self.outflows['>>'] = QuReturnCode('OK').returncode
     return super().process(self.return_code)
Exemplo n.º 14
0
 def start(self):
     self.return_msg_ = "Everything looks good!"
     self.return_code = QuReturnCode('OK')
Exemplo n.º 15
0
 def process(self):
     self.return_msg_ = 'Selecting column...'
     self.outputs['data'] = self.column(self.inputs['data'])
     self.return_msg_ = 'Selected'
     return super().process(QuReturnCode('OK'))
Exemplo n.º 16
0
}, {
    'name': 'Normal',
    'module': 'PyCell.sympy_cell',
    'categories': ['Statistics', 'Symbolic']
}, {
    'name': 'CDF',
    'module': 'PyCell.sympy_cell',
    'categories': ['Statistics', 'Symbolic']
}, {
    'name': 'Calculate',
    'module': 'PyCell.sympy_cell',
    'categories': ['Math', 'Symbolic']
}]

tf = {'True': 'True', 'False': 'False'}
OK = QuReturnCode('OK')
QUIT = QuReturnCode('QUIT')


def eval_sym(out_key=None, in_key=None, eval_key='eval', eval_out='result'):
    """
    A decorator for processes that allow calculation of a numeric result. The
    output socket located at ``out_key`` must be a :class:`QuSym`. Optionally,
    an ``in_key`` may be supplied if the formula is found in an input. The
    formula must be supplied in at least one of the two. If both are supplied,
    the output formula will have priority.
    
    :param out_key: The key to the output socket containing a QuSym that
                    includes all values neccessary for evaluation.
    :type out_key: str
    :param in_key: The key to the input socket containing a QuSym that
 def test_starter_cell(self):
     result = self.starter_cell.process()
     self.assertEqual(result, QuReturnCode('OK').returncode)