content
stringlengths
1
1.05M
input_ids
listlengths
1
883k
ratio_char_token
float64
1
22.9
token_count
int64
1
883k
# -*- coding: utf-8 -*- from __future__ import unicode_literals from django import forms
[ 2, 532, 9, 12, 19617, 25, 3384, 69, 12, 23, 532, 9, 12, 198, 198, 6738, 11593, 37443, 834, 1330, 28000, 1098, 62, 17201, 874, 198, 198, 6738, 42625, 14208, 1330, 5107, 628 ]
2.787879
33
import FWCore.ParameterSet.Config as cms from RecoEgamma.ElectronIdentification.Identification.mvaElectronID_tools import * # Documentation of the MVA # https://twiki.cern.ch/twiki/bin/viewauth/CMS/MultivariateElectronIdentificationRun2 # https://rembserj.web.cern.ch/rembserj/notes/Electron_MVA_ID_2017_documentation # # In this file we define the locations of the MVA weights, cuts on the MVA values # for specific working points, and configure those cuts in VID # # The tag is an extra string attached to the names of the products # such as ValueMaps that needs to distinguish cases when the same MVA estimator # class is used with different tuning/weights mvaTag = "Fall17NoIsoV1" # There are 6 categories in this MVA. They have to be configured in this strict order # (cuts and weight files order): # 0 EB1 (eta<0.8) pt 5-10 GeV | pt < ptSplit && |eta| < ebSplit # 1 EB2 (eta>=0.8) pt 5-10 GeV | pt < ptSplit && |eta| >= ebSplit && |eta| < ebeeSplit # 2 EE pt 5-10 GeV | pt < ptSplit && |eta| >= ebeeSplit # 3 EB1 (eta<0.8) pt 10-inf GeV | pt >= ptSplit && |eta| < ebSplit # 4 EB2 (eta>=0.8) pt 10-inf GeV | pt >= ptSplit && |eta| >= ebSplit && |eta| < ebeeSplit # 5 EE pt 10-inf GeV | pt >= ptSplit && |eta| >= ebeeSplit mvaFall17WeightFiles_V1 = cms.vstring( "RecoEgamma/ElectronIdentification/data/Fall17/EIDmva_EB1_5_2017_puinfo_BDT.weights.xml.gz", "RecoEgamma/ElectronIdentification/data/Fall17/EIDmva_EB2_5_2017_puinfo_BDT.weights.xml.gz", "RecoEgamma/ElectronIdentification/data/Fall17/EIDmva_EE_5_2017_puinfo_BDT.weights.xml.gz", "RecoEgamma/ElectronIdentification/data/Fall17/EIDmva_EB1_10_2017_puinfo_BDT.weights.xml.gz", "RecoEgamma/ElectronIdentification/data/Fall17/EIDmva_EB2_10_2017_puinfo_BDT.weights.xml.gz", "RecoEgamma/ElectronIdentification/data/Fall17/EIDmva_EE_10_2017_puinfo_BDT.weights.xml.gz" ) ## The working point for this MVA that is expected to have about 90% signal # WP tuned to give about 90 and 80% signal efficiecny for electrons from Drell-Yan with pT > 25 GeV # The working point for the low pt categories is just taken over from the high pt idName90 = "mvaEleID-Fall17-noIso-V1-wp90" MVA_WP90 = EleMVA_WP( idName = idName90, mvaTag = mvaTag, cutCategory0 = "0.9165112826974601 - exp(-pt / 2.7381703555094217) * 1.03549199648109", # EB1 low pt cutCategory1 = "0.8655738322220173 - exp(-pt / 2.4027944652597073) * 0.7975615613282494", # EB2 low pt cutCategory2 = "-3016.035055227131 - exp(-pt / -52140.61856333602) * -3016.3029387236506", # EE low pt cutCategory3 = "0.9616542816132922 - exp(-pt / 8.757943837889817) * 3.1390200321591206", # EB1 cutCategory4 = "0.9319258011430132 - exp(-pt / 8.846057432565809) * 3.5985063793347787", # EB2 cutCategory5 = "0.8899260780999244 - exp(-pt / 10.124234115859881) * 4.352791250718547", # EE ) idName80 = "mvaEleID-Fall17-noIso-V1-wp80" MVA_WP80 = EleMVA_WP( idName = idName80, mvaTag = mvaTag, cutCategory0 = "0.9530240956555949 - exp(-pt / 2.7591425841003647) * 0.4669644718545271", # EB1 low pt cutCategory1 = "0.9336564763961019 - exp(-pt / 2.709276284272272) * 0.33512286599215946", # EB2 low pt cutCategory2 = "0.9313133688365339 - exp(-pt / 1.5821934800715558) * 3.8889462619659265", # EE low pt cutCategory3 = "0.9825268564943458 - exp(-pt / 8.702601455860762) * 1.1974861596609097", # EB1 cutCategory4 = "0.9727509457929913 - exp(-pt / 8.179525631018565) * 1.7111755094657688", # EB2 cutCategory5 = "0.9562619539540145 - exp(-pt / 8.109845366281608) * 3.013927699126942", # EE ) ### WP tuned for HZZ analysis with very high efficiency (about 98%) # The working points were found by requiring the same signal efficiencies in # each category as for the Spring 16 HZZ ID # (see RecoEgamma/ElectronIdentification/python/Identification/mvaElectronID_Spring16_HZZ_V1_cff.py) idNamewpLoose = "mvaEleID-Fall17-noIso-V1-wpLoose" MVA_WPLoose = EleMVA_WP( idName = idNamewpLoose, mvaTag = mvaTag, cutCategory0 = "-0.13285867293779202", # EB1 low pt cutCategory1 = "-0.31765300958836074", # EB2 low pt cutCategory2 = "-0.0799205914718861" , # EE low pt cutCategory3 = "-0.856871961305474" , # EB1 cutCategory4 = "-0.8107642141584835" , # EB2 cutCategory5 = "-0.7179265933023059" # EE ) # # Finally, set up VID configuration for all cuts # # Create the PSet that will be fed to the MVA value map producer mvaEleID_Fall17_noIso_V1_producer_config = cms.PSet( mvaName = cms.string(mvaClassName), mvaTag = cms.string(mvaTag), # Category parameters nCategories = cms.int32(6), categoryCuts = cms.vstring(*EleMVA_6CategoriesCuts), # Weight files and variable definitions weightFileNames = mvaFall17WeightFiles_V1, variableDefinition = cms.string("RecoEgamma/ElectronIdentification/data/ElectronMVAEstimatorRun2Fall17V1Variables.txt") ) # Create the VPset's for VID cuts mvaEleID_Fall17_V1_wpLoose = configureVIDMVAEleID( MVA_WPLoose ) mvaEleID_Fall17_V1_wp90 = configureVIDMVAEleID( MVA_WP90 ) mvaEleID_Fall17_V1_wp80 = configureVIDMVAEleID( MVA_WP80 ) mvaEleID_Fall17_V1_wpLoose.isPOGApproved = cms.untracked.bool(True) mvaEleID_Fall17_V1_wp90.isPOGApproved = cms.untracked.bool(True) mvaEleID_Fall17_V1_wp80.isPOGApproved = cms.untracked.bool(True)
[ 11748, 48849, 14055, 13, 36301, 7248, 13, 16934, 355, 269, 907, 198, 6738, 3311, 78, 36, 28483, 2611, 13, 19453, 1313, 33234, 2649, 13, 33234, 2649, 13, 76, 6862, 19453, 1313, 2389, 62, 31391, 1330, 1635, 198, 198, 2, 43925, 286, 262,...
2.331194
2,337
import numpy as np import gym from utils import * from agent import * from config import * if __name__ == '__main__': env = gym.make(RAM_ENV_NAME) agent = Agent(env.observation_space.shape[0], env.action_space.n, BATCH_SIZE, LEARNING_RATE, TAU, GAMMA, DEVICE, False, DUEL, DOUBLE, PRIORITIZED) rewards_log, _ = train(env, agent, RAM_NUM_EPISODE, EPS_INIT, EPS_DECAY, EPS_MIN, MAX_T) np.save('{}_rewards.npy'.format(RAM_ENV_NAME), rewards_log) agent.Q_local.to('cpu') torch.save(agent.Q_local.state_dict(), '{}_weights.pth'.format(RAM_ENV_NAME))
[ 11748, 299, 32152, 355, 45941, 198, 11748, 11550, 198, 6738, 3384, 4487, 1330, 1635, 198, 6738, 5797, 1330, 1635, 198, 6738, 4566, 1330, 1635, 198, 198, 361, 11593, 3672, 834, 6624, 705, 834, 12417, 834, 10354, 198, 220, 220, 220, 17365...
2.380753
239
#!/usr/bin/python # Copyright (c) 2010 The Chromium Authors. All rights reserved. # Use of this source code is governed by a BSD-style license that can be # found in the LICENSE file. """ This tool launches several shards of a gtest-based binary in parallel on a local machine. Example usage: parallel_launcher.py path/to/base_unittests """ import optparse import os import subprocess import sys import threading import time def StreamCopyWindows(stream_from, stream_to): """Copies stream_from to stream_to.""" while True: buf = stream_from.read(1024) if not buf: break stream_to.write(buf) stream_to.flush() def StreamCopyPosix(stream_from, stream_to, child_exited): """ Copies stream_from to stream_to, and exits if child_exited is signaled. """ import fcntl # Put the source stream in a non-blocking mode, so we can check # child_exited when there is no data. fd = stream_from.fileno() fl = fcntl.fcntl(fd, fcntl.F_GETFL) fcntl.fcntl(fd, fcntl.F_SETFL, fl | os.O_NONBLOCK) while True: try: buf = os.read(fd, 1024) except OSError, e: if e.errno == 11: if child_exited.isSet(): break time.sleep(0.1) continue raise if not buf: break stream_to.write(buf) stream_to.flush() if __name__ == "__main__": sys.exit(main(sys.argv[1:]))
[ 2, 48443, 14629, 14, 8800, 14, 29412, 198, 2, 15069, 357, 66, 8, 3050, 383, 18255, 1505, 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...
2.507326
546
a = int(input()) for i in range(a): print('* '*(a-a//2)) print(' *'*(a//2))
[ 64, 796, 493, 7, 15414, 28955, 198, 1640, 1312, 287, 2837, 7, 64, 2599, 198, 220, 220, 220, 3601, 10786, 9, 705, 9, 7, 64, 12, 64, 1003, 17, 4008, 198, 220, 220, 220, 3601, 10786, 1635, 6, 9, 7, 64, 1003, 17, 4008 ]
1.886364
44
# # dp.py -- Data pipeline and reduction routines # # This is open-source software licensed under a BSD license. # Please see the file LICENSE.txt for details. # import numpy as np from collections import OrderedDict from ginga import AstroImage, colors from ginga.RGBImage import RGBImage from ginga.util import wcs # counter used to name anonymous images prefixes = dict(dp=0) # https://gist.github.com/stscieisenhamer/25bf6287c2c724cb9cc7 def masktorgb(mask, color='lightgreen', alpha=1.0): """Convert boolean mask to RGB image object for canvas overlay. Parameters ---------- mask : ndarray Boolean mask to overlay. 2D image only. color : str Color name accepted by Ginga. alpha : float Opacity. Unmasked data are always transparent. Returns ------- rgbobj : RGBImage RGB image for canvas Image object. Raises ------ ValueError Invalid mask dimension. """ mask = np.asarray(mask) if mask.ndim != 2: raise ValueError('ndim={0} is not supported'.format(mask.ndim)) ht, wd = mask.shape r, g, b = colors.lookup_color(color) rgbobj = RGBImage(data_np=np.zeros((ht, wd, 4), dtype=np.uint8)) rc = rgbobj.get_slice('R') gc = rgbobj.get_slice('G') bc = rgbobj.get_slice('B') ac = rgbobj.get_slice('A') ac[:] = 0 # Transparent background rc[mask] = int(r * 255) gc[mask] = int(g * 255) bc[mask] = int(b * 255) ac[mask] = int(alpha * 255) # For debugging #rgbobj.save_as_file('ztmp_rgbobj.png') return rgbobj # END
[ 2, 198, 2, 288, 79, 13, 9078, 1377, 6060, 11523, 290, 7741, 31878, 198, 2, 198, 2, 770, 318, 1280, 12, 10459, 3788, 11971, 739, 257, 347, 10305, 5964, 13, 198, 2, 4222, 766, 262, 2393, 38559, 24290, 13, 14116, 329, 3307, 13, 198, ...
2.5039
641
from torch.utils.data import Dataset from ..utils.optimal_lenght import find_optimal_lenght
[ 6738, 28034, 13, 26791, 13, 7890, 1330, 16092, 292, 316, 198, 6738, 11485, 26791, 13, 8738, 4402, 62, 11925, 456, 83, 1330, 1064, 62, 8738, 4402, 62, 11925, 456, 83, 628 ]
3
31
blacklist=set()
[ 13424, 4868, 28, 2617, 3419, 198 ]
2.666667
6
from rest_framework import viewsets from rest_framework import generics from ..models import Task from .serializers import TaskSerializer
[ 6738, 1334, 62, 30604, 1330, 5009, 1039, 198, 6738, 1334, 62, 30604, 1330, 1152, 873, 198, 198, 6738, 11485, 27530, 1330, 15941, 198, 198, 6738, 764, 46911, 11341, 1330, 15941, 32634, 7509, 628, 220, 220, 220, 220 ]
3.918919
37
__version__ = "0.0.3" __author__ = "Jason Duncan" __support__ = "jason.matthew.duncan@gmail.com"
[ 834, 9641, 834, 796, 366, 15, 13, 15, 13, 18, 1, 198, 834, 9800, 834, 796, 366, 26497, 18625, 1, 198, 834, 11284, 834, 796, 366, 73, 888, 13, 76, 1078, 6391, 13, 67, 403, 5171, 31, 14816, 13, 785, 1, 198 ]
2.309524
42
from typing import Union, List import pexpect from figcli.utils.utils import Utils import sys
[ 6738, 19720, 1330, 4479, 11, 7343, 198, 198, 11748, 613, 87, 806, 198, 198, 6738, 2336, 44506, 13, 26791, 13, 26791, 1330, 7273, 4487, 198, 11748, 25064, 198 ]
3.428571
28
# ============================================================================== # Copyright 2018-2020 Intel Corporation # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to 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. # ============================================================================== """nGraph TensorFlow bridge elementwise operations test """ from __future__ import absolute_import from __future__ import division from __future__ import print_function import pytest import numpy as np import tensorflow as tf tf.compat.v1.disable_eager_execution() from common import NgraphTest
[ 2, 38093, 25609, 28, 198, 2, 220, 15069, 2864, 12, 42334, 8180, 10501, 198, 2, 198, 2, 220, 49962, 739, 262, 24843, 13789, 11, 10628, 362, 13, 15, 357, 1169, 366, 34156, 15341, 198, 2, 220, 345, 743, 407, 779, 428, 2393, 2845, 287...
4.177866
253
#!/usr/bin/env python3 # -*- coding: utf-8 -*- """ @author: Lars Stenseng. @mail: lars@stenseng.net """ # from qc.__version__ import __version__ import georinex as gr import numpy as np from matplotlib.pyplot import figure, show import matplotlib.pyplot as plt obs = gr.load( 'tests/test_data/Rinex3/KLSQ00GRL_R_20213070000_01D_15S_MO.rnx', # tlim=['2021-11-03T12:00', '2021-11-03T12:30']) tlim=['2021-11-03T05:30', '2021-11-03T07:30']) # tlim=['2021-11-03T15:00', '2021-11-03T18:00']) # hdr = gr.rinexheader( # 'tests/test_data/Rinex3/KLSQ00GRL_R_20213070000_01D_15S_MO.rnx') # rnx_version = 3 # %% Starting test # Copying helper functions from Multipath class - later on, it could be turned # into a separate class with helper functions # Pick GPS satellites svG = [] for i in range(0, len(obs.sv)): if str(obs.sv[i].values)[0] == 'G': svG.append(str(obs.sv[i].values)) else: continue # %% # 5:30 to 7:30, G08 and G21 give 2 cycle slips # [290:300] # 'G01','G06','G08','G10','G12','G14','G17','G19','G21','G22','G24','G30','G32' sat = 'G21' sattest = obs.sel(sv=sat).dropna(dim='time', how='all') # G02 data vars with no-nan: C1C, D1C, L1C, S1C, C1W, C2W, D2W, L2W, S1W, S2W I_max = 0.4 # Maximal ionospheric delay [m/h] k = 4 # criterion factor L1 = sattest['L1C'] # GPS L2 = sattest['L2W'] # GPS # L1 = sattest['L1C'] # Galileo # L2 = sattest['L8Q'] # Galileo L4 = np.abs(L1 - L2) sigma_L4 = np.std(L4) criterion = k*sigma_L4 + I_max slips_nr = 0 L4_diff = [] for i in range(1, len(L4)): L4_diff.append(np.abs(L4[i] - L4[i-1])) if (np.abs(L4[i] - L4[i-1]) > criterion): # If satisfied, raise cycle-slip flag slips_nr = slips_nr + 1 ax = figure(figsize=(10, 6)).gca() ax.plot(L2.time[1:], L4_diff, label=sat) plt.axhline(y=criterion, label='Slip limit', linestyle='-', color='r') ax.grid() ax.legend() plt.xlabel('Time [epochs]') plt.ylabel('L4') plt.title('Single-frequency Melbourne-Wuebbena') show() print('Slips:', slips_nr, ', Slip criterion:', criterion.values) # %% # Plot all loaded sats, L1 and L2 ax = figure(figsize=(10, 6)).gca() for i in range(0, len(svG)): test = obs.sel(sv=svG[i]).dropna(dim='time', how='all') L1test = test['L1C'] L2test = test['L2W'] ax.plot(L1test.time, L1test, label=svG[i], linewidth=2.0) #ax.plot(L2test.time, L2test, label='L2', linewidth=0.5) ax.grid() ax.legend() plt.xlabel('Time [epochs]') plt.ylabel('Carrier phases') show() # %% # Plot separate sats, L1 and L2 ax = figure(figsize=(10, 6)).gca() test = obs.sel(sv='E21').dropna(dim='time', how='all') L1test = test['L1C'] L2test = test['L2W'] ax.plot(L1test.time, L1test, label='L1', linewidth=2.0) ax.plot(L2test.time, L2test, label='L2', linewidth=1.0) ax.grid() # ax.legend() plt.xlabel('Time [epochs]') plt.ylabel('Carrier phases') show() # %% Dual-frequency Melbourne-Wuebbena testing # 'G01','G06','G08','G10','G12','G14','G17','G19','G21','G22','G24','G30','G32' sat = 'G21' sattest = obs.sel(sv=sat).dropna(dim='time', how='all') # G02 data vars with no-nan: C1C, D1C, L1C, S1C, C1W, C2W, D2W, L2W, S1W, S2W freq = [1575.42, 1227.60, 1176.45] # L1, L2, L5 for GPS f1 = freq[0]*1e6 f2 = freq[1]*1e6 P1 = sattest['C1C'] P2 = sattest['C2W'] L1 = sattest['L1C'] # GPS L2 = sattest['L2W'] # GPS # L1 = sattest['L1C'] # Galileo # L2 = sattest['L8Q'] # Galileo L6 = (1/(f1-f2))*(f1*L1 - f2*L2) - (1/(f1+f2))*(f1*P1 + f2*P2) sigma_L6 = np.std(L6) k = 4 # criterion factor criterion = k*sigma_L6 slips_nr = 0 L6_diff = [] for i in range(1, len(L6)): L6_diff.append(np.abs(L6[i] - L6[i-1])) if (np.abs(L6[i] - L6[i-1]) > criterion): # If satisfied, raise cycle-slip flag slips_nr = slips_nr + 1 ax = figure(figsize=(10, 6)).gca() ax.plot(L2.time[1:], L6_diff, label=sat) plt.axhline(y=criterion, label='Slip limit', linestyle='-', color='r') ax.grid() ax.legend() plt.xlabel('Time [epochs]') plt.ylabel('L6') plt.title('Dual-frequency Melbourne-Wuebbena') show() print('Slips:', slips_nr, ', Slip criterion:', criterion.values) # %% Work in Progress # %% Testing first algorithm sliptest = Slips().slips_MW_single_freq(obs) # %% Testing plot function sliptest = Slips().plot_slips(obs, 'G08')
[ 2, 48443, 14629, 14, 8800, 14, 24330, 21015, 18, 198, 2, 532, 9, 12, 19617, 25, 3384, 69, 12, 23, 532, 9, 12, 198, 37811, 198, 31, 9800, 25, 31239, 520, 641, 1516, 13, 198, 198, 31, 4529, 25, 300, 945, 31, 301, 641, 1516, 13, ...
2.062621
2,060
from collections import OrderedDict from datetime import datetime, timezone import unittest from os.path import join from tinydb import TinyDB, storages from goldfinchsong import utils IMAGE_NAMES = ['goldfinch1.jpg', 'goldfinch2.jpg', 'goldfinch3.jpg', 'goldfinch4.jpg', 'goldfinch5.jpg'] TEST_TEXT1 = 'This is a test of the goldfinchsong project. This test checks ' \ 'abbreviations, vowel elision, length checking, and other logic. ' \ 'Tests are important!' TEST_TEXT2 = 'This is a test of the goldfinchsong project. Tests ' \ 'abbreviations, vowel elision, length checking, and other logic. ' \ 'Tests are important!'
[ 6738, 17268, 1330, 14230, 1068, 35, 713, 198, 6738, 4818, 8079, 1330, 4818, 8079, 11, 640, 11340, 198, 11748, 555, 715, 395, 198, 6738, 28686, 13, 6978, 1330, 4654, 198, 6738, 7009, 9945, 1330, 20443, 11012, 11, 336, 273, 1095, 198, 6...
2.632576
264
# Lint as: python3 # Copyright 2018 The TensorFlow Authors. 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. # ============================================================================== """Input generator for image data.""" import os import lingvo.compat as tf from lingvo.core import base_input_generator from tensorflow.python.ops import io_ops def _GetRandomImages(batch_size): images = tf.random.uniform((batch_size, 28, 28, 1), 0, 255, tf.int32) return tf.cast(images, tf.uint8) def _GetRandomLabels(batch_size): labels = tf.random.categorical(0.1 * tf.ones((1, 10)), batch_size) return tf.cast(labels, tf.uint8) def FakeMnistData(tmpdir, train_size=60000, test_size=10000): """Fake Mnist data for unit tests.""" data_path = os.path.join(tmpdir, 'ckpt') with tf.Graph().as_default(): tf.random.set_seed(91) with tf.Session() as sess: sess.run( io_ops.save_v2( data_path, tensor_names=['x_train', 'y_train', 'x_test', 'y_test'], shape_and_slices=['', '', '', ''], tensors=[ _GetRandomImages(train_size), _GetRandomLabels(train_size), _GetRandomImages(test_size), _GetRandomLabels(test_size) ])) return data_path
[ 2, 406, 600, 355, 25, 21015, 18, 198, 2, 15069, 2864, 383, 309, 22854, 37535, 46665, 13, 1439, 6923, 33876, 13, 198, 2, 198, 2, 49962, 739, 262, 24843, 13789, 11, 10628, 362, 13, 15, 357, 1169, 366, 34156, 15341, 198, 2, 345, 743,...
2.642136
693
from src.base.solution import Solution from src.tests.part1.q389_test_find_diff import FindDiffTestCases if __name__ == '__main__': solution = FindDiff() solution.run_tests()
[ 6738, 12351, 13, 8692, 13, 82, 2122, 1330, 28186, 198, 6738, 12351, 13, 41989, 13, 3911, 16, 13, 80, 29769, 62, 9288, 62, 19796, 62, 26069, 1330, 9938, 28813, 14402, 34, 1386, 628, 198, 361, 11593, 3672, 834, 6624, 705, 834, 12417, ...
2.920635
63
#unit #mydict.py
[ 2, 20850, 198, 2, 1820, 11600, 13, 9078, 198, 197, 197, 198 ]
1.666667
12
import contextlib import os import tempfile import warnings from enum import Enum import mip
[ 11748, 4732, 8019, 198, 11748, 28686, 198, 11748, 20218, 7753, 198, 11748, 14601, 198, 6738, 33829, 1330, 2039, 388, 198, 198, 11748, 285, 541, 628, 628, 628 ]
3.666667
27
from output.models.nist_data.atomic.integer.schema_instance.nistschema_sv_iv_atomic_integer_pattern_1_xsd.nistschema_sv_iv_atomic_integer_pattern_1 import NistschemaSvIvAtomicIntegerPattern1 __all__ = [ "NistschemaSvIvAtomicIntegerPattern1", ]
[ 6738, 5072, 13, 27530, 13, 77, 396, 62, 7890, 13, 47116, 13, 41433, 13, 15952, 2611, 62, 39098, 13, 77, 1023, 2395, 2611, 62, 21370, 62, 452, 62, 47116, 62, 41433, 62, 33279, 62, 16, 62, 87, 21282, 13, 77, 1023, 2395, 2611, 62, ...
2.59375
96
import re import xlsxwriter
[ 11748, 302, 201, 198, 11748, 2124, 7278, 87, 16002, 201, 198, 201, 198, 201, 198 ]
2.266667
15
#!/usr/bin/env python3 from sys import stderr, exit from TALinputs import TALinput from multilanguage import Env, Lang, TALcolors from parentheses_lib import recognize # METADATA OF THIS TAL_SERVICE: problem="parentheses" service="check_one_sol_server" args_list = [ ('input_formula',str), ('n',str), ('silent',bool), ('lang',str), ('ISATTY',bool), ] ENV =Env(problem, service, args_list) TAc =TALcolors(ENV) LANG=Lang(ENV, TAc, lambda fstring: eval(f"f'{fstring}'")) # START CODING YOUR SERVICE: n=ENV['n'] len_input = len(ENV["input_formula"])//2 if not ENV["silent"]: TAc.print(LANG.opening_msg, "green") if n=='free': answer() else: if len_input==int(n): answer() elif recognize(ENV["input_formula"], TAc, LANG) and not ENV['silent']: TAc.print(LANG.render_feedback("different_lengths", f"No! Your string represents a valid formula of parentheses but not of {n} pairs."), "red", ["bold"]) exit(0)
[ 2, 48443, 14629, 14, 8800, 14, 24330, 21015, 18, 201, 198, 6738, 25064, 1330, 336, 1082, 81, 11, 8420, 201, 198, 201, 198, 6738, 309, 1847, 15414, 82, 1330, 309, 1847, 15414, 201, 198, 6738, 1963, 346, 9000, 1330, 2039, 85, 11, 1633...
2.290618
437
"""Translates validation error messages for the response""" messages = { 'accepted': 'The :field: must be accepted.', 'after': 'The :field: must be a date after :other:.', 'alpha': 'The :field: may contain only letters.', 'alpha_dash': 'The :field: may only contain letters, numbers, and dashes.', 'alpha_num': 'The :field: may contain only letters and numbers.', 'array': 'The :field: must be an array.', 'before': 'The :field: must be a date before :other:.', 'between': 'The :field: must be between :least: and :most:.', 'between_string': 'The :field: must be between :least: and :most: characters.', 'between_numeric': 'The :field: must be between :least: and :most:.', 'boolean': 'The :field: must be either true or false.', 'confirmed': 'The :field: confirmation does not match.', 'date': 'The :field: is not a valid date.', 'different': 'The :field: and :other: must be different.', 'digits': 'The :field: must be :length: digits.', 'email': 'The :field: must be a valid email address.', 'exists': 'The selected :field: is invalid.', 'found_in': 'The selected :field: is invalid.', 'integer': 'The :field: must be an integer.', 'json': 'The :field: must be valid json format.', 'most_string': 'The :field: must not be greater than :most: characters.', 'most_numeric': 'The :field: must not be greater than :most:.', 'least_string': 'The :field: must be at least :least: characters.', 'least_numeric': 'The :field: must be at least :least:.', 'not_in': 'The selected :field: is invalid.', 'numeric': 'The :field: must be a number.', 'positive': 'The :field: must be a positive number.', 'regex': 'The :field: format is invalid.', 'required': 'The :field: field is required.', 'required_with': 'The :field: field is required when :other: is present.', 'required_without': 'The :field: field is required when :other: si not present.', 'same': 'The :field: and :other: must match.', 'size_string': 'The :field: must be :size: characters.', 'size_numeric': 'The :field: must be :size:.', 'string': 'The :field: must be a string.', 'unique': 'The :field: is already taken.', 'url': 'The :field: format is invalid.', }
[ 37811, 8291, 75, 689, 21201, 4049, 6218, 329, 262, 2882, 37811, 628, 198, 37348, 1095, 796, 1391, 198, 220, 220, 220, 705, 13635, 276, 10354, 705, 464, 1058, 3245, 25, 1276, 307, 6292, 2637, 11, 198, 220, 220, 220, 705, 8499, 10354, ...
2.828144
803
from channels import Group # websocket.connect # websocket.receive # websocket.disconnect
[ 6738, 9619, 1330, 4912, 198, 198, 2, 2639, 5459, 13, 8443, 198, 198, 2, 2639, 5459, 13, 260, 15164, 198, 198, 2, 2639, 5459, 13, 6381, 8443 ]
3.407407
27
from copy import deepcopy import numpy as np import pybullet as p import gym from gym import spaces from env.robot import Manipulator from env.work import Work
[ 6738, 4866, 1330, 2769, 30073, 198, 11748, 299, 32152, 355, 45941, 198, 11748, 12972, 15065, 1616, 355, 279, 198, 11748, 11550, 198, 6738, 11550, 1330, 9029, 198, 198, 6738, 17365, 13, 305, 13645, 1330, 35045, 8927, 198, 6738, 17365, 13, ...
3.72093
43
import _thread import time import threading # # def print_time(threadName,delay): # count = 0; # while count < 5: # time.sleep(delay) # count += 1; # print("%s: %s" % (threadName, time.ctime(time.time()))) # # try: # _thread.start_new(print_time,("Thread-1",2,)) # _thread.start_new(print_time("Thread-2",4)) # except: # print("error") # # while 1: # pass # Python3 _thread threading # _thread threading # threading _thread # threading.currentThread(): # threading.enumerate(): list # threading.activeCount(): len(threading.enumerate()) # ThreadThread: # run(): # start(): # join([time]): BAB.join()A # Btime # # isAlive(): # getName(): # setName(): exitFlag = 0 # thread1 = MyThread(1, "Thread-1", 5) thread2 = MyThread(2, "Thread-2", 5) # thread1.start() thread2.start() thread1.join() thread2.join() print ("")
[ 11748, 4808, 16663, 198, 11748, 640, 198, 11748, 4704, 278, 198, 2, 198, 2, 825, 3601, 62, 2435, 7, 16663, 5376, 11, 40850, 2599, 198, 2, 220, 220, 220, 220, 954, 796, 657, 26, 198, 2, 220, 220, 220, 220, 981, 954, 1279, 642, 25...
2.311518
382
from django.shortcuts import render from rest_framework import generics # Create your views here. from petsAPI.models import Pets from petsAPI.serializers import PetSerializer
[ 6738, 42625, 14208, 13, 19509, 23779, 1330, 8543, 198, 6738, 1334, 62, 30604, 1330, 1152, 873, 198, 198, 2, 13610, 534, 5009, 994, 13, 198, 6738, 17252, 17614, 13, 27530, 1330, 43578, 198, 6738, 17252, 17614, 13, 46911, 11341, 1330, 476...
3.977778
45
import face_recognition import sys,os import re,cv2 input_dir_path=sys.argv[1] output_dir_path=sys.argv[2] if not os.path.exists(output_dir_path): os.mkdir(output_dir_path) if not os.path.exists(output_dir_path+'/'+str(1)): os.mkdir(output_dir_path+'/'+str(1)) input_images=sorted_alphanumeric(os.listdir(input_dir_path)) cv2.imwrite(output_dir_path+'/'+str(1)+'/'+input_images[0],cv2.imread(input_dir_path+'/'+input_images[0])) if not os.path.exists(output_dir_path+'/back_imgs'): os.mkdir(output_dir_path+'/back_imgs') if not os.path.exists(output_dir_path+'/error'): os.mkdir(output_dir_path+'/error') for img_path in input_images[1:]: try: prev_similarity=0 img=face_recognition.load_image_file(input_dir_path+'/'+img_path) img_encoding=face_recognition.face_encodings(img) if img_encoding==[]: img=cv2.cvtColor(img,cv2.COLOR_RGB2BGR) cv2.imwrite(output_dir_path+'/back_imgs/'+img_path,img) continue img_encoding=face_recognition.face_encodings(img)[0] imgs_dirs=sorted_alphanumeric(os.listdir(output_dir_path)) imgs_dirs=list(set(imgs_dirs)-set(['error','back_imgs'])) for img_dir in imgs_dirs: check_img=face_recognition.load_image_file(output_dir_path+'/'+img_dir+'/'+sorted_alphanumeric(os.listdir(output_dir_path+'/'+img_dir))[0]) check_img_encoding=face_recognition.face_encodings(check_img)[0] similarity=1-face_recognition.compare_faces([img_encoding], check_img_encoding) if similarity>prev_similarity: prev_similarity=similarity result_dir=img_dir img=cv2.cvtColor(img,cv2.COLOR_RGB2BGR) if prev_similarity<0.6: new_dir=str(len(os.listdir(output_dir_path))+1) os.mkdir(output_dir_path+'/'+new_dir) cv2.imwrite(output_dir_path+'/'+new_dir+'/'+img_path,img) else: cv2.imwrite(output_dir_path+'/'+result_dir+'/'+img_path,img) except: img=cv2.cvtColor(img,cv2.COLOR_RGB2BGR) cv2.imwrite(output_dir_path+'/error/'+img_path,img)
[ 11748, 1986, 62, 26243, 653, 198, 11748, 25064, 11, 418, 198, 11748, 302, 11, 33967, 17, 198, 198, 15414, 62, 15908, 62, 6978, 28, 17597, 13, 853, 85, 58, 16, 60, 198, 22915, 62, 15908, 62, 6978, 28, 17597, 13, 853, 85, 58, 17, ...
2.158072
892
import requests from bbdata.config import output_api_url from bbdata.util import handle_response
[ 11748, 7007, 198, 6738, 275, 65, 7890, 13, 11250, 1330, 5072, 62, 15042, 62, 6371, 198, 6738, 275, 65, 7890, 13, 22602, 1330, 5412, 62, 26209, 628 ]
3.62963
27
from .exception import TakoException, TaskFailed # noqa from .session import connect # noqa
[ 6738, 764, 1069, 4516, 1330, 15804, 78, 16922, 11, 15941, 37, 6255, 220, 1303, 645, 20402, 198, 6738, 764, 29891, 1330, 2018, 220, 1303, 645, 20402, 198 ]
3.481481
27
import argparse
[ 11748, 1822, 29572, 198 ]
4
4
from django.urls import path from . import views urlpatterns = [ path('search-card', views.patients_search_card), path('search-individual', views.patients_search_individual), path('search-l2-card', views.patients_search_l2_card), path('create-l2-individual-from-card', views.create_l2_individual_from_card), path('card/<int:card_id>', views.patients_get_card_data), path('card/save', views.patients_card_save), path('card/archive', views.patients_card_archive), path('card/unarchive', views.patients_card_unarchive), path('individuals/search', views.individual_search), path('individuals/sex', views.get_sex_by_param), path('individuals/edit-doc', views.edit_doc), path('individuals/edit-agent', views.edit_agent), path('individuals/update-cdu', views.update_cdu), path('individuals/update-wia', views.update_wia), path('individuals/sync-rmis', views.sync_rmis), path('individuals/sync-tfoms', views.sync_tfoms), path('individuals/load-anamnesis', views.load_anamnesis), path('individuals/load-dreg', views.load_dreg), path('individuals/load-screening', views.load_screening), path('individuals/load-vaccine', views.load_vaccine), path('individuals/load-ambulatory-data', views.load_ambulatory_data), path('individuals/load-benefit', views.load_benefit), path('individuals/load-dreg-detail', views.load_dreg_detail), path('individuals/load-vaccine-detail', views.load_vaccine_detail), path('individuals/load-ambulatorydata-detail', views.load_ambulatory_data_detail), path('individuals/load-ambulatory-history', views.load_ambulatory_history), path('individuals/load-benefit-detail', views.load_benefit_detail), path('individuals/save-dreg', views.save_dreg), path('individuals/save-plan-dreg', views.update_dispensary_reg_plans), path('individuals/save-vaccine', views.save_vaccine), path('individuals/save-ambulatory-data', views.save_ambulatory_data), path('individuals/save-benefit', views.save_benefit), path('individuals/save-anamnesis', views.save_anamnesis), path('is-card', views.is_l2_card), path('save-screening-plan', views.update_screening_reg_plan), ]
[ 6738, 42625, 14208, 13, 6371, 82, 1330, 3108, 198, 6738, 764, 1330, 5009, 198, 198, 6371, 33279, 82, 796, 685, 198, 220, 220, 220, 3108, 10786, 12947, 12, 9517, 3256, 5009, 13, 8071, 2334, 62, 12947, 62, 9517, 828, 198, 220, 220, 22...
2.745025
804
# -*- coding: utf-8 -*- # Generated by Django 1.9.11 on 2016-11-15 07:06 from __future__ import unicode_literals import django.contrib.postgres.fields from django.db import migrations, models
[ 2, 532, 9, 12, 19617, 25, 3384, 69, 12, 23, 532, 9, 12, 198, 2, 2980, 515, 416, 37770, 352, 13, 24, 13, 1157, 319, 1584, 12, 1157, 12, 1314, 8753, 25, 3312, 198, 6738, 11593, 37443, 834, 1330, 28000, 1098, 62, 17201, 874, 198, ...
2.811594
69
import os import sys import re import glob from setuptools import setup, find_packages # long_description: Take from README file with open(os.path.join(os.path.dirname(__file__), 'README.rst')) as f: readme = f.read() # Version Number with open(os.path.join(os.path.dirname(__file__), 'xlwings', '__init__.py')) as f: version = re.compile(r".*__version__ = '(.*?)'", re.S).match(f.read()).group(1) # Dependencies if sys.platform.startswith('win'): if sys.version_info[:2] >= (3, 7): pywin32 = 'pywin32 >= 224' else: pywin32 = 'pywin32' install_requires = [pywin32] # This places dlls next to python.exe for standard setup and in the parent folder for virtualenv data_files = [('', glob.glob('xlwings*.dll'))] elif sys.platform.startswith('darwin'): install_requires = ['psutil >= 2.0.0', 'appscript >= 1.0.1'] data_files = [(os.path.expanduser("~") + '/Library/Application Scripts/com.microsoft.Excel', [f'xlwings/xlwings-{version}.applescript'])] else: if os.environ.get('READTHEDOCS', None) == 'True' or os.environ.get('INSTALL_ON_LINUX') == '1': data_files = [] install_requires = [] else: raise OSError("xlwings requires an installation of Excel and therefore only works on Windows and macOS. To enable the installation on Linux nevertheless, do: export INSTALL_ON_LINUX=1; pip install xlwings") extras_require = { 'pro': ['cryptography', 'Jinja2', 'pdfrw'], 'all': ['cryptography', 'Jinja2', 'pandas', 'matplotlib', 'plotly', 'flask', 'requests', 'pdfrw'] } setup( name='xlwings', version=version, url='https://www.xlwings.org', license='BSD 3-clause', author='Zoomer Analytics LLC', author_email='felix.zumstein@zoomeranalytics.com', description='Make Excel fly: Interact with Excel from Python and vice versa.', long_description=readme, data_files=data_files, packages=find_packages(exclude=('tests', 'tests.*',)), package_data={'xlwings': ['xlwings.bas', 'Dictionary.cls', '*.xlsm', '*.xlam', '*.applescript', 'addin/xlwings.xlam', 'addin/xlwings_unprotected.xlam']}, keywords=['xls', 'excel', 'spreadsheet', 'workbook', 'vba', 'macro'], install_requires=install_requires, extras_require=extras_require, entry_points={'console_scripts': ['xlwings=xlwings.cli:main'],}, classifiers=[ 'Development Status :: 4 - Beta', 'Operating System :: Microsoft :: Windows', 'Operating System :: MacOS :: MacOS X', 'Programming Language :: Python', 'Programming Language :: Python :: 3', 'Programming Language :: Python :: 3.6', 'Programming Language :: Python :: 3.7', 'Programming Language :: Python :: 3.8', 'Programming Language :: Python :: 3.9', 'Programming Language :: Python :: 3.10', 'Topic :: Office/Business :: Financial :: Spreadsheet', 'License :: OSI Approved :: BSD License'], platforms=['Windows', 'Mac OS X'], python_requires='>=3.6', )
[ 11748, 28686, 198, 11748, 25064, 198, 11748, 302, 198, 11748, 15095, 198, 6738, 900, 37623, 10141, 1330, 9058, 11, 1064, 62, 43789, 198, 198, 2, 890, 62, 11213, 25, 7214, 422, 20832, 11682, 2393, 198, 4480, 1280, 7, 418, 13, 6978, 13,...
2.571672
1,172
import pytest from click.testing import CliRunner from secedgar.cli import daily, filing from secedgar.utils.exceptions import FilingTypeError
[ 11748, 12972, 9288, 198, 6738, 3904, 13, 33407, 1330, 1012, 72, 49493, 198, 6738, 384, 771, 4563, 13, 44506, 1330, 4445, 11, 12180, 198, 6738, 384, 771, 4563, 13, 26791, 13, 1069, 11755, 1330, 376, 4386, 6030, 12331, 628, 628, 198 ]
3.585366
41
import os import numpy as np import matplotlib.pyplot as plt from matplotlib import gridspec nstep=200 nx=400 nv=3 u=np.zeros((nx,nv)) prim=np.zeros((nx,nv)) gam=5./3. dx=1./nx dt=1e-3 time=0 x=np.linspace(0,1,num=nx) prim[:,0]=1. prim[:,1]=0. prim[:,2]=1. for i in range(int(nx/2),nx): prim[i,0]=0.1 prim[i,1]=0. prim[i,2]=0.125 print (prim[:,2]) u=ptou(prim) uold=u pold=prim fig = plt.figure() gs = gridspec.GridSpec(nv,1) ax1 = fig.add_subplot(gs[0,0]) ax2 = fig.add_subplot(gs[1,0]) ax3 = fig.add_subplot(gs[2,0]) ax1.plot(x,prim[:,0],'pres') ax2.plot(x,prim[:,1],'pres') ax3.plot(x,prim[:,2],'pres') fig.show() for nstep in range(0,nstep): print (time) um=np.roll(u, 1,axis=0) up=np.roll(u,-1,axis=0) um[0,:] =um[1,:] up[nx-1,:]=up[nx-2,:] fm=getflux(um) fp=getflux(up) cfl=0.49 dtdx=1./getmaxv(p) dt=dtdx*dx time=time+dt un=0.5*(um+up) - cfl*dtdx* (fp-fm) u=un p=utop(u) plt.close(fig) fig = plt.figure() gs = gridspec.GridSpec(nv,1) ax1 = fig.add_subplot(gs[0,0]) ax2 = fig.add_subplot(gs[1,0]) ax3 = fig.add_subplot(gs[2,0]) ax1.plot(p[:,0]) ax2.plot(p[:,1]) ax3.plot(p[:,2]) fig.show()
[ 11748, 28686, 198, 11748, 299, 32152, 355, 45941, 198, 11748, 2603, 29487, 8019, 13, 9078, 29487, 355, 458, 83, 198, 6738, 2603, 29487, 8019, 1330, 50000, 43106, 198, 198, 77, 9662, 28, 2167, 198, 77, 87, 28, 7029, 198, 48005, 28, 18,...
1.611111
828
import unittest from pluralizer import Pluralizer import re # Standard singular/plural matches. # # @type {Array} BASIC_TESTS = [ # Uncountables. ['firmware', 'firmware'], ['fish', 'fish'], ['media', 'media'], ['moose', 'moose'], ['police', 'police'], ['sheep', 'sheep'], ['series', 'series'], ['agenda', 'agenda'], ['news', 'news'], ['reindeer', 'reindeer'], ['starfish', 'starfish'], ['smallpox', 'smallpox'], ['tennis', 'tennis'], ['chickenpox', 'chickenpox'], ['shambles', 'shambles'], ['garbage', 'garbage'], ['you', 'you'], ['wildlife', 'wildlife'], ['Staff', 'Staff'], ['STAFF', 'STAFF'], ['turquois', 'turquois'], ['carnivorous', 'carnivorous'], ['only', 'only'], ['aircraft', 'aircraft'], # Latin. ['veniam', 'veniam'], # Pluralization. ['this', 'these'], ['that', 'those'], ['is', 'are'], ['man', 'men'], ['superman', 'supermen'], ['ox', 'oxen'], ['bus', 'buses'], ['airbus', 'airbuses'], ['railbus', 'railbuses'], ['wife', 'wives'], ['guest', 'guests'], ['thing', 'things'], ['mess', 'messes'], ['guess', 'guesses'], ['person', 'people'], ['meteor', 'meteors'], ['chateau', 'chateaus'], ['lap', 'laps'], ['cough', 'coughs'], ['death', 'deaths'], ['coach', 'coaches'], ['boy', 'boys'], ['toy', 'toys'], ['guy', 'guys'], ['girl', 'girls'], ['chair', 'chairs'], ['toe', 'toes'], ['tiptoe', 'tiptoes'], ['tomato', 'tomatoes'], ['potato', 'potatoes'], ['tornado', 'tornadoes'], ['torpedo', 'torpedoes'], ['hero', 'heroes'], ['superhero', 'superheroes'], ['volcano', 'volcanoes'], ['canto', 'cantos'], ['hetero', 'heteros'], ['photo', 'photos'], ['portico', 'porticos'], ['quarto', 'quartos'], ['kimono', 'kimonos'], ['albino', 'albinos'], ['cherry', 'cherries'], ['piano', 'pianos'], ['pro', 'pros'], ['combo', 'combos'], ['turbo', 'turbos'], ['bar', 'bars'], ['crowbar', 'crowbars'], ['van', 'vans'], ['tobacco', 'tobaccos'], ['afficionado', 'afficionados'], ['monkey', 'monkeys'], ['neutrino', 'neutrinos'], ['rhino', 'rhinos'], ['steno', 'stenos'], ['latino', 'latinos'], ['casino', 'casinos'], ['avocado', 'avocados'], ['commando', 'commandos'], ['tuxedo', 'tuxedos'], ['speedo', 'speedos'], ['dingo', 'dingoes'], ['echo', 'echoes'], ['nacho', 'nachos'], ['motto', 'mottos'], ['psycho', 'psychos'], ['poncho', 'ponchos'], ['pass', 'passes'], ['ghetto', 'ghettos'], ['mango', 'mangos'], ['lady', 'ladies'], ['bath', 'baths'], ['professional', 'professionals'], ['dwarf', 'dwarves'], # Proper spelling is "dwarfs". ['encyclopedia', 'encyclopedias'], ['louse', 'lice'], ['roof', 'roofs'], ['woman', 'women'], ['formula', 'formulas'], ['polyhedron', 'polyhedra'], ['index', 'indices'], # Maybe "indexes". ['matrix', 'matrices'], ['vertex', 'vertices'], ['axe', 'axes'], # Could also be plural of "ax". ['pickaxe', 'pickaxes'], ['crisis', 'crises'], ['criterion', 'criteria'], ['phenomenon', 'phenomena'], ['addendum', 'addenda'], ['datum', 'data'], ['forum', 'forums'], ['millennium', 'millennia'], ['alumnus', 'alumni'], ['medium', 'mediums'], ['census', 'censuses'], ['genus', 'genera'], ['dogma', 'dogmata'], ['life', 'lives'], ['hive', 'hives'], ['kiss', 'kisses'], ['dish', 'dishes'], ['human', 'humans'], ['knife', 'knives'], ['phase', 'phases'], ['judge', 'judges'], ['class', 'classes'], ['witch', 'witches'], ['church', 'churches'], ['massage', 'massages'], ['prospectus', 'prospectuses'], ['syllabus', 'syllabi'], ['viscus', 'viscera'], ['cactus', 'cacti'], ['hippopotamus', 'hippopotamuses'], ['octopus', 'octopuses'], ['platypus', 'platypuses'], ['kangaroo', 'kangaroos'], ['atlas', 'atlases'], ['stigma', 'stigmata'], ['schema', 'schemata'], ['phenomenon', 'phenomena'], ['diagnosis', 'diagnoses'], ['mongoose', 'mongooses'], ['mouse', 'mice'], ['liturgist', 'liturgists'], ['box', 'boxes'], ['gas', 'gases'], ['self', 'selves'], ['chief', 'chiefs'], ['quiz', 'quizzes'], ['child', 'children'], ['shelf', 'shelves'], ['fizz', 'fizzes'], ['tooth', 'teeth'], ['thief', 'thieves'], ['day', 'days'], ['loaf', 'loaves'], ['fix', 'fixes'], ['spy', 'spies'], ['vertebra', 'vertebrae'], ['clock', 'clocks'], ['lap', 'laps'], ['cuff', 'cuffs'], ['leaf', 'leaves'], ['calf', 'calves'], ['moth', 'moths'], ['mouth', 'mouths'], ['house', 'houses'], ['proof', 'proofs'], ['hoof', 'hooves'], ['elf', 'elves'], ['turf', 'turfs'], ['craft', 'crafts'], ['die', 'dice'], ['penny', 'pennies'], ['campus', 'campuses'], ['virus', 'viri'], ['iris', 'irises'], ['bureau', 'bureaus'], ['kiwi', 'kiwis'], ['wiki', 'wikis'], ['igloo', 'igloos'], ['ninja', 'ninjas'], ['pizza', 'pizzas'], ['kayak', 'kayaks'], ['canoe', 'canoes'], ['tiding', 'tidings'], ['pea', 'peas'], ['drive', 'drives'], ['nose', 'noses'], ['movie', 'movies'], ['status', 'statuses'], ['alias', 'aliases'], ['memorandum', 'memorandums'], ['language', 'languages'], ['plural', 'plurals'], ['word', 'words'], ['multiple', 'multiples'], ['reward', 'rewards'], ['sandwich', 'sandwiches'], ['subway', 'subways'], ['direction', 'directions'], ['land', 'lands'], ['row', 'rows'], ['grow', 'grows'], ['flow', 'flows'], ['rose', 'roses'], ['raise', 'raises'], ['friend', 'friends'], ['follower', 'followers'], ['male', 'males'], ['nail', 'nails'], ['sex', 'sexes'], ['tape', 'tapes'], ['ruler', 'rulers'], ['king', 'kings'], ['queen', 'queens'], ['zero', 'zeros'], ['quest', 'quests'], ['goose', 'geese'], ['foot', 'feet'], ['ex', 'exes'], ['reflex', 'reflexes'], ['heat', 'heats'], ['train', 'trains'], ['test', 'tests'], ['pie', 'pies'], ['fly', 'flies'], ['eye', 'eyes'], ['lie', 'lies'], ['node', 'nodes'], ['trade', 'trades'], ['chinese', 'chinese'], ['please', 'pleases'], ['japanese', 'japanese'], ['regex', 'regexes'], ['license', 'licenses'], ['zebra', 'zebras'], ['general', 'generals'], ['corps', 'corps'], ['pliers', 'pliers'], ['flyer', 'flyers'], ['scissors', 'scissors'], ['fireman', 'firemen'], ['chirp', 'chirps'], ['harp', 'harps'], ['corpse', 'corpses'], ['dye', 'dyes'], ['move', 'moves'], ['zombie', 'zombies'], ['variety', 'varieties'], ['talkie', 'talkies'], ['walkie-talkie', 'walkie-talkies'], ['groupie', 'groupies'], ['goonie', 'goonies'], ['lassie', 'lassies'], ['genie', 'genies'], ['foodie', 'foodies'], ['faerie', 'faeries'], ['collie', 'collies'], ['obloquy', 'obloquies'], ['looey', 'looies'], ['osprey', 'ospreys'], ['cover', 'covers'], ['tie', 'ties'], ['groove', 'grooves'], ['bee', 'bees'], ['ave', 'aves'], ['wave', 'waves'], ['wolf', 'wolves'], ['airwave', 'airwaves'], ['archive', 'archives'], ['arch', 'arches'], ['dive', 'dives'], ['aftershave', 'aftershaves'], ['cave', 'caves'], ['grave', 'graves'], ['gift', 'gifts'], ['nerve', 'nerves'], ['nerd', 'nerds'], ['carve', 'carves'], ['rave', 'raves'], ['scarf', 'scarves'], ['sale', 'sales'], ['sail', 'sails'], ['swerve', 'swerves'], ['love', 'loves'], ['dove', 'doves'], ['glove', 'gloves'], ['wharf', 'wharves'], ['valve', 'valves'], ['werewolf', 'werewolves'], ['view', 'views'], ['emu', 'emus'], ['menu', 'menus'], ['wax', 'waxes'], ['fax', 'faxes'], ['nut', 'nuts'], ['crust', 'crusts'], ['lemma', 'lemmata'], ['anathema', 'anathemata'], ['analysis', 'analyses'], ['locus', 'loci'], ['uterus', 'uteri'], ['curriculum', 'curricula'], ['quorum', 'quora'], ['genius', 'geniuses'], ['flower', 'flowers'], ['crash', 'crashes'], ['soul', 'souls'], ['career', 'careers'], ['planet', 'planets'], ['son', 'sons'], ['sun', 'suns'], ['drink', 'drinks'], ['diploma', 'diplomas'], ['dilemma', 'dilemmas'], ['grandma', 'grandmas'], ['no', 'nos'], ['yes', 'yeses'], ['employ', 'employs'], ['employee', 'employees'], ['history', 'histories'], ['story', 'stories'], ['purchase', 'purchases'], ['order', 'orders'], ['key', 'keys'], ['bomb', 'bombs'], ['city', 'cities'], ['sanity', 'sanities'], ['ability', 'abilities'], ['activity', 'activities'], ['cutie', 'cuties'], ['validation', 'validations'], ['floaty', 'floaties'], ['nicety', 'niceties'], ['goalie', 'goalies'], ['crawly', 'crawlies'], ['duty', 'duties'], ['scrutiny', 'scrutinies'], ['deputy', 'deputies'], ['beauty', 'beauties'], ['bank', 'banks'], ['family', 'families'], ['tally', 'tallies'], ['ally', 'allies'], ['alley', 'alleys'], ['valley', 'valleys'], ['medley', 'medleys'], ['melody', 'melodies'], ['trolly', 'trollies'], ['thunk', 'thunks'], ['koala', 'koalas'], ['special', 'specials'], ['book', 'books'], ['knob', 'knobs'], ['crab', 'crabs'], ['plough', 'ploughs'], ['high', 'highs'], ['low', 'lows'], ['hiccup', 'hiccups'], ['bonus', 'bonuses'], ['circus', 'circuses'], ['abacus', 'abacuses'], ['phobia', 'phobias'], ['case', 'cases'], ['lace', 'laces'], ['trace', 'traces'], ['mage', 'mages'], ['lotus', 'lotuses'], ['motorbus', 'motorbuses'], ['cutlas', 'cutlases'], ['tequila', 'tequilas'], ['liar', 'liars'], ['delta', 'deltas'], ['visa', 'visas'], ['flea', 'fleas'], ['favela', 'favelas'], ['cobra', 'cobras'], ['finish', 'finishes'], ['gorilla', 'gorillas'], ['mass', 'masses'], ['face', 'faces'], ['rabbit', 'rabbits'], ['adventure', 'adventures'], ['breeze', 'breezes'], ['brew', 'brews'], ['canopy', 'canopies'], ['copy', 'copies'], ['spy', 'spies'], ['cave', 'caves'], ['charge', 'charges'], ['cinema', 'cinemas'], ['coffee', 'coffees'], ['favourite', 'favourites'], ['themself', 'themselves'], ['country', 'countries'], ['issue', 'issues'], ['authority', 'authorities'], ['force', 'forces'], ['objective', 'objectives'], ['present', 'presents'], ['industry', 'industries'], ['believe', 'believes'], ['century', 'centuries'], ['category', 'categories'], ['eve', 'eves'], ['fee', 'fees'], ['gene', 'genes'], ['try', 'tries'], ['currency', 'currencies'], ['pose', 'poses'], ['cheese', 'cheeses'], ['clue', 'clues'], ['cheer', 'cheers'], ['litre', 'litres'], ['money', 'monies'], ['attorney', 'attorneys'], ['balcony', 'balconies'], ['cockney', 'cockneys'], ['donkey', 'donkeys'], ['honey', 'honeys'], ['smiley', 'smilies'], ['survey', 'surveys'], ['whiskey', 'whiskeys'], ['whisky', 'whiskies'], ['volley', 'volleys'], ['tongue', 'tongues'], ['suit', 'suits'], ['suite', 'suites'], ['cruise', 'cruises'], ['eave', 'eaves'], ['consultancy', 'consultancies'], ['pouch', 'pouches'], ['wallaby', 'wallabies'], ['abyss', 'abysses'], ['weekly', 'weeklies'], ['whistle', 'whistles'], ['utilise', 'utilises'], ['utilize', 'utilizes'], ['mercy', 'mercies'], ['mercenary', 'mercenaries'], ['take', 'takes'], ['flush', 'flushes'], ['gate', 'gates'], ['evolve', 'evolves'], ['slave', 'slaves'], ['native', 'natives'], ['revolve', 'revolves'], ['twelve', 'twelves'], ['sleeve', 'sleeves'], ['subjective', 'subjectives'], ['stream', 'streams'], ['beam', 'beams'], ['foam', 'foams'], ['callus', 'calluses'], ['use', 'uses'], ['beau', 'beaus'], ['gateau', 'gateaus'], ['fetus', 'fetuses'], ['luau', 'luaus'], ['pilau', 'pilaus'], ['shoe', 'shoes'], ['sandshoe', 'sandshoes'], ['zeus', 'zeuses'], ['nucleus', 'nuclei'], ['sky', 'skies'], ['beach', 'beaches'], ['brush', 'brushes'], ['hoax', 'hoaxes'], ['scratch', 'scratches'], ['nanny', 'nannies'], ['negro', 'negroes'], ['taco', 'tacos'], ['cafe', 'cafes'], ['cave', 'caves'], ['giraffe', 'giraffes'], ['goodwife', 'goodwives'], ['housewife', 'housewives'], ['safe', 'safes'], ['save', 'saves'], ['pocketknife', 'pocketknives'], ['tartufe', 'tartufes'], ['tartuffe', 'tartuffes'], ['truffle', 'truffles'], ['jefe', 'jefes'], ['agrafe', 'agrafes'], ['agraffe', 'agraffes'], ['bouffe', 'bouffes'], ['carafe', 'carafes'], ['chafe', 'chafes'], ['pouffe', 'pouffes'], ['pouf', 'poufs'], ['piaffe', 'piaffes'], ['gaffe', 'gaffes'], ['executive', 'executives'], ['cove', 'coves'], ['dove', 'doves'], ['fave', 'faves'], ['positive', 'positives'], ['solve', 'solves'], ['trove', 'troves'], ['treasure', 'treasures'], ['suave', 'suaves'], ['bluff', 'bluffs'], ['half', 'halves'], ['knockoff', 'knockoffs'], ['handkerchief', 'handkerchiefs'], ['reed', 'reeds'], ['reef', 'reefs'], ['yourself', 'yourselves'], ['sunroof', 'sunroofs'], ['plateau', 'plateaus'], ['radius', 'radii'], ['stratum', 'strata'], ['stratus', 'strati'], ['focus', 'foci'], ['fungus', 'fungi'], ['appendix', 'appendices'], ['seraph', 'seraphim'], ['cherub', 'cherubim'], ['memo', 'memos'], ['cello', 'cellos'], ['automaton', 'automata'], ['button', 'buttons'], ['crayon', 'crayons'], ['captive', 'captives'], ['abrasive', 'abrasives'], ['archive', 'archives'], ['additive', 'additives'], ['hive', 'hives'], ['beehive', 'beehives'], ['olive', 'olives'], ['black olive', 'black olives'], ['chive', 'chives'], ['adjective', 'adjectives'], ['cattle drive', 'cattle drives'], ['explosive', 'explosives'], ['executive', 'executives'], ['negative', 'negatives'], ['fugitive', 'fugitives'], ['progressive', 'progressives'], ['laxative', 'laxatives'], ['incentive', 'incentives'], ['genesis', 'geneses'], ['surprise', 'surprises'], ['enterprise', 'enterprises'], ['relative', 'relatives'], ['positive', 'positives'], ['perspective', 'perspectives'], ['superlative', 'superlatives'], ['afterlife', 'afterlives'], ['native', 'natives'], ['detective', 'detectives'], ['collective', 'collectives'], ['lowlife', 'lowlives'], ['low-life', 'low-lives'], ['strife', 'strifes'], ['pony', 'ponies'], ['phony', 'phonies'], ['felony', 'felonies'], ['colony', 'colonies'], ['symphony', 'symphonies'], ['semicolony', 'semicolonies'], ['radiotelephony', 'radiotelephonies'], ['company', 'companies'], ['ceremony', 'ceremonies'], ['carnivore', 'carnivores'], ['emphasis', 'emphases'], ['abuse', 'abuses'], ['ass', 'asses'], ['mile', 'miles'], ['consensus', 'consensuses'], ['coatdress', 'coatdresses'], ['courthouse', 'courthouses'], ['playhouse', 'playhouses'], ['crispness', 'crispnesses'], ['racehorse', 'racehorses'], ['greatness', 'greatnesses'], ['demon', 'demons'], ['lemon', 'lemons'], ['pokemon', 'pokemon'], ['pokmon', 'pokmon'], ['christmas', 'christmases'], ['zymase', 'zymases'], ['accomplice', 'accomplices'], ['amice', 'amices'], ['titmouse', 'titmice'], ['slice', 'slices'], ['base', 'bases'], ['database', 'databases'], ['rise', 'rises'], ['uprise', 'uprises'], ['size', 'sizes'], ['prize', 'prizes'], ['booby', 'boobies'], ['hobby', 'hobbies'], ['baby', 'babies'], ['cookie', 'cookies'], ['budgie', 'budgies'], ['calorie', 'calories'], ['brownie', 'brownies'], ['lolly', 'lollies'], ['hippie', 'hippies'], ['smoothie', 'smoothies'], ['techie', 'techies'], ['specie', 'species'], ['quickie', 'quickies'], ['pixie', 'pixies'], ['rotisserie', 'rotisseries'], ['porkpie', 'porkpies'], ['newbie', 'newbies'], ['veggie', 'veggies'], ['bourgeoisie', 'bourgeoisies'], ['party', 'parties'], ['apology', 'apologies'], ['ancestry', 'ancestries'], ['anomaly', 'anomalies'], ['anniversary', 'anniversaries'], ['battery', 'batteries'], ['nappy', 'nappies'], ['hanky', 'hankies'], ['junkie', 'junkies'], ['hogtie', 'hogties'], ['footsie', 'footsies'], ['curry', 'curries'], ['fantasy', 'fantasies'], ['housefly', 'houseflies'], ['falsy', 'falsies'], ['doggy', 'doggies'], ['carny', 'carnies'], ['cabby', 'cabbies'], ['charlie', 'charlies'], ['bookie', 'bookies'], ['auntie', 'aunties'], # Prototype inheritance. ['constructor', 'constructors'], # Non-standard case. ['randomWord', 'randomWords'], ['camelCase', 'camelCases'], ['PascalCase', 'PascalCases'], ['Alumnus', 'Alumni'], ['CHICKEN', 'CHICKENS'], ['', ''], ['', ''], ['', ''], [' ', ' '], [' chicken', ' chickens'], ['Order2', 'Order2s'], ['Work Order2', 'Work Order2s'], ['SoundFX2', 'SoundFX2s'], ['oDonald', 'oDonalds'] ] # # Odd plural to singular tests. # # @type {Array} # SINGULAR_TESTS = [ ['dingo', 'dingos'], ['mango', 'mangoes'], ['echo', 'echos'], ['ghetto', 'ghettoes'], ['nucleus', 'nucleuses'], ['bureau', 'bureaux'], ['seraph', 'seraphs'] ] # # Odd singular to plural tests. # # @type {Array} # PLURAL_TESTS = [ ['plateaux', 'plateaux'], ['axis', 'axes'], ['basis', 'bases'], ['automatum', 'automata'], ['thou', 'you'], ['axiS', 'axes'], ['passerby', 'passersby'] ] if __name__ == '__main__': unittest.main()
[ 198, 11748, 555, 715, 395, 198, 6738, 22801, 7509, 1330, 1345, 1523, 7509, 198, 11748, 302, 198, 198, 2, 8997, 18032, 14, 489, 1523, 7466, 13, 198, 2, 198, 2, 2488, 4906, 1391, 19182, 92, 198, 198, 33, 1921, 2149, 62, 51, 1546, 46...
2.047856
9,027
# Copyright (c) 2017 LINE Corporation # These sources are released under the terms of the MIT license: see LICENSE import requests.sessions from django.db.models import F from promgen.version import __version__ from django.conf import settings # Wrappers around request api to ensure we always attach our user agent # https://github.com/requests/requests/blob/master/requests/api.py def setting(key, default=None, domain=None): """ Settings helper based on saltstack's query Allows a simple way to query settings from YAML using the style `path:to:key` to represent path: to: key: value """ rtn = settings.PROMGEN if domain: rtn = rtn[domain] for index in key.split(":"): try: rtn = rtn[index] except KeyError: return default return rtn
[ 2, 15069, 357, 66, 8, 2177, 48920, 10501, 198, 2, 2312, 4237, 389, 2716, 739, 262, 2846, 286, 262, 17168, 5964, 25, 766, 38559, 24290, 198, 198, 11748, 7007, 13, 82, 6202, 198, 6738, 42625, 14208, 13, 9945, 13, 27530, 1330, 376, 198...
2.714286
315
import time import kubernetes import pytest from dagster_k8s.client import DagsterK8sError, WaitForPodState from dagster_k8s.utils import retrieve_pod_logs, wait_for_job_success, wait_for_pod from dagster_k8s_test_infra.helm import get_helm_test_namespace
[ 11748, 640, 198, 198, 11748, 479, 18478, 3262, 274, 198, 11748, 12972, 9288, 198, 6738, 48924, 1706, 62, 74, 23, 82, 13, 16366, 1330, 32167, 1706, 42, 23, 82, 12331, 11, 16314, 1890, 41565, 9012, 198, 6738, 48924, 1706, 62, 74, 23, ...
2.817204
93
# Generated by Django 3.1.6 on 2021-02-15 08:52 from django.db import migrations, models import django.db.models.deletion
[ 2, 2980, 515, 416, 37770, 513, 13, 16, 13, 21, 319, 33448, 12, 2999, 12, 1314, 8487, 25, 4309, 198, 198, 6738, 42625, 14208, 13, 9945, 1330, 15720, 602, 11, 4981, 198, 11748, 42625, 14208, 13, 9945, 13, 27530, 13, 2934, 1616, 295, ...
2.818182
44
from PyQt5.QtCore import Qt, QStringListModel from PyQt5.QtWidgets import QLineEdit, QCompleter
[ 6738, 9485, 48, 83, 20, 13, 48, 83, 14055, 1330, 33734, 11, 1195, 10100, 8053, 17633, 198, 6738, 9485, 48, 83, 20, 13, 48, 83, 54, 312, 11407, 1330, 1195, 13949, 18378, 11, 1195, 5377, 1154, 353, 628, 628 ]
2.538462
39
# # importing all the modules at once # from .config import * # from .normalization import * # from .others import * # from .img_reg import * # from .transformation import * # from .visualization import * # importing the modules in a selective way import utils.config import utils.normalization import utils.misc import utils.lr_finder
[ 2, 1303, 33332, 477, 262, 13103, 379, 1752, 198, 2, 422, 764, 11250, 1330, 1635, 198, 2, 422, 764, 11265, 1634, 1330, 1635, 198, 2, 422, 764, 847, 82, 1330, 1635, 198, 2, 422, 764, 9600, 62, 2301, 1330, 1635, 198, 2, 422, 764, 7...
3.585106
94
from celery import Celery from clients.dobie_client import send_data_to_dobie app = Celery('qualichain_mediator') app.config_from_object('settings', namespace='CELERY_')
[ 6738, 18725, 1924, 1330, 15248, 1924, 198, 198, 6738, 7534, 13, 67, 672, 494, 62, 16366, 1330, 3758, 62, 7890, 62, 1462, 62, 67, 672, 494, 198, 198, 1324, 796, 15248, 1924, 10786, 13255, 488, 391, 62, 2379, 1352, 11537, 198, 1324, 1...
2.932203
59
import json, math from ingest import ingest_json_body from housepy import config, log, strings, util
[ 11748, 33918, 11, 10688, 198, 6738, 26151, 1330, 26151, 62, 17752, 62, 2618, 198, 6738, 2156, 9078, 1330, 4566, 11, 2604, 11, 13042, 11, 7736 ]
4
25
#!/usr/bin/env python '''update gandi DNS domain entry, with LiveDNS v5 Cf. https://doc.livedns.gandi.net/#work-with-domains ''' import argparse import ipaddress import json import os from subprocess import check_output import requests parser = argparse.ArgumentParser(description=__doc__) parser.add_argument('-v', '--verbose', action='store_true') parser.add_argument('domain') parser.add_argument('name') parser.add_argument('--ip', help="defaults to ifconfig.me's return") parser.add_argument('--api_key', help="defaults to GANDI_API_KEY env var, or the return of 'pass api/gandi'") args = parser.parse_args() if args.ip is None: args.ip = requests.get('http://ifconfig.me', headers={'User-Agent': 'curl/7.61.1'}).content.decode().strip() ip = ipaddress.ip_address(args.ip) if args.api_key is None: args.api_key = os.environ.get('GANDI_API_KEY', check_output(['pass', 'api/gandi'], text=True).strip()) key = {'X-Api-Key': args.api_key} r = requests.get(f'https://dns.api.gandi.net/api/v5/domains/{args.domain}/records/{args.name}', headers=key) r.raise_for_status() if r.json()[0]['rrset_values'][0] == args.ip: if args.verbose: print('ok') else: type_ = 'AAAA' if isinstance(ip, ipaddress.IPv6Address) else 'A' url = f'https://dns.api.gandi.net/api/v5/domains/{args.domain}/records/{args.name}/{type_}' data = {'rrset_values': [args.ip]} headers = {'Content-Type': 'application/json', **key} r = requests.put(url, data=json.dumps(data), headers=headers) if args.verbose: print(r.json()) else: r.raise_for_status()
[ 2, 48443, 14629, 14, 8800, 14, 24330, 21015, 198, 7061, 6, 19119, 308, 26800, 18538, 7386, 5726, 11, 351, 7547, 35, 8035, 410, 20, 198, 34, 69, 13, 3740, 1378, 15390, 13, 24489, 5907, 13, 70, 26800, 13, 3262, 31113, 1818, 12, 4480, ...
2.489063
640
# Definition for a binary tree node. # class TreeNode(object): # def __init__(self, val=0, left=None, right=None): # self.val = val # self.left = left # self.right = right from collections import deque from collections import defaultdict # My solution during mock, getting TLE, don't know why from collections import defaultdict from collections import deque
[ 2, 30396, 329, 257, 13934, 5509, 10139, 13, 198, 2, 1398, 12200, 19667, 7, 15252, 2599, 198, 2, 220, 220, 220, 220, 825, 11593, 15003, 834, 7, 944, 11, 1188, 28, 15, 11, 1364, 28, 14202, 11, 826, 28, 14202, 2599, 198, 2, 220, 22...
3.062992
127
from __future__ import absolute_import from sentry.db.models import ( ArrayField, BoundedPositiveIntegerField, Model, FlexibleForeignKey, sane_repr ) from django.db import models from jsonfield import JSONField from django.utils import timezone from sentry.constants import ObjectStatus from django.utils.translation import ugettext_lazy as _
[ 6738, 11593, 37443, 834, 1330, 4112, 62, 11748, 198, 198, 6738, 1908, 563, 13, 9945, 13, 27530, 1330, 357, 198, 220, 220, 220, 15690, 15878, 11, 347, 6302, 21604, 1800, 46541, 15878, 11, 9104, 11, 26719, 856, 33616, 9218, 11, 33241, 6...
3.545455
99
from .BaseDriver import BaseDriver from ..OAuthUser import OAuthUser
[ 6738, 764, 14881, 32103, 1330, 7308, 32103, 198, 6738, 11485, 23621, 1071, 12982, 1330, 440, 30515, 12982, 628 ]
3.888889
18
import pandas as pd import json import glob columns = ["Highlight","Title","Author","URL","Note","Location"] # for sample of the input json look at any json in the root of the `results` folder def convert_to_readwise_df(json_files): """Convert the internal json format to a readwise compatible dataframe Args: json_files (List[str]): list of json files Returns: pd.DataFrame: dataframe with columns as required by readwise """ df_data = [] for file in json_files: with open(file) as f: data = json.load(f) title = data['volume']['title'] author = ", ".join(data['volume']['authors']) for entry in data['highlights']: highlight = entry['content'] location = entry['location'] notes = "" if "notes" in entry: for note in notes: notes = notes+"\n"+note df_data.append([highlight,title,author,"",notes,location]) df = pd.DataFrame(df_data,columns = columns) return df if __name__ == "__main__": json_files = glob.glob("../results/*.json") df = convert_to_readwise_df(json_files) df.to_csv("tarang_readwise.csv",index=False)
[ 11748, 19798, 292, 355, 279, 67, 198, 11748, 33918, 198, 11748, 15095, 198, 28665, 82, 796, 14631, 11922, 2971, 2430, 19160, 2430, 13838, 2430, 21886, 2430, 6425, 2430, 14749, 8973, 198, 198, 2, 329, 6291, 286, 262, 5128, 33918, 804, 37...
2.289331
553
"""A collection of methods for determining whether a given spectrum is of high quality (likely to produce a high quality interpretation) """ from .heuristic import xrea from .isolation import CoIsolation, PrecursorPurityEstimator __all__ = [ "xrea", "CoIsolation", "PrecursorPurityEstimator" ]
[ 37811, 32, 4947, 286, 5050, 329, 13213, 1771, 257, 1813, 10958, 318, 198, 1659, 1029, 3081, 357, 40798, 284, 4439, 257, 1029, 3081, 10794, 8, 198, 37811, 198, 6738, 764, 258, 27915, 1330, 2124, 21468, 198, 6738, 764, 271, 21417, 1330, ...
3.404494
89
from .item import Item
[ 6738, 764, 9186, 1330, 9097, 628 ]
4
6
import discord from discord.ext import commands from styrobot.util.contrib import info import random def setup(bot): bot.add_cog(HelpCog(bot))
[ 11748, 36446, 198, 6738, 36446, 13, 2302, 1330, 9729, 198, 6738, 8944, 305, 13645, 13, 22602, 13, 3642, 822, 1330, 7508, 198, 11748, 4738, 628, 628, 198, 4299, 9058, 7, 13645, 2599, 198, 220, 220, 220, 10214, 13, 2860, 62, 66, 519, ...
3.02
50
# Testing with threading and queue modules for Thread-based parallelism import threading, queue, time # The worker thread gets jobs off the queue. When the queue is empty, it # assumes there will be no more work and exits. # (Realistically workers will run until terminated.) # Work function that processes the arguments q = queue.Queue() # Begin adding work to the queue for i in range(20): q.put(i) threadPool = [] # Start a pool of 5 workers for i in range(5): t = threading.Thread(target=worker, name='worker %i' % (i + 1)) t.start() threadPool.append(t) # time.sleep(5) # testing if workers die before work is queued - yes they do die # q.join() for i in range(20): q.put(i+20) for t in threadPool: t.join() # Give threads time to run # print('Main thread sleeping') # time.sleep(5) print('Main thread finished')
[ 2, 23983, 351, 4704, 278, 290, 16834, 13103, 329, 14122, 12, 3106, 10730, 1042, 198, 198, 11748, 4704, 278, 11, 16834, 11, 640, 628, 198, 2, 383, 8383, 4704, 3011, 3946, 572, 262, 16834, 13, 220, 1649, 262, 16834, 318, 6565, 11, 340...
3.07554
278
import pytest from pymongo import MongoClient import app as flask_app test_database_name = 'spartatest' client = MongoClient('localhost', 27017) db = client.get_database(test_database_name)
[ 11748, 12972, 9288, 198, 6738, 279, 4948, 25162, 1330, 42591, 11792, 198, 198, 11748, 598, 355, 42903, 62, 1324, 628, 198, 9288, 62, 48806, 62, 3672, 796, 705, 2777, 433, 265, 395, 6, 198, 16366, 796, 42591, 11792, 10786, 36750, 3256, ...
3.196721
61
"""Tools to quickly create twitter threads.""" from .thread import Threader __version__ = "0.1.1"
[ 37811, 33637, 284, 2952, 2251, 17044, 14390, 526, 15931, 198, 6738, 764, 16663, 1330, 14122, 263, 198, 198, 834, 9641, 834, 796, 366, 15, 13, 16, 13, 16, 1 ]
3.37931
29
# count numbers of pages from the Mediawiki history dumps import bz2 import subprocess import os from datetime import datetime inizio = datetime.now() dataset_folder = '/home/gandelli/dev/data/it/' totali = set() revisioni = set() revert = set() ns0 = set() for year in range(2001, 2021): dump_in = bz2.open(dataset_folder+'/it' + str(year) + '.tsv.bz2', 'r') line = dump_in.readline() print(year) while line != '': line = dump_in.readline().rstrip().decode('utf-8')[:-1] values = line.split('\t') if len(values) < 2: continue if values[23] != '': page = int(values[23]) totali.add(page) if values[28] == '0': ns0.add(page) if values[1] == 'revision': revisioni.add(page) if values[64] == 'true' and values[67] == 'true': revert.add(page) print('total page ',len(totali)) print('total pages ns0', len(ns0)) print('total revisions ns0', len(revisioni)) print('total revert ns0', len(revert) )
[ 2, 954, 3146, 286, 5468, 422, 262, 6343, 15466, 2106, 45514, 198, 11748, 275, 89, 17, 198, 11748, 850, 14681, 198, 11748, 28686, 198, 6738, 4818, 8079, 1330, 4818, 8079, 198, 198, 259, 528, 952, 796, 4818, 8079, 13, 2197, 3419, 198, ...
2.134387
506
import colorsys import cv2 from PIL import Image import pkg_resources from .LivescoreBase import LivescoreBase from .details import Alliance, OngoingMatchDetails
[ 11748, 7577, 893, 198, 11748, 269, 85, 17, 198, 6738, 350, 4146, 1330, 7412, 198, 11748, 279, 10025, 62, 37540, 198, 198, 6738, 764, 43, 1083, 7295, 14881, 1330, 18965, 7295, 14881, 198, 6738, 764, 36604, 1330, 10302, 11, 48041, 40519, ...
3.727273
44
from postDB import Model, Column, types from datetime import datetime import utils
[ 6738, 1281, 11012, 1330, 9104, 11, 29201, 11, 3858, 198, 6738, 4818, 8079, 1330, 4818, 8079, 198, 198, 11748, 3384, 4487, 628 ]
3.863636
22
""" Commom settings to all applications """ A = 40.3 TECU = 1.0e16 C = 299792458 F1 = 1.57542e9 F2 = 1.22760e9 factor_1 = (F1 - F2) / (F1 + F2) / C factor_2 = (F1 * F2) / (F2 - F1) / C DIFF_TEC_MAX = 0.05 LIMIT_STD = 7.5 plot_it = True REQUIRED_VERSION = 3.01 CONSTELLATIONS = ['G', 'R'] COLUMNS_IN_RINEX = {'3.03': {'G': {'L1': 'L1C', 'L2': 'L2W', 'C1': 'C1C', 'P1': 'C1W', 'P2': 'C2W'}, 'R': {'L1': 'L1C', 'L2': 'L2C', 'C1': 'C1C', 'P1': 'C1P', 'P2': 'C2P'} }, '3.02': {'G': {'L1': 'L1', 'L2': 'L2', 'C1': 'C1C', 'P1': 'C1W', 'P2': 'C2W'}, 'R': {'L1': 'L1', 'L2': 'L2', 'C1': 'C1C', 'P1': 'C1P', 'P2': 'C2P'} }, '3.01': {'G': {'L1': 'L1', 'L2': 'L2', 'C1': 'C1C', 'P1': 'C1W', 'P2': 'C2W'}, 'R': {'L1': 'L1', 'L2': 'L2', 'C1': 'C1C', 'P1': 'C1P', 'P2': 'C2P'} } }
[ 37811, 198, 6935, 296, 6460, 284, 477, 5479, 198, 37811, 198, 198, 32, 796, 2319, 13, 18, 198, 51, 2943, 52, 796, 352, 13, 15, 68, 1433, 198, 34, 796, 31011, 3720, 1731, 3365, 198, 37, 16, 796, 352, 13, 36189, 3682, 68, 24, 198,...
1.410112
712
from .channel_io import Channel, channel_entity_url
[ 6738, 764, 17620, 62, 952, 1330, 11102, 11, 6518, 62, 26858, 62, 6371 ]
3.923077
13
"""Test API utilities.""" import json from pytradfri.api.libcoap_api import APIFactory from pytradfri.gateway import Gateway def test_constructor_timeout_passed_to_subprocess(monkeypatch): """Test that original timeout is passed to subprocess.""" capture = {} monkeypatch.setattr("subprocess.check_output", capture_args) api = APIFactory("anything", timeout=20, psk="abc") api.request(Gateway().get_devices()) assert capture["timeout"] == 20 def test_custom_timeout_passed_to_subprocess(monkeypatch): """Test that custom timeout is passed to subprocess.""" capture = {} monkeypatch.setattr("subprocess.check_output", capture_args) api = APIFactory("anything", psk="abc") api.request(Gateway().get_devices(), timeout=1) assert capture["timeout"] == 1
[ 37811, 14402, 7824, 20081, 526, 15931, 198, 11748, 33918, 198, 198, 6738, 12972, 2213, 324, 69, 380, 13, 15042, 13, 8019, 1073, 499, 62, 15042, 1330, 3486, 5064, 9548, 198, 6738, 12972, 2213, 324, 69, 380, 13, 10494, 1014, 1330, 29916, ...
3.045283
265
# scrapes Townes van Zandt lyrics # sample code so I don't have to remember all of this stuff # the next time I want to source some verses from bs4 import BeautifulSoup as soup import requests import string punctuation_trans_table = str.maketrans("", "", string.punctuation) base_url = "http://ippc2.orst.edu/coopl/lyrics/" index = requests.get(base_url + "albums.html") parsed_index = soup(index.text) all_links = parsed_index.find_all("a") # get all <a> tags links = [l for l in all_links if l.text] # filter out image links def to_filename(s, path="texts/townes_van_zandt/"): '''Quick and dirty snake-casing''' s = s.replace("&amp;", "and") # special case, "Poncho & Lefty" s = strip_punctuation(s) s = s.lower() s = s.replace(" ", "_") s = path + s + ".txt" return s
[ 2, 15881, 274, 8329, 274, 5719, 1168, 392, 83, 15844, 198, 2, 6291, 2438, 523, 314, 836, 470, 423, 284, 3505, 477, 286, 428, 3404, 198, 2, 262, 1306, 640, 314, 765, 284, 2723, 617, 24752, 198, 198, 6738, 275, 82, 19, 1330, 23762, ...
2.634304
309
# coding=utf-8 """ if elif else Version: 0.1 Author: huijz Date: 2020-08-24 """ # 1:if flag = False name = 'huijz' if name == 'python': # python flag = True # print 'welcome boss' # else: print name # # 2:elif num = 5 if num == 3: # num print 'boss' elif num == 2: print 'user' elif num == 1: print 'worker' elif num < 0: # print 'error' else: print 'road' # # 3if num = 9 if 0 <= num <= 10: # 0~10 print 'hello' # : hello num = 10 if num < 0 or num > 10: # 010 print 'hello' else: print 'unDefine' # : unDefine num = 8 # 0~510~15 if (0 <= num <= 5) or (10 <= num <= 15): print 'hello' else: print 'unDefine' # : unDefine # 4var = 100 var = 100 if var == 100: print " var 100" print "Good bye!"
[ 2, 19617, 28, 40477, 12, 23, 198, 37811, 198, 361, 1288, 361, 2073, 198, 14815, 25, 657, 13, 16, 198, 13838, 25, 289, 84, 2926, 89, 198, 10430, 25, 12131, 12, 2919, 12, 1731, 198, 37811, 198, 2, 352, 25, 361, 198, 32109, 796, 10...
2.173295
352
from setuptools import setup from setuptools import find_packages setup( name="Jann", version="4.0.0", description="Jann is a Nearest Neighbour retrieval-based chatbot.", author="Kory Mathewson", author_email="korymath@gmail.com", license="MIT", url="https://github.com/korymath/jann", packages=find_packages(), setup_requires=[ "pytest-runner" ], tests_require=[ "pytest" ], )
[ 6738, 900, 37623, 10141, 1330, 9058, 198, 6738, 900, 37623, 10141, 1330, 1064, 62, 43789, 628, 198, 40406, 7, 198, 220, 220, 220, 1438, 2625, 41, 1236, 1600, 198, 220, 220, 220, 2196, 2625, 19, 13, 15, 13, 15, 1600, 198, 220, 220, ...
2.472222
180
# Copyright 2017 The Forseti Security Authors. 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. """KE Version Rule Scanner Tests.""" import unittest import mock from tests import unittest_utils from google.cloud.security.common.gcp_type import ( ke_cluster as ke_cluster_type) from google.cloud.security.common.gcp_type import ( organization as organization_type) from google.cloud.security.common.gcp_type import project as project_type from google.cloud.security.scanner.scanners import ke_version_scanner # pylint: disable=bad-indentation if __name__ == '__main__': unittest.main()
[ 2, 15069, 2177, 383, 27325, 316, 72, 4765, 46665, 13, 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, 2845, 287, 11...
3.498442
321
# ================================================================ # MIT License # Copyright (c) 2021 edwardyehuang (https://github.com/edwardyehuang) # ================================================================ import tensorflow as tf from iseg.metrics.seg_metric_wrapper import SegMetricWrapper from iseg.metrics.mean_iou import MeanIOU
[ 2, 46111, 4770, 25609, 18604, 198, 2, 17168, 13789, 198, 2, 15069, 357, 66, 8, 33448, 1225, 904, 5948, 13415, 648, 357, 5450, 1378, 12567, 13, 785, 14, 276, 904, 5948, 13415, 648, 8, 198, 2, 46111, 4770, 25609, 18604, 198, 198, 1174...
4
87
import math def lognormal_mean(m, stddev): """ compute mean of log x with mean and std. of x Args: m: mean of x stddev: standard deviation of x Returns: mean of log x """ return math.log(m) - (0.5 * math.log(1.0 + (stddev * stddev) / (m * m))) def lognormal_stddev(m, stddev): """ compute std. of log x with mean and std. of x Args: m: mean of x stddev: standard deviation of x Returns: std. of log x """ return math.sqrt(math.log((stddev * stddev) / (m * m) + 1)) def lognormal_underlying_mean(m, stddev): """ compute mean of x with mean and std of log x Args: m: mean of log x stddev: std of log x Returns: """ # if m == 0 or stddev == 0: # print '{}'.format('why ???') # return 0 return math.exp(m + 0.5 * stddev * stddev) def lognormal_underlying_stddev(m, stddev): """ compute std of x with mean and std of log x Args: m: mean of log x stddev: std of log x Returns: std of x """ # if m == 0 or stddev == 0: # print '{}'.format('strange why???') # return 0 return math.sqrt((math.exp(stddev**2.0) - 1.0) * math.exp(2.0*m + stddev**2.0)) #return lognormal_underlying_mean(m, stddev) * \ # math.sqrt((math.exp(stddev * stddev) - 1.0))
[ 11748, 10688, 201, 198, 201, 198, 201, 198, 4299, 300, 2360, 6636, 62, 32604, 7, 76, 11, 336, 1860, 1990, 2599, 201, 198, 220, 220, 220, 37227, 24061, 1612, 286, 2604, 2124, 351, 1612, 290, 14367, 13, 286, 2124, 201, 198, 220, 220, ...
1.964432
731
#!/usr/bin/env python # Tag Highlighter: # Author: A. S. Budden <abudden _at_ gmail _dot_ com> # Copyright: Copyright (C) 2009-2013 A. S. Budden # Permission is hereby granted to use and distribute this code, # with or without modifications, provided that this copyright # notice is copied with it. Like anything else that's free, # the TagHighlight plugin is provided *as is* and comes with no # warranty of any kind, either expressed or implied. By using # this plugin, you agree that in no event will the copyright # holder be liable for any damages resulting from the use # of this software. # --------------------------------------------------------------------- import os import glob from .config import config from .loaddata import LoadDataFile, LoadFile, GlobData from .debug import Debug
[ 2, 48443, 14629, 14, 8800, 14, 24330, 21015, 198, 2, 17467, 3334, 75, 4799, 25, 198, 2, 220, 220, 6434, 25, 220, 317, 13, 311, 13, 8578, 268, 1279, 397, 16557, 4808, 265, 62, 308, 4529, 4808, 26518, 62, 401, 29, 198, 2, 15069, 2...
3.083045
289
""" Bayes sensor code split out from https://github.com/home-assistant/home-assistant/blob/dev/homeassistant/components/binary_sensor/bayesian.py This module is used to explore the sensor. """ from collections import OrderedDict from const import * def update_probability(prior, prob_true, prob_false): """Update probability using Bayes' rule.""" numerator = prob_true * prior denominator = numerator + prob_false * (1 - prior) probability = numerator / denominator return probability def setup_platform(config): """Set up the Bayesian Binary sensor. Modified from async_setup_platform.""" name = config[CONF_NAME] observations = config[CONF_OBSERVATIONS] prior = config[CONF_PRIOR] probability_threshold = config[CONF_PROBABILITY_THRESHOLD] device_class = config[CONF_DEVICE_CLASS] return BayesianBinarySensor( name, prior, observations, probability_threshold, device_class)
[ 37811, 198, 15262, 274, 12694, 2438, 6626, 503, 422, 198, 5450, 1378, 12567, 13, 785, 14, 11195, 12, 562, 10167, 14, 11195, 12, 562, 10167, 14, 2436, 672, 14, 7959, 14, 11195, 562, 10167, 14, 5589, 3906, 14, 39491, 62, 82, 22854, 14...
3.012698
315
import os import glob import shutil import logging import matplotlib.pyplot as plt import numpy as np from scipy import ndimage, misc, signal, spatial from skimage.filters import gaussian, gabor_kernel import cv2 import math def gaussian2d(shape=(5, 5), sigma=0.5): """ 2D gaussian mask - should give the same result as MATLAB's fspecial('gaussian',[shape],[sigma]) """ m, n = [(ss - 1.) / 2. for ss in shape] y, x = np.ogrid[-m:m + 1, -n:n + 1] h = np.exp(-(x * x + y * y) / (2. * sigma * sigma)) h[h < np.finfo(h.dtype).eps * h.max()] = 0 sumh = h.sum() if sumh != 0: h /= sumh return h
[ 11748, 28686, 198, 198, 11748, 15095, 198, 11748, 4423, 346, 198, 11748, 18931, 198, 11748, 2603, 29487, 8019, 13, 9078, 29487, 355, 458, 83, 198, 11748, 299, 32152, 355, 45941, 198, 6738, 629, 541, 88, 1330, 299, 67, 9060, 11, 12747, ...
2.282828
297
from settings import VAR_DIR CACHE=VAR_DIR/'cache'
[ 6738, 6460, 1330, 569, 1503, 62, 34720, 198, 198, 34, 2246, 13909, 28, 53, 1503, 62, 34720, 14, 6, 23870, 6, 198 ]
2.363636
22
import os os.environ['TF_CPP_MIN_LOG_LEVEL'] = '2' #To suppress warnings thrown by tensorflow from time import sleep import numpy as np from cv2 import cv2 import pyautogui as pg import Sudoku_Core as SC import OCR s = 513//9 #Size of board//9 fs = 25 #Size of the final image if __name__ == '__main__': main()
[ 11748, 28686, 198, 418, 13, 268, 2268, 17816, 10234, 62, 8697, 47, 62, 23678, 62, 25294, 62, 2538, 18697, 20520, 796, 705, 17, 6, 197, 2, 2514, 18175, 14601, 8754, 416, 11192, 273, 11125, 198, 6738, 640, 1330, 3993, 198, 11748, 299, ...
2.680672
119
from app import db, login from flask_login import UserMixin from datetime import datetime from flask import url_for, redirect from werkzeug.security import generate_password_hash, check_password_hash
[ 6738, 598, 1330, 20613, 11, 17594, 198, 6738, 42903, 62, 38235, 1330, 11787, 35608, 259, 198, 6738, 4818, 8079, 1330, 4818, 8079, 198, 6738, 42903, 1330, 19016, 62, 1640, 11, 18941, 198, 6738, 266, 9587, 2736, 1018, 13, 12961, 1330, 771...
3.586207
58
# AUTOGENERATED! DO NOT EDIT! File to edit: source_nbs/12_top.ipynb (unless otherwise specified). __all__ = ['empty_tensor_handling_loss', 'nan_loss_handling', 'create_dummy_if_empty', 'BaseTop', 'SequenceLabel', 'Classification', 'PreTrain', 'Seq2Seq', 'MultiLabelClassification', 'MaskLM'] # Cell import logging from functools import partial from typing import Dict, Tuple, Union import tensorflow as tf import tensorflow_addons as tfa import transformers from transformers.modeling_tf_utils import TFSharedEmbeddings from tensorflow_addons.layers.crf import CRF from tensorflow_addons.text.crf import crf_log_likelihood from .params import BaseParams from .utils import gather_indexes class BaseTop(tf.keras.Model): # Cell # Cell # Cell # Cell # Cell # Cell
[ 2, 47044, 7730, 1677, 1137, 11617, 0, 8410, 5626, 48483, 0, 9220, 284, 4370, 25, 2723, 62, 77, 1443, 14, 1065, 62, 4852, 13, 541, 2047, 65, 357, 25252, 4306, 7368, 737, 198, 198, 834, 439, 834, 796, 37250, 28920, 62, 83, 22854, 62...
2.919414
273
import re def evaluate_cancellation_code(cancellation_code: str, booking_time_before: int, stay_duration: int) -> float: """ gives a numerical value to given cancellation code, return expected fine in percentage :return: """ cancellations = process_cancellation_code(cancellation_code) p = min(7, booking_time_before) chosen_p = min([lst for lst in cancellations if lst[0] > p], key=lambda tup: tup[0], default=[None, None, None]) expected_fine = 0 if chosen_p[0] is None else chosen_p[2] if chosen_p[1] is None else chosen_p[1] / stay_duration return expected_fine def no_show(cancellation_code: str) -> int: """ returns 1 if the cancellation code contains a no-show fee, and 0 otherwise """ cancellations = process_cancellation_code(cancellation_code) return any(lst for lst in cancellations if lst[0] == 0) def fine_after_x_days(cancellation_code: str, booking_time_before: int, stay_duration: int, days: int): """ returns the expected fine in percentages after 'days' days from reservation. """ time_before_reservation = booking_time_before - days if time_before_reservation < 0: return 0 cancellations = process_cancellation_code(cancellation_code) # convert cancellation policy to format (Days, Percentage) percentage_cancellations = [] for cancel in cancellations: if cancel[1] is None: percentage_cancellations.append((cancel[0], cancel[2])) else: percentage_cancellations.append((cancel[0], cancel[1] / stay_duration)) if not percentage_cancellations: return 0 # return the fine associated with the smallest number of days larger than time_before_reservation fines = [x for x in percentage_cancellations if x[0] > time_before_reservation] if not fines: return 0 return min(fines, key=lambda x: x[0])[1]
[ 11748, 302, 628, 198, 198, 4299, 13446, 62, 66, 590, 297, 341, 62, 8189, 7, 66, 590, 297, 341, 62, 8189, 25, 965, 11, 25452, 62, 2435, 62, 19052, 25, 493, 11, 2652, 62, 32257, 25, 493, 8, 4613, 12178, 25, 198, 220, 220, 220, 3...
2.760174
688
import re regex = re.compile('[^a-zA-Z]') def score_acronym(capitalized_acronym, corpus=None): """ For each capitalized letter in the acronym: * 10 points if first letter in a word (with exception of first letter) * 3 point if second or last letter in a word * 1 point otherwise * N bonus points if begins an N-length valid sub-word (ex: multiVariable -> 8 bonus points) * 2 bonus points if immediately following a capitalizd letter """ return sum([score_word(word, corpus=corpus) for word in capitalized_acronym.split(' ')]) - 10
[ 11748, 302, 198, 198, 260, 25636, 796, 302, 13, 5589, 576, 10786, 58, 61, 64, 12, 89, 32, 12, 57, 60, 11537, 628, 198, 198, 4299, 4776, 62, 330, 1313, 4948, 7, 27544, 1143, 62, 330, 1313, 4948, 11, 35789, 28, 14202, 2599, 198, 2...
2.75576
217
import requests num_of_iter = 2 data = open('./assets/test.jpg', 'rb').read() for i in range(0, num_of_iter): res = requests.get( url='http://0.0.0.0:8000/recognition/object/boxes_names' ) print("\n RESPONSE GET boxes names for test number {}: \n {}" .format(i, res.__dict__)) res = requests.post(url='http://0.0.0.0:8000/recognition/object/boxes', data=data, headers={'Content-Type': 'application/octet-stream'}) print("\n RESPONSE POST to boxes, test num {} \n Sending buffer length: {},\n Received {}" .format(i, len(data), res.__dict__)) res = requests.post(url='http://0.0.0.0:8000/recognition/object/image', data=data, headers={'Content-Type': 'application/octet-stream'}) print("\n RESPONSE POST to image, test num {} \n Sending buffer length: {},\n Received {}" .format(i, len(data), res))
[ 11748, 7007, 198, 198, 22510, 62, 1659, 62, 2676, 796, 362, 198, 198, 7890, 796, 1280, 7, 4458, 14, 19668, 14, 9288, 13, 9479, 3256, 705, 26145, 27691, 961, 3419, 198, 1640, 1312, 287, 2837, 7, 15, 11, 997, 62, 1659, 62, 2676, 259...
2.197701
435
import argparse import os import torch import torch.nn as nn from torchtext.data import TabularDataset, BucketIterator from torchtext.data import Field from torchtext.vocab import Vectors, GloVe from tqdm import tqdm, trange import sys import os sys.path.insert(0, "../../pyfunctor") sys.path.insert(0, "../../model") from cnn import CNNModel from lstm import LSTMModel from bilstm import BILSTMModel from sklearn import metrics import csv_handler as csv_handler import transform as transform import time #from util.weight import WeightClassCSV device = torch.device("cuda" if torch.cuda.is_available() else "cpu") if __name__ == "__main__": start_time = time.time() parser = argparse.ArgumentParser() parser.add_argument("--dataset", default=None, type=str, required=True, help="Dataset folder") parser.add_argument("--model", default=None, type=str, required=True, help="Model type: CNN, LSTM or BILSTM") parser.add_argument("--glove", default="840B", type=str, help="Golve version (6B, 42B, 840B)") parser.add_argument("--emb_size", default=300, type=int, help="Golve embedding size (100, 200, 300)") parser.add_argument("--max_seq_length", default=256, type=int, help="Maximum sequence length") parser.add_argument("--num_epoch", default=9, type=int, help="Number of training epoch") parser.add_argument("--batch_size", default=32, type=int, help="Batch size") parser.add_argument("--lr", default=1e-4, type=float, help="Learning rate") parser.add_argument("--fix_emb", default=False, type=bool, help="Fix embedding layer") parser.add_argument("--log_file", default=False, type=str, required=True, help="log file path") args = parser.parse_args() # Load data print("Loading data ...") train_iter, test_iter, vocab_size, vocab_weights = load_data(args.dataset, args.batch_size, args.max_seq_length, glove=args.glove, emb_size=args.emb_size) # Initialize model assert args.model in ["CNN", "LSTM", "BILSTM"], "Only support CNN, LSTM or BILSTM." if args.model == "CNN": model = CNNModel(vocab_size, args.emb_size, args.max_seq_length, weights=vocab_weights, fix_emb_weight=args.fix_emb) elif args.model == "LSTM": model = LSTMModel(vocab_size, args.emb_size, args.max_seq_length, weights=vocab_weights, fix_emb_weight=args.fix_emb) else: model = BILSTMModel(vocab_size, args.emb_size, args.max_seq_length, weights=vocab_weights, fix_emb_weight=args.fix_emb) model = model.to(device) # Train print("Training %s ..." % args.model) params = filter(lambda p: p.requires_grad, model.parameters()) optimizer = torch.optim.Adam(model.parameters(), lr=args.lr) loss_func = nn.CrossEntropyLoss() #label_weight = WeightClassCSV(args.dataset + "/train.csv").get_weights(['0', '1']) #loss_func = nn.CrossEntropyLoss(weight = torch.tensor(label_weight).to(device)) model.train() for epoch in trange(args.num_epoch, desc="Epoch"): total_loss = 0 for idx, batch in enumerate(tqdm(train_iter, desc="Iteration")): inputs, labels = batch.sent, batch.label inputs = inputs.to(device) labels = labels.to(device) logits = model(inputs) loss = loss_func(logits, labels) optimizer.zero_grad() loss.backward() optimizer.step() total_loss += loss.data.item() print("\tEpoch %d, total loss: %f" % (epoch, total_loss)) train_finish_time = time.time() train_overall_time = train_finish_time - start_time # Evaluate print("Evaluating ...") model.eval() predicts = [] golds = [] predicted_proba = [] with torch.no_grad(): for idx, batch in enumerate(tqdm(test_iter, desc="Iteration")): inputs, labels = batch.sent, batch.label inputs = inputs.to(device) logits = model(inputs) predicted_proba += list(logits.data.cpu().numpy()) predict = torch.argmax(logits, dim=1).data.cpu().numpy() predicts += list(predict) golds += list(labels.data.cpu().numpy()) precision, recall, f1 = F1(predicts, golds) print("Precision: %f, Recall: %f, F1: %f" % (precision, recall, f1)) train_time = train_overall_time test_time = time.time() - train_finish_time print(metrics.classification_report(golds, predicts)) (precision, recall, fscore, support) = metrics.precision_recall_fscore_support(golds, predicts) log_row = [] log_row.append(args.dataset) log_row.append(precision[1]) log_row.append(recall[1]) log_row.append(fscore[1]) log_row.append(train_time) log_row.append(test_time) pos_predicted = transform.map_func(predicted_proba, lambda p : p[1]) auc = metrics.roc_auc_score(golds, pos_predicted) log_row.append(auc) accuracy = metrics.accuracy_score(golds, predicts) log_row.append(accuracy) csv_handler.append_row(args.log_file, log_row)
[ 11748, 1822, 29572, 198, 11748, 28686, 198, 11748, 28034, 198, 11748, 28034, 13, 20471, 355, 299, 77, 198, 198, 6738, 28034, 5239, 13, 7890, 1330, 16904, 934, 27354, 292, 316, 11, 48353, 37787, 198, 6738, 28034, 5239, 13, 7890, 1330, 76...
1.952517
3,159
#!/usr/bin/env python from setuptools import setup, find_packages import sys try: import pypandoc readme = pypandoc.convert('README.md', 'rst') except(IOError, ImportError): with open('README.md') as f: readme = f.read() install_requires = [ 'cachetools>=1.1.5', 'requests>=2.7.0', 'xmltodict>=0.9.2', ] tests_require = [ 'pytest', 'requests-mock==0.7.0' ] setup( name='pinkopy', version='2.1.3-dev', description='Python wrapper for Commvault api', long_description=readme, author='Herkermer Sherwood', author_email='theherk@gmail.com', url='https://github.com/teamproserve/pinkopy', download_url='https://github.com/teamproserve/pinkopy/archive/2.1.3-dev.zip', packages=find_packages(), platforms=['all'], license='MIT', install_requires=install_requires, setup_requires=['pytest-runner'], tests_require=tests_require, classifiers=[ 'Development Status :: 4 - Beta', 'License :: Other/Proprietary License', 'License :: OSI Approved :: MIT License', 'Environment :: Console', 'Intended Audience :: Developers', 'Intended Audience :: System Administrators', 'Operating System :: MacOS :: MacOS X', 'Operating System :: Unix', 'Operating System :: POSIX', 'Programming Language :: Python :: 3.2', 'Programming Language :: Python :: 3.3', 'Programming Language :: Python :: 3.4', 'Programming Language :: Python :: 3.5', 'Topic :: Utilities', ], )
[ 2, 48443, 14629, 14, 8800, 14, 24330, 21015, 198, 198, 6738, 900, 37623, 10141, 1330, 9058, 11, 1064, 62, 43789, 198, 11748, 25064, 198, 198, 28311, 25, 198, 220, 220, 220, 1330, 279, 4464, 392, 420, 198, 220, 220, 220, 1100, 1326, ...
2.398162
653
"""Extension for built-in Sass functionality.""" from __future__ import absolute_import from __future__ import division from __future__ import print_function from __future__ import unicode_literals from itertools import product import math import os.path from pathlib import PurePosixPath from six.moves import xrange from scss.extension import Extension from scss.namespace import Namespace from scss.source import SourceFile from scss.types import ( Arglist, Boolean, Color, List, Null, Number, String, Map, expect_type) # Alias to make the below declarations less noisy ns = CoreExtension.namespace # ------------------------------------------------------------------------------ # Color creation # ------------------------------------------------------------------------------ # Color inspection # ------------------------------------------------------------------------------ # Color modification def _scale_channel(channel, scaleby): if scaleby is None: return channel expect_type(scaleby, Number) if not scaleby.is_simple_unit('%'): raise ValueError("Expected percentage, got %r" % (scaleby,)) factor = scaleby.value / 100 if factor > 0: # Add x% of the remaining range, up to 1 return channel + (1 - channel) * factor else: # Subtract x% of the existing channel. We add here because the factor # is already negative return channel * (1 + factor) # ------------------------------------------------------------------------------ # String functions # TODO this and several others should probably also require integers # TODO and assert that the indexes are valid # ------------------------------------------------------------------------------ # Number functions ns.set_function('abs', 1, Number.wrap_python_function(abs)) ns.set_function('round', 1, Number.wrap_python_function(round)) ns.set_function('ceil', 1, Number.wrap_python_function(math.ceil)) ns.set_function('floor', 1, Number.wrap_python_function(math.floor)) # ------------------------------------------------------------------------------ # List functions # TODO get the compass bit outta here # TODO get the compass bit outta here # TODO need a way to use "list" as the arg name without shadowing the builtin # ------------------------------------------------------------------------------ # Map functions # DEVIATIONS: these do not exist in ruby sass # ------------------------------------------------------------------------------ # Meta functions # ------------------------------------------------------------------------------ # Miscellaneous
[ 37811, 11627, 3004, 329, 3170, 12, 259, 48572, 11244, 526, 15931, 198, 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, 6738, 11593, 37443, ...
4.058647
665
from pypy.module.cpyext.test.test_api import BaseApiTest
[ 6738, 279, 4464, 88, 13, 21412, 13, 66, 9078, 2302, 13, 9288, 13, 9288, 62, 15042, 1330, 7308, 32, 14415, 14402, 628 ]
2.636364
22
# coding=utf-8 # Copyright 2019 The Google Research Authors. # # 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. """The runners.""" from __future__ import absolute_import from __future__ import division from __future__ import print_function import os import sys import time import numpy as np import tensorflow as tf from capsule_em import model as f_model from capsule_em.mnist \ import mnist_record from capsule_em.norb \ import norb_record from tensorflow.contrib import tfprof as contrib_tfprof from tensorflow.python import debug as tf_debug FLAGS = tf.app.flags.FLAGS tf.app.flags.DEFINE_integer('num_prime_capsules', 32, 'Number of first layer capsules.') tf.app.flags.DEFINE_float('learning_rate', 0.01, 'Initial learning rate') tf.app.flags.DEFINE_integer('routing_iteration', 3, 'Number of iterations for softmax routing') tf.app.flags.DEFINE_float( 'routing_rate', 1, 'ratio for combining routing logits and routing feedback') tf.app.flags.DEFINE_float('decay_rate', 0.96, 'ratio for learning rate decay') tf.app.flags.DEFINE_integer('decay_steps', 20000, 'number of steps for learning rate decay') tf.app.flags.DEFINE_bool('normalize_kernels', False, 'Normalize the capsule weight kernels') tf.app.flags.DEFINE_integer('num_second_atoms', 16, 'number of capsule atoms for the second layer') tf.app.flags.DEFINE_integer('num_primary_atoms', 16, 'number of capsule atoms for the first layer') tf.app.flags.DEFINE_integer('num_start_conv', 32, 'number of channels for the start layer') tf.app.flags.DEFINE_integer('kernel_size', 5, 'kernel size for the start layer.') tf.app.flags.DEFINE_integer( 'routing_iteration_prime', 1, 'number of routing iterations for primary capsules.') tf.app.flags.DEFINE_integer('max_steps', 2000000, 'Number of steps to run trainer.') tf.app.flags.DEFINE_string('data_dir', '/datasets/mnist/', 'Directory for storing input data') tf.app.flags.DEFINE_string('summary_dir', '/tmp/tensorflow/mnist/logs/mnist_with_summaries', 'Summaries log directory') tf.app.flags.DEFINE_bool('train', True, 'train or test.') tf.app.flags.DEFINE_integer( 'checkpoint_steps', 1500, 'number of steps before saving a training checkpoint.') tf.app.flags.DEFINE_bool('verbose_image', False, 'whether to show images.') tf.app.flags.DEFINE_bool('multi', True, 'whether to use multiple digit dataset.') tf.app.flags.DEFINE_bool('eval_once', False, 'whether to evaluate once on the ckpnt file.') tf.app.flags.DEFINE_integer('eval_size', 24300, 'number of examples to evaluate.') tf.app.flags.DEFINE_string( 'ckpnt', '/tmp/tensorflow/mnist/logs/mnist_with_summaries/train/model.ckpnt', 'The checkpoint to load and evaluate once.') tf.app.flags.DEFINE_integer('keep_ckpt', 5, 'number of examples to evaluate.') tf.app.flags.DEFINE_bool( 'clip_lr', False, 'whether to clip learning rate to not go bellow 1e-5.') tf.app.flags.DEFINE_integer('stride_1', 2, 'stride for the first convolutinal layer.') tf.app.flags.DEFINE_integer('kernel_2', 9, 'kernel size for the secon convolutinal layer.') tf.app.flags.DEFINE_integer('stride_2', 2, 'stride for the second convolutinal layer.') tf.app.flags.DEFINE_string('padding', 'VALID', 'the padding method for conv layers.') tf.app.flags.DEFINE_integer('extra_caps', 2, 'number of extra conv capsules.') tf.app.flags.DEFINE_string('caps_dims', '32,32', 'output dim for extra conv capsules.') tf.app.flags.DEFINE_string('caps_strides', '2,1', 'stride for extra conv capsules.') tf.app.flags.DEFINE_string('caps_kernels', '3,3', 'kernel size for extra conv capsuls.') tf.app.flags.DEFINE_integer('extra_conv', 0, 'number of extra conv layers.') tf.app.flags.DEFINE_string('conv_dims', '', 'output dim for extra conv layers.') tf.app.flags.DEFINE_string('conv_strides', '', 'stride for extra conv layers.') tf.app.flags.DEFINE_string('conv_kernels', '', 'kernel size for extra conv layers.') tf.app.flags.DEFINE_bool('leaky', False, 'Use leaky routing.') tf.app.flags.DEFINE_bool('staircase', False, 'Use staircase decay.') tf.app.flags.DEFINE_integer('num_gpus', 1, 'number of gpus to train.') tf.app.flags.DEFINE_bool('adam', True, 'Use Adam optimizer.') tf.app.flags.DEFINE_bool('pooling', False, 'Pooling after convolution.') tf.app.flags.DEFINE_bool('use_caps', True, 'Use capsule layers.') tf.app.flags.DEFINE_integer( 'extra_fc', 512, 'number of units in the extra fc layer in no caps mode.') tf.app.flags.DEFINE_bool('dropout', False, 'Dropout before last layer.') tf.app.flags.DEFINE_bool('tweak', False, 'During eval recons from tweaked rep.') tf.app.flags.DEFINE_bool('softmax', False, 'softmax loss in no caps.') tf.app.flags.DEFINE_bool('c_dropout', False, 'dropout after conv capsules.') tf.app.flags.DEFINE_bool( 'distort', True, 'distort mnist images by cropping to 24 * 24 and rotating by 15 degrees.') tf.app.flags.DEFINE_bool('restart', False, 'Clean train checkpoints.') tf.app.flags.DEFINE_bool('use_em', True, 'If set use em capsules with em routing.') tf.app.flags.DEFINE_float('final_beta', 0.01, 'Temperature at the sigmoid.') tf.app.flags.DEFINE_bool('eval_ensemble', False, 'eval over aggregated logits.') tf.app.flags.DEFINE_string('part1', 'ok', 'ok') tf.app.flags.DEFINE_string('part2', 'ok', 'ok') tf.app.flags.DEFINE_bool('debug', False, 'If set use tfdbg wrapper.') tf.app.flags.DEFINE_bool('reduce_mean', False, 'If set normalize mean of each image.') tf.app.flags.DEFINE_float('loss_rate', 1.0, 'classification to regularization rate.') tf.app.flags.DEFINE_integer('batch_size', 64, 'Batch size.') tf.app.flags.DEFINE_integer('norb_pixel', 48, 'Batch size.') tf.app.flags.DEFINE_bool('patching', True, 'If set use patching for eval.') tf.app.flags.DEFINE_string('data_set', 'norb', 'the data set to use.') tf.app.flags.DEFINE_string('cifar_data_dir', '/tmp/cifar10_data', """Path to the CIFAR-10 data directory.""") tf.app.flags.DEFINE_string('norb_data_dir', '/tmp/smallNORB/', """Path to the norb data directory.""") tf.app.flags.DEFINE_string('affnist_data_dir', '/tmp/affnist_data', """Path to the affnist data directory.""") num_classes = { 'mnist': 10, 'cifar10': 10, 'mnist_multi': 10, 'svhn': 10, 'affnist': 10, 'expanded_mnist': 10, 'norb': 5, } def get_features(train, total_batch): """Return batched inputs.""" print(FLAGS.data_set) batch_size = total_batch // max(1, FLAGS.num_gpus) split = 'train' if train else 'test' features = [] for i in xrange(FLAGS.num_gpus): with tf.device('/cpu:0'): with tf.name_scope('input_tower_%d' % (i)): if FLAGS.data_set == 'norb': features += [ norb_record.inputs( train_dir=FLAGS.norb_data_dir, batch_size=batch_size, split=split, multi=FLAGS.multi, image_pixel=FLAGS.norb_pixel, distort=FLAGS.distort, patching=FLAGS.patching, ) ] elif FLAGS.data_set == 'affnist': features += [ mnist_record.inputs( train_dir=FLAGS.affnist_data_dir, batch_size=batch_size, split=split, multi=FLAGS.multi, shift=0, height=40, train_file='test.tfrecords') ] elif FLAGS.data_set == 'expanded_mnist': features += [ mnist_record.inputs( train_dir=FLAGS.data_dir, batch_size=batch_size, split=split, multi=FLAGS.multi, height=40, train_file='train_6shifted_6padded_mnist.tfrecords', shift=6) ] else: if train and not FLAGS.distort: shift = 2 else: shift = 0 features += [ mnist_record.inputs( train_dir=FLAGS.data_dir, batch_size=batch_size, split=split, multi=FLAGS.multi, shift=shift, distort=FLAGS.distort) ] print(features) return features def run_training(): """Train.""" with tf.Graph().as_default(): # Input images and labels. features = get_features(True, FLAGS.batch_size) model = f_model.multi_gpu_model print('so far so good!') result = model(features) param_stats = contrib_tfprof.model_analyzer.print_model_analysis( tf.get_default_graph(), tfprof_options=contrib_tfprof.model_analyzer .TRAINABLE_VARS_PARAMS_STAT_OPTIONS) sys.stdout.write('total_params: %d\n' % param_stats.total_parameters) contrib_tfprof.model_analyzer.print_model_analysis( tf.get_default_graph(), tfprof_options=contrib_tfprof.model_analyzer.FLOAT_OPS_OPTIONS) merged = result['summary'] train_step = result['train'] # test_writer = tf.summary.FileWriter(FLAGS.summary_dir + '/test') sess = tf.Session(config=tf.ConfigProto(allow_soft_placement=True)) if FLAGS.debug: sess = tf_debug.LocalCLIDebugWrapperSession(sess, ui_type='curses') sess.add_tensor_filter('has_inf_or_nan', tf_debug.has_inf_or_nan) init_op = tf.group(tf.global_variables_initializer(), tf.local_variables_initializer()) sess.run(init_op) saver = tf.train.Saver(max_to_keep=FLAGS.keep_ckpt) if tf.gfile.Exists(FLAGS.summary_dir + '/train'): ckpt = tf.train.get_checkpoint_state(FLAGS.summary_dir + '/train/') print(ckpt) if (not FLAGS.restart) and ckpt and ckpt.model_checkpoint_path: print('hesllo') saver.restore(sess, ckpt.model_checkpoint_path) prev_step = int( ckpt.model_checkpoint_path.split('/')[-1].split('-')[-1]) else: print('what??') tf.gfile.DeleteRecursively(FLAGS.summary_dir + '/train') tf.gfile.MakeDirs(FLAGS.summary_dir + '/train') prev_step = 0 else: tf.gfile.MakeDirs(FLAGS.summary_dir + '/train') prev_step = 0 train_writer = tf.summary.FileWriter(FLAGS.summary_dir + '/train', sess.graph) coord = tf.train.Coordinator() threads = tf.train.start_queue_runners(sess=sess, coord=coord) try: step = 0 for i in range(prev_step, FLAGS.max_steps): step += 1 summary, _ = sess.run([merged, train_step]) train_writer.add_summary(summary, i) if (i + 1) % FLAGS.checkpoint_steps == 0: saver.save( sess, os.path.join(FLAGS.summary_dir + '/train', 'model.ckpt'), global_step=i + 1) except tf.errors.OutOfRangeError: print('Done training for %d steps.' % step) finally: # When done, ask the threads to stop. coord.request_stop() train_writer.close() # Wait for threads to finish. coord.join(threads) sess.close() def run_eval(): """Evaluate on test or validation.""" with tf.Graph().as_default(): # Input images and labels. features = get_features(False, 5) model = f_model.multi_gpu_model result = model(features) merged = result['summary'] correct_prediction_sum = result['correct'] almost_correct_sum = result['almost'] saver = tf.train.Saver() test_writer = tf.summary.FileWriter(FLAGS.summary_dir + '/test') seen_step = -1 time.sleep(3 * 60) paused = 0 while paused < 360: ckpt = tf.train.get_checkpoint_state(FLAGS.summary_dir + '/train/') if ckpt and ckpt.model_checkpoint_path: # Restores from checkpoin global_step = ckpt.model_checkpoint_path.split('/')[-1].split('-')[-1] else: time.sleep(2 * 60) paused += 2 continue while seen_step == int(global_step): time.sleep(2 * 60) ckpt = tf.train.get_checkpoint_state(FLAGS.summary_dir + '/train/') global_step = ckpt.model_checkpoint_path.split('/')[-1].split('-')[-1] paused += 2 if paused > 360: test_writer.close() return paused = 0 seen_step = int(global_step) print(seen_step) sess = tf.Session(config=tf.ConfigProto(allow_soft_placement=True)) saver.restore(sess, ckpt.model_checkpoint_path) coord = tf.train.Coordinator() threads = tf.train.start_queue_runners(sess=sess, coord=coord) try: total_tp = 0 total_almost = 0 for i in range(FLAGS.eval_size // 5): summary_j, tp, almost = sess.run( [merged, correct_prediction_sum, almost_correct_sum]) total_tp += tp total_almost += almost total_false = FLAGS.eval_size - total_tp total_almost_false = FLAGS.eval_size - total_almost summary_tp = tf.Summary.FromString(summary_j) summary_tp.value.add(tag='correct_prediction', simple_value=total_tp) summary_tp.value.add(tag='wrong_prediction', simple_value=total_false) summary_tp.value.add( tag='almost_wrong_prediction', simple_value=total_almost_false) test_writer.add_summary(summary_tp, global_step) print('write done') except tf.errors.OutOfRangeError: print('Done eval for %d steps.' % i) finally: # When done, ask the threads to stop. coord.request_stop() # Wait for threads to finish. coord.join(threads) sess.close() test_writer.close() def softmax(x): """Compute softmax values for each sets of scores in x.""" e_x = np.exp(x - np.max(x)) return e_x / e_x.sum() def eval_ensemble(ckpnts): """Evaluate on an ensemble of checkpoints.""" with tf.Graph().as_default(): first_features = get_features(False, 100)[0] h = first_features['height'] d = first_features['depth'] features = { 'images': tf.placeholder(tf.float32, shape=(100, d, h, h)), 'labels': tf.placeholder(tf.float32, shape=(100, 10)), 'recons_image': tf.placeholder(tf.float32, shape=(100, d, h, h)), 'recons_label': tf.placeholder(tf.int32, shape=(100)), 'height': first_features['height'], 'depth': first_features['depth'] } model = f_model.multi_gpu_model result = model([features]) logits = result['logits'] config = tf.ConfigProto(allow_soft_placement=True) # saver.restore(sess, tf.train.latest_checkpoint(FLAGS.ckpnt)) batch_logits = np.zeros((FLAGS.eval_size // 100, 100, 10), dtype=np.float32) batch_recons_label = np.zeros((FLAGS.eval_size // 100, 100), dtype=np.float32) batch_labels = np.zeros((FLAGS.eval_size // 100, 100, 10), dtype=np.float32) batch_images = np.zeros((FLAGS.eval_size // 100, 100, d, h, h), dtype=np.float32) batch_recons_image = np.zeros((FLAGS.eval_size // 100, 100, d, h, h), dtype=np.float32) saver = tf.train.Saver() sess = tf.Session(config=config) coord = tf.train.Coordinator() threads = tf.train.start_queue_runners(sess=sess, coord=coord) try: for i in range(FLAGS.eval_size // 100): (batch_recons_label[i, Ellipsis], batch_labels[i, Ellipsis], batch_images[i, Ellipsis], batch_recons_image[i, Ellipsis]) = sess.run([ first_features['recons_label'], first_features['labels'], first_features['images'], first_features['recons_image'] ]) for ckpnt in ckpnts: saver.restore(sess, ckpnt) for i in range(FLAGS.eval_size // 100): logits_i = sess.run( logits, feed_dict={ features['recons_label']: batch_recons_label[i, Ellipsis], features['labels']: batch_labels[i, Ellipsis], features['images']: batch_images[i, Ellipsis], features['recons_image']: batch_recons_image[i, Ellipsis] }) # batch_logits[i, ...] += softmax(logits_i) batch_logits[i, Ellipsis] += logits_i except tf.errors.OutOfRangeError: print('Done eval for %d steps.' % i) finally: # When done, ask the threads to stop. coord.request_stop() # Wait for threads to finish. coord.join(threads) sess.close() batch_pred = np.argmax(batch_logits, axis=2) total_wrong = np.sum(np.not_equal(batch_pred, batch_recons_label)) print(total_wrong) def eval_once(ckpnt): """Evaluate on one checkpoint once.""" ptches = np.zeros((14, 14, 32, 32)) for i in range(14): for j in range(14): ind_x = i * 2 ind_y = j * 2 for k in range(5): for h in range(5): ptches[i, j, ind_x + k, ind_y + h] = 1 ptches = np.reshape(ptches, (14 * 14, 32, 32)) with tf.Graph().as_default(): features = get_features(False, 1)[0] if FLAGS.patching: features['images'] = features['cc_images'] features['recons_label'] = features['cc_recons_label'] features['labels'] = features['cc_labels'] model = f_model.multi_gpu_model result = model([features]) # merged = result['summary'] correct_prediction_sum = result['correct'] # almost_correct_sum = result['almost'] # mid_act = result['mid_act'] logits = result['logits'] saver = tf.train.Saver() test_writer = tf.summary.FileWriter(FLAGS.summary_dir + '/test_once') config = tf.ConfigProto(allow_soft_placement=True) config.gpu_options.per_process_gpu_memory_fraction = 0.3 sess = tf.Session(config=config) # saver.restore(sess, tf.train.latest_checkpoint(FLAGS.ckpnt)) saver.restore(sess, ckpnt) coord = tf.train.Coordinator() threads = tf.train.start_queue_runners(sess=sess, coord=coord) i = 0 try: total_tp = 0 for i in range(FLAGS.eval_size): #, g_ac, ac lb, tp, lg = sess.run([ features['recons_label'], correct_prediction_sum, logits, ]) if FLAGS.patching: batched_lg = np.sum(lg / np.sum(lg, axis=1, keepdims=True), axis=0) batch_pred = np.argmax(batched_lg) tp = np.equal(batch_pred, lb[0]) total_tp += tp total_false = FLAGS.eval_size - total_tp print('false:{}, true:{}'.format(total_false, total_tp)) # summary_tp = tf.Summary.FromString(summary_j) # summary_tp.value.add(tag='correct_prediction', simple_value=total_tp) # summary_tp.value.add(tag='wrong_prediction', simple_value=total_false) # summary_tp.value.add( # tag='almost_wrong_prediction', simple_value=total_almost_false) # test_writer.add_summary(summary_tp, i + 1) except tf.errors.OutOfRangeError: print('Done eval for %d steps.' % i) finally: # When done, ask the threads to stop. coord.request_stop() # Wait for threads to finish. coord.join(threads) sess.close() test_writer.close() if __name__ == '__main__': tf.app.run()
[ 2, 19617, 28, 40477, 12, 23, 198, 2, 15069, 13130, 383, 3012, 4992, 46665, 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, 2845, 287, ...
2.198007
9,232
# Copyright 2021 Internet Corporation for Assigned Names and Numbers. # # This Source Code Form is subject to the terms of the Mozilla Public # License, v. 2.0. If a copy of the MPL was not distributed with this # file, you can obtain one at https://mozilla.org/MPL/2.0/. # # Developed by Sinodun IT (sinodun.com) # # Aggregation client subnet statistics import textwrap import grafanalib.core as GCore import grafanacommon as GCommon
[ 2, 15069, 33448, 4455, 10501, 329, 2195, 3916, 28531, 290, 27797, 13, 198, 2, 198, 2, 770, 8090, 6127, 5178, 318, 2426, 284, 262, 2846, 286, 262, 29258, 5094, 198, 2, 13789, 11, 410, 13, 362, 13, 15, 13, 1002, 257, 4866, 286, 262,...
3.351145
131
""" Module to train a simple MLP for demo. """ from jobman.tools import expand from jobman.tools import flatten import logging import nice_experiment import numpy as np from os import path from pylearn2.config import yaml_parse from pylearn2.neuroimaging_utils.datasets import MRI from pylearn2.neuroimaging_utils.dataset_utils import mri_nifti from pylearn2.scripts.jobman.experiment import ydict from pylearn2.utils import serial logging.basicConfig(format="[%(module)s:%(levelname)s]:%(message)s") logger = logging.getLogger(__name__) yaml_file = nice_experiment.yaml_file if __name__ == "__main__": parser = nice_experiment.make_argument_parser() args = parser.parse_args() if args.verbose: logger.setLevel(logging.DEBUG) main(args)
[ 37811, 198, 26796, 284, 4512, 257, 2829, 10373, 47, 329, 13605, 13, 198, 37811, 198, 198, 6738, 1693, 805, 13, 31391, 1330, 4292, 198, 6738, 1693, 805, 13, 31391, 1330, 27172, 268, 198, 198, 11748, 18931, 198, 11748, 3621, 62, 23100, ...
2.775362
276
#Embedded file name: /Users/versonator/Jenkins/live/output/Live/mac_64_static/Release/python-bundle/MIDI Remote Scripts/_Framework/Layer.py u""" Module implementing a way to resource-based access to controls in an unified interface dynamic. """ from __future__ import absolute_import, print_function, unicode_literals from builtins import str from builtins import object from future.utils import raise_ from itertools import repeat from .ControlElement import ControlElementClient from .Util import nop from .Resource import ExclusiveResource, CompoundResource from .Disconnectable import Disconnectable
[ 2, 31567, 47238, 2393, 1438, 25, 1220, 14490, 14, 49589, 1352, 14, 44875, 5331, 14, 12583, 14, 22915, 14, 18947, 14, 20285, 62, 2414, 62, 12708, 14, 26362, 14, 29412, 12, 65, 31249, 14, 44, 2389, 40, 21520, 12327, 82, 47835, 21055, ...
3.8125
160
# retrieve_exons_sequence_genomes.py # This script is to retrieve exons from sequenced genomes which are also present in the reference genome (A. thaliana). # To identify the contigs from the sequenced genomes, each contig has to be retrieved from A. thaliana first. # Then, for each sequence query of A. thaliana, the query can be BLAT against the database reference. # In this case, the database reference will be S. irio and A. lyrata. # Made by: Elfy Ly # Date: 19 May 2020 import os from Bio import SeqIO path_to_at_exons_dir = "/mnt/c/Users/elfyl/PycharmProjects/brassicaceae-hybseq-pipeline-offline/results/exons" path_to_at_dir = "/mnt/c/Users/elfyl/PycharmProjects/brassicaceae-hybseq-pipeline-offline/data/reference_genomes" path_to_at_reference = path_to_at_dir + "/ref-at.fasta" # Create exons_AT Directory if don't exist if not os.path.exists(path_to_at_exons_dir): os.mkdir(path_to_at_exons_dir) print("Directory ", path_to_at_exons_dir, " Created ") else: print("Directory ", path_to_at_exons_dir, " already exists") # Create new files for every sequence query of the reference genome A. thaliana count_id = 0 for seq_record in SeqIO.parse(path_to_at_reference, "fasta"): f = open(path_to_at_exons_dir + "/" + seq_record.id + ".txt", "w+") print("New text file created: " + seq_record.id + ".fa") seq_id = seq_record.id seq_seq = str(seq_record.seq) f.write(">" + seq_id + "\n" + seq_seq) f.close() count_id += 1 print("Number of sequence records: " + str(count_id))
[ 2, 19818, 62, 1069, 684, 62, 43167, 62, 5235, 2586, 13, 9078, 198, 2, 770, 4226, 318, 284, 19818, 409, 684, 422, 4726, 5864, 42136, 543, 389, 635, 1944, 287, 262, 4941, 19270, 357, 32, 13, 294, 7199, 64, 737, 198, 2, 1675, 5911, ...
2.72549
561
import re
[ 11748, 302, 198 ]
3.333333
3
import unittest from ....providers.aws.interactive import requires_replacement
[ 11748, 555, 715, 395, 198, 6738, 19424, 15234, 4157, 13, 8356, 13, 3849, 5275, 1330, 4433, 62, 35666, 5592, 628, 198 ]
3.857143
21
from setuptools import setup, find_packages setup( name='digicert-express', version='1.1dev2', description='Express Install for DigiCert, Inc.', long_description=readme(), classifiers=[ 'Development Status :: 3 - Alpha', 'Intended Audience :: Information Technology', 'License :: OSI Approved :: MIT License', 'Topic :: Security', 'Programming Language :: Python :: 2.6', 'Programming Language :: Python :: 2.7', ], url='https://github.com/digicert/digicert_express', author='DigiCert, Inc.', author_email='support@digicert.com', license='MIT', zip_safe=False, packages=find_packages(exclude=['tests.*', '*.tests.*', '*.tests', 'tests', 'scripts']), include_package_data=True, install_requires=[ 'python-augeas', 'requests>=2.8.1', 'ndg-httpsclient', 'pyasn1', 'pyOpenSSL' # prefer OS install but we can try here, too ], )
[ 6738, 900, 37623, 10141, 1330, 9058, 11, 1064, 62, 43789, 198, 198, 40406, 7, 198, 220, 220, 220, 1438, 11639, 12894, 291, 861, 12, 42712, 3256, 198, 220, 220, 220, 2196, 11639, 16, 13, 16, 7959, 17, 3256, 198, 220, 220, 220, 6764, ...
2.444724
398
import argparse import json import numpy as np import os import torch import data_ import models import utils from matplotlib import cm, pyplot as plt from tensorboardX import SummaryWriter from torch import optim from torch.utils import data from tqdm import tqdm from utils import io parser = argparse.ArgumentParser() # CUDA parser.add_argument('--use_gpu', type=bool, default=True, help='Whether to use GPU.') # data parser.add_argument('--dataset_name', type=str, default='spirals', help='Name of dataset to use.') parser.add_argument('--n_data_points', default=int(1e6), help='Number of unique data points in training set.') parser.add_argument('--batch_size', type=int, default=256, help='Size of batch used for training.') parser.add_argument('--num_workers', type=int, default=0, help='Number of workers used in data loaders.') # MADE parser.add_argument('--n_residual_blocks_made', default=4, help='Number of residual blocks in MADE.') parser.add_argument('--hidden_dim_made', default=256, help='Dimensionality of hidden layers in MADE.') parser.add_argument('--activation_made', default='relu', help='Activation function for MADE.') parser.add_argument('--use_batch_norm_made', default=False, help='Whether to use batch norm in MADE.') parser.add_argument('--dropout_probability_made', default=None, help='Dropout probability for MADE.') # energy net parser.add_argument('--context_dim', default=64, help='Dimensionality of context vector.') parser.add_argument('--n_residual_blocks_energy_net', default=4, help='Number of residual blocks in energy net.') parser.add_argument('--hidden_dim_energy_net', default=128, help='Dimensionality of hidden layers in energy net.') parser.add_argument('--energy_upper_bound', default=0, help='Max value for output of energy net.') parser.add_argument('--activation_energy_net', default='relu', help='Activation function for energy net.') parser.add_argument('--use_batch_norm_energy_net', default=False, help='Whether to use batch norm in energy net.') parser.add_argument('--dropout_probability_energy_net', default=None, help='Dropout probability for energy net.') parser.add_argument('--scale_activation', default='softplus', help='Activation to use for scales in proposal mixture components.') parser.add_argument('--apply_context_activation', default=False, help='Whether to apply activation to context vector.') # proposal parser.add_argument('--n_mixture_components', default=10, help='Number of proposal mixture components (per dimension).') parser.add_argument('--proposal_component', default='gaussian', help='Type of location-scale family distribution ' 'to use in proposal mixture.') parser.add_argument('--n_proposal_samples_per_input', default=20, help='Number of proposal samples used to estimate ' 'normalizing constant during training.') parser.add_argument('--n_proposal_samples_per_input_validation', default=100, help='Number of proposal samples used to estimate ' 'normalizing constant during validation.') parser.add_argument('--mixture_component_min_scale', default=1e-3, help='Minimum scale for proposal mixture components.') # optimization parser.add_argument('--learning_rate', default=5e-4, help='Learning rate for Adam.') parser.add_argument('--n_total_steps', default=int(4e5), help='Number of total training steps.') parser.add_argument('--alpha_warm_up_steps', default=5000, help='Number of warm-up steps for AEM density.') parser.add_argument('--hard_alpha_warm_up', default=True, help='Whether to use a hard warm up for alpha') # logging and checkpoints parser.add_argument('--monitor_interval', default=100, help='Interval in steps at which to report training stats.') parser.add_argument('--visualize_interval', default=10000, help='Interval in steps at which to report training stats.') parser.add_argument('--save_interval', default=10000, help='Interval in steps at which to save model.') # reproducibility parser.add_argument('--seed', default=1638128, help='Random seed for PyTorch and NumPy.') args = parser.parse_args() torch.manual_seed(args.seed) np.random.seed(args.seed) if args.use_gpu and torch.cuda.is_available(): device = torch.device('cuda') torch.set_default_tensor_type('torch.cuda.FloatTensor') else: device = torch.device('cpu') # Generate data train_dataset = data_.load_plane_dataset(args.dataset_name, args.n_data_points) train_loader = data_.InfiniteLoader( dataset=train_dataset, batch_size=args.batch_size, shuffle=True, drop_last=True, num_epochs=None ) # Generate test grid data n_points_per_axis = 512 bounds = np.array([ [-4, 4], [-4, 4] ]) grid_dataset = data_.TestGridDataset(n_points_per_axis=n_points_per_axis, bounds=bounds) grid_loader = data.DataLoader( dataset=grid_dataset, batch_size=1000, drop_last=False ) # various dimensions for autoregressive and energy nets dim = 2 # D output_dim_multiplier = args.context_dim + 3 * args.n_mixture_components # K + 3M # Create MADE made = models.ResidualMADE( input_dim=dim, n_residual_blocks=args.n_residual_blocks_made, hidden_dim=args.hidden_dim_made, output_dim_multiplier=output_dim_multiplier, conditional=False, activation=utils.parse_activation(args.activation_made), use_batch_norm=args.use_batch_norm_made, dropout_probability=args.dropout_probability_made ).to(device) # create energy net energy_net = models.ResidualEnergyNet( input_dim=(args.context_dim + 1), n_residual_blocks=args.n_residual_blocks_energy_net, hidden_dim=args.hidden_dim_energy_net, energy_upper_bound=args.energy_upper_bound, activation=utils.parse_activation(args.activation_energy_net), use_batch_norm=args.use_batch_norm_energy_net, dropout_probability=args.dropout_probability_energy_net ).to(device) # create AEM aem = models.AEM( autoregressive_net=made, energy_net=energy_net, context_dim=args.context_dim, n_proposal_mixture_components=args.n_mixture_components, proposal_component_family=args.proposal_component, n_proposal_samples_per_input=args.n_proposal_samples_per_input, mixture_component_min_scale=args.mixture_component_min_scale, apply_context_activation=args.apply_context_activation ).to(device) # make optimizer parameters = list(made.parameters()) + list(energy_net.parameters()) optimizer = optim.Adam(parameters, lr=args.learning_rate) scheduler = optim.lr_scheduler.CosineAnnealingLR(optimizer, args.n_total_steps) # create summary writer and write to log directory timestamp = io.get_timestamp() log_dir = os.path.join(io.get_log_root(), args.dataset_name, timestamp) writer = SummaryWriter(log_dir=log_dir) filename = os.path.join(log_dir, 'config.json') with open(filename, 'w') as file: json.dump(vars(args), file) # Training loop tbar = tqdm(range(args.n_total_steps)) alpha = 0 for step in tbar: aem.train() scheduler.step(step) optimizer.zero_grad() # training step batch = next(train_loader).to(device) log_density, log_proposal_density, _, log_normalizer = aem(batch) mean_log_density = torch.mean(log_density) mean_log_proposal_density = torch.mean(log_proposal_density) mean_log_normalizer = torch.mean(log_normalizer) if args.alpha_warm_up_steps is not None: if args.hard_alpha_warm_up: alpha = float(step > args.alpha_warm_up_steps) else: alpha = torch.Tensor([min(step / args.alpha_warm_up_steps, 1)]) loss = - (alpha * mean_log_density + mean_log_proposal_density) else: loss = - (mean_log_density + mean_log_proposal_density) loss.backward() optimizer.step() if (step + 1) % args.monitor_interval == 0: s = 'Loss: {:.4f}, log p: {:.4f}, log q: {:.4f}'.format( loss.item(), mean_log_density.item(), mean_log_proposal_density.item() ) tbar.set_description(s) # write summaries summaries = { 'loss': loss.detach(), 'log-prob-aem': mean_log_density.detach(), 'log-prob-proposal': mean_log_proposal_density.detach(), 'log-normalizer': mean_log_normalizer.detach(), 'learning-rate': torch.Tensor(scheduler.get_lr()), } for summary, value in summaries.items(): writer.add_scalar(tag=summary, scalar_value=value, global_step=step) if (step + 1) % args.visualize_interval == 0: # Plotting aem.eval() aem.set_n_proposal_samples_per_input_validation( args.n_proposal_samples_per_input_validation) log_density_np = [] log_proposal_density_np = [] for batch in grid_loader: batch = batch.to(device) log_density, log_proposal_density, unnormalized_log_density, log_normalizer = aem( batch) log_density_np = np.concatenate(( log_density_np, utils.tensor2numpy(log_density) )) log_proposal_density_np = np.concatenate(( log_proposal_density_np, utils.tensor2numpy(log_proposal_density) )) fig, axs = plt.subplots(1, 3, figsize=(7.5, 2.5)) axs[0].hist2d(train_dataset.data[:, 0], train_dataset.data[:, 1], range=bounds, bins=512, cmap=cm.viridis, rasterized=False) axs[0].set_xticks([]) axs[0].set_yticks([]) axs[1].pcolormesh(grid_dataset.X, grid_dataset.Y, np.exp(log_proposal_density_np).reshape(grid_dataset.X.shape)) axs[1].set_xlim(bounds[0]) axs[1].set_ylim(bounds[1]) axs[1].set_xticks([]) axs[1].set_yticks([]) axs[2].pcolormesh(grid_dataset.X, grid_dataset.Y, np.exp(log_density_np).reshape(grid_dataset.X.shape)) axs[2].set_xlim(bounds[0]) axs[2].set_ylim(bounds[1]) axs[2].set_xticks([]) axs[2].set_yticks([]) plt.tight_layout() path = os.path.join(io.get_output_root(), 'pytorch', '{}.png'.format(args.dataset_name)) if not os.path.exists(path): os.makedirs(io.get_output_root()) plt.savefig(path, dpi=300) writer.add_figure(tag='test-grid', figure=fig, global_step=step) plt.close() if (step + 1) % args.save_interval == 0: path = os.path.join(io.get_checkpoint_root(), 'pytorch', '{}.t'.format(args.dataset_name)) if not os.path.exists(path): os.makedirs(io.get_checkpoint_root()) torch.save(aem.state_dict(), path) path = os.path.join(io.get_checkpoint_root(), 'pytorch', '{}-{}.t'.format(args.dataset_name, timestamp)) torch.save(aem.state_dict(), path)
[ 11748, 1822, 29572, 198, 11748, 33918, 198, 11748, 299, 32152, 355, 45941, 198, 11748, 28686, 198, 11748, 28034, 198, 198, 11748, 1366, 62, 198, 11748, 4981, 198, 11748, 3384, 4487, 198, 198, 6738, 2603, 29487, 8019, 1330, 12067, 11, 1297...
2.315918
4,919
import sys sys.path.append('../utils') from utils import * from doubly_linkedlist import * def link_chords(chordprogression): """ Chord progression is a sequences of chords. A valid linked_chords can be one of the following: 1: the chord name(str) in CHORD dict 2: the key(type Key) and a music have to a signal of start and end. >>> c_p1 = [START,C_Major,'C','Am','F','G','C','Am','F','G7',END] >>> c_p2 = [START,C_Major,'C','Am','F','G','C','Am','F','G',G_Major,'Em','C','D','D7','G',END] >>> l1 = link_chords(c_p1) >>> l1 start - C - Am - F - G - C - Am - F - G7 - end >>> l2 = link_chords(c_p2) >>> l2 start - C - Am - F - G - C - Am - F - G - Em - C - D - D7 - G - end >>> l2[8].key is C_Major True >>> l2[8].chord == CHORD['G'] True >>> l2[9].key is G_Major True >>> l2[9].chord == CHORD['Em'] True >>> c_p3 = [C_Major,C_Major,START,'C',END,START,START,END,'F',G_Major] >>> l3 = link_chords(c_p3) >>> l3 start - C - end - start - start - end - F """ key = None res = LinkedList() for item in chordprogression: if type(item) is Major_Scale or type(item) is minor_Scale: key = item else: if item not in CHORD: chord = item else: chord = CHORD[item] node = LinkedChord(chord,key,item) res.append(node) return res
[ 11748, 25064, 198, 17597, 13, 6978, 13, 33295, 10786, 40720, 26791, 11537, 198, 6738, 3384, 4487, 1330, 1635, 198, 6738, 3385, 306, 62, 25614, 4868, 1330, 1635, 198, 198, 4299, 2792, 62, 354, 3669, 7, 354, 585, 1676, 32383, 2599, 198, ...
2.089337
694
# coding: utf-8 #------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for # license information. #-------------------------------------------------------------------------- import unittest import azure.mgmt.documentdb from msrestazure.azure_exceptions import CloudError from testutils.common_recordingtestcase import record from tests.mgmt_testcase import HttpStatusCode, AzureMgmtTestCase import logging #logging.basicConfig(level=logging.DEBUG) #------------------------------------------------------------------------------ if __name__ == '__main__': unittest.main()
[ 2, 19617, 25, 3384, 69, 12, 23, 198, 198, 2, 10097, 45537, 198, 2, 15069, 357, 66, 8, 5413, 10501, 13, 1439, 2489, 10395, 13, 198, 2, 49962, 739, 262, 17168, 13789, 13, 4091, 13789, 13, 14116, 287, 262, 1628, 6808, 329, 198, 2, ...
4.484663
163
import argparse PROJROOTDIR = {'mac': '/Users/taehapark/SLAB/speedplusbaseline', 'linux': '/home/somrita/Documents/Satellite_Pose_Estimation/speedplusbaseline'} DATAROOTDIR = {'mac': '/Users/taehapark/SLAB/speedplus/data/datasets', 'linux': '/home/somrita/Documents/Satellite_Pose_Estimation/dataset'} parser = argparse.ArgumentParser('Configurations for SPEED+ Baseline Study') # ------------------------------------------------------------------------------------------ # Basic directories and names parser.add_argument('--seed', type=int, default=2021) parser.add_argument('--projroot', type=str, default=PROJROOTDIR['linux']) parser.add_argument('--dataroot', type=str, default=DATAROOTDIR['linux']) parser.add_argument('--dataname', type=str, default='speedplus') parser.add_argument('--savedir', type=str, default='checkpoints/synthetic/krn') parser.add_argument('--resultfn', type=str, default='') parser.add_argument('--logdir', type=str, default='log/synthetic/krn') parser.add_argument('--pretrained', type=str, default='') # ------------------------------------------------------------------------------------------ # Model config. parser.add_argument('--model_name', type=str, default='krn') parser.add_argument('--input_shape', nargs='+', type=int, default=(224, 224)) parser.add_argument('--num_keypoints', type=int, default=11) # KRN-specific parser.add_argument('--num_classes', type=int, default=5000) # SPN-specific parser.add_argument('--num_neighbors', type=int, default=5) # SPN-specific parser.add_argument('--keypts_3d_model', type=str, default='src/utils/tangoPoints.mat') parser.add_argument('--attitude_class', type=str, default='src/utils/attitudeClasses.mat') # ------------------------------------------------------------------------------------------ # Training config. parser.add_argument('--start_over', dest='auto_resume', action='store_false', default=True) parser.add_argument('--randomize_texture', dest='randomize_texture', action='store_true', default=False) parser.add_argument('--perform_dann', dest='dann', action='store_true', default=False) parser.add_argument('--texture_alpha', type=float, default=0.5) parser.add_argument('--texture_ratio', type=float, default=0.5) parser.add_argument('--use_fp16', dest='fp16', action='store_true', default=False) parser.add_argument('--batch_size', type=int, default=32) parser.add_argument('--max_epochs', type=int, default=75) parser.add_argument('--num_workers', type=int, default=8) parser.add_argument('--test_epoch', type=int, default=-1) parser.add_argument('--optimizer', type=str, default='rmsprop') parser.add_argument('--lr', type=float, default=0.001) parser.add_argument('--momentum', type=float, default=0.9) parser.add_argument('--weight_decay', type=float, default=5e-5) parser.add_argument('--lr_decay_alpha', type=float, default=0.96) parser.add_argument('--lr_decay_step', type=int, default=1) # ------------------------------------------------------------------------------------------ # Dataset-related inputs parser.add_argument('--train_domain', type=str, default='synthetic') parser.add_argument('--test_domain', type=str, default='lightbox') parser.add_argument('--train_csv', type=str, default='train.csv') parser.add_argument('--test_csv', type=str, default='lightbox.csv') # ------------------------------------------------------------------------------------------ # Other miscellaneous settings parser.add_argument('--gpu_id', type=int, default=0) parser.add_argument('--no_cuda', dest='use_cuda', action='store_false', default=True) # End cfg = parser.parse_args()
[ 11748, 1822, 29572, 198, 198, 31190, 41, 13252, 2394, 34720, 796, 1391, 6, 20285, 10354, 220, 31051, 14490, 14, 83, 3609, 45897, 668, 14, 8634, 6242, 14, 12287, 9541, 12093, 4470, 3256, 198, 220, 220, 220, 220, 220, 220, 220, 220, 220...
2.940532
1,278
""" HyperOne HyperOne API # noqa: E501 The version of the OpenAPI document: 0.1.0 Generated by: https://openapi-generator.tech """ import re # noqa: F401 import sys # noqa: F401 from h1.api_client import ApiClient, Endpoint as _Endpoint from h1.model_utils import ( # noqa: F401 check_allowed_values, check_validations, date, datetime, file_type, none_type, validate_and_convert_types ) from h1.model.event import Event from h1.model.inline_response400 import InlineResponse400 from h1.model.insight_project_journal_create import InsightProjectJournalCreate from h1.model.insight_project_journal_credential_patch import InsightProjectJournalCredentialPatch from h1.model.insight_project_journal_transfer import InsightProjectJournalTransfer from h1.model.insight_project_journal_update import InsightProjectJournalUpdate from h1.model.journal import Journal from h1.model.journal_credential import JournalCredential from h1.model.resource_service import ResourceService from h1.model.tag import Tag from h1.model.tag_array import TagArray
[ 37811, 198, 220, 220, 220, 15079, 3198, 628, 220, 220, 220, 15079, 3198, 7824, 220, 1303, 645, 20402, 25, 412, 33548, 628, 220, 220, 220, 383, 2196, 286, 262, 4946, 17614, 3188, 25, 657, 13, 16, 13, 15, 198, 220, 220, 220, 2980, 5...
3.087571
354
from django.http import HttpResponse from django.utils.module_loading import import_string def pdf(request): """ Get form's number (decimal type: 101.15 - where "101" is form's group and "15"-number itsels). Can't use 1,2,3,4,5,6,7,8,9 for number itsels - which stands after the point. Bacause in database field store in decimal format xxx.yy - two number after dot, and active status. Must use: 01,02,03-09,10,11,12-19,20,21,22-29,30,31..... :param request: :return: """ response = HttpResponse(content_type='application/pdf') t = request.GET.get("type") response['Content-Disposition'] = 'inline; filename="form-' + t + '.pdf"' f = import_string('forms.forms' + t[0:3] + '.form_' + t[4:6]) response.write(f(request_data=request.GET)) return response
[ 6738, 42625, 14208, 13, 4023, 1330, 367, 29281, 31077, 198, 6738, 42625, 14208, 13, 26791, 13, 21412, 62, 25138, 1330, 1330, 62, 8841, 628, 198, 4299, 37124, 7, 25927, 2599, 198, 220, 220, 220, 37227, 198, 220, 220, 220, 3497, 1296, 3...
2.703333
300
#!/usr/bin/env python import PySimpleGUI as sg import cv2 import subprocess import shutil import os import sys # Demonstrates a number of PySimpleGUI features including: # Default element size # auto_size_buttons # Button # Dictionary return values # update of elements in form (Text, Input) def runCommand(cmd, timeout=None, window=None): """ run shell command @param cmd: command to execute @param timeout: timeout for command execution @return: (return code from command, command output) """ p = subprocess.Popen(cmd, shell=True, stdout=subprocess.PIPE, stderr=subprocess.STDOUT) output = '' for line in p.stdout: line = line.decode(errors='replace' if (sys.version_info) < (3, 5) else 'backslashreplace').rstrip() output += line print(line) if window: window.Refresh() retval = p.wait(timeout) return (retval, output) layout = [[sg.Text('Enter Your Passcode')], [sg.Input('', size=(10, 1), key='input')], [sg.Button('1'), sg.Button('2'), sg.Button('3')], [sg.Button('4'), sg.Button('5'), sg.Button('6')], [sg.Button('7'), sg.Button('8'), sg.Button('9')], [sg.Button('Submit'), sg.Button('0'), sg.Button('Clear')], [sg.Text('', size=(15, 1), font=('Helvetica', 18), text_color='red', key='out')], ] window = sg.Window('Keypad', layout, default_button_element_size=(5, 2), auto_size_buttons=False, grab_anywhere=False) # Loop forever reading the form's values, updating the Input field keys_entered = '' while True: event, values = window.read() # read the form if event == sg.WIN_CLOSED: # if the X button clicked, just exit break if event == 'Clear': # clear keys if clear button keys_entered = '' elif event in '1234567890': keys_entered = values['input'] # get what's been entered so far keys_entered += event # add the new digit elif event == 'Submit': keys_entered = values['input'] if values['input']=='123456': sg.popup('') w() else: sg.popup('') window['out'].update(keys_entered) # output the final string # change the form to reflect current key string window['input'].update(keys_entered) window.close()
[ 2, 48443, 14629, 14, 8800, 14, 24330, 21015, 198, 11748, 9485, 26437, 40156, 355, 264, 70, 198, 11748, 269, 85, 17, 198, 11748, 850, 14681, 198, 11748, 4423, 346, 198, 11748, 28686, 198, 11748, 25064, 198, 2, 7814, 2536, 689, 257, 127...
2.340755
1,033
# # This is Seisflows # # See LICENCE file # ############################################################################### raise NotImplementedError
[ 2, 198, 2, 770, 318, 1001, 271, 44041, 198, 2, 198, 2, 4091, 38559, 18310, 2393, 198, 2, 198, 29113, 29113, 7804, 4242, 21017, 198, 198, 40225, 1892, 3546, 1154, 12061, 12331, 198 ]
4.606061
33
from data.objects.data import Data
[ 6738, 1366, 13, 48205, 13, 7890, 1330, 6060, 198 ]
3.888889
9
# -*- coding: utf-8 -*- from rest_framework import viewsets from rest_framework.permissions import IsAuthenticatedOrReadOnly from .models import Country, Event from .serializers import CountrySerializer, EventSerializer
[ 2, 532, 9, 12, 19617, 25, 3384, 69, 12, 23, 532, 9, 12, 198, 198, 6738, 1334, 62, 30604, 1330, 5009, 1039, 198, 6738, 1334, 62, 30604, 13, 525, 8481, 1330, 1148, 47649, 3474, 5574, 5569, 10049, 198, 198, 6738, 764, 27530, 1330, 12...
3.672131
61
# -*- coding: utf-8 -*- # Spearmint # # Academic and Non-Commercial Research Use Software License and Terms # of Use # # Spearmint is a software package to perform Bayesian optimization # according to specific algorithms (the Software). The Software is # designed to automatically run experiments (thus the code name # 'spearmint') in a manner that iteratively adjusts a number of # parameters so as to minimize some objective in as few runs as # possible. # # The Software was developed by Ryan P. Adams, Michael Gelbart, and # Jasper Snoek at Harvard University, Kevin Swersky at the # University of Toronto (Toronto), and Hugo Larochelle at the # Universit de Sherbrooke (Sherbrooke), which assigned its rights # in the Software to Socpra Sciences et Gnie # S.E.C. (Socpra). Pursuant to an inter-institutional agreement # between the parties, it is distributed for free academic and # non-commercial research use by the President and Fellows of Harvard # College (Harvard). # # Using the Software indicates your agreement to be bound by the terms # of this Software Use Agreement (Agreement). Absent your agreement # to the terms below, you (the End User) have no rights to hold or # use the Software whatsoever. # # Harvard agrees to grant hereunder the limited non-exclusive license # to End User for the use of the Software in the performance of End # Users internal, non-commercial research and academic use at End # Users academic or not-for-profit research institution # (Institution) on the following terms and conditions: # # 1. NO REDISTRIBUTION. The Software remains the property Harvard, # Toronto and Socpra, and except as set forth in Section 4, End User # shall not publish, distribute, or otherwise transfer or make # available the Software to any other party. # # 2. NO COMMERCIAL USE. End User shall not use the Software for # commercial purposes and any such use of the Software is expressly # prohibited. This includes, but is not limited to, use of the # Software in fee-for-service arrangements, core facilities or # laboratories or to provide research services to (or in collaboration # with) third parties for a fee, and in industry-sponsored # collaborative research projects where any commercial rights are # granted to the sponsor. If End User wishes to use the Software for # commercial purposes or for any other restricted purpose, End User # must execute a separate license agreement with Harvard. # # Requests for use of the Software for commercial purposes, please # contact: # # Office of Technology Development # Harvard University # Smith Campus Center, Suite 727E # 1350 Massachusetts Avenue # Cambridge, MA 02138 USA # Telephone: (617) 495-3067 # Facsimile: (617) 495-9568 # E-mail: otd@harvard.edu # # 3. OWNERSHIP AND COPYRIGHT NOTICE. Harvard, Toronto and Socpra own # all intellectual property in the Software. End User shall gain no # ownership to the Software. End User shall not remove or delete and # shall retain in the Software, in any modifications to Software and # in any Derivative Works, the copyright, trademark, or other notices # pertaining to Software as provided with the Software. # # 4. DERIVATIVE WORKS. End User may create and use Derivative Works, # as such term is defined under U.S. copyright laws, provided that any # such Derivative Works shall be restricted to non-commercial, # internal research and academic use at End Users Institution. End # User may distribute Derivative Works to other Institutions solely # for the performance of non-commercial, internal research and # academic use on terms substantially similar to this License and # Terms of Use. # # 5. FEEDBACK. In order to improve the Software, comments from End # Users may be useful. End User agrees to provide Harvard with # feedback on the End Users use of the Software (e.g., any bugs in # the Software, the user experience, etc.). Harvard is permitted to # use such information provided by End User in making changes and # improvements to the Software without compensation or an accounting # to End User. # # 6. NON ASSERT. End User acknowledges that Harvard, Toronto and/or # Sherbrooke or Socpra may develop modifications to the Software that # may be based on the feedback provided by End User under Section 5 # above. Harvard, Toronto and Sherbrooke/Socpra shall not be # restricted in any way by End User regarding their use of such # information. End User acknowledges the right of Harvard, Toronto # and Sherbrooke/Socpra to prepare, publish, display, reproduce, # transmit and or use modifications to the Software that may be # substantially similar or functionally equivalent to End Users # modifications and/or improvements if any. In the event that End # User obtains patent protection for any modification or improvement # to Software, End User agrees not to allege or enjoin infringement of # End Users patent against Harvard, Toronto or Sherbrooke or Socpra, # or any of the researchers, medical or research staff, officers, # directors and employees of those institutions. # # 7. PUBLICATION & ATTRIBUTION. End User has the right to publish, # present, or share results from the use of the Software. In # accordance with customary academic practice, End User will # acknowledge Harvard, Toronto and Sherbrooke/Socpra as the providers # of the Software and may cite the relevant reference(s) from the # following list of publications: # # Practical Bayesian Optimization of Machine Learning Algorithms # Jasper Snoek, Hugo Larochelle and Ryan Prescott Adams # Neural Information Processing Systems, 2012 # # Multi-Task Bayesian Optimization # Kevin Swersky, Jasper Snoek and Ryan Prescott Adams # Advances in Neural Information Processing Systems, 2013 # # Input Warping for Bayesian Optimization of Non-stationary Functions # Jasper Snoek, Kevin Swersky, Richard Zemel and Ryan Prescott Adams # Preprint, arXiv:1402.0929, http://arxiv.org/abs/1402.0929, 2013 # # Bayesian Optimization and Semiparametric Models with Applications to # Assistive Technology Jasper Snoek, PhD Thesis, University of # Toronto, 2013 # # 8. NO WARRANTIES. THE SOFTWARE IS PROVIDED "AS IS." TO THE FULLEST # EXTENT PERMITTED BY LAW, HARVARD, TORONTO AND SHERBROOKE AND SOCPRA # HEREBY DISCLAIM ALL WARRANTIES OF ANY KIND (EXPRESS, IMPLIED OR # OTHERWISE) REGARDING THE SOFTWARE, INCLUDING BUT NOT LIMITED TO ANY # IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR # PURPOSE, OWNERSHIP, AND NON-INFRINGEMENT. HARVARD, TORONTO AND # SHERBROOKE AND SOCPRA MAKE NO WARRANTY ABOUT THE ACCURACY, # RELIABILITY, COMPLETENESS, TIMELINESS, SUFFICIENCY OR QUALITY OF THE # SOFTWARE. HARVARD, TORONTO AND SHERBROOKE AND SOCPRA DO NOT WARRANT # THAT THE SOFTWARE WILL OPERATE WITHOUT ERROR OR INTERRUPTION. # # 9. LIMITATIONS OF LIABILITY AND REMEDIES. USE OF THE SOFTWARE IS AT # END USERS OWN RISK. IF END USER IS DISSATISFIED WITH THE SOFTWARE, # ITS EXCLUSIVE REMEDY IS TO STOP USING IT. IN NO EVENT SHALL # HARVARD, TORONTO OR SHERBROOKE OR SOCPRA BE LIABLE TO END USER OR # ITS INSTITUTION, IN CONTRACT, TORT OR OTHERWISE, FOR ANY DIRECT, # INDIRECT, SPECIAL, INCIDENTAL, CONSEQUENTIAL, PUNITIVE OR OTHER # DAMAGES OF ANY KIND WHATSOEVER ARISING OUT OF OR IN CONNECTION WITH # THE SOFTWARE, EVEN IF HARVARD, TORONTO OR SHERBROOKE OR SOCPRA IS # NEGLIGENT OR OTHERWISE AT FAULT, AND REGARDLESS OF WHETHER HARVARD, # TORONTO OR SHERBROOKE OR SOCPRA IS ADVISED OF THE POSSIBILITY OF # SUCH DAMAGES. # # 10. INDEMNIFICATION. To the extent permitted by law, End User shall # indemnify, defend and hold harmless Harvard, Toronto and Sherbrooke # and Socpra, their corporate affiliates, current or future directors, # trustees, officers, faculty, medical and professional staff, # employees, students and agents and their respective successors, # heirs and assigns (the "Indemnitees"), against any liability, # damage, loss or expense (including reasonable attorney's fees and # expenses of litigation) incurred by or imposed upon the Indemnitees # or any one of them in connection with any claims, suits, actions, # demands or judgments arising from End Users breach of this # Agreement or its Institutions use of the Software except to the # extent caused by the gross negligence or willful misconduct of # Harvard, Toronto or Sherbrooke or Socpra. This indemnification # provision shall survive expiration or termination of this Agreement. # # 11. GOVERNING LAW. This Agreement shall be construed and governed by # the laws of the Commonwealth of Massachusetts regardless of # otherwise applicable choice of law standards. # # 12. NON-USE OF NAME. Nothing in this License and Terms of Use shall # be construed as granting End Users or their Institutions any rights # or licenses to use any trademarks, service marks or logos associated # with the Software. You may not use the terms Harvard or # University of Toronto or Universit de Sherbrooke or Socpra # Sciences et Gnie S.E.C. (or a substantially similar term) in any # way that is inconsistent with the permitted uses described # herein. You agree not to use any name or emblem of Harvard, Toronto # or Sherbrooke, or any of their subdivisions for any purpose, or to # falsely suggest any relationship between End User (or its # Institution) and Harvard, Toronto and/or Sherbrooke, or in any # manner that would infringe or violate any of their rights. # # 13. End User represents and warrants that it has the legal authority # to enter into this License and Terms of Use on behalf of itself and # its Institution. import copy import sys, logging import numpy as np import numpy.random as npr import scipy.linalg as spla import scipy.optimize as spo import scipy.io as sio import scipy.stats as sps try: import scipy.weave as weave except ImportError: import weave from .gp import GP from ..utils.param import Param as Hyperparameter from ..kernels import Matern52, Noise, Scale, SumKernel, TransformKernel from ..sampling.slice_sampler import SliceSampler from ..sampling.whitened_prior_slice_sampler import WhitenedPriorSliceSampler from ..sampling.elliptical_slice_sampler import EllipticalSliceSampler from ..utils import priors from ..transformations import BetaWarp, Transformer try: module = sys.modules['__main__'].__file__ log = logging.getLogger(module) except: log = logging.getLogger() print 'Not running from main.'
[ 2, 532, 9, 12, 19617, 25, 3384, 69, 12, 23, 532, 9, 12, 198, 2, 2531, 1670, 600, 198, 2, 198, 2, 31421, 290, 8504, 12, 48401, 4992, 5765, 10442, 13789, 290, 17637, 198, 2, 286, 5765, 198, 2, 198, 2, 2531, 1670, 600, 318, 257, ...
3.612022
2,928
from machine import Pin, ADC from network import LoRa import socket from utime import sleep # Use a pin for a 'config' mode configPin = Pin('P21', Pin.IN, Pin.PULL_UP) # Create an ADC object adc = ADC() # vbatt pin: vbatt = adc.channel(attn=1, pin='P16') # Initialise LoRa in LoRa mode # For Europe, use LoRa.EU868 lora = LoRa(mode=LoRa.LORA, region=LoRa.EU868) # Create a raw LoRa socket s = socket.socket(socket.AF_LORA, socket.SOCK_RAW) # Check the Config pin: configMode = not configPin() if not configMode: print('Reading Battery') pycom.rgbled(0x0000FF) message = 'Battery Status: {}'.format(battConversion()) print(message) sleep(2) print('Sending battery status estimate...') pycom.rgbled(0xFF0000) sleep(2) s.setblocking(True) # Send some data s.send(message) print('Message Sent!') pycom.rgbled(0x00FF00) sleep(2) print('Going to sleep') machine.deepsleep(300000) # Otherwise, we are in 'config' so exit to REPL print('Config Mode')
[ 6738, 4572, 1330, 13727, 11, 49169, 198, 6738, 3127, 1330, 6706, 21762, 198, 11748, 17802, 198, 6738, 3384, 524, 1330, 3993, 198, 198, 2, 5765, 257, 6757, 329, 257, 705, 11250, 6, 4235, 198, 11250, 28348, 796, 13727, 10786, 47, 2481, ...
2.553885
399