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 |
|---|---|---|---|---|---|---|---|---|---|---|---|
dd09656ed60993f418120cab33b7c7032a985097 | Python | diplodocuslongus/Pyllusion | /pyllusion/Poggendorff/poggendorff_image.py | UTF-8 | 1,112 | 2.53125 | 3 | [
"MIT"
] | permissive | import numpy as np
import PIL.Image, PIL.ImageDraw, PIL.ImageFilter, PIL.ImageFont, PIL.ImageOps
from ..image import image_line, image_rectangle
from .poggendorff_parameters import _poggendorff_parameters
def _poggendorff_image(
parameters=None, width=800, height=600, background="white", **kwargs
):
# Creat... | true |
b70e2731b670aedd85abdceba267109927106db4 | Python | isoetandar/DojoAssignments | /Python/python_fundamentals/FunctionBasicII/CountDown2.py | UTF-8 | 128 | 3.296875 | 3 | [] | no_license | def countDownArray(a):
arr=[]
for i in range (a,-1,-1):
arr.append(i)
return arr
print(countDownArray(10))
| true |
de141c21b8ba899953d1b5501e1f771133f2325c | Python | gaka2012/python3 | /runjava.py | UTF-8 | 278 | 2.859375 | 3 | [] | no_license | #!/usr/bin/python
# -*-coding:UTF-8 -*-
'''
测试程序,用来调用当前路径下的java程序,输入的参数是1,3,5.最后在shell上显示出来。
'''
import subprocess
arg1=1
arg2=3
arg3=5
subprocess.call('java HelloWorld %d %d %d' %(arg1,arg2,arg3),shell=True)
| true |
798c1e9737e5c0b3d58fcb7affa9c1724c71e22a | Python | redame/PolyU-COMP5940-Final-Dissertation-Improve-UCR-Suite-by-Low-Resolution-Technique | /Project UCR Suite - LowResED/_modules/normalization.py | UTF-8 | 2,519 | 3.65625 | 4 | [] | no_license | """
This module is for normalize queries.
Functions: forQuery(query) --> (normalzied query, query mean, query standard deviation)
forLowResQuery(query) --> (normalzied low resolution query upperbound, normalzied low resolution query lowerbound)
"""
import matplotlib.pyplot as plt
def forQuery... | true |
dcc85762790d9a82d61a484c6c074a72054ff074 | Python | rishikavaish/Projects-NLP | /Multilabel_classifier_webapp/multilabel_classifier_app.py | UTF-8 | 9,436 | 2.59375 | 3 | [] | no_license | # you can directly run this app using the command !streamlit run multilabel_classifier_app.py
# on your terminal
# import the required libraries
import os
import math
import numpy as np
import pandas as pd
from vaderSentiment.vaderSentiment import SentimentIntensityAnalyzer
import torch
from torch.nn import ... | true |
e9189bd3ddbf366c4b6b4fb745255f5a3a446dd0 | Python | llchen223/pyeq2 | /Examples/Cluster/Test_Single_Fit.py | UTF-8 | 2,153 | 2.59375 | 3 | [
"BSD-2-Clause"
] | permissive | from __future__ import print_function
from __future__ import unicode_literals
from __future__ import absolute_import
import os, sys, dispy
# ensure pyeq2 can be imported
if -1 != sys.path[0].find('pyeq2-master'):raise Exception('Please rename git checkout directory from "pyeq2-master" to "pyeq2"')
importDir = os.pat... | true |
6539a2905e18c5e181a902a38582eb78b0677210 | Python | NPRA/image-anonymisation | /src/ImageProcessor.py | UTF-8 | 8,956 | 2.5625 | 3 | [
"MIT"
] | permissive | import os
import time
import multiprocessing
import numpy as np
import config
from src.Logger import LOGGER
from src.Workers import SaveWorker, EXIFWorker, ERROR_RETVAL
from src.io.file_checker import check_all_files_written
from src.io.file_access_guard import wait_until_path_is_found
class ImageProcessor:
"""
... | true |
826ca8fc29fea082361de6e80fc26ddfddd0f25a | Python | mjiharti/mjiharti.github.io | /Python/Harjoituksia/moduuli.py | UTF-8 | 117 | 3.15625 | 3 | [] | no_license | def tulosta(syote):
print("Saatiin syöte: " + syote + "\nSyötteen pituus on " + str(len(syote)) + " merkkiä.") | true |
cd51633ae2600134999425172bf0b396eb578312 | Python | rm3shah/MSCI446Project | /exploratory_analysis.py | UTF-8 | 2,019 | 2.96875 | 3 | [] | no_license | import pandas as pd
import numpy as np
import matplotlib.pyplot as plt
from collections import Counter
import seaborn as sns
sns.set_context('talk')
# Plot Style
plt.style.use(u'ggplot')
# Read in training Data File
df = pd.read_json("../data/train.json")
# Most Common Ingredients
ingr_ind = Counter([ingredient for ... | true |
f7c051acad21121c948f23aff48f07416d81013c | Python | kipoi/kipoi | /example/models/pyt/model_files/pyt.py | UTF-8 | 2,140 | 2.828125 | 3 | [
"MIT"
] | permissive | import torch
import numpy as np
from tqdm import tqdm
class Flatten(torch.nn.Module):
# https://gist.github.com/VoVAllen/5531c78a2d3f1ff3df772038bca37a83
def __init__(self):
super(Flatten, self).__init__()
def forward(self, x):
return x.view(x.size(0), -1)
def get_model():
# N is b... | true |
681b5b6213a97206e3bb421a3774cddb33c20807 | Python | ashishjsharda/AdvancedPython | /transpose5.py | UTF-8 | 178 | 3.3125 | 3 | [] | no_license | '''
Created on Jan 14, 2020
@author: ashish
'''
import numpy as np
a=np.matrix([[1,2],[3,4]])
print("Initial matrix seen is",a)
print("Transposed matrix seen is",a.transpose())
| true |
933a3255039be8ef8f12a2e9b0dd429c862ccb1c | Python | apper2112/api-gui | /api-checker.py | UTF-8 | 5,806 | 2.53125 | 3 | [] | no_license | #!usr/bin/env python
import json
import hashlib
try:
from Tkinter import * # PYTHON 2
import tkFont
from urllib2 import urlopen
except ImportError:
from tkinter import * # PYTHON 3
import tkinter.font as tkFont
from urllib.request import urlopen
class Window(Frame):
'''An api GUI template that is modified fo... | true |
d8a792c5f6229a3eee09d7bdf000703434515797 | Python | swapnil2me/nlODE_Python | /RK4_2dof_without_live_plot.py | UTF-8 | 2,663 | 2.5625 | 3 | [] | no_license | import os
import numpy as np
import matplotlib.pyplot as plt
from scipy.integrate import odeint
from drawnow import drawnow, figure
"""
Function Definations
"""
# Model Defination
def two_dof_cubic(x, t,F0,omg,m,c,k1,k2,a3,a3_12):
x1 = x[1]
x1d = F0 * np.cos(omg * t)/m - c * x[1] / m - k1 * x[0] / m - a3 * x[... | true |
0cc50d94ab3429eacf5c12b002f14a4cdb0a8280 | Python | ausos/EpamPython2019 | /04-OOP/hw/hw_1.py | UTF-8 | 1,770 | 3.921875 | 4 | [] | no_license | import datetime
class Homework():
"""Created when adding new homework"""
__slots__ = ['text', 'deadline', 'created']
def __init__(self, text, days):
self.text = text
self.created = datetime.datetime.now()
self.deadline = datetime.timedelta(days)
def is_active(self):
r... | true |
f9c9370df9ae5c85d4157409634230f52b14f81f | Python | gharib85/QuDiPy | /qudipy/chargestability/csd_analysis.py | UTF-8 | 23,340 | 3.15625 | 3 | [] | no_license | '''
File used to analyze charge stability diagrams in order to produce capacitance matrices, virtual gating, lever arms, etc.
For a good review of the Hough transform, check https://alyssaq.github.io/2014/understanding-hough-transform/.
Hough transfrom code based off of https://github.com/alyssaq/hough_transform.
'''
... | true |
5e7b49d4a918997f871324c2d565e31a41e6d7f3 | Python | nikhil-bhargava/ids-706-fp | /model_resale.py | UTF-8 | 1,828 | 2.71875 | 3 | [
"MIT"
] | permissive | import os
from pathlib import Path
import pandas as pd
import numpy as np
from statsmodels.iolib.smpickle import load_pickle
import statsmodels.formula.api as smf
def predicted_sneaker_resale(form_dict):
repo_path = Path(os.getcwd())
lm = load_pickle(repo_path / "prod-models" / "resale_predictor.pickle")
... | true |
d66d734950ab7274b4f3ced4b1584d00c740719a | Python | fridaysometime/python_studying | /easy_tests/photo_0005.py | UTF-8 | 397 | 2.703125 | 3 | [] | no_license | from PIL import Image
import os
path='pics'
new_path='new_pics'
if not os.path.isdir(new_path):
os.mkdir(new_path)
for i in os.listdir(path):
i_path=os.path.join(path,i)
im=Image.open(i_path)
w,h=im.size
print(w)
print(h)
if((1336/w) >= (640/h)):
n=1336/w
else:
n=640/h
... | true |
5912f108fc9e2a5524524dfc678dc61269cd978c | Python | Rysul119/TemplateMatching | /getTemplate.py | UTF-8 | 3,578 | 2.75 | 3 | [] | no_license | #!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
Created on Sat Feb 27 14:58:03 2021
@author: rysul
"""
import numpy as np
import cv2 as cv
from scipy import signal
import matplotlib.pyplot as plt
def showImage(imgMatrix, name):
cv.imshow(name, imgMatrix)
cv.waitKey(0)
cv.destroyAllWindows()
# reading ... | true |
36b585cb0372c121c7307bb04ecc3a1b220ad0a6 | Python | lasj00/Python_project | /abstract.py | UTF-8 | 917 | 4.34375 | 4 | [] | no_license | from abc import ABC
import math
# by inheriting from ABC, we create an abstract class
class Shape(ABC):
def __init__(self, a=0, b=0):
self._a = a
self._b = b
def get_a(self):
return self._a
def get_b(self):
return self._b
def __str__(self):
return "{0}: [{1},... | true |
c7de319e712abb96299cf1d222766feba308f3fc | Python | LucasDatilioCarderelli/Exercises_CursoemVideo | /Aula 21 - Funções - pt2/Aula21.py | UTF-8 | 1,739 | 4.3125 | 4 | [] | no_license | print() # Ajuda Interativa
# help(input)
# print(input.__doc__)
print() # Ajuda com docstrings
# def contador(i, f, p):
# """
# -> Faz uma contagem e mostra na tela
# :param i: Início da contagem
# :param f: Fim da contagem
# :param p: Passo da contagem
# :return: Sem retorno
# """
... | true |
d05f4194b2360105be462705a4fcd72029277a0d | Python | cultivai/pandemic-disease-classifier | /crop_image.py | UTF-8 | 1,473 | 2.671875 | 3 | [] | no_license | #!/usr/bin/env python
import pathlib
import os
import matplotlib
matplotlib.use('Agg')
import matplotlib.pyplot as plt
import numpy as np
from PIL import Image
from PIL import ImageFile
ImageFile.LOAD_TRUNCATED_IMAGES = True
import time
import pandas as pd
from sklearn.metrics import average_precision_score... | true |
37867aa3cd891ac69e9f8c41b6ace66e01c8a4c1 | Python | eulersformula/Lintcode-LeetCode | /Longest_String_Chain.py | UTF-8 | 3,254 | 3.96875 | 4 | [] | no_license | # Lintcode 257//Leetcode 1048//Medium
# You are given an array of words where each word consists of lowercase English letters.
# wordA is a predecessor of wordB if and only if we can insert exactly one letter anywhere in wordA without changing the order of the other characters to make it equal to wordB.
# For exampl... | true |
af338bb241d6dd8592cba56ef310c2c4ae9a8f7f | Python | hungdoan888/algo_expert | /lowestCommonManager.py | UTF-8 | 1,962 | 3.09375 | 3 | [] | no_license | # -*- coding: utf-8 -*-
"""
Created on Thu Jan 28 20:41:23 2021
@author: hungd
"""
class OrgChart:
def __init__(self, name):
self.name = name
self.directReports = []
def addDirectReports(self, directReports):
for directReport in directReports:
self.directReports.append(dire... | true |
48eb45770cd44f3c7a2aa624268f52cbeeeb73f2 | Python | Programmeringskursen/lander | /stars.py | UTF-8 | 511 | 3.59375 | 4 | [] | no_license | import pygame
import random
class StarField:
white = (255, 255, 255)
stars = []
def __init__(self, screen, n = 100):
self.screen = screen
self.width = screen.get_width()
self.height = screen.get_height()
for i in range(n):
self.stars.append((random.randint(0, s... | true |
172bbddb075b70bf4a799d598f80fbaf2142788d | Python | TWSFar/UnderWater | /deeplab_xception/models/losses/focal_loss.py | UTF-8 | 1,028 | 3.078125 | 3 | [] | no_license | import torch
import torch.nn as nn
class FocalLoss(object):
def __init__(self, alpha=0.5, gamma=2, ignore_index=255, weight=None):
self.alpha = alpha
self.gamma = gamma
self.ignore_index = ignore_index
self.weight = weight
def __call__(self, logit, target):
device = lo... | true |
919edeb1e857c03c730b2650effb82dc5fcd524a | Python | BrianFs04/holbertonschool-web_back_end | /0x00-python_variable_annotations/0-add.py | UTF-8 | 185 | 3.84375 | 4 | [] | no_license | #!/usr/bin/env python3
"""add - Function that calculates the sum of two float numbers"""
def add(a: float, b: float) -> float:
"""Returns: the sum of a and b"""
return(a + b)
| true |
e3543554bd78b878a0c93aca7816a692065679d3 | Python | Alondg/python_digital | /Lesson 1/targil1.py | UTF-8 | 92 | 3.515625 | 4 | [] | no_license |
name="sergey jhon"
age=28
print("hello " + name + "\nHow are you?\nYour age is: " + str(age))
| true |
5eaf14264bb5ab55148886ce8259f45e94785ede | Python | BlackVegetable/network-debugger | /engine.py | UTF-8 | 6,151 | 2.859375 | 3 | [] | no_license | # DSM Engine
class Engine:
def __init__(self):
self.stacktrace = []
self.arguments = []
self.next_function = initial_state00
self.current_of_rules = set(self.get_initial_rules())
def combine_of_rules(self, of_rules_list):
'''Combines a list of OF rules into an exist... | true |
871849a60cc08f68b8f1fe82ad54e69d89756df8 | Python | kookmin-sw/2019-cap1-2019_1 | /src/ServercodeTest/StoreLogic/NodeStoreLogic.py | UTF-8 | 11,088 | 2.828125 | 3 | [] | no_license | import os
import sys
sys.path.append(os.path.dirname(os.path.abspath(os.path.dirname(__file__))))
from Database.DatabaseInstance import db
from Database.DatabaseInstance import con
from Domain.Node import Node
class NodeStoreLogic:
def selectAllNodes(self):
db.execute('SELECT node_id,node_type,node_name... | true |
7d94e202f23c6fe842db18e6bd9bc434a7597d39 | Python | wuyuz/The-application-of-python | /jisuan/new_cal.py | UTF-8 | 1,788 | 3.359375 | 3 | [] | no_license | # import numpy as np
#
# # a = np.array([[1,-1],[-1,1]])
# a = np.array([[1,-1,0,0,0,0],[-1,2,-1,0,0,0],[0,-1,2,-1,0,0],[0,0,-1,2,-1,0],[0,0,0,-1,2,-1],[0,0,0,0,-1,1]])
# b = np.linalg.eig(a)
# # print(b[0])
#
# q = np.poly1d(b[0],True)
# print(q)
from numpy import roots,poly1d,array,linalg
from tkinter imp... | true |
0858c7fae5e6e2b809757ae5be90cbd8657adb9b | Python | woodywang153/CS221_Final_Project | /linRegBase.py | UTF-8 | 2,046 | 3.390625 | 3 | [] | no_license | import numpy as np
import tensorflow as tf
import pandas as pd
from gloveProject import loadWordVectors
glove = loadWordVectors()
def initialize_parameters(vector_dim = 50):
w = np.random.randn(vector_dim, 1).reshape(-1,1)
b = 0.0
return w, b
def forward_propagate(inputs, weights, bias):
score = inputs.T.dot(wei... | true |
f67dc591f19e022aa8247f5f16f8e3f9bc360c5d | Python | alexbclay/seismoled | /led_modules/module_base.py | UTF-8 | 806 | 3.078125 | 3 | [] | no_license | #!/usr/bin/env python
import random
class LedActionModule:
def __init__(self, length):
self.length = length
# any other self vars?
pass
def trigger(self):
''' Something happened, return a list of colors to write to the leds'''
pass
def time_step(self):
''' ... | true |
17cf201848807a563485b40ab56b6150b3898958 | Python | urishabh12/practice | /387B.py | UTF-8 | 211 | 2.984375 | 3 | [] | no_license | n, m = map(int, input().split())
nc = list(map(int, input().split()))
mc = list(map(int, input().split()))
i1 = 0
i2 = 0
while i1 < n and i2 < m:
if nc[i1] <= mc[i2]:
i1 += 1
i2 += 1
print(n-i1)
| true |
4560118b2a04e7754ce98fb9bad48bbe4b1956f7 | Python | fatelei/im-demo | /imdemo/apis/handlers/thread.py | UTF-8 | 2,913 | 2.671875 | 3 | [] | no_license | # -*- coding: utf8 -*-
"""
imdemo.apis.handlers.chat
~~~~~~~~~~~~~~~~~~~~~~~~~
Chat http apis.
"""
__all__ = ["thread_app"]
from flask import Blueprint, request, jsonify
from imdemo import models
thread_app = Blueprint("thread",
__name__)
@thread_app.route("/inbox", methods=["G... | true |
0444549b99b0ab9bcaf2701164a70dbdc2b6a424 | Python | Raveena-91/Twitter-Sentiment-Analysis | /DataClean.py | UTF-8 | 2,453 | 2.84375 | 3 | [] | no_license | from textblob import TextBlob
import tweepy
import csv
import pandas as pd
from bs4 import BeautifulSoup
from nltk.tokenize import WordPunctTokenizer
import regex as re
import lxml
tok = WordPunctTokenizer()
pat1 = r'@[A-Za-z0-9]+'
pat2 = r'https?://[A-Za-z0-9./]+'
combined_pat = r'|'.join((pat1, pat2))
df = pd.read_cs... | true |
44a0335b91b625fa9954607f3c4c1075f2293234 | Python | ironboundsoftware/ironboundsoftware | /SatId/src/SatId/SGP4.py | UTF-8 | 2,430 | 2.96875 | 3 | [] | no_license | #!/usr/bin/env python
# encoding: utf-8
"""
SGP4.py
This version of the SGP4 code is based on the updated code released
by the AIAA paper of 2006.
Created by Nick Loadholtes on 04/05/2010.
Copyright (c) 2010 Iron Bound Software. All rights reserved.
"""
import sys
import os
import unittest
from math import sqrt
WGS... | true |
60598c83c2ef03e3308b4f2a132a43ac726fc869 | Python | rdhanurkar/dsbox-ta2 | /python/dsbox/template/template_hyperparams.py | UTF-8 | 4,608 | 3.265625 | 3 | [
"MIT"
] | permissive | import abc
import typing
import numpy as np
import numpy.random as random
from numpy.random import RandomState
T = typing.TypeVar('T')
class Hyperparam(typing.Generic[T]):
def __init__(self, default: T):
self._default = default
def default(self) -> T:
return self._default
@abc.abstrac... | true |
1c9361d6734c917f36458da305abdc1d66f818c3 | Python | hichem2h/flask-sse-scores | /flask-sse-backend/scores/models.py | UTF-8 | 504 | 3.15625 | 3 | [] | no_license |
class Score:
def __init__(self, id, team1, team2, score):
self.id = id
self.team1 = team1
self.team2 = team2
self.score = score
def __str__(self):
return f'{self.team1} = {self.score} = {self.team2}'
class ScoreEvent:
def __init__(self, score):
self.sco... | true |
334cc0824e04815e608c9b738a4d52e146e0dfd9 | Python | abidas1/adventOfCode | /solutions/day3.py | UTF-8 | 1,122 | 3.203125 | 3 | [] | no_license | import requests
url = 'https://adventofcode.com/2020/day/3/input'
headers = {
'Cookie': '',
'Accept': 'text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8',
'Accept-Encoding': 'br, gzip, deflate',
'Host': 'adventofcode.com',
'User-Agent': 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_13_6)... | true |
90e46ace8d9d123e6ec71ffed6c671c7561dfbff | Python | Aasthaengg/IBMdataset | /Python_codes/p03273/s555397948.py | UTF-8 | 423 | 2.984375 | 3 | [] | no_license | import numpy as np
H, W = map(int, input().split())
x = [list(map(str, list(input()))) for l in range(H)]
y = []
for i in range(H):
if set(x[i]) != {"."}:
y.append(x[i])
z = np.array(y)
zz = np.rot90(z)
zzz = zz.tolist()
ans = []
for i in range(W):
if set(zzz[i]) != {"."}:
ans.append(zzz[i])
... | true |
c8851e60f172f08284017d0e7a5e5be8e12d35d1 | Python | Allen-Lee-Junior/ex-em-python | /EX.py/EX004.py | UTF-8 | 362 | 4.28125 | 4 | [
"MIT"
] | permissive | n = input('Digite alguma coisa:')
print('o tipo primitivo desse valor é', type(n, ))
print('so tem espaço?', n.isspace())
print('É um numero?', n.isnumeric())
print('É alfabetico?', n.isalpha())
print('É alfanumerico?', n.isalnum())
print('Ésta em maisculas?', n.isupper())
print('esta em minusculas?', n.islower())
prin... | true |
d39dd53e985b81dccdc4a66fbb50d3a4bba6feb5 | Python | edoric/test | /mtime.py | UTF-8 | 557 | 3.046875 | 3 | [] | no_license | #! /usr/bin/env python
# -*- coding: utf-8 -*-
import time
class mtime(object) :
def __init__(self):
self.start = time.time()
print 'start...'
def end(self):
self.end = time.time()
print "...stop!"
def tprint(self):
self.process = self.end - self.start
self.h... | true |
a06a564fb4bdaa2ede286bb430847bacd9a0dcf3 | Python | dangerousMoron/card_game | /fire_conversion.py | UTF-8 | 592 | 2.859375 | 3 | [] | no_license | #!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
Created on Thu May 7 20:06:14 2020
@author: tfinney
"""
import pint
u = pint.UnitRegistry()
inten = 1*u.Btu/(u.ft*u.s)
# print())
m_inten = inten.to(u.kW/u.m)
print(m_inten)
test = 1 * u.kW/u.m
print(test.to(u.Btu/(u.ft*u.s)))
dist = 1*u.ft
print(dist.to(u.... | true |
3eba6a16c0f90bf944546320d8d9a201cdd26e50 | Python | RocketRider/chess | /chessgame/main/figure.py | UTF-8 | 1,112 | 4 | 4 | [] | no_license | """Figure base class for the chess game
"""
class Figure:
"""Figure base class for the chess game
"""
def __init__(self, pos_x, pos_y, color):
"""
Arguments:
pos_x {int} -- start pos of pwan
pos_y {int} -- start pos of pwan
color {String} -- COLOR_BLACK... | true |
4833d539fbae98358ed1188f7c1d24ec74061320 | Python | awwilliams/tconfig | /tconfig/core/algorithms/recursive/intmod.py | UTF-8 | 2,860 | 3.671875 | 4 | [
"MIT"
] | permissive | """
Created on Sep 16, 2017
@author: Alan Williams
"""
from typing import Union, Optional
class IntMod(object):
modulus = 0
def __init__(self, value: Union[int, "IntMod"] = 0):
self.value = value if IntMod.modulus == 0 else value % IntMod.modulus
def __str__(self) -> str:
return str(se... | true |
033c6e6bcba33d666da8504b9930b66e9e3f8609 | Python | jingpu/vision_core | /pylib/dpda2c.py | UTF-8 | 15,304 | 2.96875 | 3 | [] | no_license | #! /usr/bin/python
# Compile a chunk of bit-width-specified DPDA into C code which simulates
# its operation.
import sys
from dpdadag import expand_range
from dpdadag import parse_dpda
class CodeWriter:
"""
Little class that makes it easy to pretty-print code to a file or to stdout.
"""
def __init__(self, f... | true |
d075bfb3363478605e1639a2fa4003de8583749b | Python | reinderien/advent | /2017/19/19.py | UTF-8 | 780 | 3.1875 | 3 | [] | no_license | #!/usr/bin/env python3
from itertools import count
def run(fname):
with open(fname) as f:
lines = tuple(f)
deltas = ((0, 1), ( 1,0),
(0,-1), (-1,0))
old_dir_i = 0
coord = (lines[0].find('|'), 0)
found = ''
for steps in count(1):
xo, yo = coord
dirs = ((... | true |
3ed0f408e64823a40d744a0ec0e0471d65ef2c64 | Python | sourav731/BostonHousingPrediction | /boston.py | UTF-8 | 8,072 | 3.53125 | 4 | [] | no_license | import os #to bring operating system functionalities so to join and get file paths
import tarfile #to extract tar files accessed from web
from six.moves import urllib #to get python3 and python2 features combined
import pandas as pd #for data analysis
%matplotlib inline
import matplotlib.pyplot as plt #for data visual... | true |
ff4f0ba47fd0c8386dfaa85e52b2053058c9cf9e | Python | gade008/estudos_python | /cursoemvideo/aula17pt2.py | UTF-8 | 593 | 3.78125 | 4 | [] | no_license | pessoas = list()
dados = list()
totmai = totmen = 0
for c in range(0, 3):
dados.append(str(input('Digite seu nome: ')).lower().capitalize())
dados.append(int(input('Digite sua idade: ')))
pessoas.append(dados[:])
# Importante não esquecer o [:] pois ele cria uma copia da entrada de dados
dados.clear... | true |
8d77d135c22e5483f86b6be25548ab649f9e4615 | Python | 5l1v3r1/wqcmsexp | /结果检测.py | UTF-8 | 941 | 2.59375 | 3 | [] | no_license | import os,urllib2,time
jieguo=[]
def saveListToFile(file,list):
"""
:return:
"""
s = '\n'.join(list)
with open(file,'a') as output:
output.write(s)
def zhengli():
fp=open("jieguo.txt", "r")
alllines=fp.readlines()
fp.close()
for eachline in alllines:
eachlin... | true |
fbc32e7e78267f008f6afdbc06763e2700b05e9f | Python | YudinYury/Question_by_HackerRank | /test_Regex_and_Parsing_HTML.py | UTF-8 | 3,825 | 2.703125 | 3 | [
"Apache-2.0"
] | permissive | ''' Here I continue to try a unittest
'''
import unittest
from unittest.mock import patch
# from collections import deque
from Regex_and_Parsing_HTML import MyHTMLParser
class TestMyHTMLParser(unittest.TestCase):
# @classmethod
# @patch("socket.create_connection", ServerSocket.create_connection)
# @pat... | true |
6d68e481e815213b0052b90f68b3f35f23769df6 | Python | ronniegeiger/Abaqus_scripts-10 | /FEM_Coursework/Fem_3d_quarter_symm.py | UTF-8 | 10,262 | 3.109375 | 3 | [] | no_license | # FE analyses of a plate with a hole
# The first three lines are required to import the required ABAQUS modules and create references to the objects that are
# defined by the module. The second line means that you are importing the symbolic constants (variables with a constant
# value) that have been defined by th... | true |
2afc86e680be8e225d568dd74cc852acf0db69cb | Python | somoye123/Python-Is-Easy | /SetsDictionaries.py | UTF-8 | 439 | 3.296875 | 3 | [] | no_license | # Sets = {"Element1","Element2","Element1","Element4"}
# CountryDictionary = {'france':1, 'nigeria':2}
BlackShoes = {42:2,41:3,40:4,39:1,38:0}
print(BlackShoes)
while(True):
purchaseSize = int(input("Which shoe size would you like to buy?\n"))
if purchaseSize < 0:
break
if BlackShoes[purchaseSize] ... | true |
cdf47dbc308d44d161229e30abda59d8a5e5122c | Python | webcoffee-net/scraper_goal_data | /box.py | UTF-8 | 1,269 | 2.734375 | 3 | [] | no_license | import lxml.html
class Box:
def __init__(self, page_source, id_box):
self.page_source = page_source
self.id_box = id_box
xpath_text_title_box = "//div[@class='main-content']//div[@class='competition-matches' and @data-competition-id='{}']//div[@class='competition-name']//text()".format(id... | true |
9219fec726d71c657c0f6203e38fcf3c1902bc67 | Python | Adarsh0047/Object-Oritented-Programming | /Oops/user_defined_exception.py | UTF-8 | 106 | 3.46875 | 3 | [] | no_license | y=input("Please enter a positive number: \n")
if int(y) <=0:
raise ValueError("Negative Number")
| true |
ef1bb95beac7bf0ad1ac849bb1c7b6ac065daf56 | Python | maurop13/Data_Analytics_Bootcamp_Repo | /Week_3_Python/PyPoll/main.py | UTF-8 | 2,031 | 2.8125 | 3 | [] | no_license | import csv
from decimal import Decimal
totalNumberVotes = 0
voteCounter = 0
totalCandidates =[]
listOfCandidates = []
listOfVotesperCandidate = []
percentagesOfVotesperCandidate = []
candidateWon = ""
main_Data = "Resources/election_data.csv"
with open(main_Data, 'r') as csvfile:
csvreader = csv.reader(csvfile, de... | true |
520625ae305b6e9ed765f8651994a9634f6524e2 | Python | Manuel2311/Python_Server | /server.py | UTF-8 | 3,507 | 2.9375 | 3 | [] | no_license | import argparse
from flask import Flask, request, render_template, Response
from random import choice
from jupiter_flys import generate_seed, jupiter_flys
from user import User
import requests
app = Flask(__name__)
@app.route("/index.html")
def index():
return "This is a python server. It is awesome."
@app.rou... | true |
ba3bf42ef4972525479da95a41a08971ae2c7fe4 | Python | FloreU/MobileData | /field_summarize.py | UTF-8 | 3,603 | 2.546875 | 3 | [] | no_license | # -*- coding: UTF-8 -*-
import math
import arcgisHelper as ah
from arcgisHelper import SummaryGrid
director_span = 2 * math.pi / 16.0
# wg_shp_name = "POINTS" # 格网点(grid_id 、PX、PY)网格汇总层次
# qx_shp_name = "BOUND_17" # 区县级别数据,面数据 (SSQ 名称、QBM 编码)区县汇总层次
# jd_shp_name = "BOUND_191" # 街道级别数据,面数据 (SSJ 名称、JBM 编码)街道汇总层次
de... | true |
716d5708a49258101b9a84a6f42602aa3c99c3ee | Python | manuelmarcano22/tmuxmlbbar | /movebar.py | UTF-8 | 1,105 | 2.84375 | 3 | [] | no_license | from random import random
from sys import stdout
from time import sleep
import os
class A:
def __init__(self,pos,char):
self.pos=pos
self.char=str(char)
def move(self):
self.pos+= -1
# if self.pos==-1: self.pos=49
# elif self.pos==50: self.pos=0
text = '!Msdfafasdfa fdas... | true |
95c7960451229813e7fabaa75bdb40ed996ee2de | Python | avinashnkbio/fullstackpython | /xlrde.py | UTF-8 | 913 | 2.859375 | 3 | [] | no_license | import xlwt
from datetime import datetime
style0 = xlwt.easyxf('font: name Times New Roman, color-index red, bold on',
num_format_str='#,##0.00')
style1 = xlwt.easyxf(num_format_str='D-MMM-YY')
wb = xlwt.Workbook()
ws = wb.add_sheet('A Test Sheet')
style = xlwt.XFStyle()
style.alignment.wrap = 1
... | true |
d2fdddb9967037869d65f92edf0a93c4a1717c6f | Python | jack-alexander-ie/data-structures-algos | /Topics/2. Data Structures/Recursion/recursion.py | UTF-8 | 2,728 | 4.96875 | 5 | [] | no_license |
def sum_integers(n):
"""
Each function waits on the function it called to complete.
e.g. sum_integers(5)
The function sum_integers(1) will return 1, then feedback:
sum_integers(2) returns 2 + 1
sum_integers(3) returns 3 + 3
sum_integers(4) returns 4 ... | true |
6fc6b8f5d946af3e8abcdc1f7c369f7238b4018d | Python | daniel-zm-fang/High-school | /Contest Problems/Python/Others/CCCHK '15 J3 - Queens can't attack me!.py | UTF-8 | 793 | 2.921875 | 3 | [] | no_license | n, m = [int(x) for x in input().split()]
board = [[0] * n for x in range(n)]
for i in range(m):
x, y = [int(x) - 1 for x in input().split()]
xydiff = x - y
xygap = xydiff
for row in range(n):
if row == x:
board[row] = [1] * n
continue
for col in range(n):
... | true |
c3ba88058f0459e9373ed14906118625921d0ff6 | Python | RebeccaWPerry/python_seam_carving | /seamcarving.py | UTF-8 | 4,254 | 3.28125 | 3 | [] | no_license | """ Seam carving functions
Written for seam carving workshop -- functions to
find and remove vertical seams.
author: Rebecca Perry
"""
import random
import numpy as np
def findseam(image):
"""Find a seam running from top to bottom of image
image: color or grayscale image to remove seam from
"""
... | true |
07c8fa4c6f792e4edc882763e2448da4cc8873e5 | Python | neysene/project-euler | /src/pe0023.py | UTF-8 | 732 | 3.453125 | 3 | [] | no_license | # takes around 3.5 sec
# i wrote algorithms for finding divisors and abundants
# but they took much more time than brute force
# (i facepalmed myself)
def brute_force():
a = []
for i in xrange(12, 28123):
t = set([1])
s = int(i**0.5) + 1
for j in xrange(2, s):
if i%j == 0:
... | true |
94186b719dbf362231fe7b38d798f57d8527109a | Python | egyptnetriders/DevNet-Course-B2-Test | /1- Variables.py | UTF-8 | 1,108 | 2.6875 | 3 | [] | no_license | # name = "ahmed"
# print(name.capitalize())
# print(name.upper())
# print(name.lower())
#
#
# print(Routers)
# # print(Routers[0])
# # print(Routers[2])
#
# Routers.pop()
# print(Routers)
# Routers = ["192.168.1.1", "192.168.2.1", ["1.1.1.1", "2.2.2.2"]]
#
#
# print(Routers[2][0])
# ssh_information = {
# "ip": "1... | true |
f7fd854b45d6aea7c8fb3c14110542f1c0f92c0d | Python | sudhanshuchopra/quizsite | /questions/forms.py | UTF-8 | 3,544 | 2.578125 | 3 | [] | no_license | from django import forms
from .models import Question
from .models import Choice
import random
class QuestionForm(forms.Form):
question=forms.CharField(max_length=1000)
choice1=forms.CharField(max_length=200)
choice2=forms.CharField(max_length=200)
choice3=forms.CharField(max_length=200)
choice4=forms.CharField(m... | true |
17724e85e41e729be14b0fb5b66a6b3fe06c4448 | Python | siowchenying/ROS-SchoolProject-MA4825 | /listener.py | UTF-8 | 8,385 | 2.578125 | 3 | [] | no_license | #!/usr/bin/env python
import rospy
import dynamixel_driver
from dynamixel_driver import dynamixel_io
from dynamixel_driver import dynamixel_const
from dynamixel_driver import dynamixel_serial_proxy
from std_msgs.msg import String
from std_msgs.msg import Int16
from std_msgs.msg import Float32
from beginner_tutorials... | true |
801fac648a9573f7f22ca9d946dad6d7b183da24 | Python | kaka20180511/Work | /Fault_Diagnosis/fault_diagnosis20180601V2/fault_diagnosis0531V1/functionpy/pod_speed.py | UTF-8 | 815 | 2.6875 | 3 | [] | no_license | # ===============================
# 功能:解析车辆托盘角度数据并返回给主
# 函数(正常帧为托盘数据、特殊帧为电量
# 数据)
# 2018/05/31 lsl
# ===============================
# ===============================
# 功能:解析正常帧(托盘角度podspeed)
# 28-32字段
def PodAngle(data):
try:
AGV_PodAngle = data[28:32] # 截取车辆托盘角度字段
AGV_PodAngle = int(AGV_PodAngl... | true |
0b70eb778e3ed0450e786b476e6026fe98a08783 | Python | FlorentBerthet/Python-notes | /Python-tutorial-for-beginners-(Corey-Schafer).py | UTF-8 | 9,340 | 4.59375 | 5 | [] | no_license |
# Python Tutorial for beginners (Corey Schafer)
# 2. Strings - Working with Textual data
# https://www.youtube.com/watch?v=k9TUPpGqYTo&list=PL-osiE80TeTskrapNbzXhwoFUiLCjGgY7&index=2
message = 'Hello World'
print (message[10])
-> d
print (message[:5])
-> Hello
print (message.upper())
-> HELLO WORLD
print (me... | true |
ed20b916d22767b22b445b1c79482a429d6adab9 | Python | yalcindavid/instacard | /main.py | UTF-8 | 1,841 | 2.53125 | 3 | [] | no_license | import pandas as pd
import numpy as np
from numpy import array
from data import one_hot_post_padding
# from data import build_clients_sequences
from keras.preprocessing.sequence import pad_sequences
from sklearn.preprocessing import LabelEncoder
from sklearn.preprocessing import OneHotEncoder
from data import r... | true |
4d38db8a9c37d0edf7e04723239ba378272d8b70 | Python | lim-jonguk/ICE_HW6 | /임종욱_8.py | UTF-8 | 608 | 3.875 | 4 | [] | no_license | #8번 C111152 임종욱
# 리스트의 가장큰원소를 구하고 그것을 제외한 리스트를 만드는 함수
def getMax(lst):
# 가장 큰 원소의 위치
i =lst.index((max(lst)))
#pop메소드로 가장큰 원소를 반환하고 삭제함
M = lst.pop(i)
return M,lst
#리스트를 크기순으로 나열하는 함수, getMax이용
def mySort(lst):
M_lst =[]
while lst != []:
m,lst = getMax(lst)
... | true |
1daee2dddcc011b14d5dba78e073140167380345 | Python | mgallegos13/Codewars_Exercises | /Python/Even or Odd - Which is Greater?/solution.py | UTF-8 | 612 | 4.3125 | 4 | [] | no_license | def even_or_odd(s):
#split and convert string to intergers
a_list = list(s)
map_object = map(int, a_list)
list_of_integers = list(map_object)
#even and odd variables
evens = 0
odds = 0
#traverse thru list and adde them to count
for i in list_of_integers:
if i %... | true |
6fd85d37b1959566be4005a6b8609b287869928a | Python | GRIDAPPSD/Powergrid-Models | /archive/houses/insertHouses.py | UTF-8 | 12,443 | 2.578125 | 3 | [] | no_license | '''
Module to extract EnergyConsumers from the CIM database and replace loads with
houses, HVAC systems, and plug loads. We may also want water heaters.
Created on Jun 1, 2018
@author: thay838
'''
#******************************************************************************
# IMPORTS + PATH
#***********************... | true |
ccf5a719ca28a8716aac06a6ae57d1c5c8b74bcb | Python | cseelye/sfauto | /account_create.py | UTF-8 | 3,181 | 2.65625 | 3 | [
"MIT"
] | permissive | #!/usr/bin/env python
"""
This action will create a CHAP account on the cluster
"""
from libsf.apputil import PythonApp
from libsf.argutil import SFArgumentParser, GetFirstLine, SFArgFormatter
from libsf.logutil import GetLogger, logargs
from libsf.sfcluster import SFCluster
from libsf.util import ValidateAndDefault,... | true |
a3cbf2e7995caf8805f973bd6618a9c8e76710f8 | Python | dghuman/uni | /Uni/Queens/PHYS_825/Assignment_1/Assignment_1_5b.py | UTF-8 | 1,093 | 3.34375 | 3 | [] | no_license | # Python script to plot some functions from Q5 (b) on Assignment 1
import cmath
import matplotlib.pyplot as plt
N = 100.
omega_0 = 0.5
sigma = 0.1
C_t = []
cn_t = []
t = range(1, 101, 1)
def c_n(n):
omega_n = n/N
return cmath.exp(-(omega_n - omega_0)*(omega_n - omega_0)/(sigma*sigma))
A = 0
for i in ... | true |
2369c75889016b0311d6ecdc4b4a65dfb80bf75c | Python | ishiland/python-geoclient | /tests/mock_responses.py | UTF-8 | 2,419 | 2.53125 | 3 | [
"BSD-3-Clause"
] | permissive | # Slimmed down mock responses from the Geoclient API
address_response = {
u'address': {u'bblBoroughCode': u'1', u'boePreferredStreetName': u'WORTH STREET', u'houseNumber': u'125',
u'geosupportReturnCode': u'00'}
}
address_zip_response = {
u'address': {u'boePreferredStreetName': u'WORTH STREET... | true |
5571c5ee5727245605444f729dc1fb06f894f41b | Python | amrutha1352/ammu_321910304040 | /prime.py | UTF-8 | 154 | 3.578125 | 4 | [] | no_license | c=0
x=int(input("enter the number:"))
z=x
for i in range(2,x):
y=x%2
if(y==0):
c=c+1
if(c>0):
print(z,"is not a prime")
else:
print(z,"is a prime") | true |
20ce3108548b99d85b1f8a0ffde9ae55bc8e34cb | Python | vanderson-henrique/trybe-exercises | /COMPUTER-SCIENCE/BLOCO_35/35_2/conteudo/escreve_e_le_lista.py | UTF-8 | 349 | 3.625 | 4 | [] | no_license | # escrita
file = open("arquivo.txt", mode="w")
LINES = ["Olá\n", "mundo\n", "belo\n", "do\n", "Python\n"]
file.writelines(LINES)
file.close()
# leitura
file = open("arquivo.txt", mode="r")
for line in file:
print(line) # não esqueça que a quebra de linha também é um caractere da
file.close() # não podemos esquec... | true |
d7e7a88a29e0ef06ac2787f3cb0cd66961bfde01 | Python | Nagomez97/CTF | /PWN/Heap/UseAfterFree/rhme3/solver.py | UTF-8 | 5,411 | 2.8125 | 3 | [] | no_license | from pwn import *
BINARY = './main_patched.elf'
LIBC = './libc.so.6'
LD = './ld-2.23.so'
DEBUG = False
def alloc(name, attack = 1,
defense = 2, speed = 3, precision = 4):
p.recvuntil('choice: ')
p.sendline('1')
p.recvuntil('name: ')
p.sendline(name)
p.recvuntil('points: ')
p.sendline(str(attack))
p.r... | true |
ba59e3a682b50d758d6615bc598e779913c49370 | Python | ashkanM7/web-scraping | /silkdeals/silkdeals/spiders/example.py | UTF-8 | 851 | 2.515625 | 3 | [] | no_license | # -*- coding: utf-8 -*-
import scrapy
from scrapy_selenium import SeleniumRequest
from selenium.webdriver.common.keys import Keys
class ExampleSpider(scrapy.Spider):
name = 'example'
def start_request(self):
yield SeleniumRequest(
url = 'https://duckduckgo.com',
wait_time = ... | true |
4cda0f9263fec60d1f4224c8890e886dec5aa78c | Python | divyanarra0/pythonprogram | /p43.py | UTF-8 | 86 | 2.734375 | 3 | [] | no_license | N11,M11=raw_input().split(' ')
if(M11 in N11):
print('yes')
else:
print('no')
| true |
d8f048c8622e3283f049dd9b4bcc95e9f28087a6 | Python | dimekai/Network-Services-Administration | /Practica 01/createRDD.py | UTF-8 | 1,131 | 2.53125 | 3 | [] | no_license | import rrdtool
time_step = '60'
time_start = 'N'
type_data = ":COUNTER"
variables = [":inoctets", ":outoctets"]
limits = ":U:U"
properties = [":AVERAGE", ":MIN", ":MAX"]
valid_porcentage = [":1.0", ":0.75", ":0.5", ":0.25"]
num_steps = [":6", ":1"]
num_rows = ":600" #Lenght of Round Robin File
... | true |
692b427df9598aceba85f12ca11268f59c14fb09 | Python | haptikfeedback/PDX_Code_Guild | /basic/lab23_adventure_game.py | UTF-8 | 1,105 | 3.921875 | 4 | [] | no_license | # LAB: ADVENTURE GAME
from random import randint
class Creature:
def __init__(self, name, location, health, weapon=None):
self.name = name
self.location = location
self.health = health
if not weapon:
self.weapon = Weapon(None, randint(1, 15))
else:
s... | true |
7955c667448545bd98185fecec2a039248d72ffe | Python | PatrickLamoureux01/COMP472-A1 | /472_Assignment1_40105663_40113012/Part1/main.py | UTF-8 | 9,829 | 2.90625 | 3 | [] | no_license | import numpy as np
import matplotlib.pyplot as plt
import os
import sklearn as sk
import re
from sklearn import datasets
from sklearn.feature_extraction.text import CountVectorizer
from sklearn.model_selection import train_test_split
from sklearn.naive_bayes import MultinomialNB
from sklearn.metrics import con... | true |
627f16727dbba8f8c71d66279ee52ccee235f9f4 | Python | lovung/HyperNode-VoiceCommander | /utils/logger/logger.py | UTF-8 | 1,202 | 2.53125 | 3 | [] | no_license | import multiprocessing
import logging
import logging.handlers
def loggingConfigurer():
root = logging.getLogger()
h = logging.handlers.RotatingFileHandler('log/testLogging.log', 'a', 10*1024*1024, 10)
f = logging.Formatter('%(asctime)s %(name)-15s %(levelname)-8s %(message)s')
h.setFormatter(f)... | true |
c32bf1b9e4f0239746608b6dd04f1b1fd43405ca | Python | jiadaizhao/LeetCode | /0201-0300/0265-Paint House II/0265-Paint House II.py | UTF-8 | 810 | 2.828125 | 3 | [
"MIT"
] | permissive | class Solution:
def minCostII(self, costs: List[List[int]]) -> int:
if not costs:
return 0
min1 = min2 = -1
for i in range(len(costs)):
currMin1 = currMin2 = -1
for j in range(len(costs[i])):
if j != min1:
if i ... | true |
35377325f01d9ad706c5241f4c8298e56884c8ab | Python | loribeiro/MeuPolitico | /Code/grafo/get_dep_data/deputados.py | UTF-8 | 4,544 | 2.875 | 3 | [
"MIT"
] | permissive | from . import connecting_api
import pickle
import os
rest_of_url1 = "/deputados"
rest_of_url2 = "/deputados/{id}"
rest_of_url3 = "/deputados/{id}/despesas"
rest_of_url4 = "/deputados/{id}/frentes"
rest_of_url5 = "/deputados/{id}/orgaos"
class Deputado:
def __init__(self,**kwargs):
self.id = kwargs["kwargs... | true |
3837210931cbf836ea23f3ba585b34511d60639a | Python | Sh-wayz/enhancedcontainers | /tests/dicttest.py | UTF-8 | 518 | 2.828125 | 3 | [
"MIT"
] | permissive | import unittest
import enhancedcontainers as ec
class DictTest(unittest.TestCase):
def setUp(self):
self.edict = ec.EnhancedDict({"test": "test"})
pass
def test_dot_access(self):
self.assertIsNotNone(self.edict.test)
self.assertEqual(self.edict.test, "test")
def test_dee... | true |
db246fcf74df442b1e9e4ab7b0f76943e6a0fb5b | Python | adaptive-learning/flocs-core | /flocs/utils/names.py | UTF-8 | 1,084 | 3.4375 | 3 | [] | no_license | """ Conversion between various naming conventions
"""
from functools import singledispatch
import re
@singledispatch
def camel_to_snake_case(name):
partially_underscored = re.sub('(.)([A-Z][a-z]+)', r'\1_\2', name)
fully_underscored = re.sub('([a-z0-9])([A-Z])', r'\1_\2', partially_underscored)
return full... | true |
a4786ca5da22c721bf25cf167a370ee2dd1edb3e | Python | lorishui/cppite | /src/py/cppite.py | UTF-8 | 5,439 | 2.53125 | 3 | [
"MIT"
] | permissive | #!/usr/bin/env python
# -*- coding:utf-8 -*-
########################################################
# ITE command start with: #//
# ITE command keywords:quit,exit,byebye,bye, begin, end,
# verbose, concise, dump_project, dump_make_file, dump_cpp,
# dump_fragment,load_fragment, compile, run, edit
#
##################... | true |
4c82fdb09a37db475e1fef5744128b28c317c916 | Python | Gathondu/Amity | /tests/test_room.py | UTF-8 | 910 | 2.796875 | 3 | [] | no_license | #!/usr/local/bin/python3
# -*- coding: utf-8 -*-
import pytest
from model.room import Office, LivingSpace
@pytest.fixture(scope='module')
def office():
return Office('valhalla')
@pytest.fixture(scope='module')
def livingspace():
return LivingSpace('dojo')
def test_room_name_is_correct(office, livingspace... | true |
4d5b35ac144c1c5591e68eeaf1408db6ff3253e2 | Python | HeDefine/LeetCodePractice | /Q74.搜索二维矩阵.py | UTF-8 | 1,528 | 4.3125 | 4 | [] | no_license | #!/usr/bin/env python3
# https://leetcode-cn.com/problems/search-a-2d-matrix
# 编写一个高效的算法来判断 m x n 矩阵中,是否存在一个目标值。该矩阵具有如下特性:
# 每行中的整数从左到右按升序排列。
# 每行的第一个整数大于前一行的最后一个整数。
class Solution:
def searchMatrix(self, matrix: [[int]], target: int) -> bool:
rowLst = 0
rowRst = len(matrix) - 1
if rowLst ... | true |
a2fd3d67366d50ae3fc3236aae5e50c589c6e7f2 | Python | andysitu/algo-problems | /leetcode/100/3_longest_substring.py | UTF-8 | 546 | 2.75 | 3 | [] | no_license | class Solution:
def lengthOfLongestSubstring(self, s: str) -> int:
cdict = {}
maxcount = 0
count = 0
slen = len(s)
prev_i = 0
for i in range(slen):
c = s[i]
if not c in cdict:
count += 1
cdict[c] = i
... | true |
65827872580305fa4bea06ce6a90af1842df491d | Python | amsks/RL-Experiements | /Acrobot-SARSA/acrobot.py | UTF-8 | 2,631 | 3.109375 | 3 | [
"MIT"
] | permissive | '''
State Space :
[cos(theta1)
sin(theta1)
cos(theta2)
sin(theta2)
thetaDot1
thetaDot2
]
Action space : 0, 1, 2 Torques
Rewards : -1 everywhere, 0 to goal
'''
import numpy as np
import gym
import matplotlib.pyplot as plt
import pickle
theta_space = np.linspace(-1, +1, 10)
theta_dot_s... | true |
dc17c6608ac679e4a58f8e023b10d9678d8eadde | Python | halfendt/Codewars | /7_kyu/complete_pattern.py | UTF-8 | 186 | 3.046875 | 3 | [] | no_license | def pattern(n):
"""
Complete The Pattern #1 Kata
https://www.codewars.com/kata/5572f7c346eb58ae9c000047
"""
return '\n'.join([str(num)*num for num in range(1, n+1)]) | true |
b74ab39d6a6ec600611e1585fa1557db8a99bffd | Python | crisla/code-club | /s2/preset.py | UTF-8 | 8,253 | 3.625 | 4 | [] | no_license | # prep
def ces_output(t, k, params):
"""
Constant elasticity of substitution (CES) production function.
Arguments:
t: (array) Time.
k: (array) Capital (per person/effective person).
params: (dict) Dictionary of parameter values.
Returns:
y: (array-lik... | true |
2b7e4120ccf2dd5e3c6401439ef14b70c01b969d | Python | lyksunny/snake | /snake.py | UTF-8 | 4,807 | 3.03125 | 3 | [] | no_license | import random, sys, pygame
from pygame.locals import *
#定义颜色变量
redcolor = pygame.Color(255, 0, 0)
whitecolor = pygame.Color(255, 255, 255)
blackcolor = pygame.Color(0, 0, 0)
azureblue = pygame.Color(0,255,255)
pygame.init() #初始化pygame
fpsClock = pygame.time.Clock() #定义变量控制游戏速度
playSurface = pygame.display.set_mode((6... | true |
8905b88ecb1a9f79ee6e627da5ac0a272a216e7b | Python | alpha-timtauri/Mecanum-Car | /Micropython/gCodeInterpreter.py | UTF-8 | 5,528 | 2.921875 | 3 | [
"CC0-1.0"
] | permissive | #gCode Interpereter
import mymatrix as m
import myroboter as mr
import motorKommandos as mk
import konfig
#mode 2d == True aktiviert den 2D-Modus, hier werden die Z-Kommandos als toolHight gespeichert und es wird nur um Z rotiert
#der 2D_Modus muss im konfig.py initialisiert werden
toolHight = 0
absoluteMod... | true |
7033e6b5e07a771dd79d760c2924faaf38483d6d | Python | KatrinZ94/hotel | /room/models.py | UTF-8 | 1,414 | 2.53125 | 3 | [] | no_license | from django.contrib.auth.models import User
from django.db import models
class Room(models.Model):
number_of_room = models.SmallIntegerField(
unique=True,
db_index=True,
verbose_name="номер комнаты",
help_text="первая цифра указывает на этаж"
)
choices_of_number_of_sleep_p... | true |
7a452cafd3f34b26d64e177e9cd39d8340c8f532 | Python | hemarozario/codingground | /New Project-20170314/main.py | UTF-8 | 139 | 3.140625 | 3 | [] | no_license | from time import sleep,time
sleep(60)
t1=time()
print("Press Enter key")
input()
t2=time()-t1
print("Enter key pressed after",t2,"seconds") | true |