Unverified Commit a997cba0 authored by Mccaskey, Alex's avatar Mccaskey, Alex Committed by GitHub
Browse files

Merge pull request #102 from zpparks314/master

Python API changes to allow variables in IRGenerator declarations
parents 1c531f68 fc19af69
Pipeline #35898 passed with stages
in 9 minutes and 54 seconds
from _pyxacc import *
import os, time, json
import platform
import sys
import sys, re
import sysconfig
import argparse
import inspect
......@@ -163,6 +163,9 @@ class DecoratorFunction(ABC):
self.accelerator = None
self.src = '\n'.join(inspect.getsource(self.function).split('\n')[1:])
compiler = getCompiler('xacc-py')
if self.accelerator == None:
if 'accelerator' in self.kwargs:
......@@ -186,7 +189,19 @@ class DecoratorFunction(ABC):
def overrideAccelerator(self, acc):
self.accelerator = acc
def processVariables(self):
g = re.findall('=(\w+)', self.src)
frame = inspect.currentframe()
for thing in g:
if thing in frame.f_back.f_locals['f'].__globals__:
if isinstance(frame.f_back.f_locals['f'].__globals__[thing], str):
real = "'" + frame.f_back.f_locals['f'].__globals__[thing] + "'"
real = str(frame.f_back.f_locals['f'].__globals__[thing])
self.src = self.src.replace('='+thing, '='+real)
del frame
def nParameters(self):
return self.getFunction().nParameters()
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment