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 |
|---|---|---|---|---|---|---|---|---|---|---|---|
a3af0b321d0afa09b77e6a77ffcb3dbae99ecc62 | Python | devangverma/CTCI | /stacks_and_queues/3.6.py | UTF-8 | 2,620 | 3.46875 | 3 | [] | no_license |
class MyQueue:
def __init__(self):
self.stack1 = []
self.stack2 = []
def enqueue(self, val):
while len(self.stack2) > 0:
self.stack1.append(self.stack2.pop())
self.stack1.append(val)
def dequeue(self):
while len(self.stack1) > 0:
self.stack2.append(self.stack1.pop())
... | true |
9a54844f513f5ccc914b8c2727538508eb711ada | Python | hafiyyanabdulaziz/cekos-collaborativefiltering-notebook | /cf.py | UTF-8 | 1,844 | 2.71875 | 3 | [] | no_license | import pandas as pd
import numpy as np
from sklearn.metrics.pairwise import cosine_similarity
property_interaction_df = pd.DataFrame(pd.read_csv('dataset_interaction_excel.csv',index_col=0))
interactions_matrix = pd.pivot_table(property_interaction_df, values='ratings', index='user_id', columns='property_id', aggfunc=... | true |
68c9e7e3db57a1192c71f8bf89dcfc22f87afd37 | Python | xulzee/LeetCodeProjectPython | /54. Spiral Matrix.py | UTF-8 | 2,005 | 3.609375 | 4 | [] | no_license | # -*- coding: utf-8 -*-
# @Time : 2019/3/15 18:42
# @Author : xulzee
# @Email : xulzee@163.com
# @File : 54. Spiral Matrix.py
# @Software: PyCharm
from typing import List
class Solution:
def spiralOrder(self, matrix: List[List[int]]) -> List[int]:
if matrix == []:
return []
st... | true |
93b2934a5f1b1417ad65c27f4b6890131f59309a | Python | sjdv1982/seamless | /seamless/imperative/Transformer.py | UTF-8 | 6,832 | 2.75 | 3 | [
"MIT"
] | permissive | """Imperative transformers"""
import inspect
from copy import deepcopy
import functools
import multiprocessing
class Transformer:
def __init__(self, func, is_async, **kwargs):
"""Imperative transformer.
Imperative transformers can be called as normal functions, but
the source code of the function and the... | true |
2ea2bef9479fd0abc6fd921ebbadd973a0ab87ea | Python | estraviz/codewars | /6_kyu/longest_palindrome/python/solution.py | UTF-8 | 416 | 3.734375 | 4 | [] | no_license | """longest_palindrome"""
def longest_palindrome(s):
max_len = 0
for i in range(len(s)):
for j in range(len(s), i, -1):
if max_len >= j - i:
break
else:
sub_s = s[i:j]
if is_palindrome(sub_s):
max_len = len(sub_... | true |
11d9a1e87925fdda4f8c08a53aacc0855024b387 | Python | fariahiago/LearningPython | /FUNCOES/ex02.py | UTF-8 | 226 | 3.046875 | 3 | [] | no_license | def piramideNumCrescente(n):
a = 1
b = 1
for i in range(n+1):
while a < b:
print(a, end = " ")
a +=1
print("\n")
b +=1
a = 1
piramideNumCrescente(5) | true |
c4f12a39dcbec31e46969ea51823ffd375307ab4 | Python | davwhite/funcflasker | /flaskr/functions/funcalc.py | UTF-8 | 216 | 3.375 | 3 | [] | no_license | def two_params(aname, acolor):
return "You have entered '" + aname + "' for a name and '" + acolor + "' for a color.\n"
def one_param(alocation):
return "You have entered '" + alocation + "' for location.\n" | true |
0fd9e52b6b727c4e0315eaff59c5cffb8b12f195 | Python | AdamZhouSE/pythonHomework | /Code/CodeRecords/2744/60717/266004.py | UTF-8 | 415 | 3.40625 | 3 | [] | no_license | def isPalindrome(str1):
lenn=int(len(str1)/2)
for i in range(0,lenn):
if str1[i]!=str1[len(str1)-1-i]:
return False
return True
n=int(input())
list1=[]
for i in range(0,n):
list1.append(input().split()[1])
list2=[]
for i in range(0,n):
for j in range(0,n):
list2.append(l... | true |
95891e6ff37851cdf08b9cae68832d50962e8aec | Python | GabrielCernei/codewars | /kyu7/Remove_The_Minimum.py | UTF-8 | 840 | 4.375 | 4 | [] | no_license | # https://www.codewars.com/kata/remove-the-minimum/train/python
'''
Given an array of integers, remove the smallest value. Do not mutate the original array/list.
If there are multiple elements with the same value, remove the one with a lower index. If you get
an empty array/list, return an empty array/list.
Don't cha... | true |
e5bf60da0827e0b0b2877b389a8d67efaef9ebc1 | Python | divanshu79/GeeksForGeeks-solutions | /Rotation.py | UTF-8 | 564 | 2.90625 | 3 | [] | no_license | for _ in range(int(input())):
n = int(input())
arr = list(map(int,input().split()))
minVal = min(arr)
maxVal = max(arr)
indVal1 = arr.index(minVal)
indVal2 = arr.index(maxVal)
count_max = arr.count(maxVal)
count_min = arr.count(minVal)
listlen = len(arr)
m... | true |
9a1e98add784d971db2d08ff0aa0c777bea2438a | Python | jonjon1010/RockPaperScissor | /Main.py | UTF-8 | 3,388 | 3.921875 | 4 | [] | no_license | '''
Created on Jun 22, 2021
Program: Rock, Paper, Scissor Game
@author: Jonathan Nguyen
'''
import random
import math
play = "yes"
while play.lower() == "yes":
print("This is a game of rock, paper, and scissor")
rounds = input("How many rounds would you like to play: ")
while rounds.isdigit... | true |
940dae119184842df5c65a3bda9215c74413cca4 | Python | nrkfeller/masterpy | /BeyondTheBasics/pytest/assignment.py | UTF-8 | 1,117 | 3.171875 | 3 | [] | no_license | import os
class ConfigKeyError(Exception):
def __init__(self, this, key):
self.key = key
self.keys = this.keys()
def __str__(self):
return '{} not found{}'.format(
self.key, self.keys
)
class ConfigDict(dict):
def __init__(self, filename):
... | true |
d2032956931cc8bbb4ed6a0c8fb44a6260269283 | Python | r4vi/weboutlook | /weboutlook/scraper.py | UTF-8 | 8,521 | 2.875 | 3 | [] | no_license | """
Microsoft Outlook Web Access scraper
Retrieves full, raw e-mails from Microsoft Outlook Web Access by
screen scraping. Can do the following:
* Log into a Microsoft Outlook Web Access account with a given username
and password.
* Retrieve all e-mail IDs from the first page of your Inbox.
* Retrie... | true |
785a26e51d78a1e7c4a02fdb4595782b0dc7e3c2 | Python | SamruddhiShetty/Sudoku_player | /sudoku_solver.py | UTF-8 | 4,393 | 3.234375 | 3 | [] | no_license | import pygame
#module use to execute get and post request
import requests
#initialising the width and the background of the board displayed
WIDTH=550
background_color=(251,247,245)
#just to distinct the original numbers
original_grid_num_color=(52, 31, 151)
buffer=5
#getting the values from an API suGOku
response=req... | true |
7fa5fcc5a61395ed8f600332ff2c52d6cb23717d | Python | CarlosMiraGarcia/Honours-project | /point_cloud_ops/point_cloud_ops.py | UTF-8 | 3,943 | 2.921875 | 3 | [] | no_license | import open3d as o3d
import numpy as np
def remove_outliers(pcd, neighbors, ratio):
""" Removes outliers from a point cloud
\tpcd is the point cloud class,
\tneighbors is the number of neighbors taken into consideration to calculate the distance between points
\tand ratio is the threshold l... | true |
17fd0950cf7e115c8c7206416837e80805f3857e | Python | heyzeng/Awesome-Python | /Python-Basic/python30.py | UTF-8 | 817 | 4.4375 | 4 | [] | no_license | # -*- coding:UTF-8 -*-
# 30道python基本入门小练习
# 1. 重复元素判定
# 以下方法可以检查给定列表是不是存在重复元素,它会使用 set() 函数来移除所有重复元素
def all_unique(lst):
return len(lst) == len(set(lst))
x = [1, 2, 2, 3, 4]
y = [1, 2]
print(all_unique(x))
print(all_unique(y))
print("-----------")
# 2. 字符元素组成判定
# 检查两个字符串的组成元素是不是一样的。
from collections import ... | true |
455bbbee5245c6899ec883c349f428f87cca4f0b | Python | akinoriosamura/Semantic-Segmentation-Suite | /loss.py | UTF-8 | 548 | 2.671875 | 3 | [] | no_license | import tensorflow as tf
def dice_loss(input, target):
smooth = 1.
#if scale is not None:
# scaled = interpolate(input, scale_factor=scale, mode='bilinear', align_corners=False)
# iflat = scaled.view(-1)
#else:
iflat = tf.reshape(input, [-1])
# tflat = target.view(-1)
tflat = tf.... | true |
0ac5ef0c1e8b45510b5d511816107d7018091321 | Python | hackergong/Python-TrainingCourseLearning | /day008/8-访问限制/访问限制.py | UTF-8 | 1,926 | 3.984375 | 4 | [] | no_license | class Person(object):
#创建对象的时候自动咨执行
def __init__(self,name,age,height,weight,money):
#定义属性
self.name = name
self.height = height
self.weight = weight
self.__age__ = age
#双下划线变为不可修改内部属性
self.__money = money #Person__money
def run(self):
print(s... | true |
1592e28f72b673f4c0b696457cf972f21253aade | Python | codemaster-22/Compiler | /src/Compiler.py | UTF-8 | 42,547 | 2.546875 | 3 | [] | no_license | #!/usr/bin/env python
# coding: utf-8
# In[184]:
import sys
# In[185]:
def generatelist(code):
a=[]
if('"' in code):
j=code.find('"')
a=code[:j].split()
if('"' in code[j+1:]):
k=code[j+1:].find('"')
a=a+[code[j:j+k+2]]+generatelist(code[j+k+2:])
els... | true |
f0e2996baa5e49d6f68bf8dd355711606d529dc2 | Python | krystal2694/star_wars_sud | /A3/test_attack.py | UTF-8 | 2,075 | 3.109375 | 3 | [] | no_license | from unittest import TestCase
from unittest.mock import patch
from battle import attack
from imperial import imperial_forces
import io
class TestAttack(TestCase):
@patch('sys.stdout', new_callable=io.StringIO)
@patch('battle.randint', side_effect=[1, 3])
def test_attack_print_output_when_miss(self, mock_r... | true |
3022d157d83f77763a17445fe41c3096c010d135 | Python | juma011/programming-advance-assignment | /Own type built in types.py | UTF-8 | 775 | 4.09375 | 4 | [] | no_license | class Dog:
pass
class Dog:
def speak(self):
print("bark")
def walk(self):
print("walk")
d = Dog()
print(d.walk())
d2 = Dog()
print(d2.walk())
d.name = "jim"
d2.name = "dwight"
print(d2.name)
d.age = 30
d2.age = 35
print(type(d))
def speak():
print('speak')
d1 = 20
d2 = 60
print(d2/... | true |
3795dcbdbae92b11805359fd02acf0cb7c795350 | Python | jaitjacob/Smart-Library | /mp/book.py | UTF-8 | 451 | 3 | 3 | [] | no_license |
class Book:
def __init__(self, bookid: int, title: str, author: str, publisheddate: str):
self.bookid = bookid
self.title = title
self.author = author
self.publisheddate = publisheddate
def get_bookid(self):
return self.bookid
def get_title(self):
return se... | true |
7eaa035c654f839e48fccc06a6cf57cb472d32e8 | Python | lobo1233456/footlbotestproj | /footlbolib/IndependentDecoration/dirFunc.py | UTF-8 | 1,488 | 2.921875 | 3 | [] | no_license | import os
import settings
class dirFunc():
def __init__(self):
directory = "./dir"
# os.chdir(directory) # 切换到directory目标目录
cwd = os.getcwd() # 获取当前目录即dir目录下
def deleteBySize(self,minSize):
"""删除小于minSize的文件(单位:K)"""
files = os.listdir(os.getcwd()) # 列出目录下的文件
... | true |
5605216b4be0a9dfec1d5551c9d0bb92baab976a | Python | portscher/SIFT-SURF-HOG | /hog.py | UTF-8 | 2,847 | 3.015625 | 3 | [] | no_license | from skimage.feature import hog
from sklearn.cluster import MiniBatchKMeans
from sklearn.base import TransformerMixin, BaseEstimator
import cv2
class HogTransformer(BaseEstimator, TransformerMixin):
"""
Provides functionality to use the HoG for training clusters
and computing histograms of oriented gradi... | true |
61ef1ce82480165d8bbaf77b3eb4ca0e554e2c5a | Python | frantzmiccoli/artemisia | /src/artemisia/test/arff_exporter_test.py | UTF-8 | 1,837 | 2.640625 | 3 | [
"MIT",
"LicenseRef-scancode-other-permissive"
] | permissive | import unittest
from artemisia.exporter.arff_exporter import ArffExporter
class ArffExporterTest(unittest.TestCase):
def test_export(self):
exporter = ArffExporter()
exporter.set_columns('problem,iteration,weight'.split(','))
file_data = self._get_fake_file_data()
exporter.export... | true |
27b01f8dcc52904feeec3056cbe5d7c569f29257 | Python | aminosninatos/GitUnderHood | /gittips.py | UTF-8 | 5,571 | 2.515625 | 3 | [] | no_license | Turn paged output
--------------------------
for git branch :
git config --global pager.branch false
for git log :
git config --global pager.log false
Status in silent mode
-------------------------------------------------------------------
git status -s
will show a brief summary about the status of the file... | true |
f77b7ab3af02d140fc96f21dfc86ba50cd6013f0 | Python | marcociccone/DAL | /DAL_digits_release/datasets/unaligned_data_loader.py | UTF-8 | 2,711 | 2.65625 | 3 | [] | no_license | import torch.utils.data
from builtins import object
import torchvision.transforms as transforms
from datasets_ import Dataset
class PairedData():
def __init__(self, data_loader_A, data_loader_B, max_dataset_size):
self.data_loader_A = data_loader_A
self.data_loader_B = data_loader_B
self.s... | true |
dcdf6edbeb9892c1d5851b1f112fb45c608aed05 | Python | Rpinto02/DPhi_MachineLearning_bootcamp | /Assignment 3/app/main.py | UTF-8 | 4,238 | 2.875 | 3 | [] | no_license | import streamlit as st
import pandas as pd
import numpy as np
import joblib
from sklearn.compose import ColumnTransformer
from sklearn.preprocessing import StandardScaler
def transform_input(scaler,Gender, Married, SelfEmployed, PropertyArea, Dependents, Education, CreditHistory, ApplicantIncome, CoapplicantIncome, Lo... | true |
c06579ffb9b9b7b065f721d5b78a5070559bc1d6 | Python | AndrewKhamov/Python-Tutorials | /Задание 48. Сортировка (неделя 6).py | UTF-8 | 240 | 3.203125 | 3 | [] | no_license | n = int(input())
a = list(map(int, input().split()))
if len(a) == n:
print(sorted(a))
else:
print('error')
# Отсортируйте данный массив, используя встроенную сортировку.
| true |
34f59a9419d57f2b1181c160af4429e1f37fd21a | Python | xfdywy/vrsgd | /manual/resnet_cifar100/cifarnetdef.py | UTF-8 | 3,376 | 2.59375 | 3 | [] | no_license | #!/usr/bin/env python2
# -*- coding: utf-8 -*-
"""
Created on Thu Jul 6 20:29:23 2017
@author: yuewang
"""
import tensorflow as tf
import numpy as np
import keras
from keras.datasets import cifar10
from keras.preprocessing.image import ImageDataGenerator
from keras.models import Sequential
from keras.layers import De... | true |
6d73e0b98e489b49ec6dc9610c969172e4fc1b94 | Python | erickmiller/AutomatousSourceCode | /AutonomousSourceCode/data/raw/squareroot/852115a1-f869-4dc3-a693-5c19c28748b5__problem-009.py | UTF-8 | 307 | 3.546875 | 4 | [] | no_license | #!/usr/bin/python3
import math
def square_root(n):
s = int(math.sqrt(n))
if s * s == n:
return s
else:
return None
for a in range(1, 1000):
for b in range(a + 1, 1000):
c = square_root(a * a + b * b)
if c and a + b + c == 1000:
print(a * b * c)
| true |
c046d8195b000e2c94897581df7cf2825d0c2744 | Python | armsky/Preps | /Amazon/Minimum Depth of a Binary Tree.py | UTF-8 | 875 | 3.953125 | 4 | [] | no_license | """
Given a binary tree, find its minimum depth. The minimum depth is the number of
nodes along the shortest path from root node down to the nearest leaf node.
Note that the path must end on a leaf node. For example, minimum height of below
Binary Tree is also 2.
10
/
5
"""
class Solution:
... | true |
72635c64e06cbf4f9061019ed72b2423466109e2 | Python | ChangShuaibin/Learning | /read_time.py | UTF-8 | 85 | 2.6875 | 3 | [] | no_license | import datetime
time=datetime.datetime.now()
name=str(time)[:10]+'-'+str(time)[11:19] | true |
e091ffe41b51e5314c7ae6785472885eb73ae073 | Python | nyu-mll/jiant | /tests/tasks/lib/test_sst.py | UTF-8 | 4,460 | 3.015625 | 3 | [
"MIT"
] | permissive | import os
from collections import Counter
import numpy as np
from jiant.tasks.retrieval import create_task_from_config_path
from jiant.utils.testing.tokenizer import SimpleSpaceTokenizer
TRAIN_EXAMPLES = [
{"guid": "train-0", "text": "hide new secretions from the parental units ", "label": "0"},
{"guid": "t... | true |
491924ff15657c1c74008b866396e1b9dd0a4e14 | Python | leverans/async_curses_game | /star_animation.py | UTF-8 | 799 | 2.796875 | 3 | [] | no_license | import asyncio
import curses
from random import randint
# захотелось отделить сценарий анимации от логики, так вроде гораздо удобнее
from utilities import sleep
STAR_ANIMATION_STEPS = (
(20, curses.A_DIM),
(3, 0),
(5, curses.A_BOLD),
(3, 0),
)
BLINK_LENGTH = sum(step[0] for step in STAR_ANIMATION_STE... | true |
937e908305af796fba82cc0c0b2ce873c14899f1 | Python | JudyCoelho/exerciciosCursoPython | /aula13/aula13.py | UTF-8 | 262 | 3.953125 | 4 | [] | no_license | usuario = input('Digite seu usuário: ')
qtd_caracteres = len(usuario)
#print(usuario, qtd_caracteres, type(qtd_caracteres))
if qtd_caracteres < 6:
print('Você precisa digitar pelo menos 6 caracteres')
else:
print('Você foi cadastrado no sistema.')
| true |
644a38bfc127a8d2c47c72cf5756bbc9db6f9e33 | Python | sudosays/weatherwatch | /weatherwatch_proj/weatherwatch/views.py | UTF-8 | 714 | 2.734375 | 3 | [] | no_license | from django.http import HttpResponse
from django.template import RequestContext
from django.shortcuts import render_to_response
def index(request):
context = RequestContext(request)
context_dict = {'boldmessage':'Hi Joan! :)'}
return render_to_response('weatherwatch/index.html', context_dict, context)
def abo... | true |
d9e3c21e1b565b96fb2317380bd869161822838e | Python | willhunt/silvia | /silvia/silviacontrol/display.py | UTF-8 | 2,415 | 2.609375 | 3 | [
"MIT"
] | permissive | from django.conf import settings as django_settings
from silviacontrol.utils import debug_log
from board import SCL, SDA
import busio
import board
import adafruit_ssd1306
from PIL import Image
from PIL import ImageDraw
from PIL import ImageFont
import time
class SilviaDisplay():
"""
Display using newer Adafrui... | true |
a7cf37677f75607d3dbe5c6cc761abbfe2df4c0e | Python | dyylanl/TPs-Numerico | /TP 1/Codigo Ejercicios/Ejercicio 3/BusquedaRaicesSecante.py | UTF-8 | 2,265 | 3.1875 | 3 | [] | no_license | import math
import sympy as sym
import numpy as np
def busqueda_raiz_secante(funcion, semilla1, semilla2, error, paso_a_paso=False, iteracionesForzadas = None):
x= sym.Symbol('x')
y= sym.Symbol('y')
dato_viejo1 = semilla1
dato_viejo2 = semilla2
#si tiene mas de 50 iteraciones no va a funciona... | true |
324ab5ef867d6fc47a158c9af149eb9f90c45668 | Python | malcolmrite-dsi/JSE_Researcher | /Company_List_Generator.py | UTF-8 | 1,919 | 2.59375 | 3 | [
"MIT"
] | permissive | from request_web import SensGetter
import csv
import requests
from bs4 import BeautifulSoup
class CompanyGenerator():
def get_all_companies():
df = open("JSE_company_list.csv","w")
csv_writer = csv.writer(df)
csv_writer.writerow(["Share Code", "Short Name"])
all_comp = ["4", "A",... | true |
f90017150e79f3714f4d36c0c7f81e44bc818157 | Python | xiaoyaowudi-extreme/2019-nCoV | /test.py | UTF-8 | 806 | 3.25 | 3 | [] | no_license | from scipy import log as log
import numpy
from scipy import log
from scipy.optimize import curve_fit
def func(x, a, b):
y = a * log(x) + b
return y
def polyfit(x, y, degree):
results = {}
#coeffs = numpy.polyfit(x, y, degree)
popt, pcov = curve_fit(func, x, y)
results['polynomial'] = popt
... | true |
15b9b7007496354cb5452880b0cb889509464614 | Python | therealaleksandar/OOP-farma | /zito_klasa.py | UTF-8 | 825 | 2.6875 | 3 | [] | no_license | from usev_klasa import *
class Zito(Usev):
def __init__(self):
super().__init__(1,3,5)
self._tip="Zito"
def rasti(self,svetlost,voda):
if svetlost>=self._potrebna_svetlost and voda>=self._potrebna_voda:
#if self._status=="Izrasta" and voda>self._potrebna_voda:
... | true |
85d2d32d7c69016b4064c77e700dd110b4cd4eaa | Python | KKosukeee/CodingQuestions | /LeetCode/334_increasing_triplet_subsequence.py | UTF-8 | 1,841 | 4.125 | 4 | [] | no_license | """
Solution for 334. Increasing Triplet Subsequence
https://leetcode.com/problems/increasing-triplet-subsequence/
"""
class Solution:
"""
Runtime: 40 ms, faster than 75.02% of Python3 online submissions for Increasing Triplet
Subsequence.
Memory Usage: 13.5 MB, less than 6.80% of Python3 online su... | true |
04bd2683671687e669a0b2df68a6949d41242577 | Python | SaretMagnoslove/Python_3_Basics_Tutorial_Series-Sentdex | /Lesson44_ftplib.py | UTF-8 | 694 | 2.828125 | 3 | [] | no_license | from ftplib import FTP
# in order for this code to work you will have to fill in your credentials
ftp = FTP('DomainName.com')
ftp.login(user='username', passwd='password')
ftp.cwd('/specific_domain/') # depends on the site you connect to
# downloading a file:
def grabFile():
filename = 'filename.extention'
loca... | true |
c9cd8edca6ea4f360bc2d266b201f733169af2d5 | Python | garylvov/summer-2020---learning_ROS-Gazebo | /learning_stage/scripts/navHallway.py | UTF-8 | 1,712 | 2.625 | 3 | [] | no_license | #!/usr/bin/env python
import rospy
import math
from sensor_msgs.msg import LaserScan
from std_msgs.msg import String
from geometry_msgs.msg import Twist
rangeAhead = 0.0
maxRange = 0.0
minRange = 0.0
slightLeft = 0.0
slightRight = 0.0
left = 0.0
right = 0.0
def rangeCallback(msg):
global rangeAhead, maxRange, min... | true |
f6f3d6e5bff3115ce8a9d28c1bf49720f67f3e91 | Python | willianflasky/growup | /python/day07/循环的socket客户端.py | UTF-8 | 396 | 2.890625 | 3 | [] | no_license | import socket
client=socket.socket(socket.AF_INET,socket.SOCK_STREAM)
client.connect(('192.168.12.110',8080)) #拨通电话
while True:
msg=input('>>: ')
if not msg:continue
client.send(msg.encode('utf-8')) #客户端发消息
print('====>has send')
data=client.recv(1024) #客户端收消息
print('=====>has rec... | true |
4b0cc7770147fee7d01ad57c4956730fed8e6b3f | Python | strengthen/LeetCode | /Python3/1238.py | UTF-8 | 1,114 | 3.046875 | 3 | [
"MIT"
] | permissive | __________________________________________________________________________________________________
sample 180 ms submission
class Solution:
def circularPermutation(self, n: int, start: int) -> List[int]:
def helper(i):
if i == 1:
return [0, 1]
temp = helper(i - 1)
... | true |
ea885c686991db638e67624c1e6f1f716798c5e4 | Python | JosephLevinthal/Research-projects | /5 - Notebooks e Data/1 - Análises numéricas/Arquivos David/Atualizados/logDicas-master/data/2019-1/225/users/4000/codes/1592_1805.py | UTF-8 | 263 | 3.40625 | 3 | [] | no_license | xa = float(input("coordenadas do ponto a"))
xb = float(input("coordenadas do ponto a"))
ya = float(input("coordenadas do ponto b"))
yb = float(input("coordenadas do ponto b"))
pontox = xb + xa /2
pontoy = yb + ya /2
print(round(pontox, 1))
print(round(pontoy, 1)) | true |
70d55974a4a8ed78e362f8b1669cd9a732ce5446 | Python | andrewbeattycourseware/pands2021 | /code/week10-objects/lecture/codeForSlides.py | UTF-8 | 1,430 | 3.53125 | 4 | [] | no_license | # this is code I am using the lecture slides
# this is program does not do anything
import datetime
firstname = 'Andrew'
lastname =' Beatty'
dob = datetime.date(2010, 1, 1)
height = 180
weight = 100
person1firstname = 'Andrew'
person1lastname = ' Beatty'
person1dob = datetime.date(2010, 1, 1)
... | true |
abb22188a2c45807c403b9c9e028ba5b31f03088 | Python | gougo/ip_address_update | /read_sort_ipfile.py | UTF-8 | 2,725 | 2.75 | 3 | [] | no_license | # !/usr/bin/env python
# -*- coding: utf-8 -*-
'''
读取排序的ip文件.
排除一个ip多个地址的情况,并且将可以合并的ip段合并
Created on 2014-9-2
@author: tianfei
'''
import logging
import sys
import os
logging.basicConfig(filename = os.path.join(os.getcwd(), 'sort_ipfile.log'),
level = logging.DEBUG,
format = '%(... | true |
e0530ecc38a94ad4b617386f00aa88c46c93e80f | Python | Helsinki-NLP/OpusFilter | /opusfilter/filters.py | UTF-8 | 21,434 | 2.921875 | 3 | [
"MIT"
] | permissive | """Corpus filtering"""
import difflib
import itertools
import logging
import math
import os
import string
from typing import Iterator, List, Tuple
import regex
from . import FilterABC, ConfigurationError, CLEAN_LOW, CLEAN_HIGH, CLEAN_BETWEEN, CLEAN_TRUE, CLEAN_FALSE
from .lm import CrossEntropyFilter, CrossEntropyDi... | true |
0cf1e98771a83a773954c3d8c8003ca97d72c26d | Python | swapnanildutta/Python-programs | /Duplicates.py | UTF-8 | 230 | 3.328125 | 3 | [] | no_license | # -*- coding: utf-8 -*-
"""
Created on Fri Aug 9 05:55:10 2019
@author: aot
"""
a=[int(i) for i in input("Enter the tuple:").split()]
a=tuple(a)
ar=set(a)
for i in ar:
if(a.count(i)>1):
print(i,end=" ") | true |
90d87d66fc91a4e725cf49f4b5b486c178a9926d | Python | whitbit19/practice-problems | /stock_prices.py | UTF-8 | 1,430 | 3.921875 | 4 | [] | no_license |
def max_profits(stock_prices):
"""
Return max profit using brute force method. O(n^2) solution.
>>> max_profits([10, 7, 5, 11, 9])
6
>>> max_profits([1, 2, 3, 5])
4
>>> max_profits([])
0
"""
max_profits = 0
for i in range(len(stock_prices)):
for j in range(i + 1... | true |
70146ea534ee51280038d750740999034e69f13a | Python | B-Kroske/MatasanoCrypto | /Set1/Challenge8.py | UTF-8 | 1,198 | 3.046875 | 3 | [] | no_license | from CryptoLib import everyNth, validate
from collections import Counter
import binascii
def calcScore(array):
counter = Counter(array)
arrFreq = counter.most_common()
res = 0
for i in range(0,3):
res += arrFreq[i][1]
return res
def main():
ans = "d880619740a8a19b7840a8a31c810a3d0864... | true |
78507cd67df1ff21a650b368277b630716f88ad8 | Python | JonasWard/facade_p2p | /img_to_facade/img_to_objs.py | UTF-8 | 2,845 | 2.625 | 3 | [] | no_license | from PIL import Image
import numpy as np
dict_rectangles = {
"bathroom" : [
(48, 813),
(129, 676)
],
"window_1_left" : [
(298, 423),
(555, 113)
],
"window_1_right" : [
(785, 423),
(1039, 111)
],
"window_0_right" : [
(780, 943),
... | true |
84d4661e99da23cd2ced9b4b39abc153608b874a | Python | RajC9/Simple-Calculator | /Main.py | UTF-8 | 576 | 3.515625 | 4 | [] | no_license | number_one=int(input('please enter the first number'))
operator=input('please enter the operator:')
number_two= int(input('please enter the second number'))
if operator == '+':
print('{}+{}= '.format(number_one,number_two))
print(number_one+number_two)
elif operator == '-':
print('{}-{}='.format(number_one,number_t... | true |
0ef34541f73e0fac6e06755758436eb615571276 | Python | Songyang2017/Python-Learn-record | /py基础/输入和输出/1.py | UTF-8 | 2,238 | 4.53125 | 5 | [] | no_license | # str() 返回用户易读
# repr() 返回解释器易读
import math
s = 'Hello Shasha!'
print('str():', str(s))
print('repr():', repr(s))
x = 1.25 * 10
y = 100 * 300
s = "x的值为:" + str(x)+", y的值为:"+repr(y)+"...."
print(s)
# range(start, stop, step) 用于创建整数列表,一般用于for循环中
# start 计数开始,默认从0开始,range(5)等价range(0, 5)
# stop 结束,不包含stop
# step 步数,默认为... | true |
e249fbe512804ea8cc0edc3771fd14920d099c1a | Python | CY2020/Project-1 | /program.py | UTF-8 | 2,164 | 3.359375 | 3 | [] | no_license | #Mobile Emergency
#MakeSPPrep Project
#Heart Health
print "Welcome, please insert your health information."
print "Please select one of the following conditions:"
print "1. arrhythmia"
print "2. high blood pressure"
print "3. history cardic arrest"
print "4. heart murmurs"
print "5. coronary hartry disease"
print "6. c... | true |
607221182bf594c512cc0247e5faa9a26b8f8a92 | Python | apuya/python_crash_course | /Part_1_Basics/Chapter_10_Files_Exceptions/exercise10_6.py | UTF-8 | 631 | 4.09375 | 4 | [] | no_license | # Python Crash Course: A Hands-On, Project-Based Introduction To Programming
#
# Name: Mark Lester Apuya
# Date:
#
# Chapter 10: Files And Exceptions
#
# Exercise 10.6 Addition:
# One common problem when prompting for numerical input occurs when people provide text instead of numbers. When you try
# to convert the inp... | true |
47127fe92f48ffc611dcc54e1a7b0d00b671724d | Python | muztim/100-days-of-code-python | /Projects/Day_25/us-states-game/main.py | UTF-8 | 1,096 | 3.5625 | 4 | [] | no_license | import turtle
import pandas as pd
ALIGNMENT = "center"
FONT = ("Arial", 12, "bold")
states_df = pd.read_csv("50_states.csv")
screen = turtle.Screen()
screen.title("U.S. States Game")
image = "blank_states_img.gif"
screen.addshape(image)
turtle.shape(image)
pointer = turtle.Turtle()
pointer.penup()
pointer.hideturtle()... | true |
d3595fb1ffb51ad688c743202909f80f1abdc54d | Python | Lusarom/progAvanzada | /ejercicio75.py | UTF-8 | 224 | 3.984375 | 4 | [] | no_license | n = int(input('Ingrese un numero entero positivo:'))
m = int(input('Ingrese un numero entero positivo:'))
d = min(n, m)
while n % d != 0 or m % d !=0:
d = d-1
print("El mayor divisor comun es", n, 'y', m, "es", d) | true |
289e7e5091c0be229f5cbe72ef2c5f1b26056795 | Python | lixuewen1999/app | /appiumcloud/appiumclound.py | UTF-8 | 3,404 | 2.5625 | 3 | [] | no_license | '''
@author: lixuewen
@file: appiumclound.py
@time: 2020/9/23 14:04
@desc: 云测试平台
'''
import socket,os,subprocess,threading
from appium import webdriver
from time import sleep
from selenium.webdriver.support.wait import WebDriverWait
from selenium.webdriver.support import expected_conditions as EC
from seleni... | true |
accb9abf424d8b3796b3bbeb2c5d54e7c7ba232a | Python | ChrisLMartin/cal_data_processing | /create_shrinkage_csv.py | UTF-8 | 1,313 | 2.859375 | 3 | [] | no_license | # -*- coding: utf-8 -*-
"""
Created on Wed Oct 31 10:14:20 2018
@author: christopher.martin
"""
import datetime
import pandas as pd
# Set excel shrinkage spreadsheet path
path_in = "S:\Current Projects\R&D\Shrinkage.xlsx"
# Read records into pandas dataframe
df = pd.read_excel(path_in, "Records", index_col="Reading ... | true |
6e197fa2b8fcec9b9542f2c5c40e2869f6f67c7a | Python | LelandYan/sklearn_tensorflow | /chapter04/model_learning.py | UTF-8 | 3,356 | 3.15625 | 3 | [] | no_license | # _*_ coding: utf-8 _*_
import numpy as np
import matplotlib.pyplot as plt
# X = 2 * np.random.rand(100, 1)
# y = 4 + 3 * X + np.random.randn(100, 1)
#
# plt.plot(X, y, "b.")
# plt.xlabel("$x_1$", fontsize=18)
# plt.ylabel("$y$", rotation=0, fontsize=18)
# plt.axis([0, 2, 0, 15])
# # plt.show()
#
# X_b = np.c_[np.ones... | true |
12e2a3f03fa1d9648595bf5f7e36da64af533a42 | Python | thomasdf/Computer-Vision-Project | /learning/SlidingWindow.py | UTF-8 | 1,031 | 3.125 | 3 | [] | no_license | import numpy as np
from image.Image import Img
from image import Image
def slidingwindowclassify(image: Img, stride: int, height: int, width: int, classifier: callable):
"""Slides a classifier over an image. That is: runs classifier for each height*width frame, stride apart"""
image.normalize()
imgwidth = image.s... | true |
575d77ca79381f176b25c9229afc97535f5bb545 | Python | JarvixHsj/Py_Grammar_exercises | /oop/oop_simplestclass.py | UTF-8 | 243 | 3.65625 | 4 | [] | no_license | class Person:
pass #一个空的代码块
class Person2:
def say_hi(self, name = 'Jarvix'):
print('hi {0},how are you?'.format(name))
p = Person();
print(p)
print('-------Person2---------')
p2 = Person2()
p2.say_hi('hsj')
| true |
d946a30e785309b401e0e85efb429979c4fe1150 | Python | chandrakant100/Assignments_Python | /Practical/assignment4/product.py | UTF-8 | 548 | 3.640625 | 4 | [] | no_license | import math
count = input("Enter total numbers want to multiply(max = 4):")
if count.isnumeric() == 0:
print("It is a string!!!")
exit()
count = int(count)
countNum = 1
def multiply(num1 = 1, num2 = 1, num3 = 1, num4 = 1):
return num1*num2*num3*num4
if count > 4:
print("Maximux intput is 4")
ex... | true |
c43f5822fab1496737dbb7a07ac1ce013dd67084 | Python | BrunoLQS/Projects_and_ITA | /Z-Transform/IZ_transform/iztrans_15.Py | UTF-8 | 509 | 2.890625 | 3 | [] | no_license | title="""Simétrico da Fórmula 6"""
N=6
X=Piecewise((z/(-a + z), True), (-Sum(a**n*z**(-n), (n, -oo, -1)), True))
X=X.subs(a,2)
# a deve ser substituído por um INTEIRO !
#######
m=0.999
#######
results=[ iztrans(X,i,m) for i in nparange(-N,N+1)]
fig = figure()
ax1 = fig.add_subplot(111)
ax1.set_ylabel('Valor',font... | true |
39dadbcb094eb81fe86c09e9c048938792a2882c | Python | VaibhavD143/Coding | /leet_reorder_list_2.py | UTF-8 | 670 | 3.375 | 3 | [] | no_license | # Definition for singly-linked list.
# class ListNode:
# def __init__(self, x):
# self.val = x
# self.next = None
class Solution:
def reorderList(self, head: ListNode) -> None:
"""
Do not return anything, modify head in-place instead.
"""
if not head or not head... | true |
bb58aa94276cc0a02844da0c4183eb360200b8b0 | Python | vedrankolka/APR | /dz4/ga/population/selection.py | UTF-8 | 2,109 | 3.453125 | 3 | [
"Apache-2.0"
] | permissive | import numpy as np
class Selection:
def select_parents(self):
pass
def set_population(self, population):
pass
def update(self, population):
pass
class RouletteWheelSelection(Selection):
def __init__(self, n, minimum_effective_fitnes=0.0):
self.minimum_effective_fi... | true |
8ecc7fa0d01f0e0f73ff9dc3d58372dffc43af72 | Python | krzysztof-piasecki/python-hackerrank | /HackerRank/MediumTasks/LivingWithoutLoopsSort.py | UTF-8 | 955 | 3.28125 | 3 | [] | no_license | def partitionhelper(x, j, pivot, i):
if j < len(x) - 1:
if x[j + 1] < pivot:
x[j + 1], x[i + 1] = x[i + 1], x[j + 1]
i += 1
j += 1
return partitionhelper(x, j, pivot, i)
j += 1
return partitionhelper(x, j, pivot, i)
else:
return x, ... | true |
fd91e5f4127b050ad7b667fa9f7c71d715fa9b75 | Python | veralake777/toolkitten | /summer-of-code/week-03/nltkCh1.py | UTF-8 | 617 | 2.953125 | 3 | [
"MIT"
] | permissive | import nltk
#for line in text1:
# for word in line.split():
# if word.endswith('ing'):
# print(word)
#text1.concordance("man")
#text1.concordance("woman")
#text1.dispersion_plot(["man", "woman", "child"])
#print(len(text1))
#prints dictionary of vocab in text
##print(sorted(set(text1)))
#prints n... | true |
aafd6ef840aeaf79862a4eafe3e5208cc6601fd5 | Python | maggieaschneider/WarGame---BAMG | /screen_end.py | UTF-8 | 1,065 | 3.484375 | 3 | [] | no_license | from tkinter import *
class Screen_End(Frame):
def __init__(self, master, call_on_next, winner):
super(Screen_End, self).__init__(master)
self.call_on_selected = call_on_next
if winner=="p":
self.winner="You"
if winner=="c":
self.winner="Computer"
sel... | true |
2914bf4b980a3a68445a8b48432469af6d34d3d0 | Python | m0sk/MFTI | /01_turtle/003.py | UTF-8 | 590 | 3.5625 | 4 | [] | no_license | #!C:\UDISK\ProgramFiles\python\3.6.2\python.exe
'''
by coordinate (x,y), define in which quarter point is
^y
II | I
|
----+---->
|0 x
III | IV
'''
x = int(input()) # intput() - enter from input (keyboard)
y = int(input())
'''
x>0, y>0 = I
... | true |
48ce3f277d1e416a79299a9009bdfe9e683fdb10 | Python | njyaron/SMOP | /analizer/analizer/resultsParagraphAnalysis.py | UTF-8 | 1,812 | 2.8125 | 3 | [] | no_license | #### Paragraph analysis ####
import trigraphArray
import matplotlib.pyplot as plt
people = trigraphArray.load_all()
# distribution of similarity in sessions from the same person, for some users
names = ['Nir Yaron', 'Adi Asher', 'Yovel Rom', 'Guy Levanon']
for name in names:
person = [p for p in people if p.name ... | true |
0fd064a50f701a9036f3e113e3ca64fc6765d7a1 | Python | BossaMelon/python_tetris | /rotate_system/rotate_srs.py | UTF-8 | 1,711 | 3.140625 | 3 | [] | no_license | from tetromino import Tetromino
class SRS:
# TODO anti clockwise
# coordinate origin in left up corner
wall_kick_JLSTZ_clockwise = (((0, 0), (-1, 0), (-1, -1), (0, 2), (-1, 2)),
((0, 0), (1, 0), (1, 1), (0, -2), (1, -2)),
((0, 0), (1, 0), (... | true |
d1b97a9678290136bb886329683f683f61656746 | Python | trunksio/Supbot2 | /supbot/results.py | UTF-8 | 438 | 2.53125 | 3 | [
"MIT"
] | permissive | from enum import Enum
class GotoStateResult(Enum):
"""
When goto state successfully does its operation,
even if it doesnt reach the `to` state (as it might just take one step sometimes`
"""
SUCCESS = 0,
"""
When element is not found
"""
ELEMENT_NOT_FOUND = 1,
"""
When che... | true |
17da5a2536348093407bfc9f2b25b261f970386c | Python | AEliu/QK_learn | /05 数据持久化/上课代码/01 文件操作/02 文件的读取.py | UTF-8 | 234 | 2.953125 | 3 | [] | no_license | """
r 读取文件
"""
with open('hello.txt', mode='r', encoding='utf-8') as f:
# text = f.read()
text = f.readline()
print(text)
text = f.readline()
print(text)
text = f.readlines()
print(text) | true |
6861e25631aa9d7cd51e0b770b4a872a789e9ca7 | Python | NJ-zero/LeetCode_Answer | /string/isLongPressedName.py | UTF-8 | 1,492 | 3.890625 | 4 | [] | no_license | # coding=utf-8
# Time: 2019-10-19-17:15
# Author: dongshichao
'''
你的朋友正在使用键盘输入他的名字 name。偶尔,在键入字符 c 时,按键可能会被长按,而字符可能被输入 1 次或多次。
你将会检查键盘输入的字符 typed。如果它对应的可能是你的朋友的名字(其中一些字符可能被长按),那么就返回 True。
示例 1:
输入:name = "alex", typed = "aaleex"
输出:true
解释:'alex' 中的 'a' 和 'e' 被长按。
示例 2:
输入:name = "saeed", typed = "ssaaedd"
输出:f... | true |
3b7b7b40d2d726924ba455759b2cf497c17a72ec | Python | YIYANGLAI1997/leetcode | /past/python/Median_of_Two_Sorted_Arrays.py | UTF-8 | 883 | 3.734375 | 4 | [] | no_license | # 4 Median of Two Sorted Arrays Hard
# Should be optimized by the divide-conquer approach
class Solution:
# @return a float
def findMedianSortedArrays(self, A, B):
array = []
i = j = 0
while True:
if i == len(A):
while j < len(B):
array.app... | true |
e772da07c3ddc9fecc60876b6c3c0df5b051d72a | Python | janakhpon/Datavisualization-plot | /ex002.py | UTF-8 | 639 | 3.09375 | 3 | [
"MIT"
] | permissive | import matplotlib.pyplot as plt
years = [1950, 1955, 1960, 1965, 1970, 1975, 1980, 1985, 1990, 1995, 2000, 2005, 2010, 2015, 2016, 2017, 2018, 2019]
pops = [0.00, 1.92, 2.14, 2.22, 2.37, 2.34, 2.26, 2.10, 1.71, 1.21, 1.25, 0.94, 0.67, 0.81, 0.69, 0.64, 0.61, 0.63]
deaths = [0.00, 0.77, 0.68, 0.54, 0.38, 0.23, 0.11, 0... | true |
ec29402ab0456b6c3828cae955ae009866658649 | Python | l-boisson/cv-dockers | /dockerfiles/cv-devenv/test/hello_world.py | UTF-8 | 1,867 | 2.5625 | 3 | [
"MIT"
] | permissive | # # %%
# import cv2 as cv
# import sys
# img = cv.imread("lena.tif")
# if img is None:
# sys.exit("Could not read the image.")
# cv.imshow("Display window", img)
# k = cv.waitKey(0)
# # %%
# from __future__ import absolute_import, division, print_function, unicode_literals
# # Tensorflow imports
# import tensorfl... | true |
b77a0742ab8913b3a48ef5a72045f4349fc61020 | Python | etxyc/academic-network-scraping-and-analysis | /Analysis/CNAnalysis.py | UTF-8 | 4,412 | 2.9375 | 3 | [] | no_license | '''
This file is used to generate the citation network from the MAG data in the Mongo database
'''
import pymongo as mg
import re
import networkx as nx
import numpy as np
import pickle
from collections import Counter
from DrawGraph import drawHistogramSequence
'''
This function is to get a particular category from mag... | true |
17ec3a5a73ea4295c7b2bd185f5e4c702c9574ac | Python | sevetseh28/csv_proc_async | /producer/producer.py | UTF-8 | 4,398 | 3.0625 | 3 | [] | no_license | import argparse
import csv
import json
import logging
import logging.config
import os
import re
from typing import Generator, Tuple
import chardet
from tasks import insert_person_db
def setup_logging(
default_path='logging.json',
default_level=logging.INFO,
env_key='LOG_CFG'
):
"""
Se... | true |
f8fe92b5ec2fef3c750d1f021f8feac037b18d71 | Python | ChandanShukla/Hackerrank_Solved | /Merge_The_Tools.py | UTF-8 | 210 | 2.640625 | 3 | [] | no_license | from collections import OrderedDict
def merge_the_tools(string, k):
chunks = [string[i:i+k] for i in range(0, len(string), k)]
for chunk in chunks:
print ("".join(OrderedDict.fromkeys(chunk))) | true |
0ca9e24404185874b6655e2fb6980840cc603306 | Python | by777/python-mooc-ml-pratice | /分类/上证指数涨跌预测-svm.py | UTF-8 | 2,651 | 3.640625 | 4 | [] | no_license | # -*- coding: utf-8 -*-
"""
Created on Mon Jul 27 22:24:54 2020
@author: Xu Bai
上证指数涨跌预测
实验目的:
根据给出时间前150天的历史数据,预测当天上证指数的涨跌
技术路线:
sklearn.svm.SVC
选取5列特征:
收盘价、最高价、最低价、开盘价、成交量
------------------------------
交叉验证思想
先将数据集D划分为k个大小相似的互斥子集,每个子集都尽可能保持数据分布的一致性,
即从D中通过分层采样得到。
然后,每次用k-1个子集的并集作为训练集,余下的那个子集作为测试集;
这样就可以获得k组训练/测试集,... | true |
5ce05a1e61cd3b0d2b68e083afa716469ba397f5 | Python | tech-with-veena/snake-games | /snake.py | UTF-8 | 1,345 | 3.625 | 4 | [] | no_license | from turtle import Turtle
startingpositions=[(0,0),(-20,0),(-40,0)]
movedistance=20
up=90
down=270
left=180
right=0
class Snake:
def __init__(self):
self.segments=[]
self.createsnake()
self.head=self.segments[0]
def createsnake(self):
for position in startingposition... | true |
1a0c6e8ce11a16b50bac1d9db20ae213fbbfaa3e | Python | AthenaTsai/Python | /python_K_exercise/exercise_kevin.py | UTF-8 | 1,214 | 3.125 | 3 | [] | no_license |
##ex1
##
##member_with_error = ['sam_liao@payez.com.tw',
## 'kevin_chen@payez.com.tw',
##‘I_LOVE_SAM',
## 'jc_wang@payez.com.tw', '456']
##
## ['sam_liao@payeasy.com.tw', 'kevin_huang@payeasy.com.tw',
## 'jc_wang@payeasy.com.tw']
##
##1. create list variable member_without_error to store data
##2. for loop member_... | true |
0b4a723a8c38d3404dec74821306afda62e39ab8 | Python | murakumo512/aaaa | /6.py | UTF-8 | 77 | 3 | 3 | [] | no_license | max = 0
for a in [10,9,13,17,2,1]:
if a > max:
max = a
print(max) | true |
374c6f28ec3061ec24174c4cd2d07bd6f2402425 | Python | galviset/hen-manager | /henmanager/rcontrol.py | UTF-8 | 1,841 | 3.078125 | 3 | [] | no_license | import RPi.GPIO as GPIO
import Adafruit_DHT
class Device():
def __init__(self, label, *args):
"""
Add a device controlled by relay(s).
:param label: name of the device (string)
:param *args: GPIO pin number(s) (int)
"""
self.name = label
self.relays = []
... | true |
18d2d8615d2a126dcd35585c8f491705b7c2c3da | Python | clarelaroche/python_AtlasOEM_lib | /OEM_PH_example.py | UTF-8 | 915 | 2.96875 | 3 | [
"MIT"
] | permissive | from AtlasOEM_PH import AtlasOEM_PH
import time
def main():
PH = AtlasOEM_PH() # create an OEM PH object
PH.write_active_hibernate(1) # tell the circuit to start taking readings
while True:
if PH.read_new_reading_available(): # if we have a new reading
pH_reading = PH.re... | true |
929300ab9483ef896d94a7f2c30b3fdc454e2b71 | Python | Tony-Y/cgnn | /src/cgnn.py | UTF-8 | 10,101 | 2.546875 | 3 | [
"Apache-2.0"
] | permissive | # Copyright 2019 Takenori Yamamoto
#
# 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 applicable law or agre... | true |
c13e7bf89f403b5683157fca74e549b9c3cb61fe | Python | shanavas786/coding-fu | /python/foobar/tree.py | UTF-8 | 475 | 3.28125 | 3 | [
"LicenseRef-scancode-public-domain"
] | permissive | #!/usr/bin/env python3
cache = {}
def par_index(root, i):
if i in cache:
return cache[i]
if i == root:
return -1
left = root // 2
if (i == left) or i == (root - 1):
return root
if i < left:
return par_index(left, i)
else:
return left + par_index(left,... | true |
a9ce1021ce950743d58844233131aae62cdddbda | Python | mcastrov78/ucr-ml-lab3 | /mnist_digits.py | UTF-8 | 8,912 | 3.21875 | 3 | [] | no_license | import read_idx
import lab3
import torch
import torch.nn as nn
import torch.optim as optim
from sklearn.metrics import confusion_matrix
from sklearn.metrics import precision_score
from sklearn.metrics import recall_score
from sklearn.metrics import classification_report
# use None to process all images
NUMBER_OF_IMAGE... | true |
02b7ed4222112fcb147cc0fcab6dc6b85d5e875e | Python | bloXroute-Labs/bxcommon | /test/unit/utils/test_expiration_queue.py | UTF-8 | 4,187 | 3.171875 | 3 | [
"MIT"
] | permissive | import time
import unittest
from mock import MagicMock
from bxcommon.utils.expiration_queue import ExpirationQueue
class ExpirationQueueTests(unittest.TestCase):
def setUp(self):
self.time_to_live = 60
self.queue = ExpirationQueue(self.time_to_live)
self.removed_items = []
def test_... | true |
345c90a4d884c90e78039a8b7b37903cea45879c | Python | victor8504/Password-Locker | /tester_test.py | UTF-8 | 3,577 | 3.203125 | 3 | [
"MIT"
] | permissive | import pyperclip # Impporting the pyperclip module
import unittest # Importing the unittest module
from tester import User #Importing the user class
class TestUser(unittest.TestCase):
'''
Test class that defines test cases for the user class behaviours.
Args:
unittest.Testcase: TestCase class... | true |
99c10717fb45b38ed64a5b91c294c5996eccd2e4 | Python | kobaltkween/python2 | /Lesson 03 - Test Driven Development/testadder.py | UTF-8 | 997 | 4.09375 | 4 | [] | no_license | """
Demonstrates the fundamentals of unittest.
adder() is a function that lets you 'add' integers, strings, and lists.
"""
from adder import adder # keep the tested code separate from the tests
import unittest
class TestAdder(unittest.TestCase):
def testNumbers(self):
self.assertEqual(adder(3,4), 7,... | true |
08967275e0b70c4b93b0c517a738217cfdbc15d2 | Python | rehrler/rguard | /src/sensor/capture_data.py | UTF-8 | 1,351 | 2.75 | 3 | [] | no_license | import sqlite3
import time
import datetime
from scd30_i2c import SCD30
class SensorInterface(object):
def __init__(self):
self.scd30 = SCD30()
self.scd30.set_measurement_interval(2)
self.scd30.set_auto_self_calibration(active=True)
time.sleep(5)
self.scd30.start_periodic_m... | true |
df0d7e15319dc251c1dff76bdd51cb33c45c72bc | Python | jarvyii/techroom | /techroom.py | UTF-8 | 1,820 | 2.984375 | 3 | [] | no_license | import os
import sqlite3
from database import *
from login import *
from sqlite3 import Error
from modeltechroom import *
#This is to use function from login.py files
def create_connection(db_file):
""" create a database connection to the SQLite database
specified by the db_file
:param db_file: databas... | true |
74bcf28aa7815bd795d632a6e06ebf3ede2b1156 | Python | qangelot/streamlitNyc | /apps/app2.py | UTF-8 | 1,791 | 2.953125 | 3 | [] | no_license | import pydeck as pdk
from utils.utils import timed, df, st
import numpy as np
# CREATING FUNCTION FOR MAPS
@timed
def map(data, lat, lon, zoom):
st.write(pdk.Deck(
map_style="mapbox://styles/mapbox/light-v9",
initial_view_state={
"latitude": lat,
"longitude": lon,
... | true |