コード例 #1
0
 def receiveLogin(self):
     encodedData = self.receiveData()
     encryptedData = Helpers.decode(encodedData)
     jsonData = Security.decryptAsymPriv(eval(encryptedData),
                                         Security.getPrivKey())
     data = Helpers.fromJson(jsonData)
     return data
コード例 #2
0
def path_platform(filepath):
    """figure out which imagehost/sharing platform is being used

    Args:
        filepath (str): path to dump directory

    Returns:
        (:obj:`Helpers.HostPlatform`): Enum of which platform is being used

    """
    host = ps_helper.HostPlatform.ERROR
    types_found = 0

    if 'dropbox' in str(filepath).lower():
        host = ps_helper.HostPlatform.DROPBOX
        types_found += 1
    elif 'google' in str(filepath).lower():
        host = ps_helper.HostPlatform.GOOGLE
        types_found += 1
    else:
        raise ps_helper.UnsupportedHost('Unable to resolve host in=' +
                                        str(filepath))

    if types_found != 1:
        raise ps_helper.ConfusingHosts(
            'Multiple possible hosts identified in=' + str(filepath))

    return host
コード例 #3
0
    def CompareNames(self, name1, name2):
        if name1 == None or name2 == None:
            return False

        if name1.lower().startswith("the "):
            name1 = name1[4:].strip()
        if name1.lower().endswith(", the"):
            name1 = name1[:-5].strip()

        if name2.lower().startswith("the "):
            name2 = name2[4:].strip()
        if name2.lower().endswith(", the"):
            name2 = name2[:-5].strip()

        if name1.lower().startswith("a "):
            name1 = name1[2:].strip()
        if name1.lower().endswith(", a"):
            name1 = name1[:-3].strip()

        if name2.lower().startswith("a "):
            name2 = name2[2:].strip()
        if name2.lower().endswith(", a"):
            name2 = name2[:-3].strip()

        if name1.lower().startswith("an "):
            name1 = name1[3:].strip()
        if name1.lower().endswith(", an"):
            name1 = name1[:-4].strip()

        if name2.lower().startswith("an "):
            name2 = name2[3:].strip()
        if name2.lower().endswith(", an"):
            name2 = name2[:-4].strip()

        return Helpers.CompressName(name1) == Helpers.CompressName(name2)
コード例 #4
0
ファイル: FillBD2.py プロジェクト: dede67/FillBD2
  def __updateSum(self, ctrl, ctrl_nr):
    size=sizeAdj=0
    for key, data in ctrl.data.obj.items():
      size+=data.size
      sizeAdj+=data.sizeAdj

    if ctrl_nr==1:
      self.lp1_size.SetValue(hlp.intToStringWithCommas(size))
      self.lp1_sizeAdj.SetValue(hlp.intToStringWithCommas(sizeAdj))
      if sizeAdj<self.size:
        self.lp1_sizeAdj.SetBackgroundColour("YELLOW")
        self.lp1_sizeAdj.SetToolTip(wx.ToolTip("Not enough files to fill target"))
      else:
        self.lp1_sizeAdj.SetBackgroundColour(wx.NullColor)
        self.lp1_sizeAdj.SetToolTip(wx.ToolTip.Enable(False))
    else:
      self.lp2_sizeAdj.SetValue(hlp.intToStringWithCommas(sizeAdj))
      remSize=self.size-sizeAdj
      self.lp2_sizeRem.SetValue(hlp.intToStringWithCommas(remSize))
      if remSize<0:
        self.lp2_sizeRem.SetBackgroundColour("YELLOW")
        self.lp2_sizeRem.SetToolTip(wx.ToolTip("Files do not fit on target"))
      else:
        self.lp2_sizeRem.SetBackgroundColour(wx.NullColor)
        self.lp2_sizeRem.SetToolTip(wx.ToolTip.Enable(False))
コード例 #5
0
ファイル: oss.py プロジェクト: hh-h/ossdev
    def POST(self): # noqa
        i = web.input(bras='', action='', ip='')
        if not i.ip or not i.action or not i.bras:
            return dumps({
                'status' : Status.ERROR
            })

        if i.bras not in brasses_list:
            print('dont know dis bras {0}'.format(i.bras))
            return dumps({
                'status' : Status.ERROR
            })
        action = H.check_bras_action(i.action)
        if not action:
            print('dont know dis action {0}'.format(i.action))
            return dumps({
                'status' : Status.ERROR
            })

        ip = H.check_ip(i.ip)
        if not ip:
            return dumps({
                'status' : Status.ERROR
            })
        log.save_action(session.name, 'session', 'Делает {0} для сессии {1} на {2}'.format(action, ip, i.bras))

        return getattr(brasses_list[i.bras], H.BRAS_FUNCTIONS[action])(ip)
コード例 #6
0
	def _calc_start_metrics(self):
		
		### Metrics #############################################################
		self.start_count = 0
		self.start_day_times = [] # triples of hour, minute and second
		#########################################################################
		
		# Go over start structs
		for key, start in self._data['general']['start'].items():
			if key != 'count': # there is always one count entry that we ignore
				
				# Barrier to ignore before-setup data
				if self._check_date(start['date']):
					
					# Helpers
					date = hlp.from_date_string_to_date(start['date'])
					
					# Update count
					self.start_count += 1
					
					# Update daily use
					day_string = hlp.from_date_to_day_string(date)
					self.daily_use[day_string]['start_count'] += 1
					
					# Update start day times
					self.start_day_times.append((date.hour, date.minute, date.second))
コード例 #7
0
def create_files(components: list):
    path = "output/rel/"
    print('dumping files to {0}'.format(path))
    if not os.path.exists(path):
        os.makedirs(path)

    user_strings = []

    Helpers.append_line(
        user_strings,
        '{0},{1},{2},{3},{4}'.format('Component Type', 'Sub Component Type',
                                     'Attribute', 'Type', 'Component'))
    for type, json_definition in components:
        if json_definition:
            response = cs.Response(json_definition)
            if response.component:
                component = response.component
                append_attribute_user_string_row(user_strings,
                                                 component.attributes,
                                                 component.name, '')

                for sub in component.sub_components:
                    append_attribute_user_string_row(user_strings,
                                                     sub.attributes,
                                                     component.name, sub.name)

    Helpers.save_as_file('relationships', to_string(user_strings), path, 'csv')
コード例 #8
0
ファイル: oss.py プロジェクト: hh-h/ossdev
    def GET(self): # noqa
        i = web.input(bill='')
        if not i.bill:
            return dumps({
                'status': Status.ERROR
            })

        bill = H.check_bill(i.bill)
        if not bill:
            return dumps({
                'status': Status.ERROR
            })

        region = H.get_region_by_bill(bill)
        result = []
        for key, value in brases[region].iteritems():
            result.append(value['name'].upper())
        if not result:
            return dumps({
                'status' : Status.EMPTY
            })
        return dumps({
            'status' : Status.SUCCESS,
            'data'   : result
        })
コード例 #9
0
ファイル: main.py プロジェクト: Mateo89/AquaPC-BACKEND
def main():
    GPIO.cleanup()

    settings.load_settings()

    threads = [
        Logic.Logic(),
        Display.DisplayThread(),
        threading.Thread(target=RestThread.run_server)
    ]
    # threads.append(WatchdogThread.WatchdogThread())
    # threads.append(ReminderThread.ReminderThread())

    for th in threads:
        th.start()
        time.sleep(0.5)

    while len(threads) > 0:
        try:
            temp_threads = []

            for t in threads:
                if t is not None and t.isAlive():
                    t.join(0.2)
                    temp_threads.append(t)

            threads = temp_threads

            time.sleep(0.1)
        except (KeyboardInterrupt, SystemExit):
            Register.EXIT_FLAG = True

    Helpers.log("ZAPISYWANIE KONFIGURACJI")
    settings.save_settings()
    Helpers.log("ZAMYKANIE APLIKACJI")
コード例 #10
0
def append_attribute_user_string_row(user_strings: list, attributes: list,
                                     component: str, sub: str):
    for attr in attributes:
        Helpers.append_line(
            user_strings,
            get_user_string_row(component, sub, attr.name, attr.type,
                                attr.component or ''))
コード例 #11
0
    def __init__(self,
                 display=None,
                 centerPosX=None,
                 centerPosY=None,
                 background=None):
        self.size = (1080, 1920)
        self.font = pygame.font.SysFont('Calibri',
                                        helpers.normalize(self.size, 35, 'y'),
                                        True, False)
        self.endTime = ''
        self.startTime = ''
        self.currentTime = ''
        self.lock = thread.allocate_lock()
        self.running = False

        if background:
            self.clockFace = pygame.transform.scale(
                pygame.image.load(background),
                (helpers.normalize(self.size, 83, 'x'),
                 helpers.normalize(self.size, 48, 'y')))
        if display: self.display = display
        if centerPosX and centerPosY:
            self.centerPosImage = (centerPosX -
                                   helpers.normalize(self.size, 8, 'x'),
                                   centerPosY -
                                   helpers.normalize(self.size, 6, 'y'))
        if centerPosX and centerPosY: self.centerPos = (centerPosX, centerPosY)
コード例 #12
0
ファイル: __init__.py プロジェクト: perathkkp/firstclone
def main(req: func.HttpRequest) -> func.HttpResponse:
    logging.info('Python HTTP trigger function processed a request.')

    url = 'https://www.bot.or.th/English/Statistics/FinancialInstitutions/Pages/StatDepositsAndLoans.aspx'

    xpath = '//div[@id="ctl00_ctl73_g_17a2a365_df74_4044_abf1_b8af0ad3dd29_ctl00_plhContentDisplay"]//table//tr//td[3]//a'

    download_path = './download'

    download_links = Helpers.get_download_link(url, xpath)

    logging.info(download_links)

    upload_file_paths = []

    for link in download_links:
        if Helpers.is_downloadable(link):
            download_filepath = Helpers.download(link, download_path)
            upload_file_paths.append(download_filepath)
        break

    for upload_file_path in upload_file_paths:
        Helpers.upload_to_blob('kk1', upload_file_path)

    logging.info('Python HTTP trigger function completed.')

    return func.HttpResponse("Completed", status_code=200)
コード例 #13
0
def toggle_water_change():
    if Register.CHANGE_WATER_MODE:
        Register.CHANGE_WATER_MODE = True
        Helpers.log("Wlaczenie trybu podmiany wody")
    else:
        Register.CHANGE_WATER_MODE = False
        Helpers.log("Wylaczenie trybu podmiany wody")
コード例 #14
0
def parsimony_down(subtree, nodelist):
    """parsimony part: down direction -> from leafs to root"""
    # Arguments:
    #   subtree
    #   nodelist      - [id, originaltag, finaltag, calc[taglist]]
    element = Helpers.find_element_in_nodelist(subtree.name, nodelist)
    left_child = Helpers.find_element_in_nodelist(subtree.clades[0].name,
                                                  nodelist)
    right_child = Helpers.find_element_in_nodelist(subtree.clades[1].name,
                                                   nodelist)
    # if not both children are tagged, first tag them:
    if left_child[3] == []:
        parsimony_down(subtree.clades[0], nodelist)
    if right_child[3] == []:
        parsimony_down(subtree.clades[1], nodelist)
    # if leafs:
    if subtree.clades[0].is_terminal():
        if left_child[3][0] == 'FL':
            left_child[3][0] = 1
        else:
            left_child[3][0] = 0
    if subtree.clades[1].is_terminal():
        if right_child[3][0] == 'FL':
            right_child[3][0] = 1
        else:
            right_child[3][0] = 0
    # calculate mean
    mean = (left_child[3][0] + right_child[3][0]) / 2
    element[3].append(mean)
    return
コード例 #15
0
def handleLeftClick():
    import Bot
    import Interface
    global selectedBot
    clickedCell = gameWorld.cellByPixel(mousePos)
    if clickedCell is not None:
        if isinstance(gameWorld.worldMatrix[clickedCell[0]][clickedCell[1]], Bot.Bot):
            if isinstance(selectedBot, Bot.Bot):
                selectedBot.isSelected = False
            selectedBot = gameWorld.worldMatrix[clickedCell[0]][clickedCell[1]]
            selectedBot.isSelected = True
        else:
            if isinstance(selectedBot, Bot.Bot):
                selectedBot.isSelected = False
            selectedBot = None
    elif Helpers.isCoordsInRect(mousePos, Interface.buttonSpeedDownRect) is True:
        gameSpeedDown()
    elif Helpers.isCoordsInRect(mousePos, Interface.buttonSpeedUpRect) is True:
        gameSpeedUp()
    elif Helpers.isCoordsInRect(mousePos, Interface.buttonPauseRect) is True:
        switchGameState()
    elif Helpers.isCoordsInRect(mousePos, Interface.buttonResetRect) is True:
        reset()
    elif Helpers.isCoordsInRect(mousePos, Interface.buttonTickRect) is True:
        tick()
コード例 #16
0
    def parse(self, response):
        offenderList = []
        
        for links in response.xpath("//tr[@align='left']"):
            name = links.xpath('td[3]/a[1]/text()').extract()
            ID = links.xpath('td[3]/a[1]/@href').re("javascript: OpenDetail\('(.*?)'")

            offender={}

            nameString = ''.join(name)

            # Checks if valid path, valid path will have name
            if len(nameString)>1:
                offender['FullName'] = Helpers.fixName(nameString) 
                offender['FirstName'] = Helpers.firstName(offender['FullName'])
                offender['LastName'] = Helpers.lastName(offender['FullName'])
            
                IDString = ''.join(ID)
                offender['offenderID'] = IDString

                offender['link'] = "http://www.meganslaw.ca.gov/cgi/prosoma.dll?w6=719389&searchby=offender&id=" + IDString
                offenderList.append(offender)

        for offender in offenderList:
            # Checks if valid path, valid path will have name
            if len(nameString)>1:
                    yield scrapy.Request(offender['link'], meta={'person': offender}, callback=self.parse_offender)
コード例 #17
0
    def send(self, connection):
        assert type(connection) == Connection
        """
		data = struct.pack("<IBIIIBIHIHBB%dsI" % (len(self.description) + 1),
		#data = struct.pack("<IB64sIIBIHIHBB%dsI" % (len(self.description) + 1),
			self.uin, 
			0x01, 
			Helpers.gg_login_hash(self.password, self.seed), 
			self.status, 
			self.version, 
			0x00, 
			Helpers.ip_to_int32(self.local_ip), 
			self.local_port, 
			Helpers.ip_to_int32(self.external_ip), 
			self.external_port, 
			self.image_size, 
			0xbe,
			self.description,
			self.time)

		connection.send(repr(GGHeader(GGOutgoingPackets.GGLogin, len(data))) + data)
		"""
        data = struct.pack("<IIIIBIhIhBB%dsI" % (len(self.description) + 1),
                           self.uin,
                           Helpers.gg_login_hash(self.password, self.seed),
                           self.status, self.version, 0x00,
                           Helpers.ip_to_int32(self.local_ip), self.local_port,
                           Helpers.ip_to_int32(self.external_ip),
                           self.external_port, self.image_size, 0xbe,
                           self.description, self.time)

        connection.send(
            repr(GGHeader(GGOutgoingPackets.GGLogin60, len(data))) + data)
コード例 #18
0
ファイル: GDALData.py プロジェクト: rmcwilliams/ADONNIS
def getNearestPlace (lat, lng, timeout = 5):
    locationsUrl = "https://carto.nationalmap.gov/arcgis/rest/services/geonames/MapServer/18/query?geometry=" + str(lng) +"," + str(lat) + "&geometryType=esriGeometryPoint&inSR=4326&outSR=4326&distance=7000&units=esriSRUnit_Meter&outFields=*&returnGeometry=true&f=geojson"
    result = queryWithAttempts(locationsUrl, QUERY_ATTEMPTS, timeout = timeout, queryName="nearPlaces")
    
    if Failures.isFailureCode(result):
        return result

    try:
        data = json.loads(result.text)
    except:
        return Failures.QUERY_PARSE_FAILURE_CODE

    features = data["features"]

    nearestFeatureDistance = sys.maxsize
    nearestFeature = None
    for feature in features:
        attrib = feature["properties"]

        point = feature["geometry"]["coordinates"][0]
        distance = Helpers.fastMagDist(point[1], point[0], lat, lng)
        if distance < nearestFeatureDistance:
            nearestFeatureDistance = distance
            nearestFeature = feature
    
    attrib = nearestFeature["properties"]
    stateAlpha = attrib["state_alpha"]
    placeName = attrib["gaz_name"]

    nearestPoint = nearestFeature["geometry"]["coordinates"][0]
    distance = Helpers.degDistance(nearestPoint[1], nearestPoint[0], lat, lng)

    return {"distanceToPlace":distance, "placeName":placeName, "state":stateAlpha}
コード例 #19
0
def override_switch(switch):
    Register.POWERMOD_DATA_OVERRIDE[str(switch)]['override_time'] = datetime.datetime.now() \
                                                                    + datetime.timedelta(minutes=Register.OVERRIDE_TIME)

    if not Register.POWERMOD_DATA[str(switch)]['override']:
        Register.POWERMOD_DATA[str(switch)]['override'] = True
        Helpers.log("Zalozenie locka na: " + Register.POWERMOD_DATA[str(switch)]['name'])
コード例 #20
0
 def test_fails_invalid_entity(self):
     with self.subTest("General"):
         with self.assertRaises(XMLError):
             Helpers.parse_string_literal(f"Some text and an entity: &entity;")
     with self.subTest("Parameter"):
         with self.assertRaises(XMLError):
             Helpers.parse_string_literal(f"Some text and an entity: %entity;")
コード例 #21
0
ファイル: TkBoard.py プロジェクト: aweyonhub/Quoridor
 def handle_click(self, e):
     x = e.x
     y = e.y
     # check for button press
     for b in self.buttons:
         (x0, y0, x1, y1), callback = b
         if (x0 <= x <= x1) and (y0 <= y <= y1):
             callback()
             return
             
     if self.game_over or self.gs.current_player.ai:
         return
         
     # check for turn execution
     grid = self.point_to_grid((x,y))
     success = False
     if grid and self.moveType == "move":
         move_str = h.point_to_notation(grid)
         success = self.exec_wrapper(move_str)
     elif grid and self.moveType == "wall":
         orient, topleft = self.xy_to_wall_spec(grid, x, y)
         pos = h.point_to_notation(topleft)
         wall_str = orient+pos
         success = self.exec_wrapper(wall_str)
     if success:
         self.refresh()
コード例 #22
0
ファイル: TkBoard.py プロジェクト: pedromedina/Quoridor
    def handle_click(self, e):
        x = e.x
        y = e.y
        # check for button press
        for b in self.buttons:
            (x0, y0, x1, y1), callback = b
            if (x0 <= x <= x1) and (y0 <= y <= y1):
                callback()
                return

        if self.game_over or self.gs.current_player.ai:
            return

        # check for turn execution
        grid = self.point_to_grid((x, y))
        success = False
        if grid and self.moveType == "move":
            move_str = h.point_to_notation(grid)
            success = self.exec_wrapper(move_str)
        elif grid and self.moveType == "wall":
            orient, topleft = self.xy_to_wall_spec(grid, x, y)
            pos = h.point_to_notation(topleft)
            wall_str = orient + pos
            success = self.exec_wrapper(wall_str)
        if success:
            self.refresh()
コード例 #23
0
ファイル: DownCast.py プロジェクト: AmoghMID/beautiful-capi
def generate_down_cast(output_file, cur_class, base_class, capi_generator):
    cur_class_extra_info = capi_generator.extra_info[cur_class]
    base_class_extra_info = capi_generator.extra_info[base_class]
    output_file.put_line('template<>')
    output_file.put_line(
        'inline {return_type} down_cast(const {input_type}& input_object)'.format(
            return_type=cur_class_extra_info.get_class_name(),
            input_type=base_class_extra_info.get_class_name()
        )
    )
    with FileGenerator.IndentScope(output_file):
        Helpers.put_raw_pointer_structure(output_file)
        c_function_name = '{0}_cast_to_{1}'.format(
            base_class_extra_info.get_c_name(),
            cur_class_extra_info.get_c_name()
        )
        output_file.put_line(
            'return {0}({1}(reinterpret_cast<const raw_pointer_holder*>(&input_object)->raw_pointer), true);'.format(
                cur_class_extra_info.get_class_name(),
                c_function_name,
            )
        )
        c_function_declaration = 'void* {0}(void* object_pointer)'.format(c_function_name)
        capi_generator.loader_traits.add_c_function_declaration(c_function_declaration)
        with FileGenerator.IndentScope(capi_generator.output_source):
            capi_generator.output_source.put_line(
                'return dynamic_cast<{0}*>(static_cast<{1}*>(object_pointer));'.format(
                    cur_class.m_implementation_class_name,
                    base_class.m_implementation_class_name
                )
            )
        capi_generator.output_source.put_line('')
    output_file.put_line('')
コード例 #24
0
def build_markdown(generic_errors: dict):
    lines = []

    common_strings = dict(mdh.get_common_strings())

    if len(generic_errors.keys()) > 0:

        header = mdh.add_column('', common_strings['error_code_header'])
        header = mdh.add_column(header, common_strings['error_type_header'])
        header = mdh.add_column(header,
                                common_strings['error_examples_header'])
        header = mdh.add_column(header, common_strings['error_message_header'])

        Helpers.append_line(lines, header)
        Helpers.append_line(lines, mdh.header_seperator(4))

        for code in generic_errors:
            line = ''
            err = generic_errors[code]

            line = mdh.add_column(line, code)
            line = mdh.add_column(line, err.reason)
            line = mdh.add_column(line,
                                  '`' + '`<br/>`'.join(err.examples) + '`')
            line = mdh.add_column(line, err.message)

            Helpers.append_line(lines, line)
    else:
        Helpers.append_line(lines,
                            mdh.block_quote(common_strings['error_no_errors']))

    Helpers.append_line(
        lines,
        mdh.get_comment('Auto-generated at ' + str(datetime.datetime.now())))
    return ''.join(lines)
コード例 #25
0
ファイル: tkinter-gui.py プロジェクト: denmj/weather-app
    def get_weather_data(city, units):
        weather_url = "https://api.openweathermap.org/data/2.5/weather?"
        weather_api = "3860a5e3975d1317258172dd2623ac4d"
        url = weather_url + "q=" + city + "&units=" + units + "&appid=" + weather_api
        response = requests.get(url)

        # Loading data into SQL DataWarehouse -> WeatherDW
        response_json = response.json()
        one_dim_dict = Helpers.parse_weather_data(response_json)
        Helpers.load_weather_to_SQL(one_dim_dict)

        if response.status_code == 200:
            print("Getting weather data...")
            data = response.json()
            main = data['main']
            weather = data['weather']

            temperature = main['temp']
            humidity = main['humidity']
            pressure = main['pressure']
            report = data['weather']
            condition = weather[0]['main']

            # print(f"{city:-^30}")
            # print(f"Temperature: {temperature}")
            # print(f"Humidity: {humidity}")
            # print(f"Pressure: {pressure}")
            # print(f"Weather Report: {condition}")
            return city, temperature, humidity, pressure, condition
        else:
            # showing the error message
            print("Error in the HTTP request")
コード例 #26
0
ファイル: ELMMethod.py プロジェクト: MartinFreser/ELMEktimo
    def poisciParametre(self, X,Y):

        activation_functions = ['multiquadric' , 'softlim', 'inv_multiquadric', 'gaussian', 'tanh', 'sine', 'tribas', 'inv_tribas', 'sigmoid']

        n_hiddens = [50, 100,200, 500,800, 900, 1000, 1500, 2000, 3000, 5000, 10000]#3, 30,50,100]
        parameters = []
        alphas = [1.0,0.7,0.5,0.0]#0.0,0.2,0.4,0.5,0.7,0.9,1.0]
        nrOfTrials = len(activation_functions)*len(alphas) * len(n_hiddens)
        trial = 1
        np.random.seed(np.random.randint(10000000))
        for n_hidden in  n_hiddens:
            for alpha in alphas:
                for actFunction in activation_functions:
                    cls = GenELMClassifier(hidden_layer = RandomLayer(n_hidden = n_hidden, activation_func = actFunction, alpha=alpha))


                    parameter = Helpers.cv(X,Y,cls,5, printing = False)
                    parameter = parameter+ [n_hidden, alpha, actFunction, "normal"]
                    parameters.append(parameter)
                    print(parameter, "%d/%d" %(trial,nrOfTrials))
                    Helpers.pickleListAppend2(parameter, "parametersELM.p")

                    # parameter = Helpers.cv(X,Y,BaggingClassifier(cls,n_estimators=30),10, printing = False)
                    # parameter = parameter+ [n_hidden, alpha, actFunction, "bagged"]
                    # parameters.append(parameter)
                    # print(parameter, "%d/%d" %(trial,nrOfTrials))

                    trial = trial+1
        # pickle.dump(parameters,open("parametersMultiQuadric.p","wb"))
        return
コード例 #27
0
	def send(self, connection):
		assert type(connection) == Connection
		
		
		"""
		data = struct.pack("<IBIIIBIHIHBB%dsI" % (len(self.description) + 1),
		#data = struct.pack("<IB64sIIBIHIHBB%dsI" % (len(self.description) + 1),
			self.uin, 
			0x01, 
			Helpers.gg_login_hash(self.password, self.seed), 
			self.status, 
			self.version, 
			0x00, 
			Helpers.ip_to_int32(self.local_ip), 
			self.local_port, 
			Helpers.ip_to_int32(self.external_ip), 
			self.external_port, 
			self.image_size, 
			0xbe,
			self.description,
			self.time)

		connection.send(repr(GGHeader(GGOutgoingPackets.GGLogin, len(data))) + data)
		"""
		data = struct.pack("<IIIIBIhIhBB%dsI" % (len(self.description) + 1),
			self.uin, Helpers.gg_login_hash(self.password, self.seed), self.status, self.version, 0x00,
			Helpers.ip_to_int32(self.local_ip), self.local_port, Helpers.ip_to_int32(self.external_ip), self.external_port,
			self.image_size, 0xbe, self.description, self.time)
		
		connection.send(repr(GGHeader(GGOutgoingPackets.GGLogin60, len(data))) + data)
コード例 #28
0
ファイル: main.py プロジェクト: Mateo89/AquaPC-BACKEND
def main():
    GPIO.cleanup()

    settings.load_settings()

    threads = [Logic.Logic(), Display.DisplayThread(), threading.Thread(target=RestThread.run_server)]
    # threads.append(WatchdogThread.WatchdogThread())
    # threads.append(ReminderThread.ReminderThread())

    for th in threads:
        th.start()
        time.sleep(0.5)

    while len(threads) > 0:
        try:
            temp_threads = []

            for t in threads:
                if t is not None and t.isAlive():
                    t.join(0.2)
                    temp_threads.append(t)

            threads = temp_threads

            time.sleep(0.1)
        except (KeyboardInterrupt, SystemExit):
            Register.EXIT_FLAG = True

    Helpers.log("ZAPISYWANIE KONFIGURACJI")
    settings.save_settings()
    Helpers.log("ZAMYKANIE APLIKACJI")
コード例 #29
0
ファイル: Eigenvalues.py プロジェクト: Armi23/Eigenvalues
def characteristic(matrix): 
    H.check_square(matrix)
    if len(matrix) < 15:    
        coeffs = _coeffs(matrix) 
    else: 
        coeffs = np.poly(matrix)
    return _build(coeffs)
コード例 #30
0
ファイル: Game.py プロジェクト: blackyabhishek/AI
 def update_shortest_path(self, player):
     sp = player.shortest_path
     recalc_path = True
     if sp:
         if len(sp) > 1 and player.position == sp[1]:
             # player moved one step along shortest path.
             #   new shortest path is same as previous, starting 1 farther along
             player.shortest_path = sp[1:]
             recalc_path = False
         elif player.position == sp[0]:
             # p hasn't moved - check if sp is still clear
             broken = False
             for i in range(len(sp)-1):
                 e = (sp[i], sp[i+1], 1)
                 if not self.graph.hasEdge(e):
                     # path interrupted by new wall
                     broken = True
                     break
             # path still clear, therefore still shortest. no change!
             if not broken:
                 recalc_path = False
     
     if recalc_path:
         player.shortest_path = self.get_shortest_path_player(player, True)
         h.increment_int_stat('sp-slow-updates')
     else:
         h.increment_int_stat('sp-fast-updates')
コード例 #31
0
def characteristic(matrix):
    H.check_square(matrix)
    if len(matrix) < 15:
        coeffs = _coeffs(matrix)
    else:
        coeffs = np.poly(matrix)
    return _build(coeffs)
コード例 #32
0
def loglik_test_ordinal(theta, normalization_params, list_type):
    output = dict()
    epsilon = 1e-6

    # We need to force that the outputs of the network increase with the categories
    partition_param, mean_param = theta

    batch_size = mean_param.shape[0]

    mean_value = mean_param.reshape(-1, 1)
    soft_plus_partition_param = np.log(
        1 + np.exp(-np.abs(partition_param))) + np.maximum(partition_param, 0)

    theta_values = np.cumsum(np.clip(soft_plus_partition_param, epsilon, 1e20),
                             axis=1)
    sigmoid_est_mean = expit(theta_values - mean_value)
    mean_probs = np.c_[sigmoid_est_mean,
                       np.ones(batch_size)] - np.c_[np.zeros(batch_size),
                                                    sigmoid_est_mean]
    mean_probs = np.clip(mean_probs, epsilon, 1e20)

    mean_logits = np.log(mean_probs / (1 - mean_probs))

    pseudo_cat = 1 + Helpers.cat_sample(mean_logits)

    output['samples'] = Helpers.sequence_mask(pseudo_cat, batch_size,
                                              int(list_type['dim']))
    output['params'] = mean_probs

    return output
コード例 #33
0
def remove_override_switch(switch):
    Register.POWERMOD_DATA_OVERRIDE[str(
        switch)]['override_time'] = datetime.datetime.now()
    if Register.POWERMOD_DATA[str(switch)]['override']:
        Register.POWERMOD_DATA[str(switch)]['override'] = False
        Helpers.log("Zdjecie locka z: " +
                    Register.POWERMOD_DATA[str(switch)]['name'])
コード例 #34
0
 def test_gradient(self):
     layers = list()
     layers.append(self.Sigmoid())
     layers.append(Helpers.SoftMax())
     difference = Helpers.gradient_check(layers, self.input_tensor,
                                         self.label_tensor)
     self.assertLessEqual(np.sum(difference), 1e-5)
コード例 #35
0
def decideNextAction():
    try:
        SonarFilter.update()
        b = ActionCommand.Body()
        h = ActionCommand.Head()
        l = ActionCommand.LED()

        if Helpers.localised():
            l.leftEye(0, 1, 1)
        elif Helpers.unLocalised():
            l.leftEye(1, 0, 1)
        else:
            l.leftEye(0, 0, 1)
        if Robot.vNumBalls() > 0:
            l.rightEye(0, 1, 0)
        elif Helpers.foundBall():
            l.rightEye(1, 1, 0)
        else:
            l.rightEye(1, 0, 0)

        from math import radians

        b.actionType(ActionCommand.Body.STAND)
        skillInstance.execute(b, h, l)
        Robot.setAction(h, b, l)
        # print (b, h, l)
    except KeyboardInterrupt:
        print "###########################"
        print "##    SIGINT RECEIVED    ##"
        print "##       BY PYTHON       ##"
        print "##  ATTEMPTING SHUTDOWN  ##"
        print "###########################"
        Robot.attemptShutdown()
コード例 #36
0
def get_hours(placemark):
    pattern = re.compile('<description>.*?</description>', re.S)
    matches = re.findall(pattern, placemark)
    if len(matches) > 0:
        match = Helpers.cleanxml(matches[0])
        return Helpers.only_single_whitespace(match)
    return ""
コード例 #37
0
def generator(data,
              anchor_ratios,
              anchor_scales,
              stride,
              input_processor,
              max_height=None,
              max_width=None,
              apply_padding=False):
    while True:
        for image_data in data:
            img = image_data["image"].numpy()
            #获取grund true
            gt_boxes = Helpers.bbox_handler(img, image_data["objects"]["bbox"])
            #获取边际
            img_boundaries = Helpers.get_image_boundaries(img)
            if apply_padding:
                #500*500 标准化, 填充的边框值
                img, padding = Helpers.get_padded_img(img, max_height,
                                                      max_width)
                #更新填充后的grund true
                gt_boxes = update_gt_boxes(gt_boxes, padding)
                #更新填充后的边际
                img_boundaries = Helpers.update_image_boundaries_with_padding(
                    img_boundaries, padding)
            anchors = get_anchors(img, anchor_ratios, anchor_scales, stride)
            anchor_count = len(anchor_ratios) * len(anchor_scales)
            #产生的框与gt的相对比例 [center_x, center_y, width, height]
            bbox_deltas, labels = get_bbox_deltas_and_labels(
                img, anchors, gt_boxes, anchor_count, stride, img_boundaries)
            #图片预处理
            input_img = get_input_img(img, input_processor)
            yield input_img, [bbox_deltas, labels]
コード例 #38
0
ファイル: settings.py プロジェクト: Mateo89/AquaPC-BACKEND
def save_filter():
    with open('filter.settings', 'w') as data_file:
        configString = json.dumps(Register.FILTER_SETTINGS, default=lambda o: o.__dict__, sort_keys=True, indent=4,
                                  separators=(',', ': '))
        data_file.write(configString)
        data_file.close()
        Helpers.log("Zapisano ustawienia Filtrow")
コード例 #39
0
    def addNewMemberDetails(self):
        click(find(Pattern("first_name-1.png").similar(0.62)).right(30))
        person_name = Helpers.generate_random_string()
        type(person_name)

        click(find(Pattern("last_name-1.png").similar(0.61)).right(30))
        person_last_name = Helpers.generate_random_string()
        type(person_last_name)

        calc = find(
            Pattern("region_calendar_icon.png").similar(0.74).targetOffset(
                143, 9))

        click(calc.inside().find("1430589398792.png"))

        month = Region(791, 348, 504, 433).find(
            Pattern("Exact.png").targetOffset(-73, 1)).below(35)

        click(month)
        click(Pattern("value_month.png").similar(0.59))
        wait(2)
        #date = month.right(100)click(date)wait(1)click(find("date_drop_down.png").inside().find("1430584640795.png"))wait(1)
        doubleClick("1430894997195.png")
        type("1984")
        click(find(Pattern("birth_place.png").similar(0.61)).right(30))
        birth_place = Helpers.generate_random_string()
        type(birth_place)
        click(find(Pattern("1428488759155.png").similar(0.50)))
コード例 #40
0
ファイル: settings.py プロジェクト: Mateo89/AquaPC-BACKEND
def load_settings():

    with open('water.settings', 'r') as data_file:
        Register.WATER_SETTINGS = json.load(data_file)

    with open('lamp.settings', 'r') as data_file:
        Register.LAMPS_SETTINGS = json.load(data_file)

    with open('bottles.settings', 'r') as data_file:
        Register.BOTTLE_SETTINGS = json.load(data_file)

    with open('heater.settings', 'r') as data_file:
        Register.HEATER_SETTINGS = json.load(data_file)

    with open('co2.settings', 'r') as data_file:
        Register.CO2_SETTINGS = json.load(data_file)

    with open('o2.settings', 'r') as data_file:
        Register.O2_SETTINGS = json.load(data_file)

    with open('filter.settings', 'r') as data_file:
        Register.FILTER_SETTINGS = json.load(data_file)

    with open('ph.settings', 'r') as data_file:
        Register.PH_SETTINGS = json.load(data_file)

    Helpers.log("Wczytano ustawienia")
コード例 #41
0
    def evaluate_(self, test_loader, print_conll=False):
        correct, total = 0, 0
        self.eval()

        tag_tensors = [i.upos for i in test_loader]
        for i, batch in enumerate(test_loader):
            (
                x_forms, pack
            ), x_tags, y_heads, y_deprels = batch.form, batch.upos, batch.head, batch.deprel

            mask = torch.zeros(pack.size()[0],
                               max(pack)).type(torch.LongTensor)
            for n, size in enumerate(pack):
                mask[n, 0:size] = 1

            # get tags
            y_pred = self(x_forms, pack).max(2)[1]

            mask = Variable(mask.type(torch.ByteTensor))
            if self.cuda:
                mask = mask.cuda()

            correct += ((x_tags == y_pred) * mask).nonzero().size(0)

            total += mask.nonzero().size(0)

            if print_conll:
                tag_vocab = self.vocab[2]
                tags = [tag_vocab.itos[i.data[0]] for i in y_pred.view(-1, 1)]
                Helpers.write_tags_to_conllu(self.test_file, tags, i)

        print("Accuracy = {}/{} = {}".format(correct, total,
                                             (correct / total)))
        if self.chain: return tag_tensors
コード例 #42
0
    def handle_mouse_motion(self, x, y):
        if self.game_over or self.gs.current_player.ai:
            return
        self.recent_x = x
        self.recent_y = y
        grid = self.point_to_grid((x, y))
        if grid and self.moveType == "move":
            move_str = h.point_to_notation(grid)
            if move_str != self.active_move:
                self.active_move = move_str
                if self.gs.turn_is_valid(move_str, "move"):
                    self.draw_player(grid, self.gs.current_player_num - 1,
                                     True)
                elif self.player_ghost:
                    self.tk_canv.delete(self.player_ghost)
                    self.player_ghost = None

        elif grid and self.moveType == "wall":
            orient, topleft = self.xy_to_wall_spec(grid, x, y)
            pos = h.point_to_notation(topleft)
            wall_str = orient + pos
            if wall_str != self.active_wall:
                self.active_wall = wall_str
                active_error = not self.gs.turn_is_valid(wall_str, "wall")
                self.redraw_walls(active_error)
コード例 #43
0
    def score(self, hand):
        #find total number of points in hand, cards above 10 are worth 10 points
        points = Helpers.get_hand_value(hand)

        #find minimum turns necessary to get below 5 points
        if (points) <= 5:
            return points

        plays = Helpers.show_plays(hand)
        plays_points = list(
            map(lambda play: Helpers.get_hand_value(play), plays))

        #do a play that removes most points
        poss_plays_index = HeuristicHelpers.argsmax(plays_points)

        #check which of those leads to lowest score in future
        poss_scores = []
        for index in poss_plays_index:
            for card in plays[index]:
                next_hand = hand.copy()
                next_hand.remove(card)
                poss_scores.append(self.PENALTY_PER_TURN +
                                   self.score(next_hand))

        return min(poss_scores)
コード例 #44
0
ファイル: NeuronLayer.py プロジェクト: BGS/school
    def backpropagate(self, label):
        """
        Back propagate in order to determine the errors in the neuron
        layer (a.k.a deltas) based on the errors in the next layer
        or if the layer is the last one, calculate deltas based on the
        desired output and the actual output
        :param label: the label of the current data being analyzed
        e.g. if the current inputs of the neural net represent the digit 9,
        the label will be '9'
        :return: nothing
        """
        if self._is_output is False:
            next_weights = np.transpose(self._output_layer.get_weights())
            next_deltas = np.reshape(self._output_layer.get_deltas(),
                                     self._output_layer.get_num_neurons())
            self._deltas = np.multiply(
                np.dot(next_weights, next_deltas),
                np.reshape(Helpers.sigmoid_prime_vec(self._zs),
                           np.dot(next_weights, next_deltas).shape))
        else:
            self._deltas = (self._activations - Helpers.desired_output(label, self._activations.size)) \
                           * Helpers.sigmoid_prime_vec(self._zs)

        if self._is_input is False:
            # update nabla_b
            self._nabla_b += self._deltas

            # update nabla_w
            self._nabla_w += np.dot(
                np.atleast_2d(self._deltas).T,
                np.atleast_2d(self._input_layer.get_activations()))
コード例 #45
0
    def update_shortest_path(self, player):
        sp = player.shortest_path
        recalc_path = True
        if sp:
            if len(sp) > 1 and player.position == sp[1]:
                # player moved one step along shortest path.
                #   new shortest path is same as previous, starting 1 farther along
                player.shortest_path = sp[1:]
                recalc_path = False
            elif player.position == sp[0]:
                # p hasn't moved - check if sp is still clear
                broken = False
                for i in range(len(sp) - 1):
                    e = (sp[i], sp[i + 1], 1)
                    if not self.graph.hasEdge(e):
                        # path interrupted by new wall
                        broken = True
                        break
                # path still clear, therefore still shortest. no change!
                if not broken:
                    recalc_path = False

        if recalc_path:
            player.shortest_path = self.get_shortest_path_player(player, True)
            h.increment_int_stat('sp-slow-updates')
        else:
            h.increment_int_stat('sp-fast-updates')
コード例 #46
0
ファイル: TreeAI.py プロジェクト: aweyonhub/Quoridor
    def get_relevant_plies(game_state, verbose=False):
        relevant_walls = []
        # timing/stats
        tstart = time()
        num_plies = len(game_state.legal_walls) + len(game_state.legal_moves)
        # consider walls around the 2 players, plus or minus a row and column
        for p in game_state.players:
            pr, pc = p.position
            for r in range(pr-2, pr+2):
                for c in range(pc-2, pc+2):
                    upleft = h.point_to_notation((r,c))
                    relevant_walls.extend(['H'+upleft, 'V'+upleft])

        """ OLD VERSION: all walls in bounding box of players, + 1 border
        cp = game_state.current_player
        ops = game_state.other_players
        cpr, cpc = cp.position
        for op in ops:
            opr, opc = op.position
            for r in range(min(cpr-2, opr-2), max(cpr+2, opr+2)):
                for c in range(min(cpc-2, opc-2), max(cpc+2, opc+2)):
                    upleft = h.point_to_notation((r,c))
                    relevant_walls.extend(['H'+upleft, 'V'+upleft])
        """
        # consider 'choke points' (i.e. narrow passages on the board)
        h_choke_points = TreeAI.get_h_chokepoints(game_state, 4)
        v_choke_points = TreeAI.get_v_chokepoints(game_state, 4)
        
        # now we have choke-points. consider walls in their range
        # TODO - if multiple similar in a row, use even # one
        #           - ok maybe not. this would avoid strategy of S-turns in 3-wide space
        #      - include walls with upleft 1 space further from border than start
        #   horizontal chokes
        for ((sr, sc), length) in h_choke_points:
            for c in range(sc, sc+length):
                upleft = h.point_to_notation((sr, c))
                relevant_walls.extend(['H'+upleft, 'V'+upleft])
        #   vertical chokes
        for ((sr, sc), length) in v_choke_points:
            for r in range(sr, sr+length):
                upleft = h.point_to_notation((r, sc))
                relevant_walls.extend(['H'+upleft, 'V'+upleft])
        
        # filter so only legal walls
        relevant_walls = [wall for wall in relevant_walls if wall in game_state.legal_walls]
        
        # unique-ify them
        rw_dict = {}
        for w in relevant_walls:
            rw_dict[w] = 1
        relevant_walls = rw_dict.keys()
        
        relevant_plies = game_state.legal_moves + relevant_walls
        
        # print stats
        new_num_plies = len(relevant_plies)
        if verbose:
            print "reduced %-3d plies to %-3d in %f seconds" % (num_plies, new_num_plies, time()-tstart)
        return relevant_plies
コード例 #47
0
ファイル: Player.py プロジェクト: blackyabhishek/AI
 def duplicate(self, new=False):
     new_p = Player(self.position, h.list_copy(self.goal_positions),\
                     self.num_walls, self.name, self.sortfunc, self.ai)
     if not new:
         new_p.available_points = h.list_copy(self.available_points)
         new_p.movement_history = h.list_copy(self.movement_history)
         new_p.shortest_path = h.list_copy(self.shortest_path)
     return new_p
コード例 #48
0
ファイル: World.py プロジェクト: gzhang01/CS51FinalProject
	def remove_nodes_inside(self, p1, p2, mult):
		xlist = Helpers.get_multiples(p1.getX(), p2.getX(), mult)
		ylist = Helpers.get_multiples(p1.getY(), p2.getY(), mult)
		for x in xlist:
			for y in ylist:
				node = self.get_node(Point(x, y))
				if node is not None:
					self.remove_node(self.get_node(Point(x, y)))
コード例 #49
0
ファイル: Eigenvalues.py プロジェクト: Armi23/Eigenvalues
def _tlist_maker(matrix): 
    tlist = H.make_empty_row()
    tlist = H.add_el_to_r(tlist,trace(matrix))
    powerA = matrix
    for i in xrange(len(matrix)-1):
        powerA = H.multiply(matrix,powerA)
        tlist =  H.add_el_to_r(tlist,trace(powerA))
    return tlist
コード例 #50
0
 def show(self):
     """Displays the model using cadquery helper functions. These functions
     are provided by cadquery-freecad-module thus you should call
     this method only from FreeCad Cadquery workbench."""
     import Helpers
     for p in self.parts:
         color = (p[1][0]*255, p[1][1]*255, p[1][2]*255, 0)
         Helpers.show(p[0], color)
コード例 #51
0
 def main(self):
     #hex is a subset of tri
     self._triNums = Helpers.getTriangleNumbers(56700)
     self._pentNums = Helpers.getPentagonalNumbers(56000)
     self._hexNums = Helpers.getHexagonalNumbers(56000)
     results = self.triAndPenAndHexgen()
     for i in range(3):
         print results.next()
コード例 #52
0
def getLengthError(pattern1, pattern2):
	totalLengthError = 0
	lengths1 = [x[1] for x in pattern1]
	lengths2 = [x[1] for x in pattern2]
	normalizedLengths1 = Helpers.normalizeLengths(lengths1)
	normalizedLengths2 = Helpers.normalizeLengths(lengths2)
	for length1, length2 in zip(normalizedLengths1, normalizedLengths2):
		totalLengthError += max(length1,length2)/min(length1,length2)-1
	return totalLengthError/len(pattern1)
コード例 #53
0
ファイル: Eigenvalues.py プロジェクト: Armi23/Eigenvalues
def eigenvalue(matrix,acc=4,iacc=4): 
    H.check_square(matrix)
    if len(matrix) < 15:
        coeffs = _coeffs(matrix)
        solutions = H.roots(coeffs)
    else:
        solutions = sc.eigvals(matrix)
    (real,imag) = _splits(solutions,acc,iacc)
    return real,imag
コード例 #54
0
ファイル: DataContainer.py プロジェクト: juliameier/pyphant1
 def __init__(self, longname, shortname, attributes=None):
     self.longname = longname
     self.shortname = shortname
     self.machine = Helpers.getMachine()
     self.creator = Helpers.getUsername()
     if type(attributes) == type({}):
         self.attributes = attributes
     else:
         self.attributes = {}
コード例 #55
0
ファイル: ExportDialog.py プロジェクト: dede67/FillBD2
  def executeCMDs(self):
    progBarVal=0
    cnt=len(self.fileDict)

    self.messages.SetValue("")

    if self.jobType==0:
      cmd=["cp", "-rp"]
    elif self.jobType==1:
      cmd=["mv"]
    else:
      self.EndModal(wx.ID_CANCEL)

    if DEBUG_FS==True:
      countup=bnls=0
      formatstrg="{0:15} {1:15} {2:15} {3:15} {4:15} {5:5} {6:15}"

    # nach filename sortiert über "self.fileDict" iterieren
    for k in OrderedDict(sorted(self.fileDict.items(), key=lambda t: t[1].filename)):
      v=self.fileDict[k]
      cmdToExecute=cmd+[k, self.targetFolder] # Kommando zusammensetzen

      self.messages.AppendText(   self.listToString(cmdToExecute)+"\n")
      self.currentBytes.SetValue( hlp.intToStringWithCommas(v.sizeAdj))
      self.objRemain.SetValue(    hlp.intToStringWithCommas(cnt))
      self.bytesRemain.SetValue(  hlp.intToStringWithCommas(self.sumBytesToCopy-progBarVal))
      wx.Yield()

      if DEBUG_FS==True:
        szv=os.statvfs(self.targetFolder)
        sv=szv.f_bavail*szv.f_bsize       # Dateisystem-Restgröße vor dem copy

      self.executeSingleCMD(cmdToExecute)

      if self.abortTransfer==True:                          # Abbruch-Wunsch weiterreichen
        break
      cnt-=1
      progBarVal+=v.sizeAdj   # Fortschritt abhängig von der aktuellen Dateigröße...
      self.progBar.SetValue(progBarVal//self.gauge_devisor)  # ...darstellen
      wx.Yield()

      if DEBUG_FS==True:
        countup+=1                        # Nummer der bearbeiteten Datei
        szn=os.statvfs(self.targetFolder)
        sn=szn.f_bavail*szn.f_bsize       # Dateisystem-Restgröße nach dem copy
        delta1=(sv-sn)                    # bei letztem copy belegte Byte
        delta2=delta1-v.sizeAdj           # Differenz der belegten Byte zur Dateigröße (also der Fehler)
        bn=os.path.basename(k)            # Dateiname der gerade kopierten Datei
        bnls+=len(bn)                     # Länge der bisher kopierten Dateinamen
        print formatstrg.format(sv, sn, delta1, v.sizeAdj, delta2, countup, bn)

    self.currentBytes.SetValue( "0")
    self.objRemain.SetValue(    "0")
    self.bytesRemain.SetValue(  "0")

    self.ok.Enable()        # Schließen des Dialoges freischalten
    self.cancel.Disable()   # der Cancel-Button wird jetzt nicht mehr gebraucht
コード例 #56
0
ファイル: MetaDES.py プロジェクト: MartinFreser/ELMEktimo
 def fitWithAlreadySaved(self, saveModel = True, folder = "data/dataForMeta/"):
     print("reading already saved features in "+folder)
     metaFeatures = np.loadtxt(folder + "MetaFeatures_K"+str(self.K)+"_Kp"+str(self.Kp)+".csv", delimiter=",")
     metaResponse = np.loadtxt(folder + "MetaResponse_K"+str(self.K)+"_Kp"+str(self.Kp)+".csv", delimiter = "\n")
     print("We are fitting already computed features in "+folder)
     print("shape of the feature matrix: " + str(metaFeatures.shape))
     self.fitMetaCls(metaFeatures,metaResponse)
     print("done!")
     if saveModel: Helpers.shraniModel(self.metaCls, "data/dataForMeta/metaModels/"+self.metaCls.name+"/"+self.metaCls.name+".p")
コード例 #57
0
ファイル: SetupDialog.py プロジェクト: dede67/FillBD2
 def getData(self):
   return( ( self.name.GetValue(),
             self.comment.GetValue(),
             hlp.stringWithCommasToInt(self.size.GetValue()),
             hlp.stringWithCommasToInt(self.blocksize.GetValue()),
             self.getAddBlock(),
             self.folder.GetValue(),
             self.final.GetSelection()
           )
         )
コード例 #58
0
def convertPatternToAngleAndLength(letterPoints):
	patternInAngleAndLength = []
	oldPoint = letterPoints[0]
	for i in xrange(1,len(letterPoints)):
		newPoint = letterPoints[i]
		angle = Helpers.getAngle(oldPoint, newPoint)
		length = Helpers.getDistance(oldPoint, newPoint)
		patternInAngleAndLength.append((angle,length))
		oldPoint = newPoint
	return patternInAngleAndLength
コード例 #59
0
ファイル: Eigenvalues.py プロジェクト: Armi23/Eigenvalues
def _R_determinant(matrix):    
    if len(matrix) == 2:
        return _simple_determinant(matrix)
    else:
        answer = 0
        for i in xrange(0, len(matrix)):
            el = H.get_el(matrix,0,i)            
            smaller = H.remove_col(matrix,i)
            smaller = H.remove_row(smaller,0)
            answer += el*(-1.0)**(i+1)*_R_determinant(smaller)
    return answer