seq_id stringlengths 4 11 | text stringlengths 113 2.92M | repo_name stringlengths 4 125 ⌀ | sub_path stringlengths 3 214 | file_name stringlengths 3 160 | file_ext stringclasses 18
values | file_size_in_byte int64 113 2.92M | program_lang stringclasses 1
value | lang stringclasses 93
values | doc_type stringclasses 1
value | stars int64 0 179k ⌀ | dataset stringclasses 3
values | pt stringclasses 78
values |
|---|---|---|---|---|---|---|---|---|---|---|---|---|
452414635 | import pandas as pd
from datetime import datetime
# Covert UNIX timestamp to regular timestamp
def toTimestamp(ts):
ts = int(ts)
return datetime.utcfromtimestamp(ts).strftime('%Y-%m-%d %H:%M:%S')
# Save pd.DataFrame as .csv
def save(df, filepath):
df.to_csv(filepath)
# Load stored dataframes (with speci... | marcvernet31/redditScrapper | auxiliar.py | auxiliar.py | py | 838 | python | en | code | 2 | github-code | 90 |
21177786097 |
import os
import json
import argparse
from six.moves import cPickle, xrange
from collections import defaultdict
import pdb
def precook(s, n=4, out=False):
"""
Takes a string as input and returns an object that can be given to
either cook_refs or cook_test. This is optional: cook_refs and cook_test
can take st... | c3cannon/multilingual_video_captioning | prepro_tokens.py | prepro_tokens.py | py | 3,671 | python | en | code | 1 | github-code | 90 |
38334885781 | from tkinter import *
from tkinter import filedialog,messagebox
from os import getlogin,path
import piexif
from PIL import Image
from adjust import Adjust
from filters import Filters
from rotate import Rotate
class EditingButtons(Frame):
def __init__(self,master=None):
Frame.__init__(self,master=master , b... | Tharbouch/ImageEditor | editingbuttons.py | editingbuttons.py | py | 12,807 | python | en | code | 1 | github-code | 90 |
12114578837 | import datetime
from datetime import datetime as dt
from django.conf import settings
from django.contrib import messages
from django.contrib.auth.decorators import login_required
from django.contrib.auth.mixins import UserPassesTestMixin
from django.core.paginator import Paginator
from django.shortcuts import get_obje... | cewebbr/mover-se_superacao-coletiva | projects/views/project.py | project.py | py | 9,393 | python | en | code | 0 | github-code | 90 |
19388930638 | import _init_path
from lib.model import PartialUNet, UNet
from lib.utils import to_var
import torchvision_sunner.transforms as sunnertransforms
import torchvision_sunner.data as sunnerData
import torchvision.transforms as transforms
import torch.nn as nn
import numpy as np
import argparse
import torch
import cv2
import... | SunnerLi/P-Conv | test.py | test.py | py | 3,277 | python | en | code | 15 | github-code | 90 |
18197459779 | X, N = [int(i) for i in input().split()]
P = [int(i) for i in input().split()]
# Xは0~101の値になる
result = 0
current = 102
for i in range(102):
if i not in P:
if abs(X - i) < current:
result = i
current = abs(X - i)
print(result) | Aasthaengg/IBMdataset | Python_codes/p02641/s084432793.py | s084432793.py | py | 273 | python | en | code | 0 | github-code | 90 |
31547364793 | """Module containing various pop up display settings"""
# pylint: disable=E0203
# pylint: disable=E1101
from pygame import mouse, Surface, Rect, font, draw
from gui.gui_settings import (POPUP_SCREEN_WIDTH_OFFSET, POPUP_SCREEN_HEIGHT_OFFSET,
POPUP_SCREEN_HEIGHT, POPUP_SCREEN_WIDTH, HELVETI... | rhys-hodio/chess-py | gui/gui_screens.py | gui_screens.py | py | 11,652 | python | en | code | 0 | github-code | 90 |
32488437165 | from django.conf import settings
from django.conf.urls import include, url
from django.contrib import admin
from django.views import generic
from django.shortcuts import render
from . import forms
def index_view(request):
context = {
'login': forms.LoginForm(),
'registration': forms.RegistrationF... | gengue/django-material | tests/urls.py | urls.py | py | 1,902 | python | en | code | null | github-code | 90 |
18138072649 | import sys
n = int( sys.stdin.readline() )
cards = { pattern:[False]*13 for pattern in ( 'S', 'H', 'C', 'D' ) }
for i in range( n ):
pattern, num = sys.stdin.readline().split( " " )
cards[ pattern ][ int( num )-1 ] = True
for pattern in ( 'S', 'H', 'C', 'D' ):
for i in range( 13 ):
if not cards[ pattern ][ i ]:
... | Aasthaengg/IBMdataset | Python_codes/p02408/s489276879.py | s489276879.py | py | 366 | python | en | code | 0 | github-code | 90 |
25494924054 | import copy
import json
import uuid
import datetime
from elasticsearch import Elasticsearch
from elasticsearch.exceptions import NotFoundError, ConflictError
from django.conf import settings
from django.core.serializers.json import DjangoJSONEncoder
from rest_framework import serializers
from rest_framework.serializ... | open-cmdb/cmdb | apps/data/initialize.py | initialize.py | py | 7,174 | python | en | code | 966 | github-code | 90 |
70249091178 | # Using SQLAlchemy to connect to the Database
from sqlalchemy import create_engine,MetaData
from sqlalchemy.ext.declarative import declarative_base
from sqlalchemy.orm import sessionmaker
from sqlalchemy.ext.asyncio import create_async_engine, AsyncSession
from .config import Config
from .utils.log_helper import *
d... | LACMTA/metro-api-v2 | fastapi/app/database.py | database.py | py | 1,217 | python | en | code | 0 | github-code | 90 |
18112278239 | import sys
ERROR_INPUT = 'input is invalid'
ERROR_INPUT_NOT_UNIQUE = 'input is not unique'
def main():
S = get_input1()
T = get_input2()
count = 0
for t in T:
if linner_search(S, t):
count += 1
print(count)
def linner_search(li, key):
li.append(key)
i = 0
while... | Aasthaengg/IBMdataset | Python_codes/p02267/s536747158.py | s536747158.py | py | 1,050 | python | en | code | 0 | github-code | 90 |
6059507202 | class Employee:
noOfLeaves = 5
# Constructor
def __init__(self, name, salary, role):
self.name = name
self.salary = salary
self.role = role
# Object Method
def printDetails(self):
return f"The name is {self.name}. Salary is {self.salary}. And role is {sel... | SuryanshuTomar/Python | PythonTopics/AlternativeConstructor.py | AlternativeConstructor.py | py | 1,001 | python | en | code | 0 | github-code | 90 |
39501006079 | from django.db.models import Avg
from rest_framework import serializers
from .models import Product, Rating, Comment
class ProductSerializer(serializers.ModelSerializer):
class Meta:
model = Product
fields = ["id", "name", "description", "price"]
class RatingSerializer(serializers.ModelSerializer)... | cyberpunk3033/Comment_Product | products/serializers.py | serializers.py | py | 1,542 | python | en | code | 0 | github-code | 90 |
26588540872 | import re
hand=open('C:/Users/PC/Documents/Assignment1/regex_sum_42.txt')
sum=0
for line in hand:
line=line.rstrip()
x=re.findall('[0-9]+',line)
for n in x:
print(n)
sum+=int(n)
print(sum)
| KhadidjaArezki/PY4E | Using_Python_to_Access_Web_Data/WEEK2/Assignment2/TestSum.py | TestSum.py | py | 218 | python | en | code | 0 | github-code | 90 |
18176980809 | N,K = input().split()
scores = [int(s) for s in input().split()]
N = int(N)
K = int(K)
for i in range(K,N):
if scores[i] <= scores[i-K]:
print("No")
else:
print("Yes") | Aasthaengg/IBMdataset | Python_codes/p02602/s693006227.py | s693006227.py | py | 193 | python | en | code | 0 | github-code | 90 |
5098867928 | s=input()
s1=[]
s2=[]
ans=0
for i in range(len(s)):
if(s[i]=="\\"):
s1.append(i)
elif(s[i]=="/" and s1):
j = s1.pop()
a=i-j
ans+=a
while(s2 and s2[-1][0]>j):
a+=s2.pop()[1]
s2.append([j,a])
print(ans)
print(len(s2),*(a for j, a in s2)) | WAT36/procon_work | procon_python/src/aoj/ALDS1_3_D_Areas_on_the_Cross-Section_Diagram.py | ALDS1_3_D_Areas_on_the_Cross-Section_Diagram.py | py | 305 | python | en | code | 1 | github-code | 90 |
73467973418 | import random
line = input().rstrip().split(",")
for enemy in line:
print(enemy + "が現れた!")
num = len(line)
print("敵は" + str(num) + "匹")
attack = random.randrange(num)
print(line[attack] + "に会心の一撃" + line[attack] + "を倒した") | yuuyas222/python_lesson4 | app.py | app.py | py | 266 | python | en | code | 0 | github-code | 90 |
43007953860 | import math
P1 = input().split(" ")
P2 = input().split(" ")
XP1, YP1 = P1
XP2, YP2 = P2
XP1 = float(XP1)
YP1 = float(YP1)
XP2 = float(XP2)
YP2 = float(YP2)
distancia = math.sqrt(((XP2 - XP1)**2) + ((YP2 - YP1)**2))
distancia = format(distancia, ".4f")
print(str(distancia)) | arthursns/beecrowd-online-judge-beginner-solutions | 1015 - Distância Entre Dois Pontos/1015.py | 1015.py | py | 279 | python | en | code | 1 | github-code | 90 |
43263966381 | #input variables to Zapier Code Transfer Step 10: Create Marketo Email
input={
'token': 'Token', #from Step 4: Get Marketo Access Token
'parent id': 'fid', #from Step 5: Get Parent ID or Create Parent Folder
}
import requests
import datetime
import urllib.parse
import re
import ast
templates = {"Nurture Series... | tyron-pretorius/zapier | email_request_creation/create_marketo_email.py | create_marketo_email.py | py | 1,696 | python | en | code | 1 | github-code | 90 |
19621142121 | import os
def limpa_ecra():
os.system("cls")
def cabecalho(texto):
limpa_ecra()
print("=" * 25)
print(texto)
print("=" * 25)
def inscrever_jogador():
cabecalho("INSCREVER JOGADOR(ES)")
contador = len(lista_dados) + 1
while True:
print("Registo Nº ", contador)
... | isla-lei/2020-2021-LEI-1-D-Fundamentos-Programacao | Trabalhos/Jose Martins/Global.py | Global.py | py | 6,360 | python | pt | code | 0 | github-code | 90 |
43004758138 | from nipype import Function
from nipype.algorithms import confounds
from nipype.interfaces import afni, fsl, utility
from PUMI.engine import NestedNode as Node, QcPipeline
from PUMI.engine import FuncPipeline
from PUMI.pipelines.multimodal.image_manipulation import pick_volume, timecourse2png
from PUMI.utils import cal... | pni-lab/PUMI | PUMI/pipelines/func/deconfound.py | deconfound.py | py | 10,830 | python | en | code | 1 | github-code | 90 |
17956306659 | from itertools import permutations
from scipy.sparse.csgraph import floyd_warshall
n,m,r=map(int,input().split())
R=list(map(int,input().split()))
l=[[float('inf')]*n for _ in range(n)]
for _ in range(m):
a,b,c,=map(int,input().split())
a-=1
b-=1
l[a][b]=c
l[b][a]=c
for i in range(n):
l[i][i] = ... | Aasthaengg/IBMdataset | Python_codes/p03608/s348092998.py | s348092998.py | py | 748 | python | en | code | 0 | github-code | 90 |
18208122939 | def main():
n = int(input().strip())
L = list(map(int, input().strip().split()))
rem=sum(L)
cur=1
ans=0
for i in range(n+1):
ans+=cur
rem-=L[i]
cur-=L[i]
if cur<0 or cur==0 and i!=n:
print(-1)
return
if cur<rem:
cur... | Aasthaengg/IBMdataset | Python_codes/p02665/s286621146.py | s286621146.py | py | 403 | python | en | code | 0 | github-code | 90 |
18497620739 | from sys import stdin, setrecursionlimit
input = stdin.buffer.readline
H, W = map(int, input().split())
A = [list(map(int, input().split())) for _ in range(H)]
answer = []
for i in range(H):
for j in range(W):
if A[i][j] % 2:
if j < W - 1:
answer.append((i + 1, j + 1, i + 1, j ... | Aasthaengg/IBMdataset | Python_codes/p03263/s053247569.py | s053247569.py | py | 620 | python | en | code | 0 | github-code | 90 |
17440972443 | n=int(input("How many rows are there?\n"))
k=2
for a in range(1,n+1):
for b in range(1,2*n):
if a+b==n+1 or b-a==n-1:
print("*",end=" ")
elif a==n and b!=k:
print("*",end=" ")
k=k+2
else:
print(" ",end=" ")
print()
| Mahendra710/Star_Pattern | 8.8- Printing Star.py | 8.8- Printing Star.py | py | 306 | python | en | code | 0 | github-code | 90 |
9968706585 | import requests
import os
from dotenv import load_dotenv
load_dotenv()
def searchTweets(search_term:str):
'''
Return tweets for a keyword seach term.
'''
url = "https://api.twitter.com/2/tweets/search/recent?max_results=25&expansions=referenced_tweets.id&tweet.fields=text&query=lang%3Aen%20"+search_term
p... | ggsmith842/sentiment-api-hum | app/twitterapi.py | twitterapi.py | py | 1,621 | python | en | code | 0 | github-code | 90 |
40734712711 | from __future__ import print_function
import torch
import torch.nn as nn
import torch.nn.parallel
import torch.utils.data
from torch.autograd import Variable
# custom weights initialization called on netG and netD
def weights_init(m):
classname = m.__class__.__name__
if classname.find('Conv') != -1:
m... | saumyasinha/DynamicCamouflage | Module_Generator/SGAN_Model.py | SGAN_Model.py | py | 3,008 | python | en | code | 0 | github-code | 90 |
72978460458 | from binaryninja import *
from binaryninjaui import WidgetPane, UIActionHandler, UIActionHandler, UIAction, Menu, UIContext, UIContextNotification
from pefile import ExceptionsDirEntryData, PE, PEFormatError
from PySide6 import QtCore
from PySide6.QtCore import Qt
from PySide6.QtWidgets import QHBoxLayout, QVBoxLayout,... | EliseZeroTwo/SEH-Helper | __init__.py | __init__.py | py | 11,783 | python | en | code | 77 | github-code | 90 |
9551544073 | # -*- coding: utf-8 -*-
from PyQt5 import QtWidgets, QtCore # type: ignore
from pineboolib.core import decorators
from typing import Any, Union
class QDateEdit(QtWidgets.QDateEdit):
_parent = None
_date = None
separator_ = "-"
def __init__(self, parent=None, name=None) -> None:
super(QDate... | deavid/pineboo | pineboolib/qt3_widgets/qdateedit.py | qdateedit.py | py | 1,949 | python | en | code | 4 | github-code | 90 |
18381073799 | n=int(input())
tab = []
for i in range(n):
a,b = map(int,input().split())
tab+=[[a,b]]
def cle(x):
return x[1]
tab.sort(key = cle)
ans = "Yes"
temps = 0
for a,b in tab:
temps+=a
if temps>b: ans = "No"
print(ans)
| Aasthaengg/IBMdataset | Python_codes/p02996/s594844640.py | s594844640.py | py | 223 | python | en | code | 0 | github-code | 90 |
18538064889 | a, b, c = map(int, input().split())
k = int(input())
ABC = [a, b, c]
sort_ACB = sorted(ABC)
MAX = sort_ACB[-1]
sum_ABC = sum(ABC) - MAX
for _ in range(k):
MAX*=2
print(sum_ABC + MAX) | Aasthaengg/IBMdataset | Python_codes/p03360/s144164199.py | s144164199.py | py | 186 | python | en | code | 0 | github-code | 90 |
18560989069 | N=int(input())
S=list(map(str,input().split()))
flg=0
for i in range(N) :
if S[i]=="Y" :
flg=1
if flg==1 :
print("Four")
else :
print("Three") | Aasthaengg/IBMdataset | Python_codes/p03424/s546131098.py | s546131098.py | py | 152 | python | zh | code | 0 | github-code | 90 |
18730986310 | # This code is written by harsh.
from collections import namedtuple
if __name__ == "__main__":
n = int(input())
fields = input()
s = namedtuple("s", fields)
totalMarks = 0
for i in range(n):
temp = s(*input().split())
totalMarks += int(temp.MARKS)
print(totalMarks / n)
| harshsinghs1058/python_hackerrank_solutions | Collections_namedtuple_.py | Collections_namedtuple_.py | py | 311 | python | en | code | 1 | github-code | 90 |
27889973632 | class Solution:
def partition(self, s):
ans = []
n = len(s)
self.dfs([],0, n, ans,s)
return ans
def dfs(self, cur, start, end, ans,s):
if start >= end:
ans.append(cur)
return
for i in range(start, end):
tmp = s[start:i+1]
... | samshaq19912009/Leetcode_in_Python_my_practise | dfs/palindrome_partition.py | palindrome_partition.py | py | 466 | python | en | code | 0 | github-code | 90 |
41207238271 | import pathlib
import re
path = str(pathlib.Path(__file__).parent.absolute())
while True:
pattern = input('Enter a regular expression: ')
if pattern == 'exit':
break
try:
fhand = open(path + r'/../mbox.txt')
try:
counter = 0
for line in fhand:
... | macmgeneration/05-Python | Topics/12. StdLib/solutions/01Grep.py | 01Grep.py | py | 668 | python | en | code | 4 | github-code | 90 |
39045349828 | import json
import warnings
from os import path
import dask.dataframe as dd
import matplotlib.pyplot as plt
import numpy as np
import pandas as pd
from tqdm import tqdm
import torch
import torch.nn as nn
import torch.nn.functional as F
import torch.optim as optim
from torch.nn.utils.rnn import pad_sequence
def ts_t... | tatigabru/kaggle-plasticc | src/feature_extractors/curve_fitting_features.py | curve_fitting_features.py | py | 13,053 | python | en | code | 2 | github-code | 90 |
39087886647 | import unittest
import json
from app import app, menu
class TestMenuManagement(unittest.TestCase):
def setUp(self):
self.app = app.test_client()
app.config['TESTING'] = True
def test_add_dish(self):
response = self.app.post('/add_dish', data=json.dumps({'dish_id': '1', 'name': 'Burger... | imSAJJAKALI/prompt_eng | S2D3/LEVEL1/tests/test_menu.py | test_menu.py | py | 956 | python | en | code | 1 | github-code | 90 |
71714963817 | from telegram.ext import Updater, CommandHandler, MessageHandler, Filters
import telegram
import logging
import time
import os
from apiclient.discovery import build
from apiclient.errors import HttpError
from oauth2client.client import GoogleCredentials
import dialogflow_v2 as dialogflow
import handler_tools
from h... | asvirin/conversation-bots | bot-tg.py | bot-tg.py | py | 1,594 | python | en | code | 23 | github-code | 90 |
17981678739 | N=int(input())
A=list(map(int,input().split()))
X=[A[i] for i in range(0,N,2)]
Y=[A[i] for i in range(1,N,2)]
if N%2:
A=X[::-1]
B=Y
else:
A=Y[::-1]
B=X
print(" ".join(map(str,A+B)))
| Aasthaengg/IBMdataset | Python_codes/p03673/s841084858.py | s841084858.py | py | 201 | python | en | code | 0 | github-code | 90 |
1746549579 | import torch
import numpy as np
from lib.Uncertainty import normalize_batch_uncertainty
def memory_computation(unc_vals,output_dir,rel_class_num,
obj_class_num,obj_feature_dim=1024,
rel_feature_dim=1936,obj_weight_type='both',
rel_weight_type='both',... | sayaknag/unbiasedSGG | lib/Memory.py | Memory.py | py | 6,007 | python | en | code | 12 | github-code | 90 |
38304816960 |
# given an array of ints, is it possible to choose a group of some of the ints, beginning at the start index, such that the group sums to the given target?
# however, with the additional constraint that all 6's must be chosen
def group_sum6(start, nums, target):
if start >= len(nums):
return target == 0
... | jemtca/CodingBat | Python/Recursion-2/group_sum6.py | group_sum6.py | py | 726 | python | en | code | 0 | github-code | 90 |
41298152118 | import numpy as np
class Grid(object):
""" Finds the number of times one must apply the function,
f(a, b) = a * a + b, to each point before the result exceeds
Grid.threshold.
If Grid.elementwise equals True, Grid.fill() uses a straight-forward,
ineffecient method, one element at a ... | andysmith2378/projectkirill | main.py | main.py | py | 5,491 | python | en | code | 0 | github-code | 90 |
18185088469 | import sys
M = 10 ** 9 + 7
N, K = map(int, input().split())
p_list = []
n_list = []
z_count = 0
for A in map(int, input().split()):
if A < 0:
n_list.append(A)
elif A > 0:
p_list.append(A)
else:
z_count += 1
p_list.sort()
n_list.sort()
#print(p_list)
#print(n_list)
if len(p_list) + len(n_list) < K:
print... | Aasthaengg/IBMdataset | Python_codes/p02616/s747859042.py | s747859042.py | py | 2,092 | python | en | code | 0 | github-code | 90 |
19414977991 | import numpy
import theano
import theano.tensor as T
import mysql.connector
import six.moves.cPickle as pickle
import timeit
class LinearRegression(object):
"""Linear Regression Class
The linear regression is fully described by a weight matrix :math:`W`
and bias vector :math:`b`. Regression is done by pr... | tonitsp/INF2290_CARTOLA | linear_regrassion.py | linear_regrassion.py | py | 9,591 | python | en | code | 1 | github-code | 90 |
42325417313 | import os
from django.views.generic.edit import FormView
from django.views.generic import DetailView, ListView
from django.shortcuts import render
from django.utils.crypto import get_random_string
from django.urls import reverse
from django.urls import reverse_lazy
from django.http import HttpResponse
from django.http... | piyushbhutani1999/heroku | assignment/views.py | views.py | py | 6,601 | python | en | code | 0 | github-code | 90 |
18204295069 | def factorization(n):
if n < 2:
return []
arr = []
temp = n
for i in range(2, int(-(-n**0.5//1))+1):
if temp%i==0:
cnt=0
while temp%i==0:
cnt+=1
temp //= i
arr.append([i, cnt])
if temp!=1:
arr.append([tem... | Aasthaengg/IBMdataset | Python_codes/p02660/s531871800.py | s531871800.py | py | 545 | python | en | code | 0 | github-code | 90 |
32325140636 | budget = float(input())
tv_show_numbers = int(input())
for number in range(1, tv_show_numbers + 1):
tv_show_name = input()
tv_show_price = float(input())
discount = 1
if tv_show_name == "Thrones":
discount = 0.5
elif tv_show_name == "Lucifer":
discount = 0.6
elif tv_show_name ==... | VelkovIv/Programing-Basic-July-2022-in-SoftUni | test_exam_tasks/05.series.py | 05.series.py | py | 730 | python | en | code | 1 | github-code | 90 |
19187457786 | import csv
import re
from collections.abc import Iterable
from io import TextIOWrapper
from pathlib import Path
from typing import Any
from zipfile import ZipFile
def to_positive_float(value: Any) -> float | None:
if isinstance(value, str):
value = re.sub(r"[^\d./]", "", value) if value else ""
try:
... | rafelafrance/parser_ensemble | reconcile/pylib/util.py | util.py | py | 1,413 | python | en | code | 1 | github-code | 90 |
72318539818 | import os
import json
import string
import re
import aiohttp
import logs
import stats
import jobs
from random_string import random_string
async def post(request):
# print(await request.text())
req = (await request.post()) or (await request.json())
code = req.get('code')
output_format = req.get('format... | DXsmiley/rtex | src/api2.py | api2.py | py | 1,888 | python | en | code | 14 | github-code | 90 |
3184647787 | import torch
import os
from transformers import BertTokenizer, BertForMaskedLM
from transformers import RobertaTokenizer, RobertaForMaskedLM
from transformers import XLMRobertaTokenizer, XLMRobertaForMaskedLM
def init_decoder_weight(dataset, ontology_file, save_dir, MLM_decoder, bert_size):
type_token = []
w... | mhtang1995/CPPT | param_init.py | param_init.py | py | 2,388 | python | en | code | 1 | github-code | 90 |
32619765508 | # # # # # Clash detection 2 # # # # #
import clr
import System
import math
clr.AddReference('RevitAPI')
clr.AddReference('RevitAPIUI')
from Autodesk.Revit.DB import *
from Autodesk.Revit.UI import *
from System.Collections.Generic import List
from pyrevit import forms
from rpw.ui.forms import TextInput
doc = __revi... | ThomFgt/PyRevit | PyRevit/MyExtensions/AddIns.extension/AddIns.tab/tests.panel/Test2Pierre.pushbutton/script.py | script.py | py | 22,144 | python | en | code | 2 | github-code | 90 |
73173500455 | from PIL import Image
from OpenGL.GL import *
from src.layout_creation.rect import Rect
from src.utils.MathUtils import Vector2
class ImageSceneObject:
def __init__(self, image: Image, rect: Rect, offset: Vector2):
self.rect = rect
width, height = image.size
# Dirty hack for portrait te... | jlol/photo-album | src/opengl/image_scene_object.py | image_scene_object.py | py | 3,313 | python | en | code | 0 | github-code | 90 |
18527318339 | #import sys
#import numpy as np
import math
#from fractions import Fraction
import itertools
from collections import deque
from collections import Counter
import heapq
from fractions import gcd
#input=sys.stdin.readline
#import bisect
n,m=map(int,input().split())
d=[list(map(int,input().split())) for _ in range(m)]
c... | Aasthaengg/IBMdataset | Python_codes/p03330/s832138538.py | s832138538.py | py | 1,105 | python | en | code | 0 | github-code | 90 |
31174003482 | from rest_framework.decorators import api_view
from rest_framework.response import Response
from rest_framework import status
import pandas as pd
def transform_csv(file, email_column_name):
pass
def transform_excel(file, email_column_name):
excel = pd.ExcelFile(file.open('r'))
print(excel.sheet_names)
... | DavidRoldan523/inbound_marketing_clean | API/inboud_transform/views/service_view.py | service_view.py | py | 901 | python | en | code | 0 | github-code | 90 |
73340136937 | import numpy as np
from bds_sampler import make_degree_sequence, sample
seq = np.array(
[
[1, 2],
[3, 2],
[4, 6],
[3, 3],
[5, 3],
[4, 4],
]
)
print(sample(in_seq=seq[:, 0], out_seq=seq[:, 1], N_samples=1))
# or generate a random degree sequence with pareto dis... | ianhi/BDS-sampler | examples/basic.py | basic.py | py | 452 | python | en | code | 1 | github-code | 90 |
23800759218 | import sys
INF = int(1e9)
input = sys.stdin.readline
N = int(input())
maxdp = list(map(int, input().split()))
mindp = maxdp.copy()
maxtemp = [0, 0, 0]
mintemp = [INF, INF, INF]
for i in range(N-1):
num = str(input())
for ind, val in enumerate(num):
if ind % 2 != 0:
contin... | 723poil/boj | 백준/Gold/2096. 내려가기/내려가기.py | 내려가기.py | py | 783 | python | en | code | 0 | github-code | 90 |
35413139669 | import re, os
from tqdm import tqdm #进度条库
import threading #线程
#调用自己的模块,先获取执行的目录,再import文件
import sys
sys.path.append(".") #执行目录地址
from utils.subConvert.sub_convert import sub_convert
from utils.subConvert import list_to_content
#源文件
source_sublist_path = './utils/collectTGsub/TGsources.yaml'
#爬取的TG分享的节点
crawlTGno... | rxsweet/codes | TGlist2Node/TGlist2Node.py | TGlist2Node.py | py | 2,328 | python | en | code | 7 | github-code | 90 |
22548346323 | #while loops.
#Items - each item of a collection or a list
items = ["crayon", "scissors", "paper", "glitter glue", "markers", "pens"]
for item in items:
print(f"The item is: {item}")
#Numbers - list of numbers
numbers = [0, 1, 2, 3, 4, 5, 6, 7, 8]
numbers = range(10)
for number in range(10):
print(number)... | karolcastro/Pathway | 08/preparation_material.py | preparation_material.py | py | 1,624 | python | en | code | 0 | github-code | 90 |
35716445081 | import os
from secfsdstools.c_index.companyindexreading import CompanyIndexReader
from secfsdstools.c_index.indexdataaccess import IndexReport
CURRENT_DIR, _ = os.path.split(__file__)
PATH_TO_PARQUET = f'{CURRENT_DIR}/../_testdata/parquet/'
def test_get_latest_company_information_parquet(basicconf):
reader = Co... | HansjoergW/sec-fincancial-statement-data-set | tests/c_index/test_companyindexreading.py | test_companyindexreading.py | py | 1,019 | python | en | code | 12 | github-code | 90 |
19017640775 | # Definition for a binary tree node.
# class TreeNode:
# def __init__(self, val=0, left=None, right=None):
# self.val = val
# self.left = left
# self.right = right
class Solution:
def flatten (self, root: Optional[TreeNode]) -> None:
ptr = root
while (ptr != None):
... | Tejas07PSK/lb_dsa_cracker | Binary Search Trees/Flatten BST to sorted list/solution2.py | solution2.py | py | 771 | python | en | code | 2 | github-code | 90 |
18406241439 | from collections import deque
n=int(input())
ch=0
g=[[] for _ in range(n)]
k=[[] for _ in range(n)]
for i in range(n-1):
u,v,w=map(int,input().split())
if w%2==0:
g[u-1].append(v-1)
g[v-1].append(u-1)
else:
k[u-1].append(v-1)
k[v-1].append(u-1)
ch1=u-1
ch2=v-1
ch=1
## 0:White 1:Black... | Aasthaengg/IBMdataset | Python_codes/p03044/s816522629.py | s816522629.py | py | 884 | python | en | code | 0 | github-code | 90 |
72671747176 | import shutil
from pathlib import Path
import sh
import pytest
@pytest.fixture
def workdir(tmpdir, request):
dir_ = Path(request.fspath).parent
tdir = Path(tmpdir)
return shutil.copytree(dir_, tdir / "case")
@pytest.fixture
def run(workdir, request):
def wrapper():
test_name = Path(request.... | vantage-org/vantage | tests/conftest.py | conftest.py | py | 1,164 | python | en | code | 1 | github-code | 90 |
2033540297 | import re
class SearchParser(object):
@staticmethod
def get_dict(text):
d = {}
# Looks for one of the things to search for then colon then a non-greedy anything and then either comma or end of string
pattern = re.compile(r'(name|cmc|rarity|text):(.*?)(,|$)',re.IGNORECASE)
... | ToxicGLaDOS/magic-collection-tracker | searchparser.py | searchparser.py | py | 896 | python | en | code | 0 | github-code | 90 |
8909384587 | '''
File name : objTracking.py
Description : Main file for object tracking
Author : Rahmad Sadli
Date created : 20/02/2020
Python Version : 3.7
'''
import cv2
from Detector import detect
from KalmanFilter import KalmanFilter
import math
import gc
def dist(x, y, x1... | hatemgahmed/Circular-Objects-Motion-Prediction | objTracking.py | objTracking.py | py | 4,700 | python | en | code | 1 | github-code | 90 |
38330326304 | from django.conf.urls.defaults import *
# Uncomment the next two lines to enable the admin:
from django.contrib import admin
admin.autodiscover()
urlpatterns = patterns('',
url(r'^$', 'views.index'),
url(r'^maquinas/$', 'ping.views.index'),
url(r'^prendidas/$', 'ping.views.prendidas'),
url(r'^todas/$'... | narval/mactenimiento | urls.py | urls.py | py | 702 | python | en | code | 0 | github-code | 90 |
74132079337 | def task():
inputText = open("day13.txt", "r").readlines()
timestamp = inputText[0]
buses = inputText[1]
timestamp = timestamp.strip()
buses = buses.strip()
timestamp = int(timestamp)
IDs = []
buses = buses.split(",")
for bus in buses:
if bus != "x":
ID... | klukas17/AoC-2020 | day13-part2.py | day13-part2.py | py | 858 | python | en | code | 0 | github-code | 90 |
30392604218 | import discord
from discord.ext import commands
import random
description = '''An example bot to showcase the discord.ext.commands extension
module.
There are a number of utility commands being showcased here.'''
intents = discord.Intents.default()
intents.members = True
intents.message_content = True
bot = commands... | VXT08/M1Y4- | clear.py | clear.py | py | 659 | python | en | code | 0 | github-code | 90 |
71605598058 |
from PySide2.QtCore import *
from PySide2.QtGui import *
from PySide2.QtWidgets import *
from customLoader import loadUi
import os
import time
import sys
import ctypes
import numpy
rng = numpy.random.default_rng()
here = os.path.dirname(__file__)
def random_color():
return rng.random((1, 3))[0]*245
def nu... | Axident/active_scene | active_scene.py | active_scene.py | py | 10,494 | python | en | code | 0 | github-code | 90 |
22428291776 | """converts binary to decimal and vice versa"""
if __name__ == "__main__":
import argparse
parser = argparse.ArgumentParser(description='Convert numbers from binary to decimal and vice versa')
parser.add_argument('number')
parser.add_argument('-bin', '--bin', action='store_true', help='change from bina... | wondermike221/megaProjectIdeas | numbers/b2d.py | b2d.py | py | 510 | python | en | code | 0 | github-code | 90 |
24471101988 | import transformers
import json
model = 'Helsinki-NLP/opus-mt-en-de'
# Read files
with open('transcript.srt', 'r', encoding='utf-8') as f:
transcript_srt = f.read()
with open('transcript.json', 'r') as f:
transcript = json.load(f)
# Prepare marked english text
english_text = transcript_srt.split('\n')
timest... | lazlo-bleker/subtitle-smith | 3_translate_srt.py | 3_translate_srt.py | py | 1,933 | python | en | code | 0 | github-code | 90 |
18330972549 | N = int(input())
S = input()
S = list(S)
d = []
for n in range(1, N):
if S[n-1] == S[n]:
d.append(n)
cnt = 0
for i in d:
i -= cnt
del S[i]
cnt += 1
print(len(S)) | Aasthaengg/IBMdataset | Python_codes/p02887/s526794800.py | s526794800.py | py | 192 | python | en | code | 0 | github-code | 90 |
13735976420 | import cv2
img = cv2.imread('20220811/white.jpg', cv2.IMREAD_COLOR)
print(img.shape)
for i in range(0, 280, 10):
img[:, :i]=[255, 255, 0]
cv2.imshow('white', img)
a = cv2.waitKey(100)
print(a)
cv2.imwrite('white_copy.jpg', img)
img = cv2.imread('20220811/white.jpg', cv2.IMREAD_COLOR)
img_gray = cv2.c... | bbangdoyoon/dip | bigdata_image_work/20220811/ex01.py | ex01.py | py | 459 | python | en | code | 0 | github-code | 90 |
42487721231 | #!/usr/bin/env python3
import sys
from enum import Enum
import numpy as np
import attr
import tqdm
def read(path):
with open(path, 'r') as f:
return int(f.read().strip())
@attr.s
class Spiral():
arr = attr.ib(default=np.array(1, ndmin=2))
Dir = Enum('Dir', 'R U L D', start=0)
def _neighb... | treuherz/AdventOfCode | 17/3/solution.py | solution.py | py | 3,220 | python | en | code | 0 | github-code | 90 |
8941998147 |
from MoveZeroes import Solution
import pytest
from copy import deepcopy
SOL = Solution()
TEST_SUITS = [
([0,1,0,3,12], [1,3,12,0,0]),
([2,1], [2,1]),
([4,2,4,0,0,3,0,5,1,0], [4,2,4,3,5,1,0,0,0,0]),
]
@pytest.mark.parametrize(
"nums, ans",
deepcopy(TEST_SUITS)
)
def test(nums, ans):
SOL.mov... | hongtw/coding-life | leetcode/0283.Move-Zeroes/MoveZeroes_test.py | MoveZeroes_test.py | py | 361 | python | en | code | 1 | github-code | 90 |
18313732339 | # -*- coding: utf-8 -*-
import sys
import math
import os
import itertools
import string
import heapq
import _collections
from collections import Counter
from collections import defaultdict
from collections import deque
from functools import lru_cache
import bisect
import re
import queue
import decimal
class Scanner()... | Aasthaengg/IBMdataset | Python_codes/p02850/s170382565.py | s170382565.py | py | 3,400 | python | en | code | 0 | github-code | 90 |
27921053891 | # -*- coding: utf-8 -*-
#
# PySceneDetect: Python-Based Video Scene Detector
# ---------------------------------------------------------------
# [ Site: http://www.bcastell.com/projects/PySceneDetect/ ]
# [ Github: https://github.com/Breakthrough/PySceneDetect/ ]
# [ Documentation: htt... | sibozhang/Text2Video | venv_vid2vid/lib/python3.7/site-packages/scenedetect/frame_timecode.py | frame_timecode.py | py | 20,620 | python | en | code | 381 | github-code | 90 |
6663385380 | from pathlib import Path
from watchdog.observers import Observer
from watchdog.events import FileSystemEventHandler, FileSystemEvent
import time
from datetime import datetime
class StoredEventHandler(FileSystemEventHandler):
"""Stores all the events captured."""
def __init__(self) -> None:
super().__... | jamesWalker55/watchdog-test-cases | utility.py | utility.py | py | 3,117 | python | en | code | 0 | github-code | 90 |
5838104057 | import numpy as np
from scipy.optimize import leastsq
import pylab as plt
N = 1000 # number of data points
t = np.linspace(0, 4*np.pi, N)
data = 3.0*np.sin(t+0.001) + 0.5 + np.random.randn(N) # create artificial data with noise ndarray
data_guess = [np.mean(data), 3*np.std(data)/(2**0.5), 0, 1] # std, freq, phase, ... | salomeow/fyp_server_py | leastsq.py | leastsq.py | py | 2,105 | python | en | code | 0 | github-code | 90 |
21893541145 | import folium
import pandas as pd
import matplotlib.pyplot as plt
pd.set_option('display.max_rows', None)
pd.set_option('display.max_columns', None)
pd.set_option('display.width', None)
pd.set_option('display.max_colwidth', None)
# TODO: - allow user to change the date of the depicted data through the web page... | zouvier/COVID-19-HEAT-MAP | webmap.py | webmap.py | py | 3,395 | python | en | code | 0 | github-code | 90 |
18543479859 | a, b, c, x, y = map(int, input().split())
ans = float('inf')
for i in range(10 ** 5 + 1):
price = i * 2 * c
if x > i:
price += a * (x - i)
if y > i:
price += b * (y - i)
ans = min(ans, price)
print(ans)
| Aasthaengg/IBMdataset | Python_codes/p03371/s885414560.py | s885414560.py | py | 237 | python | en | code | 0 | github-code | 90 |
45112768483 |
#O seguinte algoritmo sorteia um aluno de uma lista
from random import choice
lista = []
n = 0
while n<10:
lista.append(str(input("Digite o nome do aluno [{}]: " .format(n))))
n+=1
print("A pessoa escolhida foi: {} " .format(choice(lista))) | G4BR-13-L/my-pyhton-journey | 11 - 20/ex019.py | ex019.py | py | 251 | python | pt | code | 1 | github-code | 90 |
42367435111 | import sys
import numpy as np
def read_data(filename):
title = []
data = []
i=0
with open(filename) as f:
for line in f:
try:
l = line.strip(' \r\n').split(' ')
data.append(list(map(f... | Moirai7/environment | EnvironmentalData/range.py | range.py | py | 972 | python | en | code | 0 | github-code | 90 |
7245501302 | #!/usr/bin/python
'''
Data loading and pre-processing functions
'''
import os
import glob
import tempfile
import numpy as np
import pandas as pd
import re
from Bio import SeqIO
import pyranges as pr
import matplotlib as mpl
import matplotlib.pyplot as plt
import sklearn
from sklearn.metrics import roc_curve
from skle... | pkhoueiry/TempoMAGE | load_data.py | load_data.py | py | 7,923 | python | en | code | 1 | github-code | 90 |
25043539212 | #!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
* find all markdown files in specified root
* convert files into html
* translate via API
* all files are sent in one request per target language
* write results back, as html
"""
import requests
import datetime
import werkzeug
import json
import time
import os
impor... | hotmaps-docker/gollum | wikitranslate/translate.py | translate.py | py | 4,501 | python | en | code | 1 | github-code | 90 |
30731754108 | from StringIO import StringIO
from flask import Response
from sqlalchemy import text
from ohm.extensions import db
def _copy_sql(sql, params, buf):
conn = db.engine.raw_connection()
c = conn.cursor()
sql = c.mogrify(sql, params)
sql = "COPY ({}) TO STDOUT WITH CSV HEADER".format(sql)
c.copy_expe... | billyfung/flask-template | app/api/utils.py | utils.py | py | 715 | python | en | code | 0 | github-code | 90 |
1987492875 | import sys
import argparse
def parseFasta(filename):
fas = {}
id = None
with open(filename, 'r') as fh:
for line in fh:
if line[0] == '>':
header = line[1:].rstrip()
id = header.split()[0]
fas[id] = []
else:
fas... | Github-Yilei/genome-assembly | Python/fasta2phylip.py | fasta2phylip.py | py | 2,061 | python | en | code | 2 | github-code | 90 |
18341398989 | import sys
input=sys.stdin.readline #文字列入力はするな!!
import heapq
n,m=map(int,input().split())
a=[]
for i in input().split():
heapq.heappush(a,-int(i))
for i in range(m):
p=-heapq.heappop(a)
p=p//2
heapq.heappush(a,-p)
print(-sum(a))
| Aasthaengg/IBMdataset | Python_codes/p02912/s445042670.py | s445042670.py | py | 269 | python | en | code | 0 | github-code | 90 |
18206256079 | N,S = list(map(int,input().split()))
A = list(map(int,input().split()))
dp = [[0]*(N+1) for i in range(S+1)]
p = 998244353
twos = [1]*N
for i in range(1,N):
twos[i] = (twos[i-1]*2)%p
for j in range(1,N+1):
flag = 0
for i in range(1,S+1):
if flag==0:
dp[i][j] = (dp[i][j-1]*2)%p
... | Aasthaengg/IBMdataset | Python_codes/p02662/s986400757.py | s986400757.py | py | 480 | python | en | code | 0 | github-code | 90 |
72774512298 | # -*- coding: utf-8 -*-
"""
LandSurfaceClustering.py
Landon Halloran
07.03.2019
www.ljsh.ca
Land use clustering using multi-band remote sensing data.
This is a rough first version. Modifications will need to be made in order to properly
treat other datasets.
Demo data is Sentinel-2 data (bands 2, 3, 4, 5, 6, 7, ... | lhalloran/LandSurfaceClustering | LandSurfaceClustering.py | LandSurfaceClustering.py | py | 3,320 | python | en | code | 28 | github-code | 90 |
24345185621 | """ Setup info for Products.MaildropHost
$Id: setup.py 1657 2008-11-01 12:10:57Z jens $
"""
import os
from setuptools import find_packages
from setuptools import setup
NAME = 'MaildropHost'
here = os.path.abspath(os.path.dirname(__file__))
package = os.path.join(here, 'Products', NAME)
def _read(name):
f = open... | pedroardaglio/Products.MaildropHost | setup.py | setup.py | py | 1,851 | python | en | code | 1 | github-code | 90 |
72615679977 | # -*- coding: utf-8 -*-
"""
@author: Sergio GARCIA-VEGA
sergio.garcia-vega@postgrad.manchester.ac.uk
The University of Manchester, Manchester, UK
BigDataFinance, Work Package 1, Research Project 1
Id: Main_VECM.py
"""
import os
import pickle
import numpy as np
import pandas as pd
from os import listdir
i... | xiaogaogaoxiao/PRL-2020 | Main_VECM.py | Main_VECM.py | py | 3,318 | python | en | code | 0 | github-code | 90 |
36517172159 | s=input()
l=s.split()
l1=l[-1]
l2=[]
l3=[]
for i in l1:
if i.isupper():
l2.append(i)
else:
l3.append(i)
if (min(l3).upper()) in l2:
print(min(l3))
else:
print(min(l1)) | 20A91A04O3/codemind-python | minimum_elemnt_from_a_string.py | minimum_elemnt_from_a_string.py | py | 199 | python | en | code | 0 | github-code | 90 |
18155234849 | import numpy as np
# import math
# import copy
# from collections import deque
import sys
input = sys.stdin.readline
# sys.setrecursionlimit(10000)
from numba import njit,i8
@njit(i8[:](i8,i8[:],i8[:],i8,i8,i8))
def SerchLoop(M,A,cnt,start,end,temp):
for i in range(1,M+2):
temp = A[i-1] ** 2
temp ... | Aasthaengg/IBMdataset | Python_codes/p02550/s742978683.py | s742978683.py | py | 1,731 | python | en | code | 0 | github-code | 90 |
31875859527 | """
Every three lines are a single group.
Get an intersection character of the lines.
Get the sum as in part no. one.
"""
with open("data/3.txt", "r") as f:
data = f.readlines()
list1 = [x.replace("\n", "") for x in data]
list2 = [list1[x:x + 3] for x in range(0, len(list1), 3)]
list3 = []
for x in list2:
se... | xSilence8x/advent_of_code_2022 | 3-2nd_part.py | 3-2nd_part.py | py | 751 | python | en | code | 0 | github-code | 90 |
73388153896 | import sqlite3
from sqlite3 import Error
import configparser
config = configparser.ConfigParser()
config.read('config.ini')
DB_FILE = config['DEFAULT']['DB_FILE']
CREATE_PLAYLIST_TABLE = '''
CREATE TABLE IF NOT EXISTS playlistKeys (
id integer PRIMARY KEY,
playlist_name NOT NULL,
rfid text,
added_date te... | jefure/mpd_rfid | repository.py | repository.py | py | 3,685 | python | en | code | 0 | github-code | 90 |
73562520298 | import pygame
from color import BLACK
from animation import Animation
pygame.mixer.init()
pygame.mixer.pre_init(44100, -16, 2, 512)
class Player:
def __init__(self, x, y):
# base img
self.animation = Animation()
self.animation_frames = self.animation.animation_frames
self.animati... | ChuDucAnh242002/Moraq_baby | player.py | player.py | py | 4,243 | python | en | code | 1 | github-code | 90 |
29161057727 | import curses
import curses.ascii
import sys
from . import kernel
from . import setting
def ctrl(c):
"""Take str/bytes and return int"""
return curses.ascii.ctrl(ord(c))
# isspace(3) isgraph(3) isprint(3)
# 0x09 '\t' True False False
# 0x0A '\n' True False False
# 0x0B '\v' Tr... | woutershep/fileobj | src/kbd.py | kbd.py | py | 3,512 | python | en | code | null | github-code | 90 |
31836566619 | # PERSEGI
def hitung_luas_persegi(): # membuat fungsi
sisi1 = float(input("Masukkan panjang persegi: ")) # input sisi dengan tipe data float
sisi2 = float(input("Masukkan lebar persegi: ")) # input sisi dengan tipe data float
luas = sisi1 * sisi2 # menggunakan rumus persergi
return luas # mengembalikan ... | rizqy6/PTTHON | UTS/soal1.py | soal1.py | py | 1,363 | python | id | code | 0 | github-code | 90 |
18497927399 | H,W = map(int,input().split())
a =[list(map(int,input().split())) for i in range(H)]
serching_pair = False
pair_count = 0
ans = []
#蛇行運転しながら奇数ペアを見つけるたびに出力
for i in range(H):
if i%2 == 0:#左から右
for j in range(0,W,1):
if a[i][j]%2==1:
if serching_pair:
ans[pair... | Aasthaengg/IBMdataset | Python_codes/p03263/s394612166.py | s394612166.py | py | 1,364 | python | en | code | 0 | github-code | 90 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.