blob_id stringlengths 40 40 | language stringclasses 1
value | repo_name stringlengths 5 133 | path stringlengths 2 333 | src_encoding stringclasses 30
values | length_bytes int64 18 5.47M | score float64 2.52 5.81 | int_score int64 3 5 | detected_licenses listlengths 0 67 | license_type stringclasses 2
values | text stringlengths 12 5.47M | download_success bool 1
class |
|---|---|---|---|---|---|---|---|---|---|---|---|
3c51b647545752c7ab0621b75a8c83364151fc58 | Python | christymthmas/amazonPriceDropNotification | /amazonDetails.py | UTF-8 | 3,670 | 3.171875 | 3 | [] | no_license | def getProductTitle(soup):
title = soup.find("span", id = "productTitle").text.strip()
return title
def getBrandName(soup):
brandName = soup.find("a", id = "bylineInfo").text.strip().replace("Visit the ","").replace("Brand: ","").replace(" Store","")
return brandName
def getMRP(soup):
mrpstr = sou... | true |
82db0d89557d22364f83156c7e691e48c28e2788 | Python | pirg/PartitionFunction | /check_partfunc.py | UTF-8 | 2,241 | 2.578125 | 3 | [
"MIT"
] | permissive | # import os
import numpy as np
import astropy.units as u
import astropy.constants as c
import astropy.io as io
from astropy.table import Column
import pylab as pl
pl.ion()
names = ['freq', 'freq_err', 'logI', 'df', 'El_cm',
'gu', 'tag', 'qncode', 'qn', 'specname']
def load_spec(tag):
""""""
tb = io.... | true |
03bd88a85c1f7ae901179421dbe827f02a5d1186 | Python | nehasinghritu8/HealthX | /X-ray fracture detection/bt1.py | UTF-8 | 744 | 2.515625 | 3 | [
"MIT"
] | permissive | import cv2
import numpy as np
import math
img = cv2.imread('bone1.jpg')
img=cv2.blur(img,(3,3))
gray = cv2.cvtColor(img,cv2.COLOR_BGR2GRAY)
th,dst=cv2.threshold(img,200,250,cv2.THRESH_BINARY)
dst=cv2.dilate(dst,(7,7),iterations=3)
dst=cv2.erode(dst,(7,7),iterations=3)
cv2.imshow('sthresh',dst)
edges = cv2.Canny(dst,10... | true |
da42ea66a8ba7ed54514a3b5ce11c63052d83103 | Python | mmveres/python05_12_2020 | /ua/univer/lesson05/xml_dict/__main__.py | UTF-8 | 459 | 2.671875 | 3 | [] | no_license | import xmltodict
import pprint
import json
with open('data.xml') as fd:
doc = xmltodict.parse(fd.read())
data_txt = json.dumps(doc)
with open("data.json", "w") as file:
file.write(data_txt)
# data_dict = json.loads(data_txt)
with open("data.json", "r", encoding="UTF") as myfile:
dat... | true |
b0add74dae7507c7e2c0688e0e2217531e4154de | Python | lizhenggan/TwentyFour | /01_Language/01_Functions/python/levenshtein.py | UTF-8 | 949 | 3.65625 | 4 | [
"MIT"
] | permissive | # coding: utf-8
def levenshtein(str1, str2, cost_ins=1, cost_rep=1, cost_del=1):
len1, len2 = len(str1), len(str2)
if len1 == 0:
return len2
if len2 == 0:
return len1
if len1 > len2:
str1, str2 = str2, str1
len1, len2 = len2, len1
cost_ins, cost_del = cost_del, ... | true |
95b0efd24ee7b64d6854806beb0d5502fac03887 | Python | XavierGimenez/procomuns-project-network | /create_tag_network.py | UTF-8 | 1,421 | 2.671875 | 3 | [] | no_license | __author__ = 'xavi'
from collections import Counter
import constants as constants
import itertools
import pandas as pd
import pyUtils
df = pd.read_csv(constants.FOLDER_DATA_DEPLOY + constants.FILE_TAGS_ADDED_2)
df = df.fillna('')
set_tags = set()
#list of possible connections between topics
connections = []
for i... | true |
114a6be23d810e376a18ebc0abaa8341cab141b7 | Python | gungunfebrianza/Belajar-Dengan-Jenius-Python | /src/Class/1. Class.py | UTF-8 | 600 | 4.15625 | 4 | [] | no_license | # CREATE CLASS
class Person:
def __init__(self, firstname, lastname, age, eyecolor):
self.firstname = firstname
self.lastname = lastname
self.age = age
self.eyecolor = eyecolor
def getFullName(self):
print(self.firstname + " " + self.lastname)
# CREATE OBJECT
hooman = ... | true |
4d344c9ba60782b3b25a90c8ac7e7fb9c170fe6f | Python | morganstanley/testplan | /releaseherald/releaseherald/plugins/plugin_config.py | UTF-8 | 5,197 | 2.5625 | 3 | [
"MIT",
"Apache-2.0"
] | permissive | from collections import defaultdict
from dataclasses import dataclass, field
from typing import Dict, Any, Optional, List, DefaultDict
import click
from boltons.cacheutils import cached, LRI
from pydantic import BaseModel
from releaseherald.plugins.interface import CommandOptions
@dataclass
class FromCommandline:
... | true |
5db57d73fbc6a13fa87916114115787cb0413ded | Python | ashish3x3/competitive-programming-python | /Hackerrank/defaultDictUse.py | UTF-8 | 746 | 3.15625 | 3 | [] | no_license | from collections import defaultdict
d = defaultdict(list)
list1=[]
n, m = map(int,raw_input().split())
for i in range(0,n):
d[raw_input()].append(i+1)
for i in range(0,m):
list1=list1+[raw_input()]
for i in list1:
if i in d:
print " ".join( map(str,d[i]) )
else:
print -1
'''
H... | true |
ecc84bec06a81477e8a3f41b1a67a3bc4d6da1fd | Python | Aasthaengg/IBMdataset | /Python_codes/p03963/s238501296.py | UTF-8 | 85 | 2.828125 | 3 | [] | no_license | N,K = map(int,input().split())
ret = K
for i in range(2,N+1):
ret *= K-1
print(ret) | true |
0620634eb819f6870f43cfb43ffb29ffedfda790 | Python | elgraves/Coursera | /Algorithmic-Thinking/Module-1/Application/Citation_Graphs.py | UTF-8 | 9,642 | 3.421875 | 3 | [] | no_license | from __future__ import division
"""
Created on Aug 26, 2014
@author: Joshua Magady
Language: Python 2.x
Script: Citation Graphing
"""
# general imports
import urllib2
#import dateutil
import matplotlib.pyplot as plot
#end general imports
CITATION_URL = "http://storage.googleapis.com/codeskulptor-alg/alg_phys-cite.tx... | true |
4189a30dce429f6b5e90d2fd361e70c8e8e40745 | Python | lessrest/danceschool | /root/usr/local/bin/dance-update-todays-classes | UTF-8 | 1,451 | 2.5625 | 3 | [] | no_license | #!/usr/bin/env python2
import json
import vobject
import dateutil.rrule as rrule
from datetime import datetime
import smtplib
from email.mime.text import MIMEText
today = datetime.today().date()
# Start with no classes today
classes = {}
# Read and parse the calendar file
cal = vobject.readOne(open("/var/dance/calen... | true |
4e2d2da971031009cf5eb52f2a9dec26067ab9a5 | Python | Sadanand-Prajapati/API_Data | /API_Data_Scrapping.py | UTF-8 | 6,206 | 2.859375 | 3 | [] | no_license | # -*- coding: utf-8 -*-
"""
Created on Thu Nov 19 11:52:16 2020
@author: Sadanand
"""
import requests
import json
import pandas as pd
import os
from sqlalchemy.orm import sessionmaker
from sqlalchemy.ext.declarative import declarative_base
import pandas as pd
import pymysql
from sqlalchemy import creat... | true |
265b1f796fa84a13aa911b76008c86df623ae9f7 | Python | Yuriy-Leonov/python-rabbitmq-example | /samples/example_shared_channel.py | UTF-8 | 997 | 2.53125 | 3 | [
"MIT"
] | permissive | import asyncio
import json
import time
from utils import connector
from utils import funcs
QUEUE_NAME = "example_shared_channel"
i = 0
async def send_message_with_shared_channel():
global i
conct = connector.Connector()
shared_channel = await conct.get_channel()
await shared_channel.basic_publish(
... | true |
063cd980237ee3c261d62adbc45f620b790cbf1a | Python | KarAbhishek/MSBIC | /All_is_code/10_600_AutomaticCode.py | UTF-8 | 7,404 | 2.578125 | 3 | [] | no_license | # -*- coding: utf-8 -*-
"""
Created on Mon Nov 21 01:00:11 2016
"""
import numpy as np
import matplotlib.pyplot as plt
from pandas.tools.plotting import scatter_matrix
import pandas as pd
#from sklearn.linear_model import LinearRegression
meanTrain = np.array([0,0])
stdTrain = np.array([0,0])
def standardi... | true |
cc7ae15fe8afb147e2b95b34a274be1cd661d8f7 | Python | averagehat/biolearn | /func.py | UTF-8 | 7,116 | 2.53125 | 3 | [] | no_license | from functools import partial, wraps
import itertools as it
import string
import sys
from collections import namedtuple
from operator import itemgetter, attrgetter as attr
from schema import Schema, SchemaError
PY3 = sys.version[0] == '3'
imap, ifilter, izip = (map, filter, zip) if PY3 else (it.imap, it.ifilter, it.iz... | true |
aee7db33e1b809b3f6599c867ff78cb9cd35618c | Python | cardadfar/Object-Illum | /bbox.py | UTF-8 | 1,677 | 3.21875 | 3 | [] | no_license | import os
import numpy as np
import matplotlib.pyplot as plt
from PIL import Image
class BBox:
''' x: starting x position
y: starting y position
wth: width of box
hgt: height of box
'''
def __init__(self, x, y, wth, hgt):
global global_id_indx
self.x =... | true |
941af6872a6ea3b8236869ed25414eb1f3cd99f7 | Python | jjpatel361/machinelearning | /code/knn_classifier.py | UTF-8 | 2,582 | 2.984375 | 3 | [] | no_license | ''''
Nearest Neighbour Classifier
:arg dataset.data
:arg trainlabel.0
:arg eta
'''
import sys;
import os;
'''
Read the data set file and labels file
'''
ds_file = sys.argv[1];
fh = open(ds_file, mode='r');
dataset = [];
for line in fh:
arr = line.split();
arr = [float(i) for i in arr];
... | true |
a0946ea6490622b82933344f247ee55657696e49 | Python | reymarkus/pyxiv-dl-reborn | /pyxiv-dl/__main__.py | UTF-8 | 3,666 | 3.078125 | 3 | [
"MIT",
"LicenseRef-scancode-unknown-license-reference"
] | permissive | """pyxiv-dl main script
This is the main script that executes the main pyxiv-dl argument parser.
"""
import argparse, sys, textwrap
from webcrawler import PixivWebCrawler
from pyxivhelpers import *
# constants
"""Script version"""
PYXIVDL_VERSION = "0.5.2"
"""Main function for accepting download args"""
def main()... | true |
d00ce07af2752deebce8d40620f75e6f7ca69300 | Python | himanshu2801/Geeksforgeeks | /Maximum Index.py | UTF-8 | 1,197 | 3.78125 | 4 | [] | no_license | """
Given an array A[] of N positive integers. The task is to find the maximum of j - i subjected to the constraint of A[i] <= A[j].
Example 1:
Input:
N = 2
A[] = {1,10}
Output: 1
Explanation: A[0]<=A[1] so (j-i)
is 1-0 = 1.
Example 2:
Input:
N = 9
A[] = {34,8,10,3,2,80,30,33,1}
Output: 6
Explanation: In the given ... | true |
6b49faf6d977aa2cf6af7608c2ea15e576bd646b | Python | hanbule/telegram-bomber | /tools/proxy_grabber.py | UTF-8 | 2,224 | 2.5625 | 3 | [
"MIT"
] | permissive | import datetime
import random
import time
import requests
from tools import config
from handlers import text
def grab(logger, database, token):
if text.active_grabber:
logger('ProxyGrabber', 'Getting proxys from Proxoid.net')
else:
return
proxys = [proxy for proxy in req... | true |
44c4127ffe96eef8847488b387612862d18ab785 | Python | andrely/sublexical-features | /ExperimentSupport/experiment_support/experiment_runner.py | UTF-8 | 21,457 | 2.59375 | 3 | [] | no_license | import logging
import os
import sys
import multiprocessing
import time
from gensim.corpora import TextCorpus
from gensim.corpora.dictionary import Dictionary
from gensim.models import Word2Vec
from gensim.utils import chunkize_serial, InputQueue
from scipy import sparse
from numpy import mean, std, zeros, array
from s... | true |
db5cd7de7bf991e3cbb34ab753f7f6fe9cfba4a0 | Python | educaris/Microbit | /Les-3_2.py | UTF-8 | 564 | 2.734375 | 3 | [] | no_license | from microbit import *
import random
while True:
if button_a.is_pressed():
display.scroll("Dobbelsteen")
if accelerometer.was_gesture('shake'):
display.clear()
choice = random.randint(0, 5)
if choice == 0:
display.show("1")
elif choice == 1:
... | true |
7322ace29e4b7bc3a3864ad98fd0d4552f2ef59c | Python | thalespaiva/sagelib | /sage/categories/examples/infinite_enumerated_sets.py | UTF-8 | 5,492 | 3.46875 | 3 | [] | no_license | """
Examples of infinite enumerated sets
"""
#*****************************************************************************
# Copyright (C) 2009 Florent Hivert <Florent.Hivert@univ-rouen.fr>
#
# Distributed under the terms of the GNU General Public License (GPL)
# http://www.gnu.org/licenses/
#******... | true |
b23536697e4b1b977cb888e08c88432c1cf8a15c | Python | MikeGongolidis/rakoczi-aliens | /settings.py | UTF-8 | 801 | 3.046875 | 3 | [] | no_license |
class Settings():
def __init__(self):
self.screen_width = 1150
self.screen_height = 864
#self.bg_color = (230, 233, 233)
self.caterpie_speed = 5
self.fleet_drop_speed = 25
self.dragon_lifes = 2
self.fireball_width = 3
self.fireball_height = 15
... | true |
041647453abd1751b983d9d60d59ee638d7e3a96 | Python | Sankarb475/Python_Learning | /Learning/adhoc.py | UTF-8 | 620 | 4.25 | 4 | [] | no_license | 1) repr method
================================================
The repr() function returns a printable representation of the given object.
class Node():
def __init__(self, data):
self.data = data
self.next = None
a = Node(3)
print(repr(a))
output: <__main__.Node object at 0x108452460>
------... | true |
16f3376f5fc0040e72832acdf0c22cca60327de3 | Python | Dragon631/Python_Learning | /Built-in module/subprocess_module.py | UTF-8 | 379 | 2.734375 | 3 | [] | no_license | #!/usr/bin/env python
# -*- coding:utf-8 -*-
import subprocess
# cmd = 'netstat -an'
cmd = 'ipconfig /all'
result_call = subprocess.Popen(cmd, shell=False, stdout=subprocess.PIPE)
# 成功获取输出内容, 但数据类型是bytes,需要进行decode,windows的默认编码为GBK
# 将返回值进行decode
result = result_call.stdout.read().decode('gbk')
print(result)
| true |
14c260cce0d89d37e4788e786c50e723cb743616 | Python | Amanda1223/Finch | /musicexample.py | UTF-8 | 1,672 | 3.71875 | 4 | [
"MIT"
] | permissive | """
Plays a list of songs. Input a number to choose.
1. Michigan fight song
2. Intro to Sweet Child of Mine
3. Mario Theme Song
Uses notes.py, an add-on library that simplifies buzzer song creation.
Thanks to Justas Sadvecius for the library!
The Finch is a robot for computer science education. Its design is the resu... | true |
30f5ac53760ca3f672505eac58da3626a9dd969b | Python | WeiSen0011/ImageProcessing-Python | /blog36-jhbh/blog36-06-xz.py | UTF-8 | 549 | 2.796875 | 3 | [] | no_license | #encoding:utf-8
#By:Eastmount CSDN 2021-02-01
import cv2
import numpy as np
#读取图片
src = cv2.imread('test.bmp')
#源图像的高、宽 以及通道数
rows, cols, channel = src.shape
#绕图像的中心旋转
M = cv2.getRotationMatrix2D((cols/2, rows/2), 30, 1) #旋转中心 旋转度数 scale
rotated = cv2.warpAffine(src, M, (cols, rows)) #原始图像 旋转参数 元素... | true |
efc70559626421e7a57fe4f5de4b1838d7b383d1 | Python | bestgopher/dsa | /hash_map/chain_hash_map.py | UTF-8 | 1,000 | 3.125 | 3 | [
"MIT"
] | permissive | from hash_map.hash_map_base import HashMapBase
from hash_map.unsorted_table_map import UnsortedTableMap
class ChainHashMap(HashMapBase):
"""Hash map implemented with separate chaining for collision resolution."""
def _bucket_getitem(self, j, key):
bucket = self._table[j]
if bucket is None:
... | true |
1bdedec4678ac7f176958f9a2b211cac2e4ede5f | Python | ElectricR/PyTrainer | /gui.py | UTF-8 | 2,102 | 3.328125 | 3 | [] | no_license | from engine import Engine
import tkinter as tk
class GUI:
def __init__(self):
self.engine = Engine()
self.window = tk.Tk()
self.window.bind('<Escape>', self.close)
self.window.geometry('900x500')
self.window.title('Radicals')
self.reset_button = tk.Button(self.wind... | true |
72fdcc5d51a07bb5428c7535775af513f07ce22b | Python | fomalhaut88/passstore | /models/commands/Delkey.py | UTF-8 | 435 | 2.859375 | 3 | [] | no_license | from Command import Command
class Delkey(Command):
title = "delkey"
def __init__(self, pass_storage, title, key):
super(Delkey, self).__init__(pass_storage)
self._title = title
self._key = key
def execute(self):
ok = self._pass_storage.delkey(self._title, self._key)
... | true |
146172840856112d8a34dc42d4b2e2ab1a6a638b | Python | earvingemenez/baymax | /baymax.py | UTF-8 | 2,172 | 2.6875 | 3 | [] | no_license | import string, cgi, time
from os import curdir, sep
from BaseHTTPServer import BaseHTTPRequestHandler, HTTPServer
class ServerHandler(BaseHTTPRequestHandler):
""" Simple webserver built to serve static web pages.
I don't know why i named it baymax so don't ask why. haha!
"""
def do_GET(self):
... | true |
4dde0946f339d2845b593c67e9fe6ea071d0365d | Python | jwelker110/store_backend | /store_app/blueprints/item.py | UTF-8 | 4,292 | 2.65625 | 3 | [] | no_license | from flask import Blueprint, request
from json import loads
from string import lower
from store_app.database import Item, CategoryItems, Category
from store_app.extensions import db
from helpers import create_response, convertToInt, decode_jwt
item_bp = Blueprint('item_bp', __name__)
@item_bp.route('/api/v1/items.j... | true |
30a44d2873bd38bdac462ec164d5823b9305334b | Python | mbenitezm/taskr | /bin/lib/taskr/Taskr.py | UTF-8 | 6,693 | 2.515625 | 3 | [] | no_license | import yaml, sys, logging
from termcolor import colored
from prettytable import PrettyTable
from os.path import expanduser
from os.path import isdir
from os import mkdir
from Utils import Utils
from Exceptions import *
from Task import Task
from WorkSession import WorkSession
class Taskr():
taskslog_name = "task_lo... | true |
7c518120cab98a92cce5fe2aef1987dda080dc14 | Python | Lethons/PythonExercises | /PythonProgram/chapter_04/4-10.py | UTF-8 | 225 | 4.1875 | 4 | [] | no_license | ls = [x for x in range(1, 11)]
print("The first three items in the list are:" + str(ls[0:3]))
print("Three items from the middle of the list are:" + str(ls[2:5]))
print("The last three items in the list are:" + str(ls[-3:]))
| true |
a5632cd84b73263fc253fe1ebb8d98351bef689e | Python | chalitgubkb/python | /ฝึกทำในหนังสือ/1.7.py | UTF-8 | 598 | 4 | 4 | [] | no_license | #วิธีการเขียนแบบ ธรรมดา
n1 = int(input('Enter Your Num 1: '))
n2 = int(input('Enter Your Num 2: '))
print(n1,'+',n2,'= %d' %(n1+n2))
print(n1,'-',n2,'= %d' %(n1-n2))
print(n1,'*',n2,'= %d' %(n1*n2))
print(n1,'/',n2,'= %d' %(n1/n2))
#วิธีการเขียนแบบ while
n = 1
o = []
while n<=2:
i = int(input('Enter Your Numb... | true |
c362d7e5bb852959cedd3fe32f70a2481ef460ac | Python | wgcn96/HPSVD | /draw/performance/demo.py | UTF-8 | 1,347 | 2.828125 | 3 | [] | no_license | # -*- coding: utf-8 -*-
"""
note something here
"""
__author__ = 'Wang Chen'
__time__ = '2019/7/24'
# if __name__ == '__main__':
# import matplotlib.pyplot as plt
#
# fig, ax = plt.subplots()
# ax.set_xscale('log', basex=5)
# ax.set_yscale('log', basey=2)
#
# ax.plot(range(1024))
# plt.show(... | true |
dd9cefff6d2b17fe514ec17753c97e229aca5094 | Python | stevenjwheeler/AntiScamAI | /record_engine.py | UTF-8 | 2,896 | 2.578125 | 3 | [] | no_license | from threading import Thread
from queue import Queue, Empty
import speech_recognition as sr
import os
import time
import random
import wit_response_engine
import gvoice_response_engine
import error_reporter
import logger
def setMicrophone(indexnumber):
audio_input_device = indexnumber
return audio_input_device... | true |
9cb83b34d51cf6b178af922227199e046d97d4f9 | Python | MikaMahaputra/Binus | /Mr Jude Project/ATM/Interface.py | UTF-8 | 3,697 | 3.484375 | 3 | [] | no_license | #Importing preivous files
import Account
import Atm
from pygame import mixer
def music():
mixer.init()
mixer.music.load("wii.mp3")
mixer.music.play(loops=-1)
def nope():
mixer.music.stop()
mixer.music.load("nope.mp3")
mixer.music.play()
#Call To Play The Music
music()
#Variables ... | true |
e154e227ec68a36f7b1f3792bbf51a8defb63cb3 | Python | ccqpein/Arithmetic-Exercises | /Buy-and-Sell-Stock/BaSS.py | UTF-8 | 963 | 3.28125 | 3 | [
"Apache-2.0"
] | permissive | test1 = [] # return 0
test2 = [2, 1, 2, 1, 0, 1, 2] # return 2
test3 = [1] # return 0
test4 = [7, 1, 5, 3, 6, 4] # return 5
test5 = [2, 4, 1] # return 2
class Solution(object):
def maxProfit(self, prices):
"""
:type prices: List[int]
:rtype: int
"""
maxT = 0
r... | true |
555e3bf24e9cf164415defc80c2797b85ffbe26c | Python | sharepusher/leetcode-lintcode | /data_structures/string/string_permutation.py | UTF-8 | 333 | 3.578125 | 4 | [
"Apache-2.0"
] | permissive | ## Reference
# https://www.lintcode.com/problem/string-permutation/description
## Easy - Permutation/String
## Description
# Given two strings, write a function to decide if one is a permutation of the other.
# Example
# Example 1:
# Input: "abcd", "bcad"
# Output: True
# Example 2:
# Input: "aac", "abc"
# Output... | true |
b6609437d1f819a494ac06d6c52225ca7e6ef622 | Python | thomasyp/project | /mpfs.py | UTF-8 | 8,260 | 2.828125 | 3 | [] | no_license | #!/home/yangpu/bin/anaconda3/bin/python
# -*- coding: utf-8 -*-
"""
Created on Thu Nov 26 10:15:47 2018
Main program for calculating maximum power peak factor of
rod withdrawal accident and rod drop accident.
Description of control rod:
Two shim rod: tr3 for 3# rod; tr5 for 5# rod.
One regulating rod: tr6 for 11# rod... | true |
dbe471ed6f26f9dc919eb98979e36a3abdb9cf82 | Python | ptparty/NLU-BERT | /BERT/vocab.py | UTF-8 | 2,337 | 2.921875 | 3 | [] | no_license | import pickle
import tqdm
import sys
from collections import Counter
class TorchVocab(object):
def __init__(self, vocab, specials=['<pad>', '<oov>']):
self.itos = list(specials)
for word in vocab:
self.itos.append(word)
# stoi is simply a reverse dict for itos
self.sto... | true |
c513ebf98e79f56f3c28baff470ccf042dfcd6af | Python | shubhamguptaiitd/bitcoin | /Message.py | UTF-8 | 295 | 2.96875 | 3 | [] | no_license | class Message():
def __init__(self,type,msg,src,dst):
self.type = type ##### Add to block,
self.msg = msg
self.src = src
self.dst = dst
def __str__(self):
return self.type + ":" + str(self.msg)+ "--" + str(self.src) + "->" + str(self.dst)
| true |
e6b4a735ff53bd5c7f3a39f4dde23758d845bcfa | Python | JohanEddeland/advent_of_code | /2017/04/test_aoc_04.py | UTF-8 | 445 | 3.125 | 3 | [] | no_license | """ test_aoc_04.py
Test for Advent of Code 2017 day 04
"""
import aoc_04
def test_valid_password():
assert aoc_04.valid('aa bb cc dd ee') == True
def test_invalid_password_repeated_word():
assert aoc_04.valid('aa bb cc dd aa') == False
def test_valid_password_similar_word():
assert aoc_04.valid(... | true |
c447189719f862b2970d7d3abc1aafefba3060c4 | Python | heineman/algorithms-nutshell-2ed | /PythonCode/adk/region.py | UTF-8 | 3,700 | 3.6875 | 4 | [
"MIT"
] | permissive | """
Defined rectangular region
"""
maxValue = 2147483647
minValue = -2147483648
X = 0
Y = 1
class Region:
"""Represents region in Cartesian space"""
def __init__(self, xmin,ymin, xmax,ymax):
"""
Creates region from two points (xmin,ymin) to (xmax,ymax). If these are not... | true |
d6a98b00b7ea330fcdd4245d781546b617b74755 | Python | cconvey/tool-configs | /my-home-dir/bin/find-similar-siblings.py | UTF-8 | 1,212 | 2.890625 | 3 | [] | no_license | #!/usr/bin/env python3
import collections
import hashlib
import os
import os.path
import sys
def main( argv ):
search_root = argv[1]
basename_to_dirnames = collections.defaultdict(list)
for root, dirs, files in os.walk( search_root ):
for filename in files:
basename_to_dirnames[ fil... | true |
4fa388613fec14bdf749b19ede701de856290c98 | Python | CognitionTree/Deep-ASL-Translator | /Python-Implementation/video_dataset.py | UTF-8 | 5,224 | 2.53125 | 3 | [] | no_license | from video import *
import glob
from random import shuffle
import numpy as np
class Video_Dataset(object):
FRONT_VIEW = 'Front'
FACE_VIEW = 'Face'
SIDE_VIEW = 'Side'
def __init__(self, path='/home/andy/Datasets/ASL/Pair_Optical_flow', view_point=FRONT_VIEW):
self.path = path
self.view... | true |
74c84cd481197be0a974a67baf82c1a3e11e4652 | Python | psorus/state | /test1.py | UTF-8 | 104 | 2.59375 | 3 | [
"MIT"
] | permissive |
class t:
def __setitem__(s,a,v):
print("setting item",a,v)
return 1
tt=t()
k=(tt["a"]=1)
| true |
ca161dcb05b1cc12db978dd275406bc8d5e33044 | Python | RaviKim/PythonParse | /1.jsonMake/fiveTest.py | UTF-8 | 4,018 | 2.515625 | 3 | [] | no_license | """forth Test"""
"""
Author : HSKIM
Date : 190618
Target : lotteimall
Difficult : Easy
ver 0.0.5
comment : 1. img url 가져오는 것 구현.
2. json 파일로 만드는 것 구현
3. 환경변수 최대한 이용할 것
"""
from selenium import webdriver
from bs4 import BeautifulSoup as BS
import json
import csv
import requests
import urllib.request
... | true |
64fe530bdc00124955dcc00b08dbe4b4754ce8d8 | Python | leventarican/cookbook | /python/dojo/kata12.py | UTF-8 | 276 | 3.25 | 3 | [] | no_license | # https://www.codewars.com/kata/5656b6906de340bd1b0000ac/train/python
def longest(s1, s2):
a = set(s1)
b = set(s2)
c = a.union(b)
d = sorted(c)
return "".join(d)
if __name__ == "__main__":
assert(longest("aretheyhere", "yestheyarehere") == "aehrsty") | true |
1d0a4e14e40acfe94007513e7e8d4c65c1e50e95 | Python | yangyuxue2333/NAMEABILITY | /calculate/get_word2vec_similarities.py | UTF-8 | 1,151 | 2.65625 | 3 | [] | no_license | import numpy as np
import pandas as pd
import sys
from gensim.models import word2vec
from itertools import combinations
def word2VecSimilarity(model,w1,w2):
print ('in method 1')
try:
return model.similarity(w1,w2)
except KeyError:
return 0
except:
return 0
def get_words(words... | true |
132d6df83b3e5e2a22deb337699c2cce7e9d33cd | Python | JatinTiwaricodes/expmath | /plots/einfache_funktionen.py | UTF-8 | 21,328 | 3.203125 | 3 | [] | no_license | import queue
import numpy as np
from bokeh.layouts import Row, WidgetBox
from bokeh.io import curdoc
from bokeh.models import ColumnDataSource
from bokeh.models.widgets import Slider, Dropdown, Toggle
from bokeh.plotting import Figure
from extensions.Latex import LatexLabel
# Some functions are not defined for negat... | true |
f240a0410f2a40313842bcab5dec6a2bd8f88e19 | Python | realnow/R_script | /R call python scripts/splitstr.py | UTF-8 | 262 | 3.71875 | 4 | [] | no_license | # splitstr.py
import sys
# Get the arguments passed in
string = sys.argv[1]
pattern = sys.argv[2]
# Perform the splitting
ans = string.split(pattern)
# Join the resulting list of elements into a single newline
# delimited string and print
print('n'.join(ans)) | true |
4bb98ea34ab1c8ac93448dcadbae214d11bec424 | Python | mateegojra/python | /mysql/connection.py | UTF-8 | 1,828 | 3.421875 | 3 | [] | no_license | import mysql.connector
import os
clear = lambda: os.system('cls')
mydb = mysql.connector.connect(host= "localhost", user="root", password="", database="python_practice")
handler = mydb.cursor()
#handler.execute("CREATE TABLE myFriends(f_id INT(6) UNSIGNED AUTO_INCREMENT PRIMARY KEY, full_name VARCHAR(30), city VARC... | true |
247ee4dd43ff58d12fe814c2a2dc9a487d324007 | Python | 191820061/CS61A | /chapter2/abstractData.py | UTF-8 | 3,507 | 3.265625 | 3 | [] | no_license | def mobile(left, right):
"""Construct a mobile from a left arm and a right arm."""
assert is_arm(left), "left must be a arm"
assert is_arm(right), "right must be a arm"
return ['mobile', left, right]
def is_mobile(m):
"""Return whether m is a mobile."""
return type(m) == list and len(m) == 3 a... | true |
bf703a22c1e5d8b8921950bd9352e52da819379b | Python | AdvancedNetworkingSystems/IFloodS | /tandem_queue.py | UTF-8 | 2,853 | 3.171875 | 3 | [] | no_license | import random
import heapq
class EventScheduler(object):
def __init__(self):
self.queue = []
self.time = 0
self.last = 0
def schedule_event(self, interval, e):
t = self.time + interval
if t > self.last:
... | true |
0113bb6085f6e4762104f841b0df1783052fc83a | Python | vpalex999/my_grokking_algorithms | /02_selection_sort.py/01_selection_sort.py | UTF-8 | 828 | 4.03125 | 4 | [
"Apache-2.0"
] | permissive | """
Алгоритмы сортировки
"""
def selection_sort(arr):
"""Сортировка выбором по возрастанию O(n^2)."""
selected_arr = []
while True:
curr_index = None
# найти наименьший элемент
for el_index in range(len(arr)):
if curr_index is None:
curr_index = el_inde... | true |
1353442305d442530fb23b880525b2f8e1d6f74e | Python | richruizv/school_scrapper | /fusiona_archivos.py | UTF-8 | 717 | 2.59375 | 3 | [] | no_license | import os
import glob
import pandas as pd
def run():
extension = 'csv'
os.chdir("csv/prod/")
all_filenames = [os.path.splitext(i)[0] for i in glob.glob('*.{}'.format(extension))]
fout=open("../final/combined_csv.csv","a",encoding="utf-8",errors="ignore")
for filename in all_filenames:
... | true |
f65c578e933b3f1928ee1a4b9db22fb05ac10e81 | Python | ikramulkayes/Python-practice-codewars.com- | /untitled79.py | UTF-8 | 1,917 | 3.421875 | 3 | [] | no_license | seconds = 7755
if seconds < 60:
print(seconds)
elif seconds < 3600:
minutes = seconds//60
seconds = seconds - 60*minutes
print(f"{minutes} minutes and {seconds} seconds")
elif seconds < 86400:
hours = seconds//3600
print(hours)
seconds = seconds - hours * 3600
print(seconds)
... | true |
773be4ccdd4cdab2be178df85f7fbf3cced80ce0 | Python | markcheno/clever_algorithms | /genetic_algorithm.py | UTF-8 | 2,482 | 3.484375 | 3 | [] | no_license | # Genetic Algorithm in the Python Programming Language
# Based on: The Clever Algorithms Project: http://www.CleverAlgorithms.com
# (c) Copyright 2012 Mark Chenoweth.
# This work is licensed under a Creative Commons Attribution-Noncommercial-Share License.
import random,operator
def fitness(bitstring): # OneMax pro... | true |
359b65ddb22bf728a9543b841a82344f5fb7ef63 | Python | peiyic2/dl_codebase | /modules/dataset/scannet_25k.py | UTF-8 | 2,557 | 2.5625 | 3 | [] | no_license | import sys
import os
import json
import numpy as np
import torch
import torchvision
from torchvision import datasets, transforms
from PIL import Image
from .baseset import base_set
class ScanNet25K(datasets.vision.VisionDataset):
'''
Semantic segmentation of ScanNet 25K downsampled data.
Data availabel at... | true |
48e3279f03b7d5b9fbbf59966af979f0fb4d7963 | Python | brooksandrew/postman_problems | /postman_problems/tests/utils.py | UTF-8 | 668 | 3.4375 | 3 | [
"MIT",
"LicenseRef-scancode-unknown-license-reference"
] | permissive | import csv
from io import StringIO
def create_mock_csv_from_dataframe(df):
"""
Converts a pandas DataFrame to a StringIO object.
Used to mock tests of functions that read from the filesystem, so we only need to keep track of one source of truth.
Args:
df (pandas dataframe): to be converted in... | true |
49e1802cf256529694a4498d0092469e3d1ecbe0 | Python | HaoYun519/Python | /彭彭Python入門/backup/function-args.py | UTF-8 | 346 | 3.71875 | 4 | [] | no_license | # 參數的預設資料
# def power(base,exp=0):
# print(base**exp)
# power(3,2)
# power(4)
# 使用參數名稱對應
# def divide(n1,n2):
# print(n1/n2)
# divide(2,4)
# divide(n2=2,n1=4)
# 無限/不定 參數資料
def avg(*ns):
sum = 0
for n in ns:
sum += n
print(sum/len(ns))
avg(3,4)
avg(3,5,10)
avg(1,4,-1,-8) | true |
76205ea66a486f8e493bc919a3fdf76c983f993d | Python | Dbof/adventcode-15 | /Day 17/day17-1.py | UTF-8 | 739 | 3.515625 | 4 | [] | no_license | # this could be made faster with sorted list
def find_combinations():
con = list(containers)
print(con)
return find(liters, con)
# very simple backtracking algorithm
def find(curr_value, con):
copy = con[:] # create new copy
count = 0
for c in con:
copy.remove(c)
remaining = cur... | true |
04358e55923585ddc2957fe38183cbe1f2142ba9 | Python | SrickySu/myPython | /com/surichard/spider/straightFlush/OutputManager.py | UTF-8 | 645 | 2.96875 | 3 | [] | no_license | #coding=utf-8
'''
Created on 2019年1月20日
@author: 74518
'''
class OutputManager(object):
def __init__(self):
self.data = []
def collectData(self, data):
if data is None:
return
if isinstance(data, list):
for item in data:
se... | true |
32e7a4529cbbc9457e0bbd8f8576068c220092f4 | Python | keyber/RP | /projet/plne.py | UTF-8 | 5,405 | 2.6875 | 3 | [] | no_license | from gurobipy import *
import utils
import solution
from time import time
import numpy as np
# noinspection PyArgumentList
def _ins_to_plne(first, ins: utils.Instance, relaxation_lin, verbose=False):
# rajoute un sommet fictif pour lequel tous les coûts entrants et sortants sont nuls
# on obtient alors facile... | true |
51a0b673ea6e4e8d367eb08707c3db7783d37806 | Python | ipiyushbhoi/Data-Structures-and-Algorithm-Problems | /binary_search_trees/replace.py | UTF-8 | 476 | 3.453125 | 3 | [] | no_license | '''
Given a string, compute recursively a new string where all appearances of "pi" have been replaced by "3.14".
Sample Input 1 :
xpix
Sample Output :
x3.14x
Sample Input 2 :
pipi
Sample Output :
3.143.14
Sample Input 3 :
pip
Sample Output :
3.14p
'''
def replace(s):
if len(s)<2:
return s
for i ... | true |
bf86aa6a243bbbb7a729014f90d775279f303917 | Python | mv-raman/Notebooks_repo | /spark_training/training_1/friends_by_age_key_value.py | UTF-8 | 700 | 3.046875 | 3 | [] | no_license | from pyspark import SparkContext,SparkConf
import collections
conf=SparkConf().setMaster("local").setAppName("FriendsByAge")
sc=SparkContext(conf=conf)
def parseLine(line):
fields=line.split(',')
age=int(fields[2])
numFriends=int(fields[3])
return age,numFriends
lines=sc.textFile("/home/venkat/Docume... | true |
d2f02a87add735510e73d71a1ac078e11ab25fe1 | Python | limo1996/ETH-DataScience | /src/contour/ContourDrawer.py | UTF-8 | 3,033 | 3.53125 | 4 | [] | no_license | '''
File name: ContourDrawer.py
Author: Jakub Lichman
Date created: 4/10/2018
Python Version: 3.6.3
'''
import os
from gmplot import gmplot
from .ContourGradients import getGradient, HeatType
class Coordinate(object):
""" Class that represents coordinates """
lat: float
lon: float
def... | true |
1c0b02bcca34ee6ff68894739bb05cc10a0a64f8 | Python | nischalshrestha/PyMonkey | /src/monkey/tokens/token.py | UTF-8 | 967 | 3.15625 | 3 | [
"MIT"
] | permissive | from typing import NamedTuple
# Constants
ILLEGAL = "ILLEGAL"
EOF = "EOF"
# Identifiers + literals
IDENT = "IDENT" # add, foobar, x, y, ...
INT = "INT" # 1343456
STRING = "STRING"
# Operators
ASSIGN = "="
PLUS = "+"
MINUS = "-"
BANG = "!"
ASTERISK = "*"
SLASH = "/"
LT = "<"
GT = ">"
EQ =... | true |
94710c4a889c01c52e5c231f66781419e4590597 | Python | Adrriii/ia-capture-the-flag | /src/game/ai/behaviorTree/NodeTree.py | UTF-8 | 1,816 | 3.40625 | 3 | [] | no_license | from abc import (ABCMeta, abstractmethod)
import copy
class NodeTree(metaclass=ABCMeta):
"""
This is a basic class for representing nodes in behavior tree.
Attributes:
_nodes (Node) : List of children.
_currentlyProcessing (Node): As a node can take many tick to processing task,
... | true |
54cb16805945696299f657dbed08777322b8004c | Python | zerosum99/python_basic | /myPython/class/mixin.py | UTF-8 | 906 | 3.5 | 4 | [] | no_license | # -*- coding: utf-8 -*-
"""
Created on Mon Feb 29 11:22:03 2016
@author: 06411
"""
class Person:
def __init__(self, name, surname, number):
self.name = name
self.surname = surname
self.number = number
class LearnerMixin:
def __init__(self):
self.classes = []
def enrol(se... | true |
4c25b065998a7ef71a392e5e82c1186c2fef761b | Python | AmrHRAbdeen/Python | /EGY_COVID_19_tracker.py | UTF-8 | 678 | 3.234375 | 3 | [] | no_license | ######################################################
# Developing a script to GET EGYPT COVID_19 Stats
######################################################
import pandas
import requests
# URL for COVID_19 Stats
URL = "https://www.worldometers.info/coronavirus/"
# GET request to URL
requestRes = requests.get(URL)
... | true |
8faa138df7939b39dc4421150b44f36c0312987c | Python | AvinashAnad/HackerRank | /wordorder.py | UTF-8 | 329 | 2.8125 | 3 | [] | no_license | n=int(input())
l=[]
if 1<=n<=10**5:
[l.append(input()) for i in range(n)]
#print (l)
#ls=set(l)
#print(len(ls))
#print(ls)
#l = ['bcdef', 'abcdefg', 'bcde', 'bcdef']
d = dict()
sampl = l
[l[i],l.count(l[i]) for i in range(len(l))]
#print (d)
#print (str(len(d))+'\n'+ str([i for i in d.values()])[1:-1].replace(",... | true |
e957eb98900e9a48a1739742892f2c1f9d0f62be | Python | konng88/My_Algorithms | /LeetCode/1.py | UTF-8 | 267 | 3.453125 | 3 | [] | no_license | def twoSum(nums,target):
for i in range(len(nums)):
for j in range(i+1,len(nums)):
if nums[i] + nums[j] == target:
return [i,j]
solution = twoSum(nums = [2, 7, 11, 15, 18 ,21], target = 33)
print(solution)
| true |
39f65d09051d63288cbac2405418cf527b40a138 | Python | 27Saidou/cours_python | /MetaClasseCompteur.py | UTF-8 | 576 | 3.671875 | 4 | [] | no_license | class MetaclasseCompteur(type):
"""Une méta-classe pour aider à compter les instances créées."""
def __init__(cls, *args, **kwargs):
super().__init__(*args, **kwargs)
cls._nb_instances = 0
@property
def nb_instances(cls):
return cls._nb_instances
def plus_une_instance(cls)... | true |
48b6c161dfd062684491efe8b90bc418e45008a9 | Python | LiLi-scripts/python_basic-1 | /hw2/numbers.py | UTF-8 | 1,191 | 4.46875 | 4 | [] | no_license | """
Дано число от 1 до 999.
1. Найти сумму цифр числа. (для 2-знач числа - lesson1/3_practice_operators.py)
2. Вывести, в каком порядке расположены цифры (возрастания/убывания/в разброс)
"""
# Ниже описан один из вариантов решения задачи.
number = int(input())
if 1 <= number < 10: # number >= 1 and numb... | true |
e65775c71a8b6c8c5b469568997766b31aed5cc1 | Python | sanjaybv/advent-of-code | /2016/day03/one.py | UTF-8 | 316 | 3.234375 | 3 | [] | no_license | count = 0
with open('input.txt') as input_file:
for line in input_file:
nums = map(int, line.strip().split())
print nums
if nums[0] < nums[1] + nums[2] and\
nums[1] < nums[0] + nums[2] and\
nums[2] < nums[0] + nums[1]:
count += 1
print count
| true |
ba3d339eaf78fdff358646f457e7f82cfe9e7ee5 | Python | jiyabing/learning | /开班笔记/python基础部分/day16/code/assert.py | UTF-8 | 351 | 4.125 | 4 | [] | no_license | def get_age():
a = input('输入年龄:')
a = int(a)
assert a < 140,'年龄不可能大于140!'
assert a >= 0,'年龄不能为负数!'
return a
try:
age=get_age()
except AssertionError as err:
print('发生了断言错误,错误对象是:',err)
age = 0 #做相应的处理
print('输入的年龄是:',age)
| true |
1645a4d0e45c68b7f4e67c930b2afc5d647b3d3e | Python | marleentheyoung/team_SEB | /project_code/algorithms/hillclimber.py | UTF-8 | 10,410 | 3.28125 | 3 | [] | no_license | # Team SEB
# Minor Programmeren (Programmeertheorie)
# hillclimber.py
#
# - HillClimber algorithm.
from project_code.classes.land import Land
from project_code.classes.house import House
from copy import deepcopy
from shapely.geometry import Polygon
from project_code.visualisations.visualise import visualise
import... | true |
f415bcffc93d7548694c1efe9ea100aa497abcdd | Python | iPERDance/iPERCore | /iPERCore/tools/utils/filesio/persistence.py | UTF-8 | 1,426 | 2.53125 | 3 | [
"MIT",
"LicenseRef-scancode-unknown-license-reference",
"LicenseRef-scancode-proprietary-license",
"Apache-2.0",
"BSD-2-Clause"
] | permissive | # Copyright (c) 2020-2021 impersonator.org authors (Wen Liu and Zhixin Piao). All rights reserved.
import os
import pickle
import json
import toml
def mkdirs(paths):
if isinstance(paths, list) and not isinstance(paths, str):
for path in paths:
mkdir(path)
else:
mkdir(paths)
r... | true |
693e20bbe87f9f358aa5d85f90d54ed8aae91b1a | Python | Zigmuntovich/python_training | /test_login_danfoss_itp.py | UTF-8 | 5,469 | 2.609375 | 3 | [
"Apache-2.0"
] | permissive | # -*- coding: utf-8 -*-
from selenium import webdriver
from selenium.common.exceptions import NoSuchElementException
from selenium.common.exceptions import NoAlertPresentException
import unittest
from data_class import Data
class UntitledTestCase(unittest.TestCase):
def setUp(self):
self.driver = webdriver... | true |
866be6bd4749d4b05a55dafbe20063521d987175 | Python | davidhendel/galpy | /galpy/actionAngle/actionAngleIsochroneInverse.py | UTF-8 | 7,628 | 2.59375 | 3 | [
"BSD-3-Clause"
] | permissive | ###############################################################################
# actionAngle: a Python module to calculate actions, angles, and frequencies
#
# class: actionAngleIsochroneInverse
#
# Calculate (x,v) coordinates for the Isochrone potential from
# given actions-angle coor... | true |
3fc05c10034885f28fddf85be10c0c72062d7aac | Python | sirexeclp/handouter | /handouter.py | UTF-8 | 714 | 2.671875 | 3 | [] | no_license | #%%
import sys
import re
input_file = sys.argv[1]
#%%
from PyPDF2 import PdfFileReader
pdf = PdfFileReader(open(input_file, 'rb'))
#%%
from PyPDF2 import PdfFileWriter, PdfFileReader
last_page = 0
output = PdfFileWriter()
pages2keep =[]
for i in reversed(range(pdf.getNumPages())):
page = pdf.getPage(i)
last_l... | true |
cc0e6aeedbf97bcbc85ffa35c0f82d51438c18dd | Python | shayan-7/accesshandler | /accesshandler/cache.py | UTF-8 | 1,271 | 3.140625 | 3 | [] | no_license | from datetime import timedelta
import redis
from nanohttp import settings
_redisconnection = None
def redisconnection():
'''
Returns an global redis connection object.
'''
global _redisconnection
if _redisconnection is None:
_redisconnection = redis.Redis(**settings.redis_)
return... | true |
90a8a6bfe5c95ba912a66b4e90b31c22e2f4944e | Python | iftekarpatel/greyatom-python-for-data-science | /Make-Sense-of-Census/code.py | UTF-8 | 1,596 | 3.421875 | 3 | [
"MIT"
] | permissive | # --------------
# Importing header files
import numpy as np
# Path of the file has been stored in variable called 'path'
data=np.genfromtxt(path, delimiter=",", skip_header=1)
print("\nData: \n\n", data)
print("\nType of data: \n\n", type(data))
print(data.ndim)
#New record
new_record=np.array([50, 9, ... | true |
1c4d49a55aa3ffc36a8cc1603ef09d014f8e4793 | Python | wbroach/python_work | /squares.py | UTF-8 | 218 | 4.46875 | 4 | [] | no_license | # Long Way:
squares = []
for value in range (1,11):
square = value**2
squares.append(square)
print(squares)
# Short Way:
squares = []
for value in range (1,11):
squares.append(value**2)
print(squares)
| true |
545b4a1355cf27a345ffe133232a95ba2fbbba3d | Python | eamanu/escrutinio-social | /elecciones/management/commands/importar_carta_marina_2019_gobernador.py | UTF-8 | 7,109 | 2.75 | 3 | [] | no_license | from decimal import Decimal
from django.core.management.base import BaseCommand
from django.conf import settings
from pathlib import Path
from csv import DictReader
from elecciones.models import Seccion, Circuito, LugarVotacion, Mesa, Categoria
import datetime
CSV = Path(settings.BASE_DIR) / 'elecciones/data/escuelas-... | true |
e2523aeb88d7afa3744fdcce54c1e5ebfb250a8f | Python | schwittlick/cursor | /tools/tests/lib.py | UTF-8 | 1,378 | 3.171875 | 3 | [
"MIT"
] | permissive | import numpy as np
from cursor.collection import Collection
from cursor.path import Path
def project_point_to_plane(point, plane_point, plane_normal):
plane_normal = plane_normal / np.linalg.norm(plane_normal) # Normalize the plane normal vector
v = point - plane_point # Vector from point on plane to point... | true |
c5596ed8422dec5c107eb3f2d56b1a93642b5720 | Python | xorudlee97/Tensorflow | /Day0821/T04_Iris.py | UTF-8 | 3,651 | 2.65625 | 3 | [] | no_license | from sklearn.model_selection import train_test_split
import numpy as np
import os
save_dir = os.path.dirname("D:/LTK_AI/LTK_AI_Study/AI_Study/Data/Numpy/")
cancer_data = np.load(save_dir+"/iris2_data.npy")
x_data = cancer_data[:,0:-1]
y_data = cancer_data[:,[-1]]
nb_classes = 3
print(x_data.shape)
print(y_... | true |
0ff1b337faf2a49209c327f69fabe332cf04453d | Python | nadavsh22/nand2tetris | /Project 10/CompilationEngine.py | UTF-8 | 15,042 | 3.0625 | 3 | [] | no_license | ############################################################
# Imports
############################################################
import JackTokenizer
import Consts as co
############################################################
# Class definition
######################################################... | true |
c0409c57b9c506cda988a92c48498dcdb93fc83c | Python | DariaMikhailovna/Web | /my_search_engine/src/run.py | UTF-8 | 995 | 3.234375 | 3 | [] | no_license | from search_engine import *
def main():
site = 'google'
tag = input('Введите тег запроса:')
max_links_count = input('Введите максимальное выводимое количество ссылок:')
is_rec = input('Введите "yes", если хотите запустить рекурсивный поиск и "no", если не рекурсивный:')
if not max_links_count.isdi... | true |
1621db6d659d264118c3478551486a9cc51a90a2 | Python | RedSpiderMkV/AncientPCAdminstrationTools | /RemoteShutdown-Windows/src/recipient.py | UTF-8 | 1,286 | 2.734375 | 3 | [] | no_license | # -*- coding: utf-8 -*-
"""
Created on Thu Feb 5 21:04:48 2015
@author: redspidermkv
"""
import time
import socket
import constants
import subprocess
class ShutdownListener:
hostAddress = ''
port = 0
socketConnection = None
def __init__(self, address, port):
self.port = port
... | true |
681db90a433e19fe1324f7a34e866d1b9f3dbb6b | Python | CharlesBayley/BF-Compiler | /nodes.py | UTF-8 | 4,532 | 3.21875 | 3 | [] | no_license | #!/usr/bin/python
class AstNode:
def __init__(self, parentNode):
self.parentNode = parentNode
class StatementNode(AstNode):
def __init__(self, parentNode, statement):
super().__init__(parentNode)
self.statement = statement
def run(self, state):
if self.statement is '+':
... | true |
babf9a580634132e4bf5b194d0a7b3d26f632fd3 | Python | RonnySun/tf-tutorials | /2_logit_regression/logit.py | UTF-8 | 2,657 | 2.78125 | 3 | [] | no_license | from sklearn import datasets
from sklearn.model_selection import train_test_split
import matplotlib.pyplot as plt
import tensorflow as tf
import numpy as np
n_features = 2
n_classes = 2
batch_size = 32
#help(plt.scatter)
#采用sklearn生成特征值是2,2分类,一共1000个样本,每个类别一个簇
x,y = datasets.make_classification(n_samples=1000,n_fea... | true |
3935a5f0594732f8a187166219ee8c58a9ba9321 | Python | saltant-org/saltant | /tasksapi/tasks/container_tasks.py | UTF-8 | 8,390 | 2.75 | 3 | [
"MIT"
] | permissive | """Contains task functionality for container-based tasks.
Note that none of these functions themselves are registered with Celery;
instead they are used by other functions which *are* registered with
Celery.
"""
from __future__ import absolute_import
from __future__ import division
from __future__ import print_functi... | true |
80576b8bed00e6bb985a2b07b65fa5d1dc18735b | Python | tochyepez/test_02_ibero | /render.py | UTF-8 | 1,706 | 3.15625 | 3 | [] | no_license |
import matplotlib.pyplot as plt
def get_data():
files = ["article2.output.txt", "articles1.output.txt", "articles3.output.txt"]
collector_f = {}
for f in files:
collector_f[f] = []
with open(f, "r") as fh:
for line in fh:
parts = line.replace('(', '').replace('... | true |
ff52c5b65dffe571102c968eeb9fd34091046877 | Python | k47ma/Scraping-Interface | /lib/Interface_unicode.py | UTF-8 | 4,435 | 3.109375 | 3 | [] | no_license | # coding=utf-8
import requests
import threading
import unicodedata
from bs4 import BeautifulSoup
from tkinter import *
# tool for looking up unicode
# look up the given character in unicode list
def lookup(value, type):
hex_code = ""
dec_code = ""
# search unicode by hex or dec code
if type == "hex" ... | true |