content
stringlengths
1
1.05M
input_ids
listlengths
1
883k
ratio_char_token
float64
1
22.9
token_count
int64
1
883k
from resources import Resources import configparser
[ 6738, 4133, 1330, 13864, 198, 11748, 4566, 48610, 198 ]
5.777778
9
""" Program displays a window with text using Tkinter when run. """ import tkinter import webbrowser from tkinter import font from tkinter import ttk
[ 37811, 198, 15167, 11298, 257, 4324, 351, 2420, 1262, 309, 74, 3849, 618, 1057, 13, 198, 37811, 198, 11748, 256, 74, 3849, 198, 11748, 3992, 40259, 198, 6738, 256, 74, 3849, 1330, 10369, 198, 6738, 256, 74, 3849, 1330, 256, 30488, 628...
3.595238
42
# -*- coding: utf-8 -*- import os import configparser import glob import sqlite3 import traceback import json from bottle import route, run, auth_basic, abort, response from sqlite3 import OperationalError config = configparser.ConfigParser() config.read('config/config.ini') def WEBRUN(): run(port=7878)
[ 2, 532, 9, 12, 19617, 25, 3384, 69, 12, 23, 532, 9, 12, 198, 198, 11748, 28686, 198, 11748, 4566, 48610, 198, 11748, 15095, 198, 11748, 44161, 578, 18, 198, 11748, 12854, 1891, 198, 11748, 33918, 198, 6738, 9294, 1330, 6339, 11, 105...
3.12
100
# coding: utf8 """ Complete collection of stopwords for the Urdu language. Maintainer: Ikram Ali(mrikram1989@gmail.com) version = 2019.04.07 Source = https://github.com/urduhack/urdu-stopwords """ # Urdu Language Stop words list STOP_WORDS = frozenset(""" """.split())
[ 2, 19617, 25, 3384, 69, 23, 198, 37811, 198, 20988, 4947, 286, 2245, 10879, 329, 262, 8799, 646, 3303, 13, 198, 44, 2913, 10613, 25, 32840, 859, 12104, 7, 76, 12602, 859, 25475, 31, 14816, 13, 785, 8, 198, 9641, 796, 13130, 13, 30...
1.419811
424
import numpy as np from progressbar import progressbar
[ 11748, 299, 32152, 355, 45941, 198, 6738, 4371, 5657, 1330, 4371, 5657, 198 ]
4.230769
13
from django.http import HttpResponseRedirect from django.views import View from ..core import app_settings
[ 6738, 42625, 14208, 13, 4023, 1330, 367, 29281, 31077, 7738, 1060, 198, 6738, 42625, 14208, 13, 33571, 1330, 3582, 198, 198, 6738, 11485, 7295, 1330, 598, 62, 33692, 628, 628 ]
3.7
30
"""The tests for multimatic integration.""" from __future__ import annotations import datetime from typing import Any from unittest.mock import AsyncMock, patch from pymultimatic.model import ( ActiveFunction, BoilerStatus, Circulation, Device, Dhw, EmfReport, Error, FacilityDetail, HolidayMode, HotWater, HvacStatus, OperatingModes, Report, Room, SettingModes, TimePeriodSetting, TimeProgram, TimeProgramDay, Ventilation, Zone, ZoneHeating, ) from pymultimatic.systemmanager import SystemManager from homeassistant import config_entries from homeassistant.components.multimatic import COORDINATORS, DOMAIN from homeassistant.const import CONF_PASSWORD, CONF_USERNAME from homeassistant.util import utcnow from tests.common import async_fire_time_changed VALID_MINIMAL_CONFIG = {CONF_USERNAME: "test", CONF_PASSWORD: "test"} def zones(with_rb=True): """Get zones.""" zones = [] heating = ZoneHeating( time_program=time_program(SettingModes.NIGHT, None), operating_mode=OperatingModes.AUTO, target_low=22, target_high=30, ) zones.append( Zone( id="zone_1", name="Zone 1", temperature=25, active_function=ActiveFunction.HEATING, rbr=False, heating=heating, ) ) if with_rb: zones.append( Zone( id="zone_2", name="Zone rbr", temperature=25, active_function=ActiveFunction.HEATING, rbr=True, heating=heating, ) ) return zones def rooms(): """Get rooms.""" room_device = Device("Device 1", "123456789", "VALVE", False, False) return [ Room( id="1", name="Room 1", time_program=time_program(), temperature=22, target_high=24, operating_mode=OperatingModes.AUTO, child_lock=False, window_open=False, devices=[room_device], ) ] def dhw(): """Get dhw.""" hot_water = HotWater( id="dhw", name="Hot water", time_program=time_program(temp=None), temperature=None, target_high=40, operating_mode=OperatingModes.AUTO, ) circulation = Circulation( id="dhw", name="Circulation", time_program=time_program(temp=None), operating_mode=OperatingModes.AUTO, ) return Dhw(hotwater=hot_water, circulation=circulation) def report(): """Get report.""" return Report( device_name="VRC700 MultiMatic", device_id="Control_SYS_MultiMatic", unit="bar", value=1.9, name="Water pressure", id="WaterPressureSensor", ) def report_dhw(): """Get report for dhw.""" return Report( device_name="Control_DHW", device_id="DomesticHotWaterTankTemperature", unit="C", value=45, name="DomesticHotWaterTankTemperature", id="DomesticHotWaterTankTemperature", ) def reports(): """Get reports.""" return [report()] def ventilation(): """Return ventilation.""" return Ventilation( time_program=time_program(SettingModes.ON, 6), operating_mode=OperatingModes.AUTO, target_high=6, target_low=2, id="ventilation", name="Ventilation", ) def active_holiday_mode(): """Return a active holiday mode.""" start = datetime.date.today() - datetime.timedelta(days=1) end = datetime.date.today() + datetime.timedelta(days=1) return HolidayMode(True, start, end, 15) def time_program(heating_mode=SettingModes.OFF, temp=20): """Create a default time program.""" tp_day_setting = TimePeriodSetting("00:00", temp, heating_mode) tp_day = TimeProgramDay([tp_day_setting]) tp_days = { "monday": tp_day, "tuesday": tp_day, "wednesday": tp_day, "thursday": tp_day, "friday": tp_day, "saturday": tp_day, "sunday": tp_day, } return TimeProgram(tp_days) def facility_detail(): """Get facility detail.""" return FacilityDetail( name="Home", serial_number="12345", firmware_version="1.2.3", ethernet_mac="01:23:45:67:89:AB", wifi_mac="23:45:67:89:0A:BC", ) def hvac_status(with_error=False, with_status=True): """Get hvac status.""" boiler_status = None if with_status: boiler_status = BoilerStatus( device_name="boiler", title="Status", status_code="1", description="This is the status", timestamp=datetime.datetime.now(), hint="Do nothing", ) errors = None if with_error: errors = [ Error( device_name="Device", title="Status", status_code="99", description="This is the error", timestamp=datetime.datetime.now(), ) ] return HvacStatus( boiler_status=boiler_status, errors=errors, online="ONLINE", update="UPDATE_NOT_PENDING", ) def emf_reports(): """Get emf reports.""" return [ EmfReport( "flexoTHERM_PR_EBUS", "VWF 117/4", "HEAT_PUMP", "COOLING", "CONSUMED_ELECTRICAL_POWER", 1000, datetime.date(2021, 1, 1), datetime.date(2021, 1, 10), ) ] def assert_entities_count(hass, count): """Count entities owned by the component.""" assert len(hass.states.async_entity_ids()) == count
[ 37811, 464, 5254, 329, 43104, 1512, 11812, 526, 15931, 198, 6738, 11593, 37443, 834, 1330, 37647, 198, 198, 11748, 4818, 8079, 198, 6738, 19720, 1330, 4377, 198, 6738, 555, 715, 395, 13, 76, 735, 1330, 1081, 13361, 44, 735, 11, 8529, ...
2.08594
2,781
# # mod-h2 test suite # check handling of invalid chars in headers # import copy import os import re import sys import time import pytest from datetime import datetime from TestEnv import TestEnv from TestHttpdConf import HttpdConf
[ 2, 198, 2, 953, 12, 71, 17, 1332, 18389, 198, 2, 2198, 9041, 286, 12515, 34534, 287, 24697, 198, 2, 198, 198, 11748, 4866, 198, 11748, 28686, 198, 11748, 302, 198, 11748, 25064, 198, 11748, 640, 198, 11748, 12972, 9288, 198, 198, 67...
3.405797
69
from scenarios import helper from scenarios.builder import Builder from model.enumerations import e_ExperienceFactor, e_MentalOrEmotionalFactor, e_PhyOrPhyFactor, e_EntityType, e_Relation, e_CausalFactorType from model.knowledge_base import kb from model.entities import Entity, CausalFactor from model.utils import BoundingBox from model import rule
[ 6738, 13858, 1330, 31904, 198, 6738, 13858, 13, 38272, 1330, 35869, 198, 6738, 2746, 13, 268, 6975, 602, 1330, 304, 62, 44901, 41384, 11, 304, 62, 44, 2470, 5574, 10161, 25453, 41384, 11, 304, 62, 2725, 88, 5574, 2725, 88, 41384, 11, ...
3.715789
95
""" The :mod:`stan.data_lex` module is the lexer for SAS-like language. """ from pyparsing import * from stan.data.data_expr import EXPR_, ID_, DATA, SET, RENAME, RUN, DROP, KEEP, SEMI_, LOGICAL_ # set up logic dataStepStmt = Forward() # data/set inline options rename_stmt = (OneOrMore(Group(ID_ + Suppress("=") + ID_ ))).setResultsName('rename') drop_stmt = OneOrMore( ID_ ).setResultsName('drop') keep_stmt = OneOrMore( ID_ ).setResultsName('keep') dataset_opt_stmt = Optional("("+ Optional(Suppress(RENAME) + "=" + "(" + rename_stmt + ")") + Optional(Suppress(DROP) + "=" + drop_stmt) + Optional(Suppress(KEEP) + "=" + keep_stmt) +")") # data step options (not inline) opt_stmt = ( (Suppress(RENAME) + rename_stmt + SEMI_) | (Suppress(KEEP) + keep_stmt + SEMI_) | (Suppress(DROP) + drop_stmt + SEMI_) #add by statement ) # data step logic s_stmt = Group(ID_ + Suppress("=") + ( LOGICAL_.setResultsName('logical') | EXPR_ ) + SEMI_) # data set statements data_stmt = Group(Suppress(DATA) + ID_.setResultsName('name') + dataset_opt_stmt.setResultsName('data opt')).setResultsName('data') + SEMI_ set_stmt = Group(Suppress(SET) + ID_.setResultsName('name') + dataset_opt_stmt.setResultsName('set opt')).setResultsName('set') + SEMI_ dataStepStmt << (data_stmt + set_stmt + (ZeroOrMore(opt_stmt) & ZeroOrMore(s_stmt).setResultsName('stmt')) + RUN + SEMI_)
[ 37811, 198, 464, 1058, 4666, 25, 63, 14192, 13, 7890, 62, 2588, 63, 8265, 318, 262, 31191, 263, 329, 35516, 12, 2339, 3303, 13, 198, 37811, 198, 198, 6738, 279, 4464, 945, 278, 1330, 1635, 198, 6738, 336, 272, 13, 7890, 13, 7890, ...
2.161379
725
import os from platform import system from setuptools import setup from subprocess import run, PIPE, CalledProcessError running_on_windows = system() == "Windows" running_in_docker = os.path.isfile("/.dockerenv") # Consistent version as AUR try: count = run(["git", "rev-list", "--count", "HEAD"], stdout=PIPE, check=True).stdout.splitlines()[0].decode('utf-8') commit = run(["git", "rev-parse", "--short", "HEAD"], stdout=PIPE, check=True).stdout.splitlines()[0].decode('utf-8') VERSION = "%s.%s" % (count, commit) except CalledProcessError: print("Could not determine package version with Git! Exiting...") raise # Additional files for *nix: completion, man page, etc. share_files = [ ('/usr/share/man/man1', ['man/neopo.1']), ('/usr/share/licenses/neopo', ['LICENSE']), ('/usr/share/neopo/scripts', ['scripts/POSTINSTALL']), ('/usr/share/bash-completion/completions', ['completion/neopo']) ] # Skip share_files on Windows, docker, or when installing as non-root if running_on_windows or running_in_docker or os.geteuid() != 0: share_files=None # Provide neopo, neopo-script, and particle commands script_unix = ['scripts/unix/neopo', 'scripts/unix/neopo-script', 'scripts/unix/particle'] script_windows = ['scripts/windows/neopo.cmd', 'scripts/windows/neopo-script.cmd', 'scripts/windows/particle.cmd'] script_files = script_windows if running_on_windows else script_unix # update version.py with open(os.path.join('neopo', 'version.py'), 'w') as file: file.writelines(['NEOPO_VERSION="%s"' % VERSION]) setup( name='neopo', version=VERSION, description='A lightweight solution for local Particle development.', long_description=""" Neopo is a Particle development management utility that simplifies the installation and usage of Particle's toolchains on a variety of distributions. It features options to build or flash projects, iterable commands, a scripting interface, and Particle Workbench/CLI compatibility.""", author='Nathan Robinson', author_email='nrobinson2000@me.com', url="https://neopo.xyz", download_url='https://github.com/nrobinson2000/neopo', license="MIT", packages=['neopo'], platforms=["Linux", "macOS", "Windows", "ARM"], data_files=share_files, scripts=script_files )
[ 11748, 28686, 198, 6738, 3859, 1330, 1080, 198, 6738, 900, 37623, 10141, 1330, 9058, 198, 6738, 850, 14681, 1330, 1057, 11, 350, 4061, 36, 11, 34099, 18709, 12331, 198, 198, 20270, 62, 261, 62, 28457, 796, 1080, 3419, 6624, 366, 11209, ...
2.798561
834
from abc import ABCMeta, abstractmethod from typing import TypeVar, Generic, List S = TypeVar('S') R = TypeVar('R') """ .. module:: Operator :platform: Unix, Windows :synopsis: Templates for operators. .. moduleauthor:: Antonio J. Nebro <antonio@lcc.uma.es> """
[ 6738, 450, 66, 1330, 9738, 48526, 11, 12531, 24396, 198, 6738, 19720, 1330, 5994, 19852, 11, 42044, 11, 7343, 198, 198, 50, 796, 5994, 19852, 10786, 50, 11537, 198, 49, 796, 5994, 19852, 10786, 49, 11537, 198, 198, 37811, 198, 492, 82...
2.98913
92
from PIL import Image, ImageDraw, ImageFont from numpy import asarray from cv2 import cvtColor, COLOR_RGB2BGR, imshow, waitKey from os import getcwd
[ 6738, 350, 4146, 1330, 7412, 11, 7412, 25302, 11, 7412, 23252, 198, 6738, 299, 32152, 1330, 355, 18747, 198, 6738, 269, 85, 17, 1330, 269, 36540, 10258, 11, 20444, 1581, 62, 36982, 17, 33, 10761, 11, 545, 12860, 11, 4043, 9218, 198, ...
3.083333
48
#!/usr/bin/env python # -*- coding: utf-8 -*- import argparse from Bio import AlignIO def concat_msa(msas, output): """concatenate msas together""" alignments = [] for msa in msas: align = AlignIO.read(msa, "fasta") # shorten id so the concatenated alignment keeps it for record in align._records: record.id = record.id.split("|")[0] if len(align._records) == 3: alignments.append(align) concatenated_alignment = alignments[0] for alignment in alignments[1:]: concatenated_alignment += alignment with open(output, "w") as outfile: AlignIO.write(concatenated_alignment, outfile, "fasta") if __name__ == "__main__": main()
[ 2, 48443, 14629, 14, 8800, 14, 24330, 21015, 198, 2, 532, 9, 12, 19617, 25, 3384, 69, 12, 23, 532, 9, 12, 198, 198, 11748, 1822, 29572, 198, 198, 6738, 16024, 1330, 978, 570, 9399, 628, 198, 4299, 1673, 265, 62, 907, 64, 7, 907,...
2.250755
331
from selenium import webdriver from selenium.webdriver.chrome.options import Options from selenium.webdriver.support.wait import WebDriverWait from selenium.webdriver.common.action_chains import ActionChains from selenium.webdriver.support import expected_conditions as EC from selenium.webdriver.common.keys import Keys from selenium.webdriver.common.by import By from webdriver_manager.chrome import ChromeDriverManager from os import path import re import json import time import datetime import xlsxwriter print("Start: " + str(datetime.datetime.now())) options = Options() prefs = {"profile.managed_default_content_settings.images": 2} options.add_experimental_option('prefs', prefs) driver = webdriver.Chrome(executable_path=ChromeDriverManager().install(), options=options) # driver = webdriver.Chrome(options=options) driver.maximize_window() driver.implicitly_wait(0.5) url_brands = "https://www.rendez-vous.ru/catalog/brands/" brands = [ "Aldo Brue", "AGL", "BANU", "Bally", 'Bresciani', 'Brimarts', 'Carlo Visintini', 'Casadei', 'Casheart,', 'Cerruti 1881', 'Cesare Casadei', 'Coccinelle', 'DKNY', 'Doria Maria', 'Doucal\'s', 'F_WD', 'Fabi', 'Fabrizio Lesi', 'Ferre Milano', 'Flower Mountain', 'Franceschetti', 'Frasconi', 'Fratelli Rossetti', 'Fratelli Rossetti One', 'Gianni Chiarini', 'Goose Tech', 'GUM', 'HIDE&JACK', 'Ice Play', 'Iceberg', 'In The Box', 'Inuikii', 'John Galliano', 'John Richmond', 'Kalliste', 'Kat Maconie', 'Kate Spade', 'Lancaster', 'Landi', 'Le Silla', 'Lemon Jelly', "L'Impermeabile", 'Marsell', 'Merola Gloves', 'Moose Knuckles', 'Moreschi', 'Moschino', 'Panchic', 'Pantanetti', 'Parajumpers', 'Pasotti', 'Pertini', 'Pierre Cardin', 'Pollini', 'Portolano', 'Premiata', 'Principe Di Bologna', 'RBRSL', "Reptile's House", 'Roberto Cavalli', 'Rocco P', 'Sergio Rossi', 'SPRAYGROUND', 'Stemar', 'Stuart Weitzman', 'V SEASON', "VIC MATIE'", "Vic Matie", 'Voile Blanche', 'What For', 'Wolford', '3JUIN', 'Premiata will be', 'Sprayground', 'Domrebel', 'GIUSEPPE ZANOTTI DESIGN', 'Giuseppe Zanotti Design', 'GIUSEPPE ZANOTTI', 'Giuseppe Zanotti' ] search_values = ['Wolford', 'RBRSL', "Rocco P", "DKNY", 'Flower Mountain', 'HIDE&JACK', 'Inuikii', 'Lancaster'] categories = [ "", '', "" ] iframe_ids = ['fl-545545'] show = "//li[@class='next']/a" pagination_class_selected = 'page selected' last_page = '//ul[@id="pagination_bottom"]/li[@class="last"]' search_btn = '//*[@id="search-toggle"]' search_bar = '//*[@id="Search_q"]' failed_pages = {'pages': []} output = xlsxwriter.Workbook('C:\\Users\\admin\\Documents\\outputs\\Rendez-vous {}.xlsx'.format(str(datetime.date.today()))) sheet = output.add_worksheet('Rendez-vous') sheet.write('A1', '') sheet.write('B1', '') sheet.write('C1', ' ') sheet.write('D1', '') sheet.write('E1', '') sheet.write('F1', ' ') sheet.write('G1', '') tables = {} count = 0 row = 2 closed = False scrolled = False if __name__ == '__main__': run()
[ 6738, 384, 11925, 1505, 1330, 3992, 26230, 198, 6738, 384, 11925, 1505, 13, 12384, 26230, 13, 46659, 13, 25811, 1330, 18634, 198, 6738, 384, 11925, 1505, 13, 12384, 26230, 13, 11284, 13, 17077, 1330, 5313, 32103, 21321, 198, 6738, 384, ...
2.587879
1,155
import getpass # prompt user without echoing output print getpass.getpass() print getpass.getpass(prompt="Custom Prompt:") print "user login name:", getpass.getuser()
[ 11748, 651, 6603, 198, 198, 2, 6152, 2836, 1231, 39915, 5072, 198, 198, 4798, 651, 6603, 13, 1136, 6603, 3419, 198, 198, 4798, 651, 6603, 13, 1136, 6603, 7, 16963, 457, 2625, 15022, 45965, 25, 4943, 198, 198, 4798, 366, 7220, 17594, ...
3.288462
52
# Generated by Django 2.2 on 2019-04-03 08:12 from django.db import migrations, models
[ 2, 2980, 515, 416, 37770, 362, 13, 17, 319, 13130, 12, 3023, 12, 3070, 8487, 25, 1065, 198, 198, 6738, 42625, 14208, 13, 9945, 1330, 15720, 602, 11, 4981, 628 ]
2.966667
30
import re from django.db import models unacceptable_chars = "[^a-z0-9\._]" duplicate_spaces_and_dots = "[\ .]+" def sanitize_short_code(input): """ We want to filter-out the undesirable characters. """ # Turn spaces and dots into single dots new_code = re.sub(duplicate_spaces_and_dots, '.', input.strip().lower()) # Filter out everything bad new_code = replace_common_words(re.sub(unacceptable_chars, '', new_code)) # Duplicates once more return re.sub(duplicate_spaces_and_dots, '.', new_code)
[ 11748, 302, 198, 6738, 42625, 14208, 13, 9945, 1330, 4981, 198, 198, 403, 16037, 62, 354, 945, 796, 12878, 61, 64, 12, 89, 15, 12, 24, 59, 13557, 30866, 198, 646, 489, 5344, 62, 2777, 2114, 62, 392, 62, 67, 1747, 796, 12878, 59, ...
2.589372
207
def som(a, b): """Bereken de som van twee getallen. Als de som groter is dan nul return je de som. Als de som kleiner is dan nul, dan return je nul. Args: a (int): het eerste getal b (int): het tweede getal """ pass assert som(1, 2) == 3 assert som(-1, -2) == -3 assert som(0, 0) == 0
[ 4299, 3870, 7, 64, 11, 275, 2599, 198, 220, 220, 220, 37227, 33, 567, 3464, 390, 3870, 5719, 665, 1453, 651, 439, 268, 13, 978, 82, 390, 3870, 7128, 353, 318, 46078, 299, 377, 1441, 11223, 390, 3870, 13, 198, 220, 220, 220, 220, ...
2.143791
153
# python3 # coding=utf-8 # Copyright 2020 Google LLC. # # 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 writing, software # distributed under the License is distributed on an "AS IS" BASIS, # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. # python3 """A Blob class for data-in representation. The Blob class contains all JSON events and all necessary metadata to the operators. """ from typing import Any, Dict, List, Optional, Tuple
[ 2, 21015, 18, 198, 2, 19617, 28, 40477, 12, 23, 198, 2, 15069, 12131, 3012, 11419, 13, 198, 2, 198, 2, 49962, 739, 262, 24843, 13789, 11, 10628, 362, 13, 15, 357, 1169, 366, 34156, 15341, 198, 2, 345, 743, 407, 779, 428, 2393, 2...
3.703704
216
# coding=utf-8 # date: 2019/1/1, 19:38 # name: smz import numpy as np import tensorflow as tf import matplotlib.pyplot as plt from sklearn.utils import shuffle from LinearModel.modules.model3 import ModelThreeClasses from LinearModel.configuration.options import opts from LinearModel.scripts.gen_data import generate_data def train_3_classes(): """softmaxsigmoid,""" model3 = ModelThreeClasses(opts) model3.build() train_x3 = np.load("../data/train_data_X3.npy") train_y3 = np.load("../data/train_data_Y3.npy") model_name = "model3s.ckpt" num_samples = len(train_x3) with tf.Session() as sess: init = tf.global_variables_initializer() sess.run(init) for epoch in range(opts["epochs"]): start_pointer = 0 train_x, train_y = shuffle(train_x3, train_y3) while start_pointer < num_samples: end_pointer = start_pointer + opts["batch_size"] batch_x = train_x[start_pointer:end_pointer] batch_y = train_y[start_pointer:end_pointer] start_pointer = end_pointer feed_dict = {model3.inputs: batch_x, model3.labels: batch_y} loss_value, glob_step_value, merge_str, _ = sess.run( fetches=[model3.loss, model3.global_step, model3.merge_op,model3.train_step], feed_dict=feed_dict) model3.writer.add_summary(merge_str, global_step=glob_step_value) print("epoch:%d, step:%d, loss:%.6f"%(epoch, glob_step_value, loss_value)) if (epoch + 1) % 10 == 0: model3.saver.save(sess, opts["checkpoints_dir"] + model_name, global_step=model3.global_step) if __name__ == "__main__": # gen_train_data() train_3_classes()
[ 2, 19617, 28, 40477, 12, 23, 198, 2, 3128, 25, 13130, 14, 16, 14, 16, 11, 678, 25, 2548, 198, 2, 1438, 25, 895, 89, 198, 198, 11748, 299, 32152, 355, 45941, 198, 11748, 11192, 273, 11125, 355, 48700, 198, 11748, 2603, 29487, 8019,...
2.140143
842
import logging import pytest from traceback import extract_tb, print_exception, format_exception, _cause_message import sys import os import re from pathlib import Path import subprocess from .tutil import slow from .._multierror import MultiError, concat_tb from ..._core import open_nursery def raiser1(): raiser1_2() def raiser1_2(): raiser1_3() def raiser1_3(): raise ValueError("raiser1_string") def raiser2(): raiser2_2() def raiser2_2(): raise KeyError("raiser2_string") def raiser3(): raise NameError def get_exc(raiser): try: raiser() except Exception as exc: return exc def get_tb(raiser): return get_exc(raiser).__traceback__ # This warning is triggered by ipython 7.5.0 on python 3.8 import warnings warnings.filterwarnings( "ignore", message=".*\"@coroutine\" decorator is deprecated", category=DeprecationWarning, module="IPython.*" ) try: import IPython except ImportError: # pragma: no cover have_ipython = False else: have_ipython = True need_ipython = pytest.mark.skipif(not have_ipython, reason="need IPython")
[ 11748, 18931, 198, 11748, 12972, 9288, 198, 198, 6738, 12854, 1891, 1330, 7925, 62, 83, 65, 11, 3601, 62, 1069, 4516, 11, 5794, 62, 1069, 4516, 11, 4808, 25587, 62, 20500, 198, 11748, 25064, 198, 11748, 28686, 198, 11748, 302, 198, 67...
2.65367
436
# Copyright 2016 The Chromium OS Authors. All rights reserved. # Use of this source code is governed by a BSD-style license that can be # found in the LICENSE file. """Driver for gpio controls through ec3po. Provides the following console controlled function: _Get_single, _Set_single, _Get_multi, _Set_multi """ import logging import pty_driver import servo # EC console mask for enabling only command channel COMMAND_CHANNEL_MASK = 0x1 # servod numeric translation for GPIO state. GPIO_STATE = { 0: '0', 1: '1', 2: 'IN', 3: 'A', 4: 'ALT' }
[ 2, 15069, 1584, 383, 18255, 1505, 7294, 46665, 13, 1439, 2489, 10395, 13, 198, 2, 5765, 286, 428, 2723, 2438, 318, 21825, 416, 257, 347, 10305, 12, 7635, 5964, 326, 460, 307, 198, 2, 1043, 287, 262, 38559, 24290, 2393, 13, 198, 3781...
3.054348
184
""" Adapted from https://github.com/bytefish/facerec """ import os from PIL import Image import numpy as np import random def asRowMatrix(X): """ Creates a row-matrix from multi-dimensional data items in list l. X [list] List with multi-dimensional data. """ if len(X) == 0: return np.array([]) total = 1 for i in range(0, np.ndim(X[0])): total = total * X[0].shape[i] mat = np.empty([0, total], dtype=X[0].dtype) for row in X: mat = np.append(mat, row.reshape(1, -1), axis=0) # same as vstack return np.asmatrix(mat) def asColumnMatrix(X): """ Creates a column-matrix from multi-dimensional data items in list X. X [list] List with multi-dimensional data. """ if len(X) == 0: return np.array([]) total = 1 for i in range(0, np.ndim(X[0])): total = total * X[0].shape[i] mat = np.empty([total, 0], dtype=X[0].dtype) for col in X: mat = np.append(mat, col.reshape(-1, 1), axis=1) # same as hstack return np.asmatrix(mat) def minmax_normalize(X, low, high, minX=None, maxX=None, dtype=np.float): """ min-max normalize a given matrix to given range [low,high]. Args: X [rows x columns] input data low [numeric] lower bound high [numeric] upper bound """ if minX is None: minX = np.min(X) if maxX is None: maxX = np.max(X) minX = float(minX) maxX = float(maxX) # Normalize to [0...1]. X = X - minX X = X / (maxX - minX) # Scale to [low...high]. X = X * (high - low) X = X + low return np.asarray(X, dtype=dtype) def shuffle_array(X, y): """ Shuffles two arrays! """ idx = np.argsort([random.random() for i in xrange(len(y))]) X = [X[i] for i in idx] y = [y[i] for i in idx] return X, y def to_col_vec(row_vec): """ :param row_vec: 1d np array :return: """ return row_vec[:, np.newaxis] def to_row_vec(col_vec): """ :param col_vec: 2d np array :return: """ return col_vec.reshape(1, -1)
[ 37811, 198, 48003, 276, 422, 3740, 1378, 12567, 13, 785, 14, 26327, 11084, 14, 2550, 8344, 198, 37811, 198, 11748, 28686, 198, 6738, 350, 4146, 1330, 7412, 198, 11748, 299, 32152, 355, 45941, 198, 11748, 4738, 628, 198, 198, 4299, 355, ...
2.16444
973
from django.apps import AppConfig
[ 6738, 42625, 14208, 13, 18211, 1330, 2034, 16934, 628 ]
3.888889
9
########################################################################## # Copyright (c) 2009, ETH Zurich. # All rights reserved. # # This file is distributed under the terms in the attached LICENSE file. # If you do not find this file, copies can be found by writing to: # ETH Zurich D-INFK, Universitaetstrasse 6, CH-8092 Zurich. Attn: Systems Group. ########################################################################## import re import tests from common import TestCommon from results import PassFailResult
[ 29113, 29113, 7804, 2235, 198, 2, 15069, 357, 66, 8, 3717, 11, 35920, 43412, 13, 198, 2, 1439, 2489, 10395, 13, 198, 2, 198, 2, 770, 2393, 318, 9387, 739, 262, 2846, 287, 262, 7223, 38559, 24290, 2393, 13, 198, 2, 1002, 345, 466, ...
4.675676
111
import argparse import os import sys import numpy as np from scipy import misc import cv2 import torch import torch.nn as nn from torch.autograd import Variable from torchvision.models import vgg16, vgg19 from torchvision.utils import save_image from lib.gradients import GradCam, GuidedBackpropGrad from lib.image_utils import preprocess_image, save_cam_image, save_as_gray_image from lib.labels import IMAGENET_LABELS if __name__ == '__main__': main()
[ 11748, 1822, 29572, 198, 11748, 28686, 198, 11748, 25064, 198, 198, 11748, 299, 32152, 355, 45941, 198, 6738, 629, 541, 88, 1330, 12747, 198, 11748, 269, 85, 17, 198, 11748, 28034, 198, 11748, 28034, 13, 20471, 355, 299, 77, 198, 6738, ...
3.135135
148
from floodsystem import stationdata, datafetcher, station stations = stationdata.build_station_list() stationdata.update_water_levels(stations) #Empty lists for each of the risk categories severe_level_station = [] high_level_station = [] moderate_level_station = [] low_level_station = [] for station in stations: #Sorts out stations into different levels level = station.relative_water_level() if level is not None: if level > 1.2: severe_level_station.append(station) elif level > 0.9: high_level_station.append(station) elif level > 0.7: moderate_level_station.append(station) else: low_level_station.append(station) #sets for the different categories severe_town = {x.town for x in severe_level_station} high_town = {x.town for x in high_level_station} moderate_town = {x.town for x in moderate_level_station} low_town = {x.town for x in low_level_station} for town in severe_town: #xx print(town)
[ 6738, 6947, 10057, 1330, 4429, 7890, 11, 1366, 34045, 2044, 11, 4429, 198, 198, 301, 602, 796, 4429, 7890, 13, 11249, 62, 17529, 62, 4868, 3419, 198, 17529, 7890, 13, 19119, 62, 7050, 62, 46170, 7, 301, 602, 8, 198, 198, 2, 40613, ...
2.672775
382
#//------------------------------------------------------------------- #/*/{Protheus.doc} ACDA035 - # #@author PEDRO ANTONIO MISSAGLIA #@since 23/09/2019 #@version P12 # # CT001 - Incluso de Lanamento de Inventrio # CT002 - Viso de um lanamento de inventrio # CT003 - Visualizao das legendas # CT004 - Alterao de Lanamento de Inventrio # CT005 - Excluso de Lanamento de Inventrio # CT007 - Alterao de Lanamento de Inventrio sem finalizar contagem # #/*/ #//------------------------------------------------------------------- from tir import Webapp import unittest import time if __name__ == '__main__': unittest.main()
[ 2, 1003, 10097, 6329, 198, 2, 15211, 14, 90, 2964, 1169, 385, 13, 15390, 92, 7125, 5631, 44215, 532, 220, 197, 197, 197, 197, 197, 197, 197, 197, 197, 197, 198, 2, 198, 2, 31, 9800, 350, 1961, 13252, 3537, 11357, 9399, 50029, 4090...
2.976636
214
from pathlib import Path from jina import Flow, Document from jina.executors import BaseExecutor from jina.parsers import set_pea_parser from jina.peapods.peas import BasePea cur_dir = Path(__file__).parent
[ 6738, 3108, 8019, 1330, 10644, 198, 198, 6738, 474, 1437, 1330, 27782, 11, 16854, 198, 6738, 474, 1437, 13, 18558, 315, 669, 1330, 7308, 23002, 38409, 198, 6738, 474, 1437, 13, 79, 945, 364, 1330, 900, 62, 431, 64, 62, 48610, 198, 6...
2.958333
72
# for loops # for letter in "Cihat Salik": # print(letter) friends = ["Hasan", "Mahmut", "Ali", "Veli"] for friend in friends: print(friend) for index in range(3, 10): print(index) for index in range(len(friends)): print(friends[index]) for index in range(5): if index == 0: print("First Iteration") else: print("Not first")
[ 2, 329, 23607, 198, 2, 329, 3850, 287, 366, 34, 4449, 265, 4849, 1134, 1298, 198, 2, 220, 220, 220, 220, 3601, 7, 9291, 8, 628, 198, 36154, 796, 14631, 19242, 272, 1600, 366, 40936, 21973, 1600, 366, 37893, 1600, 366, 53, 43733, 8...
2.470199
151
from __future__ import absolute_import from __future__ import division from __future__ import print_function import cgi from BaseHTTPServer import BaseHTTPRequestHandler, HTTPServer import tensorflow as tf from ricga import configuration from ricga import inference_wrapper from ricga.inference_utils import caption_generator from ricga.inference_utils import vocabulary FLAGS = tf.flags.FLAGS tf.flags.DEFINE_string("checkpoint_path", "/home/meteorshub/code/RICGA/ricga/model/train", "Model checkpoint file or directory containing a " "model checkpoint file.") tf.flags.DEFINE_string("vocab_file", "/home/meteorshub/code/RICGA/ricga/data/mscoco/word_counts.txt", "Text file containing the vocabulary.") tf.flags.DEFINE_string("server_ip", "59.66.143.35", "Server address") tf.flags.DEFINE_integer("server_port", 8080, "server port") tf.logging.set_verbosity(tf.logging.INFO) inf_model = InferenceModel() if __name__ == "__main__": tf.app.run()
[ 6738, 11593, 37443, 834, 1330, 4112, 62, 11748, 198, 6738, 11593, 37443, 834, 1330, 7297, 198, 6738, 11593, 37443, 834, 1330, 3601, 62, 8818, 198, 198, 11748, 269, 12397, 198, 6738, 7308, 6535, 28820, 18497, 1330, 7308, 40717, 18453, 2506...
2.752
375
import os import sys if sys.platform.startswith('linux'): from OpenGL import GL from PyQt5.QtQml import QQmlApplicationEngine from PyQt5.QtWidgets import QApplication from analysis.probe.gui.backend_classes import PythonBackendClass1, Logger from analysis.probe.gui.image_providers import PyplotImageProvider DEBUG = False if __name__ == '__main__': app = QApplication(sys.argv) appEngine = QQmlApplicationEngine() context = appEngine.rootContext() analysis_image_provider1 = PyplotImageProvider(fig=None) appEngine.addImageProvider("analysisprovider1", analysis_image_provider1) analysis_image_provider2 = PyplotImageProvider(fig=None) appEngine.addImageProvider("analysisprovider2", analysis_image_provider2) # ALL THE ADDIMAGEPROVIDER LINES BELOW ARE REQUIRED TO MAKE QML BELIEVE THE PROVIDER IS VALID BEFORE ITS CREATION # appEngine.addImageProvider('viewerprovider', CvImageProvider()) # analysis_image_provider = PyplotImageProvider(fig=None) # appEngine.addImageProvider("analysisprovider", analysis_image_provider) conf = { 'shared_directory': './' # FIXME: this is obviously BS } qml_source_path = os.path.join(conf['shared_directory'], 'qml', 'gui_qtquick', 'gui_qtquick.qml') if not os.path.isfile(qml_source_path): raise ValueError("Qml code not found at {}, please verify your installation".format(qml_source_path)) appEngine.load(qml_source_path) try: win = appEngine.rootObjects()[0] except IndexError: raise ValueError("Could not start the QT GUI") if not DEBUG: logger = Logger(context, win, "log") sys.stdout = logger print('Hello world') # icon = QIcon(os.path.join(conf.shared_directory, 'resources', 'icons', 'pyper.png')) # win.setIcon(icon) backend = PythonBackendClass1(app, context, win, analysis_image_provider1, analysis_image_provider2) # create instance of backend context.setContextProperty('py_iface', backend) # register backend python object with qml code under variable name py_iface win.show() sys.exit(app.exec_())
[ 11748, 28686, 201, 198, 11748, 25064, 201, 198, 201, 198, 361, 25064, 13, 24254, 13, 9688, 2032, 342, 10786, 23289, 6, 2599, 201, 198, 220, 220, 220, 422, 30672, 1330, 10188, 201, 198, 201, 198, 6738, 9485, 48, 83, 20, 13, 48, 83, ...
2.664234
822
import opensearchpy import curator import os import json import string import random import tempfile from time import sleep import click from click import testing as clicktest from mock import patch, Mock from . import CuratorTestCase from . import testvars as testvars import logging logger = logging.getLogger(__name__) host, port = os.environ.get('TEST_ES_SERVER', 'localhost:9200').split(':') port = int(port) if port else 9200
[ 11748, 1034, 1072, 998, 9078, 198, 11748, 46132, 198, 11748, 28686, 198, 11748, 33918, 198, 11748, 4731, 198, 11748, 4738, 198, 11748, 20218, 7753, 198, 6738, 640, 1330, 3993, 198, 11748, 3904, 198, 6738, 3904, 1330, 4856, 355, 3904, 9288...
3.390625
128
import json from pathlib import Path import re from typing import Dict import boto3 import structlog from datacube.model import Dataset from datacube.virtual import Measurement, Transformation from eodatasets3 import DatasetAssembler, serialise from eodatasets3.model import DatasetDoc, ProductDoc from eodatasets3.properties import StacPropertyView from eodatasets3.scripts.tostac import dc_to_stac, json_fallback from eodatasets3.verify import PackageChecksum from toolz.dicttoolz import get_in from datacube_alchemist.settings import AlchemistTask # Regex for extracting region codes from tile IDs. RE_TILE_REGION_CODE = re.compile(r".*A\d{6}_T(\w{5})_N\d{2}\.\d{2}") def _stac_to_sns(sns_arn, stac): """ Publish our STAC document to an SNS """ bbox = stac["bbox"] product_name = get_in(["properties", "odc:product"], stac, None) if product_name is None: product_name = stac.get("collection", None) if product_name is None: raise ValueError("No 'odc:product_name' or 'collection' found in STAC doc") attributes = { "action": {"DataType": "String", "StringValue": "ADDED"}, "datetime": { "DataType": "String", "StringValue": str(get_in(["properties", "datetime"], stac)), }, "product": { "DataType": "String", "StringValue": product_name, }, "bbox.ll_lon": {"DataType": "Number", "StringValue": str(bbox[0])}, "bbox.ll_lat": {"DataType": "Number", "StringValue": str(bbox[1])}, "bbox.ur_lon": {"DataType": "Number", "StringValue": str(bbox[2])}, "bbox.ur_lat": {"DataType": "Number", "StringValue": str(bbox[3])}, } maturity = get_in(["properties", "dea:dataset_maturity"], stac) if maturity is not None: attributes["maturity"] = {"DataType": "String", "StringValue": maturity} client = boto3.client("sns") client.publish( TopicArn=sns_arn, Message=json.dumps(stac, indent=4, default=json_fallback), MessageAttributes=attributes, ) def _munge_dataset_to_eo3(ds: Dataset) -> DatasetDoc: """ Convert to the DatasetDoc format that eodatasets expects. """ if ds.metadata_type.name in {"eo_plus", "eo_s2_nrt", "gqa_eo"}: # Handle S2 NRT metadata identically to eo_plus files. # gqa_eo is the S2 ARD with extra quality check fields. return _convert_eo_plus(ds) if ds.metadata_type.name == "eo": return _convert_eo(ds) # Else we have an already mostly eo3 style dataset product = ProductDoc(name=ds.type.name) # Wrap properties to avoid typos and the like properties = StacPropertyView(ds.metadata_doc.get("properties", {})) if properties.get("eo:gsd"): del properties["eo:gsd"] return DatasetDoc( id=ds.id, product=product, crs=str(ds.crs), properties=properties, geometry=ds.extent, ) def _guess_region_code(ds: Dataset) -> str: """ Get the region code of a dataset. """ try: # EO plus return ds.metadata.region_code except AttributeError: # Not EO plus pass try: # EO return ds.metadata_doc["region_code"] except KeyError: # No region code! pass # Region code not specified, so get it from the tile ID. # An example of such a tile ID for S2A NRT is: # S2A_OPER_MSI_L1C_TL_VGS1_20201114T053541_A028185_T50JPP_N02.09 # The region code is 50JPP. tile_match = RE_TILE_REGION_CODE.match(ds.metadata_doc["tile_id"]) if not tile_match: raise ValueError("No region code for dataset {}".format(ds.id)) return tile_match.group(1)
[ 11748, 33918, 198, 6738, 3108, 8019, 1330, 10644, 198, 11748, 302, 198, 6738, 19720, 1330, 360, 713, 198, 198, 11748, 275, 2069, 18, 198, 11748, 2878, 6404, 198, 6738, 4818, 330, 3266, 13, 19849, 1330, 16092, 292, 316, 198, 6738, 4818, ...
2.331246
1,597
# -*- coding: utf-8 -*- from __future__ import unicode_literals from django.db import migrations, models
[ 2, 532, 9, 12, 19617, 25, 3384, 69, 12, 23, 532, 9, 12, 198, 6738, 11593, 37443, 834, 1330, 28000, 1098, 62, 17201, 874, 198, 198, 6738, 42625, 14208, 13, 9945, 1330, 15720, 602, 11, 4981, 628 ]
2.891892
37
from rb.core.lang import Lang from rb.core.document import Document from rb.complexity.complexity_index import ComplexityIndex, compute_indices from rb.similarity.word2vec import Word2Vec from rb.similarity.vector_model import VectorModelType, CorporaEnum, VectorModel from rb.similarity.vector_model_factory import VECTOR_MODELS, create_vector_model from typing import Tuple, List from sklearn.svm import SVR from collections import Counter from sklearn import svm from sklearn.metrics import confusion_matrix, plot_confusion_matrix import matplotlib.pyplot as plt import pickle import os import csv import random from werkzeug import secure_filename import uuid from rb.cna.cna_graph import CnaGraph from rb.utils.rblogger import Logger logger = Logger.get_logger()
[ 6738, 374, 65, 13, 7295, 13, 17204, 1330, 16332, 198, 6738, 374, 65, 13, 7295, 13, 22897, 1330, 16854, 198, 6738, 374, 65, 13, 41887, 414, 13, 41887, 414, 62, 9630, 1330, 19157, 414, 15732, 11, 24061, 62, 521, 1063, 198, 6738, 374, ...
3.153846
247
import csv
[ 11748, 269, 21370, 628 ]
3
4
""" enclosure_tags ~~~~~~~~~~~~~~ Fix tags for MP3 enclosures (e.g. podcasts). Adds a "with tags" link to a version of the file with tags set as follows: * the entry title as title * the feed title as album * the entry/feed author as author This plugin needs additional dependencies, use the ``unstable-plugins`` extra to install them: .. code-block:: bash pip install reader[unstable-plugins] To load:: READER_APP_PLUGIN='reader._plugins.enclosure_tags:init' \\ python -m reader serve Implemented for https://github.com/lemon24/reader/issues/50. Became a plugin in https://github.com/lemon24/reader/issues/52. """ import tempfile from urllib.parse import urlparse import mutagen.mp3 import requests from flask import Blueprint from flask import request from flask import Response from flask import stream_with_context from flask import url_for blueprint = Blueprint('enclosure_tags', __name__) ALL_TAGS = ('album', 'title', 'artist') SET_ONLY_IF_MISSING_TAGS = {'artist'}
[ 37811, 198, 268, 17966, 62, 31499, 198, 15116, 8728, 4907, 198, 198, 22743, 15940, 329, 4904, 18, 13507, 16091, 357, 68, 13, 70, 13, 31969, 737, 198, 198, 46245, 257, 366, 4480, 15940, 1, 2792, 284, 257, 2196, 286, 262, 2393, 351, 1...
3.232258
310
import _sqlite3 mydb = _sqlite3.connect(database = 'namelist') with mydb: cur = mydb.cursor() name = 'update_name_placeholder' cur.execute('DELETE FROM users WHERE First_name = ?', (name,)) mydb.commit() print('Data deleted!!!') cur = mydb.cursor() selectquery = 'SELECT * FROM users' cur.execute(selectquery) results = cur.fetchall() print('Original data: ') for row in results: print(row)
[ 11748, 4808, 25410, 578, 18, 628, 198, 1820, 9945, 796, 4808, 25410, 578, 18, 13, 8443, 7, 48806, 796, 705, 7402, 46331, 11537, 198, 198, 4480, 616, 9945, 25, 198, 220, 220, 220, 1090, 796, 616, 9945, 13, 66, 21471, 3419, 628, 220, ...
2.536313
179
import struct # Message id constants command_ack_id = 10 config_airdata_id = 11 config_board_id = 12 config_ekf_id = 13 config_imu_id = 14 config_mixer_id = 15 config_mixer_matrix_id = 16 config_power_id = 17 config_pwm_id = 18 config_stability_damping_id = 19 command_inceptors_id = 20 command_zero_gyros_id = 21 command_reset_ekf_id = 22 command_cycle_inceptors_id = 23 pilot_id = 24 imu_id = 25 aura_nav_pvt_id = 26 airdata_id = 27 power_id = 28 status_id = 29 ekf_id = 30 # Constants pwm_channels = 8 # number of pwm output channels sbus_channels = 16 # number of sbus channels ap_channels = 6 # number of sbus channels mix_matrix_size = 64 # 8 x 8 mix matrix # Enums enum_nav_none = 0 # None enum_nav_nav15 = 1 # None enum_nav_nav15_mag = 2 # None # Message: command_ack # Id: 10 # Message: config_airdata # Id: 11 # Message: config_board # Id: 12 # Message: config_ekf # Id: 13 # Message: config_imu # Id: 14 # Message: config_mixer # Id: 15 # Message: config_mixer_matrix # Id: 16 # Message: config_power # Id: 17 # Message: config_pwm # Id: 18 # Message: config_stability_damping # Id: 19 # Message: command_inceptors # Id: 20 # Message: command_zero_gyros # Id: 21 # Message: command_reset_ekf # Id: 22 # Message: command_cycle_inceptors # Id: 23 # Message: pilot # Id: 24 # Message: imu # Id: 25 # Message: aura_nav_pvt # Id: 26 # Message: airdata # Id: 27 # Message: power # Id: 28 # Message: status # Id: 29 # Message: ekf # Id: 30
[ 11748, 2878, 198, 198, 2, 16000, 4686, 38491, 198, 21812, 62, 441, 62, 312, 796, 838, 198, 11250, 62, 958, 7890, 62, 312, 796, 1367, 198, 11250, 62, 3526, 62, 312, 796, 1105, 198, 11250, 62, 988, 69, 62, 312, 796, 1511, 198, 11250...
2.464107
599
""" Query construction tests. """ from hamcrest import assert_that, is_, equal_to from influxdbnagiosplugin.query import ExplicitQueryBuilder, SingleMeasurementQueryBuilder
[ 37811, 198, 20746, 5103, 5254, 13, 198, 37811, 198, 6738, 8891, 66, 2118, 1330, 6818, 62, 5562, 11, 318, 62, 11, 4961, 62, 1462, 198, 198, 6738, 3057, 24954, 9374, 363, 4267, 33803, 13, 22766, 1330, 11884, 20746, 32875, 11, 14206, 473...
3.708333
48
# -*- coding: utf-8 -*- import os import sys import types import unittest import inspect from lxml import etree from . import XSL, XML, VERSION_LIST from .core import get_module, get_stylesheet, get_source_version, get_migration_path, list_versions from .main import parse_args from .migrate import migrate_by_stylesheet, do_migration, get_params from .utils import _print, _check, _decode_data replace_list = [ ('\n', ''), ('\t', ''), (' ', ''), ] def compare_elements(el1, el2): """Compare two elements and all their children :return: True or False """ _check(el1, (etree._Element), TypeError) _check(el2, (etree._Element), TypeError) # https://stackoverflow.com/questions/7905380/testing-equivalence-of-xml-etree-elementtree if el1.tag != el2.tag: return False if _replace(el1.text) != _replace(el2.text): return False if _replace(el1.tail) != _replace(el2.tail): return False if el1.attrib != el2.attrib: return False if len(el1) != len(el2): return False return all(compare_elements(e1, e2) for e1, e2 in zip(el1, el2))
[ 2, 532, 9, 12, 19617, 25, 3384, 69, 12, 23, 532, 9, 12, 198, 11748, 28686, 198, 11748, 25064, 198, 11748, 3858, 198, 11748, 555, 715, 395, 198, 11748, 10104, 198, 198, 6738, 300, 19875, 1330, 2123, 631, 198, 198, 6738, 764, 1330, ...
2.480349
458
"""Shaft element module for STOCHASTIC ROSS. This module creates an instance of random shaft element for stochastic analysis. """ from ross.shaft_element import ShaftElement from ross.stochastic.st_materials import ST_Material from ross.stochastic.st_results_elements import plot_histogram from ross.units import Q_, check_units __all__ = ["ST_ShaftElement", "st_shaft_example"] def st_shaft_example(): """Return an instance of a simple random shaft element. The purpose is to make available a simple model so that doctest can be written using it. Returns ------- elm : ross.stochastic.ST_ShaftElement An instance of a random shaft element object. Examples -------- >>> import ross.stochastic as srs >>> elm = srs.st_shaft_example() >>> len(list(iter(elm))) 2 """ from ross.materials import steel elm = ST_ShaftElement( L=[1.0, 1.1], idl=0.0, odl=[0.1, 0.2], material=steel, is_random=["L", "odl"], ) return elm
[ 37811, 2484, 14940, 5002, 8265, 329, 3563, 46, 3398, 11262, 2149, 371, 18420, 13, 198, 198, 1212, 8265, 8075, 281, 4554, 286, 4738, 18619, 5002, 329, 3995, 354, 3477, 198, 20930, 13, 198, 37811, 198, 6738, 686, 824, 13, 1477, 14940, 6...
2.560494
405
#!/usr/bin/env python from __future__ import print_function, division from sympy.core.compatibility import xrange from random import random from sympy import factor, I, Integer, pi, simplify, sin, sqrt, Symbol, sympify from sympy.abc import x, y, z from timeit import default_timer as clock def bench_R1(): "real(f(f(f(f(f(f(f(f(f(f(i/2)))))))))))" e = f(f(f(f(f(f(f(f(f(f(I/2)))))))))).as_real_imag()[0] def bench_R2(): "Hermite polynomial hermite(15, y)" a = hermite(15, y) def bench_R3(): "a = [bool(f==f) for _ in range(10)]" f = x + y + z a = [bool(f == f) for _ in range(10)] def bench_R5(): "blowup(L, 8); L=uniq(L)" L = [x, y, z] blowup(L, 8) L = uniq(L) def bench_R6(): "sum(simplify((x+sin(i))/x+(x-sin(i))/x) for i in xrange(100))" s = sum(simplify((x + sin(i))/x + (x - sin(i))/x) for i in xrange(100)) def bench_R7(): "[f.subs(x, random()) for _ in xrange(10**4)]" f = x**24 + 34*x**12 + 45*x**3 + 9*x**18 + 34*x**10 + 32*x**21 a = [f.subs(x, random()) for _ in xrange(10**4)] def bench_R8(): "right(x^2,0,5,10^4)" a = right(x**2, 0, 5, 10**4) def _bench_R9(): "factor(x^20 - pi^5*y^20)" factor(x**20 - pi**5*y**20) def bench_R10(): "v = [-pi,-pi+1/10..,pi]" v = srange(-pi, pi, sympify(1)/10) def bench_R11(): "a = [random() + random()*I for w in [0..1000]]" a = [random() + random()*I for w in range(1000)] def bench_S1(): "e=(x+y+z+1)**7;f=e*(e+1);f.expand()" e = (x + y + z + 1)**7 f = e*(e + 1) f = f.expand() if __name__ == '__main__': benchmarks = [ bench_R1, bench_R2, bench_R3, bench_R5, bench_R6, bench_R7, bench_R8, #_bench_R9, bench_R10, bench_R11, #bench_S1, ] report = [] for b in benchmarks: t = clock() b() t = clock() - t print("%s%65s: %f" % (b.__name__, b.__doc__, t))
[ 2, 48443, 14629, 14, 8800, 14, 24330, 21015, 198, 6738, 11593, 37443, 834, 1330, 3601, 62, 8818, 11, 7297, 198, 6738, 10558, 88, 13, 7295, 13, 5589, 25901, 1330, 2124, 9521, 198, 198, 6738, 4738, 1330, 4738, 198, 6738, 10558, 88, 1330...
1.892823
1,045
from tempfile import NamedTemporaryFile import os import pytest from c10_tools.capture import main
[ 198, 6738, 20218, 7753, 1330, 34441, 12966, 5551, 8979, 198, 11748, 28686, 198, 198, 11748, 12972, 9288, 198, 198, 6738, 269, 940, 62, 31391, 13, 27144, 495, 1330, 1388, 628, 628 ]
3.387097
31
# TODO: tle import re import sys m = {"?": ".?", "*": ".*?"} for ln in sys.stdin: p, s = ln.rstrip().split() res = re.findall(tr(p), s) print(score(min(res)) if res else -1)
[ 2, 16926, 46, 25, 256, 293, 198, 11748, 302, 198, 11748, 25064, 628, 198, 76, 796, 1391, 13984, 1298, 27071, 35379, 366, 9, 1298, 366, 15885, 1701, 92, 628, 628, 198, 1640, 300, 77, 287, 25064, 13, 19282, 259, 25, 198, 220, 220, 2...
2.086957
92
#!/usr/bin/python3 import numpy as np import cv2 from mss.linux import MSS as mss from PIL import Image import time import pyautogui as pg #mon = {'top': 480, 'left': 130, 'width': 70, 'height': 35} mon = {'top': 200, 'left': 410, 'width': 50, 'height': 30} #git-b01 screen_record()
[ 2, 48443, 14629, 14, 8800, 14, 29412, 18, 198, 11748, 299, 32152, 355, 45941, 198, 11748, 269, 85, 17, 198, 6738, 285, 824, 13, 23289, 1330, 337, 5432, 355, 285, 824, 198, 6738, 350, 4146, 1330, 7412, 198, 11748, 640, 198, 11748, 12...
2.609091
110
# Copyright 2015 Tesora Inc. # All Rights Reserved. # # 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 writing, software # distributed under the License is distributed on an "AS IS" BASIS, WITHOUT # WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the # License for the specific language governing permissions and limitations # under the License. from proboscis import test from trove.tests import PRE_INSTANCES from trove.tests.scenario import groups from trove.tests.scenario.groups.test_group import TestGroup from trove.tests.scenario.runners import test_runners GROUP = "scenario.instance_create_group"
[ 2, 15069, 1853, 10696, 5799, 3457, 13, 198, 2, 1439, 6923, 33876, 13, 198, 2, 198, 2, 220, 220, 220, 49962, 739, 262, 24843, 13789, 11, 10628, 362, 13, 15, 357, 1169, 366, 34156, 15341, 345, 743, 198, 2, 220, 220, 220, 407, 779, ...
3.427481
262
# Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. import numpy as np import tensorflow as tf from reco_utils.recommender.deeprec.models.base_model import BaseModel __all__ = ["DKN"]
[ 2, 15069, 357, 66, 8, 5413, 10501, 13, 1439, 2489, 10395, 13, 198, 2, 49962, 739, 262, 17168, 13789, 13, 198, 198, 11748, 299, 32152, 355, 45941, 198, 11748, 11192, 273, 11125, 355, 48700, 198, 198, 6738, 664, 78, 62, 26791, 13, 473...
3.432836
67
import tensorflow as tf from tensorflow.keras import datasets, layers, optimizers, Sequential, metrics, losses # 1. (x, y), (x_val, y_val) = datasets.mnist.load_data() # x = tf.convert_to_tensor(x, dtype=tf.float32) / 255. # 0~1 y = tf.convert_to_tensor(y, dtype=tf.int32) # print(x.shape, y.shape) train_dataset = tf.data.Dataset.from_tensor_slices((x, y)) # train_dataset = train_dataset.batch(32).repeat(10) # batch3210 # 2. network = Sequential([ # layers.Conv2D(6, kernel_size=3, strides=1), # 63*3*1 layers.MaxPooling2D(pool_size=2, strides=2), # 2*22 layers.ReLU(), # layers.Conv2D(16, kernel_size=3, strides=1), # 163*3*6 layers.MaxPooling2D(pool_size=2, strides=2), # layers.ReLU(), # layers.Flatten(), # layers.Dense(120, activation='relu'), # 120 layers.Dense(84, activation='relu'), # 84 layers.Dense(10) # 10 ]) network.build(input_shape=(None, 28, 28, 1)) # ,batch_size=32,28*28,1 network.summary() # # 3. optimizer = optimizers.SGD(lr=0.01) # =0.01 acc_meter = metrics.Accuracy() # accuracy for step, (x, y) in enumerate(train_dataset): # batch with tf.GradientTape() as tape: # x = tf.reshape(x, (32, 28, 28, 1)) # [b,28,28]->[b,784] # x = tf.extand_dims(x, axis=3) out = network(x) # [b, 10] y_onehot = tf.one_hot(y, depth=10) # one-hot loss = tf.square(out - y_onehot) loss = tf.reduce_sum(loss) / 32 # 32batch grads = tape.gradient(loss, network.trainable_variables) # optimizer.apply_gradients(zip(grads, network.trainable_variables)) # acc_meter.update_state(tf.argmax(out, axis=1), y) # if step % 200 == 0: # 200step print('Step', step, ': Loss is: ', float(loss), ' Accuracy: ', acc_meter.result().numpy()) # acc_meter.reset_states() # l
[ 11748, 11192, 273, 11125, 355, 48700, 198, 6738, 11192, 273, 11125, 13, 6122, 292, 1330, 40522, 11, 11685, 11, 6436, 11341, 11, 24604, 1843, 11, 20731, 11, 9089, 198, 198, 2, 352, 13, 198, 7, 87, 11, 331, 828, 357, 87, 62, 2100, 1...
2.170388
851
#------------------------------------------------------------------------------- # Part of this Python script is taken from the Pycom NanoGateway # https://github.com/pycom/pycom-libraries/tree/master/examples/lorawan-nano-gateway # # Adapted by Congduc.Pham@univ-pau.fr # # This file is part of the low-cost LoRa gateway developped at University of Pau # # This program 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, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with the program. If not, see <http://www.gnu.org/licenses/>. #------------------------------------------------------------------------------- import binascii import json import os import socket import time import datetime from dateutil import parser import calendar import sys #don't generate pyc (no compilation of imported module) so change in key_* file can be done dynamically sys.dont_write_bytecode = True import key_TTN as key_LoRaWAN netserv='TTN' try: key_LoRaWAN.source_list except AttributeError: key_LoRaWAN.source_list=[] try: key_LoRaWAN.lorawan_server except AttributeError: key_LoRaWAN.lorawan_server="router.eu.thethings.network" try: key_LoRaWAN.lorawan_port except AttributeError: key_LoRaWAN.lorawan_port=1700 PROTOCOL_VERSION = 2 PUSH_DATA = 0 PUSH_ACK = 1 PULL_DATA = 2 PULL_ACK = 4 PULL_RESP = 3 RX_PK = { 'rxpk': [{ 'time': '', 'tmst': 0, 'chan': 0, 'rfch': 0, 'freq': 0, 'stat': 1, 'modu': 'LORA', 'datr': '', 'codr': '4/5', 'rssi': 0, 'lsnr': 0, 'size': 0, 'data': '' }] } TX_ACK_PK = { 'txpk_ack': { 'error': '' } } # Testing with pau_lorawan_testing/Pau_testing_device 0x26011721 # # python CloudTTN.py "QCEXASYAAAABhCGE1L87NCDMk0jLa6hYXm0e+g==" "256,64,637605665,0,28,8,-45" "125,5,12,868100" "2019-03-25T18:46:00.528+01:00" "0000B827EBD1B236" # or # python CloudTTN.py "QCEXASYAAAABhCGE1L87NCDMk0jLa6hYXm0e+g==" "256,64,637605665,0,28,8,-45" "125,5,12,868100" "`date +%FT%T%z`" "0000B827EBD1B236" # # get the base64 encrypted data from `Arduino_LoRa_temp` sending "Hello from UPPA" # # Hello from UPPA # plain payload hex # 48 65 6C 6C 6F 20 66 72 6F 6D 20 55 50 50 41 # Encrypting # encrypted payload # 84 21 84 D4 BF 3B 34 20 CC 93 48 CB 6B A8 58 # calculate MIC with NwkSKey # transmitted LoRaWAN-like packet: # MHDR[1] | DevAddr[4] | FCtrl[1] | FCnt[2] | FPort[1] | EncryptedPayload | MIC[4] # 40 21 17 01 26 00 00 00 01 84 21 84 D4 BF 3B 34 20 CC 93 48 CB 6B A8 58 5E 6D 1E FA # [base64 LoRaWAN HEADER+CIPHER+MIC]:QCEXASYAAAABhCGE1L87NCDMk0jLa6hYXm0e+g== def main(ldata, pdata, rdata, tdata, gwid): # this is common code to process packet information provided by the main gateway script (i.e. post_processing_gw.py) # these information are provided in case you need them arr = map(int,pdata.split(',')) dst=arr[0] ptype=arr[1] src=arr[2] seq=arr[3] datalen=arr[4] SNR=arr[5] RSSI=arr[6] #if lora packet is received with an SX1301 concentrator, then the packet-formatter will pass the tmst field after the date information, separated by '*' #i.e. "2019-03-25T18:46:00.528+01:00*29641444" tmst=tdata.count('*') if (tmst != 0): tdata_tmp=tdata.split('*')[0] tmst=tdata.split('*')[1] tdata=tdata_tmp else: tmst='' #from 2019-05-14T14:53:10.241191+02:00 (similar to command date +%FT%T.%6N%z) #to 2019-05-14T14:53:10.241191Z (similar to command date +%FT%T.%6NZ) dt = parser.parse(tdata) #in case you want to remove microsecond #tdata = dt.replace(microsecond=0,tzinfo=None).isoformat()+"Z" tdata = dt.replace(tzinfo=None).isoformat()+"Z" arr = map(int,rdata.split(',')) rbw=arr[0] rcr=arr[1] rsf=arr[2] rfq=arr[3]/1000.0 #LoRaWAN packet if dst==256: src_str="0x%0.8X" % src #we force to BW125 as TTN is can not handle other bandwidth right now, for instance those of Lora 2.4GHz #TODO: change when TTN will support LoRa 2.4GHz rbw=125 else: src_str=str(src) if (src_str in key_LoRaWAN.source_list) or (len(key_LoRaWAN.source_list)==0): #build the ttn_gwid which is defined to be gwid[4:10]+"FFFF"+gwid[10:] #gwid is normally defined as eth0 MAC address filled by 0 in front: 0000B827EBD1B236 ttn_gwid=gwid[4:10]+"FFFF"+gwid[10:] ttn = LoRaWAN( id=ttn_gwid, frequency=rfq, bw=rbw, sf=rsf, server=key_LoRaWAN.lorawan_server, port=key_LoRaWAN.lorawan_port) ttn.start() ttn.rx_packet(ldata, datalen, tdata, tmst, RSSI, SNR) else: print "Source is not is source list, not sending to %s" % netserv if __name__ == "__main__": main(sys.argv[1], sys.argv[2], sys.argv[3], sys.argv[4], sys.argv[5])
[ 2, 10097, 24305, 198, 2, 2142, 286, 428, 11361, 4226, 318, 2077, 422, 262, 9485, 785, 33504, 22628, 1014, 198, 2, 3740, 1378, 12567, 13, 785, 14, 9078, 785, 14, 9078, 785, 12, 75, 11127, 14, 21048, 14, 9866, 14, 1069, 12629, 14, 4...
2.320882
2,222
try: import tkinter as tk except ImportError: import Tkinter as tk
[ 28311, 25, 198, 220, 220, 220, 1330, 256, 74, 3849, 355, 256, 74, 198, 16341, 17267, 12331, 25, 198, 220, 220, 220, 1330, 309, 74, 3849, 355, 256, 74, 628 ]
2.533333
30
# -*- coding: utf-8 -*- from __future__ import unicode_literals from . import __version__ as app_version app_name = "SIqbal" app_title = "SIqbal" app_publisher = "RC" app_description = "Customizations for SIqbal" app_icon = "octicon octicon-file-directory" app_color = "green" app_email = "developer@rccorner.com" app_license = "MIT" # Includes in <head> # ------------------ # include js, css files in header of desk.html app_include_css = "/assets/siqbal/css/siqbal.css" # app_include_js = "/assets/siqbal/js/siqbal.js" # include js, css files in header of web template # web_include_css = "/assets/siqbal/css/siqbal.css" # web_include_js = "/assets/siqbal/js/siqbal.js" # include js in page # page_js = {"page" : "public/js/file.js"} # include js in doctype views # doctype_js = {"doctype" : "public/js/doctype.js"} # doctype_list_js = {"doctype" : "public/js/doctype_list.js"} # doctype_tree_js = {"doctype" : "public/js/doctype_tree.js"} # doctype_calendar_js = {"doctype" : "public/js/doctype_calendar.js"} doctype_js = { "Address": "public/js/address.js", "Architect and Contractor": "public/js/architect_and_contractor.js", "Authorization Rule": "public/js/authorization_rule.js", "Customer": "public/js/customer.js", "Delivery Note" : "public/js/delivery_note.js", "Item": "public/js/item.js", "Journal Entry": "public/js/journal_entry.js", "Landed Cost Voucher": "public/js/landed_cost_voucher.js", "Material Request" : "public/js/material_request.js", "Opportunity": "public/js/opportunity.js", "Payment Entry": "public/js/payment_entry.js", "Property Detail": "public/js/property_detail.js", "Purchase Invoice" : "public/js/purchase_invoice.js", "Purchase Order" : "public/js/purchase_order.js", "Purchase Receipt" : "public/js/purchase_receipt.js", "Quotation" : "public/js/quotation.js", "Request for Quotation": "public/js/request_for_quotation.js", "Salary Slip" : "public/js/salary_slip.js", "Sales Invoice" : "public/js/sales_invoice.js", "Sales Order" : "public/js/sales_order.js", "Stock Entry" : "public/js/stock_entry.js", "Stock Reconciliation" : "public/js/stock_reconciliation.js", "Supplier Quotation": "public/js/supplier_quotation.js" } # Home Pages # ---------- # application home page (will override Website Settings) # home_page = "login" # website user home page (by Role) # role_home_page = { # "Role": "home_page" # } # Website user home page (by function) # get_website_user_home_page = "siqbal.utils.get_home_page" # Generators # ---------- # automatically create page for each record of this doctype # website_generators = ["Web Page"] # Installation # ------------ # before_install = "siqbal.install.before_install" # after_install = "siqbal.install.after_install" # Desk Notifications # ------------------ # See frappe.core.notifications.get_notification_config # notification_config = "siqbal.notifications.get_notification_config" # Permissions # ----------- # Permissions evaluated in scripted ways # permission_query_conditions = { # "Event": "frappe.desk.doctype.event.event.get_permission_query_conditions", # } # # has_permission = { # "Event": "frappe.desk.doctype.event.event.has_permission", # } # Document Events # --------------- # Hook on document methods and events # doc_events = { # "*": { # "on_update": "method", # "on_cancel": "method", # "on_trash": "method" # } # } doc_events = { "Sales Order": { "validate": [ "siqbal.hook_events.sales_order.set_average_valuation_rate", # "siqbal.utils.validate_date" ], "before_submit": "siqbal.hook_events.sales_order.unset_needs_approval", "before_update_after_submit": "siqbal.hook_events.sales_order.validate_items_rate_and_update_boxes" }, "Sales Invoice": { "validate": [ "siqbal.hook_events.sales_invoice.validate_discount_while_return", "siqbal.hook_events.sales_invoice.validate_taxes_and_charges_from_so", "siqbal.utils.add_location", "siqbal.hook_events.sales_invoice.validate_sales_invoice" # "siqbal.utils.validate_date" ], "before_insert": "siqbal.hook_events.sales_invoice.set_supplier_details", "on_submit": [ "siqbal.hook_events.sales_invoice.update_reserved_qty", "siqbal.hook_events.sales_invoice.create_purchase_invoices_against_sales_taxes", # "siqbal.utils.change_pi_status" #"siqbal.hook_events.sales_invoice.validate_user_warehouse" ], "on_cancel": "siqbal.hook_events.sales_invoice.update_reserved_qty" }, "Payment Entry": { "validate": [ "siqbal.hook_events.payment_entry.validate_sales_order", # "siqbal.hook_events.payment_entry.validate_salaryslip_amount", #"siqbal.utils.validate_date" ], # "on_submit": "siqbal.hook_events.payment_entry.update_salaryslip_status", # "on_cancel": "siqbal.hook_events.payment_entry.update_salaryslip_status" }, "Stock Entry": { #"validate": "siqbal.utils.validate_date", #"on_submit": "siqbal.hook_events.stock_entry.validate_user_warehouse" }, "Opportunity": { "validate": "siqbal.utils.send_followup_sms" }, "Purchase Invoice": { "validate": "siqbal.utils.add_location" }, "Purchase Order": { #"validate": "siqbal.utils.validate_date" }, "Purchase Receipt": { #"validate": "siqbal.utils.validate_date" }, "Stock Reconciliation": { #"validate": "siqbal.utils.validate_date" }, # "Quotation": { #"validate": "siqbal.utils.validate_date" # }, # "Journal Entry": { # "before_save": "siqbal.hook_events.journal_entry.set_name" # } } jenv = { "methods" : [ "get_qrcode_image:siqbal.utils.get_qrcode_image" ] } # Scheduled Tasks # --------------- # scheduler_events = { # "all": [ # "siqbal.tasks.all" # ], # "daily": [ # "siqbal.tasks.daily" # ], # "hourly": [ # "siqbal.tasks.hourly" # ], # "weekly": [ # "siqbal.tasks.weekly" # ] # "monthly": [ # "siqbal.tasks.monthly" # ] # } # Testing # ------- # before_tests = "siqbal.install.before_tests" # Overriding Methods # ------------------------------ # # override_whitelisted_methods = { # "frappe.desk.doctype.event.event.get_events": "siqbal.event.get_events" # } # # each overriding function accepts a `data` argument; # generated from the base implementation of the doctype dashboard, # along with any modifications made in other Frappe apps # override_doctype_dashboards = { # "Task": "siqbal.task.get_dashboard_data" # } override_doctype_class = { 'Sales Invoice': 'siqbal.hook_events.overide_sales_invoice.OverrideSalesInvoice' }
[ 2, 532, 9, 12, 19617, 25, 3384, 69, 12, 23, 532, 9, 12, 198, 6738, 11593, 37443, 834, 1330, 28000, 1098, 62, 17201, 874, 198, 6738, 764, 1330, 11593, 9641, 834, 355, 598, 62, 9641, 198, 198, 1324, 62, 3672, 796, 366, 11584, 80, ...
2.458935
2,630
# Copyright (c) 2021, NVIDIA CORPORATION. All rights reserved. # # 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 writing, software # distributed under the License is distributed on an "AS IS" BASIS, # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. from DcgmReader import * import pydcgm import dcgm_structs import dcgm_structs_internal import dcgm_agent_internal import dcgm_fields from dcgm_structs import dcgmExceptionClass import logger import test_utils import time
[ 2, 15069, 357, 66, 8, 33448, 11, 15127, 23929, 44680, 6234, 13, 220, 1439, 2489, 10395, 13, 198, 2, 198, 2, 49962, 739, 262, 24843, 13789, 11, 10628, 362, 13, 15, 357, 1169, 366, 34156, 15341, 198, 2, 345, 743, 407, 779, 428, 2393...
3.665198
227
# Copyright (C) 2022 Intel Corporation # SPDX-License-Identifier: BSD-3-Clause import sys import os import unittest import numpy as np import matplotlib.pyplot as plt import torch import torch.nn.functional as F from lava.lib.dl.slayer.neuron import alif verbose = True if (('-v' in sys.argv) or ('--verbose' in sys.argv)) else False seed = np.random.randint(1000) # seed = 590 np.random.seed(seed) if verbose: print(f'{seed=}') if torch.cuda.is_available(): device = torch.device('cuda') else: if verbose: print( 'CUDA is not available in the system. ' 'Testing for CPU version only.' ) device = torch.device('cpu') # neuron parameters threshold = 1 current_decay = np.random.random() voltage_decay = np.random.random() threshold_decay = np.random.random() refractory_decay = np.random.random() # create input time = torch.FloatTensor(np.arange(200)).to(device) # expand to (batch, neuron, time) tensor spike_input = torch.autograd.Variable( torch.zeros([5, 4, len(time)]), requires_grad=True ).to(device) spike_input.data[..., np.random.randint(spike_input.shape[-1], size=5)] = 1 weight = torch.FloatTensor( 5 * np.random.random(size=spike_input.shape[-1]) - 0.5 ).reshape( [1, 1, spike_input.shape[-1]] ).to(device) # initialize neuron neuron = alif.Neuron( threshold, threshold_step=0.5 * threshold, current_decay=current_decay, voltage_decay=voltage_decay, threshold_decay=threshold_decay, refractory_decay=refractory_decay, persistent_state=True, ).to(device) quantized_weight = neuron.quantize_8bit(weight) neuron.debug = True # get the neuron response for full input current, voltage, th, ref = neuron.dynamics(quantized_weight * spike_input) spike = neuron.spike(voltage, th, ref)
[ 2, 15069, 357, 34, 8, 33160, 8180, 10501, 198, 2, 30628, 55, 12, 34156, 12, 33234, 7483, 25, 220, 347, 10305, 12, 18, 12, 2601, 682, 198, 198, 11748, 25064, 198, 11748, 28686, 198, 11748, 555, 715, 395, 198, 198, 11748, 299, 32152, ...
2.57
700
import decimal import pytest from amount import Amount as A
[ 11748, 32465, 198, 11748, 12972, 9288, 198, 198, 6738, 2033, 1330, 26308, 355, 317, 198 ]
4.066667
15
from __future__ import absolute_import from __future__ import print_function from __future__ import division import tensorflow as tf # import numpy as np import time import discogan import sys sys.path.insert(0, '../') import image_utils as iu from datasets import Pix2PixDataSet as DataSets results = { 'sample_output': './gen_img/', 'model': './model/DiscoGAN-model.ckpt' } paras = { 'epoch': 200, 'batch_size': 64, 'logging_interval': 5 } if __name__ == '__main__': main()
[ 6738, 11593, 37443, 834, 1330, 4112, 62, 11748, 198, 6738, 11593, 37443, 834, 1330, 3601, 62, 8818, 198, 6738, 11593, 37443, 834, 1330, 7297, 198, 198, 11748, 11192, 273, 11125, 355, 48700, 198, 2, 1330, 299, 32152, 355, 45941, 198, 198...
2.693122
189
"Used to reference the nested workspaces for examples in /WORKSPACE" ALL_EXAMPLES = [ "angular", "app", "kotlin", "nestjs", "parcel", "protocol_buffers", "user_managed_deps", "vendored_node", "vendored_node_and_yarn", "web_testing", "webapp", "worker", ]
[ 1, 38052, 284, 4941, 262, 28376, 2499, 43076, 329, 6096, 287, 1220, 33249, 4303, 11598, 1, 198, 7036, 62, 6369, 2390, 6489, 1546, 796, 685, 198, 220, 220, 220, 366, 21413, 1600, 198, 220, 220, 220, 366, 1324, 1600, 198, 220, 220, 22...
2.133803
142
from django.views.generic import TemplateView from django_tables2.config import RequestConfig from django_tables2_column_shifter.tables import ( ColumnShiftTableBootstrap2, ColumnShiftTableBootstrap3, ColumnShiftTableBootstrap4, ColumnShiftTableBootstrap5, ) from .models import Author, Book from .tables import get_author_table_class, get_book_table_class
[ 6738, 42625, 14208, 13, 33571, 13, 41357, 1330, 37350, 7680, 198, 6738, 42625, 14208, 62, 83, 2977, 17, 13, 11250, 1330, 19390, 16934, 198, 198, 6738, 42625, 14208, 62, 83, 2977, 17, 62, 28665, 62, 1477, 18171, 13, 83, 2977, 1330, 357...
3.131148
122
import numpy as np EXPERIMENT_NAME = 'EXP_12' CORPUS_PATH = '/home/dddhiraj/Documents/stuff/data/wiki_en.txt' TRAINING_WINDOW = 5 CONTEXT_DIMENSION = 64 LEANING_RATE = 1 DROPOUT = 0.05 CONTEXT_DECAY = 1 - TRAINING_WINDOW ** -0.5 CONTRASTIVE_WEIGHT = 1#0.1 NEGATIVE_SAMPLE_SIZE = TRAINING_WINDOW ** 2 CONEXT_INERTIA = np.sqrt(TRAINING_WINDOW) THREADS = 6 CHUNK_SIZE = 5000 DB = 'REDIS' if DB == 'MONGO': import pymongo myclient = pymongo.MongoClient('mongodb://localhost:27017') mydb = myclient["mydatabase"] collection = mydb.train_1#neighbour_aware_context_initilization_train_window_8 if DB == 'REDIS': import redis collection = redis.Redis(db=1) #11 key_collection= redis.Redis(db=2) #12 #import redisai # collection = redisai.Client(db=14) # key_collection = redisai.Client(db=15) ''' Experiment details: Trained on wiki data with 51 million words. '''
[ 11748, 299, 32152, 355, 45941, 628, 628, 198, 6369, 18973, 3955, 3525, 62, 20608, 796, 705, 49864, 62, 1065, 6, 198, 44879, 47, 2937, 62, 34219, 796, 31051, 11195, 14, 1860, 34985, 343, 1228, 14, 38354, 14, 41094, 14, 7890, 14, 15466,...
2.182844
443
#!/usr/bin/env python # coding: utf-8 """ yasi Date: 20th November 2013 Author: nkmathew <kipkoechmathew@gmail.com> Dialect aware s-expression indenter """ from __future__ import print_function import argparse import hashlib import os import re import shutil import sys import time import collections import json import difflib try: from functools import lru_cache except ImportError: from backports.functools_lru_cache import lru_cache # pylint: disable=unused-import from pprint import pprint # noqa __version__ = '2.1.2' def parse_args(arguments=None): """ Reads command-line arguments >>> parse_args('--indent-comments') """ if arguments is None: arguments = sys.argv[1:] if isinstance(arguments, str): arguments = arguments.split() if isinstance(arguments, argparse.Namespace): return arguments parser = create_args_parser() args = parser.parse_args(arguments) args.dialect = args.dialect.lower() if args.dialect not in ['lisp', 'newlisp', 'clojure', 'scheme', 'all', '']: parser.error("`{0}' is not a recognized dialect".format(args.dialect)) args.backup_dir = os.path.expanduser(args.backup_dir) if not os.path.exists(args.backup_dir): parser.error("Directory `{0}' does not exist".format(args.backup_dir)) if len(args.files) > 1 and args.output_file: parser.error('Cannot use the -o flag when more than one file is specified') if not args.files: # Indentation from standard input if args.modify and not args.output_file: args.modify = False args.backup = False args.warning = False if args.output_diff: # If someone requests a diff we assume they don't want the file to be # modified args.modify = False return args def read_file(fname): """ read_file(fname : str) -> str >>> read_file(r'C:\\mine\\test.lisp') r'(print "No, no, there\'s \\r\\nlife in him!. ")\\r\\n\\r\\n' The file is read in binary mode in order to preserve original line endings. Line ending Binary mode Text mode CRLF CRLF LF CR CR LF """ assert os.path.exists(fname), "\n--%s-- Warning: File `%s' does not exist..." \ % (current_time(), fname) with open(fname, 'rb') as fp: return fp.read().decode('utf-8') def current_time(): """ current_time() -> str >>> current_time() 14:28:04 Returns the current local time in 24 clock system. """ return time.strftime('%X', (time.localtime())) def backup_source_file(fname, args=None): """ backup_source_file(fname : str) >>> backup_source_file('~/Desktop/lisp/test.lisp') Create a backup copy of the source file. """ args = parse_args(args) backup_dir = args.backup_dir assert os.path.exists(fname), \ ("\n--%s-- Warning: File `%s' does not exist..." % (current_time(), fname)) assert os.path.exists(os.path.abspath(backup_dir)), \ ("\n--%s-- Warning: Directory `%s' does not exist..." % (current_time(), fname)) backup_name = backup_dir + os.sep + os.path.split(fname)[1] + args.backup_suffix try: shutil.copyfile(fname, backup_name) except IOError: message = "\n--%s-- Warning: Couldn't backup the file `%s' in `%s', check if you have enough permissions. " tpl = (current_time(), fname, backup_dir) sys.stderr.write(message % tpl) def md5sum(content): """ md5sum(content : str) -> str >>> md5sum('Keyboard not found!! Press F1 to continue...') 'ad98cde09016d2e99a726966a4291acf' Returns a checksum to be used to determine whether the file has changed. A simple textual comparison can still do the work """ return hashlib.md5(content).hexdigest() def find_line_ending(string): """ find_line_ending(string : str) -> str >>> find_line_ending('Elementary my dear Watson. \\r') '\\r' Find the line ending in the file so that we can try to preserve it. """ if CRLF in string: return CRLF if CR in string: return CR return LF def find_trim_limit(string, args=None): """ find_trim_limit(string : str) -> int >>> find_trim_limit(r'(list #\; #\")') 14 >>> find_trim_limit(r'(list ; ")') 6 >>> find_trim_limit(r'(list " ;)') 7 The function attempts to identify upto which point we are supposed to trim so that we don't mess with strings or any aligned comments. It does this by comparing the positions of semicolons and double quotes. It doesn't consider the multiline comment marker. If your code uses multiline comments(#| ... |#), you'll have to use --no-compact mode """ args = parse_args(args) # Find position of the first unescaped semi colon comment_start = re.search(r'([^\\];)|(^;)', string) # Find position of the first unescaped double quote string_start = re.search(r'([^\\]")|(^")', string) # Assign -1 if there's no match limit = string_start.end() if string_start else -1 comment_start = comment_start.end() if comment_start else -1 if comment_start != -1: # If a semi colon is found, include all the whitespace before it to preserve # any aligned comments comment_start = re.search('[ \t]*;', string).start() if args.dialect == 'newlisp': # Find out which string type comes first(normal, tag or brace strings) brace_string_start = re.search('{', string) tag_string_start = re.search('\[text\]', string) brace_string_start = brace_string_start.end() if brace_string_start else -1 tag_string_start = tag_string_start.end() if tag_string_start else -1 pos_lst = [limit, brace_string_start, tag_string_start] pos_lst = [x for x in pos_lst if x != -1] if pos_lst: limit = min(pos_lst) if comment_start != -1 and limit != -1: if comment_start < limit: # If the semicolon comes before the comma, it means the string has been # commented out limit = comment_start elif comment_start != -1 and limit == -1: # If there's a semicolon but no quote, use the semicolon position as the # limit limit = comment_start elif limit == -1: # If neither a semicolon nor a double quote has been found, use the length # of the string as the limit limit = len(string) return limit def detabify(text, args): """ tabify(text : str, args : argparse.Namespace|str) -> str Expands tabs """ args = parse_args(args) if args.tab_size < 1: return text.expandtabs(4) return text.expandtabs(args.tab_size) def tabify(text, args): """ tabify(text : str, args : argparse.Namespace|str) -> str >>> tabify(' (println "hello world")', '--tab=3') '\t\t (println "hello world")' Replace spaces with tabs """ args = parse_args(args) if args.tab_size < 1: return text tab_equiv = ' ' * args.tab_size return text.replace(tab_equiv, '\t') def pad_leading_whitespace(string, zero_level, blist, args=None): """ pad_leading_whitespace(string : str, current_level : int, zero_level : int) -> str >>> pad_leading_whitespace("(print 'Yello)") " (print 'Yello)" Takes a string and indents it using the current indentation level and the zero level. """ args = parse_args(args) if args.compact: # if compact mode is on, split the string into two, trim the first # position and merge the two portions. trim_limit = find_trim_limit(string, args) comment_line = re.search('^[ \t]*;', string, re.M) if comment_line and args.indent_comments: trim_limit = comment_line.end() substr1 = string[0:trim_limit] substr2 = string[trim_limit:] substr1 = trim(substr1) string = substr1 + substr2 else: # If in nocompact mode, remove leading spaces only string = re.sub('^[ \t]+', '', string, count=0) indent_level = zero_level if blist: indent_level = blist[-1]['indent_level'] padding = ' ' * indent_level padding = tabify(padding, args) return padding + string, indent_level def indent_line(zerolevel, bracket_list, line, in_comment, in_symbol_region, args=None): """ indent_line(zerolevel : int, bracket_list : list, line : str, in_comment : bool, in_symbol_region : bool, args : string|list) Most important function in the indentation process. It uses the bracket locations stored in the list to indent the line. """ args = parse_args(args) comment_line = re.search('^[ \t]*;', line, re.M) if args.indent_comments: # We are allowed to indent comment lines comment_line = False if not args.compact and bracket_list == [] and not in_comment: # If nocompact mode is on and there are no unclosed blocks, try to # find the zero level by simply counting spaces before a line that # is not empty or has a comment _line = detabify(line, args) leading_spaces = re.search('^[ \t]+[^; )\n\r]', _line) if leading_spaces: # NOTE: If you don't subtract one here, the zero level will increase # every time you indent the file because the character at the end of # the regex is part of the capture. zerolevel = leading_spaces.end() - 1 else: zerolevel = 0 if in_symbol_region: # No processing done in strings and comments return zerolevel, line, 0 if not comment_line and not all_whitespace(line): # If this is not a comment line indent the line. # If the list is empty, then the current_level defaults # to zero curr_line, current_level = pad_leading_whitespace(line, zerolevel, bracket_list, args) return zerolevel, curr_line, current_level return zerolevel, line, 0 # --------------------------------------------------------------------------------- # GLOBAL CONSTANTS:: CR = '\r' LF = '\n' CRLF = CR + LF KEYWORD0 = 0 # Non-keyword KEYWORD1 = 1 # Indents uniformly by 1 unit KEYWORD2 = 2 # Distinguishes subforms KEYWORD3 = 3 # Indents uniformly by 2 units KEYWORD4 = 4 # A 1-keyword used mostly for defining local functions e.g flets # Keywords that indent by two spaces SCHEME_KEYWORDS = \ ['define', 'local-odd?', 'when', 'begin', 'case', 'local-even?', 'do', 'call-with-bytevector-output-port', 'call-with-input-file', 'call-with-port', 'call-with-current-continuation', 'open-file-input-port', 'call-with-port', 'call-with-values', 'call-with-output-file', 'call-with-string-output-port', 'define-syntax', 'if', 'let', 'let*', 'library', 'unless', 'lambda', 'syntax-rules', 'syntax-case', 'let-syntax', 'letrec*', 'letrec', 'let-values', 'let*-values', 'with-exception-handler', 'with-input-from-file', 'with-interrupts-disabled', 'with-input-from-string', 'with-output-to-file', 'with-input-from-port', 'with-output-to-string', 'with-source-path', 'with-syntax', 'with-implicit', 'with-error-handler', 'module', 'parameterize'] CLOJURE_KEYWORDS = \ ['defn', 'fn', 'dorun', 'doseq', 'loop', 'when', 'let', 'defmacro', 'binding', 'doto', 'ns', ':import', 'defstruct', 'condp', 'comment', 'when', 'when-let', '->', '->>', 'extend-type', 'reify', 'binding', 'when-not', 'proxy', 'dotimes', 'try', 'finally', 'for', 'letfn', 'catch', 'iterate', 'while', 'with-local-vars', 'locking', 'defmulti', 'defmethod', 'extend' ] LISP_KEYWORDS = \ [':implementation', ':method', 'case', 'defclass', 'defconstant', 'defgeneric', 'defimplementation', 'define-condition', 'define-implementation-package', 'definterface', 'defmacro', 'defmethod', 'defpackage', 'defproject', 'deftype', 'defun', 'defvar', 'do-external-symbols', 'dolist', 'dotimes', 'ecase', 'etypecase', 'flet', 'handler-bind', 'if', 'lambda', 'let', 'let*', 'print-unreadable-object', 'macrolet', 'defparameter', 'with-slots', 'typecase', 'loop', 'when', 'prog1', 'unless', 'with-open-file', 'with-output-to-string', 'with-input-from-string', 'block', 'handler-case', 'defstruct', 'eval-when', 'tagbody', 'ignore-errors', 'labels', 'multiple-value-bind', 'progn', 'unwind-protect', 'collect' ] NEWLISP_KEYWORDS = \ ['while', 'if', 'case', 'dotimes', 'define', 'dolist', 'catch', 'throw', 'lambda', 'lambda-macro', 'when', 'unless', 'letex', 'begin', 'dostring', 'let', 'letn', 'doargs', 'define-macro', 'until', 'do-until', 'do-while', 'for-all', 'find-all', 'for' ] # The 'if' and 'else' part of an if block should have different indent levels so # that they can stand out since there's no else Keyword in Lisp/Scheme to make # this explicit. list IF_LIKE helps us track these keywords. IF_LIKE = ['if'] def assign_indent_numbers(lst, inum, dic): """ Associate keywords with their respective indentation numbers """ for i in lst: dic[i] = inum return dic def add_keywords(args): """ add_keywords(dialect : str) -> [str, str] Takes a lisp dialect name and returns a list of keywords that increase indentation by two spaces and those that can be one-armed like 'if' """ dialect = args.dialect keywords = collections.defaultdict(int) two_spacers = [] two_armed = IF_LIKE local_binders = [] if dialect == 'lisp': # Lisp two_spacers = LISP_KEYWORDS two_armed += ['multiple-value-bind', 'destructuring-bind', 'do', 'do*'] local_binders += ['flet', 'macrolet', 'labels'] elif dialect == 'scheme': # Scheme two_spacers = SCHEME_KEYWORDS two_armed += ['with-slots', 'do', 'do*'] local_binders += [] elif dialect == 'clojure': # Clojure two_spacers = CLOJURE_KEYWORDS two_armed += [] local_binders += ['letfn'] elif dialect == 'newlisp': # newLISP two_spacers = NEWLISP_KEYWORDS two_armed += [] local_binders += [] elif dialect == 'all': two_spacers = LISP_KEYWORDS + SCHEME_KEYWORDS + CLOJURE_KEYWORDS + \ NEWLISP_KEYWORDS keywords = assign_indent_numbers(two_spacers, KEYWORD1, keywords) keywords = assign_indent_numbers(two_armed, KEYWORD2, keywords) keywords = assign_indent_numbers(local_binders, KEYWORD4, keywords) if args.read_rc: rc_keywords = parse_rc_json() keywords.update(rc_keywords[dialect]) return keywords # --------------------------------------------------------------------------------- def find_first_arg_pos(bracket_offset, curr_line, args=None): """ find_first_arg_pos(bracket_offset : int, curr_line : str) -> [int, int] Arguments: bracket_offset - The position of the bracket in the current line e.g " ( list 'timey 'wimey )" --> 4 " ( list 'timey 'wimey )" --> 1 "( list 'timey 'wimey )" --> 0 >>> find_first_arg_pos(0, "( list 'one-sheep 'two-sheep )") [11, 5] Returns the position of the first argument to the function relative to the position of the opening bracket and the number of spaces between the opening bracket and the function name. The two values will to be used to align the other arguments in the subsequent line """ args = parse_args(args) spaces_before_func = 0 subline = curr_line[bracket_offset + 1:] if re.search('^[ \t]*($|\r)', subline): # whitespace extending to the end of the line means there's no # function in this line. The indentation level defaults to one. arg_pos = 1 else: if bracket_offset != len(curr_line) - 1 and curr_line[bracket_offset + 1] == ' ': # control reaches here if we are not at the end of the line # and whitespace follows. We must first find the position of the # function and then the arguments position match = re.search(' +[^)\]]| \)', subline) # Find the first non whitespace/bracket character if match: spaces_before_func = match.end() - match.start() - 1 end = match.end() else: end = 0 # Then use the end of the whitespace group as the first argument arg_pos = re.search(' +([^)])|( *(\(|\[))', subline[end:]) if arg_pos: arg_pos = arg_pos.end() + spaces_before_func + 1 else: arg_pos = spaces_before_func + 1 if re.match('^[ \t]*(#\||;|$|\r)', subline[(end - 1 + subline[end - 1:].find(' ')):]): # But, if a comment if found after the function name, the # indent level becomes one arg_pos = spaces_before_func + args.default_indent else: # If there's no space after the bracket, simply find the end of the # whitespace group match = re.search(' +([^)}\n\r])|( *(\(|\[|{))', subline) if match: # found the argument arg_pos = match.end() else: # Either empty list or argument is in the next line arg_pos = 1 if re.match('^[\t ]*(;|$|\r)', subline[subline.find(' '):]): # Again if a comment is found after the function name, the # indent level defaults to 1 arg_pos = spaces_before_func + args.default_indent return [arg_pos, spaces_before_func] def _pop_from_list(bracket, lst, line, real_pos, offset, msg_stack): """ _pop_from_list(char : str, lst : [str], line : str, real_pos : int, offset : int) The function is called when a closing bracket is encountered. The function simply pops the last pushed item and issues a warning if an error is encountered. """ # Try to spot a case when a square bracket is used to close a round bracket # block if bracket == ']': correct_closer = '[' elif bracket == ')': correct_closer = '(' else: correct_closer = '{' if lst != []: popped = lst.pop() popped_char = popped['character'] popped_pos = popped['line_number'] popped_offset = popped['bracket_pos'] if popped_char is not correct_closer: message = "Bracket `%s' does not match `%s' at (%d, %d)" message = message % (bracket, popped_char, popped_pos, popped_offset) warning_info = { 'msg': message, 'line': line, 'column': real_pos } msg_stack.append(warning_info) else: # If the list is empty and a closing bracket is found, it means we have # excess brackets. That warning is issued here. The coordinates used # will be slightly or largely off target depending on how much your # code was modified when used with compact mode message = "Unmatched closing bracket `%s'" % bracket warning_info = { 'msg': message, 'line': line, 'column': offset + 1 } msg_stack.append(warning_info) return lst def _push_to_list(lst, func_name, char, line, offset, first_arg_pos, first_item, in_list_literal, lead_spaces, args=None): """ _push_to_list(lst : [str], func_name : str, char : str, line : int, offset : int, first_arg_pos :int , first_item : int, in_list_literal : bool, lead_spaces : int, args : str) Called when an opening bracket is encountered. A hash containing the necessary data to pin point errors and the indentation level is stored in the list and the list returned. """ args = parse_args(args) keywords = add_keywords(args) pos_hash = {'character': char, 'line_number': line, 'bracket_pos': offset, 'indent_level': offset + first_arg_pos, # the default value, e.g in normal function 'func_name': func_name, 'spaces': 0} is_macro = is_macro_name(func_name, args.dialect) two_spacer = is_macro or keywords[func_name] in [KEYWORD1, KEYWORD4] if in_list_literal or char == '{' or (char == '[' and args.dialect == 'clojure'): # found quoted list or clojure hashmap/vector pos_hash['indent_level'] = first_item elif keywords[func_name] == KEYWORD2: # We only make the if-clause stand out if not in uniform mode pos_hash['indent_level'] = lead_spaces + ((offset + args.indent_size * 2) if not args.uniform else (offset + args.indent_size)) elif func_name != '': if two_spacer: pos_hash['indent_level'] = lead_spaces + offset + args.indent_size elif keywords[func_name] == KEYWORD3: pos_hash['indent_level'] = lead_spaces + offset + (2 * args.indent_size) lst.append(pos_hash) try: # A hack to make flets and labels in Lisp not indent like # functions. The 'labels' indentation may not be exactly # perfect. parent_func = lst[-3]['func_name'] # Make 'special' indentation occur only in a Clojure binding block([]) for # letfns non_bind_block = args.dialect == 'clojure' and lst[-2]['character'] != '[' if keywords[parent_func] == KEYWORD4 and not non_bind_block: lst[-1]['indent_level'] = offset + args.indent_size except IndexError: pass return lst def indent_code(original_code, args=None): """ indented_code(string : str, fname : str) -> [...] Arguments: fpath: Simply used in formatting the warning messages >>> indent_code("(print\n'Hello)") {'bracket_locations': [], 'comment_locations': [], 'in_comment': 0, 'in_newlisp_tag_string': False, 'in_string': False, 'in_symbol_with_space': False, 'indented_code': ['(print\n', " 'Hello)"], 'last_quote_location': (), 'last_symbol_location': (), 'message_stack': [], 'newlisp_brace_locations': [], 'original_code': ['(print\n', "'Hello)"], 'first_tag_string': ()} The last entry in the list is the indented string. """ args = parse_args(args) keywords = add_keywords(args) # Safeguards against processing brackets inside strings in_string = False # newLISP use curly brackets as a syntax for multiline strings # this variable here tries to keep track of that in_newlisp_string = 0 in_newlisp_tag_string = False newlisp_brace_locations = [] first_tag_string = () # zero_level helps us get the same results as Sitaram's indenter when in # --no-compact mode. zero_level = 0 # The two variables prevent formatting comment regions or symbols with whitespace in_comment = 0 in_symbol_with_space = False comment_locations = [] last_symbol_location = () # A in_symbol_region is the region between pipes(| |) or in strings. This # includes the comment region. This region is not to be messed with. in_symbol_region = in_string or in_comment or in_symbol_with_space or \ in_newlisp_string or in_newlisp_tag_string # we need to know the line number in order to issue almost accurate messages about # unclosed brackets and string line_number = 1 # Stores the last position a quote was encountered so that in case there are # any unclosed strings, we can pinpoint them last_quote_location = () line_ending = find_line_ending(original_code) code_lines = split_preserve(original_code, line_ending) indented_code = [] bracket_locations = [] # List of warnings from errors in the code message_stack = [] for line in code_lines: escaped = False curr_line = line # Get the indent level and the indented line zero_level, curr_line, indent_level = indent_line(zero_level, bracket_locations, line, in_comment, in_symbol_region, args) # Build up the indented string. indented_code.append(curr_line) regex = '^[ \t]*' lead_spaces = re.findall(regex, curr_line) if lead_spaces: curr_line = re.sub(regex, detabify(lead_spaces[0], args), curr_line) offset = 0 for curr_char in curr_line: next_char = curr_line[offset + 1:offset + 2] prev_char = curr_line[offset - 1:offset] substr = curr_line[offset + 1:] # slice to the end if escaped: # Move to the next character if the current one has been escaped escaped = False offset += 1 continue if curr_char == '\\' and not in_newlisp_string and not in_newlisp_tag_string: # the next character has been escaped escaped = True if (curr_char == ';' or (curr_char == '#' and args.dialect == 'newlisp'))\ and not in_symbol_region and not \ (prev_char == '#' and args.dialect == 'scheme'): # a comment has been found, go to the next line # A sharp sign(#) before a semi-colon in Scheme is used to # comment out sections of code. We don't treat it as a comment break # ---------------------------------------------------------- # Comments are dealt with here. Clojure and newLISP don't have Lisp # style multiline comments so don't include them. if args.dialect not in ['clojure', 'newlisp'] and curr_char == '|' \ and not in_string: if prev_char == '#' and not in_symbol_with_space: comment_locations.append((line_number, offset)) in_comment += 1 elif in_comment and next_char == '#': in_comment -= 1 comment_locations.pop() elif not in_comment: if in_symbol_with_space: last_symbol_location = () in_symbol_with_space = False else: last_symbol_location = (line_number, offset) in_symbol_with_space = True # ---------------------------------------------------------- # Strings are dealt with here only if we are not in a comment if not (in_symbol_with_space or in_comment or in_newlisp_tag_string): if curr_char == '"': last_quote_location = (line_number, offset) in_string = not bool(in_string) if args.dialect == 'newlisp' and not in_string: # We handle newLISP's multiline(brace) string here. Brace # strings can nest if curr_char == '{': newlisp_brace_locations.append((line_number, offset)) in_newlisp_string += 1 elif curr_char == '}': if newlisp_brace_locations: newlisp_brace_locations.pop() else: message = "Attempt to close a non-existent newLISP string" warning_info = { 'msg': message, 'line': line_number, 'column': offset } message_stack.append(warning_info) in_newlisp_string -= 1 if curr_char == '[' and args.dialect == 'newlisp' and not \ (in_newlisp_string or in_string): # We have to handle tag strings in newLISP here. if re.match('\[text\]', curr_line[offset:offset + 7]): in_newlisp_tag_string = True if first_tag_string == (): first_tag_string = (line_number, offset) elif re.match('\[/text\]', curr_line[offset:offset + 7]): in_newlisp_tag_string = False first_tag_string = () in_symbol_region = in_string or in_comment or in_symbol_with_space \ or in_newlisp_string or in_newlisp_tag_string if in_symbol_region: # move on if we are in a string, a symbol with a space or a comment # altogether known as the symbol region offset += 1 continue # Finds the real position of a bracket to be used in pinpointing where # the unclosed bracket is. The real position is different from the offset # because current offset is the position of the bracket in the # trimmed string not the original. real_position = (offset - zero_level) + \ len(re.findall('^[ \t]*', line)[0]) - indent_level if curr_char in ['(', '[', '{']: if curr_char in ['[', '{'] and args.dialect in ['lisp', 'newlisp']: # Square/Curly brackets are used should not contribute to # the indentation in CL and newLISP offset += 1 continue first_arg_pos, spaces_before_func = \ find_first_arg_pos(offset, curr_line, args) func_name = substr[0:first_arg_pos - 1].strip(')]\t\n\r ').lower() in_list_literal = False if re.search("[^#]('|`|#)([ \t]*\(|\[)($|\r)", curr_line[0:offset + 1]): in_list_literal = True if re.search('^[^ \t]+[ \t]*($|\r)', substr): # The function is the last symbol/form in the line func_name = substr.strip(')]\t\n\r ').lower() if in_list_literal: # an empty string is always in a non-empty string, we don't want # this. We set False as the func_name because it's not a string # in_list_literal prevents an keyword in a list literal from # affecting the indentation func_name = '' if func_name in ['define-macro', 'defmacro']: # Macro names are part of two space indenters. # This part tries to find the name so that it is not indented # like a function the next time it's used. end_of_space = re.search('^[ \t]*', substr).end() substr = substr[end_of_space:] substr = substr[re.search('[ \t]*', substr).start():].strip() macro_name = substr[:substr.find(' ')] # macro name is delimeted by whitespace if macro_name != '': keywords[macro_name] = KEYWORD1 # first_item stores the position of the first item in the literal list # it's necessary so that we don't assume that the first item is always # after the opening bracket. first_item = re.search('[ \t]*', curr_line[offset + 1:]).end() + offset + 1 bracket_locations = _push_to_list(bracket_locations[:], func_name, curr_char, line_number, offset, first_arg_pos, first_item, in_list_literal, spaces_before_func, args) elif curr_char in [']', ')', '}']: if curr_char in [']', '}'] and args.dialect in ['lisp', 'newlisp']: # Square/Curly brackets are used should not contribute to # the indentation in CL and newLISP offset += 1 continue bracket_locations = _pop_from_list(curr_char, bracket_locations[:], line_number, real_position, offset, message_stack) if bracket_locations and curr_char in [' ', '\t'] and \ keywords[bracket_locations[-1]['func_name']] == KEYWORD2: # This part changes the indentation level of a then clause so that # we can achieve something like: # (if (= this that) # 'then-form # 'else-form) # This is done by keeping track of the number of spaces found. If # you find two spaces it means that, for example that we have just # passed the then-form and hence should decrease the indentation # level by 2.(I shamelessly copied this algorithm from Dorai's # indenter) if prev_char not in [' ', '\t', ''] or not \ re.search('^[ \t]*(;|#\||$|\r)', curr_line): # The level shouldn't be decreased if the line is a comment # line. The regex above takes care of that. bracket_locations[-1]['spaces'] += 1 if bracket_locations[-1]['spaces'] == 2: bracket_locations[-1]['indent_level'] -= \ 0 if args.uniform else args.indent_size # some dummy value to prevent control from reaching here again bracket_locations[-1]['spaces'] = 999 offset += 1 line_number += 1 res = { 'message_stack': message_stack, 'first_tag_string': first_tag_string, 'in_newlisp_tag_string': in_newlisp_tag_string, 'last_symbol_location': last_symbol_location, 'comment_locations': comment_locations, 'newlisp_brace_locations': newlisp_brace_locations, 'in_string': in_string, 'in_comment': in_comment, 'in_symbol_with_space': in_symbol_with_space, 'bracket_locations': bracket_locations, 'last_quote_location': last_quote_location, 'original_code': code_lines, 'indented_code': indented_code } return res def colour_diff(diff_lines): """ colour_diff(diff_lines : lst) Print diff text to terminal in color """ try: import colorama except ImportError: # colorama is not available, print plain diff print(''.join(list(diff_lines))) return colorama.init() def p_green(text): """ Print added line in green """ print(colorama.Fore.GREEN + text + colorama.Fore.WHITE, end='') def p_yellow(text): """ Print diff section header in yellow """ print(colorama.Fore.YELLOW + text + colorama.Fore.WHITE, end='') def p_red(text): """ Print removed line in red """ print(colorama.Fore.RED + text + colorama.Fore.WHITE, end='') section = re.compile('@@\s+-\d\d,\d\d\s\+\d\d,\d\d\s+@@') for line in diff_lines: if line.startswith('-'): p_red(line) elif line.startswith('+'): p_green(line) elif section.search(line): p_yellow(line) else: print(line, end='') def _post_indentation(res, args=None, fpath=''): """ _post_indentation(res : dict): Called after the string has been indented appropriately. It takes care of writing the file and checking for unclosed strings or comments. """ fname = os.path.basename(fpath) args = parse_args(args) for msg in res['message_stack']: if args.warning: if args.files: msg['fname'] = fname sys.stderr.write('\n{fname}:{line}:{column}: {msg}'.format(**msg)) else: # Input was passed through stdin sys.stderr.write('\n:{line}:{column}: {msg}'.format(**msg)) if res['bracket_locations']: # If the bracket_locations list is not empty it means that there are some # brackets(opening) that haven't been closed. for bracket in res['bracket_locations']: line = bracket['line_number'] column = bracket['bracket_pos'] character = bracket['character'] # The bracket_locations are not very accurate. The warning might be # misleading because it considers round and square brackets to be # the same. message = "\n%s:%d:%d: Unmatched `%s'" if args.warning: sys.stderr.write(message % (fname, line, column, character)) if res['newlisp_brace_locations']: for brace in res['newlisp_brace_locations']: message = "\n%s:%d:%d: Unclosed newLISP brace string" if args.warning: sys.stderr.write(message % (fname, brace[0], brace[1])) if res['comment_locations']: for comment in res['comment_locations']: message = "\n%s:%d:%d: Unclosed multiline comment" tpl = (fname,) + comment if args.warning: sys.stderr.write(message % tpl) if res['last_symbol_location']: message = "\n%s:%d:%d: Unclosed symbol" tpl = (fname,) + res['last_symbol_location'] if args.warning: sys.stderr.write(message % tpl) if res['in_string']: message = "\n%s:%d:%d: String extends to end-of-file" tpl = (fname,) + res['last_quote_location'] if args.warning: sys.stderr.write(message % tpl) if res['in_newlisp_tag_string']: message = "\n%s:%d:%d: Tag string extends to end-of-file" tpl = (fname,) + res['first_tag_string'] if args.warning: sys.stderr.write(message % tpl) output_file = args.output_file if not output_file: output_file = fpath indented_code = res['indented_code'] indent_result = ''.join(indented_code) if indented_code == res['original_code'] and args.files: message = "File '%s' has already been formatted. Leaving it unchanged...\n" sys.stderr.write(message % fname) if output_file != fpath: with open(output_file, 'wb') as indented_file: indented_file.write(indent_result.encode('utf8')) else: if args.output_diff: diff = difflib.unified_diff(res['original_code'], indented_code, n=5) if args.colour_diff: colour_diff(diff) else: print(''.join(list(diff))) elif args.output: print(indent_result, end='') if args.modify: # write in binary mode to preserve the original line ending with open(output_file, 'wb') as indented_file: indented_file.write(indent_result.encode('utf8')) def indent_files(arguments): """ indent_files(arguments) Note: if the parallel option is provided, the files will be read and processed in parallel """ args = parse_args(arguments) if not args.files: # Indent from stdin code = sys.stdin.read() indent_result = indent_code(code, args) _post_indentation(indent_result) if args.parallel: import multiprocessing pool = multiprocessing.Pool(multiprocessing.cpu_count()) pool.starmap(indent_file, [(fname, args) for fname in args.files]) else: for fname in args.files: indent_file(fname, args) def indent_file(fname, args): """ indent_file(fname: string, args) 1. Create a backup of the source file(backup_source_file()) 2. Read the file contents(read_file()) 3. Indent the code(indent_code()) 4. Write to the file or print the indented code(_post_indentation()) """ args = parse_args(args) fname = os.path.expanduser(fname) code = read_file(fname) if not args.dialect: # Guess dialect from the file extensions if none is specified in the command # line if fname.endswith('.lisp'): args.dialect = 'lisp' elif fname.endswith('.lsp'): args.dialect = 'newlisp' elif re.search(".clj[sc]{0,1}$", fname): args.dialect = 'clojure' elif fname.endswith('.ss') or fname.endswith('.scm'): args.dialect = 'scheme' else: args.dialect = 'all' indent_result = indent_code(code, args) if args.backup: # Create a backup file in the specified directory backup_source_file(fname, args) _post_indentation(indent_result, fpath=fname) def main(): """ Entry point """ indent_files(sys.argv[1:]) if __name__ == '__main__': main()
[ 2, 48443, 14629, 14, 8800, 14, 24330, 21015, 198, 2, 19617, 25, 3384, 69, 12, 23, 198, 198, 37811, 331, 17053, 198, 198, 10430, 25, 1160, 400, 3389, 2211, 198, 13838, 25, 299, 74, 6759, 6391, 1279, 74, 541, 74, 2577, 354, 6759, 63...
2.214076
18,713
import asyncio from collections import deque from . import * CmdHelp("animoji").add_command( 'think', None, 'Use and see' ).add_command( 'ccry', None, 'Use and see' ).add_command( 'fap', None, 'Use and see' ).add_command( 'lmao', None, 'Use and see' ).add_command( 'nothappy', None, 'Use and see' ).add_command( 'clock', None, 'Use and see' ).add_command( 'muah', None, 'Use and see' ).add_command( 'heart', None, 'Use and see' ).add_command( 'gym', None, 'Use and see' ).add_command( 'earth', None, 'Use and see' ).add_command( 'moon', None, 'Use and see' ).add_command( 'lovestory', None, 'Turu Lob' ).add_command( 'smoon', None, 'Use and see' ).add_command( 'tmoon', None, 'Use and see' ).add_command( 'hart', None, 'Use and see' ).add_command( 'anim', None, 'Use and see' ).add_command( 'fuck', None, 'Use and see' ).add_command( 'sux', None, 'Use and see' ).add_command( 'kiss', None, 'Kya dekh rha h jhopdike.' ).add_command( 'fnl', None, 'Use and See.' ).add_command( 'monkey', None, 'Use and see.' ).add_command( 'hand', None, 'Use and See.' ).add_command( 'gsg', None, 'Use and See.' ).add_command( 'theart', None, 'Hearts Animation.' ).add()
[ 11748, 30351, 952, 198, 6738, 17268, 1330, 390, 4188, 198, 198, 6738, 764, 1330, 1635, 628, 628, 628, 628, 628, 628, 628, 628, 628, 628, 198, 40109, 22087, 7203, 11227, 31370, 11074, 2860, 62, 21812, 7, 198, 220, 705, 14925, 3256, 604...
2.486762
491
from deap import base from deap import creator from deap import tools import random import numpy import mlp_layers_test import elitism # boundaries for layer size parameters: # [layer_layer_1_size, hidden_layer_2_size, hidden_layer_3_size, hidden_layer_4_size] BOUNDS_LOW = [ 5, -5, -10, -20] BOUNDS_HIGH = [15, 10, 10, 10] NUM_OF_PARAMS = len(BOUNDS_HIGH) # Genetic Algorithm constants: POPULATION_SIZE = 20 P_CROSSOVER = 0.9 # probability for crossover P_MUTATION = 0.5 # probability for mutating an individual MAX_GENERATIONS = 10 HALL_OF_FAME_SIZE = 3 CROWDING_FACTOR = 10.0 # crowding factor for crossover and mutation # set the random seed: RANDOM_SEED = 42 random.seed(RANDOM_SEED) # create the classifier accuracy test class: test = mlp_layers_test.MlpLayersTest(None) toolbox = base.Toolbox() # define a single objective, maximizing fitness strategy: creator.create("FitnessMax", base.Fitness, weights=(1.0,)) # create the Individual class based on list: creator.create("Individual", list, fitness=creator.FitnessMax) # define the layer_size_attributes individually: for i in range(NUM_OF_PARAMS): # "layer_size_attribute_0", "layer_size_attribute_1", ... toolbox.register("layer_size_attribute_" + str(i), random.uniform, BOUNDS_LOW[i], BOUNDS_HIGH[i]) # create a tuple containing an layer_size_attribute generator for each hidden layer: layer_size_attributes = () for i in range(NUM_OF_PARAMS): layer_size_attributes = layer_size_attributes + \ (toolbox.__getattribute__("layer_size_attribute_" + str(i)),) # create the individual operator to fill up an Individual instance: toolbox.register("individualCreator", tools.initCycle, creator.Individual, layer_size_attributes, n=1) # create the population operator to generate a list of individuals: toolbox.register("populationCreator", tools.initRepeat, list, toolbox.individualCreator) # fitness calculation toolbox.register("evaluate", classificationAccuracy) # genetic operators:mutFlipBit # genetic operators: toolbox.register("select", tools.selTournament, tournsize=2) toolbox.register("mate", tools.cxSimulatedBinaryBounded, low=BOUNDS_LOW, up=BOUNDS_HIGH, eta=CROWDING_FACTOR) toolbox.register("mutate", tools.mutPolynomialBounded, low=BOUNDS_LOW, up=BOUNDS_HIGH, eta=CROWDING_FACTOR, indpb=1.0/NUM_OF_PARAMS) # Genetic Algorithm flow: if __name__ == "__main__": main()
[ 6738, 390, 499, 1330, 2779, 198, 6738, 390, 499, 1330, 13172, 198, 6738, 390, 499, 1330, 4899, 198, 198, 11748, 4738, 198, 11748, 299, 32152, 198, 198, 11748, 25962, 79, 62, 75, 6962, 62, 9288, 198, 11748, 1288, 18937, 198, 198, 2, ...
2.325444
1,183
# -*- coding: utf-8 -*- """ MIT License Copyright (c) 2016 Aarn Abraham Velasco Alvarez Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. """ input = { "alpha" : 0, "numeric" : 1, "<" : 2, "%" : 3, "?" : 4, "/" : 5, "=" : 6, ">" : 7, "#" : 8, "*" : 9, "+" : 10, "-" : 11, "." : 12, "'" : 13, "\"" : 14, "\\" : 15, "$" : 16, "_" : 17, "!" : 18, "`" : 19 , "&" : 20, "|" : 21, ":" : 22, "\n" : 23, " " : 24 } errors = { 1 : "Parse error, unexpected input", 2 : "Parse error, unexpected '</'", 3 : "Parse error, expecting '>'", 4 : "Unterminated comment", 5 : "Parse error, expecting \"'\"", 6 : "Parse error, expecting '`'", 7 : "Parse error, expecting variable (T_VARIABLE) or '{' or '$'", 8 : "Unterminated tag", 9 : "Parse error, expecting '.'" } #TODO Cdigo embebido table = { 0 : ((60, 28, 1 , 3 , 2 , 21, 42, 44, 20, 41, 26, 27, 29, 34, 35, 0 , 58, 60, 43, 45, 46, 47, 63, 0 , 0 , 0 ), False, 0 , 1), 1 : ((-3, 0 , 8 , 5 , 6 , 4 , 10, 9 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 ), True , 19, 1), 2 : ((0 , 0 , 0 , 0 , 11, 0 , 0 , 12, 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 11, 0 , 0 , 0 ), True , 105,1), 3 : ((0 , 0 , 0 , 0 , 0 , 0 , 13, 14, 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 ), True , 16, 1), 4 : ((15, 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 ), False, 0 , 2), 5 : ((0 , 0 , 0 , 0 , 0 , 0 , 16, 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 ), True , 5 , 1), 6 : ((18, 0 , 0 , 0 , 0 , 0 , 17, 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 ), True , 2 , 1), 7 : ((7 , 7 , 0 , 7 , 7 , 7 , 7 , 72, 7 , 7 , 7 , 7 , 7 , 65, 66, 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 0 , 7 , 7 ), False, 0 , 8), 8 : ((0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 ), True , 18, 1), 9 : ((0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 ), True , 30, 1), 10 : ((0 , 0 , 0 , 0 , 0 , 0 , 0 , 11, 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 ), True , 19, 1), 11 : ((0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 ), True , 19, 1), 12 : ((0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 ), True , 7 , 1), 13 : ((0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 ), True , 17, 1), 14 : ((0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 ), True , 8 , 1), 15 : ((15, 15, 0 , 0 , 0 , 0 , 0 , 19, 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 ), False, 0 , 3), 16 : ((0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 ), True , 6 , 1), 17 : ((0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 ), True , 3 , 1), 18 : ((18, 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 ), True , 1 , 1), 19 : ((0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 ), True , 9 , 1), 20 : ((20, 20, 20, -1, -1, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 0 , 20, 20), True , 26, 1), 21 : ((0 , 0 , 0 , 0 , 0 , 20, 23, 0 , 0 , 22, 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 ), True , 16, 1), 22 : ((22, 22, 22, 22, 22, 22, 22, 22, 22, 24, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22), False, 0 , 4), 23 : ((0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 ), True , 17, 1), 24 : ((22, 22, 22, 22, 22, 25, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22), False, 0 , 4), 25 : ((0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 ), True , 26, 1), 26 : ((0 , 28, 0 , 0 , 0 , 0 , 30, 0 , 0 , 0 , 31, 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 ), True , 29, 1), 27 : ((0 , 28, 0 , 0 , 0 , 0 , 30, 0 , 0 , 0 , 0 , 31, 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 ), True , 25, 1), 28 : ((0 , 28, 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 32, 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 ), True , 11, 1), 29 : ((0 , 33, 0 , 0 , 0 , 0 , 30, 0 , 0 , 0 , 0 , 0 , 61, 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 ), True , 28, 1), 30 : ((0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 ), True , 17, 1), 31 : ((0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 ), True , 22, 1), 32 : ((0 , 33, 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 ), True , 11, 1), 33 : ((0 , 33, 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 ), True , 11, 1), 34 : ((34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 40, 34, 36, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34), False, 0 , 5), 35 : ((35, 35, 35, 35, 35, 35, 35, 35, 35, 35, 35, 35, 35, 35, 40, 37, 35, 35, 35, 35, 35, 35, 35, 35, 35, 35), False, 0 , 5), 36 : ((34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 38, 34, 38, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34), False, 0 , 5), 37 : ((35, 35, 35, 35, 35, 35, 35, 35, 35, 35, 35, 35, 35, 35, 39, 39, 35, 35, 35, 35, 35, 35, 35, 35, 35, 35), False, 0 , 5), 38 : ((34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 40, 34, 36, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34), False, 0 , 5), 39 : ((35, 35, 35, 35, 35, 35, 35, 35, 35, 35, 35, 35, 35, 35, 40, 37, 35, 35, 35, 35, 35, 35, 35, 35, 35, 35), False, 0 , 5), 40 : ((0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 ), True , 12, 1), 41 : ((0 , 0 , 0 , 0 , 0 , 0 , 49, 0 , 0 , 48, 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 ), True , 16, 1), 42 : ((0 , 0 , 0 , 0 , 0 , 0 , 50, 49, 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 ), True , 106, 1), 43 : ((0 , 0 , 0 , 0 , 0 , 0 , 50, 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 ), True , 24, 1), 44 : ((0 , 0 , 0 , 0 , 0 , 0 , 51, 52, 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 ), True , 19, 1), 45 : ((45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 53, 45, 45, 45, 57, 45, 45, 45, 45, 45, 45), False, 0 , 6), 46 : ((0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 54, 0 , 0 , 0 , 0 , 0 ), True , 18, 1), 47 : ((0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 54, 0 , 0 , 0 , 0 ), True , 18, 1), 48 : ((0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 ), True , 16, 1), 49 : ((0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 ), True , 17, 1), 50 : ((0 , 0 , 0 , 0 , 0 , 0 , 55, 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 ), True , 30, 1), 51 : ((0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 ), True , 19, 1), 52 : ((0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 ), True , 18, 1), 53 : ((45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 56, 45, 45, 45, 56, 45, 45, 45, 45, 45, 45), False, 0 , 6), 54 : ((0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 ), True , 23, 1), 55 : ((0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 ), True , 30, 1), 56 : ((45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 53, 45, 45, 45, 57, 45, 45, 45, 45, 45, 45), False, 0 , 6), 57 : ((0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 ), True , 21, 1), 58 : ((59, 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 58, 59, 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 ), False, 0 , 7), 59 : ((59, 59, 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 59, 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 ), True , 14, 1), 60 : ((60, 60, 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 60, 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 ), True , 15, 1), 61 : ((0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 62, 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 ), False, 0 , 9), 62 : ((0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 ), True , 103, 1), 63 : ((0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 64, 0 , 0 , 0 ), True , 107, 1), 64 : ((0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 ), True , 104, 1), 65 : ((65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 7 , 65, 67, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65), False, 0 , 5), 66 : ((66, 66, 66, 66, 66, 66, 66, 66, 66, 66, 66, 66, 66, 66, 7 , 69, 66, 66, 66, 66, 66, 66, 66, 66, 66, 66), False, 0 , 5), 67 : ((65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 70, 65, 70, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65), False, 0 , 5), 69 : ((66, 66, 66, 66, 66, 66, 66, 66, 66, 66, 66, 66, 66, 66, 71, 71, 66, 66, 66, 66, 66, 66, 66, 66, 66, 66), False, 0 , 5), 70 : ((65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 7 , 65, 67, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65), False, 0 , 5), 71 : ((66, 66, 66, 66, 66, 66, 66, 66, 66, 66, 66, 66, 66, 66, 7 , 69, 66, 66, 66, 66, 66, 66, 66, 66, 66, 66), False, 0 , 5), 72 : ((-11, 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 ), True , 4 , 1), -1 : ((0 , 0 , 0 , 0 , 0 , 0 , 0 , -2, 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 ), False, 100, 1), -2 : ((0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 ), True , 0, 1), -3 : ((-3, -3, 0 , -3, -3, -3, -3, -10, -3, -3, -3, -3, -3, -4, -5, -3, -3, -3, -3, -3, -3, -3, -3, 0, -3, -3), True , 0 , 1), -4 : ((-4, -4, -4, -4, -4, -4, -4, -4 , -4, -4, -4, -4, -4, -3, -4, -6, -4, -4, -4, -4, -4, -4, -4, -4, -4, -4), True , 0 , 1), -5 : ((-5, -5, -5, -5, -5, -5, -5, -5 , -5, -5, -5, -5, -5, -5, -3, -7, -5, -5, -5, -5, -5, -5, -5, -5, -5, -5), True , 0 , 1), -6 : ((-4, -4, -4, -4, -4, -4, -4, -4 , -4, -4, -4, -4, -4, -8, -4, -8, -4, -4, -4, -4, -4, -4, -4, -4, -4, -4), True , 0 , 1), -7 : ((-5, -5, -5, -5, -5, -5, -5, -5 , -5, -5, -5, -5, -5, -5, -9, -9, -5, -5, -5, -5, -5, -5, -5, -5, -5, -5), True , 0 , 1), -8 : ((-4, -4, -4, -4, -4, -4, -4, -4 , -4, -4, -4, -4, -4, -3, -4, -6, -4, -4, -4, -4, -4, -4, -4, -4, -4, -4), True , 0 , 1), -9 : ((-5, -5, -5, -5, -5, -5, -5, -5 , -5, -5, -5, -5, -5, -5, -3, -7, -5, -5, -5, -5, -5, -5, -5, -5, -5, -5), True , 0 , 1), -10 : ((0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 ), False, 101, 1), -11 : ((-11,-11,-12,-11,-11,-11,-11,-11,-11,-11,-11,-11,-11,-11,-11,-11,-11,-11,-11,-11,-11,-11,-11,-11,-11,-11), True , 0 , 1), -12 : ((-14, 0 , 0 , 0 , 0 ,-13, 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 ), True , 0 , 1), -13 : ((-21, 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 ), True , 0 , 1), -14 : ((-14,-14, 0 ,-14,-14,-14,-14,-22,-14,-14,-14,-14,-14,-15,-16,-14,-14,-14,-14,-14,-14,-14,-14, 0 ,-14,-14), True , 0 , 1), -15 : ((-15,-15,-15,-15,-15,-15,-15,-15,-15,-15,-15,-15,-15,-14,-15,-17,-15,-15,-15,-15,-15,-15,-15,-15,-15,-15), True , 0 , 1), -16 : ((-16,-16,-16,-16,-16,-16,-16,-16,-16,-16,-16,-16,-16,-16,-14,-18,-16,-16,-16,-16,-16,-16,-16,-16,-16,-16), True , 0 , 1), -17 : ((-15,-15,-15,-15,-15,-15,-15,-15,-15,-15,-15,-15,-15,-19,-15,-19,-15,-15,-15,-15,-15,-15,-15,-15,-15,-15), True , 0 , 1), -18 : ((-16,-16,-16,-16,-16,-16,-16,-16,-16,-16,-16,-16,-16,-16,-20,-20,-16,-16,-16,-16,-16,-16,-16,-16,-16,-16), True , 0 , 1), -19 : ((-15,-15,-15,-15,-15,-15,-15,-15,-15,-15,-15,-15,-15,-14,-15,-17,-15,-15,-15,-15,-15,-15,-15,-15,-15,-15), True , 0 , 1), -20 : ((-16,-16,-16,-16,-16,-16,-16,-16,-16,-16,-16,-16,-16,-16,-14,-18,-16,-16,-16,-16,-16,-16,-16,-16,-16,-16), True , 0 , 1), -21 : ((-21,-21, 0 , 0 , 0 , 0 , 0 ,-22, 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 ), True , 0 , 1), -22 : (( 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 ), True , 102, 1), 100: ((0 , 0 , 0 , 20, 20, 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 ), True , 26, 1), 101: ((7 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 ), True , 19, 1), 102: ((103, 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 ), False, 0 , 1), 103: ((103, 103, 0, 103, 103, 103, 103, 103, 103, 103, 103, 103, 103, 103, 103, 103, 103, 103, 103, 103, 103, 103, 103, 103, 103, 103), True , 126, 1) }
[ 2, 532, 9, 12, 19617, 25, 3384, 69, 12, 23, 532, 9, 12, 198, 198, 37811, 198, 36393, 13789, 198, 198, 15269, 357, 66, 8, 1584, 317, 1501, 16660, 17378, 292, 1073, 36952, 198, 198, 5990, 3411, 318, 29376, 7520, 11, 1479, 286, 3877,...
2.04195
7,056
import re SMS_CHAR_COUNT_LIMIT = 612 # 153 * 4 # regexes for use in recipients.validate_email_address. # Valid characters taken from https://en.wikipedia.org/wiki/Email_address#Local-part # Note: Normal apostrophe eg `Firstname-o'surname@domain.com` is allowed. hostname_part = re.compile(r"^(xn-|[a-z0-9]+)(-[a-z0-9]+)*$", re.IGNORECASE) tld_part = re.compile(r"^([a-z]{2,63}|xn--([a-z0-9]+-)*[a-z0-9]+)$", re.IGNORECASE) VALID_LOCAL_CHARS = r"a-zA-Z-0-9.!#$%&'*+/=?^_`{|}~\-" EMAIL_REGEX_PATTERN = r"^[{}]+@([^.@][^@\s]+)$".format(VALID_LOCAL_CHARS) email_with_smart_quotes_regex = re.compile( # matches wider than an email - everything between an at sign and the nearest whitespace r"(^|\s)\S+@\S+(\s|$)", flags=re.MULTILINE, )
[ 11748, 302, 198, 198, 50, 5653, 62, 38019, 62, 34, 28270, 62, 43, 3955, 2043, 796, 718, 1065, 220, 1303, 24652, 1635, 604, 198, 198, 2, 40364, 274, 329, 779, 287, 20352, 13, 12102, 378, 62, 12888, 62, 21975, 13, 198, 2, 48951, 343...
2.131429
350
import time
[ 11748, 640 ]
5.5
2
from jsonclasses.cgraph import CGraph from .import_lines import import_lines from .string_query import string_query from .int_query import int_query from .float_query import float_query from .bool_query import bool_query from .sort_order import sort_order from .data_enum import data_enum from .data_class import data_class from .session_items import session_items from .session import session from .response import response_struct from .user_default import user_default from .session_manager import session_manager from .sign_out import sign_out from .request_manager import request_manager from ...utils.join_lines import join_lines
[ 6738, 33918, 37724, 13, 66, 34960, 1330, 29925, 1470, 198, 6738, 764, 11748, 62, 6615, 1330, 1330, 62, 6615, 198, 6738, 764, 8841, 62, 22766, 1330, 4731, 62, 22766, 198, 6738, 764, 600, 62, 22766, 1330, 493, 62, 22766, 198, 6738, 764,...
3.825301
166
"""Useful utils """ from .eval import * from .misc import * # progress bar from .progress.progress.bar import Bar as Bar
[ 37811, 11041, 913, 3384, 4487, 198, 37811, 198, 6738, 764, 18206, 1330, 1635, 198, 6738, 764, 44374, 1330, 1635, 198, 2, 4371, 2318, 198, 6738, 764, 33723, 13, 33723, 13, 5657, 1330, 2409, 355, 2409, 198 ]
3.361111
36
import zeep import asyncio, sys from onvif import ONVIFCamera import cv2 import numpy as np import urllib from urllib.request import urlopen IP="192.168.2.22" # Camera IP address PORT=80 # Port USER="admin" # Username PASS="C0nc3ll0M4r1n" # Password XMAX = 1 XMIN = -1 YMAX = 1 YMIN = -1 moverequest = None ptz = None active = False zeep.xsd.simple.AnySimpleType.pythonvalue = zeep_pythonvalue if __name__ == '__main__': # url_to_image('http://192.168.1.108/onvifsnapshot/media_service/snapshot?channel=1&subtype=0') # setup_move() camera = CameraController() camera.get_presets() camera.get_current_preset()
[ 11748, 41271, 538, 198, 11748, 30351, 952, 11, 25064, 198, 6738, 319, 85, 361, 1330, 6177, 12861, 4851, 18144, 198, 11748, 269, 85, 17, 198, 11748, 299, 32152, 355, 45941, 198, 11748, 2956, 297, 571, 198, 6738, 2956, 297, 571, 13, 259...
2.408759
274
from string import ascii_lowercase, digits from random import choice from re import compile
[ 6738, 4731, 1330, 355, 979, 72, 62, 21037, 7442, 11, 19561, 198, 6738, 4738, 1330, 3572, 198, 6738, 302, 1330, 17632, 198 ]
4.181818
22
from django.contrib import admin from .models import Comment
[ 6738, 42625, 14208, 13, 3642, 822, 1330, 13169, 198, 6738, 764, 27530, 1330, 18957, 628 ]
4.133333
15
import numpy as np from typing import Dict, List from monty.json import MSONable from pymatgen.core.structure import Structure from pymatgen.symmetry.groups import SymmOp from DiSPy.core.dg import DistortionGroup from DiSPy.core.vecutils import closewrapped # -- Path object and its attributes
[ 11748, 299, 32152, 355, 45941, 198, 6738, 19720, 1330, 360, 713, 11, 7343, 198, 6738, 40689, 88, 13, 17752, 1330, 6579, 1340, 540, 198, 6738, 279, 4948, 265, 5235, 13, 7295, 13, 301, 5620, 1330, 32522, 198, 6738, 279, 4948, 265, 5235,...
3.204301
93
from django.db import models import datetime as dt from django.urls import reverse # Create your models here. from cloudinary.models import CloudinaryField # class Post(models.Model): # title = models.CharField(max_length=200) # author = models.ForeignKey('auth.User', # on_delete=models.CASCADE,) # body = models.TextField() # def __str__(self): # return self.title
[ 6738, 42625, 14208, 13, 9945, 1330, 4981, 198, 11748, 4818, 8079, 355, 288, 83, 198, 6738, 42625, 14208, 13, 6371, 82, 1330, 9575, 198, 2, 13610, 534, 4981, 994, 13, 628, 198, 6738, 6279, 3219, 13, 27530, 1330, 10130, 3219, 15878, 628...
2.526946
167
from datetime import date, timedelta from allocation.domain import events from allocation.domain.model import Product, OrderLine, Batch today = date.today() tomorrow = today + timedelta(days=1) later = tomorrow + timedelta(days=10)
[ 6738, 4818, 8079, 1330, 3128, 11, 28805, 12514, 198, 6738, 20157, 13, 27830, 1330, 2995, 198, 6738, 20157, 13, 27830, 13, 19849, 1330, 8721, 11, 8284, 13949, 11, 347, 963, 198, 198, 40838, 796, 3128, 13, 40838, 3419, 198, 39532, 6254, ...
3.640625
64
# -*- coding: utf-8 -*- ''' :codeauthor: Jayesh Kariya <jayeshk@saltstack.com> ''' # Import Python libs from __future__ import absolute_import, print_function, unicode_literals # Import Salt Testing Libs from tests.support.mixins import LoaderModuleMockMixin from tests.support.unit import TestCase from tests.support.mock import ( MagicMock, patch ) # Import Salt Libs import salt.utils.json import salt.states.grafana as grafana from salt.exceptions import SaltInvocationError
[ 2, 532, 9, 12, 19617, 25, 3384, 69, 12, 23, 532, 9, 12, 198, 7061, 6, 198, 220, 220, 220, 1058, 8189, 9800, 25, 9180, 5069, 509, 2743, 3972, 1279, 33708, 5069, 74, 31, 82, 2501, 25558, 13, 785, 29, 198, 7061, 6, 198, 2, 17267,...
2.975904
166
# 5 7 # 0 1 1 # 0 2 3 # 1 2 3 # 1 3 6 # 2 3 4 # 2 4 2 # 3 4 5 import sys import heapq as hq N, M = map(int, sys.stdin.readline().split(" ")) W = [[float('inf')] * N for _ in range(N)] h = [] for _ in range(M): i, j, w = map(int, sys.stdin.readline().split(" ")) hq.heappush(h, (w, i, j)) print(h) print(Kruskal(h, 0))
[ 2, 642, 767, 198, 2, 657, 352, 352, 198, 2, 657, 362, 513, 198, 2, 352, 362, 513, 198, 2, 352, 513, 718, 198, 2, 362, 513, 604, 198, 2, 362, 604, 362, 198, 2, 513, 604, 642, 198, 198, 11748, 25064, 198, 11748, 24575, 80, 355...
1.981928
166
#from flask_restful import Resource, reqparse from flask_restplus import Resource, reqparse,fields from models import UserModel, RevokedTokenModel from flask_jwt_extended import (create_access_token, create_refresh_token, jwt_required, jwt_refresh_token_required, get_jwt_identity, get_raw_jwt) from run import api parser = reqparse.RequestParser() parser.add_argument('username', help = 'This field cannot be blank', required = True) parser.add_argument('password', help = 'This field cannot be blank', required = True) param = api.model('User registration', {'username' : fields.String('username'), 'password' : fields.String('password')}) param = api.model('User login', {'username' : fields.String('username'), 'password' : fields.String('password')})
[ 2, 6738, 42903, 62, 2118, 913, 1330, 20857, 11, 43089, 29572, 198, 6738, 42903, 62, 2118, 9541, 1330, 20857, 11, 43089, 29572, 11, 25747, 198, 6738, 4981, 1330, 11787, 17633, 11, 5416, 6545, 30642, 17633, 198, 6738, 42903, 62, 73, 46569...
3.420354
226
"""common parser argument """ # pylint: disable=missing-docstring # pylint: disable=too-few-public-methods import argparse from enum import Enum import logging from sys import exit as sys_exit from . import archivist from .logger import set_logger from .proof_mechanism import ProofMechanism LOGGER = logging.getLogger(__name__) # from https://stackoverflow.com/questions/43968006/support-for-enum-arguments-in-argparse def common_parser(description): """Construct parser with security option for token/auth authentication""" parser = argparse.ArgumentParser( description=description, ) parser.add_argument( "-v", "--verbose", dest="verbose", action="store_true", default=False, help="print verbose debugging", ) parser.add_argument( "-u", "--url", type=str, dest="url", action="store", default="https://rkvst.poc.jitsuin.io", help="location of Archivist service", ) parser.add_argument( "-p", "--proof-mechanism", type=ProofMechanism, action=EnumAction, dest="proof_mechanism", default=ProofMechanism.SIMPLE_HASH, help="mechanism for proving the evidence for events on the Asset", ) security = parser.add_mutually_exclusive_group(required=True) security.add_argument( "-t", "--auth-token", type=str, dest="auth_token_file", action="store", default=".auth_token", reqyuired=True, help="FILE containing API authentication token", ) return parser, security
[ 37811, 11321, 30751, 4578, 198, 37811, 198, 198, 2, 279, 2645, 600, 25, 220, 15560, 28, 45688, 12, 15390, 8841, 198, 2, 279, 2645, 600, 25, 220, 15560, 28, 18820, 12, 32146, 12, 11377, 12, 24396, 82, 628, 198, 11748, 1822, 29572, 19...
2.416667
684
"""Support for the UserData resource in Skytap. Specifically, this is for custom ('user data') that's applied to an environment or VM. This data can be text or, in the context of using it with this Skytap script, it can also be JSON or YAML and will then be re-parsed. This allows users to put data into a VM user data block and it'll filter down and be accessible to this script. We use this to expose variables to the user like shutdown time and other automation pieces. """ from skytap.framework.ApiClient import ApiClient import skytap.framework.Utils as Utils from skytap.models.SkytapResource import SkytapResource
[ 37811, 15514, 329, 262, 11787, 6601, 8271, 287, 5274, 44335, 13, 198, 198, 48379, 11, 428, 318, 329, 2183, 19203, 7220, 1366, 11537, 326, 338, 5625, 284, 281, 2858, 198, 273, 16990, 13, 770, 1366, 460, 307, 2420, 393, 11, 287, 262, ...
3.9
160
#!/usr/bin/env python3 # pylint: disable=unused-wildcard-import from py_derive_cmd import * import cmd s = Settings(MyCmd, print_warnings=False) CommandInfo(s, test_register, ['registered', 'r'], 'Test for register', raw_arg=True).register() shell = MyCmd() shell.cmdloop()
[ 2, 48443, 14629, 14, 8800, 14, 24330, 21015, 18, 198, 2, 279, 2645, 600, 25, 15560, 28, 403, 1484, 12, 21992, 9517, 12, 11748, 198, 6738, 12972, 62, 1082, 425, 62, 28758, 1330, 1635, 198, 11748, 23991, 198, 198, 82, 796, 16163, 7, ...
2.845361
97
# Lint as: python3 # Copyright 2019 Google LLC # # 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 # # https://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. """Date-related constants and enums.""" import enum # TODO(b/148011715): add NEAREST convention.
[ 2, 406, 600, 355, 25, 21015, 18, 198, 2, 15069, 13130, 3012, 11419, 198, 2, 198, 2, 49962, 739, 262, 24843, 13789, 11, 10628, 362, 13, 15, 357, 1169, 366, 34156, 15341, 198, 2, 345, 743, 407, 779, 428, 2393, 2845, 287, 11846, 351,...
3.635417
192
import argparse, pdb import gym import numpy as np import os import pickle import random import torch import scipy.misc from gym.envs.registration import register parser = argparse.ArgumentParser() parser.add_argument('-display', type=int, default=0) parser.add_argument('-seed', type=int, default=1) parser.add_argument('-lanes', type=int, default=3) parser.add_argument('-traffic_rate', type=int, default=15) parser.add_argument('-state_image', type=int, default=1) parser.add_argument('-save_images', type=int, default=0) parser.add_argument('-store', type=int, default=1) parser.add_argument('-data_dir', type=str, default='traffic-data/state-action-cost/') parser.add_argument('-fps', type=int, default=30) parser.add_argument('-time_slot', type=int, default=0) parser.add_argument('-map', type=str, default='i80', choices={'ai', 'i80', 'us101', 'lanker', 'peach'}) parser.add_argument('-delta_t', type=float, default=0.1) opt = parser.parse_args() opt.state_image = (opt.state_image == 1) opt.store = (opt.store == 1) random.seed(opt.seed) np.random.seed(opt.seed) torch.manual_seed(opt.seed) os.system("mkdir -p " + opt.data_dir) kwargs = dict( display=opt.display, state_image=opt.state_image, store=opt.store, fps=opt.fps, nb_lanes=opt.lanes, traffic_rate=opt.traffic_rate, data_dir=opt.data_dir, delta_t=opt.delta_t, ) register( id='Traffic-v0', entry_point='traffic_gym:Simulator', kwargs=kwargs ) register( id='I-80-v0', entry_point='map_i80:I80', kwargs=kwargs ) gym.envs.registration.register( id='US-101-v0', entry_point='map_us101:US101', kwargs=kwargs, ) gym.envs.registration.register( id='Lankershim-v0', entry_point='map_lanker:Lankershim', kwargs=kwargs, ) gym.envs.registration.register( id='Peachtree-v0', entry_point='map_peach:Peachtree', kwargs=kwargs, ) env_names = { 'ai': 'Traffic-v0', 'i80': 'I-80-v0', 'us101': 'US-101-v0', 'lanker': 'Lankershim-v0', 'peach': 'Peachtree-v0', } print('Building the environment (loading data, if any)') env = gym.make(env_names[opt.map]) env.reset(frame=0, time_slot=opt.time_slot) done = False while not done: observation, reward, done, info = env.step() env.render() print(f'Data generation for <{opt.map}, time slot {opt.time_slot}> completed')
[ 11748, 1822, 29572, 11, 279, 9945, 198, 11748, 11550, 198, 11748, 299, 32152, 355, 45941, 198, 11748, 28686, 198, 11748, 2298, 293, 198, 11748, 4738, 198, 11748, 28034, 198, 11748, 629, 541, 88, 13, 44374, 198, 6738, 11550, 13, 268, 142...
2.378296
986
import matplotlib.pylab as plt import numpy as np import random from scipy.ndimage import gaussian_filter mu =9 N = 50 k = 10 eta =10 sigma = 2 p0 = 0.5 inverse_random = False L = range(N*N) Q = np.zeros((N*mu,N*mu)) for o in range(mu*mu): print(o) F = 1000*k a = np.ones((N,N)) for k_ in range(1000): linear_idx = random.choices(L, weights=a.ravel()/float(a.sum()), k = k) x, y = np.unravel_index(linear_idx, a.shape) x += np.random.randint(-eta,eta,k) y += np.random.randint(-eta,eta,k) cond = (x<0) | (x>=N) | (y<0) | (y>=N) x_ = np.delete(x, np.where(cond)) y_ = np.delete(y, np.where(cond)) a[x_,y_]+=F a = gaussian_filter(a,sigma =sigma) if np.random.random()>p0 and inverse_random: a = a.max()-a Mx,My = np.unravel_index(o,(mu,mu)) Q[Mx*N:(Mx+1)*N,My*N:(My+1)*N] = a fig,ax = plt.subplots(1,1,figsize = (20,20)) plt.imshow(Q, interpolation='nearest') plt.axis('off')
[ 11748, 2603, 29487, 8019, 13, 79, 2645, 397, 355, 458, 83, 198, 11748, 299, 32152, 355, 45941, 198, 11748, 4738, 198, 6738, 629, 541, 88, 13, 358, 9060, 1330, 31986, 31562, 62, 24455, 198, 198, 30300, 796, 24, 198, 45, 796, 2026, 19...
1.87782
532
from model.contact import Contact import re
[ 6738, 2746, 13, 32057, 1330, 14039, 198, 198, 11748, 302 ]
4.4
10
from setuptools import setup setup( name="pure-pyawabi", version="0.2.4", description='A morphological analyzer awabi clone', long_description=open('README.md', encoding='utf-8').read(), long_description_content_type="text/markdown", url='https://github.com/nakagami/pure-pyawabi/', classifiers=[ "License :: OSI Approved :: MIT License", "Development Status :: 4 - Beta", "Intended Audience :: Developers", "Programming Language :: Python", "Programming Language :: Python :: 3.8", "Operating System :: POSIX", ], keywords=['MeCab'], license="MIT", author='Hajime Nakagami', author_email='nakagami@gmail.com', test_suite="tests", packages=['pyawabi'], scripts=['bin/pyawabi'], )
[ 6738, 900, 37623, 10141, 1330, 9058, 198, 198, 40406, 7, 198, 220, 220, 220, 1438, 2625, 37424, 12, 9078, 707, 17914, 1600, 198, 220, 220, 220, 2196, 2625, 15, 13, 17, 13, 19, 1600, 198, 220, 220, 220, 6764, 11639, 32, 17488, 2770, ...
2.496835
316
from django.db import models # from cms.models.fields import PlaceholderField from cms.models import CMSPlugin # from filer.fields.image import FilerImageField from arkestra_utilities.output_libraries.dates import nice_date # from arkestra_utilities.models import ArkestraGenericModel from arkestra_utilities.generic_models import ArkestraGenericPluginOptions, ArkestraGenericModel from arkestra_utilities.mixins import URLModelMixin from arkestra_utilities.settings import PLUGIN_HEADING_LEVELS, PLUGIN_HEADING_LEVEL_DEFAULT from contacts_and_people.models import Entity, Person #, default_entity_id # from links.models import ExternalLink from managers import VacancyManager, StudentshipManager
[ 6738, 42625, 14208, 13, 9945, 1330, 4981, 198, 198, 2, 422, 269, 907, 13, 27530, 13, 25747, 1330, 8474, 13829, 15878, 198, 6738, 269, 907, 13, 27530, 1330, 40773, 37233, 198, 198, 2, 422, 1226, 263, 13, 25747, 13, 9060, 1330, 376, 5...
3.316279
215
from rest_framework import viewsets from .models import Label from .serizalizers import LabelSerializer
[ 6738, 1334, 62, 30604, 1330, 5009, 1039, 198, 198, 6738, 764, 27530, 1330, 36052, 198, 6738, 764, 2655, 528, 282, 11341, 1330, 36052, 32634, 7509, 628 ]
4.076923
26
import json from django.utils.http import urlencode import mock import requests from olympia.amo.tests import AMOPaths, TestCase from olympia.amo.urlresolvers import reverse from olympia.files.models import FileUpload from olympia.github.tests.test_github import ( GithubBaseTestCase, example_pull_request)
[ 11748, 33918, 198, 198, 6738, 42625, 14208, 13, 26791, 13, 4023, 1330, 2956, 11925, 8189, 198, 198, 11748, 15290, 198, 11748, 7007, 198, 198, 6738, 267, 6760, 544, 13, 18811, 13, 41989, 1330, 3001, 3185, 33148, 11, 6208, 20448, 198, 673...
3.28125
96
from exopy.tasks.api import (InstrumentTask) from atom.api import Unicode, Bool, set_default import sys from exopy_qm.utils.dynamic_importer import *
[ 6738, 409, 11081, 13, 83, 6791, 13, 15042, 1330, 357, 818, 43872, 25714, 8, 198, 6738, 22037, 13, 15042, 1330, 34371, 11, 347, 970, 11, 900, 62, 12286, 198, 11748, 25064, 198, 198, 6738, 409, 11081, 62, 80, 76, 13, 26791, 13, 67, ...
3.04
50
import requests import logging from .auth import Auth domain = "https://ptx.transportdata.tw/MOTC/v2/Rail/THSR/" default_limit_count = 20 logger = logging.getLogger('flask.app') auth = Auth() def get_station(): """GET /v2/Rail/THSR/Station Returns: [dict] -- """ action = "Station" url = domain + action + '?a=' + __get_odata_parameter() headers = {} headers.update(auth.get_auth_header()) r = requests.get(url, headers=headers) if r.status_code == requests.codes.ok: return r.json() return {} def get_station_id(station_names): """id Arguments: station_names {[list]} -- Returns: [dictionary] -- key: station name, value: station id """ all_stations = get_station() matchs = {} for station_name in station_names: match = None try: match = next(filter(lambda x: station_name.strip() in x['StationName']['Zh_tw'].strip(), all_stations)) except StopIteration: pass if match: matchs[station_name.strip()] = match['StationID'] return matchs def get_fare(departure, destination): """GET /v2/Rail/THSR/ODFare/{OriginStationID}/to/{DestinationStationID} [] Arguments: departure {str} -- id destination {str} -- id """ if not departure: return {} if not destination: return {} action = "ODFare/{}/to/{}".format(departure, destination) url = domain + action + '?a=' + __get_odata_parameter() headers = {} headers.update(auth.get_auth_header()) r = requests.get(url, headers=headers) if r.status_code == requests.codes.ok: return r.json() return {} def get_timetable(no=''): """GET /v2/Rail/THSR/GeneralTimetable Arguments: no {str} -- """ action = "GeneralTimetable" if no: action += "/TrainNo/{}".format(no) url = domain + action + '?a=' + __get_odata_parameter() headers = {} headers.update(auth.get_auth_header()) r = requests.get(url, headers=headers) if r.status_code == requests.codes.ok: return r.json() return {} def get_seat(id): """GET /v2/Rail/THSR/AvailableSeatStatusList/{StationID} [] """ if not id: return {} action = "AvailableSeatStatusList/{}".format(id) url = domain + action + '?a=' + __get_odata_parameter() headers = {} headers.update(auth.get_auth_header()) r = requests.get(url, headers=headers) if r.status_code == requests.codes.ok: return r.json() else: logger.info(r) return {} def get_news(): """GET /v2/Rail/THSR/News """ action = "News" url = domain + action + '?a=' + __get_odata_parameter() headers = {} headers.update(auth.get_auth_header()) r = requests.get(url, headers=headers) if r.status_code == requests.codes.ok: return r.json() return {} def get_alert(): """GET /v2/Rail/THSR/AlertInfo """ action = "AlertInfo" url = domain + action + '?a=' + __get_odata_parameter() headers = {} headers.update(auth.get_auth_header()) r = requests.get(url, headers=headers) if r.status_code == requests.codes.ok: return r.json() return {} def __get_odata_parameter(top=0, skip=0, format="", orderby="", filter=""): """odata Keyword Arguments: top {int} -- (default: {0}) skip {int} -- (default: {0}) format {str} -- json or xml (default: {""}) orderby {str} -- , response (default: {""}) filter {str} -- (default: {""}) Returns: [type] -- odata parameterquerystring """ param = {'top': top, 'skip': skip, 'orderby': orderby, 'format': format, 'filter': filter} result = "" if top > 0: result += "&$top={top}" if skip > 0: result += "&$skip={skip}" if orderby: result += "&$orderby={orderby}" if format: result += "&$format={format}" if filter: result += "&$filter={filter}" return result.format(**param) if __name__ == '__main__': pass
[ 11748, 7007, 198, 11748, 18931, 198, 6738, 764, 18439, 1330, 26828, 198, 198, 27830, 796, 366, 5450, 1378, 457, 87, 13, 7645, 634, 7890, 13, 4246, 14, 44, 2394, 34, 14, 85, 17, 14, 44631, 14, 4221, 12562, 30487, 198, 12286, 62, 3237...
2.296578
1,841
# Authors: Davide Zoni from m5.params import * from m5.proxy import * from BasicRouter import BasicRouter
[ 2, 46665, 25, 2544, 485, 1168, 14651, 198, 198, 6738, 285, 20, 13, 37266, 1330, 1635, 198, 6738, 285, 20, 13, 36436, 1330, 1635, 198, 6738, 14392, 49, 39605, 1330, 14392, 49, 39605, 198 ]
3.147059
34
import os location = os.path.join(os.path.dirname(__file__), 'Functions\\') #location = 'Tests\\' execfile(location + 'getVersion.py') execfile(location + 'writeSBML.py') #execfile(location + 'computeSteadyStateValues.py') execfile(location + 'evalModel.py') #execfile(location + 'getAvailableSymbols.py') execfile(location + 'getBoundarySpeciesByIndex.py') execfile(location + 'getBoundarySpeciesIds.py') execfile(location + 'getBuildDate.py') #execfile(location + 'getCCode.py') #execfile(location + 'getCCodeHeader.py') #execfile(location + 'getCCodeSource.py') execfile(location + 'getCapabilities.py') execfile(location + 'getCompartmentByIndex.py') execfile(location + 'getCompartmentIds.py') execfile(location + 'getConcentrationControlCoefficientIds.py') execfile(location + 'getConservationMatrix.py') execfile(location + 'getCopyright.py') #execfile(location + 'getuCC.py') #execfile(location + 'getuEE.py') #execfile(location + 'getCC.py') #execfile(location + 'getEE.py') execfile(location + 'getEigenValueIds.py') execfile(location + 'getElasticityCoefficientIds.py') execfile(location + 'getFloatingSpeciesByIndex.py') execfile(location + 'getFloatingSpeciesInitialConcentrations.py') execfile(location + 'getFloatingSpeciesInitialConditionIds.py') execfile(location + 'getFloatingSpeciesIds.py') execfile(location + 'getFloatingSpeciesConcentrations.py') execfile(location + 'getFluxControlCoefficientIds.py') #execfile(location + 'getFullJacobian.py') Causes crash execfile(location + 'getGlobalParameterByIndex.py') execfile(location + 'getGlobalParameterIds.py') execfile(location + 'getGlobalParameterValues.py') execfile(location + 'getLastError.py') execfile(location + 'getLinkMatrix.py') execfile(location + 'getNrMatrix.py') execfile(location + 'getL0Matrix.py') execfile(location + 'getMatrixNumCols.py') execfile(location + 'getMatrixNumRows.py') execfile(location + 'getMatrixElement.py') execfile(location + 'getNumberOfBoundarySpecies.py') execfile(location + 'getNumberOfCompartments.py') execfile(location + 'getNumberOfDependentSpecies.py') execfile(location + 'getNumberOfFloatingSpecies.py') execfile(location + 'getNumberOfGlobalParameters.py') execfile(location + 'getNumberOfIndependentSpecies.py') execfile(location + 'getNumberOfReactions.py') execfile(location + 'getParamPromotedSBML.py') execfile(location + 'getRRInstance.py') execfile(location + 'getRateOfChange.py') execfile(location + 'getRatesOfChange.py') execfile(location + 'getRatesOfChangeEx.py') execfile(location + 'getRatesOfChangeIds.py') execfile(location + 'getReactionIds.py') execfile(location + 'getReactionRate.py') execfile(location + 'getReactionRates.py') execfile(location + 'getReactionRatesEx.py') #execfile(location + 'getReducedJacobian.py') execfile(location + 'getResultColumnLabel.py') execfile(location + 'getResultElement.py') execfile(location + 'getResultNumCols.py') execfile(location + 'getResultNumRows.py') execfile(location + 'getSBML.py') #execfile(location + 'getScaledElasticityMatrix.py') #execfile(location + 'getScaledFloatingSpeciesElasticity.py') execfile(location + 'getSelectionList.py') execfile(location + 'getSteadyStateSelectionList.py') execfile(location + 'getStoichiometryMatrix.py') #execfile(location + 'getStringListElement.py') #execfile(location + 'getStringListLength.py') execfile(location + 'getTempFolder.py') execfile(location + 'getValue.py') #execfile(location + 'getVectorElement.py') #execfile(location + 'getVectorLength.py') #execfile(location + 'hasError.py') execfile(location + 'loadSBML.py') execfile(location + 'loadSBMLFromFile.py') #execfile(location + 'oneStep.py') execfile(location + 'printList.py') execfile(location + 'printMatrix.py') #execfile(location + 'printResult.py') #execfile(location + 'printVector.py') execfile(location + 'reset.py') execfile(location + 'setBoundarySpeciesByIndex.py') execfile(location + 'setCapabilities.py') execfile(location + 'setCompartmentByIndex.py') execfile(location + 'setComputeAndAssignConservationLaws.py') execfile(location + 'setFloatingSpeciesByIndex.py') execfile(location + 'setGlobalParameterByIndex.py') execfile(location + 'setNumPoints.py') execfile(location + 'setSelectionList.py') execfile(location + 'setSteadyStateSelectionList.py') execfile(location + 'setTempFolder.py') execfile(location + 'setTimeEnd.py') execfile(location + 'setTimeStart.py') execfile(location + 'setValue.py') #execfile(location + 'setVectorElement.py') #execfile(location + 'simulate.py') #execfile(location + 'simulateEx.py') #execfile(location + 'steadyState.py')
[ 11748, 28686, 201, 198, 201, 198, 24886, 796, 28686, 13, 6978, 13, 22179, 7, 418, 13, 6978, 13, 15908, 3672, 7, 834, 7753, 834, 828, 705, 24629, 2733, 6852, 11537, 201, 198, 201, 198, 2, 24886, 796, 705, 51, 3558, 6852, 6, 201, 19...
2.8548
1,646
""" Models for Conditions app """ from django.db import models from common.models import OwnedModel
[ 37811, 32329, 329, 27617, 598, 37227, 198, 6738, 42625, 14208, 13, 9945, 1330, 4981, 198, 198, 6738, 2219, 13, 27530, 1330, 11744, 276, 17633, 628 ]
4.08
25
from curriculum.utils import set_env_no_gpu, format_experiment_prefix set_env_no_gpu() import argparse import math import os import os.path as osp import sys import random from multiprocessing import cpu_count import numpy as np import tensorflow as tf from rllab.misc.instrument import run_experiment_lite from rllab import config from rllab.misc.instrument import VariantGenerator from rllab.algos.trpo import TRPO from rllab.baselines.linear_feature_baseline import LinearFeatureBaseline from curriculum.envs.ndim_point.point_env import PointEnv from rllab.envs.normalized_env import normalize from rllab.policies.gaussian_mlp_policy import GaussianMLPPolicy from curriculum.envs.goal_env import GoalExplorationEnv, evaluate_goal_env from curriculum.envs.base import FixedStateGenerator, UniformStateGenerator from curriculum.state.evaluator import * from curriculum.logging.html_report import format_dict, HTMLReport from curriculum.logging.visualization import * from curriculum.logging.logger import ExperimentLogger from curriculum.experiments.goals.point_nd.utils import plot_policy_performance EXPERIMENT_TYPE = osp.basename(__file__).split('.')[0] if __name__ == '__main__': parser = argparse.ArgumentParser() parser.add_argument('--ec2', '-e', action='store_true', default=False, help="add flag to run in ec2") parser.add_argument('--clone', '-c', action='store_true', default=False, help="add flag to copy file and checkout current") parser.add_argument('--local_docker', '-d', action='store_true', default=False, help="add flag to run in local dock") parser.add_argument('--type', '-t', type=str, default='', help='set instance type') parser.add_argument('--price', '-p', type=str, default='', help='set betting price') parser.add_argument('--subnet', '-sn', type=str, default='', help='set subnet like us-west-1a') parser.add_argument('--name', '-n', type=str, default='', help='set exp prefix name and new file name') parser.add_argument('--debug', action='store_true', default=False, help="run code without multiprocessing") parser.add_argument( '--prefix', type=str, default=None, help='set the additional name for experiment prefix' ) args = parser.parse_args() # setup ec2 ec2_instance = args.type if args.type else 'm4.4xlarge' # configure instance info = config.INSTANCE_TYPE_INFO[ec2_instance] config.AWS_INSTANCE_TYPE = ec2_instance config.AWS_SPOT_PRICE = str(info["price"]) n_parallel = int(info["vCPU"]) # make the default 4 if not using ec2 if args.ec2: mode = 'ec2' elif args.local_docker: mode = 'local_docker' n_parallel = cpu_count() if not args.debug else 1 else: mode = 'local' n_parallel = cpu_count() if not args.debug else 1 default_prefix = 'goal-point-nd-trpo' if args.prefix is None: exp_prefix = format_experiment_prefix(default_prefix) elif args.prefix == '': exp_prefix = default_prefix else: exp_prefix = '{}_{}'.format(default_prefix, args.prefix) vg = VariantGenerator() vg.add('seed', range(30, 90, 20)) # # GeneratorEnv params vg.add('goal_size', [2, 3, 4, 5, 6]) # this is the ultimate goal we care about: getting the pendulum upright vg.add('terminal_eps', lambda goal_size: [math.sqrt(goal_size) / math.sqrt(2) * 0.3]) vg.add('only_feasible', [True]) vg.add('goal_range', [5]) # this will be used also as bound of the state_space vg.add('state_bounds', lambda goal_range, goal_size, terminal_eps: [(1, goal_range) + (0.3,) * (goal_size - 2) + (goal_range, ) * goal_size]) vg.add('sample_unif_feas', [True]) vg.add('distance_metric', ['L2']) vg.add('goal_weight', [1]) ############################################# vg.add('min_reward', lambda goal_weight: [goal_weight * 0.1]) # now running it with only the terminal reward of 1! vg.add('max_reward', lambda goal_weight: [goal_weight * 0.9]) vg.add('horizon', [200]) vg.add('outer_iters', [200]) vg.add('inner_iters', [5]) vg.add('pg_batch_size', [20000]) # policy initialization vg.add('output_gain', [1]) vg.add('policy_init_std', [1]) print('Running {} inst. on type {}, with price {}, parallel {}'.format( vg.size, config.AWS_INSTANCE_TYPE, config.AWS_SPOT_PRICE, n_parallel )) for vv in vg.variants(): if mode in ['ec2', 'local_docker']: run_experiment_lite( # use_cloudpickle=False, stub_method_call=run_task, variant=vv, mode=mode, # Number of parallel workers for sampling n_parallel=n_parallel, # Only keep the snapshot parameters for the last iteration snapshot_mode="last", seed=vv['seed'], # plot=True, exp_prefix=exp_prefix, # exp_name=exp_name, sync_s3_pkl=True, # for sync the pkl file also during the training sync_s3_png=True, sync_s3_html=True, # # use this ONLY with ec2 or local_docker!!! pre_commands=[ 'export MPLBACKEND=Agg', 'pip install --upgrade pip', 'pip install --upgrade -I tensorflow', 'pip install git+https://github.com/tflearn/tflearn.git', 'pip install dominate', 'pip install multiprocessing_on_dill', 'pip install scikit-image', 'conda install numpy -n rllab3 -y', ], ) if mode == 'local_docker': sys.exit() else: run_experiment_lite( # use_cloudpickle=False, stub_method_call=run_task, variant=vv, mode='local', n_parallel=n_parallel, # Only keep the snapshot parameters for the last iteration snapshot_mode="last", seed=vv['seed'], exp_prefix=exp_prefix, print_command=False, ) if args.debug: sys.exit()
[ 6738, 20583, 13, 26791, 1330, 900, 62, 24330, 62, 3919, 62, 46999, 11, 5794, 62, 23100, 3681, 62, 40290, 198, 2617, 62, 24330, 62, 3919, 62, 46999, 3419, 198, 198, 11748, 1822, 29572, 198, 11748, 10688, 198, 11748, 28686, 198, 11748, ...
2.261626
2,817
# Fitness monday variables morning_1 = "10:00" morning_2 = "8:00" afternoon_1 = "13:00" afternoon_2 = "14:30" afternoon_3 = "15:30" afternoon_4 = "17:55" evening_1 = "20:30" evening_2 = "21:10" date_announce = [1, 2, 3, 4, 5] image_file_list = [ 'Exercise_Three.png', 'Exercise_Two_2.png' ] # Messages to be display for fitness monday # messageContentVariables morning_1_msg = "Do some stretches! @everyone." morning_2_msg = "Drink water! @everyone." afternoon_1_msg = "Breath fresh air outside before starting your afternoon shift. @everyone." afternoon_2_msg = "Drink a glass of water. Stay hydrated, @everyone!" afternoon_3_msg = "Get up and stretch! @everyone." afternoon_4_msg = "Go out and breathe before the evening sync. @everyone." evening_1_msg = "Do some stretches! @everyone." evening_2_msg = "Drink water. Good night, @everyone." # Handler for all task in fitness monday
[ 2, 34545, 285, 3204, 9633, 201, 198, 43911, 62, 16, 796, 366, 940, 25, 405, 1, 201, 198, 43911, 62, 17, 796, 366, 23, 25, 405, 1, 201, 198, 201, 198, 8499, 6357, 62, 16, 796, 366, 1485, 25, 405, 1, 201, 198, 8499, 6357, 62, ...
2.575758
363
#!/usr/bin/env python # coding: utf-8 # # Author: Kazuto Nakashima # URL: https://kazuto1011.github.io # Date: 07 January 2019 from __future__ import absolute_import, division, print_function import click import cv2 import matplotlib import matplotlib.cm as cm import matplotlib.pyplot as plt import numpy as np import torch import torch.nn as nn import torch.nn.functional as F from omegaconf import OmegaConf from libs.models import * from libs.utils import DenseCRF def singleHierarchy(config_path, model_path, image_path, cuda, crf, sizeThresh=1/9, nIterations=10, doPlot=True): """ Inference from a single image """ # Setup CONFIG = OmegaConf.load(config_path) device = get_device(cuda) torch.set_grad_enabled(False) classes = get_classtable(CONFIG) postprocessor = setup_postprocessor(CONFIG) if crf else None model = eval(CONFIG.MODEL.NAME)(n_classes=CONFIG.DATASET.N_CLASSES) state_dict = torch.load(model_path, map_location=lambda storage, loc: storage) model.load_state_dict(state_dict) model.eval() model.to(device) print("Model:", CONFIG.MODEL.NAME) # Inference image = cv2.imread(image_path, cv2.IMREAD_COLOR) image, raw_image = preprocessing(image, device, CONFIG) # labelmap = inference(model, image, raw_image, postprocessor) labelmapList = inferenceHierarchy(model, image, raw_image, postprocessor, sizeThresh, nIterations) if doPlot: for labelmap in labelmapList: labels = np.unique(labelmap) # Show result for each class rows = np.floor(np.sqrt(len(labels) + 1)) cols = np.ceil((len(labels) + 1) / rows) plt.figure(figsize=(10, 10)) ax = plt.subplot(rows, cols, 1) ax.set_title("Input image") ax.imshow(raw_image[:, :, ::-1]) ax.axis("off") for i, label in enumerate(labels): mask = labelmap == label ax = plt.subplot(rows, cols, i + 2) ax.set_title(classes[label]) ax.imshow(raw_image[..., ::-1]) ax.imshow(mask.astype(np.float32), alpha=0.5) ax.axis("off") plt.tight_layout() plt.show() #single(r".\configs\cocostuff164k.yaml",r"C:\Users\ponce\Desktop\CarlosSetUpFilesHere\CompressionPaperReviewResponse\resources\deeplab-pytorch-master\data\models\coco\deeplabv1_resnet101\caffemodel\deeplabv2_resnet101_msc-cocostuff164k-100000.pth",r"image.jpg",True,True) #python demo.py single --config-path .\configs\voc12.yaml --model-path "C:\Users\ponce\Desktop\CarlosSetUpFilesHere\CompressionPaperReviewResponse\resources\deeplab-pytorch-master\data\models\voc12\deeplabv2_resnet101_msc\caffemodel\deeplabv2_resnet101_msc-vocaug.pth" --image-path image.jpg #python demo.py single --config-path .\configs\cocostuff164k.yaml --model-path "C:\Users\ponce\Desktop\CarlosSetUpFilesHere\CompressionPaperReviewResponse\resources\deeplab-pytorch-master\data\models\coco\deeplabv1_resnet101\caffemodel\deeplabv2_resnet101_msc-cocostuff164k-100000.pth" --image-path image.jpg if __name__ == "__main__": singleHierarchy()
[ 2, 48443, 14629, 14, 8800, 14, 24330, 21015, 201, 198, 2, 19617, 25, 3384, 69, 12, 23, 201, 198, 2, 201, 198, 2, 6434, 25, 16385, 9390, 22255, 1077, 8083, 201, 198, 2, 10289, 25, 220, 220, 220, 3740, 1378, 74, 1031, 9390, 8784, ...
2.190602
1,511
import setuptools import md_tangle with open("README.md", "r") as fh: long_description = fh.read() setuptools.setup( name=md_tangle.__title__, version=md_tangle.__version__, license=md_tangle.__license__, author=md_tangle.__author__, author_email=md_tangle.__author_email__, description="Generates ('tangles') source code from Markdown documents", long_description=long_description, long_description_content_type="text/markdown", url="https://github.com/joakimmj/md-tangle", packages=setuptools.find_packages(), keywords=['markdown', 'tangle', 'literate programming'], platforms=['any'], classifiers=[ "Environment :: Console", "License :: OSI Approved :: MIT License", "Operating System :: OS Independent", "Natural Language :: English", 'Topic :: Text Processing :: Markup', "Programming Language :: Python", "Programming Language :: Python :: 2", "Programming Language :: Python :: 3" ], entry_points={ 'console_scripts': [ 'md-tangle = md_tangle.main:main', ] }, )
[ 11748, 900, 37623, 10141, 198, 11748, 45243, 62, 83, 9248, 198, 198, 4480, 1280, 7203, 15675, 11682, 13, 9132, 1600, 366, 81, 4943, 355, 277, 71, 25, 198, 220, 220, 220, 890, 62, 11213, 796, 277, 71, 13, 961, 3419, 198, 198, 2617, ...
2.530201
447
import torch import torch.nn as nn import torch.nn.functional as F from .bayes_layers import VariationalLinearCertainActivations, VariationalLinearReLU from .variables import GaussianVar
[ 11748, 28034, 198, 11748, 28034, 13, 20471, 355, 299, 77, 198, 11748, 28034, 13, 20471, 13, 45124, 355, 376, 198, 198, 6738, 764, 24406, 274, 62, 75, 6962, 1330, 15965, 864, 14993, 451, 26469, 25526, 602, 11, 15965, 864, 14993, 451, 3...
3.060606
66
from datetime import date from django.db import models # Create your models here.
[ 6738, 4818, 8079, 1330, 3128, 198, 6738, 42625, 14208, 13, 9945, 1330, 4981, 198, 198, 2, 13610, 534, 4981, 994, 13, 628, 198 ]
3.695652
23