text
stringlengths
65
6.05M
lang
stringclasses
8 values
type
stringclasses
2 values
id
stringlengths
64
64
# Sample module in the public domain. Feel free to use this as a template # for your modules (and you can remove this header and take complete credit # and liability) # # Contact: Brian Carrier [carrier <at> sleuthkit [dot] org] # # This is free and unencumbered software released into the public domain. # # Anyone is f...
Python
CL
bd8ef12c5c4434beffaa3b9393f53d4630a688c1d70d4ea2dbd9fd174ab22380
# # 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 # ...
Python
CL
7b44339e542e855c867d5a3a053cb7e87d94972bd58f3f1fa112669872360f3d
"""Run this script to start the digital brain.""" from app.ask import ask import app.io as io from app.language import get_language from app.match import Matcher from app.memories.persistent import PersistentMemory from app.tell import tell from app.types.command import Command from app.types.validation import Validat...
Python
CL
e195db08285178137acdd2d64cc32c6ebd8dc865079ee5fd4db5eb70fd490917
import numpy as np import torch import json class ImageDatabase(torch.utils.data.Dataset): """ Dataset for IMDB used in Pythia General format that we have standardize follows: { metadata: { 'version': x }, data: [ { 'id': DATASET_SET_ID,...
Python
CL
167ed5a734fba6960c86bf950496a92ed610542fd118ef842571667ca102f73b
""" For now, there is a single _read() and a single _write() method, tied to the file system. In the future, these will be code cells in a context, and it will be possible to register custom _read() and _write() cells, e.g. for storage in a database. Same for _exists. _init() is invoked at startup: If authority is...
Python
CL
99d7860d6f7df96b7cdfd792a7694cbabe2021eeb5acc3befd4a4ad9febe986c
"""Test cases for rule factory.""" import string import random from urllib.parse import urljoin from looseserver.common.rule import RuleFactory from looseserver.server.application import configure_application, DEFAULT_CONFIGURATION_ENDPOINT def test_rule_factory(server_response_factory, server_rule_prototype): ...
Python
CL
cee18ec89332c1c2e47881d8cc4654259ccd619612d2277780153c254b25e524
import matplotlib; matplotlib.use("agg") from __future__ import print_function import functools import numpy as np import matplotlib.pyplot as plt import pandas as pd import ROOT; import sys sys.path.append('/global/homes/w/wbhimji/cori-envs/nersc-rootpy/lib/python2.7/site-packages/') import root_numpy as rnp # # ...
Python
CL
668a58e7656eee33e6817092f655296e709766dfb012a417e0672be9d29afb62
''' GUI module graphic generator Created on: 11-20-2019 Last edited: 11-20-2019 @Copyright - Ken Trinh @All rights reserve ''' import tkinter as tk import abc class PlotterGUI(metaclass=abc.ABCMeta): #Constructor def __init__(self): pass #String Method def __str__(self): return "Generic GUI generator" ...
Python
CL
1e9d5866b542299f154a18e26eba6065e019d9a72632849ff0fdb49b7f768996
# coding: utf-8 import random import time import hashlib from inspect import isclass from git import Repo as GitRepo from sqlalchemy.inspection import inspect as sqlalchemyinspect from sqlalchemy.ext.declarative import declarative_base from pykl.tiny.grapheneinfo import ( _is_graphql, _is_graphql_cls, _i...
Python
CL
22fb2adfec713f198880f419af613a91742872984b8d7386f81ff824301fc6a2
class Formula: def __init__(self, formula: str="", str_logic= "", disjunctions=None): self.disjunctions = [] if formula != "": formula = self.remove_comments(formula) self.num_variables, self.num_clauses, formula = self.variables_and_clauses(formula) self.str_form...
Python
CL
f9148d29ea66973dde92448d8d926f8470ed123e3c44340c065a5720ac83b025
class FSMError(Exception): """An exception class for StateMachine. """ def __init__(self, msg): self.msg = msg class StateMachine(object): """ A class to represent a Finite State Machine. """ def __init__(self): self.handlers = {} self.arrival_handlers = {} self...
Python
CL
c4c20190f64b18360e5d3aeaffd8f7830622895a4e8d396cec980099dab12af9
#!/usr/bin/env python # -*- Mode: Python; tab-width: 4; indent-tabs-mode: nil; coding: utf-8; -*- # vim:set ft=python ts=4 sw=4 sts=4 autoindent: """Per-project configuration functionality for Brat Rapid Annotation Tool (brat) Author: Pontus Stenetorp <pontus is s u-tokyo ac jp> Author: Sampo Pyysalo ...
Python
CL
d7233df58b8b111b1b8ef14e2b2fb6b5d127371716390dc90a32144f4d938c81
# coding: utf-8 # Distributed under the terms of the MIT License. """ This file defines some useful scraper functionality, like custom errors and a scraper function wrapper. """ import glob import os import gzip import traceback as tb from matador.orm.spectral import VibrationalDOS, VibrationalDispersion from matad...
Python
CL
0acee167e53749dfe7a8cf9d5b8d28519fce08076fe452efe2ddeead69fda601
import os import logging from datetime import datetime import numpy as np from sklearn.metrics import accuracy_score, f1_score import vaex import vaex.ml import vaex.ml.lightgbm # Configure logging logging.basicConfig(level=os.environ.get("LOGLEVEL", "INFO")) log = logging.getLogger(__name__) # Stream the data fro...
Python
CL
9d46b8b0ecc5e18d6b524994f06ed0ff9cd395b2e5e49beba42ab4070baa3dae
""" ### **Execution Environment** Working examples of all flavors of image specification. An image can be: * an existing image from Dockerhub or another image registry * a python image with python requirements * a dockerfile for full flexibility Code can be added to an image: * copy local code * clone from git * use ...
Python
CL
8896cd0c69cce17386bced02272d4c196a0fe54a387d4b4fc80d5eb8813ae9be
#!/usr/bin/env python import sys, math, os, glob import re as regex import argparse import toml import numpy as np import h5py import asteval import matplotlib matplotlib.use('Agg') import matplotlib.pyplot as plot from matplotlib.backends.backend_pdf import PdfPages from pbpl.units import * from .core import setup_plo...
Python
CL
f132781467585c9ba7c2ca2571dc014a23f3109fbaa6f102af7b7138c220b238
#! /usr/bin/env python3.3 """Common functions for all P4GF server implementations.""" from collections import namedtuple from contextlib import contextmanager, ExitStack import functools import logging import os import random import re import signal import sys import time import p4gf_atomic_lock from P4 import Map, P...
Python
CL
d3a4c8ca8b1a9b2d28836d1991e1314e0d2e15e48b8d517ebbed6cc7d318cf0c
# -*- coding: utf-8 -*- """ Created on Sun Feb 18 16:02:26 2021 @author: Syed Muhammmad Hamza """ from keras.layers import merge, Dropout, Dense, Lambda, Flatten, Activation from keras.layers.convolutional import MaxPooling2D, Convolution2D, AveragePooling2D from keras.layers.normalization import BatchNormaliz...
Python
CL
aceca5172043b90253a1f26a739beb1e0bcd9f7158c0bc2c763f929fe651fd4e
from __future__ import absolute_import from __future__ import division from __future__ import print_function import argparse import sys import tensorflow as tf class ImageRecognizer: def __init__(self, path, graph, labels, input_layer_name, output_layer_name, num_top_predictions): self.path = path ...
Python
CL
3e956ac922c734b85c6b09046de4f2141d5ecc7b0040e301fc8de18d48be1530
# -*- coding: utf-8 -*- r"""Kinked WLC with twist and fixed ends This module calculates statistics for a series of worm-like chains with twist (DNA linkers) connected by kinks imposed by nucleosomes. Calculations include R^2, Kuhn length, propogator matrices, full Green's function for the end-to-end distance of the po...
Python
CL
ae5a6d93f59a732751230e316016b1f1f26aec92c0591e4f90dbeefc61d1f7c9
# Class adapted from: # https://github.com/TheMrGhostman/InceptionTime-Pytorch # and # https://github.com/okrasolar/pytorch-timeseries import numpy as np from typing import cast, Union, List import torch from torch import nn from DeepLearning.deep_learning_utils import Conv1dSamePadding class ShortNetwork(nn.Module...
Python
CL
ff6fcfa2312245300dc4df93ddaea78752669a387e56075963a59b681fcd3ce1
import torch import torch.nn as nn from collections import OrderedDict # import tensorboardX as tbx from package.model.vgg import vgg16, vgg16_bn class Flatten(nn.Module): def __init__(self): super(Flatten, self).__init__() def forward(self, x): x = x.view(x.size(0), -1) return x cl...
Python
CL
70d9e66571fc9558945b7d35e33d51c3db5e90b1ae6a75a9814923068212360a
# PySNMP SMI module. Autogenerated from smidump -f python OSPF-MIB # by libsmi2pysnmp-0.1.3 at Thu May 22 11:58:06 2014, # Python version sys.version_info(major=2, minor=7, micro=2, releaselevel='final', serial=0) # Imports ( Integer, ObjectIdentifier, OctetString, ) = mibBuilder.importSymbols("ASN1", "Integer", "Obj...
Python
CL
38f6a2b426600eb4e819eeff1553b2c81deeedb7b89cae639e9317722c89cf6e
#!/usr/bin/env python3.7 ''' Python >=3.7 script to generate a human-readable XLSX dump on a specified Nutanix Prism Central instance ''' import os import os.path import sys import socket import getpass import argparse from time import localtime, strftime from string import Template try: import urllib3 impor...
Python
CL
b9420795be63d1f906125edc5fdb3a69a105f1ecec154da41397439eae4ceb99
import json from vkwave.api.methods import APIOptionsRequestContext from vkwave.bots.core.types.json_types import JSONDecoder from vkwave.http import AbstractHTTPClient from vkwave.types.responses import DocsSaveResponseModel class VoiceUploader: def __init__( self, api_context: APIOptionsRequestContext,...
Python
CL
0c41be37f2a32504bddf217f368751f01e6693d58d60d935a8675be3f274e8a8
"""Create the object store groupworkspace names, gws manager, quota and email from the elastic tape quotas and create user records, groupworkspace records and object store quotas. This script is run via ./manage runscript""" import jdma_site.settings as settings from jdma_control.models import User, Groupwork...
Python
CL
7630837e5a2c8369370257741691147b4b0fb0c8f6970f5fdd9c41e141129f79
# -*- coding: utf-8 -*- import re import numpy as np from typing import List def append_EOS(texts: List[str], eos: str) -> List[str]: """ Appends EOS to each text. >>> texts = ["a\\n", "b\\n"] >>> eos = "<EOS>" >>> append_EOS(texts=texts, eos=eos) ['a<EOS>', 'b<EOS>'] """ return [text....
Python
CL
d87842211d02e8779f4e1e2b97629d5086874566bebb2a0292a2f7aaff20bf1f
#!/usr/bin/env python3 """Handle graphing of Azure network deployments. Copyright 2021 Alexander Kuemmel 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-...
Python
CL
3d1271c9b1e9c93110676f1ffd7039d75cd2f66050fcba2a76b9b1d4d2387b6a
from django.db.models import Count from django.shortcuts import get_object_or_404 from django.http import Http404 from django.urls import reverse_lazy from django.views.generic import DetailView, TemplateView, RedirectView, ListView from django.views.generic.edit import CreateView, UpdateView, DeleteView from blog.for...
Python
CL
88d78450a570a0b39aeb4f7fd6d82d142de87e81e2449e18cd52c403ebbd2b69
#! /usr/bin/env python3 # import numpy as np import matplotlib.pyplot as plt import platform import time import sys import os import math from mpl_toolkits.mplot3d import Axes3D from sys import exit sys.path.append(os.path.join("../")) from base import plot2d, plotocc from timestamp.timestamp import timestamp from i...
Python
CL
3a01b451ac800031e3112891b2fcccc27674f08ebecc211f6c22311b928f3a88
# Copyright (c) 2019-2020, RTE (https://www.rte-france.com) # See AUTHORS.txt # This Source Code Form is subject to the terms of the Apache License, version 2.0. # If a copy of the Apache License, version 2.0 was not distributed with this file, you can obtain one at http://www.apache.org/licenses/LICENSE-2.0. # SP...
Python
CL
0160a1441a243427d7edaa7bb4342008d090d4d46627a295a66bce48173b26ad
# -*- coding: utf-8 -*- from __future__ import unicode_literals import time import xml.etree.ElementTree as ET __all__ = ["Message", "User", "Location"] def pop_from_etree(xml, tag): ele = xml.find(tag) if ele is not None: xml.remove(ele) return ele return None class D...
Python
CL
dc5bb4500e3d0200208b420a95463ac3f0d8355c8a95628f6bddbb7cf6bbc62d
# use dig to validate DNS record then add valid records to Smokeping Target # convert valid FQDNs from `dig -f +noall +answer` to SmokePing targets # # example input format # dl.t6.lixian.vip.xunlei.com. 1783 IN CNAME t0540.sandai.net. # t0540.sandai.net. 1783 IN A 61.147.76.41 # dl.t13.lixian.vip.xunlei.com. 1785 IN C...
Python
CL
62cebdd374ec14563a12f2999581f91674d0cf69f53905427cea5370a59b005b
import untangle import collections import json import operator import os import csv import io cube_visualstudio_path = os.path.join('..', '..', 'Contract_r') output_folder = os.path.join('.', 'output') def enumerable_diffs(ea, eb): return [a for a in ea if a not in eb] create_tables_using_friendly_names = True...
Python
CL
1f5cfa35126402e58b2655d098ee7637981ad2e23610c626baa7f43b40b494ae
import torch import torch.nn as nn import torch.nn.functional as F import torch.optim as optim import numpy as np import gym import matplotlib.pyplot as plt # @misc{pytorchrl, # author = {Kostrikov, Ilya}, # title = {PyTorch Implementations of Reinforcement Learning Algorithms}, # year = {2018}, # publisher = {...
Python
CL
88b0dbc06f936dc94c4293e048aae50a08994a5dc648b5f9e9d63ae218a6da29
from get_eigen_space import get_eigen_space from datagen import get_face94_male import pickle import os from test import test import argparse if __name__ == "__main__": parser = argparse.ArgumentParser() parser.add_argument('-f', '--file_path', help="file path to image data", type=str, default='data/faces94/m...
Python
CL
92406f51e7073c024d7b20aff8ed83e1550cfb79be9ad01ef97fc34f0b90a3f7
# -*- coding: utf-8 -*- import json import os import unittest from configparser import ConfigParser from unittest.mock import Mock from installed_clients.WorkspaceClient import Workspace from kb_ModelIndexer.kb_ModelIndexerImpl import kb_ModelIndexer from kb_ModelIndexer.kb_ModelIndexerServer import MethodContext cl...
Python
CL
ea0c3ec77f98e267c3b21330bd331eb487a6a7234ca758032da3557b08bd405c
import os import sys import logging import argparse sys.path.append("libs") import numpy as np import tensorflow as tf from tensorflow.keras import backend as K from utils import Init_logging from cvae import CollaborativeVAE from data import CVaeDataGenerator from pretrain_vae import get_lp_vae from la...
Python
CL
577290b6880d6a8d2578c6d4e2ce0315bc84800c02a9956503a2d894d7438c5c
""" The long short term Memory (LSTM) neural network, which can capture temporal information, has a strong ability to capture long information with its own Memory attributes """ # use RNN to finish text classification from __future__ import absolute_import from __future__ import division from __future__ import prin...
Python
CL
d752c02071c581eaad4c552bd3fffe5f32aaf836b50ca1b93b4340d14c5d1e3b
"""ProjectAuto URL Configuration The `urlpatterns` list routes URLs to views. For more information please see: https://docs.djangoproject.com/en/1.11/topics/http/urls/ Examples: Function views 1. Add an import: from my_app import views 2. Add a URL to urlpatterns: url(r'^$', views.home, name='home') Clas...
Python
CL
cb32cf4feb09bba132e1f49b9ba21ede35f99ca31191ffcd44dd86a9015d903f
""" Useful tools. Stolen from here: https://github.com/Swall0w/torchstat""" import numpy as np import torch import torch.nn as nn def compute_flops(module, inp, out): if isinstance(module, nn.Conv1d): return compute_Conv1d_flops(module, inp[0], out) if isinstance(module, nn.Conv2d): return com...
Python
CL
2c2f815216399c33b1827d63ad6a0d67245d3379ffa5df0a7817bccfb2495476
from cs import CloudStack from cs import CloudStackException from heat.engine import properties from heat.engine import resource from gettext import gettext as _ from time import sleep __author__ = 'cima' class CloudstackSecurityGroup(resource.Resource): PROPERTIES = ( API_ENDPOINT, API_KEY, ...
Python
CL
1883b7b14959e02224595dcd2e0e3fb1cbb09c253f2d9995659b9ecaa0ea0fe4
from distutils.core import setup from setuptools import find_packages setup(name='tezos-hd-util', version='0.1.7', packages=find_packages(), install_requires=[ 'chainside-btcpy-multi>=0.2.78,<0.3.0', 'pyblake2>=1.1.2,<2.0.0', 'secp256k1new>=0.13.2,<0.14.0', ]...
Python
CL
6aaab345d1d3bf3bb1ce9c82f8d57d24203c7a129ea4298cc5f2eb64c17b03ba
from data_reader.utils import get_dicts, get_schema_emb from data_reader.read_data import get_dialogues, get_seqs, get_batch, get_frame_level_data from models.utils import get_bert_tokenizer from models.model import Model import numpy as np from loss import LossFn from transformers import * import torch import os from ...
Python
CL
4c5e3bf479164926b49627915a8d9d485fab07a49c44ea5f25e8b191b96f9589
# read genIO CCI data and write it to csv timeseries import numpy as np from rsdata.ESA_CCI_SM.interface import ESA_CCI_SM from pygeogrids.grids import CellGrid import pygrids.ESA_CCI_SM as cci_grid from datetime import datetime from pytesmo.timedate import julian import matplotlib.pyplot as plt def read_gpis(): ...
Python
CL
23c1652ccf639f9274c910a3016bac56315a5e06daa9e1b584cde0ac2bc987ed
"""Miscellaneous utility methods for this repository.""" import os import errno import functools import inspect import warnings def ensure_dir(path): """Ensure that the directory specified exists, and if not, create it.""" try: os.makedirs(path) except OSError as exception: if exception.er...
Python
CL
bf61dcb530bbf06e9b9483646e79d47f22542aca2f6e614fcb4f17bedb02a29a
import numpy as np from growth_rate import growth_factor from pmh import Pmm, get_PkInterps, linz_bz from prep_camb import CAMB, Clxy from scipy.integrate import simps from params import get_params from scipy.interpolate import ...
Python
CL
4e4569f804103028ff3fe3f3caf2c5aff84ab098502636c7f4e3fce6a005f716
#!/usr/bin/python2 # # Copyright (c) 2012 The Native Client Authors. All rights reserved. # Use of this source code is governed by a BSD-style license that can be # found in the LICENSE file. """Obtain objdump and gas binaries. Usage: obtain_binutils.py <objdump> <gas> Check out appropriate version of binutils, ...
Python
CL
1e5ebc9d84fb6cc0cdce89a88ba6bb8de7d7a003032a177bde88c911cb70704b
#!/usr/bin/env python """ WSGI config for mysite project. It exposes the WSGI callable as a module-level variable named ``application``. For more information on this file, see https://docs.djangoproject.com/en/1.8/howto/deployment/wsgi/ """ import os from os.path import dirname,abspath PROJECT_DIR = dirname(dirnam...
Python
CL
8edb30ce5200a421600e344cd6442298a69f8f4d573fa232605bccd68b57594a
""" Chains find_files with a .get request: A script to list files, pulled from: https://developers.google.com/drive/api/v3/reference/files/list """ from ..CLI import CLI from ..Services import FilesService as Files from ..Utilities import Downloader params = CLI.get_parse_dict( ( "--dir", dict( ...
Python
CL
7fdfb8bb73733464a1907e3de1b16243f93fd70e0ced88ae98091ded991951fe
# *************************************************************** # Copyright (c) 2019 Dun Liang <randonlang@gmail.com>. All Rights Reserved. # This file is subject to the terms and conditions defined in # file 'LICENSE.txt', which is part of this source code package. # *************************************************...
Python
CL
e1704013bb2b9a715dc595c1792f1dfa1d3d674de687f00dcbc083c0e0b9c800
#!/usr/bin/python # -*- coding: utf-8 -*- # # Copyright 2005,2006 TUBITAK/UEKAE # Licensed under the GNU General Public License, version 2. # See the file http://www.gnu.org/licenses/old-licenses/gpl-2.0.txt from pisi.actionsapi import autotools from pisi.actionsapi import pisitools from pisi.actionsapi import shellto...
Python
CL
1e80e1797bfe01c0f57fefa43bfa163f537058290581e848488dfc3b9a3d2f15
# -*- coding:utf-8 -*- import os import sys import signal import argparse import json import time from kafka import KafkaProducer, KafkaConsumer from kafka.errors import kafka_errors from phystats.logger import logger from phystats.daemonize import daemonizef from phystats.collector.power_info import power_info from p...
Python
CL
556dbb5225d94eb1dbe6edf749027c2e4aec287b5acc073f77d2c070e809ef5f
# Chris Hicks 2020 # # Selection of the ith order statistic (e.g. smallest or median) of an array is a # fundamentally easier problem than sorting and can be done in linear time! # # Input: A file of integers, one per line, first line specifies size and i. # Output: The ith order statistic of the input array of integer...
Python
CL
1a9d43ec4ac8626dd35dc59d1324d5b127d6acf9de80ce1269a785ded8891ea3
import math import numpy import numpy.random as nrand """ Note - for some of the metrics the absolute value is returns. This is because if the risk (loss) is higher we want to discount the expected excess return from the portfolio by a higher amount. Therefore risk should be positive. """ def vol(returns):...
Python
CL
5cae5743e66147a8febae09faf34f1d3d0c0df427c47b22de9b857dd9da6c338
import base64 import os from argparse import Namespace from unittest import TestCase from unittest.mock import MagicMock, patch from onelogin_aws_cli import OneloginAWS TEST_ROOT = os.path.join(os.path.dirname(__file__), "fixtures") class TestOneloginAWS(TestCase): ROLE_PREFIX = "arn:aws:iam::123456789012:role/...
Python
CL
18ba467bdd504d155ce13e3ac1dc6234c0420ae5cd7689dbffa7db156b29d072
''' Created on Feb 21, 2018 @author: dgrewal ''' import pypeliner import pypeliner.managed as mgd from wgs.utils import helpers def create_vcf2maf_workflow( vcf_file, maf_file, reference, vep_fasta_suffix, vep_ncbi_build, vep_cache_version, vep_species, ...
Python
CL
0c2d600c41e98ad57154aea85ee8cbd8e58b7c954d0b7fdf00bef904eba65d0d
import os import requests import re from tqdm import tqdm import zipfile import numpy as np # consts DATA_DIR = 'data' RAW_DATA_DIR = os.path.join(DATA_DIR, 'raw') METRICS_DATA_DIR = os.path.join(DATA_DIR, 'with_metrics') RESULTS_DIR = 'results' EXPERIMENTS_DIR = os.path.join(DATA_DIR, 'experiments') LABEL_VAL_FIELD =...
Python
CL
78bfecbf006fefb322df707d48dd664b280501c21fd08dd952358329c305b796
"""Logging utility """ from ..helper.models import MetricUnit from .logger import ( log_metric, logger_inject_lambda_context, logger_inject_process_booking_sfn, logger_setup, ) __all__ = [ "logger_setup", "logger_inject_lambda_context", "logger_inject_process_booking_sfn", ...
Python
CL
cc8a90343cb167e91c038ef6b247eedce9fa135505c2182b61dc7eeecfe472a5
#!/usr/bin/python import logging import logging.config import sys import importlib from ansible.module_utils.basic import AnsibleModule try: from StringIO import StringIO except ImportError: from io import StringIO import datetime from ibmsecurity.appliance.isdsappliance import ISDSAppliance fro...
Python
CL
d3b8bb8b136ad1568ef78dfb188153c163307439ac19947435bce036dfabbcb7
import torch import numpy as np class PartialDataset(torch.utils.data.Dataset): def __init__(self, parent_ds, offset, length): self.parent_ds = parent_ds self.offset = offset self.length = length assert len(parent_ds) >= offset + length, Exception("Parent Dataset not long enough") ...
Python
CL
16875da198ea78345a88a083be1b2e7e1f9820bc4267879fb7180f766188ccdd
# -------------------------------------------------------- # Author: James Griffiths # Date Created: Monday, 1st July 2019 # Version: 1.0 # -------------------------------------------------------- # Challenge six ------------------------------------------ # Description: http://www.pythonchallenge.com/pc/def/peak.html...
Python
CL
159148330f91192bc7a76c8d49754a86dba4c2fc7539b343d83404bc37155a90
class RunningModeEnum: RANDOMIZATION = "data_randomization" REACTION_BASED_SLICING = "reaction_based_slicing" DUPLICATE_REMOVAL = "duplicate_removal" STATS_EXTRACTION = "stats_extraction" FILE_SHUFFLING = "file_shuffling" REACTION_VALIDATION = "reaction_validation" REAGENT_VALIDATION = "re...
Python
CL
d9ef4ab6138fe9218012680c1cc647b09c7fbc514ab92c021d7a21ed5faf6729
import tensorflow as tf import numpy as np import pandas as pd import csv import re # Load data and prepare the input layers. with open('test.csv', 'r', encoding='utf-8', newline='') as f: reader = csv.reader(f) test_sentence = [] test_label = [] for row in reader: test_sentence.a...
Python
CL
1882c676ed8ee20c5e47a09cf96e3917427058a4b066b574cc56546da7a557dc
import csv from contextlib import contextmanager from pathlib import Path from time import time from typing import Iterator from neat.reporting import BaseReporter from neat_improved.neat.evaluator import GymEvaluator _SPECIES = 'species' _POPULATION = 'population' _FIELDS = { _SPECIES: ( 'iteration', ...
Python
CL
ae5f914a1e600b276449cefcc99937dcbc9b3337740d6a244bd6ad5bed2ce476
import pandas as pd import numpy as np import time import matplotlib.pyplot as plt from sklearn.model_selection import train_test_split from sklearn.decomposition import PCA from sklearn.mixture import GaussianMixture from sklearn import metrics from sklearn import preprocessing from sklearn.cluster import KMeans from ...
Python
CL
0a71b37ec7d0a65b21cebb61aceecebb2b5f16e493be04647bc06e145539235a
# Copyright Contributors to the OpenCue Project # # 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...
Python
CL
4b415d16c7f9da4ec90da3ae16d0afe5b6cc4dae60e03f1c1743e577db3fe32d
from core.views import BaseMedFileViewSet from .models import Medicine from .serializers import MedicineSerializer class MedicineViewSet(BaseMedFileViewSet): """ CRUD options for medicine only for authenticated user. """ serializer_class = MedicineSerializer queryset = Medicine.objects.all()
Python
CL
ab4465cf46799ed2cbfef4538258b2189fce3b448814e515bb59ce4554a01681
import collections # Import Python wrapper for or-tools CP-SAT solver. from ortools.sat.python import cp_model def JobScheduling(plats_data): """Minimal platoon problem.""" # Create the model. model = cp_model.CpModel() nodes_count = 1 + max(task[0] for plat in plats_data for task in plat) all_n...
Python
CL
c3a207a21a9a13ad4863c99ff9ead2ef7afa301bfede5388e9cd28c312bd44c7
from __future__ import print_function import logging from argparse import ArgumentParser import backoff import requests import sys POLL_URL = 'https://coveralls.io/builds/{}.json' DONE_URL = 'https://coveralls.io/webhook' def setup_logging(): logger = logging.getLogger('backoff') logger.addHandler(logging....
Python
CL
44e43787d9868f6d90a38bcb7beff35e1911f4c78b47dc7c1f4eae8b217e63a0
""" This is a Python 3 port of FORTRAN code from the EXPOKIT package. gexpmv is a port of the _GEXPV routines. See R.B. Sidje, ACM Trans. Math. Softw., 24(1):130-156, 1998 and http://www.maths.uq.edu.au/expokit @author: Ashley Milsted """ from __future__ import absolute_import, division, print_function import scipy ...
Python
CL
984bba16d85b4d0b6b7d0de5959fd6829765095e378a779ec411c1e60059d56a
#!/usr/bin/env python3 import mfutil import os import paho.mqtt.client as mqtt import xattrfile import signal from acquisition.listener import AcquisitionListener class ExtraDaemonMqttListener(AcquisitionListener): client = None plugin_name = "mqtt_listener" daemon_name = "extra_daemon_mqtt_listener" ...
Python
CL
4a943d898b130c7cda382ff89c9858c7e034f73f685c9f4d5d4ce2baffbd03ec
''' Hartree-Fock for periodic systems with k-point sampling See Also: hf.py : Hartree-Fock for periodic systems at a single k-point ''' import time import numpy as np import scipy.special import pyscf.dft import pyscf.pbc.dft import pyscf.pbc.scf.hf as pbchf from pyscf.lib import logger from pyscf.pbc import tool...
Python
CL
b6694c456692d24c557c16159839b2e84649d0c6e2cd98f291c128eb3e74d5f3
class ResXWriter: def __init__(self, filename): self.fileName = filename self.file = open(filename, 'w', encoding='utf-8') self.data = {} def add_resource(self, name, value): self.data[name] = value def flush(self): self.file.truncate(0); self.file.seek(0); ...
Python
CL
ebc768ae37a488f07b55a30536e72ad585f7bcedcad2542f3133f8d833a2adc9
import mge_fit_1d as mge import numpy as np import jam_axi_rms as Jrms import matplotlib.pyplot as plt import os, sys, time import matplotlib.gridspec as gridspec from matplotlib.colors import LogNorm from scipy.misc import imread import matplotlib.cbook as cbook from galaxyParametersDictionary_v9 import * from Sabine...
Python
CL
c56b4153b43441db9d2ee6d8952b4e46bf92b891358ed15d1b0fe59571ad2625
import numpy as np import matplotlib.pyplot as plt def initialize_centroids(X, K): """ Randomly initialize K cluster centroids from the data arguments: X -- our data that we want to cluster K -- number of clusters return: centroids -- initialized centroids """ idx = np.ran...
Python
CL
ee7a61a4c0937c7d53a4fbe194f866b8661ced655f030abefd679e54072532dc
import tensorflow as tf from tensorflow.python.keras.applications.vgg16 import preprocess_input as pre_process_VGG from tensorflow.python.keras.applications.resnet50 import preprocess_input as pre_process_ResNet from tensorflow.python.keras.applications.inception_v3 import preprocess_input as pre_process_Inception from...
Python
CL
554fc8707cda1e9fec1a5541d0af8beab1f3fed2a6ebd01a51b0cd31c5370fce
from __future__ import print_function from __future__ import print_function import os import sys import numpy as np from keras.preprocessing.text import text_to_word_sequence from keras.preprocessing.text import Tokenizer from keras.preprocessing.sequence import pad_sequences from keras.utils import to_categorical fr...
Python
CL
66866b6ac9ca85916daf530091d5cc13d1b4db8a0057ce71e0294240bc398509
""" Sparse Blocks Network Copyright (c) 2017, Uber Technologies, Inc. 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 re...
Python
CL
1813b081419466e18d852c48cbd750e80671e17c2c81cbbeff33ea83a053ebbc
#--------------------------------------------- # Import necessary packages #--------------------------------------------- import numpy as np import pandas as pd import matplotlib matplotlib.use('Agg') import matplotlib.pyplot as plt import time from sklearn.model_selection import train_test_split from sklearn.neighbor...
Python
CL
2c9d270e71fbad82f5036bc0c14cc9d40c5879d7bba5d59c1dfe6414241bf6a6
import FWCore.ParameterSet.Config as cms from RecoMuon.TrackingTools.MuonServiceProxy_cff import * from RecoMuon.TrackingTools.MuonTrackLoader_cff import * from TrackingTools.GeomPropagators.StraightLinePropagator_cfi import * MuonServiceProxy.ServiceParameters.Propagators.append('StraightLinePropagator') cosmicMuon...
Python
CL
01bc5db1c1d71ac7a9b03fca873eed03db7ee7bce58d8e7ae5fa9872e2f00acc
import mxnet as mx import numpy as np from collections import namedtuple GRUState=namedtuple('GRUState', ['h']) GRUParam=namedtuple('GRUParam', ['gates_i2h_weight','gates_i2h_bias', 'gates_h2h_weight', 'gates_h2h_bias','trans_i2h_weight','trans_i2h_bias', 'trans_h2h_weight', 'trans_h2h_bias']) def myGRU(num_hidden, ...
Python
CL
5777f23e0fa115436d7954696e3568231389f86ba5ae5b267c1634f46053bd98
# -*- coding: utf-8 -*- ''' Weather functions to be used with the NWS radar and weather information download script. Jesse Hamner, 2019-2020 ''' from __future__ import print_function import os import re import datetime import json import logging from time import sleep from outage import Outage import requests impor...
Python
CL
63118ccc1dc1a82d3ffd23dbbd6ff56c7f26942f90489ed6708d9c4d63df9fae
import FWCore.ParameterSet.Config as cms process = cms.Process("PROD") process.maxEvents = cms.untracked.PSet( input = cms.untracked.int32(10) ) #generation process.source = cms.Source("EmptySource") process.load("Configuration.Generator.QCDForPF_cfi") process.generator.comEnergy = 14000. #fastsim process.loa...
Python
CL
5ee42374e180513f9e25518bac782d6cc15ea72c113c5ade1f3a1be41fe8cc56
# -*- coding: UTF-8 -*- # ----------------------------------------------------------------------------- # xierpa server # Copyright (c) 2014+ buro@petr.com, www.petr.com, www.xierpa.com # # X I E R P A 3 # Distribution by the MIT License. # # -----------------------------------------------------------...
Python
CL
50984ad7ffd8aae0cf7203c21222f1854a7d34bf8058aa56cb7fc472a29e5197
import csv from preprocessing.preprocess import PreprocessBase """ Marco Link """ class SimpleSynonyms(PreprocessBase): """ Class for replacing words with its specified synonyms. The synonyms has to be defined in a file. An entry in the file specifies the word which should be replaced followed by the...
Python
CL
8961035c7929ee325cdf17242029cfdbdc919862a7d64d10c6086a8b91409eb3
#!/usr/bin/env python # ClusterShell.CLI.Display test suite # Written by S. Thiell """Unit test for CLI.Display""" import os import sys import tempfile import unittest from StringIO import StringIO sys.path.insert(0, '../lib') from ClusterShell.CLI.Display import Display, WHENCOLOR_CHOICES, VERB_STD from ClusterSh...
Python
CL
59861f7230f0f86056de4cc36c83affa2645ee0bda93b31807475beb3413ac51
import boto3 from botocore.client import ClientEndpointBridge import botocore.exceptions def lambda_handler(event, context): """Lambda function to identify unencrypted s3 buckets associated with the AWS account in use and send an email notification via an SNS resource. Returns: response(dict): SN...
Python
CL
2c9292c3832a659e2be7058c7e6019571dabed96bfb149e403ce746edbee1791
class Building(): """A simple Building Energy Model. Consisting of one thermal capacity and one resistance, this model is derived from the hourly dynamic model of the ISO 13790. It models heating and cooling energy demand only. Parameters: * heat_mass_capacity: capacity of the building's heat mass [J/...
Python
CL
e2bc0d201562b3dd3ab9e50218ccef5e9a9ac6337dc462536bb00669b36417e6
# -*- coding: utf-8 -*- from setuptools import find_namespace_packages, setup setup( name="emmet-core", use_scm_version={"root": "..", "relative_to": __file__}, setup_requires=["setuptools_scm>=6,<8"], description="Core Emmet Library", author="The Materials Project", author_email="feedback@mat...
Python
CL
5191e814a417284652cf1d5b98090722f48d5aab12875861389f69f2e402c8a9
# -*- coding: utf-8 -*- """ SR510 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Implements the drivers to control a lock-in amplifier :copyright: 2013 by Lantz Authors, see AUTHORS for more details. :license: BSD, see LICENSE for more details. Source: SR510 Manual """ from lantz import Feat from lantz.visa i...
Python
CL
853c950039d4bb933766f6ce0a20e697e744ce9884857adb47706120c6a4dfd8
from unittest import TestCase from model import connect_to_db, db, User, Answer, Question from server import app from flask import session class FlaskTestsBasic(TestCase): """Tests all routes render, except login/logout.""" def setUp(self): """Stuff to do before every test.""" # Get the Flas...
Python
CL
e39e313e51e12a74cdf3600a3790ac2153b9262a7df27e1837f0aa1b26fbb011
# -*- coding: utf-8 -*- import sys import redis import BaseThreadedModule import Utils import Decorators @Decorators.ModuleDocstringParser class RedisList(BaseThreadedModule.BaseThreadedModule): """ Subscribes to a redis channels/lists and passes incoming events to receivers. lists: Name of redis lists t...
Python
CL
cad06f27db6d0f79d0e0d5dfe5f10582892783a4bfd550b2b6e3494b536a64d2
import os import re import subprocess from libqtile import bar, hook, layout, widget from libqtile.config import Click, Drag, Group, Key, Match, Screen from libqtile.lazy import lazy from widgets.volume import Volume, VolumeCommands mod = "mod4" keys = [ # The basics Key([mod], "Return", laz...
Python
CL
7d6de91a3816917c88f26796cff3a39fb623ffefb3cdd2147d150af62afcd220
from persimmon import primitive, single, multi, utils from persimmon.factory import ParserFactory class StandardParserFactory(ParserFactory): def make_rewind_iterator(self, data): return utils.RewindIterator.make_rewind_iterator(data) def make_success_parser(self, value): return primitive.Suc...
Python
CL
bf0035fa63eb568377d982fc8fbf34497789fccdfcc469db2acbd65ed359ae3d
#!/usr/bin/env python # # All modification made by Intel Corporation: Copyright (c) 2018 Intel Corporation # # All contributions by the University of California: # Copyright (c) 2014, 2015, The Regents of the University of California (Regents) # All rights reserved. # # All other contributions: # Copyright (c) 2014,...
Python
CL
d090e0719ac60a6f0f6660726be18482658548a2b7540e4963d77e867b805865
"""Contains most of the functions for the CLI. Put here for testing purposes.""" import click from PyInquirer import prompt import PyInquirer import jsonschema from ddl.assetpack import AssetpackFactory from ddl.validator import Validator from ddl.renderer import Renderer import ddl.asset_exploration from ddl.asset_ex...
Python
CL
720cc7b0c7054981a43668ae7f0a9c0925862fbfe2eca45137f26777ec69222f
# Copyright (c) 2019 PaddlePaddle 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 app...
Python
CL
708d6563232197f3d1a3a751f6230518dfd7b1b3561038453b40e7165387ebe7
"""Testing the functions inside the initialisation file of the ``main`` package. To run this particular test file use the following command line: nose2 -v app.tests.main.tests_init """ from app import create_app import unittest from unittest import TestCase from config import Config, basedir import os from app.main i...
Python
CL
f3a95006d72ae9d822f0769250fa97e9b82c1b9fc41623adce702fc0e072aa37
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # Rewrite pf-upper and pf-lower as their differences from pf # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # import os, glob import xarray as xr import argparse def run(fn): ds = xr.open_dataset(fn) ...
Python
CL
3e2f9c6238abe2be2f8b8efade0d406b01bbde2a7e4c5ed37b37296a675bcbab