def IIR_str_to_SDFG(iir: str): stencilInstantiation = IIR_pb2.StencilInstantiation() stencilInstantiation.ParseFromString(iir) metadata = stencilInstantiation.metadata id_resolver = IdResolver(metadata.accessIDToName, metadata.APIFieldIDs, metadata.temporaryFieldIDs, metadata.globalVariableIDs, metadata.fieldIDtoDimensions) imp = Importer(id_resolver) stencils = imp.Import_Stencils(stencilInstantiation.internalIR.stencils) UnparseCode(stencils, id_resolver) AddRegisters(stencils, id_resolver) SplitMultiStages(stencils) AddMsMemlets(stencils, id_resolver) AddDoMethodMemlets(stencils, id_resolver) exp = Exporter(id_resolver, name=metadata.stencilName) exp.Export_ApiFields(metadata.APIFieldIDs) exp.Export_TemporaryFields(metadata.temporaryFieldIDs) exp.Export_Globals({ id: stencilInstantiation.internalIR.globalVariableToValue[ id_resolver.GetName(id)].value for id in metadata.globalVariableIDs }) exp.Export_Stencils(stencils) exp.sdfg.fill_scope_connectors() return exp.sdfg
def main(): im = Importer() train = im.get_training_set() test = im.get_test_set() logis = linear_model.LogisticRegression() for i in range(100): mu1 = train['mu1'][:, i] mu0 = train['mu0'][:, i] yf = train['yf'][:, i] ycf = train['ycf'][:, i] t = train['t'][:, i] x = train['x'][:, :, i] #x = x[:, 0][:, np.newaxis] logis.fit(x, t) mu1_test = test['mu1'][:, i] mu0_test = test['mu0'][:, i] yf_test = test['yf'][:, i] ycf_test = test['ycf'][:, i] t_test = test['t'][:, i] x_test = test['x'][:, :, i] mask = [] for num in t_test: if num == 0: mask.append(False) else: mask.append(True) #x_test = x_test[:, 0][:, np.newaxis] ptx = logis.predict_proba(x_test) pt1 = np.sum(t_test)/len(t_test) pt0 = 1 - pt1 ptx1 = ptx[mask] ptx0 = ptx[np.invert(mask)] #print('pt', pt1, pt0) #print('ptx', ptx1, ptx0) w1 = pt1/ptx1[:, 1] w0 = pt0/ptx0[:, 0] #print('w', w1, w0) yw1 = yf_test[mask]*w1 yw0 = yf_test[np.invert(mask)]*w0 #print('yf', yf_test) #print('yw', yw1, yw0) avg_yw1 = np.sum(yw1)/len(yw1) avg_yw0 = np.sum(yw0)/len(yw0) #print(avg_yw1, avg_yw0) print(avg_yw1 - avg_yw0)
def importFile(self, path, importFormat): total = 0 importer = Importer(path, self.referenceManager) if importFormat == settings.ImportFormat.BIBTEX: total = importer.bibtexImport() elif importFormat == settings.ImportFormat.CSV: total = importer.csvImport() return total > 0
def import_result(args, vars, objs, actual_time_steps, url, session_id): write_progress(1, steps) imp=Importer(vars, objs, actual_time_steps, url, session_id) write_progress(2, steps) imp.load_network(args.network, args.scenario) write_progress(3, steps) imp.import_res() write_progress(4, steps) imp.save()
def import_result(args, vars, objs, actual_time_steps): write_progress(9, steps) imp = Importer(vars, objs, actual_time_steps, args.server_url, args.session_id) write_progress(10, steps) imp.load_network(args.network, args.scenario) write_progress(11, steps) #imp.set_network(network) imp.import_res() write_progress(12, steps) imp.save()
def transmitData(inputFile, logDir, predictionInterval, samplingInterval, heartbeat, drThreshold, delay, jitter, packetLoss): # Import data print "Importing data..." importer = Importer() rawInputData = importer.getInputData(inputFile, samplingInterval) exportData(logDir + "RawInputData.txt", rawInputData) # Filtering input data print "Filtering data..." samplingFreq = int(1e3 / samplingInterval) taps = 80 bands = [0.0, 10, 11, 50.0] weights = [1, 0] coefficients = scipy.signal.remez(taps, bands, weights, Hz=samplingFreq) gain = 1.0 / sum(coefficients) filteredInputData = filterData(rawInputData, logDir, "cc", samplingInterval, coefficients)[0] filteredInputData = amplifyData(filteredInputData, gain) exportData(logDir + "FilteredInputData.txt", filteredInputData) # Create the prediction vectors print "Creating the prediction vectors..." predictor = DRPredictor() predictedData = predictor.getPredictedData(filteredInputData, predictionInterval, samplingInterval) exportData(logDir + "PredictionData.txt", predictedData) # Run the transmission algorithm print "Simulating the transmission algorithm..." transmitter = DRTransmitter(heartbeat) drTxPackets = transmitter.getTransmittedPackets(drThreshold, predictedData) exportData(logDir + "DRTxPackets.txt", drTxPackets) # Simulate the transmission of the packets print "Simulating the network..." network = Network() drRxPackets = network.getReceivedPackets(drTxPackets, delay, jitter, packetLoss) exportData(logDir + "DRRxPackets.txt", drRxPackets) # Receive the packets print "Receiving the packets..." receiver = Receiver() drRxFilteredPackets = receiver.getFilteredData(drRxPackets) exportData(logDir + "DRRxData.txt", drRxFilteredPackets) return [ rawInputData, filteredInputData, predictedData, drTxPackets, drRxPackets, drRxFilteredPackets ]
def __init__(self, mail, fichier): Tk.__init__(self) self.mail = mail self.fichier = fichier self.geometry("350x400") #self.liste_mails= ['mail1', 'mail2'] #self.fichier.addListeMails(self.liste_mails) ## TOP ## top = PanedWindow(self) top_top = PanedWindow(top, orient=HORIZONTAL) top_bot = PanedWindow(top, orient=HORIZONTAL) dedoublonner = Button( top_top, text="Dédoublonner", command=self.actionListener_dedoublonner).pack(side=LEFT) valider = Button(top_top, text="Valider", command=self.actionListener_valider).pack(side=RIGHT) importer = Button( top_top, text="Importer", command=lambda: Importer(self.fichier)).pack(side=LEFT) #import_csv = Button(top_bot, text="Import CSV", command=lambda: Import_CSV(self.fichier)).pack(side=LEFT) #import_url = Button(top_bot, text="Import URL", command=lambda: Import_URL(self.fichier)).pack(side=RIGHT) top_top.pack(side=TOP) top_bot.pack(side=BOTTOM) top.pack(side=TOP) ## BOT ## self.bot = PanedWindow(self) self.bottom = self.paint(self.bot, 0) self.bottom.pack(side=TOP) """ for mail in mail.getDestinataires(): panel = PanedWindow(bot, orient=HORIZONTAL) adresse_mail = Label(panel, text=mail).pack(side=LEFT) adresse_valide = Label(panel, text=" OK" if TestMail.isMail(mail) else "PAS OK").pack(side=LEFT) supprimer = Button(panel, text="X").pack(side=RIGHT) panel.pack(anchor="e") """ self.bot.pack(side=TOP) suite = Button(self, text="Suite", command=self.actionListener_suite).pack(side=BOTTOM)
def __init__(self, in_file, out_file): self.tm = Text_manipulator() self.f = Formatter() self.i = Importer() self.tm.silent = True self.out_file = out_file self.in_file = in_file self.links = dict() self.links["mail_client.py"] = "bash" #self.links["bash"] = "mail_client.py" self.links["tg_client.py"] = "bash" self.links["bash"] = "tg_client.py"
def __init__(self): self.version = "0.5.4" self.utils = Utilities() self.save_path = "./controllers/nn/" + self.utils.getTimestamp() + "/" self.importer = Importer() self.exporter = Exporter(self.version) self.exporter.setSaveLocation(self.save_path) self.nnm = NeuralNetworkManager() self.nnm.setSaveLocation(self.save_path) self.staticController = StaticController() self.debug_mode = False self.importer.setDebugMode(False) self.nnm.setDebugMode(self.debug_mode) print("COTONN v" + self.version + "\n")
def __init__(self): space_files = [ '2010_DGD.txt', '2011_DGD.txt', '2012_DGD.txt', '2013_DGD.txt', '2014_DGD.txt', '2015_DGD.txt', '2016_DGD.txt' ] #, '2017_DGD.txt', '2018_DGD.txt'] weather_files = [ 'Inari Nellim.csv', 'Rovaniemi Lentoasema.csv', 'Ranua lentokentta.csv', 'Vantaa Lentoasema.csv' ] self.Importer = Importer() while (not self.Importer.completed): self.Importer.import_all(weather_files, space_files) self.Importer.to_json('Datafile.json') #self.Importer.df = pd.read_json("Datafile.json") self.df_split = self.split_sets() print("Import done") self.result = self.create_output(self.Importer.df) self.RunAll(self.result) self.to_json() self.to_database()
def __init__(self): self.version = "2.0" self.utils = Utilities() self.save_path = "./nn/" + self.utils.getTimestamp() + "/" self.importer = Importer() self.exporter = Exporter(self.version) self.exporter.setSaveLocation(self.save_path) self.nnm = NeuralNetworkManager() self.nnm.setSaveLocation(self.save_path) self.staticController = StaticController() self.debug_mode = False self.importer.setDebugMode(False) self.nnm.setDebugMode(self.debug_mode) print("COTONN v" + self.version + "\n") self.encode = EncodeTypes.Boolean self.var_order = Ordering.PerCoordinate self.filename = ""
import os from Configuration import Configuration from Importer import Importer os.environ['PYSPARK_PYTHON'] = '/usr/bin/python3.5' os.environ["PYSPARKDRIVER_PYTHON"]= "/usr/bin/python3.5" cfg = Configuration.configuration('config.yml') importer = Importer(cfg) importer.process(cfg['dates']['startDate'], cfg['dates']['endDate'])
def sync(uuid): Importer(uuid) return "ok"
def get_schemas(): importer = Importer(getCatalogClient(), getSchemaClient()) result = importer.get_schemas(request.data) return render_template_string(result)
features, 'tfidf_char', 'test') # Cross Validation predictions self.check_model(classifier, xcross_tfidf, self.y_cross, model_name, features, 'tfidf_char', 'cross') def get_and_print_all_scores(self): print('Running for count_vectors') for i in range(500, 5000, 500): self.count_vectors(i) self.tfidf_words(i) self.tfidf_ngram(i) self.tfidf_char(i) imp = Importer() trainDF = imp.ImportFuncs.read_csv_into_dataframe( 'csv_classification/Multi-class/classified_sentences_all.csv') prePro = PreProcessor() trainDF = prePro.clean_dataframe_for_training(trainDF) print(trainDF.head()) a = MultiClassifier(trainDF) a.get_and_print_all_scores() print(a.all_scores) exp = Exporter() exp.create_csv_scores(a.all_scores, 'all_scores_cleaned')
def startup(args: argparse.Namespace, **kwargs: Dict[str, Any]) -> None: global announce, dispatcher, group, httpServer, notification, validator global registration, remote, security, statistics, storage, event global rootDirectory global aeStatistics rootDirectory = os.getcwd() # get the root directory os.environ[ "FLASK_ENV"] = "development" # get rid if the warning message from flask. # Hopefully it is clear at this point that this is not a production CSE # Handle command line arguments and load the configuration if args is None: args = argparse.Namespace( ) # In case args is None create a new args object and populate it args.configfile = None args.resetdb = False args.loglevel = None for key, value in kwargs.items(): args.__setattr__(key, value) if not Configuration.init(args): return # init Logging Logging.init() Logging.log('============') Logging.log('Starting CSE') Logging.log('CSE-Type: %s' % C.cseTypes[Configuration.get('cse.type')]) Logging.log(Configuration.print()) # Initiatlize the resource storage storage = Storage() # Initialize the event manager event = EventManager() # Initialize the statistics system statistics = Statistics() # Initialize the registration manager registration = RegistrationManager() # Initialize the resource validator validator = Validator() # Initialize the resource dispatcher dispatcher = Dispatcher() # Initialize the security manager security = SecurityManager() # Initialize the HTTP server httpServer = HttpServer() # Initialize the notification manager notification = NotificationManager() # Initialize the announcement manager announce = AnnouncementManager() # Initialize the group manager group = GroupManager() # Import a default set of resources, e.g. the CSE, first ACP or resource structure importer = Importer() if not importer.importResources(): return # Initialize the remote CSE manager remote = RemoteCSEManager() remote.start() # Start AEs startAppsDelayed( ) # the Apps are actually started after the CSE finished the startup # Start the HTTP server event.cseStartup() # type: ignore Logging.log('CSE started') httpServer.run() # This does NOT return
from Importer import Importer im = Importer() for t in im.get_test_set()['t']: print(t)
def startup(args: argparse.Namespace, **kwargs: Dict[str, Any]) -> None: global announce, dispatcher, group, httpServer, notification, validator global registration, remote, request, security, statistics, storage, event global rootDirectory global aeStatistics global supportedReleaseVersions, cseType, defaultSerialization, cseCsi, cseRi, cseRn global cseOriginator global isHeadless rootDirectory = os.getcwd() # get the root directory os.environ[ "FLASK_ENV"] = "development" # get rid if the warning message from flask. # Hopefully it is clear at this point that this is not a production CSE # Handle command line arguments and load the configuration if args is None: args = argparse.Namespace( ) # In case args is None create a new args object and populate it args.configfile = None args.resetdb = False args.loglevel = None args.headless = False for key, value in kwargs.items(): args.__setattr__(key, value) isHeadless = args.headless if not Configuration.init(args): return # Initialize configurable constants supportedReleaseVersions = Configuration.get( 'cse.supportedReleaseVersions') cseType = Configuration.get('cse.type') cseCsi = Configuration.get('cse.csi') cseRi = Configuration.get('cse.ri') cseRn = Configuration.get('cse.rn') cseOriginator = Configuration.get('cse.originator') defaultSerialization = Configuration.get('cse.defaultSerialization') # init Logging Logging.init() if not args.headless: Logging.console('Press ? for help') Logging.log('============') Logging.log('Starting CSE') Logging.log(f'CSE-Type: {cseType.name}') Logging.log('Configuration:') Logging.log(Configuration.print()) # Initiatlize the resource storage storage = Storage() # Initialize the event manager event = EventManager() # Initialize the statistics system statistics = Statistics() # Initialize the registration manager registration = RegistrationManager() # Initialize the resource validator validator = Validator() # Initialize the resource dispatcher dispatcher = Dispatcher() # Initialize the request manager request = RequestManager() # Initialize the security manager security = SecurityManager() # Initialize the HTTP server httpServer = HttpServer() # Initialize the notification manager notification = NotificationManager() # Initialize the group manager group = GroupManager() # Import a default set of resources, e.g. the CSE, first ACP or resource structure # Import extra attribute policies for specializations first importer = Importer() if not importer.importAttributePolicies() or not importer.importResources( ): return # Initialize the remote CSE manager remote = RemoteCSEManager() # Initialize the announcement manager announce = AnnouncementManager() # Start AEs startAppsDelayed( ) # the Apps are actually started after the CSE finished the startup # Start the HTTP server event.cseStartup() # type: ignore httpServer.run() # This does return (!) Logging.log('CSE started') if isHeadless: # when in headless mode give the CSE a moment (2s) to experience fatal errors before printing the start message BackgroundWorkerPool.newActor( delay=2, workerCallback=lambda: Logging.console('CSE started') if not shuttingDown else None).start() # # Enter an endless loop. # Execute keyboard commands in the keyboardHandler's loop() function. # commands = { '?': _keyHelp, 'h': _keyHelp, '\n': lambda c: print(), # 1 empty line '\x03': _keyShutdownCSE, # See handler below 'c': _keyConfiguration, 'C': _keyClearScreen, 'D': _keyDeleteResource, 'i': _keyInspectResource, 'l': _keyToggleLogging, 'Q': _keyShutdownCSE, # See handler below 'r': _keyCSERegistrations, 's': _keyStatistics, 't': _keyResourceTree, 'T': _keyChildResourceTree, 'w': _keyWorkers, } # Endless runtime loop. This handles key input & commands # The CSE's shutdown happens in one of the key handlers below loop(commands, catchKeyboardInterrupt=True, headless=args.headless) shutdown()
import sys import os import shelve import dbm sys.path.append("/root/develop/suidev/server/") sys.path.append("/root/develop/suidev/server/BlenderImporter/") print("Blender Script run at %s", sys.executable) print("Script File path is %s", sys.path[0]) from Importer import Importer from Config import Config #render_task = shelve.Shelf(dbm.open(Config.data_path + "temp/render", 'r')) render_task = shelve.open(Config.data_path + "temp/render", protocol=2, writeback=True) kind = render_task["kind"] render_task.close() importer = Importer() importer.Render(kind)
def import_csv(): importer = Importer(getCatalogClient(), getSchemaClient()) result = importer.import_data(request.data) return render_template_string(result)