blob_id large_string | repo_name large_string | path large_string | src_encoding large_string | length_bytes int64 | score float64 | int_score int64 | detected_licenses large list | license_type large_string | text string | download_success bool |
|---|---|---|---|---|---|---|---|---|---|---|
0df61dc635835ce29e970287efff026b9c44aee3 | Skuttokova/tdd23medusa | /main.py | UTF-8 | 12,843 | 2.703125 | 3 | [] | no_license | import pygame, sys
import events
from random import randrange
from pygame.locals import *
class Main(events.Event):
def __init__(self):
self._running = True
self._display_surf = None
self._set_image = None
self._credit_screen = None
self._set_start_text = None
self.vi... | true |
0d4b822f86d434a5a8b3e17341ed75b7b108dc37 | senties-31/pythonEnero2018 | /Intermedio/ManejoFicheros/Formatos/ejJSON.py | UTF-8 | 304 | 2.96875 | 3 | [] | no_license | import json
print(json.dumps(["e1",{"sub1":(0,None,1.0)}]))
nombres='{"primerNombre":"Alan","apellido":"Garrido"}'
obj=json.loads(nombres)
print(obj['primerNombre'])
infile=open("marks.json")
archivo=infile.read()
print(archivo)
objson=json.loads(archivo)
print(objson['markers'][0]["information"]) | true |
5c6378eb5da2df2b4a97d30c5dd3c79764ad89c9 | MikhailFourtyn/SorokinPython | /Prj1-HelloWorld/Lesson2_Arrays/SwapAdjacentEls.py | UTF-8 | 182 | 3.3125 | 3 | [] | no_license | n = int(input())
A = list(map(int, input().split()))
for i in range(1, n, 2):
temp = A[i - 1]
A[i - 1] = A[i]
A[i] = temp
for i in range(n):
print(A[i], end = ' ') | true |
99cce328ea70da4573d15a5e658df038633fd67d | jclifton333/spatial-RL | /src/estimation/optim/utils.py | UTF-8 | 1,348 | 2.703125 | 3 | [] | no_license | import math
import numpy as np
from itertools import combinations
from src.utils.misc import onehot
def nCk(n, r):
f = math.factorial
return f(n) / f(r) / f(n - r)
def num_candidate_states(evaluation_budget, treatment_budget):
"""
:return num_candidates: number of actions we can afford to evalu... | true |
35d15bd8067be34de8f0cb1a06a728a9d245f7d8 | Wzy-source/Data-Science-Assignment | /WzySpiderProject/NewsHeadlines/BaiDuNewsSpider/BaiDu.py | UTF-8 | 2,379 | 2.703125 | 3 | [] | no_license | import re # 正则表达式,进行文字匹配
import urllib.request, urllib.error # 网页源码的获取
from bs4 import BeautifulSoup
import xlwt
import urllib.request, urllib.error # 网页源码的获取
from bs4 import BeautifulSoup
import requests
import json
def main():
dataList = []
baseURL1 = "https://m.baidu.com/sf/vsearch?word=%E7%96%AB%E6%83%... | true |
fd8bdebd3ced602bcd8fecf304287b76cc7ecf0e | HaroldMills/Vesper | /vesper/util/yaml_preset.py | UTF-8 | 488 | 2.8125 | 3 | [
"MIT"
] | permissive | """Module containing class `YamlPreset`."""
from vesper.util.preset import Preset
import vesper.util.yaml_utils as yaml_utils
class YamlPreset(Preset):
"""Abstract superclass for YAML presets."""
def __init__(self, name, data):
# Parse YAML into a Python data structure.
... | true |
f7dee4696fc2eb60627c6726ab25ce1b432a30e4 | twb1235/twinkle | /中文分词+词性标注-基于HMM/代码/evaluate.py | UTF-8 | 3,607 | 2.84375 | 3 | [] | no_license | from models import ShortTokenizer
from models import HmmToken
from models import HmmPosTag
from tqdm import tqdm
def word_segmentation_eval(trainfile):
#评估分词模型
with open(trainfile, 'r', encoding='utf8') as f:
dataset = [line.strip().split(' ') for line in f.readlines()]
dataset = dataset[0:6000]
... | true |
69b1d39c7799a7826775b22044eec7248e50e383 | cgarwood/python-openzwave-mqtt | /script/dump_mqtt.py | UTF-8 | 1,562 | 2.625 | 3 | [
"Apache-2.0"
] | permissive | #!/usr/bin/env python3
"""Dump mqtt output."""
import argparse
import logging
from threading import Timer
from typing import Any
try:
import paho.mqtt.client as mqtt
except ImportError:
mqtt = None
def get_args() -> argparse.Namespace:
"""Get arguments."""
parser = argparse.ArgumentParser(description... | true |
e3c5cffb9fbde1dd5bbaf96b3137bd24724c7a29 | aschuster3/slackbotbot-source | /the-birth-of-slackbotbot/more.py | UTF-8 | 3,611 | 3.09375 | 3 | [
"MIT"
] | permissive | from breezycreate2 import Robot
import time
from datetime import datetime
# To elaborate a little more as to what this is,
# the note variable reflects the note that we want to
# play, the duration corresponds to how long we want
# the note to play, and the eighths variable tells
# us how long an eighth note is held (... | true |
775ff3475b9a4b16cada56763d445d95622ba415 | rpm1995/LeetCode | /905_Sort_Array_By_Parity.py | UTF-8 | 394 | 3.296875 | 3 | [
"MIT"
] | permissive | class Solution:
def sortArrayByParity(self, A: List[int]) -> List[int]:
n = len(A)
ans = [0 for _ in range(n)]
start = 0
end = n - 1
for integer in A:
if integer % 2 == 0:
ans[start] = integer
start += 1
else:
... | true |
1c316f2e0293304605937e2f5b8c592317ed6e77 | mingrener/mygit | /learnPython/python基础-02/06-隐藏属性.py | UTF-8 | 258 | 3.859375 | 4 | [] | no_license | class Dog:
def set_age(self, new_age):
if new_age>0 and new_age<100:
self.age = new_age
else:
self.age = 0
def get_age(self):
return self.age
dog = Dog()
dog.set_age(-10)
age = dog.get_age()
print(age)
| true |
466bdddeb727709fb77c11a1e42931c91571f8b0 | prabodhprakash/problemsolving | /spoj/lastdig.py | UTF-8 | 494 | 3.328125 | 3 | [] | no_license | # http://stackoverflow.com/questions/7214419/how-to-find-the-units-digit-of-a-certain-power-in-a-simplest-way
table = [0, 0, 0, 0, 1, 1, 1, 1, 6, 2, 4, 8, 1, 3, 9, 7, 6, 4, 6, 4, 5, 5, 5, 5, 6, 6, 6, 6, 1, 7, 9, 3, 6, 8, 4, 2, 1, 9, 1, 9]
noInputs = int(input())
for i in range(0, noInputs):
ab = list(map(int, i... | true |
9859c4d12ebbd4f11d47b26aadd6e5816b10c2e2 | ystk/debian-redhat-cluster | /fence/agents/rsb/fence_rsb.py | UTF-8 | 10,895 | 2.53125 | 3 | [] | no_license | #!/usr/bin/python
import getopt, sys
import os
import socket
import time
import atexit
from telnetlib import Telnet
TELNET_TIMEOUT=30 #How long to wait for a response from a telnet try
MAX_TRIES = 20
# WARNING!! Do not add code bewteen "#BEGIN_VERSION_GENERATION" and
# "#END_VERSION_GENERATION" It is generated by ... | true |
c9dc30d08abf2bb1842e291cbf6d424cf2c93d68 | sam-ng/Tile-Problem-Solver | /Code/Heuristics.py | UTF-8 | 1,202 | 3.703125 | 4 | [] | no_license | # Samuel Ng 112330868
# CSE 352 Assignment 1
class Heuristics:
def __init__(self, H):
self.H = H
self.h_cost = 0
# function wrapper that chooses one of the heuristic functions based on H
def heuristic_cost(self, state, goal):
if self.H == 1:
self.h_cost = self.heuristic1(state, goal)
elif ... | true |
dbb82be27720ed9616d8662ffa4630cb16c42497 | mcshakes/bits_and_pieces | /data_structs_algos/graph/breadth_first_search.py | UTF-8 | 285 | 2.796875 | 3 | [] | no_license | from graph import Graph
from vertex import Vertex
from queue.queue import Queue
def bfs(g, start):
start.set_distance(0)
start.set_pred(None)
vert_queue = Queue()
vert_queue.enqueue(start)
while vert_queue.size() > 0:
current_vert = vert_queue.dequeue()
| true |
5eba8012bae0e69f72a0174514dadfe6480e5fe6 | murali-kotakonda/PythonProgs | /PythonBasics1/basics/oops/Ex5.py | UTF-8 | 908 | 4.28125 | 4 | [] | no_license | """
create a class with id, anme , age as instance variables.
create 3 objs , set data and display.
simplify the display logic for objects.
solution:
write a function that takes object as input argument for dispalying thge obj data
"""
#write a function that takes obj as input arg
def display(pObj):
print(pObj... | true |
441aad1c969c9374edbf465b206fd0f22c7d1246 | Arielcarv/Intro-Ciencia-da-Computacao-USP | /Part 1/Week 6/NIM Game.py | UTF-8 | 3,159 | 4.34375 | 4 | [
"MIT"
] | permissive | # n o número de peças inicial
# m o número máximo de peças que é possível retirar em uma rodada.
def computador_escolhe_jogada(n, m):
if m == n:
jogada_computador = n
elif (n % (m + 1)):
jogada_computador = (n % (m + 1))
else:
jogada_computador = m
if jogada_computador == 1:
... | true |
60483af7ed507d56209dd7032b14351852ece796 | dozingLee/Preprocess-data | /pascal_sentence_dataset.py | UTF-8 | 5,090 | 2.78125 | 3 | [] | no_license | from urllib.parse import urljoin
from pyquery import PyQuery
import os
import requests
import csv
import pandas as pd
from sklearn.model_selection import train_test_split
class PascalSentenceDataSet:
DATASET_DIR = 'dataset/'
SENTENCE_DIR = 'sentence/'
PASCAL_SENTENCE_DATASET_URL = 'http://vision.cs.uiuc.e... | true |
e736932075a94b5e29a2635cd17fdd90fceeb124 | mantissa-aidan/TwoUp | /gym/gym/envs/aidan_envs/two_up.py | UTF-8 | 3,951 | 2.96875 | 3 | [
"MIT"
] | permissive | import numpy as np
import gym
from gym import spaces
from gym.utils import seeding
def flip(np_random):
return 1 if np_random.uniform() < 0.5 else 0
def subset_sum(numbers, target, partial=[], partial_sum=0):
if partial_sum <= target:
yield partial
if partial_sum >= target:
return
for... | true |
38e2d7a3095cd121702ff4ad0376b3d2f41889dd | mghasemi/Irene | /examples/Parsopoulos.py | UTF-8 | 1,083 | 3.0625 | 3 | [
"MIT"
] | permissive | """
Minimize the Parsopoulos function
"""
from scipy.optimize import minimize
from pyswarm import pso
from sympy import *
from Irene import *
x = Symbol('x')
y = Symbol('y')
s1 = Symbol('s1')
c1 = Symbol('c1')
s2 = Symbol('s2')
c2 = Symbol('c2')
f = c1**2 + s2**2
rels = [s1**2 + c1**2 - 1, s2**2 + c2**2 - 1]
Rlx = SDPR... | true |
1b40d66aa8347fa4ad889ed85106993c7e779de2 | bunjj/Catadioptric-Stereo | /intrinsics.py | UTF-8 | 11,692 | 2.796875 | 3 | [] | no_license | import cv2
import numpy as np
from utils import *
from FrameIterator import FrameIterator
def calibrateChessboard(
filepattern,
chess_size,
tile_size,
split_position=None,
partition=None,
flip=False,
scale=1.0,
verbose=0,
show=False,
):
"""
Compute the camera intrinsics... | true |
945da3ab22072b88810c24cee5d6bae53c313089 | sxhmilyoyo/Algorithm_Python | /stringMatchRecursive.py | UTF-8 | 1,713 | 3.90625 | 4 | [] | no_license | # recursive version
# match string that contains the wildcast
class Trie:
def __init__(self):
self.children = {}
self.isWord = False
def insert(self, word):
if word == '':
self.isWord = True
return
if word[0] not in self.children.keys():
... | true |
b3b94dce04a1c672aba4f87da4b92ca19b30b657 | Takkoyanagi/insight_computer_vision | /preprocessing/find_duplicate_images.py | UTF-8 | 1,631 | 3.125 | 3 | [
"MIT"
] | permissive | from image_hashing import hash_image
from PIL import Image
import os
# load the list of categories to download
labels = [labels.rstrip('\n') for labels in open('key_words_updated.txt')]
# create a list of filenames in the directory "image_path"
image_path = []
for label in labels:
image_path.append("/home/tk/Doc... | true |
7f8907fe6c04c18786204438a528d07eb1af9b3a | calliope-project/calliope | /calliope/backend/where_parser.py | UTF-8 | 19,814 | 2.609375 | 3 | [
"Apache-2.0"
] | permissive | # Copyright (C) since 2013 Calliope contributors listed in AUTHORS.
# Licensed under the Apache 2.0 License (see LICENSE file).
from __future__ import annotations
import operator
from typing import Any, Union
import numpy as np
import pandas as pd
import pyparsing as pp
import xarray as xr
from calliope.backend imp... | true |
19b85caf7de54cdea2329fd53a15b9d908ad40ba | sK4rdell/A2C-synchronised-advantage-actor-critic | /src/model/a2c.py | UTF-8 | 3,018 | 2.578125 | 3 | [] | no_license | import torch
import torch.nn as nn
import torch.nn.functional as F
import torch.autograd as autograd
from torch.autograd import Variable
import numpy as np
def weights_init(m):
if isinstance(m, nn.Conv2d):
weight_shape = list(m.weight.data.size())
fan_in = np.prod(weight_shape[1:4])
fan_ou... | true |
fe6ffff15874cd72ba057698cc729af51b6c49f4 | mehradans92/nlcc | /nlcc/openai.py | UTF-8 | 1,146 | 2.90625 | 3 | [] | no_license | import openai
import os
openai.api_key = os.getenv('OPENAI_API_KEY')
def code_engine(query, T=0.00, stop=None, n=1):
response = openai.Completion.create(
engine="davinci-codex",
prompt=query,
temperature=T,
max_tokens=64,
top_p=1,
frequency_penalty=0.0,
pre... | true |
388762d209b35939d803ef8114652353177069d7 | inwk6312winter2019/week4labsubmissions-likithpoluparthi | /lab4task3.py | UTF-8 | 843 | 3.3125 | 3 | [] | no_license | import string
count=0
d=dict()
d1=dict()
fin=open("book1.txt")
fin2=open("words.txt")
for line in fin:
line=line.strip()
line=line.lower()
line=line.split()
#print(line)
for word in line:
count+=1
x=(word.strip(string.punctuation))
#print(x)
if word not in d:
d[word]=1
else:
d[... | true |
fd9b615b0d3da3f89b241d5c2f32dffddfbd80dd | looking123456/mypython | /src/testDraw/mylinregress.py | UTF-8 | 3,120 | 2.921875 | 3 | [] | no_license |
import numpy as np
import pylab
from scipy import stats
import pandas as pd
from pandas.core.frame import DataFrame
from matplotlib.pyplot import plot
def myLinregree(data):
bb = range(0,len(data));
x = np.array(bb);
y = data
print("x=",x)
print("y=",y)
print("................... | true |
c08552e114b553ccf5229337c8293325dca91e17 | szabgab/code-maven.com | /examples/python/cli/prompt.py | UTF-8 | 237 | 2.765625 | 3 | [] | no_license | from cmd import Cmd
class MyPrompt(Cmd):
prompt = 'pb> '
intro = "Welcome! Type ? to list commands"
def do_exit(self, inp):
'''exit the application.'''
print("Bye")
return True
MyPrompt().cmdloop()
| true |
d321242c055718eae47a05526796e95f37aa62d2 | rathorevipul28/udapter | /scripts/evaluate_feats.py | UTF-8 | 4,343 | 2.671875 | 3 | [
"MIT"
] | permissive | #!/usr/bin/env python
"""Evaluation for the SIGMORPHON 2019 shared task, task 2.
Computes various metrics on input.
Author: Arya D. McCarthy
Last update: 2018-12-21
"""
import argparse
import logging
import numpy as np
from collections import namedtuple
from pathlib import Path
log = logging.getLogger(Path(__file... | true |
a11c6fac3f8edc253ed0ad722d0b77e676fe65f3 | mitchlyon/assignment | /unit2.py | UTF-8 | 170 | 3.875 | 4 | [] | no_license | # question 1
fahrenheit = eval(input("what is the fahrenheit temperature:"))
celsius = (fahrenheit - 32) / 1.8
print("the temperature is", celsius, "degrees celsius" ) | true |
2fc5b588f01b9d10019b7f780c85dbf093549884 | gaofeng1998/python | /绘图报告.py | UTF-8 | 11,891 | 2.9375 | 3 | [] | no_license | # -*- coding: utf-8 -*-
"""
Created on Wed Dec 27 14:16:26 2017
@author: gaofeng
"""
import pandas as pd
import numpy as np
import matplotlib.pyplot as plt
from pylab import mpl
f= pd.read_csv(r"C:\Users\gaofeng\Desktop\data\datacut.csv",encoding = 'utf-8')
#性别分布
def Gender_distribution():
plt.bar(range(2),f.性... | true |
ede6ad5bcbcd1b7f9fdd065a7bcec758127bad4e | EgorSys/Homework | /HW2.py | UTF-8 | 1,457 | 3.625 | 4 | [] | no_license | import math
#read dimension
dim = int(input())
#read vector
vec = list(map(float, input().split()))
if len(vec) != dim:
print('Incorrect dimension!')
exit()
#calculate length
length = len(vec)
#scale by input constant
def scale(vec, c):
ans = [el*c for el in vec]
return ans
scaled_vector = scale(vec... | true |
6cd272cc938bfa9be98f6a4c5b9917389a4ef98b | shashi278/Virtual-Music | /music_playing/main.py | UTF-8 | 10,976 | 2.609375 | 3 | [
"MIT"
] | permissive | import numpy as np
import cv2
from collections import deque
#from kivy.core.audio import SoundLoader
from pygame import mixer
import os
from tensorflow.python import framework
PATH = os.path.dirname(os.path.abspath(__file__))
piano2 = os.path.join(PATH, "assets", "piano2")
class Music():
already_in_blue = Fa... | true |
e49a7d4d6590634e59942920e5f57b665aa6efe7 | Amnonop/voice-corruption-classifier | /siamese_loader.py | UTF-8 | 3,227 | 2.609375 | 3 | [] | no_license | import pickle
from pathlib import Path
import numpy as np
import torch
from torch import Tensor
import librosa
from sklearn.utils import shuffle
from commons import SAMPLE_SIZE
CSV_FILENAME_PREFIX = 'siamese_speakers_{0}.csv'
DATASET_FILE_FORMAT = 'siamese_{0}_{1}.npy'
class SiameseLoader:
_data_subsets = ['tr... | true |
e93b522c8722c149de42ffe6607fea9d348ab430 | Sibula/pythonlike | /pythonlike/src/entity.py | UTF-8 | 4,164 | 2.765625 | 3 | [
"MIT"
] | permissive | import random
import tcod
import numpy as np
class Entity:
def __init__(self, x, h, name, char, color, b_armor, b_armor_res, attributes, equipment={}):
self.x = x
self.h = h
self.name = name
self.char = char
self.color = color
self.constitution = attributes[0]
... | true |
ef71ee0d1a9fd2e71ae64f760eee0b7dee5affe2 | lemoncrest/learn-pygame-games | /data/states/load_screen.py | UTF-8 | 985 | 2.53125 | 3 | [] | no_license | import pygame as pg
from data import setup, tools
from data.constants import *
class Load_Screen(tools._State):
def __init__(self):
tools._State.__init__(self)
def startup(self, current_time, persistant):
self.next = "FIRST_LEVEL"
self.surface = pg.Surface(SCREEN_SIZE)
self.re... | true |
d91fd04db0382c5d9bcffaffec3eb8769b919ea0 | lzxin96/python_spider | /src/urllib/urljoindome.py | UTF-8 | 841 | 3.4375 | 3 | [] | no_license | from urllib.parse import urljoin
# urljoin(base_url, url)
# base_url:基URL,只能设置scheme、netloc、path
# url:不是一个完整的URL,会将第2个参数的值加到第1个参数后面,自动补齐(/);如果第2个参数为完整的URL,则直接返回第2个参数的值
# 输出https://www.jd.com/index.html
print(urljoin('https://www.jd.com','index.html'))
# 输出https://www.taobao.com
print(urljoin('https://www.jd.com','ht... | true |
5648bb9dc4709da8378664b811213ec112a15b42 | ibews/NSS | /uebung9/aufgabe2.py | UTF-8 | 3,430 | 2.515625 | 3 | [] | no_license | # -*- coding: utf-8 -*-
"""
Created on Tue Dec 17 16:46:56 2013
@author: ibews
"""
grammar = nltk.parse_fcfg("""
% start S
# Grammar Productions
S -> NP[CASE=?c, AGR=?a]
NP[CASE=?c, AGR=?a] -> N[CASE=?c, AGR=?a]
NP[CASE=?c, AGR=?a] -> ADJ[CASE=?c, D=?d, AGR=?a] N[CASE=?c, AGR=?a]
NP[CASE=?c, AGR=?a] -> Det[CASE... | true |
5eb66160c0b4b6a188e85f759829f9f40a2f1b76 | mdu2017/6pool | /graphs.py | UTF-8 | 8,172 | 2.859375 | 3 | [] | no_license | import streamlit as st
import altair as alt
import pandas as pd
import numpy as np
import loader
import damage
"""
This file contains methods for drawing the graphs on the page
"""
CHART_WIDTH = 700
CHART_HEIGHT = 550
CHART_FONT_SIZE = 16
CHART_LABEL_SIZE = 18
BAR_COLOR = 'steelblue'
# BAR_COLOR = '#82CEB7'
BAR_HIGH... | true |
a81b3b3a27ede1b4d4e50ad8893775a64d0d547f | jiankangren/abstract-value-iteration | /sarl/main/smdp.py | UTF-8 | 3,059 | 2.625 | 3 | [] | no_license | from util.rl import test_policy, get_rollout
import numpy as np
# global constants
R_MAX = 1000000.
# class representing a semi-markov decision process
# expected reward and probabilities are estimated from sample runs
class SMDP:
# abstract_map: implements get_abstract_state(state) - maps concrete state to ab... | true |
05b3b5f6193c55711f4973a453807a1e1bcd202a | merose/tabletop | /util/show-hough | UTF-8 | 8,241 | 3.125 | 3 | [
"BSD-3-Clause"
] | permissive | #! /usr/bin/env python
from __future__ import print_function
import sys
import time
import cv2
import numpy as np
from math import sin, cos, tan, acos, atan2, pi
def show_time(caption, start):
print('{0}: {1:.3f} sec'.format(caption, time.time() - start))
def near(p1, p2, max_dist):
d_squared = (p1[0] - p2[0... | true |
728b5987ff90575798f94047286ca04f51dc6f94 | Altynai/imdb | /tool.py | UTF-8 | 1,984 | 2.9375 | 3 | [] | no_license | #!/usr/bin/env python
# -*- coding: utf-8 -*-
from RedisCommand import getRedisCommand
def string2int(string):
try:
return int(string)
except ValueError:
return string
def isRedisCommand(command):
commands = getRedisCommand()
arglist = command.split(' ')
argv = len(arglist)
commandType = arglist[0].lower(... | true |
aac01a7fda60b75b3e5494306b4aba63a26dae60 | brianretford/nnvm-rocm | /mxnet_imagenet_inference.py | UTF-8 | 2,521 | 2.515625 | 3 | [
"MIT"
] | permissive | """://mxnet.incubator.apache.org/versions/master/api/python/gluon/model_zoo.html
The list of available gluon models are here
https://mxnet.incubator.apache.org/versions/master/api/python/gluon/model_zoo.html
So far, we confirmed that the model alexnet, resnet18_v1, resnet50_v1 can be loaded to nnvm
Other models do not... | true |
37fda06a1b761b5d112dcb9d14624ec7b409de79 | gabibu/pymong | /coursesManagment/coursesManagment/dal/studentsDal.py | UTF-8 | 2,343 | 2.578125 | 3 | [] | no_license |
#from pymongo import MongoClient
from .dbconnection import client
from bson.objectid import ObjectId
#client = MongoClient('localhost', 27017)
db = client.UniversityDB
class StudentsDal:
def insert(self, name, age, studentId):
return db.Students.insert_one(
{
"_id": studen... | true |
cc25aef0d26250f04a8794acc6de87e9f6c00ac3 | Hrishikesh-3459/leetCode | /prob_724.py | UTF-8 | 212 | 2.9375 | 3 | [] | no_license | class Solution:
def pivotIndex(self, nums: List[int]) -> int:
for i, num in enumerate(nums):
if (sum(nums[:i]) == sum(nums[i+1:])):
return i
return -1
| true |
586bc933b885d38c2016d744b36eed45feaa2d25 | ExQA/WebAcademyPython | /include/python_year.py | UTF-8 | 225 | 3.15625 | 3 | [] | no_license | YEAR_PYTHON = 1991
DELTA = 10
year_user = float(input(">>>>>> "))
delta_usr = abs(year_user - YEAR_PYTHON)
if delta_usr ==0:
print("Goood!!!")
elif delta_usr <= DELTA:
print("Almost win!!")
else:
print("no win") | true |
44a6ecdebf8c277e7f6ab51e9c0b4b0c33996465 | li630925405/buaa-ML | /team/facedetect.py | UTF-8 | 8,406 | 2.59375 | 3 | [] | no_license | # -*- coding: utf-8 -*-
"""
Created on Thu Dec 12 19:49:16 2019
@author: 27221
"""
import numpy as np
import tensorflow as tf
import cv2
from PIL import Image
#TRAIN_FILE = 'training.csv'
TEST_FILE = 'test.csv'
SAVE_PATH = './model2' #模型保存路径
VALIDATION_SIZE = 100 #验证集大小 TRAIN_NUM * 0.3
EPOCHS = 1 ... | true |
cfa869f624b1cfc74fa134bff76978a175dbe411 | brettrick4/TTA_Basic_Python_Projects | /osModule.py | UTF-8 | 1,241 | 3.09375 | 3 | [] | no_license | import os
items = os.listdir("C:\sqlite\db\pythonsqlite.db")
print(items)
# This lists the contents of the directory in pythonsqlite.db
newlist = []
for names in items:
if names.endswith(".txt"):
newlist.append(names)
print(newlist)
# This lists the text files in the directory that end with ".txt"
fName =... | true |
337714e8148ee8c82f80c063dfaa15b16dd6833c | htadigadapa/Inmar_CodingTest | /Solution_Q2.py | UTF-8 | 99 | 4.3125 | 4 | [] | no_license |
input_string=input("Enter a string:")
print("Reverse of given string is: "+input_string[::-1])
| true |
74833adcd869056b977ae227be716bec8e4a2299 | kaki1104/Su-CS550 | /bankaccount.py | UTF-8 | 1,093 | 4.15625 | 4 | [] | no_license | #bankaccount
class Bankaccount :
def __init__ (self, name, number, pin, balance) :
self.name = "Kaki"
self.number = 13474062
self.pin = 1104
self.balance = 0
def deposit (self):
self.balance += float(amount)
status = "You have deposited "+amount+" dollars."
return status
def withdraw (self):
if ... | true |
96ad2eaef3b8dda1e88211c37a43e7b836afa29d | rafpaf/OpenHatch | /mysite/base/unicode_sanity.py | UTF-8 | 837 | 2.734375 | 3 | [] | no_license | ### I will not be afraid of Unicode.
### I do want to monkey-patch away Python stdlib functions
### that stress me out.
### Sadly our dependencies use them, so I can't.
import urllib
import mysite.base.decorators
_urlencode = urllib.urlencode
def urlencode(unicode_dict):
utf8_dict = {}
bad_keys = []
ba... | true |
6b3b0177d50e56c19c76226b5528396466d683c6 | bogipeneva/-Programming-101-Python-2019 | /week07/with_performance.py | UTF-8 | 618 | 3.015625 | 3 | [] | no_license | import datetime
import time
from time import sleep
from contextlib import contextmanager
@contextmanager
def performance(file_name):
start_time = time.time()
yield
file = open(file_name, 'a')
current_time = datetime.datetime.fromtimestamp(time.time()).strftime('%Y-%m-%d %H:%M:%S')
... | true |
f440a87f2f9b8784cfc95e351aa7956061923bae | thuyvyng/CS160 | /labs/lab6/lab6_4.py | UTF-8 | 550 | 3.359375 | 3 | [] | no_license | def userinput():
flist = []
blank = ""
askf = int(input("How many fruits? "))
for x in range(askf):
fruits = input("Enter fruit: ")
pounds = input("Enter number of pounds of " + fruits+ " : " )
flist.append([fruits,pounds])
# print(flist)
for i in range(len(flist)):
for j in range(len(flist)):
if fl... | true |
0e9a45496491eaf983711c6c4e100e385b0289f6 | stevenMevans/fonduer | /fonduer/supervision/lf_helpers/structural.py | UTF-8 | 6,007 | 3.28125 | 3 | [
"MIT"
] | permissive | ############################
# Structural modality helpers
############################
from builtins import str
import numpy as np
from lxml import etree
from lxml.html import fromstring
from fonduer.candidates.models import TemporarySpan
def get_tag(span):
"""Return the HTML tag of the Span.
If a candid... | true |
3431595002b129e05cdb0053da1943818e18042b | tangzhoutz/baseAPI | /dataManager/yamlManager.py | UTF-8 | 3,767 | 2.640625 | 3 | [] | no_license | # -*- coding: utf-8 -*-
# @Project : PyCharm
# @Time : 2019/3/15 9:17
# @Author : tangzhou
# @File : yamlManager.py
# @Software: PyCharm Community Edition
# @Contact : 505200187@qq.com
# @desc :
import os
import yaml
import re
import aiofiles
from utils.bxmTool import *
from configs import bxmat
async def y... | true |
ccc266f89661b09e10390478ab885d7589893de0 | cooolcai/py-0901 | /14-while循环语句/cz-while.py | UTF-8 | 1,228 | 4.25 | 4 | [] | no_license | # 序列:字符串有序排列。 通过下标偏移量可以访问到某个成员或者某介个成员。
# 序列包括:字符串、列表、元组。
# 字符串也是序列,可以使用下标记。
#chinese_zodiac = '鼠牛虎兔龙蛇马羊猴鸡狗猪'
chinese_zodiac = '猴鸡狗猪鼠牛虎兔龙蛇马羊'
#while循环当条件一直为真时,会循环后续代码块
while True:
print('a')
#使用break语句可以条出当前循环。
break
#持续打印b,知道num大于10后中止循环
num = 5
while True:
print('b')
temp = num +1
num = temp... | true |
27419de323af9087df93bb8e94c06c017fe45202 | ywang512/boto3-iris | /iris-models.py | UTF-8 | 18,402 | 2.796875 | 3 | [] | no_license | #!/usr/bin/env python
# coding: utf-8
# # Train, Evaluate and Tune Models
# In[1]:
import numpy as np
import matplotlib.pyplot as plt
import ternary
from sklearn import datasets as skdatasets
from sklearn.model_selection import train_test_split
from sklearn.preprocessing import label_binarize
from sklearn.decomposi... | true |
affab8809203e444ee90bb0d23f2fd2fcdcd9d90 | badele/reeborg-tips | /around-3.py | UTF-8 | 750 | 3.125 | 3 | [] | no_license | # Init world
# Execute two times (for select the world and execute this code)
#####################################
# !!! Around 2 and Around 3 same code
#####################################
World("Around 3")
color=255
set_trace_style("thick")
set_trace_color("rgb(%(color)s, 0, 0)" % locals())
think(100)
def turn_r... | true |
991c8c8911b09e085e882de8550262f30ec1b7ee | wylee/dotfiles | /local/bin/timer | UTF-8 | 5,038 | 3.09375 | 3 | [] | no_license | #!/usr/bin/env python3
"""A simple countdown timer.
Times can be specified in the following formats:
- S where S > 0
- M:S where M > 0 and S in [00, 59]
- H:M:S where H > 0 and M in [00, 59] and S in [00, 59]
"""
import argparse
import datetime
import re
import sys
import time
DEFAULT_MESSAGE = 'Elapsed: ... | true |
43322ba657cca5100c12038b6cf89a65a785f3ec | nishanthpp93/curation | /data_steward/cdr_cleaner/cleaning_rules/null_person_birthdate.py | UTF-8 | 5,196 | 2.546875 | 3 | [
"MIT"
] | permissive | """
Null Person Table Birth Date Fields
In the person table, the fields month_of_birth, day_of_birth, and birth_datetime should be nulled.
The year_of_birth field should remain unchanged.
Original Issue: DC-1356
"""
# Python imports
import logging
# Project imports
import constants.bq_utils as bq_consts
from cdr_cl... | true |
56219d083658d63f52f09d5560f45a059d721f6b | tangjz/acm-icpc | /51nod/1064.py | UTF-8 | 679 | 2.890625 | 3 | [
"Apache-2.0"
] | permissive | import heapq, bisect
maxn = 10 ** 100
f = {0 : 0, 1 : 1}
def F(x) :
if x in f :
return f[x]
if (x & 1) == 1 :
f[x] = F(x >> 1) + F((x + 1) >> 1)
else :
f[x] = F(x >> 1)
return f[x]
idx, val = [0], [F(0)]
que = [1]
while len(que) > 0 :
u = heapq.heappop(que)
... | true |
bf46e1fe0d3e024e1c21cf3ff23d866191871da5 | bittorrent/python-simpledb | /simpledb/models.py | UTF-8 | 12,304 | 2.84375 | 3 | [
"BSD-3-Clause"
] | permissive | import simpledb
import datetime
import uuid
import config
__all__ = ['ItemName', 'FieldError', 'Field', 'NumberField', 'BooleanField', 'DateTimeField', 'Manager', 'Model']
class FieldError(Exception): pass
class Field(object):
name = False
def __init__(self, default=None, required=False, islist=False):
... | true |
010b3c2422d9b66abd5c22eb865452c15c77cb42 | pedestrianlove/10901_Python_THU | /EX/1124/CSV_input.py | UTF-8 | 1,046 | 3.765625 | 4 | [] | no_license | def main ():
## Create a file containing all countries and areas, ordered by area.
## Display first five lines of the file.
countries = placeRecordsIntoList ("../CH5/UN.txt")
countries.sort (key = lambda country : country[3], reverse = True)
displayFiveLargestCountries (countries)
writeNewFile (countries)
def pl... | true |
3917aaca7f1d1a927f7468fe6b100b9d550f98de | vivek715/hackerearthcodemonk | /monkandsortingalgorithm.py | UTF-8 | 239 | 2.859375 | 3 | [] | no_license | # Write your code here
n = int(input())
a = list(map(int, input().split()))
max_a = max(a)
mul = 1
rem = 10**5
while max_a:
a.sort(key = lambda x: (x/mul)%rem)
print(" ".join(map(str, a)))
mul *= rem
max_a //= rem | true |
d24fe004cd98662e68036e65d12c94ec0fb186d0 | nihalshetty-boop/hyperstyle | /test/resources/inspectors/python/case16_comments.py | UTF-8 | 52 | 3.125 | 3 | [
"Apache-2.0",
"LGPL-2.0-only",
"LGPL-2.1-only"
] | permissive | n = int(input())
# n += 20
n += 10
print(n) # ok
| true |
ab711d2cdeab29b8e7200cfc904ed8995140de13 | akri16/Parallel-Huffman-Compression | /src/ui/constants.py | UTF-8 | 1,024 | 2.78125 | 3 | [] | no_license | icon_path = "../res/compress.ico"
accepted_ext = {'Text Files': '*.txt', 'Binary Files': '*.bin'}
COMPRESS = 0
DECOMP = 1
# strings
root_title = "Fast CompDe"
choose_file = "Choose File"
compress = "Compress"
decompress = "Decompress"
hello = " Hello! "
compressing = "Compressing . . . "
decompressing = "Decom... | true |
59a6a2eb991260ef98e09c5e3f764573f8fc59b4 | lalbricenov/quartaLiceo202021 | /Metodosnumericos/clase4-integrales/trapecio.py | UTF-8 | 879 | 4.1875 | 4 | [] | no_license | # programa que calcula la integral de una función usando el método
# del trapecio.
# incluyo la libreria math
import math
# Defino la función a integrar:
def f(x):
#return math.exp(x)
return math.exp(-x**2)
# Defino los extremos y el valor de n
a = -0.5
b = 0.5
n = 2000
# Calculo el ancho de cada trapecio: ... | true |
295b3961ad920c0ff978de6a72b5042379a2c01b | sananand007/RandomCompetitiveCoding | /bloomberg/Climbingstairs.py | UTF-8 | 621 | 4 | 4 | [] | no_license | '''
Climbing stairs
- 1st solution is dp, bottom up
- 2nd solution is dp, memoization
'''
class Solution(object):
def climbStairs(self, n):
if n==0 or n==1 or n==2 : return n
memo = [1,2]
for i in range(2,n):memo.append(memo[i-1]+memo[i-2])
return memo[n-1]
def climb... | true |
7c8f9a000c2a9eb48ec165495f703dfcc443693d | djkormo/k8s-AKS-primer | /apps/cat-dog-horse/app/app.py | UTF-8 | 4,051 | 2.609375 | 3 | [] | no_license | import json
import os
import io
# Imports for the REST API
from flask import Flask, request, jsonify
from flask_restplus import Api, Resource, fields, cors
from flask_cors import CORS, cross_origin
from werkzeug.datastructures import FileStorage
# Imports for image procesing
from PIL import Image
# Imports for pre... | true |
5893daa66a2a3e44a0fdda1cc23e493e268c5ec6 | btrif/Python_dev_repo | /test/test_python.py | UTF-8 | 262 | 3.46875 | 3 | [] | no_license | # import time
def test_function(x):
y = 0
for i in range(x):
y += i
return y
# t1 = time.time()
#
#
# print('test function: ' , test_function(10**7) )
#
#
# t2 = time.time()
# print('Completed in :', round((t2-t1)*1000,6), 'ms\n\n')
| true |
ad3c74e5e105a5a44e394f03c523a7a9d77fead7 | zhukovsv/Sel-15_test-repository | /Lesson11/pages/base_page.py | UTF-8 | 586 | 2.875 | 3 | [
"Apache-2.0"
] | permissive | # from selenium.webdriver.common.by import By
from selenium.webdriver.support.wait import WebDriverWait
# from selenium.webdriver.support import expected_conditions as EC
class Base_Page(object):
def __init__(self, driver):
self.driver = driver
self.driver.implicitly_wait(0)
self.wait = W... | true |
13b56695cc05328694f9be82d81c5a2887c9f30a | joe753/hello | /Database/try_db1.py | UTF-8 | 2,489 | 2.890625 | 3 | [] | no_license | import pymysql
import random
fam_names = list("김이박현하오우장정연마피고강구임허")
first_names = list("성현정민현희진영래주혜도영진선재현호시우인성마무별솔온하라")
def make_name():
sung = random.choice(fam_names)
name = "".join(random.sample(first_names, 2))
return (sung + name)
# def make_addr():
data = []
for i in range (0,100):
data.app... | true |
7d1e1fe5e2e4a6ea28c7e25cefbc4622e4cbaf26 | FrankvVeelen/EA | /main.py | UTF-8 | 6,792 | 2.734375 | 3 | [] | no_license | # Python script to run different EA algorithms on different problems. For now only TSP problem with MOEA/D
from problem_generation import Problem
from population import Population
from fitness import Fitness
from crossover import Crossover
from mutation import Mutation
from plotter import Plotter
from weights import ... | true |
9a1ceecff017e86510748f3e375d73dd3d208314 | alehat/BSUIR_python_labs | /lab_rab_2/task5_logger.py | UTF-8 | 1,100 | 3.28125 | 3 | [] | no_license | class Logger(object):
log = ""
def __getattribute__(self, item):
attr = object.__getattribute__(self, item)
if callable(attr):
def tmp_func(*args, **kwargs):
func_result = attr(*args, **kwargs)
self.log += "{func_name}({args}, {kwargs}) == {func_resu... | true |
e55bc6c4ffb50f90c6b1f4e60d78d39f8071998a | reckeen/oo_python_exercises | /ex15.py | UTF-8 | 631 | 3.703125 | 4 | [] | no_license | # import the argv method from module sys
from sys import argv
# read in the script name and one command line argument
script, filename = argv
# open the file passed in as the first arg
txt = open(filename)
# print the message and the contents of the file
print "Here's your file %r:" % filename
print txt.read()
# print ... | true |
81c557b04d40e7c3ac9575ed0af2a05b41d5d754 | Bourdonn/Projet-Python | /graph.py | UTF-8 | 184 | 2.890625 | 3 | [] | no_license | import matplotlib.pyplot as plt
import numpy as np
x = [0.5, 0.5]
y = [1.5, 2.5]
plt.plot(x, y)
plt.title("2 Robots in the room")
plt.axis('equal')
plt.grid()
plt.show()
plt.close()
| true |
684d24013119e4c10df1a031f0abfad3e4663045 | lily-liu-17/ICS3U-Unit2-03-Python-Circumference | /circumference.py | UTF-8 | 555 | 3.828125 | 4 | [] | no_license | #!/usr/bin/env python3
# Created by: Lily Liu
# Created on: Sept 2021
# This program calculates the circumference using tau
# with radius inputted from the user
import consatant
def main():
# This program calculates the circumference using tau
# input
radius = int(input("Enter the radius of the circ... | true |
e6e99092d68e1bc68e233bb6522e727b082b2685 | robj137/advent_of_code | /2016/day15.py | UTF-8 | 1,636 | 3.3125 | 3 | [] | no_license | import re
import hashlib
import numpy as np
from datetime import datetime as dt
from collections import deque
import heapq
def get_discs(test=False):
path = 'inputs/day15.txt'
if test:
path = 'inputs/day15.alt.txt'
with open(path) as f:
lines = [x.strip() for x in f.readlines()]
p = 'D... | true |
bea839dc364a11daff33d6639e0e8695a1b6a139 | diegoshakan/curso-em-video-python | /Desafio36M02.py | UTF-8 | 685 | 4.1875 | 4 | [] | no_license | '''Faça um programa para aprovar um empréstimo bancário para a compra de uma casa.
O programa irá perguntar o valor da casa, o salário do comprador e em quantos anos ele pretende pagar.
Calcule o valor da prestação mensal, visando não ultrapassar 30% do valor do salário, ou então o
empréstimo será negado.'''
casa = fl... | true |
85b683951b1060d87874da3d4df84d7dcfbd5268 | grisha-dd/python | /lesson-3/3.5.py | UTF-8 | 719 | 4.15625 | 4 | [] | no_license | def my_sum():
total_sum = 0
while True:
user_str = input("Введите строку чисел, разделенных пробелом. Для выхода введите z: ")
user_list = user_str.split(" ")
sub_sum = 0
for item in user_list:
if item == "z":
return sub_sum, total_sum
sub... | true |
cae07ca1a216f90269c420a37cc569486f914773 | zrlram/leds | /layouts/my_sphere_perfect.py | UTF-8 | 1,951 | 2.953125 | 3 | [] | no_license | #!/usr/bin/env python
from math import sin, cos, pi, asin
from connection import row
# see also: http://blog.marmakoide.org/?p=1
r = 1
#row = [40, 40, 40, 32, 32, 32, 24, 24, 16, 8, 0] # height- rows
#row = [40, 40, 32, 32, 24, 24, 24, 16, 16, 8, 0] # 512 - multiples of 8
#row = [40, 36, 32, 32, 28, 24, ... | true |
54859b4517a76e333f3a73e5cec041daa617c95a | brittneyexline/euler | /problem2.py | UTF-8 | 757 | 4.0625 | 4 | [] | no_license | #!/usr/local/bin/python
# Each new term in the Fibonacci sequence is generated by adding the previous two terms.
# By starting with 1 and 2, the first 10 terms will be:
#
# 1, 2, 3, 5, 8, 13, 21, 34, 55, 89, ...
#
# By considering the terms in the Fibonacci sequence whose values do not exceed four million,
# find the ... | true |
f04f30a78c90ac13cadbf528284b697c75b505b3 | SS1908/30_days_of_python | /Day 11/datetime_module.py | UTF-8 | 738 | 3.75 | 4 | [] | no_license | """
We can import a module named ' datetime ' to work with date and time as date object;
Formate code discription example
%a weekday , sort tue
%A weekday , full tuesday
%b ... | true |
669fb8069298d4aedf3f248dc74f5d90a023569c | KBicks/CMEECourseWork | /Week2/Code/scope.py | UTF-8 | 1,273 | 3.90625 | 4 | [] | no_license | #!/usr/bin/env python3
"""Demonstrates that global variables appear outside the function, whereas
variables set inside the function do not alter variables outside the function."""
__appname__ = "scope.py"
__author__ = "Katie Bickerton <k.bickerton18@imperial.ac.uk>"
__version__ = "3.5.2"
__date__ = "10-Oct-2018"
# Par... | true |
57ccb148231c8e7e168ac95d501b9657a244c82e | gulishana/Coursera_Python_for_Everybody_Specialization | /15.4_ex_Twfriends.py | UTF-8 | 5,129 | 2.671875 | 3 | [] | no_license | import urllib.request, urllib.parse, urllib.error
# remember you need to put 4 keys in the hidden.py
import twurl
import json
import sqlite3
import ssl
TWITTER_URL = 'https://api.twitter.com/1.1/friends/list.json'
conn = sqlite3.connect('friends.sqlite')
cur = conn.cursor()
# 'CREATE TABLE IF NOT EXISTS' means:
#(1)... | true |
441689d447e6f5fcf5107accc2b58a02a178a015 | hermesfeet/durga | /app/jules_alexa.py | UTF-8 | 8,749 | 2.921875 | 3 | [
"MIT"
] | permissive | import random
from knowledge import *
import nltk, re, pprint, urllib
from nltk.tokenize import *
from nltk import word_tokenize
import time, datetime, uuid
import collections
from numpy.random import choice
ts = time.time()
st = datetime.datetime.fromtimestamp(ts).strftime('%Y-%m-%d %H:%M:%S')
id = str(uuid.uuid4())... | true |
0dfedbc75d4192afbbb9efe7fc03cbdd25af555d | Novark/Hanabi | /core/hanabi_server.py | UTF-8 | 3,217 | 3.15625 | 3 | [] | no_license | """
Server game logic implementation
"""
import random
from players import player_server as ps
from network import message
from network import protocol
class Rule(object):
pass
class Round(object):
#Maybe this is just a property in the Game class...
pass
class Game(object):
pass
class GameServer(... | true |
7004f90e33cb033472050803c052874138349165 | bigseanpeng/MLGame | /games/arkanoid/ml/train_with_log_SVM_1202.py | UTF-8 | 4,875 | 2.578125 | 3 | [] | no_license | #from sklearn import svm
import pickle
import os
import numpy as np
import matplotlib.pyplot as plt
item_index = 0
load_file = 0
folder_path = "C:\\Users\\bigse\\MLGame\\games\\arkanoid\\arkanoid" #指定LOG資料夾位置
folder_content = os.listdir(folder_path)
Frame = [ ]
Status = [ ]
Ballposition = [ ]
Platformposition = [ ... | true |
b96ce9d0f4fe3d5b9f3ddb22d74be4f3fef2db62 | RadoslawPotyka/DataVisualiser | /Visualiser/modules/charts/tests/test_samples.py | UTF-8 | 2,578 | 2.984375 | 3 | [] | no_license | from ...charts.models import *
from ...common.models import *
class ChartSampleGenerator(object):
"""
Class for chart sample creating.
"""
@staticmethod
def create_chart():
df = ChartSampleGenerator.create_data_source()
chart = Chart()
chart.data_source.data = df
c... | true |
d1982a2610c4dbcf7130c841b44f646dc8b7804d | RishitAghera/internship | /python/scrabble-score/scrabble_score.py | UTF-8 | 541 | 3.546875 | 4 | [] | no_license | def score(word):
s1=["A", "E", "I", "O","U", "L", "N", "R","S", "T"]
s2=["D","G"]
s3=["B","C","M","P"]
s4=["F","H","V","W","Y"]
s5=["J","X"]
s6=["Q","Z"]
cnt=0
for i in word.upper():
if(i in s1):
cnt+=1
elif(i in s2):
cnt+=2
elif(i in s3):... | true |
111038174f46b63f840a52ee65269cc29168dd1c | ArbelRivitz/Crossword | /crossword3d.py | UTF-8 | 4,090 | 3.265625 | 3 | [] | no_license | ###############################################################################
# FILE: ex4.py
# WRITER: Lior_Fishman, Arbel Rivitz, liorf, Arbelr, 208305797, 207904632
# EXERCISE: intro2cs ex5 2017-2018
# DESCRIPTION: This exercise searches for words from a given list in a given 3d
# matrix.
####################... | true |
5a8c05398c5910489cc798aecb46bf8e78ad01a8 | positivedefinite/dig-etl-engine | /utilities/timeseries/trend/io_utils.py | UTF-8 | 3,992 | 2.921875 | 3 | [
"MIT"
] | permissive | import json
import re
class parse_input:
def __init__(self, file_type, file_path, out_path):
self.type = file_type
self.src = file_path
self.dst = out_path
def parse_line(self, line, series_alias):
line_json = json.loads(line)
return self.modify_input(line_json[series_... | true |
0d751305008c6b74d9f5e4a664fc19399c46dee7 | sheyiqi/algorithm | /1_datastruct/my_heap.py | UTF-8 | 744 | 3.4375 | 3 | [] | no_license | def heapBuild(data):
dataLen = len(data)
for flag in range(dataLen//2,-1,-1):
heapAdjust(data,flag,dataLen)
def heapAdjust(data,flag,dataLen):
left = 2*flag
right = 2*flag+1
index = flag
if left < dataLen and data[left] > data[index]:
index = left
if right < dataLen and data... | true |
966f564c16e0d5b327f926451949d8153ab009ee | wintersalmon/Dungeon-Of-Mandom-Python | /src/mandom/weapons/weapon.py | UTF-8 | 874 | 3.140625 | 3 | [] | no_license | # Salmonjoon
# DungeonOfMandom
# 2016.05.28
#
# Weapon
#
class Weapon:
def __init__(self, code, name, armor, can_slayer_monsters):
self.__code = code # if isinstance(code, WeaponType) else WeaponType.noname
self.__name = name
self.__armor = armor
self.__can_slayer_monsters = can_sl... | true |
fd18584463efea4f7a00b3f4585b86ec617b0c03 | plparent/NPDL | /layers/Residual.py | UTF-8 | 2,427 | 2.71875 | 3 | [] | no_license | import copy
class Residual:
def __init__(self, layers):
self.layers = layers
def forward_npdl(self, X, **kwargs):
"""Propagation avant au travers d'une couche résiduelle.
Arguments:
X {ndarray} -- Entrée de la couche.
Returns:
ndarray -- Sortie résidu... | true |
9fac82f27f26a47e0c2f347908d5165fbdf3f0aa | ryankenney-dev/advent-of-code-2020 | /day-10/part_1_main.py | UTF-8 | 422 | 2.90625 | 3 | [] | no_license | import part_1
import sys
with open(sys.argv[1], 'r') as f:
message = f.read()
jolt_adapters = part_1.parse_jolt_adapters(message)
differences = part_1.count_jolt_differences(jolt_adapters)
product = part_1.product_of_1_and_3_jolt_differences(jolt_adapters)
print("")
print("[[[ Jolt Difference Counts: %s ]]]" % d... | true |
840794794eddb652c39e396102d01ac50f7d405f | vmodhavadia/Project-Euler | /done37.py | UTF-8 | 1,416 | 3.765625 | 4 | [] | no_license | """def get_primes(n):
m = n+1
numbers = [True for i in range(m)]
for i in range(2, int((n ** 0.5))):
if numbers[i]:
for j in range(i*i, m, i):
numbers[j] = False
primes = []
for i in range(2, m):
if numbers[i]:
primes.append(i)
return pr... | true |
f035551dc862b04e26768f38d3c688fb869a20ce | Rjp9601/digital-encoder | /datacomm.py | UTF-8 | 5,431 | 2.59375 | 3 | [] | no_license | import sys
import matplotlib.pyplot as plt
import random
import numpy as np
def nrz_l(inp):
inp1=list(inp)
res = []
for i in inp1:
if i=='0':
res.append(-1)
else:
res.append(1)
return res
def nrz_i(inp):
nrzi=[]
if inp[0]=='1':
... | true |
e0f2dbc237f9e646fbd572d716478c41c0e0c954 | weezer/fun_scripts | /algo/681. Next Closest Time.py | UTF-8 | 1,129 | 3.078125 | 3 | [] | no_license | def next_closest_time(input_time):
lst = []
for i in input_time:
if i.isdigit():
lst.append(i)
first_half = int(input_time[:2])
second_half = int(input_time[3:])
#take care digit 4
for i in lst:
i_34 = input_time[3]
if i > input_time[4]:
i_34 += i
... | true |