예제 #1
0
def saveData(signalsDictionary, targetFolder, bounds, threshold):
    for signalName, valuesList in signalsDictionary.items():
        try:
            moduleTasks.isBounded(valuesList, bounds, threshold)
        except ValueError:
            continue
        else:
            with open(targetFolder + '/' + signalName + '.txt', 'w') as mf:
                for value in valuesList:
                    mf.write('{0:.3f}\n'.format(float(value)))
예제 #2
0
def saveData(signalsDictionary, targetFolder, bounds, threshold):
    #emp_list = []
    for sig, sig_val in signalsDictionary.items():
        #if (sig_val == None):
        #continue
        #elif(len(sig_val) == 0):
        #    continue
        #else:
        try:
            #print(moduleTasks.isBounded(sig_val, bounds, threshold))
            if (moduleTasks.isBounded(sig_val, bounds, threshold)):
                path = targetFolder + "/" + sig + ".txt"

                #print(path)

                #print("Now this is just stupid -.-")

                with open(path, 'w') as f:
                    for val in sig_val:
                        f.write('%.3f \n' % val)

            else:
                continue
        except:
            pass
예제 #3
0
def saveData(signalsDictionary, targetFolder, bounds, threshold):
    for signal, values in signalsDictionary.items():
        if values is not None and values != [] and mT.isBounded(
                values, bounds, threshold):
            signalFile = targetFolder + '/' + signal + '.txt'
            with open(signalFile, 'w') as myFile:
                for val in values:
                    myFile.write('{:.3f}\n'.format(float(val)))
    myFile.close()
    return
예제 #4
0
def saveData(signalsDictionary, targetFolder, bounds, threshold):
    for files, values in signalsDictionary.items():
        path = targetFolder + '/' + files + '.txt'
        try:
            if values and values != []:
                if moduleTasks.isBounded(values, bounds, threshold):
                    with open(path, 'w') as file:
                        file.write("{:.3f}".format(values[0]))
                        for items in values[1:]:
                            file.write("\n{:.3f}".format(items))
        except ValueError:
            continue
    return None
예제 #5
0
    def testIsBounded(self):
        values = [-4, -4, -3, -2, -1, 0, 1, 2, 3, 3.5]

        self.assertTrue(isBounded(values, (-3, 3), 4))
        self.assertTrue(isBounded(values, (3, -3), 4))
        self.assertTrue(isBounded(values, (-3, 3), 3))

        self.assertFalse(isBounded(values, (-3, 3), 2))
        self.assertFalse(isBounded(values, (-3, 3), 1))

        self.assertFalse(isBounded(values, (0, 0), 1))
예제 #6
0
def saveData(signalsDictionary, targerFolder, bounds, threshold):
    for singal in signalsDictionary:
        path = targerFolder + '/' + singal + '.txt'

        try:
            if (moduleTasks.isBounded(signalsDictionary[singal], bounds,
                                      threshold)):
                with open(path, "w") as myFile:
                    for lines in range(len(
                            signalsDictionary[singal])):  #write new file
                        myFile.write("{0:.3f}".format(
                            signalsDictionary[singal][lines]))
                        if not lines == (len(signalsDictionary[singal]) -
                                         1):  #start new line
                            myFile.write("\n")
        except:
            pass
예제 #7
0
def saveData(signalsDictionary, targetFolder, bounds, threshold):

    for k, v in signalsDictionary.items():
        try:
            bound = moduleTasks.isBounded(v, bounds, threshold)
        except ValueError:
            pass
        else:
            if bound:
                new_filename = k + ".txt"
                path_string = targetFolder + "/" + new_filename
                with open(path_string, "w") as myFile:

                    for val in v[:-1]:
                        final_str = "{:.3f}\n".format(val)
                        myFile.write(final_str)

                    final_str = "{:.3f}".format(v[-1])
                    myFile.write(final_str)
            else:
                pass
예제 #8
0
 def testIsBoundedNoValues(self):
     try:
         val = isBounded([], (0, 1), 3)
         self.fail('ValueError not raised for no data')
     except ValueError as err:
         self.assertTrue(str(err), 'Signal contains no data.')