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 |
|---|---|---|---|---|---|---|---|---|---|---|---|
427c23dd8e6f5dd177a28576a7c6dd77b7c01761 | Python | disiji/pycalib | /benchmark/synthetic_data.py | UTF-8 | 10,874 | 2.5625 | 3 | [
"MIT"
] | permissive | import os
import numpy as np
import scipy
import pandas as pd
import matplotlib.pyplot as plt
import pycalib.calibration_methods as cm
import pycalib.benchmark as bm
import pycalib.scoring as meas
from pycalib.plotting import reliability_diagram
import pycalib.texfig as texfig
if __name__ == "__main__":
########... | true |
d464bc473488ddefa4754bfef97dd814cd3b5f46 | Python | JohnWong/leetcode | /solution/3sum.py | UTF-8 | 986 | 3.359375 | 3 | [] | no_license | class Solution:
# @param {integer[]} nums
# @param {integer} target
# @return {integer[]}
def twoSum(self, nums, target):
s = nums
i = 0
j = len(s) - 1
r = set()
while i < j:
sums = s[i] + s[j]
if sums == target:
r.add((s[i]... | true |
cdc0975dc185f52a8c030a6a1b0d0057e930d982 | Python | lgt494371725/leetcode | /二叉查找树.py | UTF-8 | 7,683 | 3.34375 | 3 | [] | no_license | class BinarySearchTree:
def __init__(self):
self.root=None
self.size=0
def length(self):
return self.size
def __len__(self):
return self.size
def __iter__(self):#调用树节点的迭代器
return self.root.__iter__()
def put(self,key,val):#插入key构造BST,根据key来决定插入位置
... | true |
79c73ad5d61c8a1705cd859b7e54748996a26d8a | Python | lfjd05/backTrack-algorithm | /model.py | UTF-8 | 3,643 | 3.078125 | 3 | [] | no_license | def backTrack(assignment, csp, domain, method='natural'):
# assignment的定义:dict index=color
# backTrack:通过递归,对assignment做尝试赋值并AC-3检查,保存副本(浪费空间,但是作为练习够用),失败则回复副本.
# domain:当前domain assignment:当前赋值位置
# csp:问题描述(static)
# method:选择下一个变量采用的方法
if len(assignment) == len(csp):
return assignment
... | true |
a4a7a5330ccb3bc0e3ef11482b10b58ec40e2cf2 | Python | PeteCarrott/old-motronic | /tools/arduino_eprom_reader/read.py | UTF-8 | 464 | 2.609375 | 3 | [] | no_license | import serial
import time
adr = 0
buffer = []
ser = serial.Serial('/dev/ttyS10', 57600, timeout = 60)
ser.write('dummy_dummy_dummy_dummy'.encode('ascii'))
time.sleep(5)
ser.write('g'.encode('ascii'))
for x in range(2**16):
data = ser.read_until()[:-2]
ser.write('g'.encode('ascii'))
v = int(data)
adr += 1
buffe... | true |
119c2beb245ae8f363b19831c9e9bce979b9e8db | Python | MarkRDul/Sliding-Puzzle | /slidingPuzzle.py | UTF-8 | 8,684 | 3.765625 | 4 | [] | no_license | # 1234_5678 -> 3.9 Seconds No Heuristic, 17 Moves
# 1234_5678 -> 0.385 Seconds Simple Heuristic, 21 Moves
# 1234_5678 -> 0.309 Seconds Manhattan, 17 Moves
import sys
import math
import time
from queue import *
class Node:
def __init__(self, value, parent=None):
self.value=value
self.pare... | true |
3db707a11cdf9b650bf6348278bbbcd35016bded | Python | silchencko/python_puzzle | /lesson4/estimation/task/task.py | UTF-8 | 495 | 3.328125 | 3 | [] | no_license | class Task:
def __init__(self, a, m, b):
self._a = a
self._m = m
self._b = b
# def __init__(self, estimations):
# self._a = Decimal(estimations[0].strip())
# self._m = Decimal(estimations[1].strip())
# self._b = Decimal(estimations[2].strip())
@property
... | true |
7305d4eea6c7fd02655a25e4898729156a595718 | Python | HelenIISc/Forward-Probem | /Assests.py | UTF-8 | 2,787 | 3.78125 | 4 | [] | no_license | """Imports and performs minor modifications to pygame sprites.
2-D images used for sprites like vehicles, background tiles etc. are imported
here. Modifications are made to the images to fit the required dimensions of
sprites and also to match with background.
Typical usage example:
image = pygame.image.... | true |
cfb29bddbac90084468dcd81d8c52da023f325ac | Python | braytac/micropython | /tests/basics/builtin_dict.py | UTF-8 | 169 | 2.71875 | 3 | [
"MIT"
] | permissive | class A:
def __init__(self):
self.a=1
self.b=2
try:
d=A().__dict__
print(d['a'])
print(d['b'])
except AttributeError:
print("SKIP")
| true |
bd6dfc80bb26b19e725f6c9a51d13aefc1bfa8ec | Python | rosecondon/DataScience-Dev | /Python/simulation/airport-checker-simulation.py | UTF-8 | 2,958 | 3.40625 | 3 | [] | no_license | import simpy
import random
# Senario : Build a simulation of the system, and then vary the number of ID/boarding-pass checkers and personal-check queues
# to determine how many are needed to keep average wait times below 15 minutes.
# In airport, boarding pass takes place first, then customer will go to personal sec... | true |
b3764414aa9f51b6f9e313ba483718cdd9340247 | Python | L1nwatch/leetcode-python | /5.最长回文子串/test_solve.py | UTF-8 | 596 | 3.109375 | 3 | [] | no_license | #!/bin/env python3
# -*- coding: utf-8 -*-
# version: Python3.X
"""
"""
import unittest
from solve import Solution
__author__ = '__L1n__w@tch'
class TestSolution(unittest.TestCase):
def test_solve_func(self):
test_data_list = [([1, 3], [2]), ([1, 2], [3, 4])]
right_answer_list = [2.0, 2.5]
... | true |
da919494b9daaa8b84b59b5463a47053e7264986 | Python | lzahray/prosodyGan | /testClassifier.py | UTF-8 | 4,408 | 2.5625 | 3 | [] | no_license | import numpy as np
import torch
import torch.nn as nn
import math
import os
from torch.utils.data import Dataset, random_split, DataLoader
from torch.nn.utils.rnn import pack_padded_sequence, pad_packed_sequence, pad_sequence
from model import Classifier, Generator2
from utils import EmotionDataset, MidiWriter, Emotio... | true |
3439cfc8256a7b56fa97460edb3f32483afebd20 | Python | Calysto/metakernel | /metakernel/magics/pipe_magic.py | UTF-8 | 1,611 | 2.859375 | 3 | [
"BSD-3-Clause"
] | permissive | # Copyright (c) Metakernel Development Team.
# Distributed under the terms of the Modified BSD License.
from metakernel import Magic, option
class PipeMagic(Magic):
def __init__(self, *args, **kwargs):
super(PipeMagic, self).__init__(*args, **kwargs)
def cell_pipe(self, pipe_str):
"""
... | true |
2c4c60b5f4fb31246443057a95c33be4f28f97af | Python | SFin94/molLego | /molLego/utilities/plot_frames.py | UTF-8 | 21,619 | 2.78125 | 3 | [] | no_license | """Module containing general plotting routines for molecules."""
import sys
import os
import numpy as np
import pandas as pd
import seaborn as sns
import matplotlib.pyplot as plt
import matplotlib.cm as cm
import matplotlib.axes as axes
import matplotlib.lines as mlin
from mpl_toolkits.axes_grid1.inset_locator import... | true |
0a4e79269a9ee963f8cf304c3a9bf68009b87f54 | Python | u101022119/NTHU10220PHYS290000 | /student/101022114/drop_ball_time.py | UTF-8 | 256 | 3.625 | 4 | [] | no_license | g=10.0
h=float(raw_input("Put the height of the tower: "))
def drop_ball_time(h):
if h>0:
t=(2*h/g)**0.5
return t
elif h==0:
return 0
else:
return'Sorry, the height cannot be negative.'
print drop_ball_time(h)
| true |
6b9ed5b4932e8eceafffd20f516f51c1a69d2631 | Python | Santhiyaraju/flask-tutorial-demo | /mybio.py | UTF-8 | 407 | 2.59375 | 3 | [
"MIT"
] | permissive | """
Flask app to host my simple bio
Habit: Develop -> test locally -> commit -> push to remote -> deploy to prod -> test on prod === 30 minutes
"""
from flask import Flask
app = Flask(__name__)
@app.route("/")
def index_page():
"The search page"
return "<html><h1>Under construction</h1>Hello, I'm arun.<html... | true |
54a8bb47b07f9ab61b41f2c787fd4343f9d0cea9 | Python | jpulec/My--RPG | /GameObject.py | UTF-8 | 301 | 2.703125 | 3 | [] | no_license |
import Position
class GameObject(Position.Position):
def __init__(self):
Position.Position.__init__(self)
self.type = 0 # Type 0 means ... ummm... nothing.
def getType(self):
return self.type
def setType(self,type):
self.type = type
| true |
47281ec46074cb3d7a4c8d7c3c4140639302fecc | Python | HangChenn/GCN_DGL | /generate_dataset.py | UTF-8 | 13,318 | 2.828125 | 3 | [] | no_license | import networkx as nx
from networkx.algorithms.approximation import steiner_tree
import dgl
import torch as th
import numpy as np
import math
import statistics
class generate_connected_graphs_G_classfication(object):
"""The dataset class.
Parameters
----------
num_graphs: int
Number of graph... | true |
7c7ccbc87f5663314ab0a17a5097dc6fc2052e8a | Python | EdFarrell/250MilesCrossingPhila | /Python/GPX_to_KML.py | UTF-8 | 1,273 | 2.5625 | 3 | [] | no_license | import gpxpy
import gpxpy.gpx
import simplekml
## Variables to be transferred to inputs in UI script
tour_name = 'Test'
gpx = 'SampleData/140606.gpx'
flyto_duration = .5
# Create the output KML File
kml = simplekml.Kml()
# Create the tour
tour = kml.newgxtour(name=tour_name)
# Create a playlist in the tour
playlist = ... | true |
9f5cb9510be786ba5d5dec416b742a7a739b15c1 | Python | bornfight/shell-me-up-scotty | /scripts/github.py | UTF-8 | 886 | 3.015625 | 3 | [
"Apache-2.0"
] | permissive | from os import system
print """
Grabbing the source code from github\n
But before we do that, you'll need to go to github.com and add your newly created ssh key to your GitHub account\n
The details are here: https://help.github.com/articles/adding-a-new-ssh-key-to-your-github-account/\n
When you're don... | true |
a27f4b036348aa17030cac1191d3700c021d0370 | Python | ayeshamujtaba/ICTPRG-Python | /looptest.py | UTF-8 | 68 | 2.671875 | 3 | [] | no_license | #infinite loop
while (True):
print("loop")
print ("Finished") | true |
d952866f6f1ea4d75e4769622e0f7f606b6d04b6 | Python | stevenylai/pysf | /sf/device/zigbee/light/__init__.py | UTF-8 | 1,355 | 2.609375 | 3 | [] | no_license | '''Zigbee light device'''
import time
from ..zcl import on_off, level_control
class Device(on_off.Device, level_control.Device):
'''Light with on/off and level control clusters'''
end_point = 1
def __init__(self, event_loop, bindable='127.0.0.1:3000', key=b''):
'''Create light device.
Add... | true |
9361f99d928a76557a8af4d2f806a2958775046f | Python | cloudy/sawyer-fk-model | /utils/grapher.py | UTF-8 | 945 | 2.765625 | 3 | [] | no_license | import matplotlib
matplotlib.use('Agg')
import matplotlib.pyplot as plt
from matplotlib.backends.backend_pdf import PdfPages
plt.rcParams.update({'figure.max_open_warning': 0})
def plot_performance(hist, ptitle):
print("Generating performance plot...")
k = list(hist.keys())
range_epochs = range(0, len(his... | true |
e39f46bcb35e18755e0ecfe688563bfed05393b3 | Python | saker77/dahua-toggle-ivs | /dahuaEnableIVS.py | UTF-8 | 1,769 | 2.5625 | 3 | [] | no_license | #!/usr/bin/python3
import requests
from requests.auth import HTTPDigestAuth
import re
# SYNTAX FOR SETTING OPTIONS
# http://<ip>/cgi-bin/configManager.cgi?action=setConfig&<paramName>=<paramValue>[&<paramName>=<paramValue>...]
# SHOW ALL VideoAnalyseRules IN BROWSER
# http://<ip>/cgi-bin/configManager.cgi?action=getC... | true |
f5228f78aa3cca269300bf2f5cb69aa26dec561c | Python | james20141606/eMaize | /bin/infer_parent_genotypes.py | UTF-8 | 4,553 | 2.78125 | 3 | [] | no_license | #! /usr/bin/env python
import argparse, sys, os, errno
import logging
logging.basicConfig(level=logging.INFO, format='%(asctime)s %(name)s [%(levelname)s] : %(message)s')
logger = logging.getLogger('infer_parent_genotypes')
def prepare_output_file(filename):
try:
os.makedirs(os.path.dirname(filename))
... | true |
2053718c8b653efa071ab9eb2d7bc7682d59cf13 | Python | SRimbaud/Passerelle_LoPy | /scripts/Bibliotheques/node_core.py | UTF-8 | 6,675 | 2.84375 | 3 | [] | no_license | from machine import unique_id
from crypto import AES
import crypto
# On va utiliser une classe qui implémente de manière générale un noeud que ce
# soit une gateway ou un endPoint device. En effet l'héritage n'est pas fonctionnel
# à 100% en microPython on va donc créer des objets possédant le Node_Core.
# Leurs métho... | true |
ae12e704ce22b38a6fdef59bfff30313b0cf6e16 | Python | Vinicius-Bitencourt-Pereira/Python-3-Curso-em-Video | /MUNDO 1/EXERCíCIOS/Ex000.py | UTF-8 | 303 | 4.21875 | 4 | [] | no_license | # A função print() serve para imprimir os argumentos passados a ela no terminal.
# Usa-se '' ou "" para imprimir caracteres. string.--> print('str')
# para números e variáveis não usamos aspas. --> print()
# Crie um programa que mostre 'Ola, mundo!' na tela.
print('Olá, Mundo!')
| true |
ceb6963a7beb053468fbf83707bcfae0772c9386 | Python | jean-schneider/desktop-2048 | /fcts.py | UTF-8 | 2,499 | 3.03125 | 3 | [] | no_license | #================================================
#= 2048 =
#================================================
# J.Schneider
# 10/14-01/15
#
#################### FUNCTIONS MODULE #################
# Part of the 2048 for PC Project.
from random import randint
def test... | true |
fed00bd846ca7b2ead9ad2644dcd726136bcba0a | Python | dalor/drulatebot | /rulate_to_epub.py | UTF-8 | 2,542 | 2.6875 | 3 | [] | no_license | from rulate_parser import Book, Picture, Link, Chapter, HTML
from ebooklib import epub
def chapter_filename(chapter: Chapter) -> str:
return (chapter.url.replace('/', '_') if chapter.url else chapter.volume) + '.xhtml'
def picture_filename(pic: Picture) -> str:
return 'images/' + pic.filename
def row_to_h... | true |
9eb2ac0cdb564bcbbdc9b1f55549b26fc1c84b00 | Python | semaaltun/diabetic-retinopathy-code | /create_image_sframes.py | UTF-8 | 5,892 | 2.515625 | 3 | [
"MIT"
] | permissive | import graphlab as gl
import re
import random
from copy import copy
import os
from os.path import join, abspath, expanduser, split
from itertools import chain
import subprocess
random_seed = 0
n_duplicates = 4
random.seed(random_seed)
# Run this script in the same directory as the train/ test/ and
# processed/ direc... | true |
bf7f4572175a9a5d1d9f137df5bcae1848519821 | Python | vishal1565/Cryptography | /VigenereCipher/decrypt.py | UTF-8 | 322 | 3.140625 | 3 | [] | no_license | cipherText = input("Enter CipherText: ")
cipherText.upper()
key = input("Enter Key: ")
m = len(key)
key = key.upper()
mval = [(26-ord(i)+65) for i in key]
text = []
for i in range(len(cipherText)):
text.append(chr((ord(cipherText[i])+mval[i%m]-65)%26+97))
pt = "".join(i for i in text)
print("PlainText:",p... | true |
4b40062d6a8306f1cb474b8945bfe35689d66fd7 | Python | cytokine4242/SnakeVenom | /groupAl.py | UTF-8 | 4,536 | 2.734375 | 3 | [] | no_license | import sys
import csv
from Bio import SeqIO
from Bio.SeqIO import FastaIO
from Bio import Phylo
# get the parent node of a node
def get_parent(tree, child_clade):
node_path = tree.get_path(child_clade)
return node_path[-2]
#create a dictionary of all parent nodes and childs
def all_parents(tree):
parents = ... | true |
114336f473c6869f3c039667142765d26eb9ef8c | Python | ruot-nyak/Superhero-Team-Duel | /heroes-main/hero.py | UTF-8 | 3,908 | 4.0625 | 4 | [] | no_license | from ability import Ability
from armor import Armor
from weapon import Weapon
import random
class Hero:
def __init__(self, name, starting_health=100):
self.abilities = list()
self.armors = list()
self.deaths = 0
self.kills = 0
self.name = name
self.starting_health = ... | true |
21d09cac7ef61397e7b98820f78ad19eec0c38d1 | Python | cstaubli/ml_yt | /tf-feature_engineering.py | UTF-8 | 1,060 | 2.84375 | 3 | [] | no_license | # coding=utf-8
# https://github.com/random-forests/tensorflow-workshop/blob/master/archive/examples/07_structured_data.ipynb
import numpy as np
import tensorflow as tf
import pandas as pd
CENSUS_TRAIN_URL = (
"https://archive.ics.uci.edu/ml/machine-learning-databases/adult/adult.data"
)
CENSUS_TEST_URL = (
"... | true |
42153723c5e2afc2898e92f33c4e56fae779ea31 | Python | girishramnani/compititive_coding | /SPOJ/spoj-EDIST.py | UTF-8 | 378 | 3.40625 | 3 | [] | no_license | # -*- coding: utf-8 -*-
"""
Created on Sun Oct 26 20:49:09 2014
@author: girish
"""
iteration = int(input())
for i in range(iteration):
x=input()
y=input()
x=x.capitalize()
y=y.capitalize()
count=0
count+=abs(len(x)-len(y))
w=min(len(x),len(y))
for z in range(w):
... | true |
916800654e83c10d42773141782aa2a500feee88 | Python | samarthsaxena/Python3-Practices | /Practices/advanced python/CountersDemo.py | UTF-8 | 1,447 | 4.3125 | 4 | [] | no_license | # Demo the usage of Counters object
# https://book.pythontips.com/en/latest/collections.html#counter
from collections import Counter as cnt
def main():
# list of students in class 1
class1 = ["Bob", "Becky", "chad", "Darcy", "frank", "Hannah", "kevin", "james", "malanie", "panny", "steve"]
# list of stu... | true |
bfc07b315eb8839c491210f116b42c019a34eba5 | Python | Abdallah9/DATA-ENCRYPTION | /MultCipher_python/CeasarCipherGUI.py | UTF-8 | 4,026 | 3.109375 | 3 | [] | no_license | #import tkinter as tk
from tkinter import *
#from tkinter import ttk
from tkinter import scrolledtext
def encrypt(text, s):
result = ""
# traverse text
for i in range(len(text)):
charct = text[i]
if(charct==","):
result += ","
elif(charct==";"):
result += ";"
elif(charct==":"):
result += ":"
... | true |
51c6aea6ce3f2fc074d98ad4d0391bf89ed7db5f | Python | K-Class/Her-Seviyeye-Uygun-Python-Egzersizleri | /05-Project Euler/02-Cevaplar/py/PE17-Cevap.py | UTF-8 | 723 | 3.484375 | 3 | [] | no_license | birler = ["zero", "one", "two", "three", "four", "five", "six", "seven", "eight", "nine",
"ten", "eleven", "twelve", "thirteen", "fourteen", "fifteen", "sixteen", "seventeen", "eighteen", "nineteen"]
onlar = ["", "", "twenty", "thirty", "forty", "fifty", "sixty", "seventy", "eighty", "ninety"]
def ingilizce(n... | true |
dffe318caad9e25a508e7ec1104bb78a951189de | Python | Kevke93/CodingGame | /Hard/RollerCoaster/Solution.py | UTF-8 | 878 | 2.8125 | 3 | [] | no_license | waitingQueue,memoDict = [],{}
cash, nextGroup = 0, 0
l, c, n = [int(i) for i in input().split()]
for i in range(n):
waitingQueue.append(int(input()))
for i in range(c):
if nextGroup in memoDict.keys():
cash += memoDict[nextGroup]['rideCash']
nextGroup = memoDict[nextGroup]['nextGroup']
el... | true |
cd4e9209a35a74ed6eb8e9bee7e2ae4af6b0e38d | Python | Johnny112F/flask-notes | /models.py | UTF-8 | 1,874 | 2.921875 | 3 | [] | no_license | from flask_sqlalchemy import SQLAlchemy
from flask_bcrypt import Bcrypt
bcrypt = Bcrypt()
db = SQLAlchemy()
class User(db.Model):
"""Site user"""
__tablename__ = "users"
username = db.Column(db.String(20),
nullable=False,
unique=True,
... | true |
93eda24864433f23eeedc90b5ab21ec302bf2eb2 | Python | Bengaluru17/team-8 | /chandy/Amogh/db/makeform.py | UTF-8 | 2,900 | 2.5625 | 3 | [] | no_license | import requests
from bs4 import BeautifulSoup
import random
class MakeForm():
def generate(self,url):
form_id = ""
for i in range(5):
form_id += str(random.choice(range(0,10)))
r = requests.get(url)
soup = BeautifulSoup(r.text, 'html.parser')
form = soup.find_all... | true |
60ee6d7a1a031580c692dc6bb925ebc7dee34a4a | Python | ClimberY/video_super_resolution_toolbox | /cut_picture.py | UTF-8 | 1,052 | 2.578125 | 3 | [
"MIT"
] | permissive | import cv2
for big_i in range(1, 3344):
src = cv2.imread('Vid4/sandy/%04d.jpg' % big_i, -1)
cnt = 1
num = 1
sub_images = []
sub_image_num = 2
src_height, src_width = src.shape[0], src.shape[1]
sub_height = src_height // sub_image_num
sub_width = src_width // sub_image_num
for j in r... | true |
391167c2398d9f38822dac7c356e732ec2a81481 | Python | acanalda/pytrader | /strategies/__init__.py | UTF-8 | 670 | 3.09375 | 3 | [] | no_license | class Strategy:
"""Called on strategy start."""
def start(self, engine):
raise NotImplementedError("Should have implemented this")
"""Called on every bar of every instrument that client is subscribed on."""
def newBar(self, instrument, cur_index):
raise NotImplementedError("Should have... | true |
1934e0c429738e9cb6f0c0b8330d958c65f6415b | Python | Raniac/NEURO-LEARN | /env/lib/python3.6/site-packages/dipy/reconst/tests/test_peakdf.py | UTF-8 | 2,415 | 2.703125 | 3 | [
"Apache-2.0"
] | permissive | import numpy as np
import numpy.testing as npt
from dipy.direction.peaks import default_sphere, peaks_from_model
def test_PeaksAndMetricsDirectionGetter():
class SillyModel(object):
def fit(self, data, mask=None):
return SillyFit(self)
class SillyFit(object):
def __init__(self,... | true |
2ca0ade708ebda3183eea43d78e00fe7574341e6 | Python | 0xtalent/studying_python | /section06-1.py | UTF-8 | 1,554 | 3.40625 | 3 | [] | no_license | # Section06-1
# Selenium
# Selenium 사용 실습(1) - 설정 및 기본 테스트
import sys
import io
sys.stdout = io.TextIOWrapper(sys.stdout.detach(), encoding = 'utf-8')
sys.stderr = io.TextIOWrapper(sys.stderr.detach(), encoding = 'utf-8')
# selenium 임포트하기
from selenium import webdriver
# webdriver 성정(Chrome, Firefox 등 다 됨)
browser ... | true |
dc28dd0f8038f5ea0e062cc306928e47406325bf | Python | chughtaimh/WeatherApp | /tests.py | UTF-8 | 1,992 | 2.890625 | 3 | [] | no_license | import unittest
from main import get_html_for_zip, parse_html
from main import location_from_soup, temp_from_soup, cond_from_soup, humidity_from_soup
from utils import remove_tabs_new_lines, validate_zipcode
class AppTests(unittest.TestCase):
def remove_tablines_test(self):
self.assertEqual(re... | true |
672588ae3549a0fc889d5a0f844191141ecaa04d | Python | melisekm/Travelling-salesman-problem | /src/utils.py | UTF-8 | 2,116 | 3.296875 | 3 | [] | no_license | import math
optimal = {
"default20": 896,
"wi29": 27601,
"att48": 33522,
"berlin52": 7544,
}
class City:
def __init__(self, x, y):
self.x = x
self.y = y
def load_input():
print("Koniec [q]")
print("Predvygenerovane: [default20] [wi29] [att48] [berlin52]")
print("aleb... | true |
4e0b33820a07d0e6f3017d6f72fbbd54ca30cc97 | Python | BangpengGao/MachineLearning_By_Tensorflow | /LogisticRegression.py | UTF-8 | 1,307 | 2.6875 | 3 | [] | no_license | # -*- coding:utf-8 -*-
import tensorflow as tf
import numpy as np
learning_rate = 0.01
train_epoch = 500
batch_size = 10
loss = []
x = tf.placeholder("float")
y = tf.placeholder("float")
w = tf.Variable(tf.random_normal(shape), dtype = tf.float32, name = 'Weights')
b = tf.Variable(tf.random_normal(shape), dtype = tf... | true |
7160076d74d1a7faf94f13dd6d30590a329b320f | Python | rvsmegaraj1996/Megaraj | /register function.py | UTF-8 | 721 | 2.828125 | 3 | [] | no_license | #function with default argument
#def fun_name(parameter='')
def register(prefix,name,location="Ms/Miss/Mrs"):
if location=='salem':print(prefix,name,"has approved in",location)
elif location=='chennai':print(prefix,name,"has gone under waiting state since its",location)
else:print("Business not approved")
r... | true |
6f41689bc1d98ffb0b18d9af123ba69eb5a5c507 | Python | bboychencan/Algorithm | /leetcode/weekly_contests/weekly185/1420.py | UTF-8 | 943 | 2.5625 | 3 | [] | no_license | class Solution:
def numOfArrays(self, n: int, m: int, k: int) -> int:
dp = [[[-1 for i in range(k+1)] for i in range(m+1)] for i in range(n+1)]
def dfs(arrlen, lgst, cost):
# print(arrlen, lgst, cost)
if dp[arrlen][lgst][cost] != -1:
return dp[arrlen][lgst][... | true |
be5ab5ba534ba4b0f2d38d32eac8f647af167fbd | Python | kngwyu/Rainy | /rainy/replay/test_deque.py | UTF-8 | 1,797 | 3.390625 | 3 | [
"Apache-2.0"
] | permissive | import random
from collections import deque
from .array_deque import ArrayDeque
def test_deque_push_back() -> None:
deq = ArrayDeque(capacity=10)
for i in range(14):
deq.push_back(i)
for i in range(4, 14):
assert deq[i - 4] == i
def test_deque_push_front() -> None:
deq = ArrayDeque... | true |
6b76bd1cd1a9b94de22650905143d43a38582306 | Python | pypeit/PypeIt | /pypeit/inputfiles.py | UTF-8 | 31,807 | 2.671875 | 3 | [
"BSD-3-Clause"
] | permissive | """ Class for I/O of PypeIt input files
.. include:: ../include/links.rst
"""
from pathlib import Path
import os
import glob
import numpy as np
import yaml
from datetime import datetime
import io
import warnings
import configobj
from astropy.table import Table, column
from astropy.io import ascii
from pypeit import... | true |
5e65a62c397f0d33db919cc52bd2060c9d5cf223 | Python | kumaruday691/KARNA | /actions/DisplayAmbienceAction.py | UTF-8 | 904 | 2.65625 | 3 | [] | no_license | import datetime
import math
from actions.AbstractAction import AbstractAction
from peripherals.PeripheralFactory import PeripheralFactory
from peripherals.humidity.HumiditySensor import HumiditySensor
class DisplayAmbianceAction(AbstractAction):
# region Constructor
def __init__(self):
super().__in... | true |
5a6b1f4f6aa02766320171a53dcefec2eba9728f | Python | michaela-williams/CS585_TestCasePrioritization | /TestPrioritize.py | UTF-8 | 14,053 | 2.546875 | 3 | [] | no_license | import time
from random import randrange
from copy import deepcopy
from math import ceil
maxNumTests = 30000
numRuns_randomAverage = 100
percentFailures = .9
sortSizeTestVals = [1000, 500, 100, 50]
def runAllTests():
runAllTests_googleCodeData()
runAllTests_generatedData()
def runAllTests_googleCodeDat... | true |
542e9838b505c56bb6654c074de8e18bf8f99116 | Python | Scavi/SnakeSqueeze | /src/snake_squeeze/Y2022/Day6TuningTrouble.py | UTF-8 | 235 | 2.59375 | 3 | [] | no_license | from collections import Counter
class Day6TuningTrouble:
@staticmethod
def solve(signal: str, marker: int) -> int:
return [i for i in range(marker, len(signal)) if max(Counter(signal[i - marker:i]).values()) == 1][0]
| true |
b1df5155f0cc2e8437f81f44a8d45957cfc2f1ae | Python | panoczy/pano-2 | /calculator.py | UTF-8 | 1,102 | 3.109375 | 3 | [] | no_license | #!/usr/bin/env python3
import sys
def result(argv):
for s in sys.argv[1:]:
try :
number,salary = s.split(':')
salary = int(salary)
except(IndexError,ValueError):
print("Parameter Error")
else:
a = salary - 3500 - suf(salary)
income... | true |
fcd833a4460a3789ebea55ddc52a90cc9d71d3e5 | Python | Nori93/DangerDagger | /menus/menu.py | UTF-8 | 4,671 | 2.828125 | 3 | [] | no_license | import pygame as pg
from game.color import *
from game.input_handlers import handle_main_menu
from game.render_function import draw_text, draw_panel
from game.text_align import TEXT_ALIGN
from ui.label import Label
from ui.select import Select
from ui.panel import Panel
class Menu():
def __init__(self, game):
... | true |
c09af2d3ad07b599e4995b32c6a77b45b69b8e9a | Python | lucychang0220/SOFT3888_Usyd19P38 | /code_comments.py | UTF-8 | 3,547 | 2.65625 | 3 | [] | no_license |
/** addEventListener.js
* This file contains functions for scroll map features.
* These helper functions will get the scroll position and mouse position,
* and updated them when needed.
*/
/** auto_click.js
* Helper function that links to start function when the button is clicked.
*/
/** backgroundTracke... | true |
08b227e5a2d5b655f35854390db9fd365ae63071 | Python | sajjadjafaribojd/python-handbook | /module.py | UTF-8 | 306 | 2.921875 | 3 | [] | no_license | import mymodule as jabj #Re-naming a Module
from mymodule2 import personal_info2 #Import From Module
#print(mymodule.txtinfo("sajjad"))
print(jabj.txtinfo("sajjad"))
#x= mymodule.personal_info["age"]
x= jabj.personal_info["age"]
print(x)
print(dir(jabj))
print(personal_info2["age"]) #Import From Module | true |
5f013fbb58bd37f44cab9db77dac5d3b3103b261 | Python | hyejun18/daily-rosalind | /prepare/template_scripts/bioinformatics-stronghold/PRSM.py | UTF-8 | 918 | 2.953125 | 3 | [] | no_license | ##################################################
# Matching a Spectrum to a Protein
#
# http://rosalind.info/problems/PRSM/
#
# Given: A positive integer n followed by a collection
# of n protein strings s_1, s_2, ..., s_n and a
# multiset R of positive numbers (corresponding
# to the complete spectrum of some un... | true |
91ec37a927497df5df1036193d090705d03c8ea4 | Python | KC64ML/Python | /Python/code/Day 2/string formating.py | UTF-8 | 235 | 3.203125 | 3 | [] | no_license | name = "goorm"
age = 26
height = 171.2323
print("저의 이름은 %s입니다." %name)
print("저의 나이는 %d입니다." %age)
print("저의 키는 %.2f입니다." %height)
print("test")
print("test")
print("test")
print("test") | true |
66a40f9644a48a5905ebb33d5ce03826717247bb | Python | wanggl617/python_o | /py_03_self.py | UTF-8 | 244 | 3.84375 | 4 | [] | no_license | class Cat:
'''这是一个猫类'''
def eat(self):
#哪一个对象调用的方法,self就是其的引用
print("%s 爱吃鱼" % self.name)
tom=Cat()
tom.name="TOM"
tom.eat()
jelf=Cat()
jelf.name="JELF"
jelf.eat()
| true |
5ee120ab9182d71ed20b344cb59d0c011be818c7 | Python | sigmaleph/sklearn_transforms | /my_custom_sklearn_transforms/sklearn_transformers.py | UTF-8 | 1,261 | 3.0625 | 3 | [] | no_license | from sklearn.base import BaseEstimator, TransformerMixin, ClassifierMixin
import xgboost as xgb
# All sklearn Transforms must have the `transform` and `fit` methods
class DropColumns(BaseEstimator, TransformerMixin):
def __init__(self, columns):
self.columns = columns
def fit(self, X, y=None):
... | true |
e7a24df2d94a9f2f2b389576b10d4490307083f7 | Python | subbul/python_book | /tuples.py | UTF-8 | 912 | 3.984375 | 4 | [] | no_license | print "######################TUPLES######################"
x = ('a','b','c','d') # tuples are covered with paranthesis ( )
print "Tuple -->", x
print "Type of x-->",type(x)
x = 3
y = 4
z = (x+y,) #, within () indicates one element Tuple
print "Z is -->", z
print "(a,b,c,d) = (1,2,3,4)"
(a,b,c,d) = (1,2,3,4) ... | true |
76c501c7a41c2998e8da34980b12999dad305d64 | Python | vgyg/angr-doc | /examples/a_unicorn_examples/task/fibonacci.py | UTF-8 | 2,938 | 2.53125 | 3 | [
"BSD-2-Clause"
] | permissive | from unicorn import *
from unicorn.x86_const import *
import struct
def read(name):
with open(name, "rb") as f:
return f.read()
def u32(data):
return struct.unpack("I", data)[0]
def p32(num):
return struct.pack("I", num)
def hook_code(mu, address, size, user_data):
# print('>>> Tracing i... | true |
07dab7813c67ca7e26d79bcd5b196d5ec7dd8c1d | Python | proknow/proknow-python | /proknow/Audit.py | UTF-8 | 8,456 | 3.03125 | 3 | [
"MIT"
] | permissive | __all__ = [
'Audit',
]
import copy
class Audit(object):
"""
This class should be used to interact with the audit logs in a Proknow organization. It is
instantiated for you as an attribute of the :class:`proknow.ProKnow.ProKnow` class.
"""
def __init__(self, proknow, requestor):
"""Ini... | true |
4b9fe2164ed7a066118b5cb574c85051ebfdf4b4 | Python | R-3030casa/Coursera | /ricardo_cursera/exercíciosenviados 6/somaHipo.py | UTF-8 | 467 | 3.1875 | 3 | [
"MIT"
] | permissive | def calcular_hipotenusa(a, b):
return ((a*a) + (b*b))
def soma_hipotenusas(n):
c = 1
soma = 0
while (c <= n):
_c = (c*c)
a = 1
b = 1
while (a < n):
while (b < n):
if (_c == calcular_hipotenusa(a, b)):
soma = soma + c... | true |
4782679a917829095f03acd879f00cb4f7778641 | Python | jon-chuang/rlgraph | /rlgraph/utils/ops.py | UTF-8 | 14,593 | 2.6875 | 3 | [
"Apache-2.0"
] | permissive | # Copyright 2018/2019 The RLgraph authors. All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by appli... | true |
51d996361d7528163ce8c4dbf6f62432135124da | Python | IDdesigner/readit | /books/tests/test_forms.py | UTF-8 | 1,309 | 2.671875 | 3 | [] | no_license | from django.core.exceptions import NON_FIELD_ERRORS
from django.test import TestCase
from books.forms import ReviewForm, BookForm
from books.factories import AuthorFactory, BookFactory
class ReviewFormTest(TestCase):
def test_no_review(self):
form = ReviewForm(
data={
'is_favourite': False,
},
)
sel... | true |
c7b908bdb4f5769fdb17d2470d135aa6ba5eefb4 | Python | andrey-ladygin-loudclear/tankclient | /test.py | UTF-8 | 1,925 | 3.609375 | 4 | [] | no_license | from math import atan, fabs
def check(points, check_point):
sum = 0
px = check_point[0]
py = check_point[1]
for k in range(len(points)):
x1 = points[k][0] - px
y1 = points[k][1] - py
print(x1)
try:
x2 = points[k + 1][0] - px
y2 = points[k + 1][1... | true |
9184919aa54e22b8592c9f29abf251914ef449c6 | Python | liupeng89/CalligraphyEvaluationTool | /test/pypotrce_test.py | UTF-8 | 1,114 | 2.671875 | 3 | [] | no_license | from __future__ import division, print_function
from svgpathtools import Path, Line, QuadraticBezier, CubicBezier, Arc, wsvg, svg2paths, smoothed_path, kinks
paths, attributes = svg2paths("../test_images/src_resize.svg")
# for p in paths:
# print(type(p))
# print(len(p))
# print(len(paths))
# print(type(pat... | true |
ab3f01c358b0f92faa6cbc18e3580654207d05da | Python | CS205IL-sp15/workbook | /demo_pos/py/classDemos.py | UTF-8 | 2,013 | 2.859375 | 3 | [
"MIT"
] | permissive | import json
from nltk.tokenize import word_tokenize
from nltk.tokenize import sent_tokenize
from nltk.tokenize import TextTilingTokenizer
from nltk import pos_tag
from nltk import ne_chunk
from collections import defaultdict
def traverse(t):
try:
t.label()
except AttributeError:
ret... | true |
474b310fbd1fb3fbe32b6f48e8ff9197f10e31e6 | Python | harpone/statsmodels | /statsmodels/sandbox/regression/predstd.py | UTF-8 | 4,006 | 2.84375 | 3 | [
"BSD-3-Clause"
] | permissive | '''Additional functions
prediction standard errors and confidence intervals
A: josef pktd
'''
import numpy as np
from scipy import stats
def atleast_2dcol(x):
''' convert array_like to 2d from 1d or 0d
not tested because not used
'''
x = np.asarray(x)
if (x.ndim == 1):
x = x[:, None]
... | true |
e901f9388e7e361918bd0d17f49e811dac85de2e | Python | lee-seul/development_practice | /python/step_by_step/02/13_even_odd.py | UTF-8 | 410 | 3.453125 | 3 | [] | no_license | # coding: utf-8
a, b = map(int, input().split())
ar = ''
br = ''
if a % 2 == 0:
ar = "even"
else:
ar = "odd"
if b % 2 == 0:
br = "even"
else:
br = "odd"
if ar == br:
print("{}+{}={}".format(ar, br, "even"))
else:
print("{}+{}={}".format(ar, br, "odd"))
if ar == "even" or br == "even":
p... | true |
16175f44aed9d8f499717e3794bbde93abb15cb4 | Python | angelamyu/Edify | /cgi-bin/load_db.py | UTF-8 | 1,562 | 2.828125 | 3 | [] | no_license | #!/usr/bin/python
from createTable import create_tables
from insert_select_data import parse_load_csv
from get_lat_long import get_location
""" Parse the CSV's for populating the tables """
def main():
""" Controls the loading of the database and its tables """
create_tables() # create database tables
... | true |
d7108c9579d0832cf29d63abb371e758e532d68a | Python | ixaxaar/dnc-lm | /model.py | UTF-8 | 3,235 | 2.578125 | 3 | [] | no_license | import torch.nn as nn
from torch.autograd import Variable
from dnc import DNC
class RNNModel(nn.Module):
"""Container module with an encoder, a recurrent module, and a decoder."""
def __init__(
self,
rnn_type,
ntoken,
ninp,
nhid,
nlayers,
dropout=0.5,
tie_weights=... | true |
68be516c37a6b1aeb2a1822fa7ed359db7d12bbe | Python | StephenAjayi/learning_py1 | /convenience_functions.py | UTF-8 | 2,090 | 4.03125 | 4 | [] | no_license | def create_tunnel (cave_from, cave_to):
"""Create tunnel between cave_from
and tunnel_to"""
caves[cave_from].append(cave_to)
caves[cave_to].append(cave_from)
def visit_cave(cave_number):
"""Mark cave as visited"""
visit_caves.append(cave_number)
unvisited_caves.remove(cave_number)
def choo... | true |
c129beb50d43dd9d0e858a7bf591cfab8c9d0336 | Python | vedant-jad99/ML_beginner_codes_using_sklearn | /Linear_Regression_using_sklearn/LinearReg_using_sklearn.py | UTF-8 | 1,471 | 2.875 | 3 | [] | no_license | # %matplotlib inline
import pandas as pd
import pylab as pl
import numpy as np
import matplotlib.pyplot as plt
from sklearn import linear_model
from sklearn.metrics import r2_score
data = pd.read_csv("/home/thedarkcoder/Desktop/ML/Coursera/datasets/FuelCompsumtion.csv")
print(len(data))
# print(data)
# print(data.... | true |
e0a0ac495b7b4ad14a52fecf290336e8258010cb | Python | tahir24434/cracking_the_code_interview | /ctci/sorting_and_searching/10_1_sorted_merge.py | UTF-8 | 759 | 3.984375 | 4 | [] | no_license | # You are given two sorted arrays, A and B, where A has a large enough buffer at the
# end to hold B. Write a method to merge B into A in sorted order.
# This solution assumes that array A fits array B perfectly(it becomes a full array).
# Time: O(a)
# Space: O(a)
def sorted_merge(A, B):
A_idx = len(A) - len(B) -... | true |
498f54e9738bea6068e9aa2a127543d3274a24ab | Python | StefanEvanghelides/modellingSimulation | /video/video.py | UTF-8 | 3,020 | 2.859375 | 3 | [] | no_license | import cv2
import numpy as np
import glob
import time
import os, sys, shutil
import argparse
imagesDirectory = "plotting_result"
imagesPath = os.path.abspath(imagesDirectory)
videoDirectory = "video_result"
videoPath = os.path.abspath(videoDirectory)
FRAMES_PER_SECOND = 20
# Arguments
parser = argparse.ArgumentPa... | true |
e2df814ae7681abe960261c59ca05a1857aa0349 | Python | renkeji/leetcode | /python/src/main/python/Q069.py | UTF-8 | 600 | 3.28125 | 3 | [] | no_license | from src.main.python.Solution import Solution
# Implement int sqrt(int x).
#
# Compute and return the square root of x.
class Q069(Solution):
def mySqrt(self, x):
"""
:type x: int
:rtype: int
"""
if x < 2:
return x
epsilon = 0.000001
left, right... | true |
55173b859d232dd4b697491b075c5ad7e576cf89 | Python | swallat/sublimetext-vhdl-utils | /VHDL_Additions.py | UTF-8 | 10,082 | 2.78125 | 3 | [
"MIT"
] | permissive | import sublime, sublime_plugin
import re
from pprint import pprint
# This finds the entity around the current cursor/selection and parses out the name, generics, and ports
def parseEntity(view):
entityReg = None
genericListReg = None
portListReg = None
regionList=view.find_by_selector('meta.block.en... | true |
5a5eeeeef56353ee34ad457d9af4f32f87df4051 | Python | alexhagiopol/tensorflow-deeplab-resnet | /batch_inference.py | UTF-8 | 5,878 | 2.53125 | 3 | [
"MIT"
] | permissive | import argparse
import os
import tensorflow as tf
import numpy as np
import glob
from tqdm import tqdm
from deeplab_resnet import DeepLabResNetModel, dense_crf, inv_preprocess, prepare_label, decode_labels, threshold
from PIL import Image
# tuning constants
IMG_MEAN = np.array((104.00698793, 116.66876762, 122.67891434... | true |
931198181f43d21c1bc0978ec7d32259ade0251c | Python | SteephanSteve/Hunter_Program | /str_sort_lower.py | UTF-8 | 87 | 3.203125 | 3 | [] | no_license | n=int(input())
s=raw_input().split(' ')
s.sort()
for i in s:
print i.lower()
| true |
acd8c814b7e52d1f912b4e098916d9d74ef62a89 | Python | icisneros/uav_landing | /OtherssCode/SmartCamera-master/pl_sim.py | UTF-8 | 6,690 | 2.5625 | 3 | [
"MIT"
] | permissive | #!/usr/bin/python
import cv2
import numpy as np
import math
import time
from position_vector import PositionVector
from vehicle_control import veh_control
from droneapi.lib import VehicleMode, Location, Attitude
import sc_config
from pl_util import shift_to_image
current_milli_time = lambda: int(round(time.time() * 10... | true |
716519d24a16e0002abfce7e1a58aa396da016bb | Python | GreekPanda/leetcode | /Search/SearchInsertPosition/SearchInsertPosition.py | UTF-8 | 602 | 3.5 | 4 | [] | no_license | class SearchInsertPosition:
def searchInsertPosition(self, nums, k):
if nums is none:
return -1;
start, end = 0, len(nums) - 1
while start + 1 < end:
mid = (start + end) / 2
if nums[mid] == target:
end = mid
... | true |
fb1261d3815522afe7a5eb735bb8201e1eeafb16 | Python | eragnew/dojodojo | /day2/bike_chain.py | UTF-8 | 752 | 3.953125 | 4 | [] | no_license | class Bike(object):
def __init__(self, price, max_speed):
self.price = price
self.max_speed = max_speed
self.miles = 0
def displayInfo(self):
print 'Price: $%s' % str(self.price)
print 'Maximum Speed: %s' % str(self.max_speed)
print 'Total Miles Ridden: %s' % str(self.miles)
def ride(self):
print 'Ridi... | true |
e608723a230ee482da71f0dc1606a6040f3119cc | Python | FarhanHP/watershed | /watershed.py | UTF-8 | 5,661 | 2.953125 | 3 | [] | no_license | import numpy as np
class Pixel :
def __init__(self, grayScale, label=None, neighbors=None):
'''
int grayscale;
String label;
'''
self.grayScale = grayScale
self.label = label
if(neighbors == None):
self.neighbors = lis... | true |
6a6d3023e52ead0bd4ac8b31b72fed201defa096 | Python | fpjnijweide/FPGA-RPi-based-video-game | /py/threaded_pin.py | UTF-8 | 1,642 | 3 | 3 | [] | no_license | import threading
import constants
import initialisation
class threadPin (threading.Thread):
global pi
def __init__(self, name, pin):
threading.Thread.__init__(self)
self.name = name
self.pin = pin
def write(self, bit):
print("Writing the bit", bit, "to pin", self.pin)
... | true |
380ff24d3b51e2f3bf9b7448fc799374f28ea893 | Python | roothuntervn/CTF-Writeup | /Newark-Academy-CTF-2019/Code/test.py | UTF-8 | 178 | 2.65625 | 3 | [] | no_license | #!/usr/bin/env python3
from PIL import Image
im = Image.open('../Files/The_phuzzy_photo.png')
im2 = Image.new('RGB', (300, 300))
im2.putdata(list(im.getdata())[::6])
im2.show() | true |
3761576417aa4a685a975b7706bd4acb80d16523 | Python | clausserg/tictactoepy | /tictactoepy/tests/test_board_class.py | UTF-8 | 529 | 3.21875 | 3 | [
"BSD-3-Clause"
] | permissive | """
Module:
test_board_class.py
This module contains tests for:
tictactoepy.board_class.py
"""
import pytest
from tictactoepy.board_class import Board
def test_get_players():
"""Testing the print dunder of a Board object"""
my_board = Board()
str1 = " _1_ _2_ _3_ \n"
str2 = "1|___|___|___|\n"
... | true |
61bfb25dee4055f12d16e719d393eb2203927a07 | Python | MTG/smc-2016 | /src/jingjuSegAlign/src/concatenateSegment.py | UTF-8 | 6,056 | 2.90625 | 3 | [] | no_license | import numpy as np
import json
class ConcatenateSegment(object):
def __init__(self):
self.fs = 44100.0
self.hopSize = 256.0
########################################## notes manipulation ######################################################
def readPyinMonoNoteOut(self, monoNoteOut_filen... | true |
85e28a78094bf7cd260e5ea27b2590b8699920eb | Python | Something12343213412/Graphing-Program | /ShapeLine.py | UTF-8 | 640 | 3.40625 | 3 | [] | no_license | from PositionalVectors import Vector2
import pygame
class Line:
def __init__(self, One : Vector2, Two : Vector2, Color : (int,int,int), Width : int):
self.One = One
self.Two = Two
self.Color = Color
self.Width = Width
def getStartingPosition(self):
return self.One
... | true |
bc325a5b51f53e6f9351a23b1bea86d35a74b00c | Python | LvJC/myLittle | /数据结构/mergeSort.py | UTF-8 | 1,290 | 4.03125 | 4 | [] | no_license | # 1.
def mergeSort(alist):
if len(alist)<=1:
return alist
mid = len(alist)//2
left = mergeSort(alist[:mid])
right = mergeSort(alist[mid:])
return merge(left, right)
def merge(left, right):
newlist = []
i=0
j=0
while i<len(left) and j<len(right):
if left[i]<right[j]:
... | true |
fe0198e88e57ca01a2aff84513cd67444b651ed7 | Python | DMALab/autotf | /autotf/feature_engineering/feature_selection/wrapper.py | UTF-8 | 2,783 | 2.8125 | 3 | [
"BSD-3-Clause"
] | permissive | from sklearn.model_selection import train_test_split
from sklearn.metrics import accuracy_score
def _evaluate(x, y, clf, loss, selected):
if loss == "holdout":
x_train, x_valid, y_train, y_valid = train_test_split(x, y, test_size=0.3, stratify=y)
clf.fit(x_train[:, selected], y_train)
y_pr... | true |
ace4645e4cf9013494b4388db965a20b5252c8dc | Python | derkrisz/Python-training-11_2020 | /Day 4/using_tests/my_point.py | UTF-8 | 620 | 3.984375 | 4 | [] | no_license | class Point:
#static property
points = 0
@staticmethod # belongs to the class, not to the instance
def how_many_points():
return Point.points
def __init__(self, x = 0, y = 0):
self.x = x
self.y = y
Point.points += 1
def where_am_i(self):
... | true |
8598433000a1d90fdf751ea60a1d88fddad62bd3 | Python | JulioPDX/multi-vendor-python | /nornir_example/group_run.py | UTF-8 | 1,369 | 2.5625 | 3 | [] | no_license | #!/usr/bin/env python
"""
Source from Nick Russo Course
on Pluralsight
"""
import json
from nornir import InitNornir
from nornir_napalm.plugins.tasks import napalm_get
from nornir_utils.plugins.tasks.files import write_file
from nornir_utils.plugins.functions import print_result
import urllib3
# Disable warnings
url... | true |
2d81c292230ea522ddaece78aed27e3f6c4f5a37 | Python | hyeness/machine-learning-2018 | /hw1-diagnostic/util.py | UTF-8 | 6,250 | 2.9375 | 3 | [] | no_license | import numpy as np
import pandas as pd
from datetime import datetime
import matplotlib.pyplot as plt
import seaborn as sns
import json
import requests
from urllib.request import urlopen
#####################
# QUESTION 1 #
#####################
GRAFFITI = 'Data/graffiti.csv'
ALLEY_LIGHTS = 'Data/alley_lights.... | true |
6cf40eb004d850bdc83423b15da1ac451ed7d8c3 | Python | didierrevelo/AirBnB_clone_v2 | /web_flask/8-cities_by_states.py | UTF-8 | 655 | 2.84375 | 3 | [] | no_license | #!/usr/bin/python3
""" Script that starts a Flask web application
listened on 0.0.0.0 port 5000 using storage and routing
states_list
"""
from flask import Flask, render_template
from models import storage
from models.state import State
app = Flask(__name__)
@app.teardown_appcontext
def close(self):
""" closi... | true |
50678cc16ca33153617565c719d9319a3ddde7ea | Python | dr-dos-ok/Code_Jam_Webscraper | /solutions_python/Problem_135/1009.py | UTF-8 | 1,231 | 3.25 | 3 | [] | no_license | input_file = "A-small-attempt0.in"
with open("magic_trick.out", 'w') as output:
with open(input_file, 'r') as f:
n_cases = int(f.readline())
numbers = list(range(1, 17))
for i in range(n_cases):
first_answer = int(f.readline())
first_table = []
for j in... | true |