index
int64
0
1,000k
blob_id
stringlengths
40
40
code
stringlengths
7
10.4M
14,200
6c4e42631a909243557e54a636b3759dbea29936
def stock_availability(inventory, command, *args): if command == 'delivery': return inventory + [*args] if not args: return inventory[1:] if isinstance(args[0], int): count = int(args[0]) return inventory[count:] sold_items = set(args) return [item for item in invento...
14,201
7a3a0ca584c3890e6c2aa7947849bada7bdd60f1
import subprocess def run(command): out = subprocess.check_output(command, shell=True) if out: return out.decode('utf-8').strip() def git_hash(short=False): if short: return run('git rev-parse --short HEAD') return run('git rev-parse HEAD') def git_origin(): return run('git remote get-url origin...
14,202
b3ff4449f72325c32155a5b402404aa7947f2e6f
import math import random from random import randint import time def partition(arr, low, high): i = (low - 1) pivot = arr[high] for j in range(low, high): if arr[j] <= pivot: i = i + 1 arr[i], arr[j] = arr[j], arr[i] arr[i + 1], arr[high] = arr[high], arr[i + 1] r...
14,203
fecbc98e550b93a73e43872079aa30783e6a02c7
import unittest import requests class TestBooks(unittest.TestCase): @classmethod def setUpClass(cls): cls.book_id = None @classmethod def tearDownClass(cls): pass def setUp(self): self.base_url = 'http://pulse-rest-testing.herokuapp.com' self.book_data = {"author"...
14,204
cad118626090366b0551de25f91bf7ceb7a23dcd
"""Setup for doc-helper See: https://github.com/ynshen/DocHelper """ # Always prefer setuptools over distutils from setuptools import setup, find_packages from os import path here = path.abspath(path.dirname(__file__)) # Get the long description from the README file with open(path.join(here, 'README.md'), encoding='...
14,205
a58448761aa49b54805445c1628e881cf76dd383
def persistence(n): n = str(n) counter = 0 while len(n) > 1: sum = 1 for num in n: sum *= int(num) n = str(sum) counter += 1 return counter print(persistence(int(input("Num:"))))
14,206
6143dc00e5b74ca5ff84a2ee3041d72e7457ae24
from pyswip.prolog import Prolog class Doctor(object): """A Python adapter to the prolog medical system.""" def __init__(self, prolog_file): self.prolog_file = prolog_file def __repr__(self): return 'Doctor("%s")' % self.prolog_file def diagnose(self, symptoms, age_group=None): """Returns a lis...
14,207
3fe8dd11ed249a6d9885c5b704b6025bcf81788d
lst = [[0,1,2,3],[3,4,5,5],[6,7,8,8],[9,0,1,9]] print(f"minimum value element in the array:{min(map(lambda x: min(x),lst))}") print(f"maximum value element in the array:{max(map(lambda x: max(x),lst))}") col_min = list(min(map(lambda x: x[i],lst)) for i in range(4)) print(f"elements with minimum values column-wise: {...
14,208
8db94bb9345665334fe029750cff590abe520ee8
#coding: UTF-8 # Author - 袁骏涛和家人共同完成 import time # 让程序停止 import os, subprocess from colorama import init,Fore,Back,Style # 导入颜色模块 init(autoreset=True) # 初始化Colorama class Light: # 构造函数 def __init__(self): # 定义light列表 self.light = [] # 自动初始化 self.prepare_light() def pr...
14,209
5aafb6d2b8b082edba0c509b16c7a12b91861a42
""" A basic pygame template """ import pygame import random import time # Define some colors BLACK = ( 0, 0, 0) WHITE = ( 255, 255, 255) GREEN = ( 0, 255, 0) RED = ( 255, 0, 0) pygame.init() # Set the width and height of the screen [width, height] size = (800, 600) screen = pygame.d...
14,210
9a1cf3fc8adb6d43e9c1442bda82c73fe1767438
k=[] n=int(input("Enter number of elements:")) for i in range(1,n+1): b=int(input("Enter element:")) k.append(b) k.sort() print("Largest element is:",k[n-1])
14,211
79f0d5da6ba70f240bd0764467b61360224c8421
import rospy import time import numpy as np from geometry_msgs.msg import Twist from std_msgs.msg import Float64, Float32 from openai_ros import robot_gazebo_env from nav_msgs.msg import Odometry class CATVehicleEnv(robot_gazebo_env.RobotGazeboEnv): def __init__(self): """ Initializes a ...
14,212
749a5396a5e7b29e619461e1e871fc58b0dfa9fb
class BackupError(Exception): pass class RestoreError(Exception): pass
14,213
324648f2ad6d5bc2bf670bbef69210fc0b882ac3
#encoding=utf-8 import MySQLdb from config_handler import ConfigParse class DB(object): def __init__(self): self.db_conf = ConfigParse().get_db_conf() self.conn = MySQLdb.connect( host = self.db_conf["host"], port = self.db_conf["port"], user = self.db_conf["user...
14,214
da23a4e6ae38b1ead935ae8cde8b44ad49e989e1
# Upper Confidence Bound # Importing the libraries import numpy as np import matplotlib.pyplot as plt import pandas as pd # Importing the dataset dataset = pd.read_csv('Ads_CTR_Optimisation.csv') import math d = 10; N = 10000; ads_selected = [] # Implementing UCB # step - 1 numbers_of_selections = [0] * d sums_of_re...
14,215
26423ccc0a58942a59fe04d6b1f7fd4b3346e0c8
#!/usr/bin/python import re # functions ported from rmgarbage https://github.com/zw/rmgarbage # Rule L: if string is longer than 40 characters, it is garbage def too_long(string): if len(string) > 40: return True return False # Rule A: if a string's ratio of alphanumeric characters to total ch...
14,216
23a7b405d57a823299a5895afe527ea763b4fac1
############################################################################################################### ###################################################SREENIDHIN C C############################################## ################################################################################################...
14,217
c6183f4770320865c91b4641382a01bc7a6362c1
import os import sys from machine import * class Cluster: def __init__(self, machineConfig, machinesPerType, minCpu, minMem, jobSizeThreshold , smallJobThreshold, largeJobThreshold ): self.numMachines = 0 self.machines = [] self.machinesByType = {} self.cpuUsage = 0 self.memUsage = 0 self.totCpu = 0 se...
14,218
dd1f4261852ef6057ccdc85daf53835561b56e6b
import asyncio import logging import logging.config import sys from .config import ReceptorConfig from .diagnostics import log_buffer from .logstash_formatter.logstash import LogstashFormatter logger = logging.getLogger(__name__) def main(args=None): try: config = ReceptorConfig(args) except Except...
14,219
904cb530fbb1afdf349391b78d63420401a2b6d7
from flask import Flask, render_template # 모듈을 임포트 시켜서 파이썬 파일을 실행할 수 있다. ex) import hello import datetime import random app = Flask(__name__) @app.route("/") # 데코레이터 , endpoint def hello(): # def : 함수 생성 , -> Hello Ssafy를 반환하는 hello라는 함수를 만듦. # return "Hello Ssafy!" return render_template('index.html') # rend...
14,220
0bf35e7b9d877b47699d4658f80082593130098e
__author__ = 'cmccully' from matplotlib import pyplot from glob import glob from astropy.io import fits import numpy as np from astropy.io import ascii def setup_plot(): pyplot.rcParams['axes.titlesize'] = 'x-large' pyplot.rcParams['axes.labelsize'] = 'x-large' pyplot.rcParams['axes.labelweight'] = 'normal...
14,221
984d29009c36797e9db376dbdc94754c38b3f613
""" Création du TEIheader pour le catalogue d'exposition D'après un programme récupérant ces mêmes types d'informations réalisées par Claire Jahan. Author: Juliette Janès, 2021 Esteban Sánchez Oeconomo, 2022 """ from lxml import etree as ET from ..variables import contenu_TEI def creation_header(): """ Fonct...
14,222
9762edbc626d875c750cc8c1cbd196f88f3b1590
import torch import jieba import tensorflow as tf from bert4keras.tokenizers import Tokenizer from bert4keras.models import build_transformer_model from model.modeling_roformer import RoFormerModel jieba.initialize() config_path = 'E:/BaiduNetdiskDownload/chinese_roformer_L-12_H-768_A-12/bert_config.json' checkpoint_p...
14,223
19d4011674c461e6150ead02efcb358f489d2bf6
# -*- coding: utf-8 -*- """ Created on Fri Nov 1 15:05:04 2019 @author: Lizerhigh """ from pandas import DataFrame from pandas import read_json def sk(val): return val[1] def unpack(s): if not b'(' in s: return {s: b''} #print(s) se = [] c = 0 st = 0 ret = {}...
14,224
26e35d4e6d3af654c9d5623e48be9e364cd18e13
#!/usr/bin/env python3 import re import os import sys import getopt import shutil inputfile = '' outputfile = '' try: opts, args = getopt.getopt(sys.argv[1:],"hi:o:",["ifile=","ofile="]) except getopt.GetoptError: print (sys.argv[0] + " -i <inputfile> -o <outputfile>") sys.exit(2) for opt, arg in opts: ...
14,225
e6fad67bf775277830f3e0d77e448272af106d93
from tornado.web import RequestHandler class BaseHandler(RequestHandler): def get_current_user(self): return self.get_secure_cookie("username")
14,226
9c5724a28e4af1264f732b5c3ae5943f5fd05e15
"""Plot the electric field generated by three point charges in a plane.""" import numpy as np import pylab as plt import vectorplot as vp dpi = 100 size = 700 video = False # Charges : (q, x, y) charges = [(10, +0.5, +0.5), (-10, -0.5, -0.5), (4, +0.2, -0.2)] xs = np.linspace(-1, 1, size).astype(np.float32)[None, ...
14,227
0b922dc6048c8b99d778578f385585b2e7a46dab
#! /usr/bin/env python """Script to see if some standard files have changed A 'change' is any change to size, mtime or md5sum """ from __future__ import print_function import os import csv import sys import argparse from datetime import datetime from bdb import BdbQuit __version__ = '1.0.0' def run_args(args, met...
14,228
4178dce5e2040898102fbde56f0b9ffe61903bb3
from context import of from context import ls import numpy as np def test_Hessian(F,x_0): return F.Hessian(x_0) def test_Gradient(F,x_0): return F.Gradient(x_0) def test_NewtonStep(F,x_0): # Quick and dirty Newton step test. return -1*np.linalg.solve(F.Hessian(x_0),F.Gradient(x_0)) def test_Newton...
14,229
7a3a6570b80a16eb31f1533d5c580af000efd45c
#!/usr/bin/env python3 # -*- coding: utf-8 -*- """ Created on Sat Jul 28 13:49:53 2018 @author: dannilew """ import sqlite3 connection = sqlite3.connect("week4.db") #adding data model cursor = connection.cursor() sql_command = """ CREATE TABLE people ( id integer primary key, name varchar, position varchar, ...
14,230
91c417ef30ee0739a139e017ee1b783dd7706f6c
from libraryClass import * class Parser: def __init__(self, filename='data/a_example.txt'): self.filename = filename self.hashcode = None def parse(self, filename): with open(filename) as f: #data = f.readlines() # each element in data is line from input file data = f.read().splitlines() # read...
14,231
1ec802d2b5d1921e06b8e5ee6663d9048f28a9e5
# Generated by Django 2.2.5 on 2019-11-12 03:36 from django.db import migrations, models class Migration(migrations.Migration): dependencies = [ ('homepage', '0006_auto_20191111_1825'), ] operations = [ migrations.AlterField( model_name='farmowner', name='email',...
14,232
85e680041900da4e23019c9854a41faaedd76317
from django.db import models from django.contrib.auth.models import User class Category(models.Model): class Meta: verbose_name_plural = 'Categories' name = models.CharField(max_length=254) friendly_name = models.CharField(max_length=254, null=True, blank=Tru...
14,233
8c8111f9f31f3426d544eb8386274f15caec02c4
import sys, time, os import socket class BufferedMessage(): """ Setup buffered messaging on socket connection. """ def __init__(self, conn, addr): """ Initialize the buffered message. """ self.conn = conn self.addr = addr self.buff = "" self.recvsize = 1024 ...
14,234
af7c33d1c06d3a9774b2da487acd41265a91611e
#!python3 """Dictionary and Tuple Exercise... """ __author__ = "Gavin Jones" """ # 1 Write a program that allows to store age of your family members. # Program should ask to enter the person name and age # Once you are done you should be able to input the name of the person and retrieve the age. # Now print Name o...
14,235
bcf1ecca0e89eeb9342a67a260aba1fd0962b5f2
# # 映画レビューのテキスト分類 # # (https://www.tensorflow.org/tutorials/keras/text_classification) import altair as alt import pandas as pd from tensorflow import keras # ## IMDB datasetのダウンロード imdb = keras.datasets.imdb (train_data, train_labels), (test_data, test_labels) = imdb.load_data(num_words=10000) # ## データの観察 print(f"T...
14,236
3356f29e81e3ec947ac9fc55aa6378dc812c7208
import os import sys import random from torch.utils.data import Dataset from language import Language from utils import tokens_to_seq, contains_digit, shuffle_correlated_lists, chunks from operator import itemgetter import datetime currentDT = datetime.datetime.now() class OneFoldSequencePairDataset(Dataset): de...
14,237
2e978f80ce15fc6b14941c4672056b41ad9cbe40
# AUTOGENERATED! DO NOT EDIT! File to edit: 00_core.ipynb (unless otherwise specified). __all__ = ['SCOPES', 'KEY_FILE_LOCATION', 'ga_to_df'] # Cell from apiclient.discovery import build from oauth2client.service_account import ServiceAccountCredentials import os from dotenv import load_dotenv import pandas as pd l...
14,238
5b24417c1beee1622c368c393b6e64902090326b
#!/usr/bin/env python """ Renames image files to label + file creation date + count Creation date is read if EXIF data is available Otherwise get_exif_date returns nullstring Example 1: img_140015.jpg -> label_2021_01_02_1_.jpg Example 2: scann_15.jpg -> label.jpg """ import os from tkinter import Tk, Label, Entry, Bu...
14,239
5ef45c059e63d1b5f98aaa05a06267a9f373b287
#coding=utf-8 ''' 4. 编写程序,完成“名片管理器”项目 需要完成的基本功能: 添加名片 删除名片 修改名片 查询名片 退出系统 程序运行后,除非选择退出系统,否则重复执行功能 ''' #初始化一个名片存储 cards = {} i = 0 while i == 0: print("=" * 10 + "欢迎使用名片管理器" + "=" * 10) print("1.添加名片") print("2.删除名片") print("3.修改名片") print("4.查询名片") print("5.退出系统") j = input("请选择使用功能系统的编号"...
14,240
e4a23ff1d6b8177c6d8abf2b8b9ce510efb8abd7
import sys from typing import TYPE_CHECKING if sys.version_info < (3, 7) or TYPE_CHECKING: from ._yref import YrefValidator from ._yanchor import YanchorValidator from ._y import YValidator from ._xref import XrefValidator from ._xanchor import XanchorValidator from ._x import XValidator fr...
14,241
a44f3b2249c59be3af2bbe6df49038a7ce823188
#!/usr/bin/env python3 import rospy from std_msgs.msg import Float32 n = 0 def cb(message): global n n = message.data*2 if n > 100: n = message.data*3 if n > 300: n = message.data/5 rospy.init_node('twice') sub = rospy.Subscriber('count_up', Float32, cb) pub = rospy.Publisher('tw...
14,242
bddf7a70eda5f1771bbbd93775141c5e73d23409
from flask import Blueprint from scsr.api import ScsrAPI class ScsrView: scsr_app = None def __init__(self): self.scsr_app = Blueprint('scsr_app', __name__) self.games_view = ScsrAPI.as_view('games') self.scsr_app.add_url_rule('/games/', defaults={'game_id':None}, view_fu...
14,243
b72f8c6544bf9f2b27b76dc7bcb1282b5d567472
from element_operate.UnionLotto.UnionLotto_choosenumber import UnionLottoChooseNumber_lelun from element_operate.UnionLotto.confirm_lottery import ConfirmLottery_lelun from element_operate.baofoo_payment import BaofooPayment_lelun from element_operate.choose_bank import ChooseBank_lelun from element_operate.confirm_pay...
14,244
fa63590e543a5c53c28090a8f8d6cc9d165bee7d
import glob import logging import os import shutil import subprocess import time import pytest import yaml from cekit.descriptor import Image from cekit.errors import CekitError from cekit.generator.docker import DockerGenerator from cekit.tools import Map from tests.utils import merge_dicts try: from unittest.m...
14,245
cbb18c178cd56f7eef3c8f1655e6166ea61b76bf
#!/usr/bin/env python3 # -*- coding: utf-8 -*- """ Core RAMP-UA model. Created on Wed Apr 29 19:59:25 2020 @author: nick """ import sys import os os.environ['R_HOME'] = 'C:/Users/gy17m2a/AppData/Local/Programs/R/R-4.2.0' #path to your R installation os.environ['R_USER'] = 'C:/ProgramData/Anaconda3/envs/analyse_resul...
14,246
2279a901451487517a0d981d22c4bb2ce8c0848f
ways = [] amount = 4 def count_change(change, way): global ways for i in range(len(change)): way_new = way + [change[i]] if sum(way_new) < amount: count_change(change[i:], way_new) elif sum(way_new) == amount: print(way_new) ways.append(way_new)...
14,247
b8947e3517934910d47a1868c217ec08e72991b7
# Copyright (c) 2019, NVIDIA CORPORATION. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to...
14,248
62f329b40d6017552c3655a9ac49709b9c533904
import requests import time import json from django.conf import settings import errno from socket import error as socket_error import logging log = logging.getLogger(__name__) def change_eva(teacher, form, eva): # ++++++++++++++++++ Obtencion de token ++++++++++++++++++++++++++++++ username = form.cleaned_dat...
14,249
6b47dfb436733105f06561eb03809526de760de3
class Solution: def setZeroes(self, matrix: List[List[int]]) -> None: """ Do not return anything, modify matrix in-place instead. """ m, n = len(matrix), len(matrix[0]) firstRow, firstCol = False, False for i in range(m): for j in range(n): ...
14,250
b89137c61c9b500ab5407e81d9d45b00df39ffc4
my_list = [2323,4344,2325,324413,21234,24531,2123,42234,544,456,345,42,5445,23,5656,423] #Your code here: aux = 0 for number in my_list: aux += number aux = aux / len(my_list) print(aux)
14,251
c2d18c772301e2ede1ff7d1af35fdcc7ec121dd9
#!/usr/bin/env python # coding: utf-8 # # Data Visualization: Trump's Winning Rate # This report provides detailed facts about Trump's Winning Rate and its correlation between economics indicators, both at national level and at state level # In[5]: import pandas as pd import datetime import time import matplotlib.p...
14,252
97146cebb2e77a2be542b75ccacc479f04ce8b14
import sys import pathlib try: PATH_HERE = pathlib.Path(__file__).parent PATH_ABFS = PATH_HERE.joinpath("../../data/abfs/").resolve() PATH_SRC = PATH_HERE.joinpath("../../src/").resolve() print(PATH_SRC) sys.path.insert(0, str(PATH_SRC)) import pyabf except: raise EnvironmentError() if __...
14,253
e56f24a4b50d49b40428262d76126f5690454848
from flask import Flask import app
14,254
918e0c66a75126d922e0af4ad1abf1461e42219c
from Gui import * g = Gui() g.title('MyFirst GUI') #g.widget(Button, text="trying", command=None) g.mainloop()
14,255
aeb898ec847b967652e183f13b1cbd36ca08220f
import time from rest_framework import generics from rest_framework import permissions from post.models import Post from post.serializer import PostSerializer from utils.pagination import PostPagination __all__ = ( 'PostList', 'PostDetail', ) class PostList(generics.ListCreateAPIView): queryset = Post.o...
14,256
fa1de198efedb6f134ffbb4c4f838a297108a180
from flask import Flask, render_template from flask_wtf import FlaskForm from wtforms import StringField, PasswordField app = Flask(__name__) app.config['SECRET_KEY'] = 'thisissceret!' class LoginForm(FlaskForm): username = StringField('username') password = PasswordField('password') @app.route('/form', methods=...
14,257
a605fefc1fb9c4cd20799280a71278cf8b2d7702
#!/usr/bin/env python # encoding: utf-8 """ visitortracker.py Created by Jeremiah Shirk on 2012-09-05. Copyright (c) 2012 Monitis. All rights reserved. """ from monitis.api import get, post, MonitisError, validate_kwargs def visitor_tracking_tests(**kwargs): ''' Get a user's visitor trackers ''' required = ...
14,258
1db2f74ebcea3a0863e9b269e05a95db7ff95d0f
# Code by Jaime Eduardo Sttivend Velez # Date:03/24/2019 def queens_attack(n, k, r_q, c_q, obstacles): """ Function to calculate te attack movements possible for a queen located in row r_q column r_c of a n size board with obstacles located on the "obstacles" tuple array. """ queen = (r_q...
14,259
5fb1bebe46e751730bb5efaed950e2a1d6bcee4e
# Generated by Django 2.2.13 on 2020-07-01 17:36 from django.db import migrations, models class Migration(migrations.Migration): dependencies = [ ('indexer', '0002_indexrun_indexrunerror'), ] operations = [ migrations.AlterField( model_name='indexrun', name='obje...
14,260
74e117393b8b2a18f6c21f53e4d0bb3cd4adafec
#!/usr/bin/python # -*- coding: utf-8 -*- """ Problem definition: Write three functions that compute the sum of the numbers in a given list using a for-loop, a while-loop, and recursion. """ import sys def calculate_sum_using_for_loop(numbers): result = 0 for number in numbers: result += number ...
14,261
24576904c878f10e016801455d0fba04f8540b0d
#Prints the whole google page import urllib.request page = urllib.request.urlopen('https://google.com') print(page.read())
14,262
15a92fce6410e392790cdef8ba6009128b752e42
### Author: Roholt ### 10-2020 from ConfigLoader import ConfigLoader from KeyboardWatcher import KeyboardWatcher def main(): settings = ConfigLoader("./config.yml").config keyboardWatcher = KeyboardWatcher() for setting in settings: keyboardWatcher.addShortcut(setting["shortcut"], setting["script"], settin...
14,263
63ecd260dbe8b8709b7004ea67f66f1de40ba836
# Hecho por William, si vas a ver este codigo espero que mi documentacion sea de ayuda :D # Importancion de las librerias from flask import Flask from flask import render_template from flask import request from flask import url_for from flask import redirect from flask import flash from flask import session fr...
14,264
6570b8fbdadbaaa6e2263932d148b53f10073a5c
from graph.Node import Node class Graph: def __init__(self): self.graph = {} self.nodes_no = 0 self.nodes = [] def create(self, sinks): for sink in iter(sinks): self.process_operator(sink) def process_operator(self, operator): self.add_node(operator.ki...
14,265
e80a555c879bddef72373c0d7997a2d144d9fea8
#!/usr/bin/python import sys, re, codecs ''' Created by Raj Nath, 24th Sept 2016 Purpose: Created to get the text from the conll format file Usage: python prep_test_data.py TEXT.conll ''' if len(sys.argv) !=2: print 'Usage: python', sys.argv[0], 'TEXT.conll' exit() fname = sys.argv[1] fin = codecs.open(fname, ...
14,266
5e8854274d51a1566673e9fcb17aa210c7380a30
'''Write a Python program to sum of three given integers. However, if two values are equal sum will be zero''' num1=int(input("enter the number:")) num2=int(input("enter the number")) num3=int(input("enter the number:")) if num1!= num2!=num3: add=num1+num2+num3 print(add) if num1==num2: print("zero"...
14,267
ce8638af48e65d85979c0724bfe3a5604037c452
from aski import двоцифрени def test0(): assert двоцифрени([64, 65, 66]) == '@AB' def test1(): assert двоцифрени(list(range(27, 33))) == '' def test2(): assert двоцифрени([-3, -2, -1]) == '' def test3(): assert двоцифрени([100, 101, 200, 3000]) == '' def test4(): assert двоцифрени(list(ran...
14,268
dc5eea23cb93b2aefc417ab924e6e877f079d78d
from __future__ import absolute_import from __future__ import division from __future__ import print_function import os, sys # sys.path.append("..") import pywt import pywt.data import numpy as np import matplotlib.pyplot as plt import pandas as pd from scipy import signal import tensorflow as tf tf.logging.set_verbos...
14,269
6b34e6869efaee5e1b9acb029df790b9cbd33512
from __future__ import absolute_import, division, print_function import sys from PyQt4 import QtCore, QtGui from widgets.SidebarSkel import Ui_Sidebar from widgets.ImageFormSkel import Ui_ImageForm from widgets.GPSFormSkel import Ui_GPSForm from widgets.GZCQWidgets import QwwColorComboBox from os.path import join, base...
14,270
11ca3b62e8e708798a9ed82a24ccbc910da51228
''' Description: Main program used in train and testing my network Author:Charles Shen Date:8/22/2020 ''' import numpy as np import time import os import argparse import torch import torch.nn as nn import torch.optim as optim from torch.autograd import Variable from models.encoder import Encoder from models.decoder im...
14,271
6ab96bf012ff58aab428551d03e5a1c952d39fb3
import pytest from day10.monitoring_station import parse_asteroid_map, can_detect, count_detectable_asteroids, find_best_station, sort_for_laser_round, shoot from common.io import read @pytest.mark.parametrize("input,expected", [ ("""##. .#. ..#""", [(0, 0), (1, 0), (1, 1), (2, 2)]) ]) def test_pa...
14,272
2e7a6303deeea59b1d3e55c6c46934f89a647da8
""" Основаная идея заключалается в отстреле кораблей противника по одному """ import json from dataclasses import dataclass from enum import Enum from typing import List from random import random # region Primitives @dataclass class Vector: x: int y: int z: int def __add__(self, other): if...
14,273
118a4483ca1cf645d66de85cad611d4b936981a8
# SOFTVEROVY NASTROJ PLGP # Furtkevicova Ludmila, cast diplomovej prace # script: okno s piatimi zalozkami, funkcie, tlacidla, modely # ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ import os import tkMessageBox import Tkinter import ttk from Tkinter import * from ttk import * impor...
14,274
4ca8a4b1e20657503a1055125de23b7b0fd90644
#!/usr/bin/python import subprocess import glob subprocess.check_call(["pdflatex", "-halt-on-error", "-file-line-error", "main.tex"]) if len(glob.glob("*.bib"))>0: subprocess.check_call(["bibtex", "main"]) subprocess.check_call(["pdflatex", "-halt-on-error", "-file-line-error", "main.tex"]) subprocess.check_call(["...
14,275
51ed93bb791fa5bdc51f90c91564870adde027e3
""""" for c in "Bruno gostoso": # for com string print (c) """ """" range(0, 10, 1) # (start, stop, step) x = list(range(0, 10, 1)) # Função range retorna em range, por isso converti em list print(x) # range é parecido com Progressão Aritmética """ """" for i in range(10, 100, 5):...
14,276
95da2d9fcd3c09c343d7f23886bb2f5f45075f2f
from django.contrib import admin from django.utils.html import format_html # Register your models here. from .models import Question class QuestionsAdmin(admin.ModelAdmin): """ Set up question and answer in back end admin page """ list_display=["Question","Answer","dateAsked", "Question_Status"] se...
14,277
d4c0bb0a03c58a52d4a0c6caa7e20833927adc41
# # Copyright 2021 Ocean Protocol Foundation # SPDX-License-Identifier: Apache-2.0 # from ocean_lib.web3_internal.currency import to_wei from ocean_lib.web3_internal.event_filter import EventFilter def test_transfer_event_filter(alice_ocean, alice_wallet, alice_address, bob_address): token = alice_ocean.create_d...
14,278
f3ee082ab616718afa315b127fdc490da4724ed6
#!/usr/bin/python3 ''' [-2, -1, 0, 5, 10] [0, 1, 4, 25, 100] ''' def sortedSquareArray(array): squared_array = [0 for _ in array] smallerValueIdx = 0 greaterValueIdx = len(array) - 1 for idx in reversed(range(len(array))): smallerValue = array[smallerValueIdx] greaterValue = a...
14,279
971e6c4637f37cb6cf49ecaf1f54deed70e073a9
from . import utils from . import energy from . import seamops from . import warnings from . import advanced
14,280
5ae54564ce4d7e3930990c687a92499e66dcee41
def input_tuple_lc(prompt, types, sep): answer_str = input(prompt) new_list = answer_str.split(sep) new_tuple = () if len(new_list) != len(types): print("Number of values inputted do not match number of values intended") return () i = 0 if len(new_list) == len(types): whi...
14,281
cc16b73f8150786547f479358ffcf21b1baf6b10
# Copyright 2011-2014 Isotoma Limited # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in wr...
14,282
a72fc3f7d5476e7e9ab95d38a5b93dd8f32a0b28
# ############################################################################# # array.py # ======== # Author : Sepand KASHANI [kashani.sepand@gmail.com] # ############################################################################# """ Tools and utilities for manipulating arrays. """ def index(x, axis, index_spec...
14,283
d7f5dbd116e2d4ce77bdfa129ba37e7e8a60959f
from listeners import *
14,284
f1826e55bbc34039e2c0d9e39b980aac4517404d
# -*- coding: utf-8 -*- # Generated by Django 1.9.7 on 2016-09-09 20:43 from __future__ import unicode_literals from django.db import migrations, models import django.db.models.deletion import django.db.models.manager class Migration(migrations.Migration): initial = True dependencies = [ ('contentt...
14,285
0bff24da254eaac4d00b66366e57d9222d730130
# 172. Factorial Trailing Zeroes class Solution(object): def trailingZeroes(self, n): """ :type n: int :rtype: int """ ans = 1 while n > 1: ans, n = ans*n, n-1 count = 0 for ch in str(ans)[::-1]: if ch == "0": co...
14,286
163444d45931432915959c4b7a1d92ac4f34c58e
def findLoop(n,m,arr): for i in range(n): x = arr[i] for j in range(m): if arr[i+j] != x: break
14,287
10735cce6ba21ac14d6000da1b139a7509c58ae8
from . import report_shopping_book from . import report_sales_book
14,288
f109a6e910faa71376aca52f07c310b089ffa4cc
import pandas as pd import plotly.express as px import numpy as np import csv def getDataSource(data_path): Days=[] Marks=[] with open(data_path) as csv_file: csv_reader=csv.DictReader(csv_file) for row in csv_reader: Days.append(float(row["Marks In Percentage"])) ...
14,289
c15e41d84389e2838c78157fd336062d3696d023
''' Description: ----------- Generates traces for comparing declarative and procedural Synoptic algorithms. Generates 100 log files, ranging over event types from an alphabet of 8 events, each log contains 24 event instances. $ python gen_traces.py ''' import sys import os import random import sys def clear_dir(di...
14,290
6c6e3ac5255ec5f69a10f7ba0b3d954ad39dd274
from django.shortcuts import render from .models import Clothes, Shoes, Watch, Cap # Create your views here. def index(request): clothes = Clothes.objects.all() shoes = Shoes.objects.all() watch = Watch.objects.all() cap = Cap.objects.all() return render(request, 'tezcoder/index.html', {'clot...
14,291
88a0450305c6dcba8d9f1d933e28cc83227b7b5d
# # Copyright (C) 2020 IBM. All Rights Reserved. # # See LICENSE.txt file in the root directory # of this source tree for licensing information. # from test_integration.contract_skills import ContractSkills class TestSkillFixit(ContractSkills): def get_skill_name(self): return 'fixit' def get_comma...
14,292
645d66fe3db85b131afd1b77312f2709bbcbed39
import pandas as pd import os from sqlalchemy import create_engine def main(): engine = create_engine('postgresql://postgres:postgres@localhost:5432/molecular_prediction') query = ''' SELECT magnetic_sheilding_tensors.* , structures.atom , structures.x , structures.y ...
14,293
c45a45adbb7f34f008480bddc894d3efd2f54649
# Generated by Django 3.1.3 on 2020-11-14 06:08 from django.db import migrations class Migration(migrations.Migration): dependencies = [ ('visitas', '0003_auto_20201114_0005'), ] operations = [ migrations.RenameModel( old_name='visita', new_name='RegistrarVisita'...
14,294
9579a34b89cd94aafb3ccd6285a5061e2d2e0599
import io import os import shutil import zipfile import re import unicodedata from PIL import Image MAX_FILESIZE = 20 * 1024 ** 3 # 20MB def set_dir(filepath): """ Create a folder if the given path does not exist. Otherwise remove and recreate the folder. :param filepath: path :return: """ ...
14,295
0bd869b078824465d917f71e4f5e75ed36cde85c
# -*- coding: utf-8 -*- from __future__ import unicode_literals from django.db import models, migrations class Migration(migrations.Migration): dependencies = [ ] operations = [ migrations.CreateModel( name='DjangoAdminLog', fields=[ ('id', models.AutoFie...
14,296
bcd03881a30a88ad5423446e8b2b803cb5e71a96
''' ABCCDEABAA ABCDE ''' t, s = input(), input() for i in range(len(s)): print() for j in range(len(s)): print(s[(i + j) % len(s)])
14,297
bfe75dc32398b320767822176eb6e806d0b9a63f
import paho.mqtt.client as mqtt import time import ssl import json from sense_hat import SenseHat sense = SenseHat() from cpu_temp import CPUTemp cput = CPUTemp() cput.__init__() cput.open() host = "node02.myqtthub.com" port = 1883 clean_session = True client_id = "set client id from client.js...
14,298
2bf9f845e953f7a44150b978a1394d3dbedd585d
n = int(input()) r = n // 100 l = n % 100 if r <= 12 and 1 <= r: if l <= 12 and 1 <= l: print("AMBIGUOUS") else: print("MMYY") else: if l <= 12 and 1 <= l: print("YYMM") else: print("NA")
14,299
010839e0fd81c437ce130c4b86f2ece358ec207f
from fastai.text import * import sklearn.feature_extraction.text as sklearn_text import pickle from sklearn.linear_model import LogisticRegression, LinearRegression from sklearn.feature_extraction.text import CountVectorizer from dataclasses import asdict, dataclass, field, fields from sklearn.metrics import mean_squar...