blob_id stringlengths 40 40 | content_id stringlengths 40 40 | repo_name stringlengths 5 114 | path stringlengths 5 318 | language stringclasses 5
values | extension stringclasses 12
values | length_bytes int64 200 200k | license_type stringclasses 2
values | content stringlengths 143 200k |
|---|---|---|---|---|---|---|---|---|
100e86f10736415c88c853fe61a37ce01aef8923 | bf59ad4eed88087ed97fc5b772950ebc41cdeb89 | prsurve/ocs-ci | /tests/ecosystem/upgrade/test_logging_upgrade.py | Python | py | 7,486 | permissive | import logging
import pytest
from ocs_ci.ocs.cluster import CephCluster, CephHealthMonitor
from ocs_ci.ocs.resources.csv import CSV
from ocs_ci.utility.deployment_openshift_logging import (
check_health_of_clusterlogging,
get_clusterlogging_subscription,
)
from ocs_ci.ocs.exceptions import CommandFailed
from ... |
894d831b6dea2b32834b2194ffd4a15523a2a21a | 5e62eb62ebc42ba48f16f094b512dd5fd8cf6b2b | sharadbhat/Competitive-Coding | /LeetCode/Binary_Search.py | Python | py | 439 | no_license | # Leetcode
# https://leetcode.com/problems/binary-search/
class Solution:
def search(self, nums: List[int], target: int) -> int:
left, right = 0, len(nums) - 1
while left <= right:
mid = (left + right) // 2
if nums[mid] == target:
return mid
if ... |
a8d5fa9a8a4cda9caa589f272f4e67a140f5f262 | d035b15a908ea29f92cab9758a5e996e96134245 | YTMikeyyy/GetFalseURL | /getfalse.py | Python | py | 676 | no_license | #encoding=UTF-8
import urllib2
import sys
reload(sys)
sys.setdefaultencoding('utf-8')
# 在相同文件路径下将需要检查的文件
false = []
string = ''
i = 0
for line in open('./urls.txt'):
try:
request = urllib2.Request(line.encode('utf-8'))
request.add_header('User-Agent', 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) App... |
066cd0e3d811f68c299ce8d94b4436b8b8f1386c | 62625480671b80edc8f876b9c9e086e51ebbae72 | hbsdev/pydemo2 | /tests/test_pydemo2.py | Python | py | 444 | permissive | #!/usr/bin/env python
# -*- coding: utf-8 -*-
"""
test_pydemo2
----------------------------------
Tests for `pydemo2` module.
"""
import unittest
from pydemo2 import pydemo2
class TestPydemo2(unittest.TestCase):
def setUp(self):
pass
def test_something(self):
import pydemo2
asser... |
d0f82b33146c44e37d37542debf3032545b74e0b | 075fb996215165febbea5f21ce2e02c99be423e1 | Daniel451/praktikumNN | /PyMLP/NeuralNetworkVisu.py | Python | py | 8,293 | no_license | #!/usr/bin/env python3.4
#-*- coding: utf-8 -*-
import numpy as n
import KTimage as KT
import threading
from time import sleep
def _tanh(x): # diese Funktion stellt die Übertragungsfunktion der Neuronen dar. Forwardpropagation
return n.tanh(x)
def _tanh_deriv(x): # diese Funktion stell... |
945d7c149e1fc23d84d54254ef3e2261abb61c00 | 5d537326e2b29a1b14f2f16cb7b3430f7edf02ac | dahlia/attest | /attest/run.py | Python | py | 3,852 | permissive | from __future__ import with_statement
import sys
import os
from os import path
from pkg_resources import get_distribution
from optparse import OptionParser, make_option
from attest.collectors import Tests
from attest.reporters import get_all_reporters, get_reporter_by_name
from attest.utils import parse_options
from ... |
ebfdc8c9d628855ea75e804f857ca18a9ebf45f7 | 5d44a4244e3573953dc5891fd1c961fe5821f908 | smyang2018/goatools | /tests/test_print_results.py | Python | py | 1,616 | permissive | #!/usr/bin/env python
"""Test GOEnrichmentStudy::print_results."""
import os
# from goatools.rpt.goea_nt_xfrm import MgrNtGOEAs # get_goea_nts_all
from goatools.test_data.genes_NCBI_10090_ProteinCoding import GENEID2NT as GeneID2nt_mus
from goatools.test_data.nature3102_goea import get_geneid2symbol, get_goeaobj
__c... |
021367667d14783e3065bd41f80c6d1f0e4a10bb | 58042a8f51c9cd853fa15ada5108951a055e161a | emansije/thonny | /thonny/roughparse.py | Python | py | 33,753 | permissive | """Facilities for learning the structure of incomplete Python code
Mostly copied/adapted from idlelib.HyperParser and idlelib.PyParse
"""
import re
import string
from collections import Mapping
from keyword import iskeyword
from typing import Dict # @UnusedImport
NUM_CONTEXT_LINES = (50, 500, 5000000)
# Reason las... |
96e54ae2c6fc1c25a88305feda6f235b85930b79 | 6c4196590ff985dcf48c8549b750dced0596de1e | joekadam/final-projects-win20 | /ftarke/featureExtraction.py | Python | py | 2,341 | no_license | #!/usr/bin/env python3
import numpy as np
import matplotlib.pyplot as plt
from matplotlib import style
from ShowRepPlot import *
'''
File loads a numpy array generated by the guiTesting_FT.py file.
It then integrates the acceleration data and appends it to the numpy array
to provide velocity as an additional feature ... |
0782d75c28de79257942f24da34d68ca56422a32 | a83bc3aa3df73f662317a616e648dd7f7d023440 | firefly-uics/tensor_flow_demo | /keras/fashion_mnist.py | Python | py | 3,198 | permissive | # TensorFlow and tf.keras
import os
import tensorflow as tf
from tensorflow import keras
# Helper libraries
import numpy as np
import matplotlib.pyplot as plt
import ssl
# SSL: CERTIFICATE_VERIFY_FAILED” Error
ssl._create_default_https_context = ssl._create_unverified_context
# 下载数据集 存在不再下载
fashion_mnist = keras.d... |
f2d63ad9c94c5f867e6ecc6316b83e08d9dff7a7 | 07aee444f037b2aa9c2ac27ffb4fcaf19b89b889 | Blouglou2/TracingIDS | /handlerCreationTrace2.py | Python | py | 4,566 | no_license | #!/usr/bin/env python
import os
import re
import threading
import time
import subprocess
import sys
from os.path import splitext, expanduser, normpath
import click
from watchdog.events import FileSystemEventHandler
from watchdog.observers import Observer
try:
from Queue import Queue
except ImportError:
from... |
2a37f2b0d94745d515edd3e432c34cf1c2c6474f | 49d2058a63b63325f1670cc93f7797e1c3a80d0c | Den4i/BusVRN | /posts/admin.py | Python | py | 351 | no_license | from django.contrib import admin
# Register your models here.
from .models import Post
class PostUpAdmin(admin.ModelAdmin):
list_display = ["title", "timestamp"]
list_filter = ["timestamp"]
search_fields = ["title", "content"]
#list_editable = ['title']
class Meta:
model = Post
admin.s... |
f488e7ba334e3d3d1108ed659211c771b350cd6d | 28fdfb49cf19ef46af9165c281392a6126967863 | hzue/ACM-MM2017-SMP | /bin/transfer_predict.py | Python | py | 1,123 | no_license | from pprint import pprint
from sklearn.ensemble import RandomForestRegressor
from sklearn.neighbors import KNeighborsRegressor
from sklearn.metrics import mean_squared_error
from sklearn.metrics import mean_absolute_error
from sklearn.externals import joblib
from minepy import MINE
import numpy as np
import os
import h... |
729d41014d944e875761a6342a61bea8692c9caf | a159f63d2f098f36a8a03f81a63860c4f5f0d4a3 | leocalzavara/ProgrammingExercises | /GooglePython/babynames/babynames.py | Python | py | 2,659 | no_license | #!/usr/bin/python
# Copyright 2010 Google Inc.
# Licensed under the Apache License, Version 2.0
# http://www.apache.org/licenses/LICENSE-2.0
# Google's Python Class
# http://code.google.com/edu/languages/google-python-class/
# Leonardo P. Calzavara
# https://github.com/leocalzavara
import sys
import re
"""Baby Name... |
dae061049f6057c3f169e0d0941c4df34c4b7d27 | 4bc2c2ee4cc7327140fc39587cbda6734f45ae7b | AWalkInClouds/SEED2.0 | /Applications/setup.py | Python | py | 368 | permissive | """
py2app build script for SEED2_0
"""
from setuptools import setup
APP = ['SEED2_0.py']
DATA_FILES = ["data"]
OPTIONS = {'argv_emulation': True,
'iconfile': 'icon.icns',
'packages': ['PIL','sklearn','pandas','pysindy']
}
setup(
app=APP,
data_files=DATA_FILES,
options={'py2a... |
69d2bc9ddcb70afd5619181796b30625ba5120b3 | 8daa2306c00f38081ed6ac1f4fa75bac91f9ccb8 | Aasthaengg/IBMdataset | /Python_codes/p02691/s364766551.py | Python | py | 413 | no_license | N = int(input())
As = list(map(int,input().split()))
dic = {}
array = []
x = As[0]
init = 1 - x
for i in range(1,N):
v = init + i - 1 - As[i]
array.append(v)
if v not in dic:
dic[v] = 1
else:
dic[v] += 1
if 0 in dic:
ans = dic[0]
else:
ans = 0
for i in range(1,N):
y = As[i] ... |
a8849b1398e028ea202257278aea4ba39dc75e0c | 2862c1240013c63fb64445b96ca0d10d2e58c8d3 | MalachiBlackburn/CSC221 | /encrypt.py | Python | py | 1,543 | no_license | #Malachi Blackburn
#4/19/18
def main():
menu()
CRYPT = {'a': '1','b': '2','c': '3','d': '4','e': '5','f': '6','g': '7',\
'h': '8','i': '9','j': '!','k': '@','l': '#','m': '$','n': '%',\
'o': '^','p': '&','q': '*','r': '(','s': ')','t': '-','u': '=',\
'v': '_','w': '+','x':... |
e53741f84c51b956fd250530a0dccee8f22d3764 | b63c5e37c5cdc02d7dadd06a05e103de0f106e1a | Wuskysong/python01_- | /python_one_learn/day03/exercise02.py | Python | py | 849 | no_license | """
练习:在控制台中获取一个季度(春夏秋冬),
显示相应的月份。
春 --> 1月2月3月
夏 --> 4月5月6月
秋 --> 7月8月9月
冬 --> 10月11月12月
14:18
"""
season = input("请输入季度:")
# if season == "春":
# print("1月2月3月")
# if season == "夏":
# print("4月5月6月")
# if season == "秋":
# print("7月8月9月")
# if season == "冬":
#... |
bc1aa59fa8ab644cab988c864396ef15983ac174 | 6051088722364bdff796f35c7adf74c8cc21ff37 | kushkansara02/aquadrone2020 | /thruster_control/nodes/faulty_thrust_distributor_node.py | Python | py | 977 | no_license | #!/usr/bin/env python3
import rospy
from thruster_control.thrust_computer.thruster_configurations import ThrusterConfiguration
from thruster_control.thrust_distributor.faulty_thrust_distributor import FaultyThrustDistributor
"""
This class is responsible for listening to the motor_command topic where the thrusts fo... |
35b942d42202acb7f6781b2ec5848c10e298d8cf | 207bc4f29fff087646c3d2c803a74775a93d84a4 | wuqiangch/AAAI2020-RFMetaFAS | /main.py | Python | py | 7,555 | no_license | """Main script for ADDA."""
import os
import os.path as osp
import argparse
import torch
from torch import nn
from tensorboardX import SummaryWriter
from core import Train, Test
from datasets.DatasetLoader import get_dataset_loader
from datasets.TargetDatasetLoader import get_tgtdataset_loader
from misc.utils import i... |
014d4bee91ad91e512d15b248ff900e003f8350e | cfaae669999c8218dc1fc33923f66cff0cd9ce33 | 3oos97/facebook | /venv/Scripts/pip3-script.py | Python | py | 417 | no_license | #!C:\Users\minamdoss\PycharmProjects\MyFlask\venv\Scripts\python.exe
# EASY-INSTALL-ENTRY-SCRIPT: 'pip==19.0.3','console_scripts','pip3'
__requires__ = 'pip==19.0.3'
import re
import sys
from pkg_resources import load_entry_point
if __name__ == '__main__':
sys.argv[0] = re.sub(r'(-script\.pyw?|\.exe)?$', '', sys.a... |
6f6e4ded95f70cf10e01ec5ca17212c48d8798ca | 3ae8697d07ae0e583e04dd3406da5894d45c1841 | nekapoor7/Python-and-Django | /Python/cppsecrets.com/program 78.py | Python | py | 370 | no_license | """Python Program to Count the Number of Blank Spaces in a Text File"""
with open("C:\\Users\\nekapoor\\git\\Python-and-Django\\PYTHON PROGRAMS\\file_data\\word.txt",'r',encoding='utf-8') as file1:
data = file1.read()
line = data.splitlines()
words = data.split()
spaces = data.split(" ")
charc = (l... |
6e75b11be2a2c3f088c9092351b12e8e9056c228 | e221c3f39bc0ebc29811a8beb2f98ca62d845745 | adamw1623/QEC_Analysis | /sentiment_analysis_watson.py | Python | py | 4,243 | no_license |
import nltk
#nltk.download('vader_lexicon')
#nltk.download('punkt')
from nltk.sentiment.vader import SentimentIntensityAnalyzer as SIA
from watson_developer_cloud import PersonalityInsightsV3
from watson_developer_cloud import WatsonApiException
from os.path import join, dirname
#Watson API Things
personality_insight... |
137d0b37703f6d16c2e16a25d32a4a52b1bfab8a | bf43ecd2d45306e0b9f723910fc96fbad5fcd939 | esmaeilinia/TensorFlow-cn | /source/_static/code/zh/basic/example/numpy.py | Python | py | 571 | no_license | import numpy as np
X_raw = np.array([2013, 2014, 2015, 2016, 2017])
y_raw = np.array([12000, 14000, 15000, 16500, 17500])
X = (X_raw - X_raw.min()) / (X_raw.max() - X_raw.min())
y = (y_raw - y_raw.min()) / (y_raw.max() - y_raw.min())
a, b = 0, 0
num_epoch = 10000
learning_rate = 1e-3
for e in range(num_epoch):
... |
8aa9095a9a44d7f92f2e10b5868f7376565369b6 | 1e5d4381cae45bcd89de03e2cce2b9471a580bf7 | zjunweihit/Compute | /tf/4_tensorboard/multiply.py | Python | py | 431 | no_license | #
# Load the result:
#
# tensorboard --logdir=train/mul
#
import tensorflow as tf
g = tf.Graph()
with g.as_default():
a = tf.placeholder(tf.float32, name = "a")
b = tf.placeholder(tf.float32, name = "b")
multiply = tf.multiply(a, b, name = "multiply")
with tf.Session() as ss:
res = ss.run(mu... |
47bb77bfd9de426fd119be32e8472250af3f0721 | 4e73f4ca334af6f418d45aa8a166dd9aa82ea876 | TheMn/internet-engineering-project | /manage.py | Python | py | 626 | permissive | #!/usr/bin/env python
"""Django's command-line utility for administrative tasks."""
import os
import sys
def main():
os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'helli5.settings')
try:
from django.core.management import execute_from_command_line
except ImportError as exc:
raise ImportE... |
0ea90f4f328fb05f37bf3484d139b5457c9868ae | 19e2440df79ecc194fbd2540a1af425e9439f4c3 | zhenbaidang/ssd_pytorch_repuloss_ml | /train_backup.py | Python | py | 10,267 | no_license | from data import *
from utils.augmentations import SSDAugmentation
from layers.modules import MultiBoxLoss
from ssd import build_ssd
import os
import sys
import time
import torch
from torch.autograd import Variable
import torch.nn as nn
import torch.optim as optim
import torch.backends.cudnn as cudnn
import torch.nn.in... |
fed40cda1b1b8cbd6b773eed4053f5a68a556b5b | e27b57a7284b102a8ca0329f2a859f12a4f45b13 | kirarpit/topic-categorization | /utils.py | Python | py | 1,570 | no_license | #!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
Created on Sun Sep 30 22:29:27 2018
@author: Arpit
"""
import os, csv
from scipy import sparse
import numpy as np
import matplotlib.pyplot as plt
"""
Returns the sparse version if it exists
otherwise it loads the data, converts it to sparse
and saves it for the futur... |
e80a569c8774e2d8358ca885045936a0a27a4138 | b204a3e61635b96efd78d84592dd713d55d1c7c6 | sajastu/RedSumm2021 | /src/models/reporter.py | Python | py | 9,358 | permissive | """ Report manager utility """
from __future__ import print_function
from datetime import datetime
import time
import math
import sys
from distributed import all_gather_list
from others.logging import logger
def build_report_manager(opt):
if opt.tensorboard:
from tensorboardX import SummaryWriter
... |
a7833ea40aa4e15d73f50af6b8451011b55d18c8 | c9b40a408d263c0454930316b5bd6270db44ad4a | welsny/solutions | /617.Merge_Two_Binary_Trees.py | Python | py | 603 | no_license | #!/usr/bin/env python
# -*- coding: utf-8 -*-
# Definition for a binary tree node.
# class TreeNode(object):
# def __init__(self, x):
# self.val = x
# self.left = None
# self.right = None
class Solution:
def mergeTrees(self, t1, t2):
"""
:type t1: TreeNode
:type... |
ff605a3588bbf6ceb997967c7d49dcac008cdbf8 | 18d51456b44e944756cd6af18716ab52f1e9c16d | aaqibkhorasi/redis-proxy | /app.py | Python | py | 5,030 | no_license | from flask import Flask, render_template, request
from redis import StrictRedis
from werkzeug.contrib.cache import SimpleCache
from rq import Queue
from rq.job import Job
import time
from urllib.parse import urlparse
import os
import json
DB_HOST = "localhost"
DB_PORT = 6379
MAX_CONNECTION = 3
CACHE_SIZE = 2
POP_SIZE... |
f844cf110e99bba722ee90be159c60f390aa10d7 | 006b322cdb3e5f4c0f02b9b9bbab8468fdb844f7 | BenWinchester/HEATDesalination | /src/heatdesalination/tests/mut/test_solar.py | Python | py | 12,648 | permissive | #!/usr/bin/python3
# type: ignore
########################################################################################
# test_solar.py - Tests for the solar module. #
# #
# Author: Ben Winch... |
0e20e27d05eea8d46d15ed854c505bb01f0451f7 | 18bb4d6a46eb2df4bd916e0df59c95b54d5dad89 | lxtxl/aws_cli | /codecommit_write_2/approval-rule-template-with-repository_associate.py | Python | py | 932 | no_license | #!/usr/bin/python
# -*- codding: utf-8 -*-
import os
import sys
sys.path.append(os.path.dirname(os.path.abspath(os.path.dirname(__file__))))
from common.execute_command import write_two_parameter
# url : https://awscli.amazonaws.com/v2/documentation/api/latest/reference/codecommit/associate-approval-rule-template-with... |
85b7139b8fd9d915e9b2d33fb712cfa55b8b0d98 | c786fad9b456ad50015d76c1308b74d516c9875d | virtualbjorn/BjornIoT | /backend/Amazing_app/todo/urls.py | Python | py | 214 | no_license | from django.urls import include
from django.conf.urls import url
from .views import HomeViewSet
urlpatterns=[
url(r'^todo/$', HomeViewSet.as_view({
'get':'list',
'post':'create',
}))
] |
06f9d66b4c6915861850aacc582fc16f85b099e9 | 56c4cd127b5df68a276b36aac0a9abe9292abe14 | Narunoir/Top_Down_Shooter_continued | /main.py | Python | py | 15,432 | no_license | import pygame as pg, pygame
import sys
from os import path
from settings import *
from sprites import*
from tilemap import *
## HUD Functions ##
def draw_player_health(surf, x, y, pct):
if pct < 0:
pct = 0
BAR_LENGTH = 100
BAR_HEIGHT = 20
fill = pct * BAR_LENGTH
outline_... |
1322f3ed99acd95853490f9082de70505b1ffe56 | 15c0d5387683c10a812057baaf249f292ed36b43 | johnerick89/bookstore | /books/tests/test_models.py | Python | py | 1,059 | no_license | from django.test import TestCase
from books.models import Book, Rental
class BookTest(TestCase):
""" Test module for Book model """
def setUp(self):
Book.objects.create(
title='Gifted Hands', code='Biography101', book_type='regular',daily_rental_charge=1.5)
def test_book_created(s... |
532103b6cec61885683eb83d7bc66c66e469d8b8 | a85eb8ff109134cd295869f2adb94ac3429a12e5 | tkhan3/CECS-229 | /Beginner Tutorial/Chapter3.py | Python | py | 808 | no_license | bicycles = ["trek", "cannondale", "redline", "specialized"]
print(bicycles)
print(bicycles[0])
print(bicycles[-1])
print(bicycles[-2])
message = "My first bicycle was a " + bicycles[0] + "."
print(message)
motorcycles = ['honda', 'yamaha', 'suzuki']
print(motorcycles)
motorcycles[0] = 'ducati'
print(motorcycles)
mo... |
c02f03f1c6227490575e1899fbc277a6c6210da6 | 20b169ca878fdfc53a010f9a9062ceac2d8273d5 | justindujardin/mathtastic | /libraries/mt_python/tests/test_tree_node.py | Python | py | 437 | permissive | from ..mathtastic.tree import BinaryTreeNode
def test_tree_node_constructor():
tree = BinaryTreeNode(BinaryTreeNode(), BinaryTreeNode())
assert tree.left is not None and tree.right is not None
count = 0
def node_visit(node, depth, data):
nonlocal count
count = count + 1
tree.visi... |
e577ce5d841f04e512eeb7247e7f3e589c124375 | 026a9c6708c80832765539dccf34575e01c73776 | Rushikesh8/Registeration_API | /authreg/serializers.py | Python | py | 719 | no_license | from rest_framework import serializers
from django.contrib.auth.models import User
class UserSerializer(serializers.ModelSerializer):
email = serializers.EmailField(max_length=100,min_length=4)
password = serializers.CharField(max_length=15,min_length=4,write_only=True)
class Meta:
model = U... |
7389393c90392ce832727f804f89bc9626304804 | 9de205f516376ff7a1f9e94b9d0ad6bb104734a0 | guschde/DHBW-DB-Projekt | /index/forms.py | Python | py | 1,461 | no_license | from django import forms
from datetime import datetime
from datetime import date
from . import models
# pro Model eine Klasse in forms , bei fields keine Primary Keys ausser wenn wir sie selber definieren
class CreatePersonal (forms.ModelForm):
class Meta:
model = models.Personal
fields = ['Vorna... |
32a27d6a31f1acf0895022b33d7304afa7c50abc | a6fa1e6e346b637e0c9e1cb601fed393327ff185 | suddashankar/updatedbookstore | /bookpro/wsgi.py | Python | py | 407 | no_license | """
WSGI config for bookpro project.
It exposes the WSGI callable as a module-level variable named ``application``.
For more information on this file, see
https://docs.djangoproject.com/en/2.2/howto/deployment/wsgi/
"""
import os
from django.core.wsgi import get_wsgi_application
os.environ.setdefault(... |
6d7a4f3af0726addd6e2aad55bb0d217d883a36f | 7547506a45d24b0cd30aae6dcfde3672fabb0a47 | slozenger/radio-scraper | /export.py | Python | py | 3,001 | no_license | #!/usr/bin/env python3
from datetime import date, datetime, timedelta
import sys, os
from functools import partial
eprint = partial(print, file=sys.stderr)
station = 'ro/tananana'
work_dir = os.getenv('HOME') + '/radio/' + station
playlist_dir = os.path.join(work_dir, 'playlist')
tracks_fn = os.path.join(work_dir... |
e67f92d207fd9e2e8c1fe48d6b427e062c4f0381 | 52a9cdf2d74abafc4a3f7926c7fd0d619742ec45 | yoavcaspi/aoc2019 | /day24/solution.py | Python | py | 4,259 | no_license | from __future__ import annotations
import argparse
from typing import Tuple, Dict, Set
from collections import defaultdict
def neighbors_pos(x: int, y: int) -> Tuple[int, int]:
yield x + 1, y
yield x - 1, y
yield x, y + 1
yield x, y - 1
def sol1(data: str) -> int:
seen_boards: Set[Tuple[Tuple[in... |
61fa1c4d452dcb0bb4649362b9b4c24297f3cb18 | ab5694882a0394817db8f128fed6efe1c59561ef | zackbeucler/Tic-Tac-Toe | /test_TTT_unittest.py | Python | py | 2,803 | permissive | import Tic_tac_toe
import unittest
from unittest.mock import patch
class TestTicTacToe(unittest.TestCase):
def test_random(self):
"""This test case ensures that the program actually selects the player who goes
first at random"""
counter = 0
for i in range(100):
... |
7de0b4dd7a685e766782b6b73613c607901c3ba7 | 1897704d9f60028bbda08ae5c08e4c9b98b39c46 | luzofex/plottingid-blockchain-1 | /plottingid/wallet/puzzles/p2_delegated_puzzle_or_hidden_puzzle.py | Python | py | 3,624 | permissive | """
Pay to delegated puzzle or hidden puzzle
In this puzzle program, the solution must choose either a hidden puzzle or a
delegated puzzle on a given public key.
The given public key is morphed by adding an offset from the hash of the hidden puzzle
and itself, giving a new so-called "synthetic" public key which has t... |
2d8137e9ce199aa0439684006f6d29b8f6145666 | 0c037eafb9647934d3e51b0fa62b0f3c2a782202 | nctimmer/CMPT-120L-910-20F | /Assignments/Assignment 6/leap_year.py | Python | py | 516 | permissive | def leap_year(year):
if (year % 4) == 0:
if (year % 100) == 0:
if (year % 400) == 0:
print(year, "is a Leap Year!")
else:
print(year, "is not a Leap Year.")
else:
print(year, "is a Leap Year!")
else:
print(year, "is not ... |
3273d23fd280d90c92745cff7ffd87d68147882c | 1f69068ecba7a445d61b38a4226b721429d8a71b | Aravind-Chowdary/Final_Project | /Kerschbaum.py | Python | py | 3,895 | no_license | import Crypto.Random
import math
class Kersch:
MAX = None
n = None
T = None
def __init__(self, l, n):
self.n = n
self.MAX= self.calc_max(l)
class Tree:
left = None
right = None
plain = None
cipher = None
def __init__(self, plain, cipher):
... |
e03ae30fd98938475bdf6bfac7a3a0351021390a | 854c2520df1e6e473883923c31f995f01171ea8b | pombredanne/deuce | /deuce/tests/db_mocking/swift_mocking/client.py | Python | py | 2,967 | permissive |
import os
import io
import shutil
from swiftclient.exceptions import ClientException
import hashlib
container_path = '/tmp/swift_mocking'
def _get_vault_path(vault_id):
return os.path.join(container_path, vault_id)
def _get_block_path(vault_id, block_id):
vault_path = _get_vault_path(vault_id)
return... |
d491314afa9d19a6c026512cc725ade6548e0c61 | 17d6a13ab80528dd7b51bbe3b876a04d5a2fdb2b | pkruskal/detectron2 | /projects/DensePose/densepose/vis/extractor.py | Python | py | 5,084 | permissive | # Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved
import logging
from typing import Sequence
import torch
from detectron2.layers.nms import batched_nms
from detectron2.structures.instances import Instances
from densepose.vis.bounding_box import BoundingBoxVisualizer, ScoredBoundingBoxVisualizer
f... |
7e19d5f4cacbae13ab1aed85883f84de2905d454 | 417223e114bce3bd29877599a1ee375d680ba7a0 | KennyTzeng/LeetCode | /908/main.py | Python | py | 300 | no_license | class Solution:
def smallestRangeI(self, A, K):
"""
:type A: List[int]
:type K: int
:rtype: int
"""
min_A, max_A = min(A), max(A)
if max_A - min_A > K * 2:
return max_A - min_A - K * 2
else:
return 0 |
07d8547d555a7f606ce04759c00c0ff1c99aa932 | 865e702003c9cb85cb46872bb707a01539f62b60 | morinlab/pipeline-components | /sequenza_seqzbinning/component_main.py | Python | py | 3,779 | no_license | """
component_main.py
@author: bgrande
"""
import glob
import os.path
import logging
from kronos.utils import ComponentAbstract
class Component(ComponentAbstract):
"""
Sequenza seqz-binning
"""
def __init__(self, component_name="sequenza_seqzbinning", component_parent_dir=None,
se... |
27843728fbf0047b457796b41d8def3b11a86704 | d4a839d22556c3fd7463b9551376a39ae6a6cdb1 | duplxey/NForum | /settings/migrations/0004_auto_20200406_1913.py | Python | py | 620 | permissive | # Generated by Django 3.0.5 on 2020-04-06 17:13
from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
('settings', '0003_auto_20200406_1908'),
]
operations = [
migrations.AlterField(
model_name='sitecolorpalette',
name='... |
1419ca3fc8950fa5de3638edc7166f80d4876da1 | 0cd5d8e06f31232da097166f44610e59bf4df62c | PETTOKEN/PETT | /test/functional/test_framework/messages.py | Python | py | 39,754 | permissive | #!/usr/bin/env python3
# Copyright (c) 2010 ArtForz -- public domain half-a-node
# Copyright (c) 2012 Jeff Garzik
# Copyright (c) 2010-2017 The Bitcoin Core developers
# Distributed under the MIT software license, see the accompanying
# file COPYING or http://www.opensource.org/licenses/mit-license.php.
"""Bitcoin test... |
8b4b86eea48608ebb168806d4dc3801b6995015b | 4ed0c7b5b4b9e355866162c5ce9bf58daaa8e1d5 | dhita-irma/check-hauling | /todok/checkhaulingTodok2019.py | Python | py | 800 | no_license | #! python3
# check_hauling.py
import openpyxl as xl
wb1 = xl.load_workbook('Hauling Todok 2019.xlsx')
haulingRM = wb1.active
wb2 = xl.load_workbook('dataBB_todok.xlsx')
dataBB = wb2.active
print('Reading rows...')
for row1 in range(3, haulingRM.max_row + 1):
voucher1 = haulingRM.cell(row=row1, column=2).value
... |
268306b57442ae307e8d0d67ab635ad8a46ce7dc | 7a82d8006908bd0c3086235a8ff0976017e112e7 | gugabfigueiredo/DjangoBlogClone | /blog/admin.py | Python | py | 223 | no_license | # -*- coding: utf-8 -*-
from __future__ import unicode_literals
from django.contrib import admin
from blog import models
# Register your models here.
admin.site.register(models.Post)
admin.site.register(models.Comment) |
b057e9cef8ce12cbbfc1a5063f6768a3347d5a37 | 819df5a473b55d2777c5e027953781a82811f702 | kam40oz/w3af | /plugins/infrastructure/finger_pks.py | Python | py | 2,710 | no_license | '''
finger_pks.py
Copyright 2006 Andres Riancho
This file is part of w3af, http://w3af.org/ .
w3af 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 version 2 of the License.
w3af is distributed in the hope that ... |
134c4e9cc0904a79db9678305f328f049ec586f7 | ecd4b5dc5af771005a9b2b89d96b3947a7465232 | Da-Yuan/reid-project | /dirStr.py | Python | py | 703 | no_license | #coding: utf-8
import os
import re
# 递归查找路径下所有xml
def dirList(mainPath, allFileList):
"""
:param mainPath:
:param allFileList: a list
:return:
"""
fileList = os.listdir(mainPath)
for fileName in fileList:
filePath = os.path.join(mainPath, fileName)
if os.path.isdir(filePath... |
4148b6b070c39853ea05036e0a9706e515d226d6 | ad64454f1fe57ab8854b35782546203c5fca4fb1 | adamglueck/Multiplication-table | /multiplication-table.py | Python | py | 932 | permissive | """
multiplication-table.py
Author: Adam Glueck
Credit: None
Assignment:
Write and submit a Python program that prints a multiplication table. The user
must be able to determine the width and height of the table before it is printed.
The final multiplication table should look like this:
Width of multiplication tabl... |
384b7656b116538b3a19dbbaf3306fa648e6a3ed | 96e93c5e03bab0baf7dec488198fb9f948da2749 | Omardyab/drf-api-permissions-postgres | /trip/tests.py | Python | py | 3,711 | no_license | from django.test import TestCase
# Create your tests here.
from django.contrib.auth import get_user_model
from django.test import TestCase
from django.urls import reverse
from rest_framework import status
from rest_framework.test import APITestCase
from .models import Trip
class tripModelTests(TestCase):
@clas... |
5b83e4063b3c7a1c5f577959828157634d005e81 | cd065d148475e5001db8b0febebfe8dce82e7bd0 | sandeeprajurs/hackathon | /finance_buddy_api/app/es_data_service.py | Python | py | 3,419 | no_license | from elasticsearch import Elasticsearch
class ESDataService(object):
def __init__(self, host='10.40.0.9', port='9200'):
self.es_endpoint = "{0}:{1}".format(host, port)
self.es = Elasticsearch(self.es_endpoint)
def get_company_details(self, company_name):
query = {
"query":... |
276a8287750c61aeb4aceefc863938c6cca27e4b | 455b6f14c9a083ee9eb5d8ee36f7ef4c434fced3 | Sudarsan-Sridharan/Django-CRM-API | /communication/tests/test_models.py | Python | py | 3,463 | no_license | from django.test import TestCase
from django.contrib.auth.models import User
from ..models import ClientDetail, SalesStage, SalesSub
from lead.models import LeadProcess
# class ClientDetailTest(TestCase):
# """ Test module for ClientDetail model """
# def setUp(self):
# user = User.objects.create(use... |
a42c173a4f2aa693e12777ce0c159e157b86fc8c | c9988c75be61b46d7854681258826ab39d2b2d5e | acgrafton/coding_challenges | /compress-string.py | Python | py | 1,029 | no_license | """Write a function that compresses a string.
Repeated characters should be compressed to one character and the number of
times it repeats:
>>> compress('aabbaabb')
'a2b2a2b2'
If a character appears once, it should not be followed by a number:
>>> compress('abc')
'abc'
The function should handle letters, whitespac... |
b55c5c759cf99b379414ceed82a6bfbeb18e648f | 923600225dcc17f9f1845a9d4bfc13994506e99b | shironano/watchmen-matryoshka-doll | /watchmen/pipeline/single/stage/unit/action/merge_row.py | Python | py | 2,352 | permissive | import logging
import time
from watchmen.common.constants import pipeline_constants
from watchmen.monitor.model.pipeline_monitor import UnitActionStatus
from watchmen.pipeline.model.pipeline import UnitAction
from watchmen.pipeline.single.stage.unit.mongo.index import run_mapping_rules, build_query_conditions, \
_... |
31746bf764518262c3a66609a3e2d04ff9cd0fdf | d4aade133539eb19b9fc2c455dd249ec0d2a2ab1 | zhanglicaiabc/DIP_pro | /test1.py | Python | py | 1,309 | no_license | from read_data import *
from test import *
import numpy as np
import cv2
if __name__ == '__main__':
# x_train, y_train, x_valid, y_valid, x_test = load_data()
x_train_mean = np.load('x_train_mean.npy')
x_valid_mean = np.load('x_valid_mean.npy')
x_train_co_matrix = np.load('x_train_co_matrix.np... |
6b3354acd4e2019bd4ec56512d8109b52bda7005 | 848b5ed386d53100d37545783a697aafc947a635 | cysin/py-lz4 | /setup.py | Python | py | 498 | no_license | #!/usr/bin/env python
from distutils.core import setup, Extension
setup(name='lz5 Module',
version='0.1',
description='lz4',
author='',
author_email='blueflycn@gmail.com',
url='',
packages=['lz4'],
ext_modules=[Extension("lz4/_lz4",
["src/py_lz4.... |
54390260317cd0a213002592cb969bd3e8bebc5b | fb083550d2666a0121f2c0127d53a209df4484c0 | raj13aug/Python-learning | /example-programs/string.py | Python | py | 723 | no_license |
#
print("python for 'beginner'")
#
print('python /for "beginner"')
#multi line string
course = '''
Hi John,
Here is our first email to you.
Thank you,
The support team
'''
print(course)
#index
store = 'Nataraj'
print(store[1])
print(store[-1])
# character start from 0 to 3. but last character exlude.
print(sto... |
92d7ec7403b3cd4f3a701929e0e7efa426fc5f35 | c166e88e0b7f7b132dec4d8ffda32c7df4477acf | Jasurbek-Sharofiddinov/Student-Attendance-Management-System | /attendance/migrations/0001_initial.py | Python | py | 7,027 | no_license | # Generated by Django 3.2.5 on 2021-09-18 19:25
from django.conf import settings
import django.contrib.auth.models
import django.contrib.auth.validators
from django.db import migrations, models
import django.db.models.deletion
import django.utils.timezone
class Migration(migrations.Migration):
initial = True
... |
4855195a6160af7b53dd4735ca03c24c761ab9ce | d34bcd2e358b83e75aa39d97d76154ed3c925d5c | Jerry3062/jerry_ml | /kaggle/furniture_recongnition/down_validation.py | Python | py | 1,254 | no_license | import urllib.request
import os
import json
dir_path = 'F:/dataset/iMaterialist Challenge (Furniture) at FGVC5'
images_path = 'F:/dataset/iMaterialist Challenge (Furniture) at FGVC5/validation'
url_file_path = 'validation.json'
url_file_abs_path = os.path.join(dir_path, url_file_path)
with open(url_file_abs_path, 'rb'... |
8cf51b21fbaaeb16f941552ac212cc22787f3a9c | 394e96ddc8caa39b557b439a2fbcf4723fdd9dca | ellinx/LC-python | /TheMazeIII.py | Python | py | 4,716 | no_license | """
There is a ball in a maze with empty spaces and walls.
The ball can go through empty spaces by rolling up (u), down (d), left (l) or right (r),
but it won't stop rolling until hitting a wall. When the ball stops, it could choose the next direction.
There is also a hole in this maze. The ball will drop into the hole... |
bb370fbd688f330a6630c1395b255e652dd36f19 | 59deeace006947d1f822815ffeebddf05ce6bce0 | slowmoyang/QGJets | /0-GenerateJets/runCMSSubmit.py | Python | py | 526 | no_license | #!/usr/bin/env python2
import os
from glob import glob
files = glob('/xrootd/store/mc/RunIISummer16DR80Premix/QCD_Pt-15to7000_TuneCUETP8M1_FlatP6_13TeV_pythia8/AODSIM/PUMoriond17_80X_mcRun2_asymptotic_2016_TrancheIV_v6-v1/*/*root')
files = [f.replace('/xrootd', 'root://cms-xrdr.sdfarm.kr:1094///xrd')
for f i... |
205e5e3e1ff43c616017f19ccbc634bf33ec041c | cdcee3b7095ae961ac336ba9cd69d3177a079a40 | hcfw007/LeetCode | /algorithms/python3/25 Reverse Nodes in k-Group.py | Python | py | 759 | no_license | class Solution:
def reverseKGroup(self, head, k):
pre = ListNode("ph")
pre.next = head
prehead = pre
curr = head
reverseGroup = []
while (curr != None):
reverseGroup.append(curr)
curr = curr.next
if (len(reverseGroup) == k):
... |
fa65c1ef04584d4c0fd834390a1b13e480fc5e1d | f1f86b8acbb3b7b46f950fff1f30bf61be263202 | AlexKarlsen/thesis-src | /DDNN/dnn/dnn_runner.py | Python | py | 1,999 | no_license | import torch.nn.functional as F
from time import perf_counter
class predictor:
def __init__(self, model, data, model_type):
self.nExits = 4
if model_type == 'b-densenet' or model_type == 'b-resnet':
self.exits = [model.exit1, model.exit2, model.exit3, model.exit4]
if model_... |
3cccac7a1ff83f02b040cf7b6beade9e8ad03005 | 860bbd153fb2501a3da7254b2585ab942fdd5180 | craigderington/django-drf-examples | /setup.py | Python | py | 1,856 | permissive | #!.env/bin/python
from setuptools import setup, find_packages
desc = ''
with open('README.md') as f1:
desc = f1.read()
setup(
name='django-drfexamples',
version='0.0.1',
description='Demonstration of the Django REST Framework',
url='https://github.com/craigderington/django-drfexamples.git',
a... |
e6dde7d3da738ea4834fbc7944311489f02f7215 | 8a3c9e6771c6f5a4e603834d55467b056b816cfd | LAOS-Y/AgriVision | /gen_odgt.py | Python | py | 1,811 | no_license | import json
import os
import os.path as P
import argparse
from tqdm import tqdm
import numpy as np
from PIL import Image
parser = argparse.ArgumentParser(description="Generate odgt for Agri-Vision dataset")
parser.add_argument('--root', '-r')
parser.add_argument('--dataset', '-d')
parser.add_argument('--odgt-path', '-... |
27411d0f1647c434290fdfab0361512d65a9caa4 | 825d6ae60b81c21c8c67651c064c2ae7796abda1 | bhavya4official/Summary_PM_Folks | /server.py | Python | py | 1,056 | permissive | import re
from mbot import telegram_chatbot
bot = telegram_chatbot("config.cfg")
Previous_Date = datetime.datetime.today() - datetime.timedelta(days=6)
Previous_Date_Formatted = Previous_Date.strftime ('%d/%m/%y') # format the date to dd/mm/yy
pre_date = str(Previous_Date_Formatted)
f = open("WhatsApp Chat with s3 -... |
ba52ab140ddf0af2ba929287366eba86e36aa679 | aadacb4629ed10167c3523caf008e2ab38ee0803 | mahmoudeljiddawi/TN | /GUI.py | Python | py | 2,382 | no_license | import tkinter as tk
from tkinter import *
from tkinter import messagebox
import Back_end
#import Back_end
X_window = '600x'
Y_window = '300'
window = tk.Tk()
Activation=0
window.title('Task 1')
Activation_List = tk.Listbox(window , height=3, width=8 ,selectmode=tk.SINGLE)
Activation_List.place(x=2,y=50)
Activa... |
86abf5f5bdfc3cc419c9e238ffeed2e352b75879 | d18cfa09fa94145ede70b0f6e4c3bf8fa7ecca1a | cuzkop/algorithm_and_data_structure_python | /chapter5/flog1.py | Python | py | 223 | no_license | n = 7
h = [2, 9, 4, 5, 1, 6, 10]
dp = [0]*n
for i in range(1, n):
if i == 1:
dp[i] = abs(h[i]-h[i-1])
continue
dp[i] = min(dp[i-1] + abs(h[i]-h[i-1]), dp[i-2] + abs(h[i]-h[i-2]))
print(dp) |
5746106e478da6e74d58584b45876ed32cc6723d | 8727b0830e38a8f408ab3a4c10155f1fa96949b6 | bsircelj/sentinelhub-py | /sentinelhub/os_utils.py | Python | py | 3,120 | permissive | """
Module for managing files and folders
"""
import os
import errno
from sys import platform
def get_content_list(folder='.'):
""" Get list of contents in input folder
:param folder: input folder to list contents. Default is ``'.'``
:type folder: str
:return: list of folder contents
:rtype: lis... |
4d7add32823f55df6559fcbf05a89cab4a6acb76 | 3a5b440b3235379eb0876d94d6ba54c347fe1893 | leinian85/note | /练习/练习题100/python005.py | Python | py | 353 | no_license | # 题目005:输入三个整数x, y, z,请把这三个数由小到大输出。
def short(*args):
_list = list(args)
for i in range(len(_list)-1):
for j in range(i+1,len(_list)):
if _list[i] > _list[j]:
_list[i],_list[j] = _list[j],_list[i]
for item in _list:
print(item,end=" ")
short(3,5,2) |
214e6ab0b1ba388cf786e00005bd6faf83f6b4a3 | 72312eb2017ae53bd7003e113e3003eeb5705936 | GRNCheetah/Joueur.py | /games/catastrophe/game.py | Python | py | 7,945 | permissive | # Game: Convert as many humans to as you can to survive in this post-apocalyptic wasteland.
# DO NOT MODIFY THIS FILE
# Never try to directly create an instance of this class, or modify its member variables.
# Instead, you should only be reading its variables and calling its functions.
from joueur.base_game import Ba... |
54143bcaa95819e765bfe5bad0a6cc452b9d6a51 | aaee569197a0eaf8ff0ae996181e6509ce9d9ea1 | gopichandu-tech/Neuron | /or.py | Python | py | 449 | permissive | import pandas as pd
from utils.model import Perceptron
from utils.all_utils import prepare_data, save_model, save_plot
OR = {
"x1": [0,0,1,1],
"x2": [0,1,0,1],
"y": [0,1,1,1],
}
df = pd.DataFrame(OR)
df
X,y = prepare_data(df)
ETA = 0.3 # 0 and 1
EPOCHS = 10
model_OR = Perceptron(eta=ETA, epochs=EP... |
00ceaf881109e3063135e35ae1ee85778d07acf6 | 8e461b780306636dade2b4e0d23034946a0ced9f | tuxido-feynman/rce | /framework/rce/master/user.py | Python | py | 36,074 | permissive | #!/usr/bin/env python
# -*- coding: utf-8 -*-
#
# user.py
#
# This file is part of the RoboEarth Cloud Engine framework.
#
# This file was originally created for RoboEearth
# http://www.roboearth.org/
#
# The research leading to these results has received funding from
# the E... |
9a320c219c2905b2dbd5dcf09d25e39afec759bc | cdbc72f2247f3cbb81398539698bb5fb23e1d6de | asnani04/tech_meet | /pvecGs.py | Python | py | 1,955 | no_license | from __future__ import print_function
import math
import numpy as np
import os
import random
import tensorflow as tf
import gensim as gs
from gensim.models import Doc2Vec
import gensim.models.doc2vec
import multiprocessing
# from io import open
from collections import namedtuple
wdir = "./testInputs/"
gdir = "./gsPve... |
6b1dbbf998985f388f3b5a1bf04a9c473ce21103 | 3183587f38fc676956b94fb8938b13fb26813eaf | StephanErb/pants | /tests/python/pants_test/scm/test_git.py | Python | py | 22,294 | permissive | # coding=utf-8
# Copyright 2014 Pants project contributors (see CONTRIBUTORS.md).
# Licensed under the Apache License, Version 2.0 (see LICENSE).
from __future__ import absolute_import, division, print_function, unicode_literals
import os
import unittest
from builtins import open
from contextlib import contextmanager... |
23f3e99ee46e1a6938af9400862f032ce3c86d1e | 05292bef34af5c8df443588cc06afc9c62cce773 | HangCoder/micropython-simulator | /tests/basics/int_big_mul.py | Python | py | 467 | permissive | # tests transition from small to large int representation by multiplication
for rhs in range(2, 11):
lhs = 1
for k in range(100):
res = lhs * rhs
print(lhs, '*', rhs, '=', res)
lhs = res
# below tests pos/neg combinations that overflow small int
# 31-bit overflow
i = 1 << 20
print(i * ... |
9b581e445ece5c33c4112a5ce17e9c9807d0aecb | e813e074177f349dd44bbce08c19cb58b5c1770c | JamesKoj/Trading-Simulator | /tradingplatform/migrations/0002_auto_20200701_1239.py | Python | py | 699 | no_license | # Generated by Django 3.0.7 on 2020-07-01 16:39
import datetime
from django.db import migrations, models
import django.utils.timezone
class Migration(migrations.Migration):
dependencies = [
('tradingplatform', '0001_initial'),
]
operations = [
migrations.AddField(
model_name... |
309db4364d102ddc4a196e7ffdade8fffa676304 | 022a8c3ae4cf15b3d1480f6721744791dfdb12b9 | valenca/Evolutionary-Computation-Engine | /ECLib/scatter.py | Python | py | 1,103 | no_license | from cPickle import load
import numpy as np
import matplotlib.pyplot as plt
import matplotlib.animation as animation
global it
it=0
class PolygonHandler:
# Constructor
def __init__(self):
self.X = []
self.Y = []
self.listx = []
self.listy = []
self.numberPoints = 0
self.fig , ax = plt.subplots()
self... |
5057b55066f9d03558b2866f9ff5326c0293f05f | e13c165035605606acd910e88e4579263be0d903 | patriciohc/OnlineStore | /api_rest/urls.py | Python | py | 764 | no_license | from django.conf.urls import url, patterns, include
from rest_framework.urlpatterns import format_suffix_patterns
from api_rest.views import ProductViewSet, CategoryList, ImageViewSet
from rest_framework.routers import DefaultRouter
router = DefaultRouter()
router.register(r'product', ProductViewSet)
router.register(... |
0c84fdb759fe9cd6488e87dbfdc21be0a27ef6c5 | 104b335eee3e522f445c61a1dd15d1a03af0f491 | 369geofreeman/MITx_6.00.1x | /HackerRank/if-else.py | Python | py | 526 | no_license | # If Else
# Task:
# Given an integer, n, perform the following conditional actions:
#
# If n is odd, print Weird
# If n is even and in the inclusive range of 2 to 5, print Not Weird
# If n is even and in the inclusive range of 6 to 20, print Weird
# If n is even and greater than 20, print Not Weird
import random
n ... |
41b84387bdb7db1ae7fd93125f9506e3a009c763 | 6d22e9678d123d5f6a234e383be72d716757ea1d | JediKnightChan/Adapting-OCR | /src/criterions/ctc.py | Python | py | 1,213 | permissive | import torch
import torch.nn
import math
import pdb
class CustomCTCLoss(torch.nn.Module):
# T x B x H => Softmax on dimension 2
def __init__(self, dim=2):
super().__init__()
self.dim = dim
self.ctc_loss = torch.nn.CTCLoss(reduction='mean', zero_infinity=True)
def forward(self, logi... |
85f6db09cd70d9f4a9e558a7fb905a0ba5a861f2 | d1bea0cb3337a7a304bed2c4387016d257d6a9b8 | blue-yonder/postgraas_server | /postgraas_server/create_app.py | Python | py | 1,529 | permissive | import logging
from flask import Flask
from flask_restful import Api
from raven.contrib.flask import Sentry
import postgraas_server
from postgraas_server.backends import get_backend
from postgraas_server.configuration import get_application_config, get_meta_db_config_path
from postgraas_server.management_resources im... |
7700c08fefa2be326d0228d87c472a458a291361 | 8dba3d95464650f0f6776c691961a11c87ed4443 | billboggs/stock-analysis-engine | /analysis_engine/iex/helpers_for_iex_api.py | Python | py | 4,771 | permissive | """
Functions for getting data from IEX using HTTP
"""
try:
import urllib.parse as urlparse
except ImportError:
import urlparse as urlparse
import requests
import pandas as pd
import analysis_engine.iex.consts as iex_consts
import analysis_engine.iex.build_auth_url as iex_auth
import spylunking.log.setup_loggi... |
7f38d5095d4707b8b04e6c522f5099869b340410 | 367183b011d51cb61db93f7c1f7c52b048b5512a | cesarzxk/directlog-rastreio | /Rastreamento-directlog.py | Python | py | 5,894 | no_license | import requests
import bs4
import time
from pygame import mixer
mixer.init()
mudanca = 0
finish = 's'
loop = 0
tempo = 0
Try = 1
rem = ''
tamanho = 0
while finish != 'n':
if Try == 1:
try:
with open("remessas.txt",'r') as arq:
for i in arq:
tamanho += 1
if tamanho != 0:
print... |
e713102771c3dd95e239e283de24d72afcd5b5c1 | f4caf17b60d65964bca5298d7dd0c220c5086655 | BSchilperoort/pandas | /pandas/tests/indexing/test_multiindex.py | Python | py | 51,718 | permissive | from datetime import datetime
from warnings import catch_warnings
import numpy as np
import pytest
from pandas.errors import PerformanceWarning, UnsortedIndexError
import pandas as pd
from pandas import (
DataFrame, Index, MultiIndex, Panel, Period, Series, Timestamp, date_range,
period_range)
from pandas.te... |
a73a7be6d9de5acf245dd8d23d0fd8366422edb1 | bb6a63467a49e884530aee31eaee1d368e205e3c | AbbasElHachem/extremes | /b_get_data.py | Python | py | 19,782 | no_license | #-------------------------------------------------------------------------
# Name: get_data
# Purpose: read the precipitation data from the hdf5 file
#
# Author: mueller
#
# Created: 07.08.2013
# Copyright: (c) mueller 2013
# Licence: <your licence>
#----------------------------------... |
60774503cb6e703219d6d6126c9ca4640ab49c46 | 40d6412cb92c06d0a978fae3617833f691296a4f | LongerVision/SimpleCV | /SimpleCV/Shell/Tutorial.py | Python | py | 13,970 | permissive | #!/usr/bin/python
# A Basic SimpleCV interactive shell tutorial
#load required libraries
from SimpleCV import *
from subprocess import call
from code import InteractiveInterpreter
import platform
lb = "\n" #linebreak
tb = "\t" #tab
tutorial_interpreter = InteractiveInterpreter(globals())
logo = None
img = None
clon... |
821116640fcd991c508358a696df792dda6358fb | 6b4c75bc033032c2255713248765a3dd0aa6b766 | YuHongShanghai/myshop | /shop/recommender.py | Python | py | 1,581 | no_license | import redis
from django.conf import settings
from .models import Product
r=redis.StrictRedis(host=settings.REDIS_HOST,port=settings.REDIS_PORT,db=settings.REDIS_DB)
class Recommender(object):
def get_product_key(self,id):
return 'product:{}:purchased_with'.format(id)
def products_bought(self,product... |
28b69a3c3b0821177279a3073e512ed2dc590342 | ff6db8366da7575b226e1f16c7a831e582117b9b | nicohiggs/course_project | /brute_force_f.py | Python | py | 7,000 | no_license | import numpy as np
import random
from queue import PriorityQueue
from queue import Queue
def run_sim(f):
beta = 1 / 1.5 # beta is 1/lambda
# interarrival_times = np.random.exponential(scale=beta, size=10000)
interarrival_times = np.random.lognormal(4.5, 4, size=10000)
arrival_times = np.cumsum(interarr... |
5d77ec44c888cd3b3309c2937c9b341d0bc7c802 | 568e3b5a1e263ea1b9b37d8e59b931400fc177a7 | shaobenbin/alipay-sdk-python | /alipay/aop/api/request/AlipayMobileBeaconMessageSendRequest.py | Python | py | 3,694 | permissive | #!/usr/bin/env python
# -*- coding: utf-8 -*-
import json
from alipay.aop.api.FileItem import FileItem
from alipay.aop.api.constant.ParamConstants import *
class AlipayMobileBeaconMessageSendRequest(object):
def __init__(self, biz_model=None):
self._biz_model = biz_model
self._biz_content = No... |
d7c172b0e9fa5e7d36e94695bd234ec988051f81 | 11e2ac0fb044d555ddc66f77ad5253532b1a722a | jubayerr/python-basic | /dictionary.py | Python | py | 325 | no_license | # dictionary
monthConversions = {
"Jan": "January",
"Feb": "February",
"Mar": "March",
"Apr": "April",
"May": "May",
"Jun": "June",
"Jul": "July",
"Aug": "August",
"Sep": "September",
"Oct": "October",
"Nov": "November",
"Dec": "December",
}
print(monthConversions["Oct... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.