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 |
|---|---|---|---|---|---|---|---|---|---|---|---|
4101bff03019ec9fa68b0a6ea0724b5fcac571b1 | Python | hiuhongyung/Unit_Test_Selenium | /testcase/element.py | UTF-8 | 816 | 2.828125 | 3 | [] | no_license | from selenium.webdriver.support.ui import WebDriverWait
class BasePageElement(object): #represent one element on the page (search bar/ form)
locator = "q"
def __set__(self,obj,value):
driver = obj.driver
WebDriverWait(driver, 100).until(
lambda driver: driver.find_element_by_n... | true |
11391ff07c89f1e555449fe3c95b549a98c1511d | Python | vfdev-5/distracted-driver-detection | /pca_svm/test.py | UTF-8 | 4,245 | 2.828125 | 3 | [] | no_license | #
# Script to predict results using trained SVM Classifier
#
# Python
import logging
import os
from datetime import datetime
from glob import glob
from time import time
# Numpy
import numpy as np
# Sklearn
from sklearn.externals import joblib
# Project
from common.preprocessing import get_data_parallel
logger = lo... | true |
59026d95c2437772e35f306e0f83c98149e6bbde | Python | poudelkhem/MPI | /failFind.py | UTF-8 | 882 | 2.703125 | 3 | [] | no_license | def main():
#minvals = [10000 for i in range(99)]
#with open("output.txt") as out:
# lines = out.readlines()
# for linen in lines:
# line = linen.split(",")
# if len(line) >= 2:
# if (len(line[0].split(":")) == 2 and len(line[1].split(":")) ==2 ):
# ... | true |
e9511912ff9df9aedeb0b4e4270a102de6110a5b | Python | PaperHS/leetcode | /java/ReverseInteger.py | UTF-8 | 278 | 3.84375 | 4 | [] | no_license | #Reverse digits of an integer.
#Example1: x = 123, return 321
#Example2: x = -123, return -321
class Solution:
# @return an integer
def reverse(self, x):
if x>=0:
i=1
else:
i=-1
s=str(abs(x))
return i*int(s[::-1])
| true |
c8f0f8c118a931dd5c5dfe3f0efb43d6a4e4bc63 | Python | wuwujun/service-quality-extraction | /core/nlp/ltp_analyse.py | UTF-8 | 4,074 | 2.765625 | 3 | [] | no_license | import os
import jieba
import time
from pyltp import SentenceSplitter
from pyltp import Postagger
from pyltp import Parser
from pyltp import SementicRoleLabeller
from urllib import request
from urllib import parse
LTP_DATA_DIR = '/home/wuwujun/NLP/ltp_data'
pos_model_path = os.path.join(LTP_DATA_DIR, 'pos.model') # 词... | true |
170d138bddbed85a7501e483ce2d5abcf345d09a | Python | knuu/competitive-programming | /atcoder/abc/abc034_c.py | UTF-8 | 315 | 2.921875 | 3 | [
"MIT"
] | permissive | mod = 10**9+7
def inv(x):
return pow(x, mod - 2, mod)
def nCk(n, k):
assert 0 <= k <= n
k = min(k, n - k)
ret = 1
for i in range(k):
ret *= n - i
ret %= mod
ret *= inv(i + 1)
ret %= mod
return ret
W, H = map(int, input().split())
print(nCk(W+H-2, W-1))
| true |
62758519de9b0e5452a35b76c214ed8b70528948 | Python | rainwangphy/ensemble_distr_distillation | /src/dataloaders/uci/uci_base.py | UTF-8 | 3,907 | 2.875 | 3 | [
"MIT"
] | permissive | """UCI dataset"""
from abc import abstractmethod
import logging
from pathlib import Path
import numpy as np
import torch.utils.data as torch_data
from sklearn.model_selection import KFold
import urllib.request
# TODO: Check all url:s
class UCIData():
"""UCI base class"""
def __init__(self, file_path, url, se... | true |
84b8de3ca861c1a08a1d0de7b0ce72252b32c9fb | Python | hajicj/muscima | /muscima/graph.py | UTF-8 | 38,432 | 2.640625 | 3 | [
"MIT",
"CC-BY-NC-SA-4.0"
] | permissive | """This module implements an abstraction over a notation graph, and
functions for manipulating notation graphs."""
from __future__ import print_function, unicode_literals
from builtins import range
from builtins import object
import copy
import logging
import operator
from muscima.cropobject import CropObject, cropo... | true |
c1fccf2893e11dd14c1353fc15b3eef1792ed9fe | Python | jisshub/python-development | /advanced_oops/multipl_inherit.py | UTF-8 | 443 | 3.875 | 4 | [] | no_license | class Birds:
def __init__(self):
self.feathers = True
self.wings = True
self.four_legs = False
class Flying:
def fly(self):
return 'they can fly'
def speak(self):
return 'Can Speak'
class Nonflying(Birds, Flying):
def fly(self):
return 'Cant Fly'
bi... | true |
fac6ccd85e9b4c36dd109125855f4a268a9ef66b | Python | farrukhkhalid1/100Days | /Day19/challenges.py | UTF-8 | 862 | 3.984375 | 4 | [] | no_license | import random
import turtle
screen = turtle.Screen()
screen.setup(height=400,width=500)
input = screen.textinput(title='Turtle race',prompt='Name the color of your turtle')
colors = ['red','green','brown','blue','orange','purple']
count = 0
y= -60
turtle_list =[]
race_on = True
for i in range(len(colors)):
tim... | true |
6d45a5bb82aa847979018285a12673714fc048cb | Python | ckclark/leetcode | /py/number-of-boomerangs.py | UTF-8 | 619 | 3 | 3 | [
"Apache-2.0"
] | permissive | from collections import Counter
class Solution(object):
def numberOfBoomerangs(self, points):
"""
:type points: List[List[int]]
:rtype: int
"""
cs = [Counter() for _ in xrange(len(points))]
for i1, p1 in enumerate(points):
for i2 in range(i1 + 1, len(point... | true |
0f21ab7f4c3cfe9a3849437f26a4f42bed30e554 | Python | ItsTalha0/web-pdf-scraper | /pdf.py | UTF-8 | 968 | 2.84375 | 3 | [
"CC0-1.0"
] | permissive | import PyPDF2 as p2
import pandas as pd
import numpy as np
na_list=[]
roll_list=[]
def roll_extract(a):
roll_no=''
for i in range(20,35):
if name[i][-10:]=='118College':
for j in name[i][:-10]:
if j in '1234567890':
roll_no=roll_no+str(j)
... | true |
9076a4326dc9b6a64413fbc53560015b0f3a21b7 | Python | m-mohsin-zafar/img2cap-assignment | /extract_features.py | UTF-8 | 2,345 | 3 | 3 | [] | no_license | """
COMP5623M Coursework on Image Caption Generation
Forward pass through Flickr8k image data to extract and save features from
pretrained CNN.
"""
import torch
import numpy as np
import torch.nn as nn
from torchvision import transforms
from models import EncoderCNN
from datasets import Flickr8k_Images
from utils... | true |
441f34f887ce3c4a2ae8af1efd01972e12ec20df | Python | blockchain-certificates/cert-issuer | /cert_issuer/signer.py | UTF-8 | 2,689 | 2.640625 | 3 | [
"MIT"
] | permissive | import logging
import os
import time
import requests
from cert_issuer.models import SecretManager
class FileSecretManager(SecretManager):
def __init__(self, signer, path_to_secret, safe_mode=True, issuing_address=None):
super().__init__(signer)
self.path_to_secret = path_to_secret
self.s... | true |
11ce358075a5f47b42b5d8af7cd48d8f1aa8d5b8 | Python | 808sAndBR/Capstone | /alternate_text_sources/twitter_scraper.py | UTF-8 | 2,224 | 2.96875 | 3 | [] | no_license | import twitter
import csv
from time import sleep
# Set up a config.py file with your values
# can create/get your existing from https://apps.twitter.com/
from config import key, secret, token_key, token_secret
api = twitter.Api(consumer_key = key,
consumer_secret = secret,
... | true |
ffd12c1737f9ebe901fcd1326c82f76e9ddf9869 | Python | ceejii/makeradmin | /multiaccess-program/multi_access/dump/db_info.py | UTF-8 | 1,917 | 2.984375 | 3 | [] | no_license | import sqlalchemy
class PEP240(object):
""" https://www.python.org/dev/peps/pep-0249/#cursor-attributes """
def __init__(self, dict_entry):
assert isinstance(dict_entry, tuple)
assert len(dict_entry) == 7
self.name = dict_entry[0]
self.type_code = dict_entry[1]
self.dis... | true |
3e189943172ebdb90b2e128728bb0b9167dc7a1c | Python | AbhinavGor/Hackerrank-Python- | /Searching in Strings.py | UTF-8 | 666 | 3.609375 | 4 | [] | no_license | def count_substring(string, sub_string):
# string = str(input("Give a string for checking."))
subs = list()
for i in range(len(string) + 1):
for j in range(len(string) + 1):
if string[i:j] != "":
subs.append(string[i:j])
# print(subs)
# key = str(i... | true |
e4306c59765fb1fd494d931673b3a1962f41f801 | Python | PedroS50/CBD | /Lab-1/2/CountNames.py | UTF-8 | 752 | 2.890625 | 3 | [] | no_license | # Script used to write initials4redis.txt
inputFile = 'female-names.txt'
outputFile = 'initials4redis.txt'
with open(inputFile, 'r') as fileR:
with open(outputFile, 'w') as fileW:
line = fileR.readline()
wordCount = 0
letter = None
# If the file is not empty...
if line is not None:
letter = line[0].low... | true |
5193766eea3c88bb15a1a106eb0634d7da9ce07d | Python | pshirshov/agatsuma | /agatsuma/minicache.py | UTF-8 | 2,625 | 3.125 | 3 | [] | no_license | import threading
# I've tried django RWLock. It is very slow, so I prefer
# usual threading.Lock. Yes, it gives exclusive access for readers,
# but faster for five times.
#from agatsuma.third_party.rwlock import RWLock
class MiniCache(object):
"""Implements thread-safe dict-based cache. Intended only for internal... | true |
f784cd05ca7443394a21c77d109843ee7e24ae74 | Python | rain567/liupanshui_job | /python/8_unit/person.py | UTF-8 | 641 | 4.53125 | 5 | [] | no_license | # 人:设计一个Person(人)类,包括姓名、年龄和血型属性。编写构造方法用于初始化属性值,编写detail方法用于打印输出每个属性值。
# 创建一个Person类的实例,并调用detail方法,打印输出实例的属性值。
class Person:
def __init__(self, name, age, blood_type) -> None:
self.name = name
self.age = age
self.blood_type = blood_type
def detail(self):
print('姓名:{},年龄:{}岁,血型... | true |
e7b4e71b9cf3d1a5101e1f520e605d184ba67189 | Python | ErikBavenstrand/Project-Euler | /src/009.py | UTF-8 | 223 | 3.265625 | 3 | [] | no_license | value = 0
c = 0
for a in range(1, 1001):
for b in range(1, 1001):
c = 1000 - a - b
if a*a + b*b == c*c:
value = a*b*c
break
if value != 0:
break
print(value) | true |
d53169f0b4b58c2cb54044243bd89aff3742dc2a | Python | andreplacet/exercicios_python | /aula16.5.py | UTF-8 | 273 | 3.78125 | 4 | [] | no_license | a = (2, 5, 4)
b = (5, 8, 1, 2)
print(a)
print(b)
c = a + b
print(c)
print(sorted(c))#ordem crescente
print(len(a))
print(len(b))
print(len(c))
print(c.count(4))#conta a quantidade de valores solicitados no parametro
print(c.index(8))#mostra o indice do valor do parametro
| true |
2ad425dbf946304ce2f19ddc7ef7828aefacc336 | Python | jordanblakey/algorithms-dojo | /Python/possible_pin_numbers.py | UTF-8 | 3,911 | 3.40625 | 3 | [] | no_license | ################################################################
REFACTORED SOLUTION
################################################################
from itertools import product
def get_pins(obs):
p = { '1': ['1', '2', '4'], '2': ['1', '2', '3', '5'], '3': ['2', '3', '6'], '4': ['1', '4', '5', '7'], '5': ['2', '4'... | true |
d5f24c88c7f1b817d1b399d20f22a1aa96ce8b59 | Python | onemillet/Learn | /Python/prj3_spider/img_spr.py | UTF-8 | 530 | 2.84375 | 3 | [] | no_license | #!/usr/bin/env python
import urllib, urllib2
import re
def getHtml(url):
page=urllib2.urlopen(url)
return page.read()
def getImage(html):
re_img=re.compile(r'<img class="BDE_Image" src="(.*?)".*?>')
img_list=re_img.findall(html)
# return img_list
i=1
for img_url in img_list:
print ... | true |
676746be80f49880fa835df39ae05b911ab9fbcc | Python | andrewdelamare/University | /YEAR2/SEMESTER2/CS2521-Algorithms/Assessment/Assignment/Assignment/Source/Routing2d.py | UTF-8 | 1,052 | 3.421875 | 3 | [] | no_license | from readfile import Read
from dijkstra import dijkstra
from copy import deepcopy
'''
Write a program to compute the time at which the last passenger(s) arrive at their destination; given the input files, as output, your program should return a single number — the time at which the last passenger(s) arrive at their d... | true |
c6947358aa4c3ab27fedf2a35f7a2094adb59513 | Python | dominiquepieton/python-scrapping | /main.py | UTF-8 | 478 | 3.109375 | 3 | [] | no_license | '''
Projet : Scrap V1.0
Objectif du projet est de faire une application afin de pouvoir executer un scrapping en toute simplicité.
On utilisera :
- la bibliothèque bs4 pour parser le html.
- la bibliothèque time pour espace le scrapping
- la bibliothèque requests pour faire une requête
'''
import requests
imp... | true |
e0977431f91b95b890e70668b0ca999901a17041 | Python | octopusengine/octopuslab | /esp32-micropython/examples/test_servo.py | UTF-8 | 422 | 2.921875 | 3 | [] | no_license | # servo test - example
from time import sleep
from utils.pinout import set_pinout
from components.servo import Servo
# todo: PWM double setup error
pinout = set_pinout()
# s1 = Servo(pinout.PWM1_PIN)
# s2 = Servo(pinout.PWM2_PIN)
s3 = Servo(pinout.PWM3_PIN)
angles = [0, 20, 50, 70, 90]
while True:
for a in an... | true |
04ed05d23d0dbfe3952b49e45ba50cf7f044bb84 | Python | freemanwang/Algorithm | /leetcode/sort/8.冒泡.py | UTF-8 | 478 | 3.765625 | 4 | [] | no_license | # 把大的冒泡到后面
def bubleSort(lst:list):
if not lst:
return
# 不改变传入数组
lst = lst[:]
length = len(lst)
i = length -1
# 比的范围每次-1,因为每次总有1个当前最大挪到后面
while i > 0:
for j in range(i):
if lst[j] > lst[j+1]:
lst[j], lst[j+1] = lst[j+1], lst[j]
i -= 1
r... | true |
bb50680d653e7bd51c6fd2ae1fbd429affcf3b62 | Python | Furqannasir7/Web_Scraping_Portfolio | /Bot for google search scrapping with Selenium.py | UTF-8 | 1,973 | 3.15625 | 3 | [] | no_license | from selenium import webdriver
from selenium.webdriver.common.by import By
from selenium.webdriver.support.ui import WebDriverWait
from selenium.webdriver.support import expected_conditions as EC
import pandas as pd
import time
# path to chromedriver.exe
path = '//Driver/chromedriver'
# create instance of webdriver
dr... | true |
972860973210ca702a3b7286550b0af50bc345af | Python | DongHyun99/boneAge_predict | /Experiment/creat_dataframe.py | UTF-8 | 986 | 2.671875 | 3 | [
"MIT"
] | permissive | import numpy as np
import pandas as pd
#data load
train_img_path = 'bone_data/train/'
train_csv_path = 'bone_data/training_dataset.csv'
# dataset setting
train_data = pd.read_csv(train_csv_path)
train_data.iloc[:, 1:3] = train_data.iloc[:, 1:3].astype(np.float)
df = []
t1 = train_data[train_data['boneage']<57]
t2 = ... | true |
2b6518c625aead7c09ed14ffdf24f2d53d9d72c8 | Python | dq-code/leetcode | /52-NQueensII.py | UTF-8 | 987 | 3.3125 | 3 | [] | no_license | class Solution(object):
def noFight(self, row, col, board):
i = row - 1
j = col - 1
k = col + 1
while i >= 0:
if board[i][col] == 'Q': return False
if j >= 0 and board[i][j] == 'Q': return False
if k < self.n and board[i][k] == 'Q': return False
... | true |
2d93b3ce7f0d9a98b62f0ddd417657b638363a78 | Python | itsolutionscorp/AutoStyle-Clustering | /all_data/exercism_data/python/rna-transcription/9f4de2dba4a54beab0846cc8dc143728.py | UTF-8 | 1,082 | 3.8125 | 4 | [] | no_license | # -*- coding: utf-8 -*-
import re
def to_rna(dna):
""" given a DNA strand, returns its RNA complement (per RNA transcription)
:param dna: DNA strand
:type dna: str
:return: thr RNA complement of the given DNA strand
:rtype: str
"""
dna = dna.upper()
if re.match('^[GCTA]+$', dna) is no... | true |
75e6a67728648dd484cf05bf38264d54eeba4384 | Python | vinsis/points-in-2d | /concentric_circles/loader.py | UTF-8 | 914 | 2.84375 | 3 | [
"MIT"
] | permissive | import torch
import torch.nn as nn
from torch.utils.data import Dataset, DataLoader
import numpy as np
two_pi = 2 * np.pi
class Point(Dataset):
def __init__(self):
self.offset_and_length = (3,2)
self.inner_to_outer_ratio = 0.5
def __len__(self):
return 50000
def to_outer_class(se... | true |
badb7aa82656bee1c8db2a02bd7b9c7f52d9b203 | Python | jim-shaw-web/flopp_test | /scripts/haplo_truth_2_pickle.py | UTF-8 | 823 | 2.8125 | 3 | [] | no_license | import numpy as np
import pickle
import sys
haplo_string = sys.argv[1]
out_haplo_string = sys.argv[2]
ploidy = int(sys.argv[3])
print("THER ENEEDS TO BE A FILLER LINE ON TOP!! ASSUME START AT LINE 2")
with open(haplo_string,'r') as file:
next(file)
H = []
for i in range(ploidy):
H.append([])
fo... | true |
17955723e8850ab4997a7dbbc64ec371fedc1133 | Python | RoboticsBrno/RoboticCourse | /Python/pyramidSolution.py | UTF-8 | 117 | 3.453125 | 3 | [] | no_license | import time
while True:
for i in range(1, 20):
print((20-i)*' ' + (2*i-1)*'*')
time.sleep(0.02)
| true |
273272ede26f1780710e8242ac96b5bed8fb552a | Python | YannTorres/Python-mundo1e2 | /Desafios/35AnalisandoTriangulo.py | UTF-8 | 423 | 4.25 | 4 | [] | no_license | print('-' * 28)
print('Analisador de Triângulos')
print('-' * 28)
s1 = float(input('Primeiro segmento: '))
s2 = float(input('Segundo segmento: '))
s3 = float(input('Terceiro segmento: '))
if (s2 - s3) < s1 < s2 + s3 and (s1 - s3) < s2 < s1 + s3 and (s2 - s1) < s3 < s1 + s2:
print('Com estes valores poderá se... | true |
fb48e3aacdb0993325a4aaca9690bc9ffbece213 | Python | Derfador1/thunderdome | /thunderdome.py | UTF-8 | 7,558 | 3.140625 | 3 | [] | no_license | #! /usr/bin/env python3
import random
import sys
import psycopg2
import time
import itertools
type_chart = {
"Physical":{"Radioactive":2, "Mystical":.5},
"Biological":{"Physical":2, "Chemical":2, "Mystical":2},
"Radioactive":{"Biological":2, "Chemical":.5, "Technological":.5, "Mystical":2},
"Chemical":{"Physical"... | true |
3e140064622f4a1e7ef77b15bc55b4d7bfdb5b70 | Python | pooya-mohammadi/OpenCVPython | /_03_transformation/_01_resize.py | UTF-8 | 709 | 2.75 | 3 | [] | no_license | import matplotlib.pyplot as plt
import cv2
img = cv2.imread('pooya.jpg')
height, width, _ = img.shape
img_resize = cv2.resize(img, (width * 2, height * 2))
img_resize_2 = cv2.resize(img, dsize=None, fx=0.5, fy=0.5)
img_resize_flag = cv2.resize(img, dsize=None, fx=0.5, fy=0.5, interpolation=cv2.INTER_LINEAR)
plt.sub... | true |
ea10a62e6a5a5f8a7dc093ce7bfaa84785bc4fa5 | Python | luanborelli/ipeadatapy | /ipeadatapy/themes.py | UTF-8 | 1,917 | 2.578125 | 3 | [
"MIT"
] | permissive | import pandas as pd
from .api_call import api_call
def themes(theme_id=None, name=None, macro=None, regional=None, social=None):
"""
:param theme_id: Theme ID by which the return will be filtered
:type theme_id: int, optional
:param name: Theme name by which the return will be filtered
:typ... | true |
2a8375b8bcc1521c665c722b5c7fe347120d4585 | Python | mazariks/ITI0102 | /iti0102-2020-master/PR/pr03_pancakes/pancakes.py | UTF-8 | 3,368 | 4.4375 | 4 | [] | no_license | """Pancakes."""
def make_n_pancakes(n: int, ingredients: list) -> int:
"""
Make n pancakes.
If you can not make n pancakes, make as many as you can.
If you can make more than n pancakes, do not make more. In that case make exactly n pancakes.
Use the following functions here.
Tip: the first s... | true |
1ea5f32aea6fdea5a65a8bfe3ac48db41727cda3 | Python | Jianyang-Hu/numpypractice | /threading_Lock_0408.py | UTF-8 | 2,266 | 3.625 | 4 | [
"Apache-2.0"
] | permissive | # -*- coding: utf-8 -*-
# @version : Python3.6
# @Time : 2017/4/8 9:32
# @Author : Jianyang-Hu
# @contact : jianyang1993@163.com
# @File : threading_Lock_0408.py
# @Software: PyCharm
"""
http://www.cnblogs.com/suoning/p/5599030.html
"""
import threading
import time
"""
threading.Thread类的使用:
1,在自己的线程类的__i... | true |
d67c8df02a4c05c49caddf9dafe54edb0ee0f25b | Python | SPAI-Lab/Audio-Super-Resolution | /eda.py | UTF-8 | 2,833 | 2.53125 | 3 | [] | no_license | import os
import h5py
import numpy as np
import matplotlib.pyplot as plt
from scipy.io import wavfile
from scipy import signal, misc
import pygame
import tensorflow as tf
from pygame import mixer
from time import sleep
from data import VCTK
print(tf.version.VERSION)
def play_sound(filename):
pygame.mixer.init()
... | true |
7cdd9f8afac4f4e93143f5ff87b2bbcbbab33cb9 | Python | mrice88-zz/CtCI | /chapter 1/1_2.py | UTF-8 | 569 | 4 | 4 | [] | no_license | # Given two strings, write a method to decide if one is a permutation of the other.
def checkpermutation(a,b):
try: # Handles weird input being handed to it.
return sorted(a) == sorted(b)
except TypeError:
return False
test1 = ['', 'a']
test2 = ['abc', 'acb']
test3 = ['', '']
test4 = ['abc... | true |
ea1ce4be8390dbd29b3658fdde9e6bc869891392 | Python | jaegomez/WeatherApp | /weatherProgram.py | UTF-8 | 290 | 2.546875 | 3 | [] | no_license | from weatherApiHandler import ApiHandler
from weatherInputHandler import InputHandler
def main():
db_handler = ApiHandler()
input_handler = InputHandler(db_handler)
while True:
command = raw_input("Weather App>")
input_handler.handle_command(command)
main()
| true |
2bdf954159e671e66f5884b5a5c535bd2bc07c7b | Python | delaven007/3-sql-django-ajax-web- | /3Django/1-框架开发-HTTP 协议-视图 view-请求和响应/mywebsite1原/mywebsite1/views.py | UTF-8 | 2,538 | 2.828125 | 3 | [] | no_license | from django.http import HttpResponse
def birthday_view(request):
html="生日为:"
if request.method == 'GET':
year=request.GET['year']
month=request.GET['month']
day=request.GET['day']
html+=year+'年'+ month +'月'+ day +'日'
return HttpResponse(html)
def sum_view(request):
html... | true |
6528bd98216614226cf1c3198d011cce4da09ff1 | Python | niciyan/dumyapp | /app/main/forms.py | UTF-8 | 953 | 2.796875 | 3 | [] | no_license | # -*- coding: utf-8 -*-
from flask_wtf import FlaskForm
from wtforms import StringField, SubmitField, TextAreaField
from wtforms.validators import Required, Length
from flask_pagedown.fields import PageDownField
class MessageForm(FlaskForm):
body = PageDownField(
"下に変換されたテキストが描画されます",
defa... | true |
520eb7e07c55f70647b863d72dba68d43af9c3b0 | Python | prasadbylapudi/competetive-programming | /sum_of_first_last_digits.py | UTF-8 | 136 | 3.671875 | 4 | [] | no_license |
x=int(input())
last_digit=x%10;
while(x>=10):
x=x//10
sum_of_first_last_digit=x+last_digit;
print(sum_of_first_last_digit)
| true |
1793854c6193ea1d7fa6b6c95169c9ed4d247459 | Python | Renaud17/testyme | /app.py | UTF-8 | 6,063 | 2.53125 | 3 | [] | no_license | import streamlit as st
import sqlite3
import pandas as pd
import geocoder
conn = sqlite3.connect('data.db')
c = conn.cursor()
def create_table():
c.execute('CREATE TABLE IF NOT EXISTS dealtable(RC TEXT,Société TEXT,Secteur TEXT,Activités TEXT,Adresse TEXT,Téléphone TEXT,Région TEXT,Latitude TEXT,Longitude TEXT)... | true |
6bbca3d66d399d16d3f18082c0ef69bc4a367a0b | Python | asmelo/python_course | /scriptProva.py | UTF-8 | 175 | 2.875 | 3 | [] | no_license | from random import choice
n = [2, 5, 9, 1, 4]
res = 2 % n[0]
print(res)
res = 5 % n[0]
print(res)
res = 9 % n[0]
print(res)
res = 1 % n[0]
print(res)
res = 4 % n[0]
print(res) | true |
d6f3179bcccdc1b9f9f80453f06f7d240221b0be | Python | SzBence911/12aProjects | /server/database.py | UTF-8 | 3,702 | 2.703125 | 3 | [] | no_license | import os
def createdb(name):
try:
if not os.path.isdir('database/' + name):
os.mkdir("database/" + name)
return True
else:
return "DB already exist"
except OSError:
return "Os error except while create " + name + " db"
def getfrdb(name):... | true |
d4bb413b11d1a364a2a5701fdaf608da407a697f | Python | joydas65/Codeforces-Problems | /Case_Of_The_Zeroes_And_Ones.py | UTF-8 | 330 | 3.328125 | 3 | [] | no_license | n = int(input())
s = input()
arr,c = [],0
for i in s:
if c > 0 and arr[-1] == '0' and i == '1':
arr.pop()
c -= 1
elif c > 0 and arr[-1] == '1' and i == '0':
arr.pop()
c -= 1
else:
arr.append(i)
c += 1
print(... | true |
177aa991e2b99f1ff2bb237226499560ac40e74b | Python | niuniu6niuniu/ML | /ex7/Ml07-K-means Clustering and Principal Component Analysis.py | UTF-8 | 11,098 | 3.09375 | 3 | [] | no_license | import os
import numpy as np
import re
from matplotlib import pyplot as plt
from mpl_toolkits.mplot3d import Axes3D
import matplotlib as mpl
from IPython.display import HTML, display, clear_output
try:
plt.rcParams["animation.html"] = "jshtml"
except ValueError:
plt.rcParams["animation.html"] = "html5... | true |
e42d00b2ca3eb8a7273787a784d40d025a02b450 | Python | hhoangnguyen/mit_6.00.1x_python | /week_3/lists.py | UTF-8 | 111 | 2.9375 | 3 | [] | no_license | L = [2, 1, 3]
L.append(5)
L = L + [7]
print(L)
L.extend([4, 9])
L1 = [1, 2, 3]
L2 = [1, 2, 3]
print(L1 == L2)
| true |
d1b9657fefa0c2b4fb22951d953201bbaf2e7cee | Python | usman-pervaiz/LAB-03 | /PE 3.py | UTF-8 | 269 | 3.640625 | 4 | [] | no_license | print("Muhammad Usman Pervaiz - 18B-006-CS - SEC-A")
print("LAB NO: 03")
#finding angular velocity
v = 10 # linear velocity is denoted by v
r = 0.3 # radius is denoted by r
w = v/r # angular velocity is denoted by w
print("\n\nThe angular velocity is",w,"rad/sec")
| true |
e038f918a76063cd65f240a44764b53528585d51 | Python | ztonege/Computer-Vision---16720A | /hw2_2020fall/python/planarH.py | UTF-8 | 4,237 | 2.71875 | 3 | [] | no_license | import numpy as np
from numpy import linalg as LA
import cv2
import random
import math
def computeH(x1, x2):
#Q2.2.1
#Compute the homography between two sets of points
A = np.empty(shape=(0,9))
for i in range(len(x1)):
arr = np.empty(shape=(1,9))
# -x -y 1 0 0 0 xu ... | true |
4206367df008ef4800a959f1ff6758dc88345bad | Python | GerardoNavaDionicio/Programacion_Orientada_a_Objetos | /Nueva carpeta (2)/servidor3.py | UTF-8 | 407 | 2.625 | 3 | [] | no_license | from socket import *
serverName = 'localHost'
serverPort = 12007
direccionCliente = serverName,serverPort
clienteTCPsocket = socket(AF_INET,SOCK_STREAM)
mensajeTCP = input('Ingresa una frase')
clienteTCPsocket.send(mensajeTCP.encode())
mensajeTCPModificado= clienteTCPsocket.recv(1024)
print('Mensaje enviado desde el s... | true |
f372b2a4e9d95a8665fffd53bdc94c4f2fc598c2 | Python | gohdong/algorithm | /programmers/85002.py | UTF-8 | 758 | 3.078125 | 3 | [] | no_license | from typing import Counter
def solution(weights, head2head):
answer = []
for h in range(len(head2head)):
heavy_win = 0
temp = {
'W' : 0,
'N' : 0,
'L' : 0
}
for i,b in enumerate(head2head[h]):
temp[b] += 1
if b == 'W'... | true |
c6eadc6da41f1a137a2cd4eb3f8df4b527ceb6ee | Python | DANS-KNAW/dccd-webui | /src/main/assembly/cronjobs/submissions_by_organisations.py | UTF-8 | 2,588 | 2.671875 | 3 | [
"Apache-2.0"
] | permissive | #!/usr/bin/python
# -*- coding: utf-8 -*-
"""Compile data on the number of objects submitted by each organisation
Retrieves the json data from the dccd-rest interface
Example output:
This file could then be read by a webapplication to show a summary chart using Morris.js
Requires:
docop... | true |
1532e572f745b28fc2f685220e5446a00f6791f1 | Python | desaivaibhav95/Object-Oriented-Programming-Python- | /Linked Lists/deleting_a_key at_given_position.py | UTF-8 | 1,905 | 3.90625 | 4 | [] | no_license | class Node:
def __init__(self, data):
self.data = data
self.next = None
class LinkedList:
def __init__(self):
self.head = None
# inserting a new node at the beginning
def push(self, new_data):
new_node = Node(new_data)
new_node.next = self.head
... | true |
758282e02330d3e85d389f3860c67d194572213e | Python | archanray/singular_vals | /similarities.py | UTF-8 | 691 | 3.109375 | 3 | [] | no_license | import numpy as np
from sklearn.metrics import pairwise_distances as euclid
def sigmoid(data1, data2, sigma=1):
"""
sigmoid = tanh(xy/sigma+1.0)
"""
similarity_matrix = np.matrix(data1) * np.matrix(data2.T)
similarity_matrix = (similarity_matrix / sigma) + 1.0
similarity_matrix = np.tanh(simila... | true |
4edb0787c503273ef112bac8569cbe18151713b7 | Python | wikmol/Python--exercices | /Zadania - listy/5zad_nr_2.py | UTF-8 | 126 | 3.578125 | 4 | [] | no_license | def multiply_numbers(x):
sum = 1
for n in x:
sum *= n
return sum
li = [2,2,3]
print(multiply_numbers(li)) | true |
37cb8ccdcaa392df24781f41fa518dbef5fc1726 | Python | foreverzmy/PythonDemo | /OpenCV/putText.py | UTF-8 | 761 | 3.234375 | 3 | [] | no_license | import cv2
def putText(fileName, text, position, fontFamily, fontSize, color, fontWeight):
"""
照片上添加文字
Parameters
----------
fileName : 文件名
text : 添加的文字
position : 左下角坐标
fontFamily : 字体
fontSize : 字号
color : 颜色
fontWeight : 字体粗细
"""
img = cv2.imread(fileName)
... | true |
1465ea3fe5a727d615ee6baf75d867e860160b5e | Python | lixiaojim1991/Py4e | /first.py | UTF-8 | 303 | 3.40625 | 3 | [] | no_license | sh = input("Enter Hours:")
sr = input("Enter Rate:")
try:
fh = float(sh)
fr = float(sr)
except:
print("Error, please enter numeric input")
quit()
print(fh,fr)
if fh > 40:
reg = fr * fh
otp = (fr-40)*(fr*0.5)
xp = reg+otp
else:
xp = fh*fr
print("Pay:",xp)
| true |
923e74b6624d0a1860040edc00a5a8afbf28b2bd | Python | pum-purum-pum-pum/octopus | /Visualization/strength_triangle.py | UTF-8 | 4,569 | 2.671875 | 3 | [] | no_license | import numpy as np
import pandas as pd
import argparse
import json
import os
epilog = \
"EXAMPLE of usage:\n" +\
"python strength_triangle.py --id1 19 --id2 75"
parser = argparse.ArgumentParser(description='input output files', epilog=epilog)
parser.add_argument('--id1', type=int, help="player1 id")
parser.ad... | true |
20a2a30bc03bdf829eb07abb8f31ff5f9cf64988 | Python | browarekk/RPG-w-tabelce | /locations.py | UTF-8 | 7,161 | 3.578125 | 4 | [] | no_license | from enemy import *
#########from RPG import *
def kanaly(score):
enemy = enemy_kanaly(goblin, rat, spider, big_rat)
print("groźny", enemy.name, "się pojawił!")
print("masz 4 opcje...")
while enemy.health > 0:
choice = input("1. atak mieczem\n2. atak magiczny\n3. ucieczka i powrót d... | true |
068002ba71369f679603be9ee18252e61b9d8e7c | Python | Gitiauxx/FBC | /source/losses/cross_entropy_loss.py | UTF-8 | 1,007 | 2.859375 | 3 | [] | no_license | import torch.nn as nn
from source.losses.templates import TemplateLoss
class CELoss(TemplateLoss):
"""
Implement a cross entropy loss with logits as torch BCEWithLogitsLoss
"""
def __init__(self):
super().__init__()
def forward(self, target, prelogits):
"""
:param targe... | true |
facafe28597496af06017eeb0552a8a434f37567 | Python | inovei6un/SoftUni-Studies-1 | /FirstStepsInPython/Basics/More Exercises/Conditional Statements /05. Firm.py | UTF-8 | 598 | 3.453125 | 3 | [
"MIT"
] | permissive | import math
hours_needed = int(input())
days_available = int(input())
workers_overtime = int(input())
# every worker can work only 2 hours a day overtime
overtime = 2 * workers_overtime * days_available
# time for training
total_hours_available = (((days_available - (days_a... | true |
016067f1433e15769cf4c6bd7b2314998743ee4c | Python | shruthiviswam/PYTHON | /reverse of a number.py | UTF-8 | 110 | 3.546875 | 4 | [] | no_license | a=int(input ("Enter the number : "))
r=0
b=a
while a!=0:
m=a%10
r=r*10+m
a=a//10
print(r)
| true |
3d9b0fb535c568a28cef1296d2bada0102841968 | Python | FlagJJohn/SpaceShooter | /modules/checks/__init__.py | UTF-8 | 5,444 | 2.953125 | 3 | [] | no_license | try:
from modules.ships import *
from modules.draw import *
except ModuleNotFoundError:
print('Não foi possível carregar algum módulo.')
def check_health(self):
"""
checa a vida do player e atribui uma imagem correspondente a barra de vida /
check the player's health and defines its health ba... | true |
203327de37c769dae96d03d8db9f037d312ebb64 | Python | aadiupadhyay/CodeForces | /codeforces/160/A.py | UTF-8 | 216 | 2.796875 | 3 | [] | no_license | n=int(input())
l=list(map(int,input().split()))
l.sort()
s=sum(l)
c=1
i=n-2
x=l[n-1]
s=s-l[n-1]
while i>=0:
if x>s:
break
else:
x=x+l[i]
s=s-l[i]
c=c+1
i=i-1
print(c)
| true |
41ee7da3799a321a968f380ce0eebfc39b649099 | Python | xandalm/Easy-Chatbot | /trychatbot/data/cornell/cornelldata.py | UTF-8 | 3,081 | 2.59375 | 3 | [] | no_license |
import pandas as pd
from ..prepare_data import Data
from six.moves import cPickle
import itertools
import os
import ast
class CornellData(Data):
def __init__(self):
super().__init__()
self.path = "data/cornell/"
self.dataset_size = 20000
def _normalize_data(self):
... | true |
35513f2f8edf013f8d72370a7918af368f59ff77 | Python | UnHumbleBen/Linear_Perceptron_Learning | /gradient_descent.py | UTF-8 | 3,458 | 3.484375 | 3 | [] | no_license | import math
import numpy as np
start_point = [1, 1]
learning_rate = 0.1
error_threshold = 10 ** -14
iterations_threshold = 15
def error_surface(uv_list=None):
u = uv_list[0]
v = uv_list[1]
return (u * math.exp(v) - 2 * v * math.exp(-u)) ** 2
def error_surface_gradient(uv_list=None, u=None, v=None):
... | true |
e75a765803cff1dbd5d55667503e359d30dc65d5 | Python | teeso/Better_color_detection_for_OpenCV | /test.py | UTF-8 | 1,808 | 2.671875 | 3 | [] | no_license | import numpy as np
import matplotlib.pyplot as plt
from mpl_toolkits.mplot3d import Axes3D
from mpl_toolkits.mplot3d.art3d import Poly3DCollection
import cv2
from os import listdir
from os.path import isfile, join
from color_detector import ColorDetector
# prepare arrays: positive and negative HSV points
hp, sp, vp =... | true |
3e70a3997fd357fbffb9e06e0d38e2d4324ab38f | Python | hadrien/pyramid_caching | /pyramid_caching/ext/metrics.py | UTF-8 | 1,108 | 2.625 | 3 | [] | no_license | """An extension that records the performance of the caching layer by sending
information about cache hits and cache misses events to a statistics aggregator
via pyramid_metrics.
"""
from pyramid.events import subscriber
from pyramid_caching.events import ViewCacheHit, ViewCacheMiss
def includeme(config):
"""Inc... | true |
32e5f0ce7b48967d783d7d0adc8892badbe446f8 | Python | standardgalactic/AnaFlow | /examples/06_compare_extthiem2d_grfsteady.py | UTF-8 | 902 | 2.59375 | 3 | [
"MIT"
] | permissive | # -*- coding: utf-8 -*-
import numpy as np
from matplotlib import pyplot as plt
from anaflow import ext_thiem_2d, ext_grf_steady
from anaflow.tools.coarse_graining import T_CG
rad = np.geomspace(0.05, 4) # radius from the pumping well in [0, 4]
r_ref = 2.0 # reference radius
var = 0.5 ... | true |
587efb2a5f55fd5bd795bb3819ce7ba4781564fd | Python | OdellBIII/112-Term-Project | /modes/Screen.py | UTF-8 | 1,556 | 3.046875 | 3 | [] | no_license | import pygame
from objects.GamePiece import GamePiece
from widgets.Widget import Widget
from widgets.TextInput import TextInput
class Screen(object):
def __init__(self, width, height, color):
self.gamePieceGroup = pygame.sprite.Group()
self.userInterfaceGroup = pygame.sprite.Group()
self.... | true |
82b55c467176d5781f6f435d113a94d3486bfdf1 | Python | joeashcraft/adventofcode | /day4.py | UTF-8 | 2,923 | 3.640625 | 4 | [] | no_license | #!env python
from collections import defaultdict
import re
def part1_parse(sorted_input):
# data structure might look like:
# { GuardId: [0 * 60], ... }
guards_sleeps = defaultdict(lambda: list(
map(lambda zz: int(zz), '0' * 60)))
for line in sorted_input:
parsing = re.split(r'[ \[\]... | true |
f73b9b2d138cccb06bd43e149d326a08945d650a | Python | Sars666/web-flask-ZhiHu_Copy | /week2/ZhiHu_Flask/ZhiHu/answer.py | UTF-8 | 253 | 2.609375 | 3 | [] | no_license |
import os
basepath = os.path.dirname(__file__)
print(basepath)
path = os.path.join(basepath,'static/img/uploads/')
print(path)
for img in os.listdir(path):
img_path = os.path.join(path,img)
print(img_path)
print(img)
os.remove(img_path) | true |
c7289fe52e791ffa979fea1e162427cac36de621 | Python | ehabel-kady/Item-Catalog | /add.py | UTF-8 | 1,710 | 2.59375 | 3 | [] | no_license | from sqlalchemy import create_engine, asc
from sqlalchemy.orm import sessionmaker
from database_setup import Base, Categories, Items,User
engine = create_engine('sqlite:///itemcatalog.db')
# Bind the engine to the metadata of the Base class so that the
# declaratives can be accessed through a DBSession instance
Base.m... | true |
9ac656b0086fe067295e5ab3311209304ca8dcf7 | Python | snehadujaniya/SIH-2020 | /Scripts/naukri_scrap.py | UTF-8 | 1,739 | 2.765625 | 3 | [] | no_license | from selenium import webdriver
import pandas as pd
from bs4 import BeautifulSoup
driver = webdriver.Chrome("./chromedriver")
df = pd.DataFrame(columns=["Title", "Location", "Company", "Salary", "Experience","Description"])
for i in range(0, 50):
driver.get('https://www.naukri.com/cloud-computing-jobs-' + str(i)... | true |
930be33ecd70ebe735f533381df4225a9b7476df | Python | Bye-lemon/PyTorch-Practice | /tests/test_DQN.py | UTF-8 | 1,262 | 2.71875 | 3 | [] | no_license | from unittest import TestCase
from models.DQN import *
class TestReplyMemory(TestCase):
@classmethod
def setUpClass(cls):
cls.memory = ReplyMemory(5)
def test_push(self):
try:
for i in range(6):
self.memory.push(i, i, i, i)
assert tuple(zip(*self.m... | true |
367cc34bdf950a46086202a829edddebafb5281a | Python | tavares-guilherme/WebScrapingForBetting | /LeagueStats.py | UTF-8 | 5,676 | 3.171875 | 3 | [] | no_license | import time
import requests
import pandas as pd
from bs4 import BeautifulSoup
from selenium import webdriver
from selenium.webdriver.firefox.options import Options
from match import match
import numpy as np
import json
class LeagueStats:
"""
This class is used to select a soccer league and generate the ur... | true |
59a7998e4b1b88a5675f8e7df05c5b9d9fb7bf8a | Python | krishnanunni-pr/Pyrhon-Django | /OBJECT_ORIENTED_PROGRAMMING/student oop.py | UTF-8 | 670 | 3.28125 | 3 | [] | no_license | class Student:
def __init__(self,name,rollno,course,mark):
self.name=name
self.rollno=rollno
self.course=course
self.mark=mark
def printval(self):
print("Name :",self.name)
print("Roll no :",self.rollno)
print("Course :",self.course)
print("Mark ... | true |
dae1f946d3a980c33d3cce85fa6af82d477083fd | Python | diwadd/SeaLionPopulation | /single_image_check.py | UTF-8 | 2,724 | 2.71875 | 3 | [
"MIT"
] | permissive | import os
import sys
import glob
import cv2
import numpy as np
import matplotlib.pyplot as plt
import data_handling_and_preparation as dhap
def plot_image(img, title="Title"):
plt.subplots()
plt.imshow(cv2.cvtColor(img, cv2.COLOR_BGR2RGB))
plt.colorbar()
plt.title(title)
plt.show()
def load_si... | true |
7bcba1fe0ed59c6df2869ca8054e6a4158f9c4c3 | Python | ZhuChaoyu/NLTK-learning | /第一章/1-2-list-string.py | UTF-8 | 752 | 3.734375 | 4 | [] | no_license | # coding=utf-8
##from nltk.book import *
##
##print sent1
###本节重点介绍python List,索引和切片
##为 Python 变量选择名称(或标识符)时请注意:首先,应该以字母开始,
##后面跟数字(0 到 9)或字母。因此,abc23 是好的,23abc 会导致一个语 法错误。
##名称是大小写敏感的。这意味着 myVar 和 myvar 是不同的变量。
##变量名不能包含空格,但可以用下划线把单词分开,如 my_var。
##注意不要 插入连字符来代替下划线:my-var不对,因为 Python 会把-解释为减号。
##我们可以把词用链表连接起来组成单... | true |
3338cc0c3321658902bd38af89415c5a73c8f10a | Python | glucn/datacamp | /Unsupervised_Learning_in_Python/01_Clustering_for_dataset_exploration/exercise07.py | UTF-8 | 690 | 2.859375 | 3 | [] | no_license | ########################################################
# Clustering stocks using KMeans
# See exercise07.md
#
# Preload
from sklearn.cluster import KMeans
from sklearn.pipeline import make_pipeline
from preload import stock_movements as movements
########################################################
# Import No... | true |
e5d64274a9e1c24c298c17aefc91ecdb59b37d15 | Python | Pavithra-Rajan/DSA-Practice | /Leetcode/Remove_Elem.py | UTF-8 | 616 | 3.15625 | 3 | [] | no_license | class Solution:
def removeElement(self, nums: List[int], val: int) -> int:
i=0
j=len(nums)
while i<j:
if nums[i]==val:
nums.pop(i)
j-=1
continue
else:
i+=1
return len(nums)
... | true |
023327c163e9221fcd3e8d23ccb46661b017206c | Python | SethThomas/data-structures-and-algorithms | /python/algorithms/insertion_sort/insertion_sort.py | UTF-8 | 660 | 4.46875 | 4 | [
"MIT"
] | permissive |
def insertion_sort(arr):
# BigO = O(2n)
# 0 Elements: Exception
if len(arr) == 0:
raise Exception('No Elements')
# 1 Element: Early Return
if len(arr) == 1:
return arr
for i in range(len(arr)):
# the value to be insertion-sorted
val = arr[i]
... | true |
adb605a3f085cd3d4ae1aa7a000c4b9d4567b943 | Python | josejimenezluna/pyGPGO | /pyGPGO/surrogates/GaussianProcess.py | UTF-8 | 8,251 | 2.984375 | 3 | [
"MIT"
] | permissive | import numpy as np
from scipy.linalg import cholesky, solve
from collections import OrderedDict
from scipy.optimize import minimize
class GaussianProcess:
def __init__(self, covfunc, optimize=False, usegrads=False, mprior=0):
"""
Gaussian Process regressor class. Based on Rasmussen & Williams [1]_ ... | true |
9bf7ddb374f6d73c91442969dd4436c55569917b | Python | a143753/AOJ | /0349.py | UTF-8 | 604 | 2.8125 | 3 | [
"Apache-2.0"
] | permissive | from itertools import dropwhile
n = int(input())
d = list(map(int,input().split()))
c = set()
for i in range(n):
if i in c:
continue
j = i
t = []
while True:
if j in c:
break
elif j in t:
# print("i={0},j={1}".format(i,j))
if i == j:
... | true |
5c556a5299aa18b17f2bbf26d858985be135188e | Python | yasmina85/DSA-stories | /src/count_number_of_words.py | UTF-8 | 5,979 | 2.671875 | 3 | [] | no_license | import numpy
import os
import re
import sys
import platform
def translate_non_alphanumerics(to_translate, translate_to=u' '):
not_letters_or_digits = u'!"#%\'()*+,-./:;<=>?@[\]^_`{|}~1234567890$&\u201C\u2018\u2019\u2014\u201D\u00AB.\u20AC\u25A0\uFD3E\uFD3F\u2022\u2013\u060C\u061F\u00BB\u0640\u2026\u202B\u2022\u20... | true |
d6e0d64c855f9aba2eaebf627718210e70d5ba68 | Python | jpchato/pdx_code | /programming_102/unit_3/search_google.py | UTF-8 | 1,085 | 3.5625 | 4 | [] | no_license | import sys
import webbrowser
# sys.argv will capture additional info
# passed through the command line
def search(url, query=''):
'''
Search google for the query
'''
search_url = url + query
print(search_url)
webbrowser.open(search_url)
print(sys.argv)
for item in sys.argv:
print(ite... | true |
034830d90348fbe5cd2c4c7408df4f88d3c42e7a | Python | zinsmatt/PyTorch-Examples | /mnist/classify.py | UTF-8 | 6,645 | 2.53125 | 3 | [] | no_license | import torch
import torch.nn as nn
import numpy as np
from torchvision import datasets, transforms
import torch.nn.functional as F
import torch.optim as optim
from torch.optim.lr_scheduler import StepLR
from torch.autograd import Variable
from distributions import SmoothOneHot, Dirichlet
BATCH_SIZE = 20
BATCH_SIZE_TES... | true |
84bbdb08d11f8858c43340e82ad312dab7d0e585 | Python | ykhoja/cv_project | /test/opencv_test.py | UTF-8 | 326 | 3.109375 | 3 | [] | no_license | import numpy as np
import cv2
# Folder with test images in it
path = './test_data/'
# Loading image '1.jpg', will display in a window
# and wait for keystroke to close image
img = cv2.imread(path + '1.jpg')
cv2.imshow('image',img)
cv2.waitKey(0)
cv2.destroyAllWindows()
# The loaded image is a numpy array
print(img.... | true |
50a14906a8062b1c0b300082b3060e3f3e5f09bc | Python | anthaas/Advent-of-Code-2019 | /day6/part1.py | UTF-8 | 427 | 3.453125 | 3 | [] | no_license | #!/usr/bin/python3
dict = {}
with open('input.txt') as f:
for line in f:
parent,child = line.rstrip().split(")")
dict[child] = parent
def calculate_orbit(element):
if dict.get(element) != None:
return 1 + calculate_orbit(dict.get(element))
return 0
unique_objects = set(list(dict.keys()) + list(dict.value... | true |
bad34fb7e427b56e30e11e3b9ee69cad88c8b37d | Python | cirusthenter/python | /src/others/max_of_test_randint.py | UTF-8 | 273 | 3.625 | 4 | [] | no_license | import random
from max import max_of
print("max limit")
num = int(input("number of random int: "))
lo = int(input("min: "))
hi = int(input("max: "))
x = [None] * num
for i in range(num):
x[i] = random.randint(lo, hi)
print(f'{(x)}')
print(f'max value: {max_of(x)}')
| true |
f13f9b9b91e131a9ec25a7e30cc7eb4c2b9c3318 | Python | Raushan117/Python | /027_Walking_Python_Directory.py | UTF-8 | 568 | 3.75 | 4 | [] | no_license | # Reference: https://automatetheboringstuff.com/chapter9/
# Best book ever!
import os
for folderName, subfolders, filenames in os.walk(os.getcwd()):
# print('Folder: ' + folderName)
# I think this is cleaner, less information :)
print(folderName)
for subfolder in subfolders:
# print('\tSubfol... | true |
877dfa97e15cd013cf52c6890190f0d243d77b2c | Python | tommyshere/python-deep-dive | /iterator_iterable.py | UTF-8 | 1,779 | 4.25 | 4 | [] | no_license | # iterable is created once
# iterator is created every time for a fresh iteration
class Cities:
def __init__(self):
self._cities = ['Paris', 'Berlin', 'Rome', 'London']
self._index = 0
def __len__(self):
return len(self._cities)
class CityIterator:
def __init__(sel... | true |
a955f21e89a1892e3cba11aad541181d1f7a8a5a | Python | nhsb1/clipboardlogger | /cxz-gui.py | UTF-8 | 1,026 | 2.828125 | 3 | [] | no_license | from easygui import *
import sys
import pyperclip
from argparse import ArgumentParser
parser = ArgumentParser(description = 'cxz - copy paste to text')
parser.add_argument("-f", "--file", required=True, dest="filename", help="file name to write output", metavar="FILE")
args = parser.parse_args()
while 1:
msg = "... | true |
ae051a5c9c8ac42c2c9be3fc33ec4e750f9ce1ec | Python | Jeko-Mus/Investigate-patients-skipping-medical-appointments | /Investigate_a_Dataset.py | UTF-8 | 10,718 | 3.515625 | 4 | [] | no_license | #!/usr/bin/env python
# coding: utf-8
#
# # Project: Investigate factors that affect whether or not a patient shows up to their medical appointment
#
# ## Table of Contents
# <ul>
# <li><a href="#intro">Introduction</a></li>
# <li><a href="#wrangling">Investigating the data</a></li>
# <li><a href="#eda">Findings and... | true |