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 |
|---|---|---|---|---|---|---|---|---|---|---|
f3801ef046106714590c3dca778507bd86e2b7b0 | fhamborg/se19hyperpartisanbvs | /Preprocessing/row2elmo.py | UTF-8 | 4,890 | 2.5625 | 3 | [
"Apache-2.0"
] | permissive | #!/usr/bin/env python
'''
NOTE: This uses the alannlp PyTorch implementation of Elmo!
Process a line corpus and convert text to elmo embeddings, save as json array of sentence vectors.
This expects the sents corpus which has fields title, article, domains. and treates
title as the first sentence, then splits the articl... | true |
2696c02987e390ad5777ece90d6a6939167975f2 | ivonu/eth-data-minig | /project02-svm/code/crossvalidation.py | UTF-8 | 2,255 | 2.609375 | 3 | [] | no_license | #!/usr/bin/env python2.7
import sys
import fileinput
import numpy as np
import mapper_copy as mapper
BUCKET_FILE_PREFIX = "../data/training"
TRAINING_TXT = "../data/training.txt"
pegasos_k = 10
k = 10
bucket_size = 10000
errmin = sys.float_info.max
best_lambda = 0
lambdas = [0.1, 1, 0.01, 0.001, 0.0001, 0.00001]... | true |
8a7dee1314b52e8f3524ea9105925f4ca42b597e | sgkang/vtki | /tests/test_geometric_objects.py | UTF-8 | 506 | 2.609375 | 3 | [
"MIT"
] | permissive | import numpy as np
import vtki
def test_cylinder():
surf = vtki.Cylinder([0, 10, 0], [1, 1, 1], 1, 5)
assert np.any(surf.points)
assert np.any(surf.faces)
def test_arrow():
surf = vtki.Arrow([0, 0, 0], [1, 1, 1])
assert np.any(surf.points)
assert np.any(surf.faces)
def test_sphere():
s... | true |
353e942f0048cdd47136a25b26bed0ce9f0c8802 | ZhengLiangliang1996/Speech-Recogniton-Tool-Box | /utils/split_data.py | UTF-8 | 2,325 | 3 | 3 | [
"MIT"
] | permissive | """
Author: Liangliang ZHENG
Time: 2020/3/06
Split the MFCC npy data in the samples files to training and test set
"""
import split_folders
import sys
import os
import random
import shutil
sys.path.append('..')
# Copy the file to train dev and test folder
def copy_file(filename_list, input_path, output_path):
... | true |
a52bc344eec07d72a9e19fb1bb0b7f0a03f07140 | kvklink/full-OMR-pipeline | /dewarp/deskew.py | UTF-8 | 4,842 | 2.6875 | 3 | [
"MIT"
] | permissive | import math
import numpy as np
from denoise.denoise import *
from utils.util import *
# ====== PARAMS =====================================
# All Hough
RHO = 1 # 1 pixel
THDEG = 90 # 90 degrees
# Std Hough
THRES = 500
# Prob Hough
PTHRES = 600
MIN_PRC = 60
MAX_PRC = 5
# =================================... | true |
76f7f23a156ec376fc723548f5b85fc3e49ed2f9 | cswangjiawei/pytorch-char-cnn-text-classification | /main.py | UTF-8 | 3,403 | 2.578125 | 3 | [] | no_license | import argparse
from util import load_datasets
import time
from model import CharCNN
import torch.nn as nn
import torch.optim as optim
from torch.optim.lr_scheduler import StepLR
from train import train_model, evaluate
from torch.utils.tensorboard import SummaryWriter
import os
import torch
import random
import numpy a... | true |
8eb7065b25d32142565b637e253802789218d139 | astride09/projet1 | /experience1.py | UTF-8 | 7,978 | 2.515625 | 3 | [] | no_license | import matplotlib.pyplot as plt
from keras.datasets import mnist
from keras.optimizers import Adam
from keras.models import Sequential, Model
from keras.layers import Dense, Activation, Flatten, Input, BatchNormalization, Reshape
from keras.layers.advanced_activations import LeakyReLU
from sklearn.model_selection... | true |
dea3cb5e551c3c6811b1938db15f6a891539dd0e | mendez6412/Stack-Pracitce | /stack.py | UTF-8 | 1,214 | 3.765625 | 4 | [] | no_license | class InvalidCapacity(Exception):
pass
class StackOverflow(Exception):
pass
class StackUnderflow(Exception):
pass
class Stack:
def __init__(self, capacity=10, values=None):
if not isinstance(values, list):
values = []
elif len(values) > capacity:
raise Stack... | true |
ec205361577f8b81ddfb4534befd8c82ad9b562b | cyjhunnyboy/PythonTutorialProj | /pers/cyj/day02/02-print输出/print输出.py | UTF-8 | 338 | 4.5 | 4 | [] | no_license |
# 打印到屏幕上一些信息
print("Sunny is a good woman!")
print("Tom is a good man!")
# 打印多行信息
# 可以接受多个字符串,用逗号分隔,遇到逗号会输出一个空格
print("John is a good man!", "Ann is a good woman!")
# 输出数字
print(18)
# 输出运算结果
print(10 + 8)
print("10 + 8 = ", 18)
| true |
303b8eb535371435b68bb988ef1916333028ba9c | Programacion-Algoritmos-18-2/tarea-03-tutoria-chjuca | /paquete1/modelado.py | UTF-8 | 1,751 | 3.734375 | 4 | [] | no_license | class Docente: # Creamos la Clase Docente
def __init__(self,n,a): # Creamos el Metodo __init__
self.nombre=n # Atributo nombre de la clase Docente
self.ciudad=a # Atributo ciudad de la clase Docente
def setNombre(self,n): #Funcion da valor n el atributo nombre
self.nombr... | true |
15848162ca9b0d8ed89b675d849e24fa445fe731 | Maryville-SWDV-610-3W18SP2/week-4-stacks-queues-and-lists-CodeNamor | /PythonStackwithLinkedList.py | UTF-8 | 987 | 4 | 4 | [] | no_license | #F. Derek Roman - GitHub Profile CodeNamor
#SWDV-610-3W - Data Structures
#Unit 4 Assignment - I Attest that this is my own work
class Stack:
#Constructor creates a list
def __init__(self):
self.stack = list()
#Adding elements to stack
def push(self, data):
#check to avoi... | true |
5a8b595fa4b3dfb325cb9d630378297a7f0adae9 | xiaoyulyu2020/labsheet | /patient_v1_142.py | UTF-8 | 258 | 3.40625 | 3 | [] | no_license | #!/usr/bin/env python3
class Patient(object):
def __init__(self, name, age, doctor):
self.name = name
self.age = age
self.doctor = doctor
def __str__(self):
return f"Name: {self.name}\nAge: {self.age}\nDoctor: {self.doctor}"
| true |
8619ea0aa7b997234dc55911c333a598261cfff6 | seojinsarejj/TIL | /coding-test/practice/chapter01/볼링공고르기.py | UTF-8 | 214 | 3.421875 | 3 | [] | no_license | # 1차
def solution(ball):
n = len(ball)
cnt = 0
for i in range(n):
if ball[i] in ball[i+1:]:
cnt += 1
return n * (n-1) // 2 - cnt
print(solution([1,5,4,3,2,4,5,2]))
# 2차 | true |
1fe640ef8ae4e92c0ef59d852e7f72843644349c | wlwx/python-sdk | /Demo.py | UTF-8 | 1,160 | 2.6875 | 3 | [] | no_license | #!/usr/bin/python3
# -*- coding:utf-8 -*-
#filename:Demo
__author__ = 'zhouzhao'
import requests,json,hashlib
from urllib.parse import quote
def send_sms():
# 短信提交地址,请联系管理员获取
url = 'http://127.0.0.1:8861'
# 用户账号,必填
uid = "XXXXXX"
# 用户密码,必填
pwd = "XXXXXXXXX"
# 长号码,选填
srcphone = "10690013... | true |
c01153e28934689c62478421900f2f752f787714 | seiya-kumada/cct_blog | /quantum_entanglement/main.py | UTF-8 | 384 | 2.84375 | 3 | [] | no_license | #!/usr/bin/env python
# -*- coding:utf-8 -*-
import blueqat as bq
if __name__ == "__main__":
# 2量子ビットを使う回路
c = bq.Circuit(2)
# アダマールゲートを最初のビット(0)に適用
x = c.h[0]
# 2つのビット(0,1)にCNOTゲートを適用
x = x.cx[0, 1]
# 1000回測定する。
y = x.m[:].run(shots=1000)
print(y)
| true |
f8e3e373aaf9eae9deed46b12be1ef54484251de | boop34/adventofcode-2020 | /day_1/day_1.py | UTF-8 | 879 | 3.75 | 4 | [] | no_license | #!/usr/bin/env python3
from input import arr
# make a dictionary of the iputs to do a O(1) lookup
ip_dict = {i: True for i in arr}
# two numbers that add upto 2020
for i in arr:
if ip_dict.get((2020 - i), False) and i != (2020 - i):
# print(f"{i} * {2020 - i}: {(2020 - i) * i}")
print((2020 - i) ... | true |
85c9ac23faf583d76c8993b1f7f0a6e00b3e0f24 | 19as/greenatom-ml-2019-11 | /source/images/bases/base-data/packages/smart_hr/data/dismissal.py | UTF-8 | 2,720 | 2.828125 | 3 | [] | no_license | #!/usr/bin/env python
# -*- coding: utf-8 -*-
import os
from dataclasses import dataclass, asdict
from datetime import datetime
from typing import ClassVar
import pandas as pd
data = {}
@dataclass
class FeatureImportance:
filename: ClassVar = None
updated_at: ClassVar = None
feature_name: str
impo... | true |
4cfe2e110ae53ec98775ff875d43609a1fcf10ea | dehuagit/mypython | /parallel/signal1.py | UTF-8 | 349 | 2.609375 | 3 | [] | no_license | import sys, signal, time
def now():
return time.ctime(time.time()) #current time string
def onSignal(signum, stackframe): # python signal handler
print('Got signal', signum, 'at', now()) # most handler stay in effet
signum = int(sys.argv[1])
signal.signal(signum, onSignal) # install signal handler
w... | true |
5652f91ee8c44c8aad46612eb44233dd8356b54e | Siegfriedchao/HoloBlade | /fpga_firmware/myhdl_dev/src/fifo.py | UTF-8 | 3,072 | 2.578125 | 3 | [] | no_license | import sys
import traceback
import myhdl
from myhdl import *
class Error(Exception):
pass
def fifo(dout, din, re, we, empty, full, clk, maxFilling=sys.maxsize):
""" Synchronous fifo model based on a list.
Ports:
dout -- data out
din -- data in
re -- read enable
we -- write enabl... | true |
ba8cd8d64fc159aa4c38c80d90b5b132e5cf2bda | 3ZadeSSG/ContentBased-Movie-Recommendation-using-Sentiment-Analysis | /3. Google Cloud Deployment of Model with Recommendation System Code/commons.py | UTF-8 | 4,808 | 2.796875 | 3 | [
"MIT"
] | permissive | ''' same code from the Training With Preprocessed Data Notebook
with getSetSentimentPredictionResult function written to load
model, perform tokenization on given string and return the result
'''
import torch.nn as nn
import io
from string import punctuation
from collections import Counter
import torch
impor... | true |
5099954b1b033372703e1b940ea7c74895bfb95e | Aasthaengg/IBMdataset | /Python_codes/p03311/s567154750.py | UTF-8 | 172 | 2.828125 | 3 | [] | no_license | N = int(input())
A = list(map(int,input().split()))
A = [A[i] - i for i in range(N)]
A.sort()
b = A[N//2]
ans = 0
for i in range(N):
ans += abs(A[i] - b)
print(ans) | true |
b17045dc086940a195d7606a5a527d404f2cb57a | cmahadeo/DnDnC | /tutorial/lessons/03 - FUNCTIONS.py | UTF-8 | 4,303 | 4.5 | 4 | [] | no_license | # MODULE
# global a, b
def f(x):
'''
This function takes a number x, and returns its square value.
1. What are the arguments, and their types? x is a float, or int type.
2. What does your function do? Squares x!
3. What does your function output? Returns the square of x.
'''
... | true |
613dad4b909e5529de19dca8a623ecaab21e6516 | lpfan/time_tracker | /tracker/shared_lib/decorators.py | UTF-8 | 735 | 2.8125 | 3 | [] | no_license | import flask
from functools import wraps
def validate_input(method):
"""Decorator allows to validate input data for HTTP handler"""
def wrapper(self, *args, **kwargs):
validator_name = '%s_validator' % (flask.request.method.lower(),)
validator = getattr(self, validator_name, None)
i... | true |
231898a6c4f4b00acb9777c86a8a844206718c92 | thedrkpenguin/CPT1110 | /Week 13/cashRegister.py | UTF-8 | 1,042 | 4.375 | 4 | [] | no_license | # Programming Exercise 10-7
import retail
class CashRegister:
# Initialize an empty list to hold purchased items.
def __init__(self):
self.__items = []
# Method that clears the contents of the cash register.
def clear(self):
self.__items = []
# Method that simu... | true |
bf144a2c79e94f8a2982db74326a710df31c4334 | onisz/py | /end_count_sum.py | UTF-8 | 145 | 3.5625 | 4 | [] | no_license | s = 0
while True:
n = input("Введите число: ")
n1 = str(n)
if n1 == "Стоп":
break
s += float(n)
print(s)
| true |
a25fd8a2c477d5e0d1aa48dea9b9f64c204dd009 | Platforuma/Beginner-s_Python_Codes | /9_Loops/21_For_Dictionary--sorting-by-keys.py | UTF-8 | 274 | 4 | 4 | [] | no_license | '''
Write a Python program to sort a dictionary by key
'''
dic = {'India': 'Delhi',
'Nepal': 'Kathmandu',
'Japan': 'Tokyo',
'China': 'Beijing',
'England': 'London'}
print(dic)
for i in sorted(dic):
print("%s: %s" %(i, dic[i]))
| true |
84299cc5f1a0dec9339573419920a7bd901e377e | mohsenabedelaal/holbertonschool-python | /0x01-python-if_else_loops_functions/101-remove_char_at.py | UTF-8 | 148 | 3.390625 | 3 | [] | no_license | #!/usr/bin/python3
def remove_char_at(str,n):
if n > len(s):
return str
else:
return s = "{:s}".format(str[:n] + str[n+1:])
| true |
3e695c0f5493e65b918d06111edf15bbcbf51f7b | BEEmod/BEE2.4 | /src/precomp/conditions/marker.py | UTF-8 | 5,111 | 2.921875 | 3 | [] | no_license | """Conditions that read/write a set of positional markers."""
from __future__ import annotations
import attrs
from srctools import Property, Entity, Vec, Matrix
import srctools.logger
from precomp.conditions import make_flag, make_result
COND_MOD_NAME = 'Markers'
# TODO: switch to R-tree etc.
MARKERS: list[Marker] =... | true |
1f19199e1e137e2d6e7ff48ec610b1be2d0348a7 | zhzenghui/crt- | /python练习/break.py | UTF-8 | 164 | 3.1875 | 3 | [] | no_license | #Filename : break.py
while True:
s = raw_input('Enter sonmeThing : ')
if s == 'quit':
break
print 'Length of the string is',len(s)
print 'Done' | true |
41ea5661b6d2e24741e9f3724726d78984b68dd8 | vmizener/euler | /src/problems/p0049/main.py | UTF-8 | 1,525 | 3.515625 | 4 | [] | no_license | from itertools import combinations, permutations
from functools import reduce
from operator import add
from ...utils.primes import Primes
def main():
# Set used to keep track of what has already been tested
D = set()
# Collection used to check if a number is prime
primes = Primes()
# Set ... | true |
31f744e2c1183833dd65a8de2455d020097913d2 | kevinchan159/pixelcode | /app/src/pixelcode/plugin/layers/text.py | UTF-8 | 767 | 2.703125 | 3 | [] | no_license | from .text_span import TextSpan, params_equal
from . import *
class Text(BaseLayer):
"""
Class representing a Text layer in Sketch
"""
def parse_elem(self, elem):
"""
Args:
Refer to args in __init__
"""
t = elem["children"]
textspan = []
i = 0
while i < len(t):
tspan = ... | true |
b2797a6fbbe7986ce00aefbc4f5222b046e1cb8f | hwqDqwh/Python-jk | /super_python/week03/part1/scanner.py | UTF-8 | 8,903 | 2.875 | 3 | [] | no_license | # -*- coding: utf-8 -*-
import argparse
import os
import queue
from multiprocessing import Process, Queue
import threading
import time
import socket
import json
class Scanner:
"""
scanner class 检查各IP段和端口可用性的扫描器
"""
can_use_ip_list = Queue()
cant_use_ip_list = Queue()
can_use_port_list = Queue... | true |
3797f3eeb201a7c08f4c0cc32d72897385a164b4 | SammyH1994/gittest | /naam.py | UTF-8 | 176 | 3.4375 | 3 | [] | no_license | import random
NAMES = ['Stephen', 'Daan', 'Kees', 'Dennis', 'Gerard', 'Lisa']
def get_name():
return random.choice(NAMES)
print("Hey, ik ben {naam}".format(naam=get_name())) | true |
33561c135421d1db398b324b4fa59e68b8a32eda | nemux/AVAAR | /Reporter/lib/gcs/reportdata.py | UTF-8 | 8,666 | 2.6875 | 3 | [] | no_license | #!/usr/bin/env python
# -*- coding: UTF-8 -*-
"""
package.module
~~~~~~~~~~~~~
A description which can be long and explain the complete
functionality of this module even with indented code examples.
Class/Function however should not be documented here.
:copyright: 2014 by NeMuX, see AUTHORS for more details
:license... | true |
9f76c4f95d129809bbe7122dd6971ee597d7585a | arielbro/TimeSeriesNetworkInference | /attractor_learning/cyclic_conversion_script.py | UTF-8 | 6,783 | 2.640625 | 3 | [
"MIT"
] | permissive | """
A script for the specific conversion (and a small model bug fix) for models IL-1, IL-6, EFGR and MAPK,
creating a cyclic and acyclic version that I could later test model building on.
"""
import graphs
import logic
import sympy
import networkx
import os
def to_acyclic(G, cycle_edges):
"""
Creates and ret... | true |
df983577d1bb844526d8ab282cf50ee56e4513dc | LeonNie52/AlgorithmPrac | /Leetcode/reverseInteger.py | UTF-8 | 499 | 4.3125 | 4 | [] | no_license | """
Reverse digits of an integer.
Example1: x = 123, return 321
Example2: x = -123, return -321
"""
class Solution(object):
def reverse(self, x):
"""
:type x: int
:rtype: int
"""
if x == 0:
return 0
sign = 1 if x > 0 else -1
reverse = str(sign... | true |
bc29c15fbaa64b623221411048db6bea440e1a8f | pordnajela/AlgoritmosCriptografiaClasica | /Transposicion/TransposicionSimple.py | UTF-8 | 2,607 | 3.328125 | 3 | [
"Apache-2.0"
] | permissive | #!/usr/bin/env python3
# -*- coding: UTF-8 -*-
class TransposicionSimple(object):
def __init__(self, cadena=None):
self.cadena = cadena
self.bloque1 = list()
self.bloque2 = list()
self.textoCifrado = ""
self.textoClaro = ""
def cifrar(self, cantidadRelleno=0):
textoCifrado = ""
saltosLinea = len(self.... | true |
664a8f5c5869da31b5d083486cc3e1f6ee5961dc | ccallen001/Playing-w-Python | /password_strength.py | UTF-8 | 704 | 3.625 | 4 | [] | no_license | """Password Strength Checker"""
import pyperclip
import re
import sys
def main():
try:
pw = sys.argv[1]
except IndexError:
print("Please provide a password through the command line.")
quit()
length = re.compile('\w{8}')
down = re.compile('[a-z]')
up = re... | true |
50b5df944614b350e712f43411020bc6884172c7 | xuhuanyunxiao/jupyter-notebook | /proj_mfa/clustering/dao/mysql/base_data_view.py | UTF-8 | 4,984 | 2.515625 | 3 | [] | no_license | #!/usr/bin/python
# -*- coding: utf-8 -*-
import langid
from db_mysql import BaseMysql
from entity import ClusterMessageObj
group_id_dict = {
1: ([1, 5, 13], 0),
2: ([7, 16], 1),
3: ([2, 3, 4, 11], 0),
4: ([15], 1),
5: ([16], 1)
}
class BaseDataView(BaseMysql):
def __init__(self):
s... | true |
56e302b86edfeb25d22a58ce9ad05a8a1b74eae8 | ecaoili24/AirBnB_clone_v3 | /api/v1/views/users.py | UTF-8 | 2,977 | 2.8125 | 3 | [
"LicenseRef-scancode-public-domain"
] | permissive | #!/usr/bin/python3
"""
Create a new view for Amenity objects that handles
all default RESTful API actions
"""
import os
from flask import Flask, jsonify, abort, request
from models import storage
from api.v1.views import app_views
from models.user import User
@app_views.route('/users', methods=['GET'], strict_slashes... | true |
d2f4b66d16627056ac3ad0692fec5a0047fb78eb | cleilsonjose/algoritmo | /uri 1175.py | UTF-8 | 127 | 3.1875 | 3 | [] | no_license | N=[None ]*20
for i in range(20):
N[i] = int(input())
for i in range(20):
print("N[%d] = %d" %(i,N[19-i]))
| true |
7e55ae061b0febe347bb265454193c59352f14b8 | martin-bjork/testGame | /GamePlay/shapes.py | UTF-8 | 15,631 | 3.390625 | 3 | [] | no_license | # Classes that represent objects in the game, such as moveable boxes,
# world boundaries, walls, etc.
from __future__ import division
from math import pi
import pygame
import pymunk
import yaml
from Physics import collision_callbacks as col_call
from Graphics import view
# TODO: Add properties such as friction and ... | true |
2e3f70ff0ae59d4d7bb3b14380be4c97a60d981f | Gawss/api-model-ggj | /server.py | UTF-8 | 4,157 | 2.609375 | 3 | [] | no_license | from keras.layers import Input
from keras.layers import Dense
from keras.models import Sequential
from keras.models import model_from_json
from sklearn.preprocessing import MinMaxScaler
import csv
from flask import Flask, jsonify, request
inputs_ = []
outputs_ = []
inputs_testing = []
#GET INPUTS FOR TRAINING
with op... | true |
a1a1eadd841bc06d21e3466d4eb51428217289d0 | emanuele/tutorial_ht_classifiers | /cv_issues.py | UTF-8 | 15,239 | 3.03125 | 3 | [] | no_license | """This experiment compares the effects of the statistical dependency
between the predictions across the folds of cross-validation when
performing statistical tests. The comparison is computed over:
- Student's 1-sample t-test on the accuracies across the folds.
- Binomial test on the sum of the correct predictions acr... | true |
ec8e933a1d747da5018760508db16f56f5f8e37e | cvtai2409/BTpyBuoi2 | /book3.py | UTF-8 | 143 | 3.515625 | 4 | [] | no_license | N = int(input("Nhap N: "))
TongL = 0
for i in range (1, N+1):
if (i % 2 != 0):
TongL = TongL + i
print(f"Tong le la: {TongL}") | true |
4327d37605c33584113d668ae05db596f8426b65 | zhengchaoxuan/Lesson-Code | /Python/Python基础/day 13/验证类在另一个类中调用方法.py | UTF-8 | 856 | 3.65625 | 4 | [] | no_license | """
lesson 1 : 演示了100个线程向同一个银行账户转账(转入1元钱)的场景
Author : 郑超轩
Date : 2020.02.28
"""
class Account(object,):
def __init__(self):
self._balance = 0
def deposit(self,money):
"""计算存款的余额"""
new_balance = self._balance + money
#受理的时间0.1s
self._balance = new_balance
... | true |
08385c549545536a3d92def0630cff4ca10da7ac | dcgfz2/OTP-Keygen-and-Encryption | /bin_otp.py | UTF-8 | 895 | 2.765625 | 3 | [] | no_license | #!/usr/bin/env python3
# -*- coding: utf-8 -*-
import sys
with open (sys.argv[1], 'r') as sinput:
lineNumber = 0
while lineNumber < int(sys.argv[2]):
KEY = sinput.readline()
lineNumber += 1
KEY = KEY[4:]
KEY = KEY.rstrip()
with open (sys.argv[3], 'r') as sinput:
INPUT = sinput.read()
INPU... | true |
531f68e8d5f591e5e0286b8c7cca32aa1198118e | 356108814/study | /Algorithm/sort/merge.py | UTF-8 | 1,532 | 4.15625 | 4 | [] | no_license | # encoding: utf-8
"""
归并排序
迭代法
申请空间,使其大小为两个已经排序序列之和,该空间用来存放合并后的序列
设定两个指针,最初位置分别为两个已经排序序列的起始位置
比较两个指针所指向的元素,选择相对小的元素放入到合并空间,并移动指针到下一位置
重复步骤3直到某一指针到达序列尾
将另一序列剩下的所有元素直接复制到合并序列尾
递归法
原理如下(假设序列共有n个元素):
将序列每相邻两个数字进行归并操作,形成 {\displaystyle floor(n/2)} floor(n/2)个序列,排序后每个序列包含两个元素
将上述序列再次归并,形成 {\displaystyle floor(n/4)} floor(n/... | true |
bf01cf1f8ee2b5d6e74e733aaab401013d1fb536 | mrAvi07/data_structures_algorithms | /3. Array/dvd_question.py | UTF-8 | 580 | 3.671875 | 4 | [] | no_license | class DVD:
def __init__(self, name, director, year):
self.name = name
self.director = director
self.year = year
if __name__=="__main__":
dvd1 = DVD("love song", "anupam khair", 2002)
dvd2 = DVD("SAD song", "Ashish chanchlani", 2008)
dvd3 = DVD("masups song", "gabbar singh", 1... | true |
d547a680890f9bbbbb1d9ed67345c7cca329bf12 | vinheim3/Advent-of-Code | /y19/day12/code.py | UTF-8 | 2,980 | 3.484375 | 3 | [] | no_license | import math
import re
from util import get_fname
fname = get_fname(__file__)
class Moon:
def __init__(self, x, y, z):
self.x = x
self.y = y
self.z = z
self.vel_x = 0
self.vel_y = 0
self.vel_z = 0
self.initial_x = x
self.initial_y = y
self.... | true |
e980c13bb41dc191c149dfc21a97f46cdf1c814d | wuyongqiang2017/AllCode | /day34/re模块.py | UTF-8 | 4,771 | 3.59375 | 4 | [] | no_license | #元字符:. ^ $ + ? {}
import re
# ret= re.findall("a..in","helloalvin")
# print(ret)
# ret=re.findall("^a...n","albinhelloawwm")
# print(ret)
# ret = re.findall('a..n$','albinhhelloawwn')
# print(ret)
# ret = re.findall('abc*','abcccc')#[0,+oo]
# print(ret)
# ret=re.findall('abc?','abccc')#[0,1]
# print(ret)
# ret=re.finda... | true |
7e03c058ed6edff8afa397b2b099a940a06a1880 | theartofcleancode/pythonapi | /pythonapi/tupledict_request.py | UTF-8 | 326 | 2.640625 | 3 | [
"MIT"
] | permissive | from ._api import Request
class TupleDictRequest(Request):
def adapt(self, *args:([{}]), **kwargs):
data = args[0]
res = {}
for d in data:
k, v = list(d.items())[0]
if isinstance(v, tuple):
v = self.adapt(v)
res.update({k:v})
retu... | true |
d1da4a4f3e04a8c905f0612cbe0fd24c97494c93 | andreypopp/statics | /statics/cli.py | UTF-8 | 1,922 | 2.65625 | 3 | [] | no_license | """ Command line utilities."""
# TODO: This is subject to refactoring.
import sys
__all__ = ["run", "command", "message", "error", "progress"]
def message(msg):
print>>sys.stderr, msg
def error(msg, code=1):
message("error: %s" % msg)
sys.exit(code)
def progress(msg):
message("progress: %s" % m... | true |
be3f5b0b2d4dce08b40c9cc882b3a5534d4d5feb | laviniaclare/Code-Challenge | /seed.py | UTF-8 | 2,428 | 2.90625 | 3 | [] | no_license | import os
import csv
from datetime import datetime
from app_settings import app, db
from models import Host, Appartment
def create_tables():
db.reflect()
db.drop_all()
db.create_all()
db.session.commit()
def load_data():
with open('data/AB_NYC_2019.csv', mode='r') as csv_data:
csv_reader = csv.reader(csv_data... | true |
f5578d2d029f33bb5028db190f6d36160a50c254 | i-machine-think/am-i-compositional | /src/evaluate/significance_testing.py | UTF-8 | 936 | 3.203125 | 3 | [
"MIT"
] | permissive | import argparse
from scipy import stats
def p_test(results1, results2, one_sided=True):
t, p = stats.ttest_ind(results1, results2, equal_var=False)
if one_sided:
p /= 2
return p
if __name__ == "__main__":
parser = argparse.ArgumentParser()
parser.add_argument("--results1", type=float, na... | true |
0ea120516b720f3d3b772f5aa1f149cec420d03b | bupthl/Python | /Python从菜鸟到高手/chapter2/demo2.08.py | UTF-8 | 1,147 | 2.625 | 3 | [] | no_license | '''
--------《Python从菜鸟到高手》源代码------------
欧瑞科技版权所有
作者:李宁
如有任何技术问题,请加QQ技术讨论群:264268059
或关注“极客起源”订阅号或“欧瑞科技”服务号或扫码关注订阅号和服务号,二维码在源代码根目录
如果QQ群已满,请访问https://geekori.com,在右侧查看最新的QQ群,同时可以扫码关注公众号
“欧瑞学院”是欧瑞科技旗下在线IT教育学院,包含大量IT前沿视频课程,
请访问http://geekori.com/edu或关注前面提到的订阅号和服务号,进入移动版的欧瑞学院
“极客题库”是欧瑞科技旗下在线题库,请扫描源代码根目录中的小程序码安装“极客... | true |
dbdd383fd57145945a2206e13da965d2d8292d7a | nipy/nipy | /nipy/modalities/fmri/fmristat/model.py | UTF-8 | 16,447 | 2.609375 | 3 | [
"BSD-3-Clause"
] | permissive | # emacs: -*- mode: python; py-indent-offset: 4; indent-tabs-mode: nil -*-
# vi: set ft=python sts=4 ts=4 sw=4 et:
"""
This module defines the two default GLM passes of fmristat
The results of both passes of the GLM get pushed around by generators, which
know how to get out the (probably 3D) data for each slice, or par... | true |
0a12bb961001571653c38193ca506b56b46480f2 | revangel/nostalgiabot2 | /nb2/errors.py | UTF-8 | 763 | 2.671875 | 3 | [] | no_license | from flask import jsonify
def _error_response(status_code, message):
"""
Helper method for returning an API error response.
"""
payload = {
'message': message
}
response = jsonify(payload)
response.status_code = status_code
return response
def validation_error(message):
... | true |
0430bd75f60b7536c6a3026d33d71c268e30de2d | kangsl2000/Blind-Source-Separation | /BSSProject/likehoodICA.py | UTF-8 | 3,846 | 2.65625 | 3 | [] | no_license | import numpy as np
import tool
import matplotlib.pyplot as plt
#本书中提到的最大似然度的估计算法似乎比较适用于适定情况,虽然可能仅对少数的信号有作用,但是必须对与输入信号数量相同的信号进行估计
#我也不知道为啥这个算法的FastICA就是跑不起来
#我检查了半天和书上基本都是一致的,实在想不通哪儿有问题,而且此处的梯度算法虽然看起来好像能用,但是和书上的其实也是不一样的,学习率和书上的正负正好相反
def gP(y):
return -2*tool.tanh(y)
def gN(y):
return tool.tanh(y)-y
... | true |
9fe762949d4ea0c04f78dd3538a5749f923358f1 | preetmodh/COMPETETIVE_CODING_QUESTIONS | /CODECHEF/D-Dimensional MST .py | UTF-8 | 3,881 | 2.96875 | 3 | [] | no_license | #!/usr/bin/env python
from __future__ import division, print_function
from operator import itemgetter
import os
import sys
from io import BytesIO, IOBase
def main():
pass
# region fastio
BUFSIZE = 8192
class FastIO(IOBase):
newlines = 0
def __init__(self, file):
self._fd... | true |
3355c44a7bb33c5fb0e8b0fb28eeee7fd32ab9fe | ryypee/moro_ros | /moro_navigation/src/moro_navigation/shortest_path.py | UTF-8 | 1,465 | 3.28125 | 3 | [] | no_license | #!/usr/bin/env python
import numpy as np
from collections import deque
# Values for node status
VIRGIN = 0
ACTIVE = 1
DEAD = 2
def dijkstra(graph, start, goal):
"""Plan a path from start to goal using Dijkstra's algorithm.
Args:
graph (ndarray): An adjacency matrix, size (n,n)
start (int): T... | true |
e5e5db991b925b7c33047aa6833f1d5df039049d | kmykoh97/Basic-Programming-SJTU | /School/python/4rd lesson/1.py | UTF-8 | 567 | 3.78125 | 4 | [
"Apache-2.0"
] | permissive | # Shangji Practice No 1
# Meng Yit Koh
# 517030990022
from random import *
def main():
n = input("Please insert number of throws:")
squareSidesLength = input("Please insert sides length of square:")
radius = squareSidesLength / 2.0
numberOfThrows, h = n * 1.0, 0
while n > 0:# loop started until fi... | true |
ee373137596662c0c2d3661d8ea2d0fb4cefd817 | eonignis/ejercicios_clase | /Programación - Python/UF2/Practica_grupal/ex_A.py | UTF-8 | 2,651 | 3.71875 | 4 | [] | no_license | # <=== Imports ===>
import os
# <=== Variables ===>
# <--- La posición 0 SIEMPRE será descripción de lo que hay dentro de la lista --->
pez=["Lista de Peces", ["Raza", "Pisqui"], ["Nombre del Animal", "loles"], ["Nombre del Dueño", "lolita"], ["Peso", 12], ["Chip", 1234]]
perro=["Lista de Perros", ["Raza", "Pisqui"], ... | true |
68e5a964f9bd03a7dda6fbbf819399ca17f32a75 | tungvv55/ktpm2013 | /test_generation/output.py | UTF-8 | 2,479 | 2.96875 | 3 | [] | no_license | __author__='VUTUNG'
from input import *
import collections
import unittest
import itertools
#get number in docstring
def get_value(string):
lines=string.expandtabs().splitlines()
k = []
a = len(lines)
for c in range(1,a-1):
s = "".join(x if x.isdigit() else " " for x in lines[c])
digitSt... | true |
b845568a11caaeb4b6f19cd49b5ca9fe55111937 | Ankan1998/Chatbot-for-Transport-Rental-Agency | /model.py | UTF-8 | 524 | 2.53125 | 3 | [] | no_license | import torch
import torch.nn as nn
class ChatNet(nn.Module):
def __init__(self,input_size,classes):
super().__init__()
self.l1=nn.Linear(input_size,128)
self.l2=nn.Linear(128,64)
self.l3=nn.Linear(64,32)
self.l4=nn.Linear(32,classes)
self.d0=nn.Dropout(p=0.1)
self.relu=nn.ReLU()
def f... | true |
688a5816b6b50e35dd30ce9e868ee2936507a922 | supratikn/Language-Interpreter | /interpreter.py | UTF-8 | 18,500 | 3.4375 | 3 | [] | no_license | '''
Created on Feb 28, 2018
@author: Supratik Neupane
'''
# static integers that keep track of the data types
any = 0
integer = 1
string = 2
name = 3
boolean = 4
error = 5
unit = 6 # unit =["unit",unit,varname,val/arg,perv type/indices]
fun = 7
# check if the given input can be changed to an integer
def isInteger... | true |
707e305fac0ad0ad8a3b2e527996f5f75f57ce31 | nikoGao/Leetcode | /64. Minimum Path Sum/AC_Answer.py | UTF-8 | 734 | 3.3125 | 3 | [] | no_license | # Dynamic Design, this time, use path[][] to record sum. Only thing need to notice is that border of each loop.
class Solution(object):
def minPathSum(self, grid):
"""
:type grid: List[List[int]]
:rtype: int
"""
m = len(grid); n = len(grid[0])
path = [[0 for i... | true |
294f748ec9099c12cbf5182ff8536b418d6e1282 | ucn-eu/loggingserver | /vpnresolve.py | UTF-8 | 792 | 2.515625 | 3 | [] | no_license | from netaddr import IPNetwork, IPAddress
class VPNResolve(object):
def __init__( self, cidr, statusfile):
self.statusfile = statusfile
self.cidr = cidr
def clientip(self, request):
if len(request.access_route) > 1:
host = request.access_route[-1]
else:
host = request.access_route[0]
if IPAddres... | true |
fe16f72bd733606944622e57ba99af312c6b8b6b | WeikangChen/algorithm | /lintcode/93_balanced-binary-tree/balanced-binary-tree.py | UTF-8 | 812 | 3.46875 | 3 | [] | no_license | # coding:utf-8
'''
@Copyright:LintCode
@Author: chenweikang
@Problem: http://www.lintcode.com/problem/balanced-binary-tree
@Language: Python
@Datetime: 16-04-22 14:45
'''
"""
Definition of TreeNode:
class TreeNode:
def __init__(self, val):
self.val = val
self.left, self.right = None, None
... | true |
9cdb161525a55e8266191d61261c9ae0d547d4f1 | sasakishun/atcoder | /discovery2019/C.py | UTF-8 | 1,609 | 3.34375 | 3 | [] | no_license | # 入力 : 自然数 ex) 12
# 出力 : 約数リスト ex) [2, 2, 3]
def factorization(n):
R = int(n)
s = 0
L = []
div = 2
while s == 0:
for i in range(div, R + 1):
if n % i == 0:
n = n / i
div = i
if n == 1:
s = 1
L... | true |
061a7c7cbfd05ac3f463a339c74297aded119167 | YunruiZhang/Slack | /src/other.py | UTF-8 | 9,537 | 2.90625 | 3 | [] | no_license | '''
This file contains information about anything relating to all the other
functions. The methods in this file relate to listing all users, searching,
and hangman. There are some helper methods that just check the
existence of channels and users and the game state of hangman.
'''
import urllib.request
from random im... | true |
53a64d4f04e4a6dac9655c6e3ee15861bca1893d | katchum/test | /cube.py | UTF-8 | 4,145 | 3.046875 | 3 | [] | no_license | import pygame
from pygame.locals import *
from OpenGL.GL import *
from OpenGL.GLU import *
import random
vertices = (
(1, -1, -1),
(1, 1, -1),
(-1, 1, -1),
(-1, -1, -1),
(1, -1, 1),
(1, 1, 1),
(-1, -1, 1),
(-1, 1, 1)
)
edges = (
(0, 1),
(0, 3),
(0, 4),
(2, 1),
(2, ... | true |
052295f22ae7d5ec0cca0ecd6b27b70b8d6c8791 | hello-base/ohashi | /ohashi/redis/utils.py | UTF-8 | 2,244 | 2.8125 | 3 | [
"LicenseRef-scancode-warranty-disclaimer",
"MIT",
"BSD-2-Clause"
] | permissive | import collections
import redis
import time
from django.conf import settings
from django.contrib.contenttypes.models import ContentType
def build_value(instance):
return '%d:%d' % (ContentType.objects.get_for_model(instance).id, instance.id)
def factory_object(ct_obj_string):
"""
Utility function that ... | true |
7e01ef60488c501634eb69c5efb612dfcee2147d | marthakarran/Python-Challenge | /PyPoll/PyPoll_main.py | UTF-8 | 3,097 | 3.984375 | 4 | [] | no_license | #PYPOLL
# In this challenge, you are tasked with helping a small, rural town modernize its vote-counting process.
# (Up until now, Uncle Cleetus had been trustfully tallying them one-by-one, but unfortunately, his concentration isn't what it used to be.)
# You will be give a set of poll data called election_data.csv.... | true |
11489b71064173f867660b53967b6820006d52e5 | fofoni/atfa | /get-atfa-api.py | UTF-8 | 3,305 | 2.890625 | 3 | [] | no_license | #!/usr/bin/python3
# -*- coding: utf-8 -*-
"""
Universidade Federal do Rio de Janeiro
Escola Politécnica
Projeto Final de Graduação
Ambiente de Teste para Filtros Adaptativos
Pedro Angelo Medeiros Fonini <pedro.fonini@smt.ufrj.br>
Orientador: Markus Lima
"""
import sys
import pathlib
import urllib.request
from urllib... | true |
3854f7b33d7f4567098fa79d5d40fbaee5527868 | elimu-ai/ml-DataGeneratorSimulator | /model/score.py | UTF-8 | 431 | 2.921875 | 3 | [
"MIT"
] | permissive | import classifer
import pandas as pd
# Load simulated data set for experiment
df = pd.read_csv('../usage.txt',index_col=0)
# Create a model object using the loaded data
pred = classification.Model(df,'nograd')
# Run classification using 10-fold cross validation
# Classifier used: Logistic Regression (LR)
# Output fo... | true |
c9493b3b9352c4b6ce3e922d61ac6f11269af11f | PhoebeJackson/Kickstart | /2016/kickstart2016A3.py | UTF-8 | 1,381 | 3.0625 | 3 | [] | no_license | import random
def result(costs, r, M):
total=-int(costs[0])*(1+r)**(M+1)
for month in range(1,M+1):
total+=int(costs[month])*(1+r)**(M+1-month)
if total>0:
positive = True
else:
positive = False
return total, positive
T = int(input())
for test in range(1,T+1):
M = int(inp... | true |
43619ad54787b900409555633ef4f560c61fdc22 | nickramsay19/py-stat-pval | /main.py | UTF-8 | 742 | 3.109375 | 3 | [] | no_license | import math, sys
from myutils import float_range
m, s, p1, p2 = 0, 1, -10, 10
for i, arg in enumerate(sys.argv[1:]):
if i == 0: m = int(arg)
elif i == 1: s = int(arg)
elif i == 2: p1 = int(arg)
elif i == 3: p2 = int(arg)
precision = 5
snd = lambda x : (math.e**((-x**2)/2*(1**2))) / (math.sqrt(2*math... | true |
3cf957a1e3d260ffca4a876430f99e3408a42abb | qbytes-dq/Pi3CarAudio | /home/pi/python_V2/Ch18/Read_temp.py | UTF-8 | 835 | 3.171875 | 3 | [] | no_license | #Read the temperature from an LM335 from analogue input 1
#in A/D in the PCF8591P @ address 74
from smbus import SMBus
# comment out the one that does not apply to your board
bus = SMBus(0) # for revision 1 boards
#bus = SMBus(1) # for revision 2 boards
address = 74
Vref = 4.35
convert = Vref / 256
print "Read the t... | true |
9fdb36af827a21deced48039fe09942d3ee34444 | Nelcyberth86/IntroProgramacion | /funciones/ejercicio4.py | UTF-8 | 382 | 3.9375 | 4 | [] | no_license |
def letra(vocal):
if vocal == "a" or vocal == "e" or vocal == "i" or vocal == "o" or vocal == "u":
print(vocal,"es una vocal")
elif vocal!="a" or vocal == "e" or vocal == "i" or vocal == "o" or vocal == "u":
print("letra minuscula!")
else:
print(vocal,"no es una vocal")
letra1= str... | true |
23d66373cb75482f4a11a4bf295bb44ce747b78d | apai25/titanic-survival | /find_best_model.py | UTF-8 | 2,083 | 3.40625 | 3 | [] | no_license | import numpy as np
import pandas as pd
# Importing the main dataset
dataset = pd.read_csv('train.csv')
# Creating numpy arrays for independent variables X and dependent variable Y
x = dataset.iloc[:, [2, 4, 5, 9, 11]].values
y = dataset.iloc[:, 1].values
# Creating family_size array by adding SibSp and Parch
famil... | true |
4d14831853a3d080e9f6040165a93b9bd7f7a3f2 | sansan-inc/randd-engineering-training | /python_training/batch/pipeline/tasks/data_handler.py | UTF-8 | 6,143 | 2.546875 | 3 | [] | no_license | from logging import getLogger
import gokart
import numpy as np
import pandas as pd
from pipeline.tasks.data_loader import LoadCardDataTask
from pipeline.utils.node2vec import SNAP
from pipeline.utils.template import GokartTask
from sklearn.preprocessing import LabelEncoder
logger = getLogger(__name__)
class CoOccur... | true |
bf6cbbffbb47f2d03570a891eb9d2f69f807b770 | vishalhjoshi/python | /sortdict.py | UTF-8 | 132 | 2.828125 | 3 | [] | no_license | dict = {
'vishal':24,
'pradip':6,
'shubham':52,
'rizwan':45
}
print(sorted(dict.items(),key= lambda t:t[0])) | true |
5629fd5d867c0e22addd7ecdafb8ae865fa36bdb | nanqiaobei/Road_tfboy | /demo03.py | UTF-8 | 2,327 | 3.34375 | 3 | [] | no_license | import tensorflow as tf
from tensorflow.keras import layers
###有2中方式去实例化一个model
##第一种(我喜欢叫他函数式模型编程,像一步步写数学公式) 是使用 "functional API" 使用input的地方,将会链式的连接每一层,并且通过每一层的call(定义前向传播)
##区分出模型的前向传播,最后,创建了一个从输入到输出的模型
inputs=tf.keras.Input(shape=(3,),name='inputs')
###填写激活函数的参数名字有2种,一种是采用参数的string 名字,一种是指定函数,激活函数,激活函数默认无
... | true |
8eb69a4d34a8e83d1fc8b41384a6aff2985d5e84 | martinschnurer/BachelorWork | /skusky/gather.py | UTF-8 | 422 | 2.59375 | 3 | [] | no_license | import tensorflow as tf
import numpy as np
lst = [
[
[1,2,3],
[4,5,6],
[7,8,9]
],
[
[11,12,13],
[14,15,16],
[17,18,19]
]
]
vec = tf.Variable(lst, dtype=tf.float32)
init = tf.global_variables_initializer()
wi... | true |
6bb6ed08826d20df473b107cf38dd2a26b450ffa | mindspore-ai/mindspore | /tests/st/ops/cpu/test_elu_op.py | UTF-8 | 3,687 | 2.515625 | 3 | [
"Apache-2.0",
"LicenseRef-scancode-proprietary-license",
"MPL-1.0",
"OpenSSL",
"LGPL-3.0-only",
"LicenseRef-scancode-warranty-disclaimer",
"BSD-3-Clause-Open-MPI",
"MIT",
"MPL-2.0-no-copyleft-exception",
"NTP",
"BSD-3-Clause",
"GPL-1.0-or-later",
"0BSD",
"MPL-2.0",
"LicenseRef-scancode-f... | permissive | # Copyright 2021 Huawei Technologies Co., Ltd
#
# 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 agreed to... | true |
4c7d8ec7fa44b360d511c778c65c59b2976da541 | syurskyi/Python_Topics | /120_design_patterns/002_builder/_exercises/exercises/000_builder.py | UTF-8 | 8,588 | 3.3125 | 3 | [] | no_license | # -*- coding : utf-8 -*-
#
# abc.ABC basically just an extra layer over metaclass_abc.ABCMeta. i.e abc.ABC implicitly defines the metaclass for us.
# The only difference is that in the former case you need a simple inheritance and in the latter you need
# to specify the metaclass.
# New class ABC has ABCMeta as its me... | true |
acf281683b52a6570ca6fa78400d985ebbede773 | chihfenl/bomoda-practice | /Q1/b/mapper.py | UTF-8 | 1,143 | 2.796875 | 3 | [] | no_license | #!/usr/bin/python
# This mapper only parses the required information and pass it to combiner.py
import simplejson as json
import re
import sys
for line in sys.stdin:
try:
data = json.loads(line)
# Status related information
status_id = data['status']['id']
status_userid = data['status']['user']['id']
... | true |
f5470c79b54c18a451296470b4e12d414144a7cb | PacktPublishing/Secret-Recipes-of-the-Python-Ninja | /Chapter03/funct_as_arg.py | UTF-8 | 219 | 3.265625 | 3 | [
"MIT"
] | permissive | >>> def mult(x, y):
... return x * y
...
>>> def div(x, y):
... return x / y
...
>>> def math(func, x, y):
... result = func(x, y)
... return result
...
>>> math(mult, 4, 2)
8
>>> math(div, 4, 2)
2.0
| true |
b2636989a2b903534295b9ebbf3148ffa6d84d5a | Enchan1207/PyBJ | /main.py | UTF-8 | 1,652 | 3.734375 | 4 | [] | no_license | #
# ブラックジャックを書いてみる
#
from deck import Deck
from hand import Hand
#--
deck = Deck()
myhand = Hand()
cphand = Hand()
#--デッキ初期化
deck.deckinit()
print("デッキを初期化しました")
#--先にcpuもプレイヤーも強制的に一枚ドロー
myhand.add(deck.draw())
cphand.add(deck.draw())
#--自分のターン
myc = myhand.getsum()
print("カードの数値:" + str(myc))
flg = False
while f... | true |
9a4c94217de1ad409d36bcacdf71b05eb351374b | sherylmehta/Demosaicing-with-deep-image-prior | /utils/demosaicing_utils.py | UTF-8 | 5,734 | 2.53125 | 3 | [] | no_license |
from .common_utils import *
def bayer_mosaic(img_np, pattern='rggb'):
c, w, h = img_np.shape
# Create zero array, same as size of the original image
mask_np = np.zeros((1, w, h), dtype=np.float32)
# Map the RGB values in the original picture according to the pattern
if pattern=='rggb':
... | true |
3ac6e43e1afed925ec3b7708a3436b181579d3e9 | DuscraperRn/LearningRepo | /sum.py | UTF-8 | 103 | 2.890625 | 3 | [] | no_license | import sys
#a=sys.argv[1]
#b=sys.argv[2]
a=int(input("Enter a:"))
b=int(input("Enter b:"))
print(a+b)
| true |
a27017bf91f97e96ce2b1b8eaa1517da4ba17408 | rbshadow/Python_URI | /Beginner/URI_1146.py | UTF-8 | 341 | 3.46875 | 3 | [
"MIT"
] | permissive | def math():
while True:
read_x = int(input())
if read_x != 0:
for i in range(1, read_x+1):
if i == read_x:
print(i, end='')
else:
print(i, end=' ')
else:
break
print()
if __name__ == '_... | true |
edc4a29a714777c1d2e9053879dab07e49723488 | lacerda/minimal-qa | /qa-select.py | UTF-8 | 5,653 | 2.796875 | 3 | [] | no_license | import argparse
import os
import sys
from gensim.models import Word2Vec as W2V
import numpy as np
import csv
###################################
# Definitions
###################################
model_fn = 'cases_w2v.bin'
output_fn = 'outputData.csv'
argparser = argparse.ArgumentParser(description='A question answer... | true |
b597fe0a90f535acbf128cd6f5ae161b98db8e6f | yongjoons/test1 | /028.py | UTF-8 | 364 | 3.234375 | 3 | [] | no_license | seq1='ATGTTATAG'
new1=''
for s in seq1:
if s=='A':
new1 +='T'
elif s=='T':
new1 +='A'
elif s=='C':
new1 +='G'
elif s=='G':
new1 +='C' #you can use dictionary.
print(seq1)
print(new1)
'''rev_seq=''
compdic={'A':'T','T':'A','C':'G','G':'C'}
for s in seq1:
rev_seq +=comp... | true |
afb6e52ac449ed10d36f7ff97326e9f2fb9e3762 | 5l1v3r1/hetical-forensic | /scripts/linkedin_investigation.py | UTF-8 | 412 | 2.640625 | 3 | [] | no_license | # -*- coding: utf-8 -*-
from googlesearch import search
import json
with open('./data/db.json') as f:
data = json.load(f)
for student in data['students']:
for url in search('site:linkedin.com intext:"HETIC" inurl:"/in/{}-{}"'.format(student['firstName'], student['lastName']), stop=1):
print('Linkedin ... | true |
9ef2491039036eeaacd71cf8b17c28a8e860e7a5 | zy20091082/pytorch-convis | /convis_heatmap.py | UTF-8 | 4,503 | 2.625 | 3 | [
"MIT"
] | permissive | # A PyTorch implementation of: https://gist.github.com/ProGamerGov/8f0560d8aea77c8c39c4d694b711e123
import os
import copy
import torch
import torch.nn as nn
import torch.optim as optim
import torchvision.transforms as transforms
from PIL import Image
from torch.autograd import Variable
from CVGG import vgg19, vgg16, n... | true |
72ae77aeff99f997ab1a236a6853ba7a4274c719 | natatat/tcw2 | /tbd/skew.py | UTF-8 | 58 | 2.671875 | 3 | [] | no_license | font = CurrentFont()
for glyph in font:
glyph.skew(7) | true |
610bf4d42341798c11b41cb262c3b56f8bcc9956 | adam-formela/Adam-s-repo | /12_OOP_cd/point.py | UTF-8 | 301 | 3.359375 | 3 | [] | no_license | class Point:
def __init__(self, num):
self.__x = '0'
self.num = num
def get(self):
return self.__x
def set(self, x):
self.__x = x
p1 = Point(10)
print('point value', p1.num)
print('point x params:', p1.get())
p1.set(1)
print('point x params:', p1.get()) | true |
c1ee52fb7babd1b95dd837ca2a55845818836b1d | Samuelgranato/MorseLanguage | /main_morse.py | UTF-8 | 18,344 | 2.765625 | 3 | [] | no_license | import sys
import copy
import re
import operator
import morse_encoder
import morse_lex
class SymbolTable():
def __init__(self):
self.table = {}
self.functions = {}
def set_symboltable(self,symboltable):
self.table = symboltable.table
class Node:
def __init__(self,value,node_... | true |