src stringlengths 721 1.04M |
|---|
import numpy as np
import pytest
from proximal.tests.base_test import BaseTest
from proximal.lin_ops import Variable, mul_elemwise, subsample
from proximal.prox_fns import norm1, sum_squares
from proximal.algorithms import Problem
from proximal.utils.utils import Impl
import cvxpy as cvx
class TestProblem(BaseTest):... |
#!/usr/bin/python
"""Test of flat review of text and a toolbar."""
from macaroon.playback import *
import utils
sequence = MacroSequence()
sequence.append(KeyComboAction("<Control>f"))
sequence.append(TypeAction("Application main window"))
sequence.append(KeyComboAction("Return"))
sequence.append(KeyComboAction("Ta... |
"Change Manager for literal values (supporting ==)"
from .bitmap import bitmap
from .index_update import IndexUpdate
from .changemanager_base import BaseChangeManager
class LiteralChangeManager(BaseChangeManager):
"""
Manage changes that occured in a literal value between runs.
"""
VALUE = bitmap([0]... |
from setuptools import setup
import pycuber as pc
long_desc = """
PyCuber
=======
PyCuber is a Rubik's Cube package in Python 2/3.
--------------------------------------------------
The cube can be revealed as expanded view in the terminal, so it's easy
to visualise the cube, just inside the terminal. (Not tested on... |
#!/usr/bin/env python
# Copyright 2014 Google Inc. All Rights Reserved.
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions are
# met:
#
# * Redistributions of source code must retain the above copyright
# notice, this list of c... |
#!/usr/bin/python
import os
import subprocess
def fix_stage1_size():
stage2_size = os.stat("stage2").st_size
kernel_size = os.stat("kernel64").st_size
stage2_size = (stage2_size + kernel_size + 511) / 512
if stage2_size >= 255:
raise Exception("stage2 & kernel are too large")
with open(... |
"""
testscript.py
-------------
This is a test script for decu.
"""
from decu import Script, experiment, figure, run_parallel
import numpy as np
import matplotlib.pyplot as plt
class TestScript(Script):
@experiment(data_param='data')
def exp(self, data, param, param2):
"""Compute x**param for each... |
# -*- coding: utf-8 -*-
#
# Bento documentation build configuration file, created by
# sphinx-quickstart on Sun Jan 3 12:53:13 2010.
#
# This file is execfile()d with the current directory set to its containing dir.
#
# Note that not all possible configuration values are present in this
# autogenerated file.
#
# All c... |
# coding: utf-8
"""
Kubernetes
No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator) # noqa: E501
The version of the OpenAPI document: release-1.18
Generated by: https://openapi-generator.tech
"""
import pprint
import re # noqa: F401
import si... |
# This file is part of multiRemote.
#
# multiRemote is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 2 of the License, or
# (at your option) any later version.
#
# multiRemote is distributed in t... |
import os
import os.path
from hashlib import sha384
from datetime import datetime, timedelta
from cryptography import x509
from cryptography.hazmat.backends import default_backend
from acmems.config import ConfigurationError
class StorageImplementor():
def __init__(self, type, name, options):
self.type ... |
# Copyright 2016 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 applica... |
'''
Given a string s and a non-empty string p, find all the start indices of p's anagrams in s.
Strings consists of lowercase English letters only and the length of both strings s and p will not be larger than 20,100.
The order of output does not matter.
Example 1:
Input:
s: "cbaebabacd" p: "abc"
Output:
[0, 6]
E... |
#!/usr/bin/python3
from PyQt5.QtCore import QSettings
from PyQt5.QtWidgets import QDialog
from torrentbro.ui import Ui_Settings
class Settings(QDialog):
def __init__(self):
super().__init__()
self.initUI()
self.initEvents()
self.exec_()
self.show()
def initUI(self)... |
#!/usr/bin/env python3.6
import os, argparse, subprocess
def main():
parser = argparse.ArgumentParser()
parser.add_argument("project")
args = parser.parse_args()
home = os.path.join(os.path.expanduser("~"), "Videos", "Mine", "WIP")
dest_dir = os.path.join(home, args.project, "footage")
if no... |
# -*- coding: utf-8 -*-
# Copyright (c) 2015, Frappe Technologies Pvt. Ltd. and contributors
# For license information, please see license.txt
from __future__ import unicode_literals
import frappe
import json
from frappe import _
from frappe.model.document import Document
from frappe.utils import get_request_session
f... |
# This file is part of xrayutilities.
#
# xrayutilities is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# This program is distributed... |
# Copyright 2016 Red Hat, 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 required by applicable law or agreed ... |
# -*- coding: utf-8 -*-
#
# This file is part of CDS.
# Copyright (C) 2015, 2016 CERN.
#
# CDS is free software; you can redistribute it
# and/or modify it under the terms of the GNU General Public License as
# published by the Free Software Foundation; either version 2 of the
# License, or (at your option) any later v... |
"""Satalite date models"""
from __future__ import division, absolute_import, print_function, unicode_literals
from django.db import models
from db import models as db_models
class LogTempLive(models.Model):
"""Messages from Buoy"""
sensor = models.ForeignKey(db_models.Sensor)
processed = models.BooleanFie... |
# Copyright (c) 2015, NVIDIA CORPORATION. All rights reserved.
import sys
import os.path
import re
import digits
from digits.utils import subclass, override
from digits.task import Task
# NOTE: Increment this everytime the pickled object
PICKLE_VERSION = 1
@subclass
class AnalyzeDbTask(Task):
"""
Reads inf... |
# -*- Mode: python; tab-width: 4; indent-tabs-mode:nil; coding: utf-8 -*-
# vim: tabstop=4 expandtab shiftwidth=4 softtabstop=4
from abc import ABCMeta, abstractmethod
import numpy as np
from .properties import _create_property
from .writepdb import _writepdb
from . import messages
from . import utilities
from scipy.sp... |
# -*- coding: utf-8 -*-
from __future__ import unicode_literals
import re
import django
from django.db import models, migrations
from django.db.models import Q
def add_self_organized_host(apps, schema_editor):
"""Make new host: self-organized."""
Host = apps.get_model('workshops', 'Host')
Host.objects.cr... |
# -*- coding: utf-8 -*-
##
# Copyright 2013-2021 Ghent University
#
# This file is part of EasyBuild,
# originally created by the HPC team of Ghent University (http://ugent.be/hpc/en),
# with support of Ghent University (http://ugent.be/hpc),
# the Flemish Supercomputer Centre (VSC) (https://www.vscentrum.be),
# Flemis... |
import json
from urllib2 import urlopen, HTTPError
class PyAptgraph(object):
def __init__(self, apiKey, debug=False):
'''
Connect to the Aptgraph API
@param string $apikey Your Aptgraph apikey
@param boolean $debug Turn on/off debugging messages
'''
self.apiKey = ... |
from __future__ import absolute_import, unicode_literals
import os
from celery import Celery
# set the default Django settings module for the 'celery' program.
os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'ploghub.settings')
app = Celery('ploghub', broker='redis://localhost:6379/0')
# Using a string here means th... |
"""
Functions for processing input commands.
All global functions in this module whose name does not start with "_"
is considered an inputfunc. Each function must have the following
callsign:
inputfunc(session, *args, **kwargs)
Where "options" is always one of the kwargs, containing eventual
protocol-options.
Th... |
import pytest
import unittest
import numpy as np
from atom.api import Atom, Bool
from psi.context.expression import Expr, ExpressionNamespace
class TestExpression(unittest.TestCase):
def test_eval(self):
context = dict(a=1, b=2, c=3)
test_cases = [
('1+2', 3),
... |
from slackclient import SlackClient
import os,sys,time,logging,re
class slackRequestHandler(object):
def __init__(self,token=""):
self.token = token
self.client = None
self.last_ping = 0
self.id = None
self.name = None
self.selector = None
self.callback = None
def connect(self):
self.slack_client = ... |
# -*- coding: utf-8 -*-
# wasp_general/os/linux/lvm.py
#
# Copyright (C) 2017 the wasp-general authors and contributors
# <see AUTHORS file>
#
# This file is part of wasp-general.
#
# Wasp-general is free software: you can redistribute it and/or modify
# it under the terms of the GNU Lesser General Public License as pu... |
"""
Conway's Game of Life - Unlimited Edition
http://www.codewars.com/kata/52423db9add6f6fc39000354/train/python
"""
from copy import deepcopy
def get_generation(cells, generations):
origin = deepcopy(cells)
if generations == 0:
return origin
if generations > 1:
origin = get_generation(or... |
# -*- coding: utf-8 -*-
from collections import defaultdict
import csv
from datetime import datetime, timedelta
from itertools import chain
import dateutil.parser
import json
import networkx as nx
import pytz
import re
from typing import Any, DefaultDict, Dict, List, Optional, Set, Tuple, Union
from django.conf impor... |
# encoding: utf-8
"""
@author: monitor1379
@contact: yy4f5da2@hotmail.com
@site: www.monitor1379.com
@version: 1.0
@license: GNU General Public License(Version 3)
@file: mnist_decoder.py
@time: 2016/8/16 20:03
对MNIST手写数字数据文件转换为bmp图片文件格式。
数据集下载地址为http://yann.lecun.com/exdb/mnist。
相关格式转换见官网以及代码注释。
===================... |
#!/usr/bin/env python
"""A collection of compatibility fixes for client."""
from grr.client.client_actions import standard as standard_actions
from grr.lib import aff4
from grr.lib import config_lib
from grr.lib import flow
from grr.lib import rdfvalue
from grr.lib.rdfvalues import client as rdf_client
class RDFFind... |
# encoding: utf-8
import datetime
from south.db import db
from south.v2 import SchemaMigration
from django.db import models
class Migration(SchemaMigration):
def forwards(self, orm):
# Changing field 'Spell.altname'
db.alter_column('spell', 'altname', self.gf('django.db.models.fields.Slug... |
from __future__ import division
from nose.tools import assert_equal
from nose.tools import assert_false
from nose.tools import assert_raises
from nose.tools import raises
import networkx as nx
def _setUp(self):
cnlti = nx.convert_node_labels_to_integers
self.grid = cnlti(nx.grid_2d_graph(4, 4), first_label=... |
import logging
from importlib.machinery import SourceFileLoader
import inspect
import os
from collections import defaultdict
from contextlib import contextmanager
import mdt
import mot
from mdt.configuration import get_config_dir
from mdt.model_building.signal_noise_models import SignalNoiseModel
from mot.library_funct... |
# Copyright 2015, Tresys Technology, LLC
#
# This file is part of SETools.
#
# SETools is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 2 of the License, or
# (at your option) any later version.
... |
from unittest import TestCase
from lutris.installer import ScriptInterpreter, ScriptingError
class MockInterpreter(ScriptInterpreter):
""" a script interpreter mock """
script = {'runner': 'linux'}
def is_valid(self):
return True
class TestScriptInterpreter(TestCase):
def test_script_with_c... |
#
# The MIT License (MIT)
#
# Copyright (c) 2015 Dmitry Sovetov
#
# https://github.com/dmsovetov
#
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to deal
# in the Software without restriction, including without limit... |
# Documentation for Zulip's authentication backends is split across a few places:
#
# * https://zulip.readthedocs.io/en/latest/production/authentication-methods.html and
# zproject/prod_settings_template.py have user-level configuration documentation.
# * https://zulip.readthedocs.io/en/latest/subsystems/auth.html ha... |
# -*- coding: utf-8 -*-
"""
Created on 2015-10-05
@author: Zhixiong Zhao
"""
import __init__
from HHFormat import *
import molecule.HHMolecule
import molecule.HHAtom
import molecule.HHResidue
import molecule.HHBond
import geometry.HHPoint
Mol=molecule.HHMolecule.Molecule
Atom=molecule.HHAtom.Atom
Res=molecule.HHRes... |
# coding: utf-8
from PyQt4.QtCore import Qt, pyqtSlot
from nxdrive.wui.dialog import WebDialog, WebDriveApi
class WebModalApi(WebDriveApi):
@pyqtSlot(str)
def result(self, button_id):
self.dialog.set_result(button_id)
def _json_default(self, obj):
if isinstance(obj, WebModalButton):
... |
# Copyright 2019 The TensorFlow Probability 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 o... |
# DataHub Settings.
DEBUG = True
TEMPLATE_DEBUG = DEBUG
ADMINS = (
('Anant Bhardwaj', 'anantb@csail.mit.edu'),
)
MANAGERS = ADMINS
DATABASES = {
'default': {
'ENGINE': 'django.db.backends.postgresql_psycopg2', # Add 'postgresql_psycopg2', 'mysql', 'sqlite3' or 'oracle'.
'NAME': 'datahub', ... |
"""
Functions for TF analysis.
@author: mje
@email: mads [] cnru.dk
"""
import mne
from mne.time_frequency import (psd_multitaper, tfr_multitaper, tfr_morlet,
cwt_morlet)
from mne.viz import iter_topography
import matplotlib.pyplot as plt
import numpy as np
def calc_psd_epochs(epochs... |
#!/usr/bin/env python
# Copyright (c) 2012 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.
"""Extracts native methods from a Java file and generates the JNI bindings.
If you change this, please run and update the tests."""... |
import json
import os
import glob
#https://github.com/Twentysix26/Red-DiscordBot/blob/master/dataIO.py
default_settings = ('{"curReg": 0, "lastSp": "sp1", "sp1": 0, "sp2": 0}')
def fileIO(filename, IO, data=None):
if IO == "save" and data != None:
with open(filename, encoding='utf-8', mode="w") as f:
f.wri... |
import os
import csv
import lzma
import pickle
DIRECTORY_PATH = 'WKRRaces'
def files():
directory = DIRECTORY_PATH
f = []
for file in os.listdir(directory):
if file.endswith(".csv"):
f.append(os.path.join(directory, file))
return f
def history_item(item, is_null_time):
s = ite... |
# -*- encoding: utf-8 -*-
import reportlab
from reportlab.pdfgen import canvas
from reportlab.lib.pagesizes import A4
from reportlab.lib.units import mm
def n(integer):
return str('{:.2f}'.format(integer))
class Invoice2PDF:
def __init__(self, type, file):
self.file = file
self.type = type
self.p = canvas.Ca... |
# -*- coding: UTF-8 -*-
import os, django
os.environ['DJANGO_SETTINGS_MODULE'] = 'crm_site.settings'
django.setup()
from crm.models import *
from crm.common import *
# Demo initialize
# UserRoleType
userRoleTypes = [
['SALES_ROLE', u"销售"],
['DEV_ROLE', u"CRM开发"]
]
for userRoleType in userRoleTypes:
p = ... |
"""TODO(lauraruis): DO NOT SUBMIT without one-line documentation for generate_extra_data.
TODO(lauraruis): DO NOT SUBMIT without a detailed description of generate_extra_data.
"""
from __future__ import absolute_import # Not necessary in a Python 3-only module
from __future__ import division # Not necessary in a Py... |
# -*- coding: utf-8 -*-
from django.core.urlresolvers import reverse
from ietf.utils.test_utils import TestCase
from ietf.group.models import Group
from ietf.person.models import Person
from ietf.utils.test_data import make_test_data
import debug # pyflakes:ignore
SECR_USER='secretary'
de... |
import numpy as np
import networkx as nx
import math
import random
def convert(something):#use networkx conversion from numpy array
#g = nx.from_numpy_matrix(someNPMat)
g = nx.to_networkx_graph(something)
return g
def deleteSelfLoops(graph, nNodes): #used to take away self loops in final graph for stat p... |
# -*- coding: utf-8 -*-
from lxml import etree
from odoo.tools.misc import file_open
def check_with_xsd(tree_or_str, xsd_path):
if not isinstance(tree_or_str, etree._Element):
tree_or_str = etree.fromstring(tree_or_str)
xml_schema_doc = etree.parse(file_open(xsd_path))
xsd_schema = etree.XMLSchema... |
import numpy as np # linear algebra
import pandas as pd # data processing, CSV file I/O (e.g. pd.read_csv)
from subprocess import check_output
from keras.models import Model
from keras.layers import Dense, Embedding, Input , Activation
from keras.layers import LSTM, Bidirectional, GlobalMaxPool1D, Dropout, GRU
from ker... |
"""
test_activations.py - Unit tests for YANN core activation functions
defined in yann/core/activations.py
"""
import unittest
import numpy as np
import theano
import theano.tensor as T
import yann.core.activations as A
try:
from unittest.mock import Mock
except ImportError:
from mock import Mock,patch
clas... |
# Copyright 2011 Justin Santa Barbara
# 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 requ... |
# -*- coding: utf-8 -*-
"""
Created on Tue Jul 14 19:34:31 2015
@author: Tennessee
"""
import numpy as np
import matplotlib.pyplot as plt
def altitude(atm_hpa, sea_level_hpa):
return 44330 * (1.0 - np.power(atm_hpa / sea_level_hpa, 0.1903))
def plot_alt():
default_msl = 101300.0
pressure = np.l... |
import logging
import os
import time
from configparser import ConfigParser
import httplib2
from apiclient import discovery
from apiclient.http import MediaFileUpload
from oauth2client import client
from oauth2client.file import Storage
try:
import argparse
media_types = ["photo", "video"]
parser = argpar... |
# Copyright 2019 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 applica... |
from ambassador.utils import RichStatus
from ambassador.utils import ParsedService as Service
from typing import Any, ClassVar, Dict, List, Optional, Type, Union, TYPE_CHECKING
from ..config import Config
from .irbasemapping import IRBaseMapping, normalize_service_name
from .irbasemappinggroup import IRBaseMappingGr... |
"""Package for before_after."""
__project__ = 'before_after'
__version__ = '1.0.1'
VERSION = __project__ + '-' + __version__
PYTHON_VERSION = 2, 7
import sys
if not sys.version_info >= PYTHON_VERSION: # pragma: no cover (manual test)
exit("Python {}.{}+ is required.".format(*PYTHON_VERSION))
from contextlib ... |
#!/usr/bin/python
# -*- coding: utf-8 -*-
#
# Copyright 2013 The Plaso Project Authors.
# Please see the AUTHORS file for details on individual 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 L... |
# -*- coding: utf-8 -*-
from unittest import TestCase
from nesasm.compiler import compile
import os
import re
from nesasm.compiler import lexical, syntax, semantic
class MetaInstructionCase(type):
def __new__(cls, name, bases, args):
def gen_lex():
def test(self):
tokens = l... |
#!/usr/bin/env python
#-*- coding:utf-8 -*-
import os, sys
sys.path.append(os.path.dirname(os.path.dirname(os.path.abspath(__file__))))
# NOTE: this example requires PyAudio because it uses the Microphone class
import speech_recognition as sr
import requests
import config1 as config
try:
# Obtain audio from the mi... |
#!/usr/bin/python
import numpy as np
import matplotlib.pyplot as plt
#VortexQuantum = 1.0/(4*np.pi)
VortexQuantum = 1.0
# === Functions
def IwireElement(y,x):
return VortexQuantum* y/np.sqrt(x**2+y**2)**3
def IwireFinite(y,x1,x2):
# finite wire with constant distribution of current
# integral_a sin(a... |
from __future__ import absolute_import
from __future__ import unicode_literals
# -*- coding: utf-8 -*-
from django import VERSION
from django.conf import settings as django_settings
from django.core.exceptions import ImproperlyConfigured
import warnings
from six import string_types
# TODO: Don't use wildcards
from .a... |
# -*- coding: utf-8 -*-
# pylint: disable=bad-whitespace
"""
kunstkopf [ˈkʊnstkɔp͜f] is a set of tools that handle audio (meta-)data and control hi-fi gear.
Copyright © 2015 Jürgen Hermann <jh@web.de>
Licensed under the GNU General Public License, Version 3.0
"""
# Copyright © 2015 Jürgen Hermann <jh@we... |
# Amara, universalsubtitles.org
#
# Copyright (C) 2013 Participatory Culture Foundation
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU Affero General Public License as
# published by the Free Software Foundation, either version 3 of the
# License, or (at your op... |
import os
import sys
import unittest
import threading
# add the source directory to the path so the unit test framework can find it
sys.path.append(os.path.join(os.path.dirname(os.path.realpath(__file__)), '..', 'EPLaunchLite'))
try:
from FileTypes import FileTypes
has_gtk = True
except ImportError as e:
... |
# coding: utf-8
#
# drums-backend a simple interactive audio sampler that plays vorbis samples
# Copyright (C) 2009 C.D. Immanuel Albrecht
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Fou... |
from django.conf import settings
import os.path
import sys
collect_ignore = []
if sys.version_info[0] > 2:
collect_ignore.append("tests/contrib/flask")
if sys.version_info[1] == 2:
collect_ignore.append("tests/handlers/logbook")
try:
import gevent
except ImportError:
collect_ignore.append("te... |
# Copyright (c) 2006-2012 Mitch Garnaat http://garnaat.org/
# Copyright (c) 2011, Nexenta Systems Inc.
# Copyright (c) 2012 Amazon.com, Inc. or its affiliates. All Rights Reserved
#
# Permission is hereby granted, free of charge, to any person obtaining a
# copy of this software and associated documentation files (the... |
# -*- coding: utf-8 -*-
# Generated by Django 1.11.5 on 2017-09-25 16:16
from __future__ import unicode_literals
from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
('vpc', '0022_auto_20170926_0005'),
]
operations = [
migrations.AlterField(
... |
# Copyright 2010 United States Government as represented by the
# Administrator of the National Aeronautics and Space Administration.
# Copyright 2011 Justin Santa Barbara
# All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License"); you may
# not use this file except in compliance wi... |
# vim:fileencoding=utf-8
# Copyright (c) 2008-2011 gocept gmbh & co. kg
# See also LICENSE.txt
# $Id$
"""pycountry"""
import os.path
import pycountry.db
LOCALES_DIR = os.path.join(os.path.dirname(__file__), 'locales')
DATABASE_DIR = os.path.join(os.path.dirname(__file__), 'databases')
class Countries(pycountry.db... |
#!/usr/bin/env python
# *********************************************************************
# * Copyright (C) 2014 Luca Baldini (luca.baldini@pi.infn.it) *
# * *
# * For the license terms see the file LICENSE, distributed *
# * along ... |
"""
Clean the Pubmed Post Processing
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Dump obtained on: July 11, 2016 (double check).
Python 3.5
"""
import re
import os
import blaze
import numpy as np
import pandas as pd
from blaze import *
from copy import deepcopy
from collections import defaultdict
from collecti... |
"""
[2017-06-12] Challenge #319 [Easy] Condensing Sentences
https://www.reddit.com/r/dailyprogrammer/comments/6grwny/20170612_challenge_319_easy_condensing_sentences/
# Description
Compression makes use of the fact that repeated structures are redundant, and it's more efficient to represent the
pattern and the count ... |
#!/usr/bin/env python
# -*- coding: utf-8 -*-
#
# Licensed to the Apache Software Foundation (ASF) under one
# or more contributor license agreements. See the NOTICE file
# distributed with this work for additional information
# regarding copyright ownership. The ASF licenses this file
# to you under the Apache Licen... |
# $Filename$
# $Authors$
# Last Changed: $Date$ $Committer$ $Revision-Id$
#
# Copyright (c) 2003-2011, German Aerospace Center (DLR)
# All rights reserved.
#
#Redistribution and use in source and binary forms, with or without
#
#modification, are permitted provided that the following conditions are
#met:
#
... |
# -*- coding: utf-8 -*-
"""
@license: gpl2
@copyright: Copyright (C) 2014, University of Kansas Center for Research
Lifemapper Project, lifemapper [at] ku [dot] edu,
Biodiversity Institute,
1345 Jayhawk Boulevard, Lawrence, Kansas, 66045, USA
This program is free software; ... |
def filter_shadowed_reflections(experiments, reflections, experiment_goniometer=False):
from dxtbx.masking import is_inside_polygon
from scitbx.array_family import flex
shadowed = flex.bool(reflections.size(), False)
for expt_id in range(len(experiments)):
expt = experiments[expt_id]
im... |
#!/usr/bin/env python3
# Copyright (c) 2019 Pieter Wuille
# Copyright (c) 2019-2020 The Bitcoin developers
"""Test-only secp256k1 elliptic curve implementation
WARNING: This code is slow, uses bad randomness, does not properly protect
keys, and is trivially vulnerable to side channel attacks. Do not use for
anything ... |
# Copyright 2016 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 applica... |
# -*- coding: utf-8 -*-
#
# Copyright (C) 2003-2009 Edgewall Software
# Copyright (C) 2003-2005 Daniel Lundin <daniel@edgewall.com>
# All rights reserved.
#
# This software is licensed as described in the file COPYING, which
# you should have received as part of this distribution. The terms
# are also available at http... |
from distutils.core import setup
from ideascaleapi import __version__,__license__,__doc__
license_text = open('LICENSE').read()
long_description = open('README.rst').read()
setup(name="python-ideascaleapi",
version=__version__,
py_modules=["ideascaleapi"],
description="Libraries for interacting with... |
import numpy
import scipy.signal
import scipy.interpolate
from matplotlib import pyplot as plt
from breezylidar import URG04LX
def flags2segs(Flags, window):
'''
ARGUMENTS:
- Flags: a sequence of class flags (per time window)
- window: window duration (in seconds)
RETURNS:
- seg... |
#!/usr/bin/env python3.6
import subprocess
import datetime
import configparser
import json
import platform
def getRAMofProcess(processName):
proc = subprocess.Popen('ps -C '+processName+' -o rss=', stdout=subprocess.PIPE, shell=True)
sums = 0
for line in proc.stdout:
sums += int(line.rstrip())
return sums
def g... |
import RPi.GPIO as GPIO
import time
import pifacedigitalio
import picamera
import datetime
import json
import sys
import os
media_directory = 'home-server/public/images/media'
data_directory = 'home-server/public/data/'
schedule = json.loads(open(data_directory + 'schedule.json').read())
in_hours = False
previous_stat... |
from dis import dis
from io import StringIO
from itertools import product, chain
import random
import sys
import pytest
from codetransformer.code import Code, Flag, pycode
from codetransformer.instructions import LOAD_CONST, LOAD_FAST, uses_free
@pytest.fixture(scope='module')
def sample_flags(request):
random.... |
# Copyright 2016 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 applica... |
# PBNT: Python Bayes Network Toolbox
#
# Copyright (c) 2005, Elliot Cohen
# All rights reserved.
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions
# are met:
#
# * Redistributions of source code must retain the above copy... |
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
space: Colour spaces, part of the colourlab package
Copyright (C) 2013-2016 Ivar Farup
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either versi... |
import sys
import os.path
import HebbLearn as hl
import numpy as np
import matplotlib.pyplot as plt
try:
import h5py
except:
print('h5py cannot be loaded - may cause error')
pass
fl = hl.NonlinearGHA()
if os.path.isfile('processed_data.npy'):
print('==> Load previously saved (preprocessed) data')
... |
# Code for line numbers
# https://stackoverflow.com/questions/40386194/create-text-area-textedit-with-line-number-in-pyqt-5
from PyQt4.Qt import Qt
from PyQt4.QtCore import QRect
from PyQt4.QtCore import QSize
from PyQt4.QtCore import SIGNAL
from PyQt4.QtGui import QColor
from PyQt4.QtGui import QPainter
from PyQt4.Qt... |
# Copyright 2001-2009 Brad Chapman.
# Revisions copyright 2009-2010 by Peter Cock.
# Revisions copyright 2009 by David Winter.
# Revisions copyright 2009-2010 by Leighton Pritchard.
# All rights reserved.
# This code is part of the Biopython distribution and governed by its
# license. Please see the LICENSE file that ... |
"""doc."""
import wtforms
from wtforms.validators import DataRequired
from models import Entry, Tag
class ImageForm(wtforms.Form):
file = wtforms.FileField('Image file')
class TagField(wtforms.StringField):
"""doc."""
def _value(self):
"""doc."""
if self.data:
# Display tag... |
from itertools import product
import cvxpy as cvx
import numpy as np
from sklearn.metrics import make_scorer
from sklearn.utils import check_X_y
from fri.model.base_lupi import (
LUPI_Relevance_CVXProblem,
split_dataset,
is_lupi_feature,
)
from fri.model.ordinal_regression import (
OrdinalRegression_R... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.