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 |
|---|---|---|---|---|---|---|---|---|---|---|---|
bfe512be9ddced55c4065aeac9ec5b40b2c9dd8a | Python | thdchang/Biodiversity-Dashboard | /app.py | UTF-8 | 4,154 | 2.640625 | 3 | [] | no_license | ## import dependencies
from flask import Flask, render_template, jsonify
#from flask_sqlalchemy import SQLAlchemy
from sqlalchemy.ext.automap import automap_base
from sqlalchemy.orm import Session
from sqlalchemy import create_engine, inspect, column
import os
import pandas as pd
from flask_sqlalchemy import SQLAlche... | true |
d24ae522c6f7ca4c8f9c100e2b30c37aaeacd3e6 | Python | EnzoZuniga/Python | /Seance 1/Exo02.py | UTF-8 | 126 | 3.609375 | 4 | [] | no_license | a=int(input('Entrez votre valeur a: '))
b=int(input('Entrez votre valeur b: '))
temp=a
a=b
b=temp
print('a=',a)
print('b=',b)
| true |
8f12a088af02afb940530ba89cbe246fa97d6958 | Python | martiansideofthemoon/Photometric-Redshifts | /test_codes/tf_redshifts.py | UTF-8 | 5,390 | 2.734375 | 3 | [] | no_license | import tensorflow as tf
from tensorflow.contrib.layers import xavier_initializer
import math
from math import isnan
import numpy as np
#COMMENT: np.random.seed(1337)
import time
import matplotlib.pyplot as plt
#COMMENT: tf.set_random_seed(1337)
def gloret(name, shape):
return tf.get_variable(name, shape=shape,
i... | true |
2b2cb710ed0d4bac2d3a687058a2203c5eb12b42 | Python | sylgas/HistoricalSocialNetworkAnalysis | /src/analysis/graph/centrality.py | UTF-8 | 2,962 | 2.875 | 3 | [] | no_license | import operator
import networkx as nx
from src.analysis.printer import FunctionPrinter
class CentralityMeasurer:
def __init__(self, graph):
self.graph = graph
def print_all(self):
FunctionPrinter.print_statistic(self.degree_centrality_ranking)
FunctionPrinter.print_statistic(self.be... | true |
e7fb6ba6a037eda946364550bb77e027525fb562 | Python | dr-dos-ok/Code_Jam_Webscraper | /solutions_python/Problem_116/1153.py | UTF-8 | 1,160 | 3.28125 | 3 | [] | no_license | # Python version 2.7
import sys
size = 4
def oneCase():
game = []
for i in range(size):
game.append(sys.stdin.readline())
mX = map(lambda line: map(lambda c: 1 if c=='X' or c=='T' else 0, line), game)
mO = map(lambda line: map(lambda c: 1 if c=='O' or c=='T' else 0, line), game)
haveE... | true |
79c267d328202511b55729dfe866e2b4417e14f6 | Python | Raj-kar/Python | /Nptel/week- 03 solutions.py | UTF-8 | 714 | 3.5625 | 4 | [] | no_license | # <------ solution programming assignment 1 -------> #
s1 = int(input())
s2 = int(input())
s3 = int(input())
s4 = int(input())
s5 = int(input())
print((s1 + s2 + s3 + s4 + s5) / 5, end="")
# <------ solution programming assignment 2 -------> #
list_1 = []
for i in range(1, 51):
list_1.append(i)
a, b = input().sp... | true |
6eaf3cca5a631e40872c7ae44318c0058192527b | Python | renfanzi/python3_Variance_Chisquare | /common/util/myAnalysis.py | UTF-8 | 3,744 | 2.890625 | 3 | [] | no_license | #!/usr/bin/env python
# -*- coding:utf-8 -*-
from scipy.stats import chisqprob
from common.base import my_log
import pandas as pd
from statsmodels.formula.api import ols
import statsmodels.api as sm
from pandas import DataFrame
def MyVariance(df_dropna, variableOne, variableTwo):
try:
# df_dropna = MyVar... | true |
28342e000112f51658bc1608fd9f0bf3fc21a38b | Python | andrea841/pythonbackup | /1.4.2/Jia_1.4.2.py | UTF-8 | 9,885 | 3.390625 | 3 | [] | no_license |
''' Part 1: Working with a File System '''
#4 C:/Users/Student login/Desktop/nice.jpg
#5 ../Student login/Desktop/nice.jpg
#6 C:\\Windows\\Cursors\\cursor1.png is an absolute filename, and can make
# sense no matter which directory it is currently in. The difference between
# these commands is that they pe... | true |
8c83732d355d1f5712eae04426ce22ab9ed74377 | Python | sinoroc/pmpc | /tests/test_fsm.py | UTF-8 | 3,686 | 3.015625 | 3 | [
"Apache-2.0"
] | permissive | """ Tests for finite state machine
"""
import unittest
import pmpc.fsm
class Machine: # pylint: disable=too-few-public-methods
""" FSM test subject
"""
def __init__(self):
states = {
'one': {
'transitions': {
'switch': {
... | true |
80280279f8355601eb1c7a934290d2f1b4da19fd | Python | turnkeylinux/octohub | /contrib/offline-issues/parse.py | UTF-8 | 3,627 | 2.828125 | 3 | [] | no_license | #!/usr/bin/python3
# Copyright (c) 2013 Alon Swartz <alon@turnkeylinux.org>
#
# This file is part of octohub/contrib
#
# OctoHub is free software; you can redistribute it and/or modify it under the
# terms of the GNU General Public License as published by the Free Software
# Foundation; either version 3 of the License,... | true |
1bd40c0567e1be830c061d73e6028a2e84e9f218 | Python | tiagodavi70/sentiment_models | /image_training/training_models.py | UTF-8 | 3,932 | 2.609375 | 3 | [] | no_license |
from keras import *
import keras
import keras.preprocessing.image as im
import cv2 as cv
import numpy as np
import pandas as pd
import os
import matplotlib.pyplot as plt
import model_utils as utils
import argparse
from keras.applications.imagenet_utils import preprocess_input
### Plot charts or images, wrapper for ma... | true |
4e8adc4f033b90345c01d279fdabf83c8d3bdce5 | Python | augustsemrau/Pandas_Scikit-Learn_Classification_Model-Optimization | /models.py | UTF-8 | 3,033 | 2.828125 | 3 | [] | no_license | """
Building predictive model on classification principles.
@AugustSemrau
"""
from data_loader import dataLoader
# SciKit-Learn
from sklearn.linear_model import LogisticRegression
from sklearn.naive_bayes import GaussianNB
from sklearn.linear_model import SGDClassifier
from sklearn.neighbors import KNeighborsClassifi... | true |
8eab802feb245be2a89c161a24ecda4ca966ef70 | Python | j-pettit/pfinance | /tests/test_functions.py | UTF-8 | 14,822 | 3.015625 | 3 | [
"MIT"
] | permissive | from pfinance import conversion, depreciation, general, securities, time_value
# Helper functions
def _compare_list_float(list1, list2, rounding_precision):
# Compares two lists of floats after rounding.
if len(list1) != len(list2):
print("Lists are different lengths.")
print("list1 length:", ... | true |
bcf1a981f51dde8e4cab65bf6906b8c1fe3a4d6e | Python | DexiongYung/NLPNoiseModel | /Utilities/Json.py | UTF-8 | 311 | 2.828125 | 3 | [] | no_license | from collections import OrderedDict
import json
def load_json(jsonpath: str) -> dict:
with open(jsonpath) as jsonfile:
return json.load(jsonfile, object_pairs_hook=OrderedDict)
def save_json(jsonpath: str, content):
with open(jsonpath, 'w') as jsonfile:
json.dump(content, jsonfile)
| true |
822fa085209ee6e52c9e32dcd29fc70f80302d70 | Python | ryukinix/programming-techniques-ufc | /src/Pratica_9/ex1.py | UTF-8 | 666 | 3.375 | 3 | [
"MIT"
] | permissive | #!/usr/bin/env python3
# -*- coding: utf-8 -*-
#
# Copyright © 2017 Manoel Vilela
#
# @project: Prática 9 - Python
# @author: Manoel Vilela
# @email: manoel_vilela@engineer.com
#
from empregados import Empregados
def main():
e1 = Empregados('Wendley', 'Silva', 8000)
e2 = Empregados('Silvio', '... | true |
7a46791326bac025c86fefed530bbc5fd92f166e | Python | boconlonton/python-deep-dive | /part-3/4-specialized_dictionary/exercise-3.py | UTF-8 | 1,027 | 3.265625 | 3 | [
"MIT"
] | permissive | """
Write a function that has a single argument (env name) and returns the "combined" dictionary
that merge 2 dictionaries together with the environment specific settings overriding any common settings already defined
"""
import json
from contextlib import ExitStack
from collections import ChainMap
# Declare setting ... | true |
68c89f991398db2a153c52f21ce0687f14cea59e | Python | krishnakadiyala/PythonExercisesFromKirk | /Week2.py | UTF-8 | 1,365 | 3.578125 | 4 | [] | no_license | """f = open("new.txt")
output = f.read()
print(type(output))
print(output)
f.close()
Another way to read a file - using a context manager form
with open("new.txt") as f:
output = f.readlines()
print(type(output))
Python automatically closes the file, we don't have to explicitly close the file.
Exercise2:
... | true |
35e8790fc68171b4f1c5098617328f62b381dc0f | Python | brianchu5/abcsmc | /particle.py | UTF-8 | 4,738 | 2.546875 | 3 | [] | no_license | import numpy as np
from operator import attrgetter
from numpy import random as rnd
from copy import deepcopy
class perturbationKernel:
def __init__(self,lower,upper):
scale = upper - lower
self.lower = -scale/2.0
self.upper = scale/2.0
def reinitialize(... | true |
e66380d8b529ff5ccea2e3bf3845be66b0b16a5a | Python | mrcszk/BOIKWD | /Lab 02/zad1.py | UTF-8 | 428 | 2.875 | 3 | [] | no_license | from saport.simplex.model import Model
model = Model("zad1")
x1 = model.create_variable("x1")
x2 = model.create_variable("x2")
x3 = model.create_variable("x3")
model.add_constraint(x1 + x2 + x3 <= 30)
model.add_constraint(x1 + 2*x2 + x3 >= 10)
model.add_constraint(0 * x1 + 2*x2 + x3 <= 20)
model.maximize(2*x1 + x2 ... | true |
7d38ebaf65635b01508b077c8cb302f858d17667 | Python | nikhilgk/halo-ml | /pyspark_feature_importance.py | UTF-8 | 3,119 | 2.5625 | 3 | [] | no_license | from pyspark import SparkConf, SparkContext
from sklearn.tree import DecisionTreeRegressor
from sklearn.base import copy
import sys
import pandas as pd
import numpy as np
import json
input_file = sys.argv[1]
output_file = input_file[6:-18]+'_importances.json'
def getSparkContext():
"""
Gets the Spark Context
... | true |
cc0a7562c80f992488a5ba869e79bb282543d9fb | Python | j32u4ukh/GrandResolution | /loss/__init__.py | UTF-8 | 11,669 | 3.03125 | 3 | [
"MIT"
] | permissive | import cv2
import numpy as np
import tensorflow as tf
import torch
from tensorflow.math import (
greater,
add,
subtract,
multiply,
divide,
square,
pow as tf_pow,
reduce_mean as tf_mean,
reduce_std as tf_std
)
from utils import (
showImage
)
from utils.math import (
log,
... | true |
19e93a469db2c48e6bd137aa75c7a7259b7885f5 | Python | LLisowskaya/Echo_server | /server.py | UTF-8 | 1,234 | 2.90625 | 3 | [] | no_license | #!/usr/bin/env python3
# -*- coding: utf-8 -*-
import logging
import socket
# Set logging parameters.
log_format = '%(asctime)s %(name)s: %(levelname)s: %(message)s'
date_format = '%Y-%m-%d %H:%M:%S'
log_name = "TCP-Server"
logging.basicConfig(
format=log_format, level=logging.INFO, datefmt=date_format)
# Create... | true |
ac4fdf645616b90ef3784787c828842c68fa3bff | Python | Johnson-xie/jeetcode | /contest/199/02.py | UTF-8 | 314 | 3.171875 | 3 | [] | no_license | class Solution:
def minFlips(self, target: str) -> int:
target.lstrip('0')
if not target:
return 0
status = [i for i in target.split('0') if i]
return 2 * len(status) - 1
if __name__ == '__main__':
s = '00000'
ret = Solution().minFlips(s)
print(ret)
| true |
a217d19630e7601e7d1147207ad97ea0765351a1 | Python | at3103/Leetcode | /Add_and_Search_word.py | UTF-8 | 1,395 | 3.96875 | 4 | [] | no_license | import re
class WordDictionary(object):
def __init__(self):
"""
initialize your data structure here.
"""
self.data = dict()
self.wlength = set()
def addWord(self, word):
"""
Adds a word into the data structure.
:type word: str
:rtype: void... | true |
72da56cf2f6d20de419062b8b5dfa144f462aece | Python | Daehyun-Bigbread/Bigbread-Python | /python_for_everyone/17A-trun.py | UTF-8 | 2,167 | 4.21875 | 4 | [] | no_license | # 터틀런 만들기1
import turtle as t
import random
te = t.Turtle() # 악당 거북이(빨간색)
te.shape("turtle")
te.color("red")
te.speed(0)
te.up()
te.goto(0, 200)
ts = t.Turtle() # 먹이(초록색 동그라미)
ts.shape("circle")
ts.color("green")
ts.speed(0)
ts.up()
ts.goto(0, -200)
def turn_right(): # 오른쪽으로 방향을 바꿉니다.
... | true |
2e140c1749176e13deb85868d4f9dff1e61eaf9e | Python | bihutchins/word2vec_pipeline | /pipeline_src/__main__.py | UTF-8 | 2,032 | 2.546875 | 3 | [
"CC0-1.0",
"LicenseRef-scancode-public-domain"
] | permissive | #! /usr/bin/env python
"""
Usage:
word2vec_pipeline import_data
word2vec_pipeline phrase
word2vec_pipeline parse
word2vec_pipeline embed
word2vec_pipeline score
word2vec_pipeline predict
word2vec_pipeline metacluster
word2vec_pipeline analyze
The code that is run by each command is found in the filen... | true |
77e14c64d71ec550082b1b264b2005c3007fa2cb | Python | josue9912/Repositorios_Empresa | /Archivo.py | UTF-8 | 1,000 | 2.828125 | 3 | [] | no_license | import os
# coding: utf-8
import shutil
thisdir = "/Users/josuesantanagalvan/Desktop/Carpeta/Carpeta1/Carpeta2"
for r, d, f in os.walk(thisdir): #Creo las carpetas
if 'CarpetaFinal' in r:
try:
r1 = os.path.join(r, 'main')
os.mkdir(r1)
r2 = os.path.... | true |
21e56e635432d33bb9c55a4449e4c0730937b6b0 | Python | microsoft/SDNet | /Utils/GeneralUtils.py | UTF-8 | 3,127 | 2.65625 | 3 | [
"MIT",
"Apache-2.0",
"LGPL-2.1-or-later"
] | permissive | # Copyright (c) Microsoft Corporation.
# Licensed under the MIT license.
import math
import re
from Utils.Constants import *
import spacy
import torch
import torch.nn.functional as F
import unicodedata
import sys
from torch.autograd import Variable
nlp = spacy.load('en', parser = False)
# normalize sent... | true |
48c16b77fe36d451e5514a23e7c4b50d7dcabb37 | Python | GlorianY/My-Coding-Puzzles-Solutions | /Hackerrank/count_triplets.py | UTF-8 | 1,020 | 3.265625 | 3 | [] | no_license | from collections import Counter
def countTriplets(arr, r):
r2 = Counter()
r3 = Counter()
count = 0
for v in arr:
if v in r3:
# get the count from the r2, and increment r2 using that count
# use the count from r3 (r3 stores the last value of a complete triplet)
#... | true |
7a007d3edf34cc8ca8ee76c167d6902fdeba5696 | Python | Dinesh-Sivanandam/Data-Structures | /Queue/printing the binary numbers.py | UTF-8 | 1,867 | 4.5 | 4 | [] | no_license | #importing the deque module from collections
from collections import deque
#creating the class for queue
class Queue:
#constructor which automatically executes when the object is created
#it creates the queue
def __init__(self):
self.buffer = deque()
#function for enqueue
#i... | true |
755fcbe0d3d60aed527b3ec955fbea27d1d77783 | Python | izxle/FuelCellCatalystAnalysis | /fccalib/electrode.py | UTF-8 | 6,265 | 2.8125 | 3 | [] | no_license | from numbers import Real
from numpy import pi
class Area(object):
# TODO: maybe inherit d dict
_format = '6.3f'
def __init__(self, geom=None, CO=None, H=None, CV=None):
self.geom = geom
self.CO = CO
self.H = H
self.CV = CV
def big(self):
# TODO: mejorar
... | true |
b5dba3f09768297ca0c34ea0ad1af441d392e49f | Python | indirap/state-of-states | /src/join_with_wb_data.py | UTF-8 | 5,369 | 3.25 | 3 | [] | no_license | '''
join_with_wb_data.py
Combines
* datascraped from wikipedia
* data obtained from the world bank
* country codes used for the d3 map.
Takes as input
1: World Bank CSV
2: Feature TSV file from Wikipedia
3: ISO file from D3 Map
'''
import os
import csv
import sys
import os
from types import *
def clean_filename(na... | true |
8dd8c967a056c9fe9c25e6d8ef870b5846d4fac4 | Python | dcurto95/Energy-consumption-prediction | /src/plot.py | UTF-8 | 7,385 | 2.9375 | 3 | [] | no_license | import matplotlib.colors as mcolors
import matplotlib.pyplot as plt
import seaborn as sns
import numpy as np
from sklearn.model_selection import train_test_split
def multiple_line_plot(x_list, y_list, labels, file_name, folder='.', title='', figsize=(20, 20)):
# plot the data
fig = plt.figure(figsize=figsize... | true |
957ed0a05f52820941b958f374e329be478c0486 | Python | kaedub/data-structures-and-algorithms | /recursion/every_other.py | UTF-8 | 534 | 3.53125 | 4 | [] | no_license | def every_other(s, i=0):
if i >= len(s):
return ''
print(s[i], end='')
return every_other(s, i+2)
def every_other2(s, i=0):
if i >= len(s):
return ''
return s[i] + every_other2(s, i+2)
print('should print every other char')
every_other("hello")
print('')
print('should print every other char')
every_... | true |
8efe1cecf9fda2d4dd356fd80163f5aaccff5a36 | Python | Nyrt/time_skip_RL | /basic_q_agent.py | UTF-8 | 4,042 | 3.171875 | 3 | [] | no_license | import gym
import numpy as np
import pandas
import random
import matplotlib.pyplot as plt
# Adapted from https://github.com/vmayoral/basic_reinforcement_learning/blob/master/tutorial4/README.md
class Q_agent:
def __init__(self, actions, epsilon, alpha, gamma):
self.q = {} # Q-learning table, indexed with ... | true |
f364c2f38dd7fcff3802db1117cd521dd02419c4 | Python | Vojtech-Sassmann/programmingProblemsAnalysis | /ASTAnalysis.py | UTF-8 | 7,702 | 2.640625 | 3 | [] | no_license | import codecs
import csv
import ast
import os
import sys
import math
from os import listdir
from os.path import isfile, join
from collections import namedtuple
from data import tasks
# searched_nodes = [
# "+", "-", "*", "/", "for", "while", "print", "%", "if", "==", "is"
# ]
searched_nodes = [
"Add", "Sub",... | true |
72e8a134272d57f0692fe99ea8bb30160b8b48ce | Python | wudlike/spherical-coordinates-transform- | /sph_coor_transf.py | UTF-8 | 2,556 | 2.96875 | 3 | [] | no_license | import numpy as np
def point_change(init_lon, w_e, init_lat, s_n, r, psi):
psi = np.deg2rad(psi)
ang_c = np.pi/2-np.deg2rad(init_lat)
cos_a = np.cos(r)*np.cos(ang_c)+np.sin(r)*np.sin(ang_c)*np.cos(psi)
new_lati = np.abs(90-np.rad2deg(np.arccos(cos_a)))
ang_B = np.rad2deg(np.arcsin(np.sin(psi)*np.si... | true |
f5fdc435cec97770a7dc562f82b26c316cce02c4 | Python | s152b/py-crawler | /PyCrawler/web_crawler/house_price/house_crawler.py | UTF-8 | 3,348 | 2.59375 | 3 | [] | no_license | # -*- coding: utf-8
## sinyi crawler, with thread
from bs4 import BeautifulSoup
from threading import Thread,Lock
import Queue
import sqlite3
import pandas as pd
import datetime,requests,ipdb
import time
def getZipCode(address):
# given chinese address return zipCode
zipCodeApi = 'http://zipcode.mosky.tw/ap... | true |
ce5ad0ce2c6fa081b36a7a777091590dde1ba4ef | Python | utrade/muTradeApi2 | /SampleCode-I20_RHEL8/src/benchmarking/benchmarkStats.py | UTF-8 | 2,327 | 2.765625 | 3 | [] | no_license | import numpy as np
from os import listdir
from os.path import isfile, join
def processFile(inputFile):
#inputFile = raw_input("Enter input file:")
a = np.array([])
iFile = open(inputFile, "r")
x=iFile.readline().split(",")
maxCount = 50000
count=0
for i in x:
count +=1
if count... | true |
74e17324d438086a8de5fddaabbf2b58eb22fa31 | Python | Aasthaengg/IBMdataset | /Python_codes/p03231/s345072979.py | UTF-8 | 264 | 2.546875 | 3 | [] | no_license | import fractions
N,M=map(int,input().split())
S=input()
T=input()
n=N//fractions.gcd(N,M)
m=M//fractions.gcd(N,M)
g=fractions.gcd(N,M)
judge=True
for i in range(g):
if S[i*n]!=T[i*m]:
judge=False
if judge==True:
print(N*M//g)
else:
print(-1) | true |
eeba37421d5593dbbbd123aaa8ad627f4f3d1a65 | Python | RonenNess/Fileter | /tests/test_sources.py | UTF-8 | 6,646 | 3.390625 | 3 | [
"MIT"
] | permissive | #!/usr/bin/env python
# -*- coding: utf-8 -*-
"""
Tests for the file filters.
"""
import fileter
import unittest
class TestSources(unittest.TestCase):
"""
Unittests to test file sources.
"""
def _list_by_iter(self, source):
"""
this helper function iterate over a source and return a l... | true |
31929518da193b45ba838f29a3663d754a981951 | Python | pactg97/Codigos_TFM | /Codigos/norm_min_cut_dendogram.py | UTF-8 | 7,338 | 3.03125 | 3 | [] | no_license | # -*- coding: utf-8 -*-
"""
Created on Thu Apr 8 13:07:58 2021
@author: 34625
"""
import networkx as nx
import numpy as np
import matplotlib.pyplot as plt
from scipy.cluster.hierarchy import dendrogram, linkage
from itertools import chain, combinations
def normalized_cut(G,c):
A=nx.adjacency_mat... | true |
f9ad3bb4a3df51167da6aa71484912750cbbfb05 | Python | LOVEDEEPKAUR5/ML1 | /app.py | UTF-8 | 1,821 | 2.796875 | 3 | [] | no_license | import streamlit as st
from PIL import Image
import pickle
import numpy as np
import matplotlib.pyplot as plt
import pandas as pd
st.set_option('deprecation.showfileUploaderEncoding', False)
# Load the pickled model
pickle_in = open("/content/drive/My Drive/decision_model.pkl","rb")
model=pickle.load(pickle_in)
datase... | true |
e99075d040b2f5e8f30c5231f3315b4b5e0951cf | Python | aptend/leetcode-rua | /Python/1041 - Robot Bounded In Circle/1041_robot-bounded-in-circle.py | UTF-8 | 814 | 2.734375 | 3 | [] | no_license | from leezy import solution, Solution
class Q1041(Solution):
@solution
def isRobotBounded(self, instructions):
# 28ms 89.40%
face = [0, 1] # north
pos = [0, 0]
for ins in instructions:
if ins == 'L':
face[0], face[1] = -face[1], face[0]
e... | true |
fd182abde225313a8d149a4b9e4fd2a6cdf5eda6 | Python | intermezzio/differential-transistor-analysis | /analyze.py | UTF-8 | 3,341 | 3.140625 | 3 | [] | no_license | import numpy as np
import matplotlib.pyplot as plt
from scipy.optimize import curve_fit
def plot_preconfig(ax, ftype):
"""
configure plot to loglog / semilog as necessary
"""
ax = ax if ax else plt
# log / semilog scales
if ftype == "exp":
ax.set_yscale("log")
elif ftype == "loglog":
ax.set_xscale("log")
... | true |
40f398deb87b80dca2ed16d70bcaa8dccefbaa53 | Python | samanthaalcantara/codingbat2 | /list-1/has23.py | UTF-8 | 177 | 2.875 | 3 | [] | no_license | """
Date: 06 08 2020
Author: Samantha Alcantara
Question: Given an int array length 2, return True if it contains a 2 or a 3.
"""
#Answer
def has23(nums):
return 2 in nums or 3 in nums
| true |
3e668207cd14987c9597ea2b462b7e84d7a60096 | Python | Hassan-Farid/PyTech-Review | /Python Basics/Taking User Input/using InputMethod.py | UTF-8 | 1,529 | 5.15625 | 5 | [] | no_license | '''
For user input, we use the input() method which allows the user to type a particular input
'''
#Using the input method to take a message like "Hello World"
message = input() #Allows user to type in some sort of text message
print(message) #Display the message on the screen
#Using the input method to take an i... | true |
afd0654c6f8957518f613790af41dc98d07994f1 | Python | JaysesS/4hsl33p_borda | /flask/data/fill.py | UTF-8 | 721 | 2.59375 | 3 | [] | no_license | import json, random, string
def get_random_string(length):
letters = string.ascii_lowercase
result_str = ''.join(random.choice(letters) for i in range(length))
return result_str
data = { "data" : []}
for x in range(50):
data['data'].append(
{
"name": get_random_string(470),
... | true |
b604044c604b08025c8fd41686589f3cb4e73a19 | Python | dkaramit/pseudo-Goldstone_DM | /Pseudo_Goldstone/util/Tuples.py | UTF-8 | 119 | 2.71875 | 3 | [
"MIT"
] | permissive | from itertools import combinations_with_replacement as itTuples
def Tuples(List,k):
return list(itTuples(List,k))
| true |
13e4314bc542363f45c503d948c0d962716f5821 | Python | Hemalatha30/mycodewash | /01-jsonmaker.py | UTF-8 | 696 | 3.359375 | 3 | [] | no_license |
#!/usr/bin/python3
'''Author:Hema | Email: Hemasnet@yahoo.com || json learning with Python'''
# with python, the json batteries are in box, but you need to plug them in
import json
def main():
# create a list of dictionaries
videogames = [{"game1":"red", "game2":"whisker","game3":"hema","game4":"Sakthivel"... | true |
da892946662875575f056595603adce28c616f3e | Python | xuefengji/Python | /demos/single.py | UTF-8 | 820 | 3.25 | 3 | [] | no_license | # @Time: 2022/4/16 21:46
# @Author: xuef
# @File: single.py
# @Desc:
# 单例模式1
# class A:
# pass
#
# a = A()
#
# a1 = a
# a2 = a
# a3 = a
# print(id(a1))
# print(id(a2))
# print(id(a3))
# 使用 __new__ 方法
# class A:
# def __new__(cls, *args, **kwargs):
# print('__new__ is call')
# if not hasattr(cl... | true |
2757c0e77201d7c097e5207f6491d9becf8f90b8 | Python | KholdStare/projecteuler | /experiments/dynamic.py | UTF-8 | 3,860 | 3.46875 | 3 | [] | no_license | #!/usr/bin/env python
# allow importing from utils
import sys
import os
import random
sys.path.append(os.path.dirname(os.path.realpath(__file__)) + "/../utils")
###########################################################################
# dynamic programming experiments #
######... | true |
153846fff7bb04e8a167a0077919f3508900d883 | Python | SalazakuIII/Gold-Rush | /main_app/views.py | UTF-8 | 2,405 | 2.703125 | 3 | [] | no_license | from django.shortcuts import render, redirect
import random, datetime
# Create your views here.
def index(request):
if "gold_src" not in request.session:
request.session["gold_amt"] = 0
request.session["activity_log"] = []
request.session.save()
return redirect("/display")
def disp... | true |
778ecb05aeb256118e188d4b6b99363756fd90b5 | Python | Grace-Joydhar/Python-Learning | /Study Mart/10. List.py | UTF-8 | 568 | 4.21875 | 4 | [] | no_license | a = "List is a collection which is changeable and ordered. It allows duplicate values."
print(a)
b= "\nList with nested list:"
print(b)
list = [1,["Grace", 5, 54, 60], 10,4.5,6, 6,20,22, "Grace"]
print(list)
print(list[1][3])
list.extend([3,4,5,6,7]) #To add new values in the array
list.remove(10) #Direct... | true |
cad831b3fac92f4108e1000a1105e64db682c6fc | Python | amisha1garg/Strings_in_python | /LargestNoWithGivenSum.py | UTF-8 | 1,310 | 3.671875 | 4 | [] | no_license | # Geek lost the password of his super locker. He remembers the number of digits N as well as the sum S of all the digits of his password. He know that his password is the largest number of N digits that can be made with given sum S. As he is busy doing his homework, help him retrieving his password.
#
# Example 1:
#... | true |
ce08004137bd3143f010bf36f0ae5ae6e8316348 | Python | onceuponpython/Class-1.1 | /1_1_printing_complete.py | UTF-8 | 133 | 3.0625 | 3 | [] | no_license | # -*- coding: utf-8 -*-
"""
Created on Mon Feb 18 14:43:11 2019
@author: Owner
"""
x=input("What is your name? ")
print("Hello", x) | true |
1faf8b848752c2bcec279ddaf908befe9a773476 | Python | WokoLiu/LeetCode_python | /p0011_M_ContainerWithMostWater.py | UTF-8 | 1,502 | 3.828125 | 4 | [] | no_license | # -*- coding: utf-8 -*-
# @Time : 2019/3/24 17:28
# @Author : Yulong Liu
# @File : p0011_M_ContainerWithMostWater.py
"""
题号:11
难度:medium
链接:https://leetcode.com/problems/container-with-most-water
描述:等距柱形图哪两根柱子之间装水更多
"""
from typing import List
class Solution(object):
def maxArea01(self, height: List[int]... | true |
145b8b34745cd39308b5d9de841278ee3aee3bd6 | Python | liuweilin17/algorithm | /interview/lianjia3.py | UTF-8 | 1,026 | 3.078125 | 3 | [] | no_license | ###########################################
# Let's Have Some Fun
# File Name: lianjia3.py
# Author: Weilin Liu
# Mail: liuweilin17@qq.com
# Created Time: Tue Sep 18 12:15:12 2018
###########################################
#coding=utf-8
#!/usr/bin/python
def findPair1(a, sumV):
b = sorted(a)
l = len(a)
i ... | true |
cc00be51f796349a2dd901a91cf6b577da6fe8b9 | Python | chrissiedesemberg/code_college-python | /chap8/tiy200_8-3.py | UTF-8 | 220 | 3.578125 | 4 | [] | no_license | def make_shirt(size, message):
print(f"\nThe shirt you would like is a size {size.upper()} and should have the following message printed on {message.title()}")
make_shirt("small", "winner, winner, chicken dinner!")
| true |
a89924ff86a399f02ab26d4e2d9a1f89bf0af127 | Python | blackbogdan/interviewcake | /coding bat/warmup1.py | UTF-8 | 6,448 | 4.25 | 4 | [] | no_license | # coding=utf-8
'''We have a loud talking parrot. The "hour" parameter is the current hour time in the range 0..23. We are in trouble if the parrot is talking and the hour is before 7 or after 20. Return True if we are in trouble.
parrot_trouble(True, 6) → True
parrot_trouble(True, 7) → False
parrot_trouble(False,... | true |
054b47421662446f63216f1743469e6ef98530b1 | Python | aqurilla/data-structures-and-algorithms | /python/edit_distance.py | UTF-8 | 811 | 3.5625 | 4 | [] | no_license | # https://leetcode.com/problems/edit-distance/
class Solution:
def minDistance(self, word1: str, word2: str) -> int:
nrows = len(word2) + 1
ncols = len(word1) + 1
T = [[0 for c in range(ncols)] for r in range(nrows)]
for i in range(nrows):
T[i][0] = i
for j i... | true |
8990b99d6a7be42e67a4a11ea65f7c366084fe69 | Python | inrixx/work | /do_cv2.py | UTF-8 | 1,533 | 2.921875 | 3 | [] | no_license | # coding=utf-8
import numpy as np
import cv2 as cv
import random
#图片旋转
def rotate(image, angle, center=None, scale=1.0):
(h, w) = image.shape[:2]
if center is None:
center = (w//2, h//2)
M = cv.getRotationMatrix2D(center, angle,scale)
rotated = cv.warpAffine(image, M, (w, h))
return rotated
#图片仿射 4点映射
def aff... | true |
2faffda9ac23e6138e4bf0faba74d091bcc1e48d | Python | tageorgiou/ptolemy_scraper | /buildingdata.py | UTF-8 | 534 | 2.578125 | 3 | [] | no_license | from urllib2 import Request, urlopen
import json
buildingcoords = {}
buildings = open("buildinglist").read().split('\n')
for building in buildings:
try:
r = Request(url="http://whereis.mit.edu/search?type=query&q=%s&output=json"
% building)
response = urlopen(r)
j = json.lo... | true |
27877aae85f14ed37da25e03488b2a78a7385a38 | Python | zcharif/MeiTag | /MeiTagAlpha/MeiServer/SymmetricCryptoTest.py | UTF-8 | 954 | 2.75 | 3 | [] | no_license | #!/usr/bin/python\
import base64
import os
from cryptography.fernet import Fernet
from cryptography.hazmat.backends import default_backend
from cryptography.hazmat.primitives import hashes
from cryptography.hazmat.primitives.kdf.pbkdf2 import PBKDF2HMAC
def encryptF(password, salt, message): #use this to encrypt. Al... | true |
87a8186ea30411374eb5dd0fb4d4b69c70406f09 | Python | RYANCOX00/programming2021 | /Week04-Flow/4.2.5. Average.py | UTF-8 | 944 | 4.90625 | 5 | [] | no_license | # A program to read in numbers, add them to a list and find the average of the list.
# Author: Ryan Cox
# Reading in a number and saving as the int 'number'
number = int(input("Enter a number (0 to stop): "))
# Creating a list 'numbers'
numbers = []
# Setting a loop until the user types 0.
while number != 0:
# ... | true |
1ba118c4473b08623eb28259099fa2f4c7209676 | Python | nicoluv/TareaP1 | /tarea1/tarea1python/__init__.py | UTF-8 | 226 | 3.6875 | 4 | [] | no_license | from Main import calcular
print("Ingrese los numeros binario que desea calcular: \nRecuerde que deben ser binarios y separase por espacios!\n Ejem. 111 + 1000 - 1010: ")
s = input()
print("El rersultado es: ", calcular(s)); | true |
9fd8b7e5962ac763f4229d0061d1dc1ae6086c78 | Python | Ela-Na/evaluation-metrics | /msle - rmsle.py | UTF-8 | 456 | 2.78125 | 3 | [] | no_license | # -*- coding: utf-8 -*-
"""
Created on Fri Nov 6 10:33:50 2020
@author: Ela
"""
import numpy as np
import math
def mean_squared_log_error(y_true, y_pred):
error = 0
msle = 0
rmsle = 0
for yt, yp in zip(y_true, y_pred):
error += (np.log(1 + yt ) - np.log... | true |
58bb645c90a17343c3689bbd83cfab886acf6f35 | Python | papalagichen/leet-code | /0077 - Combinations.py | UTF-8 | 958 | 3.0625 | 3 | [] | no_license | from typing import List
class Solution:
def combine(self, n: int, k: int) -> List[List[int]]:
return self.helper(1, n + 1, k)
def helper(self, start: int, end: int, k: int):
results = []
if k > 0:
for i in range(start, end):
for result in self.helper(i + 1,... | true |
8be019728b3b7289a70e9d3b394f9d62a8b6bc04 | Python | tsubasaokabe/test_apps | /test_apps/train.py | UTF-8 | 405 | 2.609375 | 3 | [] | no_license | from sklearn import svm
from sklearn import datasets
from sklearn.externals import joblib
def main():
#SVMを分類機にする
clf = svm.SVC()
#データセットの読み込み
iris = datasets.load_iris()
#従属変数と説明変数
X,y = iris.data, iris.target
#学習
clf.fit(X,y)
joblib.dump(clf,'./model/sample-model.pkl')
if __name_... | true |
b7f8db343455ad65da8eac994216cd728331c631 | Python | Sharisi123/PythonTasks7 | /task_3.py | UTF-8 | 460 | 3.640625 | 4 | [] | no_license | import datetime
def printTimeStamp(name):
print('Автор програми: ' + name)
print('Час компіляції: ' + str(datetime.datetime.now()))
printTimeStamp('Наживотов Олександр')
off = False
uniqueValues = set()
while off != True:
word = input('Введіть значення: ')
if(word == ''):
o... | true |
9141cdf4a75047a3356dc439e0cf52d83c395d47 | Python | harshonyou/SOFT1 | /week6/test_p05_ex1.py | UTF-8 | 1,007 | 3.71875 | 4 | [
"Apache-2.0"
] | permissive | import unittest
from practical_5 import split_text
class TestExo1(unittest.TestCase):
def testEmptyText(self):
self.assertEqual([], split_text("",''))
def testTextOnlyWhiteSpace(self):
self.assertEqual(["As", "Python's", "creator,", "I'd", "like", "to", "say"], \
split_text("As Py... | true |
009db55e7c5401386c5fb1041f1cd9bc0227398b | Python | nathanBarloy/polynoms | /poly.py | UTF-8 | 9,804 | 3.140625 | 3 | [] | no_license | # -*- coding: utf-8 -*-
"""
Created on Wed Oct 21 13:58:31 2020
@author: nathan barloy
"""
from numbers import Number
class Polynom() :
def __init__(self, coeffs=[]) :
self.coeffs = coeffs
self.simplify()
def simplify(self) :
max_deg = len(self.coeffs)-1
while... | true |
08a7dde4b7c482779fedc3e829e4531f45f968fe | Python | yue008/python-code | /chapter07/rollercoaster.py | UTF-8 | 541 | 3.296875 | 3 | [] | no_license | # -*- coding: utf-8 -*-
'''
@author: acer4560g
@file: rollercoaster.py
@time: 2020/2/2 8:22
@contact:python初学者(微信公众号)
@vision:3.7.3
---------------------
'''
import sys
print('本程序在python3.7.3编译,运行时请注意python版本')
print('python当前版本:\n' + sys.version)
print('--------------------------\n')
height=input('How tall are you... | true |
920ea80dfffca4eb22260c78b0774ae45fdcf5a4 | Python | joohyun333/programmers | /백준/이진탐색/가장 긴 증가하는 수열2.py | UTF-8 | 294 | 2.90625 | 3 | [] | no_license | # https://www.acmicpc.net/problem/12015
import sys, bisect
input = sys.stdin.readline
N = int(input())
arr = list(map(int, input().split()))
result = [0]
for i in arr:
if result[-1]<i:
result.append(i)
else:
result[bisect.bisect_left(result,i)] = i
print(len(result)-1)
| true |
fbfc3a87d0384f4fffb6a68c678d4aa485e2b5b9 | Python | Scripthen-KS/Genny | /gennylib.py | UTF-8 | 1,083 | 3.359375 | 3 | [] | no_license | #!/usr/bin/python
#!/usr/bin/env python
# -*- coding: UTF-8 -*-
#
# Genny Lib, will only contain string variables and
# calculations and directory options.
# List of to do.
menu_index="""
Welcome to Genny!
To get started, please read this short story of Genny's life
then you may proceed.
================ Genny =====... | true |
01cd2e440a1e96b306b2866938492fa4fbda76e8 | Python | LizEve/PopGen_Fall2014 | /62_Pop_Gen_Hw_GGM.py | UTF-8 | 3,525 | 3.734375 | 4 | [] | no_license | #!/usr/bin/env python
import math
import random
import numpy
import matplotlib.pyplot as plt
#1/p=(4N)/(k(k-1)) is the average coalescence time mean of an exponetial distribution
#p= 1/(4N)/(k(k-1))
#go back a number of generations drawn from an expoenetial distripution with the expectation was seen in the thingy abo... | true |
223147019f9d8b90d3eb8c6dc4b671aae6d63494 | Python | iridium-browser/iridium-browser | /ash/webui/camera_app_ui/resources/utils/gen_preload_images_js.py | UTF-8 | 1,242 | 2.703125 | 3 | [
"BSD-3-Clause"
] | permissive | #!/usr/bin/env python3
# Copyright 2020 The Chromium Authors
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.
"""Generates an array of images to be preloaded as a ES6 Module."""
import argparse
import json
import os
import shlex
import sys
def main():
argument... | true |
f9824f4d44a1278bb8b93d179976a26f4d678610 | Python | Sk8erboi99/Py_Expense_template | /expense.py | UTF-8 | 1,332 | 2.734375 | 3 | [] | no_license | from PyInquirer import prompt
import csv
from prompt_toolkit.validation import Validator, ValidationError
from user import get_user, get_user_option
class NumberValidator(Validator):
def validate(self, document):
try:
int(document.text)
except ValueError:
raise ValidationEr... | true |
d2919a08ebab52219485e41bb6f1e18efb74d057 | Python | ropeake/budget-automator | /Date_Process.py | UTF-8 | 3,073 | 3.03125 | 3 | [] | no_license | # -*- coding: utf-8 -*-
"""
Created on Sat Jan 20 14:18:07 2018
#Changelog 16 Feb 2019 bug fixes and performance improvements
#Changelog 20 Apr 2019 Committing comments to keep track of branches - columns not yet added!
@author: Ro
"""
import pandas as pd
import win32ui
import win32con
import os.path
import budgetML... | true |
0f2c220b8eabdce2d0345721bb1dad6b6cb71310 | Python | MingKeungZhang/Mastermind-Python-3.5.1- | /Mastermind.py | UTF-8 | 2,393 | 4.34375 | 4 | [] | no_license | #William Zhang
import random
#Globcal color variable
COLORS=['red','orange','yellow','green','blue','purple']
#Generate random color
def hidden_color():
#hidden color list
hiddenColor=[]
#Generate random color
for i in range(4):
randColor=COLORS[random.randint(0,5)]
hid... | true |
14f89d30c0e8bae892a4ed2fff0900ddc08b1a86 | Python | Hunt2behunter/synackapi | /scope_download_threaded.py | UTF-8 | 1,344 | 2.59375 | 3 | [
"MIT"
] | permissive | import requests
import warnings
import json
from threading import Thread
from Queue import Queue
warnings.filterwarnings("ignore")
token = raw_input("Please enter your Synack Auth Header (Command from web console: sessionStorage.getItem('shared-session-com.synack.accessToken')): ")
target_code = raw_input("Please ente... | true |
2952c687f88f485703fb1db5e9e92c736dbcfcfb | Python | errnox/some-matplotlib-things | /matplotlib-demo/data_plotter.py | UTF-8 | 367 | 3.3125 | 3 | [] | no_license | import numpy
import pylab
"""
Simple Line Plot
----------------
Shows how to make and save a simple line plot with labels, title and grid.
"""
data = numpy.loadtxt('./datafile')
pylab.plot(data)
pylab.xlabel('time (s)')
pylab.ylabel('temperature (degrees C)')
pylab.title('Simple data visualization')
pylab.grid(Tr... | true |
19f6e02c2d1f4740b0c66fedc80f0b92b075d863 | Python | gauthamkrishna-g/HackerRank | /Algorithms/Sorting/Palindrome_Index.py | UTF-8 | 401 | 3.4375 | 3 | [
"MIT"
] | permissive | T = int(input())
for _ in range(T):
S = input()
flag = 0
l = 0
r = len(S)-1
while l < r:
if S[l] != S[r]:
if S[l+1] == S[r] and S[l+2] == S[r-1]:
print (l)
else:
print (r)
flag = 1
break
els... | true |
85425853edac6c6fa36ddc764aabb2443a199aeb | Python | jwodder/doapi | /doapi/ssh_key.py | UTF-8 | 3,006 | 2.75 | 3 | [
"MIT"
] | permissive | from six import string_types
from .base import ResourceWithID
class SSHKey(ResourceWithID):
"""
An SSH key resource, representing an SSH public key that can be
automatically added to the :file:`/root/.ssh/authorized_keys` files of new
droplets.
New SSH keys are created via the :meth:`doapi.creat... | true |
6cf756f91a5427e9dcd7d0f25ab82230c6898e33 | Python | Rtgher/ProcGen-RPG | /Proc Gen RPG/GameWindow.py | UTF-8 | 1,752 | 3.375 | 3 | [
"Unlicense"
] | permissive | """GameWindow.py
This is the main game window.
It provides the main game functionality.
"""
#import section
import pygame
import eztext
import sys
from pygame.locals import *
#global variables initialization
#screen size
win_width= 800
win_height =600
#colors
black= (0, 0, 0)
grey=(100,100,... | true |
560828f98016f7004644dc364122a20d370bba88 | Python | victora0007/DashBoardDS4A | /Pages/StaticModelPageData.py | UTF-8 | 2,119 | 2.78125 | 3 | [
"MIT"
] | permissive | # Numeric Fields
fields = [
{"Label": "Price", "Description": "Price of device att moment of purchase", "type": "number"},
{"Label": "Past purchases", "Description": "Number of purchases done by user", "type": "number"},
{"Label": "Hours elapsed", "Description": "Total hours in local... | true |
8905361a1016644fd49284b736344cb9ef13d43b | Python | sivaprakashSP/Python-Stuffs | /Skillrack DC/Sum_of_2_nos_==_k.py | UTF-8 | 627 | 3.125 | 3 | [] | no_license | #l=[int(x) for x in input().split()]
n,y=input().split()
people = [int(x) for x in input().split()]
def tessa(source):
result = []
for p1 in range(len(source)):
for p2 in range(p1+1,len(source)):
result.append([source[p1],source[p2]])
return result
pairi... | true |
fd4511fff452ec5ade05b2c3eb8f0192694eec46 | Python | rpryzant/code-doodles | /interview_problems/2018/CRACKING/3.5_v2.py | UTF-8 | 1,221 | 3.96875 | 4 | [] | no_license | """
insertion sort
two variabls: min, index
1) move [:index] elements to 2nd stack
2) find min in remaining stack (moving elemnts to 2nd stack)
3) transfer back to original stack, but pluck out the min and move it to the index^th spot
4) increment index
O(n^2) but who'se counting??
struggled with this more than i ... | true |
d7a73efdf1d77c9a63307e9006804c448ea17f56 | Python | cassief2/Labs | /Vol1B/MonteCarlo2-Sampling/testDriver.py | UTF-8 | 8,547 | 3.453125 | 3 | [
"CC-BY-3.0"
] | permissive | # solutions.py
"""Volume 1, Lab 16: Importance Sampling and Monte Carlo Simulations.
Solutions file. Written by Tanner Christensen, Winter 2016.
"""
from __future__ import division
import matplotlib.pyplot as plt
import numpy as np
import scipy.stats as stats
def prob1(n):
"""Approximate the probability that a ra... | true |
8246abe974fea49cc3d2fad21c95abb546f017cd | Python | josephchenhk/learn | /Python/python3-cookbook/chp13脚本编程与系统管理/13.6 执行外部命令并获取它的输出/13.6.py | UTF-8 | 376 | 2.9375 | 3 | [] | no_license | # -*- coding: utf-8 -*-
# @Time : 11/1/2019 9:02 AM
# @Author : Joseph Chen
# @Email : josephchenhk@gmail.com
# @FileName: 13.6.py
# @Software: PyCharm
"""
13.6 执行外部命令并获取它的输出
"""
import subprocess
out_bytes = subprocess.check_output(['netstat','-a']) # This will take a huge amount of time!
out_... | true |
af368f826b8ccb1e6c6f65cdc896262c28a3b3f4 | Python | IsaacMagno/python3_curso_em_video | /PythonExercicios/ex099.py | UTF-8 | 478 | 4 | 4 | [] | no_license | from time import sleep
def maior(*num):
print('Analisando os valores passados...')
for n in num:
print(f'{n} ', end='')
sleep(0.2)
print(f'Foram infomados {len(num)} valores ao todo.')
if len(num) == 0:
print(f'Nenhum valor foi informado.')
else:
print(f... | true |
570b4458afbd768a2c9236166e424e6348176d33 | Python | gebbz03/PythonProject | /calculator/main.py | UTF-8 | 1,749 | 3.921875 | 4 | [] | no_license |
import hello
import Calculator
#hello.printHello("Gebb Ebero")
var1 = "n"
while(var1 == "n"):
print("1. Addition")
print("2. Subtraction")
print("3. Division")
print("4. Multiplication")
userSelected = input("Input: ")
num1=input("Please enter first number: ")
num2=input("... | true |
b2cb5d46c6d30fd077e45b91157368e93b863e38 | Python | Pathairush/data_manipulation | /model_explainability/model_explanation.py | UTF-8 | 3,430 | 2.71875 | 3 | [] | no_license | import numpy as np
import pandas as pd
from sklearn.model_selection import train_test_split
from sklearn.ensemble import RandomForestClassifier
import eli5
from eli5.sklearn import PermutationImportance
def print_permutation_importance(fitted_model, data_model : tuple, random_state = 1):
if len(data_model... | true |
2ddb4d0dbba21079341006fe3521d54b61ceb607 | Python | SamThomas/PyExpLabSys | /LivePlots/LivePlotsRunning.py | UTF-8 | 4,655 | 2.96875 | 3 | [] | no_license |
""" Running Plots """
#import matplotlib
#matplotlib.use('GTKAgg')
#from matplotlib.figure import Figure
#from matplotlib.backends.backend_gtkagg import FigureCanvasGTKAgg
from LivePlotsCommon import Plot
from LivePlotsExceptions import NLinesError, NDataError
import gtk
import time
class NPointRunning(Plot):
... | true |
4ef45fd769a4e42e52787a11b2ac07f986c22c68 | Python | TheRoboticsClub/colab-gsoc2020-Diego_Charrez | /models/dqn_catpole/args.py | UTF-8 | 1,911 | 2.6875 | 3 | [] | no_license | import argparse
def dqn_args_train():
"""Parse DQN training arguments.
Returns:
args: The parsed arguments.
"""
parser = argparse.ArgumentParser()
parser.add_argument(
'--seed',
dest='seed',
type=int,
help='Seed for numpy and tensorflow.',
defau... | true |
f5c25e0412ddbe42c3b26f4d7b1c986bdd378b1d | Python | Zeroeh/Python-RSA | /rsa.py | UTF-8 | 643 | 2.625 | 3 | [
"MIT"
] | permissive | #!/usr/bin/env python3
#with python3, you may need to do 'sudo pip3 install cryptodome'
from Crypto.PublicKey import RSA
from Crypto.Cipher import PKCS1_OAEP
import base64
__author__ = 'Zeroeh'
#need to be byte strings
player_email = b'email@mail.com'
player_password = b'password123'
pub_key = ("-----BEGIN PUBLIC ... | true |
7d4cdf58f35457797b66fda6d02167847318ec38 | Python | hoseinakbo/AI-P1-classic-pathfinding | /Pathfinding.py | UTF-8 | 2,180 | 3.390625 | 3 | [] | no_license | import PSA
import queue
class PathFindingState(PSA.State):
def __init__(self, board_array):
self.board_array = list(board_array)
def __eq__(self, other):
if len(self.board_array) != len(other.board_array):
return False
for i in range(0, len(self.board_array)):
... | true |
806befb71706fb2ff4d46ef6e7e83e32dbb874df | Python | peaceattack/pyFile | /win_zip.py | UTF-8 | 204 | 2.796875 | 3 | [] | no_license |
+# -*- coding:utf-8 -*-
+
+import zipfile
+MyZip = "C:\Users\Administrator\Desktop\MAC.zip"
+MyZipOBJ = zipfile.ZipFile(MyZip)
+MyZipOBJ.namelist()
+
+for i in MyZipOBJ.namelist():
+ print i
| true |
ae3881e7d033b2c4692bc6b5477b9d8ec8ad64ff | Python | Killavus/PyGame-SpaceInvaders | /GameModule/Env/Enemy.py | UTF-8 | 966 | 3.15625 | 3 | [] | no_license | #!/usr/bin/python2.7
from BattleObject import BattleObject
import pygame
import math
class Enemy( BattleObject ):
def __init__(self, maxHitpoints):
super( Enemy, self ).__init__(maxHitpoints)
self.direction = 1
def setDirection(self):
self.direction *= -1
def move(self, x):
self.rect.mov... | true |
456e621336c37267a9f1a51a5e14c364821aeb07 | Python | mdeependu/Machine-Learning | /Programs/Linear Regression.py | UTF-8 | 1,053 | 2.921875 | 3 | [] | no_license | x=[1,2,3,4,5]
y=[2,4,5,4,5]
sum_X=sum(x)
print(sum_X)
sum_Y=sum(y)
print(sum_Y)
mean_X=(sum_X)/len(x)
mean_Y=(sum_Y)/len(y)
X_2=[]
for i in x:
temp=i*i
X_2.append(temp)
''''print(X_2)'''
sum_X_2=sum(X_2)
print(sum_X_2)
Y_2=[]
for i in y:
temp=i*i
Y_2.append(temp)
''''print(Y_2)'''
sum_Y_2=sum(Y_2... | true |