blob_id stringlengths 40 40 | language stringclasses 1
value | repo_name stringlengths 5 133 | path stringlengths 2 333 | src_encoding stringclasses 30
values | length_bytes int64 18 5.47M | score float64 2.52 5.81 | int_score int64 3 5 | detected_licenses listlengths 0 67 | license_type stringclasses 2
values | text stringlengths 12 5.47M | download_success bool 1
class |
|---|---|---|---|---|---|---|---|---|---|---|---|
0c9a038aea4c6a6975b9b27c234006990be1d69c | Python | ulan2005/ulllan | /for i in range(10):.py | UTF-8 | 1,096 | 3.328125 | 3 | [] | no_license | # lang1='Rust'
# languages=['go','java','php','python','javascript','ruby']
# for i in range(3):
# if languages[i] == lang1:
# print('this languages is in list')
# else:
# print('NOT')
#2
'''lang='php'
languages=['go,'java','php','python','javascript','ruby']
i = 0'
while languages[i] != lang:
print(languages[i... | true |
807cbb45a332b26a3c42945ab45fd6d7571ef9e1 | Python | junxuuuuu/2D-bin-packing-maximal-rectangles-algorithm- | /run.py | UTF-8 | 12,572 | 2.5625 | 3 | [] | no_license | import sys
import time
import pygame
import cv2
import pickle
import numpy as np
import matplotlib.pyplot as plt
white = 255, 255, 255
containers = [[0, 0, 300, 300]]
firstcontainer = containers[0]
show = True
rrectangles = [[0, 0, 50, 50], [0, 0, 200, 200], [0, 0, 30, 40], [0, 0, 70, 70], [0, 0, 30, 30], [0, 0, 10, ... | true |
891b267ea313ef5416c47d52d9eb72006e9b327c | Python | j-a-c/avengers | /camera.py | UTF-8 | 833 | 3.4375 | 3 | [] | no_license | import pygame
from constants import SCREEN_WIDTH,SCREEN_HEIGHT
class Camera(object):
def __init__(self,screen):
self.screen = screen
self.window = pygame.Rect(0,0,SCREEN_WIDTH,SCREEN_HEIGHT)
def updatePosition(self,player_rect):
#camera center on player
self.window.center = pl... | true |
dd20d550a4e70bb495ca3c07bd9988ac133a3640 | Python | wakabame/kyopro | /atcoder_contest/agc019/c.py | UTF-8 | 816 | 3.390625 | 3 | [] | no_license | import math
def LIS(L):
from bisect import bisect_left
seq = []
for i in L:
pos = bisect_left(seq, i)
if len(seq) <= pos:
seq.append(i)
else:
seq[pos] = i
return len(seq)
x1, y1, x2, y2 = map(int, input().split())
N = int(input())
W = abs(x2 - x1)
H =... | true |
52944bb327a35b1e0030d5fa38b3c68f7b899a05 | Python | krinj/open-images-starter | /modules/loader.py | UTF-8 | 6,851 | 2.859375 | 3 | [
"MIT"
] | permissive | # -*- coding: utf-8 -*-
"""
Use this to load, save, and display images, samples, and labels.
"""
import csv
import json
import os
import urllib.request
from typing import Dict, List
from modules.detect_region import DetectRegion
from modules.sample import Sample
from modules.settings import ProjectSettings
from tool... | true |
81a380b716fe72c491f9eb7d924a7ec949e449d8 | Python | timpowellgit/thesis | /code/unigramforlatex.py | UTF-8 | 517 | 2.78125 | 3 | [] | no_license | from tabulate import tabulate
import re
f = open('scorefile70.txt')
lines = f.readlines()
table = []
for line in lines[:100]:
strength,word = line.split(',')[0],line.split(',')[1]
predictor = re.sub(r"(']|^\su')", "", word)
score = re.sub(r"^\[", '', strength)
pred =r'%s' %(predictor[:-1].decode('unicode-es... | true |
7701217c088e4f130c5d7715874086b597fd4548 | Python | dannystaple/PythonSubdivision | /pygame_subdiv.py | UTF-8 | 4,827 | 3.171875 | 3 | [
"CC-BY-3.0"
] | permissive | import json
import sys, pygame
import time
black = 0, 0, 0
white = 0xff, 0xff, 0xff
def subdivide():
return [[], [], [], []]
def test_tree():
tree = subdivide()
tree[0] = subdivide()
tree[0][1] = subdivide()
tree[0][1][0] = subdivide()
return tree
class Game:
_tree = []
_lastChang... | true |
00dd211e629a2c105d61278544ef5c0c1179da94 | Python | SantiagoYoung/eVeryDay | /CorePythonProgram/PyUseInput.py | UTF-8 | 2,384 | 3.609375 | 4 | [] | no_license | from pymouse import PyMouse
from pykeyboard import PyKeyboard
m = PyMouse()
k = PyKeyboard()
x_dim , y_dim = m.screen_size()
m.click(x_dim/2, y_dim/2)
k.type_string('Hello World!')
PyKeyboard还有很多种方式来发送键盘键入:
# pressing a key
k.press_key('H')
# which you then follow with a release of the key
k.release_key('H')
# or... | true |
aacff58e435905c12d51aa3b9800165e4381a28f | Python | pasmavie/oldgulo | /tests/test_stationarity.py | UTF-8 | 1,278 | 3.140625 | 3 | [] | no_license | import numpy as np
import unittest
from gulo.mean_reversion.stationarity import adf, hurst_exp
from gulo.brownian import brownian
class TestStationarity(unittest.TestCase):
def setUp(self):
np.random.seed(0)
self.N = 5000
self.stationary_series = np.random.poisson(0.5, size=self.N)
... | true |
79db3c6304311ea844d7a164c8003737e26985d9 | Python | Zarrathustra/Script | /Plot_Scripts/Year_Resolution.py | UTF-8 | 582 | 3.140625 | 3 | [] | no_license | from pylab import *
import matplotlib.patches as mpatches
filename = "Year_Resolution.csv"
# Data Reading and Checking
# Collecting and Cleaning Data
lines = open(filename, "r").readlines();
X = [line.strip().split(",")[0] for line in lines]
Y = [line.strip().split(",")[1] for line in lines]
X = X[-6:]
Y = Y[-6:]
X ... | true |
01c9aa2a90bf425f333bf27fc906063e52d22ce3 | Python | feigaoxyz/adventofcode | /year2017/day03.py | UTF-8 | 2,683 | 3.84375 | 4 | [] | no_license | import itertools
import math
from common import validation, neighbors
PART1_DOC = """
## [Day 03: Spiral Memory](http://adventofcode.com/2017/day/3)
### Part 1
Compute the Manhatten distance between a number and 1 in spiraling grid:
```
17 16 15 14 13
18 5 4 3 12
19 6 1 2 11
20 7 8 9 10
21 ... | true |
a12b4471e02aeddf7b7de0714f4a79478f089e68 | Python | JrGoodle/clowder | /clowder/util/git/model/factory.py | UTF-8 | 10,995 | 2.53125 | 3 | [
"MIT"
] | permissive | """git model factory
.. codeauthor:: Joe DeCapo <joe@polka.cat>
"""
from pathlib import Path
from typing import List, Optional, Tuple
from clowder.util.git.offline import GitOffline
from clowder.util.git.online import GitOnline
from .change import Change
from .diff import Diff
from .branch.local_branch import Loca... | true |
a5a2498098f131bc3f99d5f0427efeab1d064cfa | Python | kasanitej/Project-Euler-Python | /07_10001st prime.py | UTF-8 | 389 | 3.265625 | 3 | [] | no_license | from math import log
number=10001
limit = number * (log(number) + log(log(number))) #Rosser's Theorem
a = [True] * int(limit)
a[0] = a[1] = False
for (i, isprime) in enumerate(a):
if i%2 == 0 and i != 2:
a[i]=False
if isprime:
for n in range(i*i,int(limit),i):
a[n]=Fals... | true |
5474831c22a1f46a13834f630e7f42b1aaa2f440 | Python | shit-happens/housing-prices-prediction | /housing price regression model.py | UTF-8 | 5,254 | 2.609375 | 3 | [] | no_license | # -*- coding: utf-8 -*-
"""
Spyder Editor
This is a temporary script file.
"""
# Importing the libraries
import numpy as np
import matplotlib.pyplot as plt
import pandas as pd
# Importing the dataset
dataset1 = pd.read_csv('train.csv')
dataset2 = pd.read_csv('test.csv')
#dataset.isnull().sum().sum()
#preparing the d... | true |
b960c8e9e0a19bd01cac84623bf8c7f714c5b9eb | Python | ray-project/ray | /rllib/examples/export/onnx_tf.py | UTF-8 | 2,484 | 2.609375 | 3 | [
"MIT",
"BSD-3-Clause",
"Apache-2.0"
] | permissive | import argparse
import numpy as np
import onnxruntime
import os
import shutil
import ray
import ray.rllib.algorithms.ppo as ppo
parser = argparse.ArgumentParser()
parser.add_argument(
"--framework",
choices=["tf", "tf2"],
default="tf2",
help="The TF framework specifier (either 'tf' or 'tf2').",
)
i... | true |
13952628f00eef66beb8eecf8b6b49230c689a64 | Python | catboost/catboost | /contrib/python/fonttools/fontTools/misc/bezierTools.py | UTF-8 | 44,168 | 2.953125 | 3 | [
"MIT",
"LicenseRef-scancode-unknown-license-reference",
"OFL-1.1",
"BSD-3-Clause",
"Apache-2.0"
] | permissive | # -*- coding: utf-8 -*-
"""fontTools.misc.bezierTools.py -- tools for working with Bezier path segments.
"""
from fontTools.misc.arrayTools import calcBounds, sectRect, rectArea
from fontTools.misc.transform import Identity
import math
from collections import namedtuple
try:
import cython
COMPILED = cython.c... | true |
eb381473ab1bde04586e5eefe6042bb778f60057 | Python | chatper/sentilo-client-python | /src/AlarmsServiceOperations.py | UTF-8 | 1,150 | 2.59375 | 3 | [] | no_license | from utils import SentiloRestClient, SentiloLogs, SentiloUtils, SentiloResponse
path = {
'path' : '/alarm'
}
def publish(alert, inputMessage):
SentiloLogs.debug('Publishing alarm!')
inputMessage.update(path)
inputMessage['path'] = inputMessage['path'] + '/' + alert
if inputMessage['body']['message... | true |
7ab8bd126898b3c3cac36dfa9994ffe27811add0 | Python | huiup/python_code | /emoji/emoji.py | UTF-8 | 571 | 3.28125 | 3 | [] | no_license | import emoji
'''
https://www.unicode.org/emoji/charts/full-emoji-list.html#1f618
function:
demojize: 将unicode emoji替换为字符串简码用于存储
emoji_count: 返回字符串中emoji的数量
emoji_lis: 返回字符串中emoji的位置
emojize: 将字符串简码替换成unicode emoji
get_emoji_regexp: 返回编译后的正则表达式,匹配`emoji.UNICODE_EMOJI_ALIAS`
'''
# for ... | true |
f97fe098af84fce32a988f3ea516a1cfa3dfc791 | Python | KalsaHT/lc_practice | /backtracking/51.py | UTF-8 | 2,910 | 2.921875 | 3 | [] | no_license | #-*-coding:utf-8-*-
'''
@Author: llei
@Date: 2022-05-28 10:30:20
'''
from operator import le
import sys
import os
from turtle import right
from typing import List, Tuple, Dict
sys.path.append("..")
# 超时
class Solution1:
def solveNQueens(self, n: int) -> List[List[str]]:
from copy import deepcopy
e... | true |
12681da49a1b58f8832de4a7636681211f77395e | Python | smsrikanthreddy/InterviewBit | /arrays/getDecimalValue.py | UTF-8 | 807 | 3.328125 | 3 | [] | no_license | # Definition for singly-linked list.
# class ListNode:
# def __init__(self, val=0, next=None):
# self.val = val
# self.next = next
class Solution:
def getDecimalValue(self, head: ListNode) -> int:
sums = 0
'''
### O(n) + O(1)
#while head:
# sums = 2*su... | true |
252c49cb3c737629e1eaf485dca6885780d7279e | Python | diegolazareno/Machine-Learning | /Code/K-nearest neighbours (1).py | UTF-8 | 2,207 | 3.625 | 4 | [] | no_license | # -*- coding: utf-8 -*-
"""
Created on Tue Jul 28 13:12:12 2020
@author: López Lazareno Diego Alberto
"""
#%% K-Nearest Neighbours
# Parte 1. KNN (MNIST dataset)
# Librerías
import pandas as pd
import numpy as np
from sortedcontainers import SortedList
# K-Nearest Neighbours (objeto)
class KNN(object):
# Ini... | true |
2dcc9597d9b2d9fd5acce75401aae09e29254639 | Python | Yosri-ctrl/holbertonschool-web_back_end | /0x07-Session_authentication/api/v1/auth/session_auth.py | UTF-8 | 795 | 2.75 | 3 | [] | no_license | #!/usr/bin/env python3
"""class SessionAuth that inherits from Auth
"""
from api.v1.auth.auth import Auth
from uuid import uuid4
class SessionAuth(Auth):
"""class SessionAuth that inherits from Auth
for creating a new authentication mechanism
"""
user_id_by_session_id = {}
def create_session(self... | true |
55e9340cbd74b561e08c65f65238f3bf9cee60a7 | Python | ngthnam/Python | /Python Basics/31_String_Manipulations.py | UTF-8 | 1,778 | 4.625 | 5 | [] | no_license | string = 'Hello my name is Prateek Singh\nI\'m a 27 year young'
print("Original String: ",string)
print(string[:5]) # slicing the string upto 'n' index value from the first index
print(string[6:]) # slicing the string from 'n' index value upto the last index
print(string[6:25]) # slicing the string from a specific in... | true |
4844146ef0b2060a44b5bd04948754d91fb65129 | Python | miquimus1/CodeWars | /convert_string_to_camel_case.py | UTF-8 | 608 | 4.28125 | 4 | [] | no_license | '''
Complete the method/function so that it converts dash/underscore delimited words into camel casing. The first word within the output should be capitalized only if the original word was capitalized (known as Upper Camel Case, also often referred to as Pascal case).
Examples
to_camel_case("the-stealth-warrior") # re... | true |
4fe26bf9e83fff635fe84aa27b41402aab615513 | Python | EECS388-F19/lab-conbeard21 | /helloworld.py | UTF-8 | 154 | 3.5 | 4 | [] | no_license | import random
print("Connor")
a = random.randrange(100)
b = random.randrange(100)
print(a)
print(b)
print("Sum = ", a + b)
print("Average = ", (a+b)/2)
| true |
7180e05c4035d3251899783a93f20fa83825588a | Python | vivekkumark/BigO | /algo/interesting_problems/python/plus_one.py | UTF-8 | 286 | 3.359375 | 3 | [] | no_license | # Add One To Number
#
def plusOne(A):
L = [0]
L.extend(A)
i = len(A)
while L[i] == 9:
L[i] = 0
i -= 1
L[i] += 1
i = 0
while not L[i]:
i += 1
return L[i:]
if __name__ == '__main__':
print(plusOne([0, 0, 4, 5, 9, 9, 9]))
| true |
8ccb4c5ea99e7e3d9e8f392dee7162abe2d6ab12 | Python | NayyarUnda/Pythonclass | /Newyork Taxi Trip Analysis-Final Project/analysis_5.py | UTF-8 | 2,041 | 2.84375 | 3 | [] | no_license | import numpy as np
from datetime import datetime
import seaborn as sns
import matplotlib.pyplot as pl
import pandas as pd
data_nyc=pd.read_csv('/Users/nayyar/Downloads/yellow_tripdata_2010-01.csv')
def strip(string):
parts=string.split(':')
year=str(parts[0][:4])
month=str(parts[0][5:-6])
day=str(p... | true |
dfd60ad01b9184279898ff16d1c1e37c9f670110 | Python | davidoevans/play35 | /tests/base.py | UTF-8 | 3,942 | 2.84375 | 3 | [] | no_license | """
# Overview
This module is intended to provide a test harness that mimics the behaviour seen on the hackerrank site. Using
this harness enables localized testing of the hackerrank challenges and the resulting code can be posted
verbatum to the hackerrank site.
The general behaviour goes as follows:
* test data is... | true |
af543e78c2969b8ac8e28106f30f665cd80ffdb7 | Python | horaciobelardita/ejercicios_programacion_I | /2do Parcial/prog1.py | UTF-8 | 881 | 3.28125 | 3 | [] | no_license | import os
archivo = open("emple.txt", "a")
while True:
# ingreso de datos
edad = int(raw_input("Ingrese la edad: "))
if edad == 0:
break
nom_ape = raw_input("Ingrese Nombre y apellido: ")
sueldo_basico = float(raw_input("Ingrese sueldo basico: "))
while True:
sexo = int(raw_... | true |
6f834de4afe22e3a3f27f829b10bd98dddf14e56 | Python | asbl/miniworldmaker | /source/miniworldmaker/boards/board_templates/pixel_board/token_pixelboardsensor.py | UTF-8 | 5,274 | 2.75 | 3 | [
"MIT"
] | permissive | import math
from typing import Union, List
import miniworldmaker.boards.board_templates.pixel_board.board as board_mod
import miniworldmaker.positions.position as board_position
import miniworldmaker.positions.rect as board_rect
import miniworldmaker.positions.vector as board_vector
import miniworldmaker.tokens.manage... | true |
1fb238264c57b6f0be1de31b814b0afa6b28f463 | Python | liaosboy/web_crawer | /pchome/pchome_selenium.py | UTF-8 | 2,135 | 2.859375 | 3 | [] | no_license |
from selenium import webdriver
from bs4 import BeautifulSoup
import random as rnd
import random as rnd
import time
import pandas as pd
from openpyxl import load_workbook
import re
import requests
urls = []
def get_Prod_url(keyword):
urls.clear()
browser = webdriver.Chrome()
browser.get("https://24h.pch... | true |
e0699773a4a40435561b047c5b18627261531120 | Python | idafchev/stego_http | /stego_http_server.py | UTF-8 | 2,283 | 3.0625 | 3 | [] | no_license | #!/usr/bin/env python3
from http.server import BaseHTTPRequestHandler, HTTPServer
def bin2chr( byte ):
c = chr(int( byte, 2 ))
return c
# Read the hidden bits from a single line/header
def read_from_line( line ):
binary = []
index = line.find(' ')
while(True):
# Hidden data starts from the second space
ind... | true |
f418ebff49ab351724bea0d846622faf05a0cabf | Python | DeepPSP/torch_ecg | /torch_ecg/models/ecg_seq_lab_net.py | UTF-8 | 7,301 | 2.65625 | 3 | [
"MIT"
] | permissive | """
Sequence labeling nets, for wave delineation,
the labeling granularity is the frequency of the input signal,
divided by the length (counted by the number of basic blocks) of each branch
Pipeline
--------
multi-scopic cnn --> (bidi-lstm -->) "attention" (se block) --> seq linear
References
----------
[1] Cai, Wen... | true |
10654a89a3996b7710ca6c2e59c1429ff0776049 | Python | Abheyraj/gitjenkinslearning | /myfile.py | UTF-8 | 84 | 2.609375 | 3 | [] | no_license | print("hello World")
print("How are you")
print("What are you doing?")
print(2 + 3) | true |
3348bf56c35a440da13b1d32e8e8a05ada8cd8a5 | Python | kenito2050/BICL | /pages/BICL/logout/IE_Logout.py | UTF-8 | 953 | 2.609375 | 3 | [] | no_license | from selenium.webdriver.common.by import By
from selenium.webdriver import ActionChains
class IE_Logout():
def __init__(self, driver):
self.driver = driver
def Page_Elements(self):
self.logout_link = self.driver.find_element(By.XPATH, "/html/body/div[1]/header/div[3]/div/ul/li/a")
r... | true |
07947cfe19a86c89ba29bd0a601bd7d71dce9d93 | Python | smarkh/inventory-simulator | /main.py | UTF-8 | 2,825 | 2.640625 | 3 | [] | no_license | import pandas as pd
import yaml
from sqlalchemy import create_engine
import urllib
from math import ceil
# read in queries
SAMPLES = 20 # number of sample weeks to do
WEEKS = 6 # should be between 1 and 6 (number of weeks to check until stock out)
with open(r'config.yml') as file:
config = yaml.load(file, Loa... | true |
9e52b3d58023543a46e62b2f38955e256de5c633 | Python | newyork167/LeetCode-Scaffold | /DailyChallenges/Daily_2021/June/Day_17_NumberOfSubarraysWithBoundedMaximum/NumberOfSubarraysWithBoundedMaximum.py | UTF-8 | 878 | 3.421875 | 3 | [
"MIT"
] | permissive | """
NumberOfSubarraysWithBoundedMaximum - https://leetcode.com/problems/number-of-subarrays-with-bounded-maximum/
"""
from typing import List
from Scaffold import ScaffoldClass
import pathlib
import ast
class Solution(ScaffoldClass.LeetCodeScaffold):
def __init__(self):
super().__init__(pathlib.Path(__fil... | true |
134caf06cd332533f91af3d4d56070a8b898c1ed | Python | nicholasinatel/GALILEO_ONBOARD | /GPIOscript/BUZZER_script.py | UTF-8 | 1,392 | 3.046875 | 3 | [] | no_license |
#!/usr/bin/python
import sys
import time
def pins_export():
try:
pin1export = open("/sys/class/pwm/pwmchip0/export","w")
pin1export.write("3")
pin1export.close()
except IOError:
print "ERRO EM PIN_EXPORT"
def enable_buzz( value ):
try:
enable1buzz = open( "/sys/cl... | true |
e71f411f2fabf903621de69c3efa0c887490d30e | Python | vittal666/Python-Assignments | /First Assignment/Question_4-[Swapping values].py | UTF-8 | 112 | 3.296875 | 3 | [] | no_license | list = [1, 2, 3, 4]
var1 = list.pop(0)
var2 = list.pop(2)
list.insert(0, var2)
list.insert(3, var1)
print(list)
| true |
dcb3eb048e1faa0414fa295ba6c8ed16179e7dad | Python | bamingqiang/QuantPractice | /message.py | UTF-8 | 1,844 | 2.65625 | 3 | [] | no_license | import json
from datetime import datetime
import requests
import time
import hmac
import hashlib
import base64
from urllib import parse
def cal_timestamp_sign(secret):
# 根据钉钉开发文档,修改推送消息的安全设置https://ding-doc.dingtalk.com/doc#/serverapi2/qf2nxq
# 也就是根据这个方法,不只是要有robot_id,还要有secret
# 当前时间戳,单位是毫秒,与请求调用时间误差不能超过... | true |
b2aca19dff8da6089b9430f46d77d121e7248ca6 | Python | mrakrathod/django-rest-service-with-docker | /api_service/tests.py | UTF-8 | 2,207 | 2.890625 | 3 | [] | no_license | from faker import Factory
from rest_framework import status
from rest_framework.test import APITestCase
from rest_framework.exceptions import ErrorDetail
from .models import BirthDay
from .model_factory import BirthDayFactory
faker = Factory.create()
class BirthdayTestCase(APITestCase):
def setUp(self):
... | true |
a0eb8b41b2cbd50cb34fe2a4adf23d788296ed8b | Python | strangemk2/oj | /leetcode/6.py | UTF-8 | 1,383 | 3.21875 | 3 | [] | no_license | import sys
class Solution(object):
def convert(self, s, numRows):
"""
:type s: str
:type numRows: int
:rtype: str
"""
def cal_pos(x, y, n):
if y == 0 or y == n-1:
return y + (2 * n - 2) * x
else:
mod = x % 2
... | true |
1955c4730c14da3c242f327c6cc146633726a8a8 | Python | guozengxin/ldict | /ldutil/htmlfetcher.py | UTF-8 | 1,276 | 2.609375 | 3 | [
"MIT"
] | permissive | #!/usr/bin/env python
# encoding=utf-8
import urllib2
from urllib2 import HTTPError, URLError
import sys
from gzipSupport import ContentEncodingProcessor
def get_headers():
header = {'User-agent': 'Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.22 (KHTML, like Gecko) Chrome/25.0.1364.97 Safari/537.22'}
... | true |
bb5a82f7edcc9e31603d1b6db28729331c42a8cc | Python | SanaAwan5/smart_contracts7 | /python-paillier/examples/alternative_base.py | UTF-8 | 2,031 | 3.515625 | 4 | [
"Apache-2.0",
"GPL-3.0-only",
"GPL-1.0-or-later"
] | permissive | #!/usr/bin/env python3.4
import math
import phe.encoding
from phe import paillier
class ExampleEncodedNumber(phe.encoding.EncodedNumber):
BASE = 64
LOG2_BASE = math.log(BASE, 2)
print("Generating paillier keypair")
public_key, private_key = paillier.generate_paillier_keypair()
def encode_and_encrypt_exam... | true |
4b35ba73e03650fdd1e4dc467e1f02855f8b41f8 | Python | akai-katto/Social-Distancing-Sandbox | /workplace.py | UTF-8 | 1,074 | 2.515625 | 3 | [] | no_license | from socialplace import SocialPlace
import names
class Sector:
def __init__(self, sector_name: str, mean_salary: int, density: int, social_distancing_layoff: float):
self.sector_name = sector_name
self.mean_salary = mean_salary
self.social_distancing_layoff = social_distancing_layoff
... | true |
96935ad4a3634ac54ea07658d578a50e58afc053 | Python | adityamanglik/Algorithm-Implementations | /Machine Learning/Sklearn Implementations/Dimensionality Reduction/Kernel-PrincipalComponentAnalysis.py | UTF-8 | 2,716 | 3.09375 | 3 | [
"MIT"
] | permissive | #!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
Created on Mon Apr 13 17:54:16 2020
@author: admangli
"""
import numpy as np
import pandas as pd
import matplotlib.pyplot as plt
dataset = pd.read_csv('Social_Network_Ads.csv')
X = dataset.iloc[:, 2:-1].values
y = dataset.iloc[:, -1].values
#%%
# Feature scaling
fr... | true |
7518004531b95c6c3c44b0e7e9fc1485fa861c8e | Python | Lao-Tzu-Taoism/sv_score_calibration | /tools/voices_scorer/score_voices | UTF-8 | 1,809 | 2.625 | 3 | [
"Apache-2.0"
] | permissive | #!/usr/bin/env python
"""
Scoring script for VOiCES from a Distance Challenge
Author: Mitchell McLaren
Email: mitchell.mclaren@sri.com
Date: January 7. 2016 (v2 SITW scoring script)
Date: January 23, 2019 (revised for VOiCES)
"""
import os, sys, time
import argparse
from voices_tools import *
if(__name__=="__main__"... | true |
4943bb8670e8e21f422e3ad65f0d083d2448ef12 | Python | petitefille/Python | /Oppg/chap_5/f2c_shortcut_plot.py | UTF-8 | 437 | 3.703125 | 4 | [] | no_license | # Exercise 5.12
import numpy as np
import matplotlib.pyplot as plt
def exact_conv(F):
return 5 / 9. * (F - 32)
def approx_conv(F):
return 0.5 * (F - 30)
Flist = np.linspace(-20, 120, 141)
# subplot explained p. 236
ax = plt.subplot(111)
ax.plot(Flist, exact_conv(Flist))
ax.plot(Flist,... | true |
6d71584fb15c01b1626577cef0755b5978df3492 | Python | arsalanazmi/Python-Assignments | /BMI.py | UTF-8 | 614 | 4.03125 | 4 | [] | no_license | # TASK # 22
# CALCULATE BODY MASS INDEX
weight = int(input("Enter Your Body Weight in Kg: "))
height = int(input("Enter Height In cm: "))
height = height/100 # cm to m conversion
bmi = round((weight / height**2), 2)
print("Your BMI result =",bmi)
if bmi < 18.5:
print("You are Underwight")
elif bmi >= 18.5 and b... | true |
979e8d16684fff79809523b49df76c6520f7b167 | Python | sauravpurva/ICG | /bouncing_ball.py | UTF-8 | 1,854 | 3.21875 | 3 | [] | no_license | import pygame
from pygame import gfxdraw
import math
import sys
import time
pygame.init()
black = (0, 0, 0)
white = (255, 255, 255)
yellow = (255, 255, 0)
blue = (176, 224, 230)
red = (255, 0, 0)
size = [700, 500]
screen = pygame.display.set_mode(size) #Opens a window of size 700,500, and stores it in a variable calle... | true |
bf4d6b91019d7067abfe426a7a31dde2e7975ad2 | Python | anze3db/adventofcode2017 | /src/day10.py | UTF-8 | 2,113 | 3.515625 | 4 | [] | no_license | """Day 10: Knot Hash."""
import pytest
from functools import reduce
def day10(arg):
"""Day 10."""
res = knot_hash(list(map(int, arg.split(','))))
return res[0] * res[1]
def day10p2(arg):
"""Day 10 part 2."""
inputs = to_ascii(arg) + [17, 31, 73, 47, 23]
res = knot_hash(inputs, 256, 64)
... | true |
968b8b6a940756d92981d9408e3ac7007a0ffb3c | Python | lorenzocastillo/Algos-and-DS | /python_problems/ZeroMatrix.py | UTF-8 | 1,045 | 4.09375 | 4 | [] | no_license | def zero_matrix(matrix):
"""
We are going to iterate through the array, and placing a 0 in the first column or row if that row/column has a 0.
We will do a second traversal through the first row and column, and zero out the row and col
:param matrix:
:return:
"""
for r in range(1,len(matrix)... | true |
eb97a56d35ec222e7a2818d09333a83da84ed6ac | Python | Berezhnyk/Berezhnyk | /main.py | UTF-8 | 1,221 | 2.65625 | 3 | [
"MIT"
] | permissive | import json
with open('clone.json', 'r') as fh:
now = json.load(fh)
with open('clone_before.json', 'r') as fh:
before = json.load(fh)
timestamps = {before['clones'][i]['timestamp']: i for i in range(len(before['clones']))}
latest = dict(before)
for i in range(len(now['clones'])):
timestamp = now['clones'... | true |
4eee693cc88fcbc844921b4e15192002bd9cde04 | Python | jatasya/jetbrains-python-zookeeper | /Problems/Desks/main.py | UTF-8 | 304 | 3.734375 | 4 | [] | no_license | # put your python code here
number1 = int(input())
number2 = int(input())
number3 = int(input())
n1 = (number1 % 2) + (number1 // 2)
n2 = (number2 % 2) + (number2 // 2)
n3 = (number3 % 2) + (number3 // 2)
print(n1 + n2 + n3)
is_open = True
is_closed = False
print(is_open) # True
print(is_closed)
| true |
09e2207b11693f0e0c6132a2a3f479afdb293270 | Python | shitianshiwa/y2b-map | /update_list.py | UTF-8 | 872 | 2.6875 | 3 | [] | no_license | import requests
import csv
info = requests.get('https://api.vtbs.moe/v1/info').json()
info_sorted = sorted(info, key=lambda x: x['follower'], reverse=True)
with open('map.csv', 'r', newline='', encoding='utf8') as csvfile:
fieldnames = ['name', 'mid', 'channelId']
reader = csv.DictReader(csvfile, fieldnames=f... | true |
922b71823f6d34a94266a69c2db9eb73414d13f2 | Python | ilpan/web_cache | /web_cache/handler/util.py | UTF-8 | 3,598 | 2.84375 | 3 | [
"MIT"
] | permissive | #!/usr/bin/env python
# -*- coding:utf-8 -*-
import gzip
import hashlib
import zlib
"""
这里存放一些与通信无关的方法
"""
# =============================== some get methods ====================================
# 解析请求报文
def get_request_info(request_msg):
request_header, request_body = get_msg_info(request_msg)
request_line... | true |
fcd68c8bf34c4bff5d7a8f7f9623d3cf7bab1d1d | Python | igorperic17/bengali-ocr | /good_network.py | UTF-8 | 1,916 | 2.625 | 3 | [] | no_license | # inputs = Input(shape = (INPUT_SIZE, INPUT_SIZE, 1))
# model = Conv2D(filters=32, kernel_size=(3, 3), padding='SAME', activation='relu', input_shape=(INPUT_SIZE, INPUT_SIZE, 1))(inputs)
# model = Conv2D(filters=32, kernel_size=(3, 3), padding='SAME', activation='relu')(model)
# # model = BatchNormalization(momentum=0... | true |
a209a07de8ecff60126c995448602dc5bd205ce2 | Python | treefriend/NLP_study_tf2 | /NNLM/models/data_proc.py | UTF-8 | 2,883 | 2.8125 | 3 | [
"MIT"
] | permissive | # -*- coding: utf-8 -*-
# @Time : 2020-05-02 12:17
# @Author : Shupeng
from collections import defaultdict
from multiprocessing import cpu_count, Pool
import nltk
import numpy as np
import pandas as pd
from nltk.corpus import brown, stopwords
import models.config as cfg
# implemented but not used here
# as wo... | true |
be6ac48697fee4e52c9fbab850108fd5434124d4 | Python | ClaudiuGeorgiu/Obfuscapk | /src/obfuscapk/obfuscators/class_rename/class_rename.py | UTF-8 | 15,169 | 2.6875 | 3 | [
"MIT"
] | permissive | #!/usr/bin/env python3
import logging
import os
import re
import xml.etree.cElementTree as Xml
from typing import List, Set, Dict, Union
from xml.etree.cElementTree import Element
from obfuscapk import obfuscator_category
from obfuscapk import util
from obfuscapk.obfuscation import Obfuscation
class ClassRename(obf... | true |
5f03b43da21ebad56408e171e802fcf66bdd3bf7 | Python | jsheperd/node-weighbridge | /tester/test_hw.py | UTF-8 | 391 | 2.703125 | 3 | [
"Unlicense"
] | permissive | #!/usr/bin/python
import serial, time
ser = serial.Serial('/dev/ttyUSB0') # open serial port
def comm(msg):
print("msg: %s" % msg)
ser.write("XA/%s\r\n" % msg )
resp = ser.readline()
print resp
print(ser.name) # check which port was really used
msgs = ['kamu', 'N?', 'B?', 'T?']
# test he... | true |
9672e98172f1a423f67f1a1c8193557edb4000b2 | Python | thkemp/bash-python-git-bootcamp | /bmi/bmi.py | UTF-8 | 203 | 3.75 | 4 | [] | no_license | #python code to calculate BMI
w= raw_input("Enter Weight (in pounds): ")
h=raw_input("Enter Height (in inches): ")
#using pounds and inches
bmi=(float(w)/float(h)**2)*703
print 'BMI is: ',round(bmi,1)
| true |
a25ce55bbe56bdb48943821f618c5870de56ebe2 | Python | davidmello/python-fundamentals | /Aula 02/host_connect.py | UTF-8 | 284 | 2.90625 | 3 | [] | no_license | #!/usr/bin/python
# modulo que nao mostra o que esta sendo digitado
import getpass
hostname = raw_input('Insira o IP do host: ')
user = raw_input('Entre com o Usuario: ')
password = getpass.getpass('... e agora a senha: ')
print "Acessando host %s:%s@%s" % (user,password,hostname) | true |
c961d1791d87d214788ece82eb26415a07196a20 | Python | Sniper970119/leetCode | /L0101~L0150/L0111.py | UTF-8 | 1,615 | 3.296875 | 3 | [] | no_license | # -*- coding:utf-8 -*-
"""
┏┛ ┻━━━━━┛ ┻┓
┃ ┃
┃ ━ ┃
┃ ┳┛ ┗┳ ┃
┃ ┃
┃ ┻ ┃
┃ ┃
┗━┓ ┏━━━┛
┃ ┃ 神兽保佑
┃ ┃ 代码无BUG!
┃ ┗━━━━━━━━━┓
┃ ┣┓
┃ ┏┛
┗━┓ ┓ ┏━━━┳ ┓ ┏━┛
┃ ┫... | true |
f3583d0bd02c9b7e93350f9e8235ed8297402249 | Python | andrewhead/netseq-proto | /proto/kivy/filechooser/kivy-launch-tkinter.py | UTF-8 | 662 | 3.28125 | 3 | [] | no_license | import kivy
from kivy.app import App
from kivy.uix.button import Button
import Tkinter
import tkFileDialog
def callback(instance):
# Explictly make and then hide the Tkinter root window
root = Tkinter.Tk()
root.withdraw()
# Get the filename from the dialog
filename = tkFileDialog.askopenfilename()... | true |
f8e0efe1769c55450fd700b8cd10e86053edafe9 | Python | runningshuai/jz_offer | /25.复杂链表的复制.py | UTF-8 | 2,886 | 4.15625 | 4 | [] | no_license | """
题目描述
输入一个复杂链表(每个节点中有节点值,以及两个指针,一个指向下一个节点,另一个特殊指针random指向一个随机节点),
请对此链表进行深拷贝,并返回拷贝后的头结点。(注意,输出结果中请不要返回参数中的节点引用,否则判题程序会直接返回空)
"""
# -*- coding:utf-8 -*-
class RandomListNode:
def __init__(self, x):
self.label = x
self.next = None
self.random = None
class Solution1:
# 返回 RandomListN... | true |
ea85f21d0279f7a57bf82f9710ad0241cecf4541 | Python | S8s8Max/python_practice | /oop_practice.py | UTF-8 | 2,205 | 3.640625 | 4 | [] | no_license | class Human:
def __init__(self, name):
self.name = name
class Patient(Human):
def __init__(self, name, patient_id, symptom):
super().__init__(name)
self.symptom = symptom
self.patient_id = patient_id
class Clinic:
def __init__(self):
se... | true |
8070ad4d3da6fff26b4b5d32b36e4e31d4e77aa9 | Python | BIAOXYZ/variousCodes | /_CodeTopics/LeetCode_other_problems/面试题/剑指Offer(第2版)/38/38.py | UTF-8 | 1,149 | 3.34375 | 3 | [] | no_license | class Solution(object):
def permutation(self, s):
"""
:type s: str
:rtype: List[str]
"""
# 典型的回溯算法,类似 `LC47 全排列 II`:也就是可以有重复元素的全排列。
length = len(s)
res = set()
def backtrack(currInds, leftInds):
if len(leftInds) == 0:
... | true |
bef4cf7da8e6e5cd31f5b529d90e07bccfc3a04f | Python | dharmeshptl/recordlinker | /recordlinker/preprocess.py | UTF-8 | 6,926 | 3.03125 | 3 | [
"MIT"
] | permissive | '''Preprocess string name columns in dataframes'''
from __future__ import absolute_import
from __future__ import print_function
import re
import numpy as np
import fuzzy
from keras.utils.np_utils import to_categorical
from . import utils
def lower_and_strip(x):
'''Lower case, strip white space and punctuation... | true |
cd623df2f69c9dc490ce8063b716694ce2fd7bfc | Python | AndresArdila89/SCRIPTING-LANGUAGE | /Assignment_4/ProjectCircle/basisclasses/circle.py | UTF-8 | 862 | 3.25 | 3 | [] | no_license | class Circle:
import math
pi = math.pi
idSequence = 1000
def __init__(self,radius,color):
self.circleId = 'CIR_' + str(Circle.idSequence)
self.radius = radius
self.color = color
self.perimeter = 2*Circle.pi*radius
self.area = Circle.pi*(radius**2)
... | true |
42d6116eb5b0cc7b51735290c6406ee4c8275e97 | Python | europeanecho/game | /game.py | UTF-8 | 1,525 | 3.8125 | 4 | [] | no_license | import random
import json
with open("config.json", "r") as f:
config = json.load(f)
def guessgame():
to_guess = random.randint(
config["min_guess"],
config["max_guess"],
)
guesses = config["guesscount"]
while True:
print(f"You have {guesses} left, what is your guess?")
... | true |
a479d2fc7753554408afd3ea53e1bedab82611ae | Python | bherren98/data-science-is-our-passion | /Project3/app.py | UTF-8 | 1,697 | 2.78125 | 3 | [] | no_license | import dash
import dash_core_components as dcc
import dash_html_components as html
import sys
import csv
import numpy as np
import pandas as pd
import plotly.graph_objects as go
from dash.dependencies import Input, Output
from flask import Flask
external_stylesheets = ['https://codepen.io/chriddyp/pen/bWLwgP.css']
ser... | true |
2a70e9cc6a081fad236fb3a6f642e25d93e7887d | Python | xieyingxing/python- | /web自动化/Demo_弹出框.py | UTF-8 | 624 | 2.65625 | 3 | [] | no_license | import time
from selenium import webdriver
from selenium.webdriver.support.select import Select
driver = webdriver.Chrome()
driver.get('file:///D:/%E8%B0%A2%E5%BA%94%E5%85%B4'
'/python%E6%B5%8B%E8%AF%95%E4%BB%A3%E7%A0%81/pagetest/%E6%B3%A8%E5%86%8CA.html')
driver.find_element_by_css_selector('[type="butto... | true |
5b8587788ca07ea1534d85663a707bfd5be4dd71 | Python | haiiliin/pyabaqus | /src/abaqus/Odb/SectionCategory.py | UTF-8 | 3,809 | 3.03125 | 3 | [
"MIT"
] | permissive | from .SectionPoint import SectionPoint
from .SectionPointArray import SectionPointArray
class SectionCategory:
"""The SectionCategory object is used to group regions of the model with like sections.
Section definitions that contain the same number of section points or integration points
are grouped togeth... | true |
4166d9e67f3f8045af23bfdafd93543a35bb1e29 | Python | aisuluub/2task4 | /2task4.py | UTF-8 | 310 | 3.28125 | 3 | [] | no_license | def clock_face():
hour1 = 6
hour2 = 6
min1 = 1
min2 = 2
sec1 = 30
sec2 = 10
clock1_in_sec = (hour1 * 60 * 60) + (min1 *60) + sec1
clock2_in_sec = (hour2 * 60 * 60) + (min2 * 60) + sec2
clock3_in_sec = clock2_in_sec - clock1_in_sec
print(clock3_in_sec)
clock_face() | true |
d4e1d89494f638a5a918e54dd46edf6fd3f2d450 | Python | kshwork1/memo | /4w/05_update.py | UTF-8 | 556 | 2.8125 | 3 | [] | no_license | from pymongo import MongoClient # pymongo를 임포트 하기(패키지 인스톨 먼저 해야겠죠?)
client = MongoClient('localhost', 27017) # mongoDB는 27017 포트로 돌아갑니다.
db = client.dbsparta # 'dbsparta'라는 이름의 db를 만듭니다.
# db.people.update_many(찾을조건,{ '$set': 어떻게바꿀지 })
user = db.users.find_one({'name':'bobby'})
print (u... | true |
3f821993ad0458b679784f5b78000de6d98e2e73 | Python | fresmini/store-sales-prediction | /webapp/handler.py | UTF-8 | 1,303 | 2.671875 | 3 | [
"MIT"
] | permissive | import os
import pickle
from flask import Flask, request, Response
import pandas as pd
from rossmann.Rossmann import Rossmann
#carregar modelo
model = pickle.load( open( 'modelo/model_rossmann_lr.pkl', 'rb' ) )
#inicialização da API
app = Flask( __name__ )
@app.route( '/rossmann/predict', methods = [... | true |
ff7eb39b94c6aad4d589508eb92fec69ad14665d | Python | dtmuelle/cda_builder | /file_manager/test3.py | UTF-8 | 643 | 2.71875 | 3 | [] | no_license |
# Creates a clinic, saves patient files and then retrieves all .pkl
# files from a particular day.
import file_manager
import patient
import datetime
fm = file_manager.FileManager ()
fm.create_clinic_dir ('my_clinic3', '.')
p = patient.patient ()
p.date = datetime.datetime.now ()
p.family_name = "smith"
p.id = "1... | true |
a7efc48fdb77b3d0c98d9a165d6b7979f489ca19 | Python | xlxb/jisuanke | /前置课程学习进度/ZhangZhiQiang/03测试重构的线上练习/格式化路径.py | UTF-8 | 706 | 3.28125 | 3 | [] | no_license | import sys
for s in sys.stdin:
s = s.strip()
s = s.replace('\\', '/')
items = []
items += s.split('/')
flag = False
i = 0
while i < len(items):
if not items[i]:
items.pop(i)
elif items[i] == '.':
items.pop(i)
elif items[i] == '..':
... | true |
12bd0d102a8a4c361ce670226c40c3fae8a58fe9 | Python | ippossebon/neural-nets | /classification/neuralnetwork.py | UTF-8 | 12,804 | 2.875 | 3 | [] | no_license | import math
import numpy as np
from instance import Instance
from utils import FileUtils
class NeuralNetwork(object):
def __init__(self, neurons_per_layer, reg_factor, training_data):
self.num_layers = len(neurons_per_layer)
self.neurons_per_layer = neurons_per_layer
self.reg_factor = reg... | true |
643a25b21617d98a84b319d3bc90a735ffd9c098 | Python | zerolugithub/trionika | /Sites/ET/order_et.py | UTF-8 | 1,621 | 2.515625 | 3 | [] | no_license | # coding: utf8
#!/usr/bin/env python
# -*- coding: utf-8 -*-
import random
import string
import allure
import pytest
from selene.conditions import text
from selene.api import *
import time
from General_pages.order_steps import random_mail
@allure.step('Выбираем случайны Paper Format')
def choice_paper_format():
... | true |
ecab6ff227fb6b6d4adf0869b7a4dad99ebb3cd0 | Python | Warober/CursoPy | /Numero_ mas_pequeno.py | UTF-8 | 600 | 4.03125 | 4 | [] | no_license |
my_lista = []
numero_pequeno = 0
numero = input("Introduce 10 numeros y te dire el mas pequeño: ")
while len(my_lista) < 10:
while not numero.isdigit():
print("Has introducido un valor que no es numerico ")
numero = (input("Introduce un numero: "))
my_lista.append(int(numero))
print("Num... | true |
017a471b545195a0833ba25c5a3cf998d2a94286 | Python | AntonioRevail/AulasPython | /projeto1.py | UTF-8 | 841 | 3.40625 | 3 | [] | no_license | def calculo_inss(salariobruto):
if salariobruto <= 1000:
return 0.0
if salariobruto <= 2000:
return salario * 0.1
else:
return salariobruto * 0.2
def calculo_ir(salarioliquido):
if salarioliquido <= 1400.0:
return 0.0
elif salarioliquido <= 2500.0:
return sal... | true |
a0294ddc0a267e4c53f13b2005b00329e96c2126 | Python | anders-ahsman/advent-of-code | /2020/day07/main.py | UTF-8 | 1,366 | 3.359375 | 3 | [] | no_license | import re
import sys
def read_lines():
return [line.rstrip() for line in sys.stdin]
def create_graph(lines):
bag_to_contents = {}
for line in lines:
contents = {}
m = re.match(r'^(\w+ \w+) bags contain (.*)', line)
bag, inside = m[1], m[2]
if 'no other' not in inside:
... | true |
43d02fda2c5d1fddea0103059186ca0e453020fc | Python | MaloryBergezCasalou/labo-python-2020-2021 | /encryption/script.py | UTF-8 | 952 | 3.359375 | 3 | [] | no_license | #!/usr/bin/env python
# malorybergezcasalou
# simple script encryption passwd / txt
typePass = input("type text: ")
def encryption(typePass, decalage=2):
res = ""
"""
for lettre in typePass:
if 65 >= ord(lettre) <= (65 + 26 - decalage):
res += chr(ord(lettre) + decalage)
elif... | true |
e71710b6ff38193a9450ef77af0f1de1d152ffe2 | Python | Quarz0/Linear-Equations-Solver | /resultset.py | UTF-8 | 1,460 | 3 | 3 | [] | no_license | class ResultSet(object):
def __init__(self, matrixA=None, matrixB=None, variables=None, name=None, tables=None, solution=None,
precisions=None, time=None, iters=None, roots={}):
self.matrixA = matrixA
self.matrixB = matrixB
self.variables = variables
self.name = name... | true |
7c924cce41d2df12b60d75fa17d6d1397c332162 | Python | Ruby-Dog/III | /人工智慧與機器學習/0603/10-2-tuple-cards.py | UTF-8 | 551 | 3.546875 | 4 | [] | no_license | # 製作一副牌 洗牌 抽出第一張牌
all = []
for c in range(4):
for n in range(13):
card = (c, n)
all.append(card)
print(all)
# google search unicode 特殊內碼符號表
transcolor = ["\u2660", "\u2661", "\u2662", "\u2663"]
transnum = ["A", "2", "3", "4", "5", "6", "7", "8", "9", "10", "J", "Q", "K"]
print(transcolor)
c = all... | true |
13b03ceb556c331fcdee8fb69b47234bfc07954f | Python | yoshio15/AtCoder | /ELSE_CONTEST/競プロ典型 90 問/004.py | UTF-8 | 447 | 3 | 3 | [] | no_license | h, w = map(int, input().split())
a = [list(map(int, input().split())) for _ in range(h)]
row_total = [sum(i) for i in a] # 各行の総和
col_total = [0] * w # 各列の総和
for i in range(w):
col_total[i] = sum([el[i] for el in a])
ans_list = [[""] * w for _ in range(h)]
for i in range(h):
for j in range(w):
ans_li... | true |
55d1bc6b03061469b552a2e08c5aa95507c739d5 | Python | samuellando/CodeChallenges | /problems/Find Peak Element/Solution.py | UTF-8 | 622 | 3.203125 | 3 | [] | no_license | class Solution:
def findPeakElement(self, nums: List[int]) -> int:
l = 0
r = len(nums) - 1
while r >= l:
if r == l:
return r
mid = (r + l) // 2
if (mid == 0 or nums[mid-1] < nums[mid]) and (mid == len(nums) - 1 or nums[mid+1] < num... | true |
94fbc3bb061404249a268ffbbf16311cdb11f83a | Python | xSakix/etf_expert | /py_code/neural/nn_untreasholded_grad_descent_stochastic.py | UTF-8 | 853 | 3.015625 | 3 | [
"Apache-2.0"
] | permissive | #gradient descent for training a linear unit
import numpy as np
import matplotlib.pyplot as plt
import csv
def main():
x = [[0.,0.],[0.,1.],[1.,0.],[1.,1.]]
d = [0.,1.,1.,1.]
w = [np.random.uniform(0.,1.),np.random.uniform(0.,1.)]
alfa = 0.1
w_old = []
G_E = []
while True:
E = 0.
print('start'+str(w))... | true |
0173789c4b30a47f3c9ab028d30ca3be53baa79b | Python | ceyhunsahin/TRAINING | /EXAMPLES/EDABIT/EXPERT/001_100/58_the_Josephus_problem.py | UTF-8 | 1,430 | 4.59375 | 5 | [] | no_license | """
The Josephus Problem
The Josephus Problem is a mathematical problem in which a circle is made, its circumference formed of n people.
Starting from the person in the 0th position, each person eliminates the person to their left (the next person in the circle). The next living person then does the same, and the proc... | true |
641f32e92e8805b31630c5ef9e635355e61ab18c | Python | larsvansoest/commix | /evaluation_composed.py | UTF-8 | 4,676 | 2.8125 | 3 | [
"Apache-2.0"
] | permissive | #!/usr/bin/env python3
import argparse
import numpy as np
import tensorflow as tf
import evaluation
import data
"""
WARNING! DO NOT USE!
Provided only for comparison to previous research.
The correct evaluation is the one in evaluation.py.
"""
def get_composed_based_rank(composed_repr, targets, max_rank, diction... | true |
d3fa2e19a632aa1e7bd927d12eaf020062cef9a9 | Python | oukaja/websites | /websites/spiders/worldbank.py | UTF-8 | 2,884 | 2.515625 | 3 | [] | no_license | # -*- coding: utf-8 -*-
from __future__ import unicode_literals
from scrapy import Spider
from websites.items import ArticleItem
from scrapy.http import Request
from bidi.algorithm import get_display
import arabic_reshaper
import re
class WorldbankSpider(Spider):
name = 'worldbank'
allowed_domains = ['blogs.w... | true |
3aeba3b5f0746f95948342b4573088ab82ce1fa1 | Python | santoshkosgi/Programming | /Leetcode/315.py | UTF-8 | 2,213 | 3.8125 | 4 | [] | no_license | class Node(object):
def __init__(self, value, index):
self.value = value
self.index = index
self.solution = 0
self.left = None
self.right = None
self.num_of_elements_in_left_subtree = 0
class Solution:
def countSmaller(self, nums):
"""
The idea ... | true |
f5010d49eead82bf52cbf597a80c5ecbcfc7909d | Python | JosephRedfern/OpenSaucyDominator | /dominator/tests/thresholdSegmentation.py | UTF-8 | 421 | 2.734375 | 3 | [] | no_license | import numpy as np
from ..segmentation.threshold import ThresholdSegmentation
import matplotlib.pyplot as plt
img = (np.random.rand(100,100) * 255).astype(np.uint8)
ts = ThresholdSegmentation(img, 128)
seg_img, _ = ts.segment_image()
plt.figure('ThresholdSegmentation Example')
plt.subplot(1, 2, 1)
plt.imshow(img... | true |
6ddef201a64cb76a41503bebbc4d36cfc0deee9f | Python | wangfan010101/deeplearning | /neural/utils/loss_function.py | UTF-8 | 1,002 | 3.515625 | 4 | [] | no_license | # loss function
import numpy as np
# mean squared error function
def mean_squared_error(y, t):
return 0.5 * np.sum((y - t) ** 2)
# cross entropy error function
def cross_entropy_error(y, t):
if y.ndim == 1:
t = t.reshape(1, t.size)
y = y.reshape(1, y.size)
delta = 1e-7
batch_size = ... | true |
b71778c4ddd8ad4f93df18ccf4359c45ffe51cdf | Python | geographika/mappyfile | /tests/test_expressions.py | UTF-8 | 10,465 | 2.734375 | 3 | [
"MIT"
] | permissive | # -*- coding: utf-8 -*-
import logging
import json
import inspect
import pytest
from mappyfile.parser import Parser
from mappyfile.pprint import PrettyPrinter
from mappyfile.transformer import MapfileToDict
def output(s):
"""
Parse, transform, and pretty print
the result
"""
p = Parser()
m = M... | true |
2c9e1110063d53ddb786528f6ee77124f529f346 | Python | praneetha28/repo | /remedial/CSPP-1_Question/CSPP-1_Question/sudoku.py | UTF-8 | 2,383 | 3.625 | 4 | [] | no_license | def create_set(g, r, c):
lis = set()
for i in range(9):
if g[r][i] != '0':
lis.add(g[r][i])
if g[i][c] != '0':
lis.add(g[i][c])
return lis
def possibilities(mat):
for i in range(9):
for j in range(9):
res = ""
s = set()
... | true |
5e087bc1e173626bf350789e9fe1865d8f00abb0 | Python | 866/PyFx | /processing/mathalgs.py | UTF-8 | 5,722 | 2.578125 | 3 | [] | no_license | import numpy as np
import data_structuring.frame_class as fc
import mainAPI.print as prt
def find_correlation_by_C(tf1, tf2, shift=0): #shift is the shift of tf1
tf1, tf2 = fc.mutual_time_frames(tf1, tf2)
if not (len(tf1) == 0 or len(tf2) == 0):
if shift == 0:
return np.corrcoef(tf1.get_C_... | true |
34ddf87a05be0b9782bc00d455c75276a73c91b9 | Python | BeatrizInGitHub/python-sci | /sesion_3/mat2.py | UTF-8 | 219 | 3.390625 | 3 | [] | no_license | def crear_mat(n, m):
mat = []
for i in range(0, n):
row = []
for j in range(0, m):
row.append(i * m + j)
mat.append(row)
return mat
print crear_mat(3, 6) | true |
ae334d366ab9619b64a1406c69127bbbf2519d87 | Python | netChen/jiemeibang | /crawler/joke.py | UTF-8 | 2,431 | 2.671875 | 3 | [] | no_license | #-*- encoding:utf8 -*-
'''
Created on 2013-12-29
笑话 http://www.jokeji.cn/hot.asp
@author: conway
'''
import re
from pyquery import PyQuery as pq
from crawler.base import BaseParser
import urllib
class Joke(BaseParser):
def __init__(self, postUrls = None):
BaseParser.__init__(self)
... | true |