repo_name stringlengths 7 65 | path stringlengths 5 185 | copies stringlengths 1 4 | size stringlengths 4 6 | content stringlengths 977 990k | license stringclasses 14
values | hash stringlengths 32 32 | line_mean float64 7.18 99.4 | line_max int64 31 999 | alpha_frac float64 0.25 0.95 | ratio float64 1.5 7.84 | autogenerated bool 1
class | config_or_test bool 2
classes | has_no_keywords bool 2
classes | has_few_assignments bool 1
class |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
bernardopires/django-tenant-schemas | examples/tenant_tutorial/tenant_tutorial/middleware.py | 13 | 1257 | from django.conf import settings
from django.contrib.contenttypes.models import ContentType
from django.db import connection
from django.http import Http404
from tenant_schemas.utils import get_tenant_model, remove_www_and_dev, get_public_schema_name
from django.db import utils
class TenantTutorialMiddleware(object):... | mit | d45f364b8fccc99493320dd6f8292453 | 38.28125 | 113 | 0.677009 | 4.218121 | false | false | false | false |
neherlab/treetime | treetime/aa_models.py | 1 | 4591 | from __future__ import division, print_function, absolute_import, absolute_import
import numpy as np
from .seq_utils import alphabets
def JTT92(mu=1.0):
from .gtr import GTR
# stationary concentrations:
pis = np.array([
0.07674789,
0.05169087,
0.04264509,
0.05154407,
... | mit | 563da98f80ce796da6e942ecd3d08a2f | 74.262295 | 188 | 0.701808 | 1.823272 | false | false | false | false |
neherlab/treetime | treetime/node_interpolator.py | 1 | 14693 | import numpy as np
from . import config as ttconf
from .distribution import Distribution
from .utils import clip
from .config import FFT_FWHM_GRID_SIZE
def _convolution_integrand(t_val, f, g,
inverse_time=None, return_log=False):
'''
Evaluates int_tau f(t+tau)*g(tau) or int_tau f(t-t... | mit | 90b33addf019e918f22af8d3c76d1316 | 40.041899 | 182 | 0.580957 | 3.436959 | false | false | false | false |
alerta/alerta-contrib | plugins/dingtalk/alerta_ding.py | 1 | 1353 | from dingtalkchatbot.chatbot import DingtalkChatbot
import time
import json
import sys
import os
import logging
try:
from alerta.plugins import app # alerta >= 5.0
except ImportError:
from alerta.app import app # alerta < 5.0
from alerta.plugins import PluginBase
LOG = logging.getLogger('alerta.plugins.di... | mit | 054f7eb30fc50caca5b9dd0dba20b00c | 21.55 | 91 | 0.625277 | 3.442748 | false | false | false | false |
alerta/alerta-contrib | plugins/dingtalk/dingtalkchatbot/chatbot.py | 1 | 14512 | #!/usr/bin/env python
# _*_ coding:utf-8 _*_
# create time: 07/01/2018 11:35
__author__ = 'Devin -- http://zhangchuzhao.site'
import json
import time
import logging
import requests
try:
JSONDecodeError = json.decoder.JSONDecodeError
except AttributeError:
JSONDecodeError = ValueError
def is_not_null_and_blan... | mit | 3a45e77e683c5b010323d1732387696e | 31.733509 | 141 | 0.516282 | 2.778499 | false | false | false | false |
sfu-natlang/glm-parser | src/feature/ner_fgen.py | 1 | 15522 | import feature_vector
import feature_generator_base
import debug.debug
from data.file_io import fileRead, fileWrite
from ner_PER_list import ner_per_list
from ner_LOC_list import ner_loc_list
import string
import copy
__version__ = '1.1'
per_list = ner_per_list
loc_list = ner_loc_list
class FeatureGenerator(featu... | mit | 971cc2410aff995a10d65eafab318e4f | 35.43662 | 103 | 0.541425 | 3.478709 | false | false | false | false |
alerta/alerta-contrib | plugins/prometheus/alerta_prometheus.py | 1 | 7937 | import datetime
import logging
import os
import requests
import json
from typing import Any
try:
from alerta.plugins import app # alerta >= 5.0
except ImportError:
from alerta.app import app # alerta < 5.0
from alerta.models.alert import Alert
from alerta.plugins import PluginBase
LOG = logging.getLogger('... | mit | f9fcd9bbe1cd159ef974960a449ce100 | 44.096591 | 173 | 0.577422 | 3.966517 | false | false | false | false |
alerta/alerta-contrib | plugins/opsgenie/alerta_opsgenie.py | 1 | 6138 | import logging
import os
import re
import requests
try:
from alerta.plugins import app # alerta >= 5.0
except ImportError:
from alerta.app import app # alerta < 5.0
from alerta.plugins import PluginBase
LOG = logging.getLogger('alerta.plugins.opsgenie')
LOG.info('Initializing')
OPSGENIE_EVENTS_CREATE_URL =... | mit | 860304e7cf04c09ff1ad3e59effbe0a7 | 41.625 | 116 | 0.609482 | 3.454136 | false | false | false | false |
alerta/alerta-contrib | integrations/supervisor/evlistener.py | 1 | 2703 | #!/usr/bin/env python
import sys
import json
import platform
from alertaclient.api import Client
class Listener(object):
def wait(self):
data = sys.stdin.readline()
headers = dict([x.split(':') for x in data.split()])
data = sys.stdin.read(int(headers['len']))
body = dict([x.spl... | mit | 78cc3482a186b579eb1ae7da5c6392bf | 30.8 | 86 | 0.468368 | 4.475166 | false | false | false | false |
cantools/cantools | cantools/database/can/c_source.py | 2 | 53130 | import re
import time
from decimal import Decimal
from ...version import __version__
HEADER_FMT = '''\
/**
* The MIT License (MIT)
*
* Copyright (c) 2018-2019 Erik Moqvist
*
* Permission is hereby granted, free of charge, to any person
* obtaining a copy of this software and associated documentation
* files (... | mit | 63fe3810aa88ee181e04d7a5fe078866 | 30.326651 | 98 | 0.522341 | 4.16151 | false | false | false | false |
jepegit/cellpy | cellpy/readers/instruments/pec_csv.py | 1 | 16574 | """pec csv-type data files"""
import logging
import os
import warnings
from datetime import datetime
import numpy as np
import pandas as pd
from dateutil.parser import parse
from cellpy.parameters.internal_settings import get_headers_normal
from cellpy.readers.core import Data, FileID, humanize_bytes
from cellpy.read... | mit | 0759a320b5fa8cafc98c3d53d4b8a376 | 37.096552 | 115 | 0.557507 | 3.797434 | false | false | false | false |
miguelgrinberg/python-socketio | examples/server/tornado/app.py | 1 | 2432 | import os
import tornado.ioloop
from tornado.options import define, options, parse_command_line
import tornado.web
import socketio
define("port", default=5000, help="run on the given port", type=int)
define("debug", default=False, help="run in debug mode")
sio = socketio.AsyncServer(async_mode='tornado')
async de... | mit | d0190ff9cccf533f9a5bda72d6dc46dd | 23.816327 | 79 | 0.618421 | 3.524638 | false | false | false | false |
qiniu/python-sdk | qiniu/utils.py | 1 | 4783 | # -*- coding: utf-8 -*-
from hashlib import sha1
from base64 import urlsafe_b64encode, urlsafe_b64decode
from datetime import datetime
from .compat import b, s
try:
import zlib
binascii = zlib
except ImportError:
zlib = None
import binascii
_BLOCK_SIZE = 1024 * 1024 * 4
def urlsafe_base64_encode(d... | mit | 7a584c3d6c17e054ef8459177c6a1095 | 19.5 | 77 | 0.529008 | 2.551662 | false | false | false | false |
meejah/txtorcon | txtorcon/onion.py | 1 | 53398 | import os
import re
import six
import base64
import hashlib
import functools
import warnings
from os.path import isabs, abspath
from zope.interface import Interface, Attribute, implementer
from twisted.internet import defer
from twisted.python import log
from txtorcon.util import find_keywords, version_at_least
from... | mit | fd57a0ab1489127f54c0a317304c6346 | 33.832355 | 116 | 0.592232 | 4.291754 | false | false | false | false |
meejah/txtorcon | txtorcon/torinfo.py | 1 | 9645 | # -*- coding: utf-8 -*-
from __future__ import absolute_import
from __future__ import print_function
from __future__ import unicode_literals
from __future__ import with_statement
import functools
from twisted.internet import defer
from txtorcon.interface import ITorControlProtocol
class MagicContainer(object):
... | mit | 9c4cd161cfc133163774c02024ba4e1e | 32.489583 | 79 | 0.555314 | 4.332884 | false | false | false | false |
meejah/txtorcon | txtorcon/stream.py | 1 | 11697 | # -*- coding: utf-8 -*-
"""
Contains an implementation of a :class:`Stream abstraction used by
:class:`TorState to represent all streams in Tor's state. There is
also an interface called :class:`interface.IStreamListener` for
listening for stream updates (see also
:meth:`TorState.add_stream_listener`) and the interfac... | mit | eea8f2ce5f426a32fbcd2ba90641c6cf | 36.251592 | 159 | 0.558519 | 4.371076 | false | false | false | false |
tdryer/hangups | examples/sync_recent_conversations.py | 3 | 1429 | """Example of using hangups to get recent conversations."""
import hangups
from common import run_example
async def sync_recent_conversations(client, _):
request = hangups.hangouts_pb2.SyncRecentConversationsRequest(
request_header=client.get_request_header(),
max_conversations=20,
max_e... | mit | 759292b804599ce026ebb3a11f52b924 | 33.02381 | 76 | 0.636809 | 3.770449 | false | false | false | false |
tdryer/hangups | setup.py | 1 | 2156 | from setuptools import setup
import os
import sys
if sys.version_info < (3, 6):
raise RuntimeError("hangups requires Python 3.6+")
# Find __version__ without import that requires dependencies to be installed:
exec(open(os.path.join(
os.path.dirname(__file__), 'hangups/version.py'
)).read())
with open('REA... | mit | bc715f3f8941f2ef196cf3f135acc601 | 29.8 | 79 | 0.616883 | 3.61139 | false | false | false | false |
tdryer/hangups | hangups/ui/__main__.py | 1 | 48593 | """Reference chat client for hangups."""
import appdirs
import asyncio
import configargparse
import contextlib
import logging
import os
import sys
import urwid
import readlike
from bisect import bisect
import hangups
from hangups.ui.emoticon import replace_emoticons
from hangups.ui import notifier
from hangups.ui.uti... | mit | b080acbabc3086f4ee7ded3812026b64 | 38.667755 | 79 | 0.579013 | 4.198099 | false | false | false | false |
tdryer/hangups | hangups/test/test_event.py | 1 | 1588 | """Tests for the simple observer implementation."""
import asyncio
import pytest
from hangups import event
def coroutine_test(coro):
"""Decorator to create a coroutine that starts and stops its own loop."""
def wrapper(*args, **kwargs):
future = coro(*args, **kwargs)
loop = asyncio.new_event... | mit | b8a7518ecc9c02988abe8c7cd8619b37 | 21.055556 | 77 | 0.594458 | 3.254098 | false | true | false | false |
tdryer/hangups | hangups/test/test_notifier.py | 3 | 2837 | import subprocess
import unittest.mock
from hangups.ui import notifier
NOTIFICATION = notifier.Notification(
'John Cleese', 'Cheese Shop', 'How about a little red Leicester?'
)
MOCK_DBUS = unittest.mock.patch(
'subprocess.check_output', autospec=True, return_value=b'(uint32 7,)\n'
)
MOCK_APPLE = unittest.moc... | mit | 9d98bfa75599b126eedac1202d3a8487 | 31.609195 | 79 | 0.63976 | 3.451338 | false | true | false | false |
tableau/server-client-python | tableauserverclient/server/endpoint/databases_endpoint.py | 1 | 5306 | import logging
from .default_permissions_endpoint import _DefaultPermissionsEndpoint
from .dqw_endpoint import _DataQualityWarningEndpoint
from .endpoint import api, Endpoint
from .exceptions import MissingRequiredFieldError
from .permissions_endpoint import _PermissionsEndpoint
from .. import RequestFactory, Database... | mit | 2379da72b491dc2a2f9a0025e949bac7 | 38.303704 | 108 | 0.671504 | 3.881492 | false | false | false | false |
tableau/server-client-python | samples/set_refresh_schedule.py | 1 | 3554 | ####
# This script demonstrates how to set the refresh schedule for
# a workbook or datasource.
#
# To run the script, you must have installed Python 3.7 or later.
####
import argparse
import logging
import tableauserverclient as TSC
def usage(args):
parser = argparse.ArgumentParser(description="Set refresh sc... | mit | 1850edbe771a4c38cbafaa3337d108b7 | 30.451327 | 116 | 0.664603 | 3.648871 | false | false | false | false |
tableau/server-client-python | tableauserverclient/_version.py | 1 | 18449 | # This file helps to compute a version number in source trees obtained from
# git-archive tarball (such as those provided by githubs download-from-tag
# feature). Distribution tarballs (built by setup.py sdist) and build
# directories (produced by setup.py build) will contain a much shorter file
# that just contains th... | mit | 6e9246c48021c7deada821eba7872819 | 32.482759 | 105 | 0.5764 | 3.902898 | false | false | false | false |
tableau/server-client-python | tableauserverclient/server/endpoint/subscriptions_endpoint.py | 1 | 3224 | import logging
from .endpoint import Endpoint, api
from .exceptions import MissingRequiredFieldError
from .. import RequestFactory, SubscriptionItem, PaginationItem
logger = logging.getLogger("tableau.endpoint.subscriptions")
from typing import List, Optional, TYPE_CHECKING, Tuple
if TYPE_CHECKING:
from ..reque... | mit | 94764b5ddef8ff02140f25f57eb3ec69 | 45.724638 | 115 | 0.692308 | 4.117497 | false | false | false | false |
tableau/server-client-python | test/test_fileuploads.py | 1 | 2568 | import os
import unittest
import requests_mock
from tableauserverclient.server import Server
from ._utils import asset
TEST_ASSET_DIR = os.path.join(os.path.dirname(__file__), "assets")
FILEUPLOAD_INITIALIZE = os.path.join(TEST_ASSET_DIR, "fileupload_initialize.xml")
FILEUPLOAD_APPEND = os.path.join(TEST_ASSET_DIR, ... | mit | f588eaf32961b6a2abcb262735a77ddf | 39.125 | 97 | 0.63824 | 3.309278 | false | true | false | false |
tableau/server-client-python | test/test_flow.py | 1 | 7281 | import unittest
import requests_mock
import tableauserverclient as TSC
from tableauserverclient.datetime_helpers import format_datetime
from ._utils import read_xml_asset, asset
GET_XML = "flow_get.xml"
POPULATE_CONNECTIONS_XML = "flow_populate_connections.xml"
POPULATE_PERMISSIONS_XML = "flow_populate_permissions.x... | mit | fd37f01ab7f2ccc0295d178b6d4648cc | 52.933333 | 104 | 0.671886 | 2.979133 | false | true | false | false |
tableau/server-client-python | tableauserverclient/models/property_decorators.py | 1 | 4709 | import datetime
import re
from functools import wraps
from ..datetime_helpers import parse_datetime
def property_is_enum(enum_type):
def property_type_decorator(func):
@wraps(func)
def wrapper(self, value):
if value is not None and not hasattr(enum_type, value):
error ... | mit | 5e90e2275e13bece184ea506d49894f8 | 27.889571 | 120 | 0.589722 | 4.280909 | false | false | false | false |
tableau/server-client-python | tableauserverclient/models/metric_item.py | 1 | 5102 | import xml.etree.ElementTree as ET
from ..datetime_helpers import parse_datetime
from .property_decorators import property_is_boolean, property_is_datetime
from .tag_item import TagItem
from typing import List, Optional, TYPE_CHECKING, Set
if TYPE_CHECKING:
from datetime import datetime
class MetricItem(object):... | mit | 90b2dba860cae12a336bca0849d84186 | 30.8875 | 94 | 0.600941 | 3.787676 | false | false | false | false |
tableau/server-client-python | test/test_user_model.py | 1 | 5671 | import logging
import unittest
from unittest.mock import *
from typing import List
import io
import pytest
import tableauserverclient as TSC
class UserModelTests(unittest.TestCase):
def test_invalid_name(self):
self.assertRaises(ValueError, TSC.UserItem, None, TSC.UserItem.Roles.Publisher)
self.... | mit | b7292b7acb8db4a3c48d12f4df07a946 | 39.798561 | 104 | 0.637454 | 3.537742 | false | true | false | false |
tableau/server-client-python | samples/create_project.py | 1 | 3902 | ####
# This script demonstrates how to use the Tableau Server Client
# to create new projects, both at the root level and how to nest them using
# parent_id.
#
#
# To run the script, you must have installed Python 3.7 or later.
####
import argparse
import logging
import sys
import tableauserverclient as TSC
def cre... | mit | 4e900064d358662807992dce4b05eb76 | 40.073684 | 116 | 0.688365 | 4.077325 | false | false | false | false |
tableau/server-client-python | tableauserverclient/server/request_options.py | 1 | 7010 | from ..models.property_decorators import property_is_int
import logging
logger = logging.getLogger("tableau.request_options")
class RequestOptionsBase(object):
# This method is used if server api version is below 3.7 (2020.1)
def apply_query_params(self, url):
try:
params = self.get_query... | mit | 54761aed8771d23c067396934d5bb9c2 | 27.04 | 113 | 0.571612 | 3.785097 | false | false | false | false |
tableau/server-client-python | tableauserverclient/server/server.py | 1 | 7383 | import logging
import warnings
import requests
import urllib3
from defusedxml.ElementTree import fromstring, ParseError
from packaging.version import Version
from .endpoint import (
Sites,
Views,
Users,
Groups,
Workbooks,
Datasources,
Projects,
Auth,
Schedules,
ServerInfo,
... | mit | 1894116c1a1a5ff872f15678b57175e7 | 30.961039 | 114 | 0.616822 | 3.988655 | false | false | false | false |
materialsvirtuallab/monty | monty/serialization.py | 1 | 4391 | """
This module implements serialization support for common formats such as json
and yaml.
"""
import json
import os
try:
from ruamel.yaml import YAML
except ImportError:
YAML = None # type: ignore
from monty.io import zopen
from monty.json import MontyDecoder, MontyEncoder
from monty.msgpack import default,... | mit | 15cce3e7fcb2d0d7e243527396246c9c | 34.128 | 115 | 0.580733 | 4.024748 | false | false | false | false |
earwig/mwparserfromhell | src/mwparserfromhell/smart_list/smart_list.py | 2 | 5535 | # Copyright (C) 2012-2020 Ben Kurtovic <ben.kurtovic@gmail.com>
# Copyright (C) 2019-2020 Yuri Astrakhan <YuriAstrakhan@gmail.com>
#
# 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 re... | mit | 9c65dafe19794565bb082b02fd3c3d76 | 34.031646 | 79 | 0.605781 | 4.019608 | false | false | false | false |
materialsvirtuallab/monty | monty/collections.py | 1 | 6532 | """
Useful collection classes, e.g., tree, frozendict, etc.
"""
import collections
def tree():
"""
A tree object, which is effectively a recursive defaultdict that
adds tree as members.
Usage:
x = tree()
x['a']['b']['c'] = 1
Returns:
A tree.
"""
return collection... | mit | 596ef942b758b216b64227faad6b9790 | 28.690909 | 101 | 0.574556 | 4.203346 | false | false | false | false |
materialsvirtuallab/monty | monty/string.py | 1 | 3098 | """
Useful additional string functions.
"""
import sys
def remove_non_ascii(s):
"""
Remove non-ascii characters in a file. Needed when support for non-ASCII
is not available.
Args:
s (str): Input string
Returns:
String with all non-ascii characters removed.
"""
return ""... | mit | 8aa0fe8a5b6d1b5c733b922742b885e8 | 20.971631 | 80 | 0.526791 | 3.692491 | false | false | false | false |
earwig/mwparserfromhell | tests/test_text.py | 1 | 2363 | # Copyright (C) 2012-2020 Ben Kurtovic <ben.kurtovic@gmail.com>
#
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to deal
# in the Software without restriction, including without limitation the rights
# to use, copy, ... | mit | fca217c1641d027e6b1af5e99e73e667 | 31.527778 | 79 | 0.684885 | 3.699842 | false | true | false | false |
materialsvirtuallab/monty | monty/os/__init__.py | 1 | 1232 | """
Os functions, e.g., cd, makedirs_p.
"""
import errno
import os
from contextlib import contextmanager
__author__ = "Shyue Ping Ong"
__copyright__ = "Copyright 2013, The Materials Project"
__version__ = "0.1"
__maintainer__ = "Shyue Ping Ong"
__email__ = "ongsp@ucsd.edu"
__date__ = "1/24/14"
@contextmanager
def c... | mit | 0b293157b1d7c6308087bdaf34b5c184 | 21.4 | 77 | 0.608766 | 3.677612 | false | false | false | false |
materialsvirtuallab/monty | tasks.py | 1 | 4101 | #!/usr/bin/env python
"""
Deployment file to facilitate releases of monty.
"""
import datetime
import glob
import json
import os
import re
import requests
from invoke import task
from monty import __version__ as ver
from monty.os import cd
__author__ = "Shyue Ping Ong"
__copyright__ = "Copyright 2012, The Materia... | mit | 042880b43f71d44b2c2a8fca0f61d264 | 26.52349 | 92 | 0.532065 | 3.431799 | false | false | false | false |
materialsvirtuallab/monty | monty/subprocess.py | 1 | 2634 | """
Calling shell processes.
"""
import shlex
import threading
import traceback
from subprocess import PIPE, Popen
from .string import is_string
__author__ = "Matteo Giantomass"
__copyright__ = "Copyright 2014, The Materials Virtual Lab"
__version__ = "0.1"
__maintainer__ = "Matteo Giantomassi"
__email__ = "gmatteo@g... | mit | d9272a47371302c4f6a3dfa88e46866b | 24.823529 | 90 | 0.577828 | 4.2969 | false | false | false | false |
materialsvirtuallab/monty | monty/itertools.py | 1 | 2755 | """
Additional tools for iteration.
"""
import itertools
try:
import numpy as np
except ImportError:
np = None # type: ignore
def chunks(items, n):
"""
Yield successive n-sized chunks from a list-like object.
>>> import pprint
>>> pprint.pprint(list(chunks(range(1, 25), 10)))
[(1, 2, 3,... | mit | edcaadbd60c215ea57db9652716cb128 | 28 | 76 | 0.544828 | 3.196056 | false | false | false | false |
earwig/mwparserfromhell | src/mwparserfromhell/nodes/extras/parameter.py | 1 | 2892 | # Copyright (C) 2012-2020 Ben Kurtovic <ben.kurtovic@gmail.com>
#
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to deal
# in the Software without restriction, including without limitation the rights
# to use, copy, ... | mit | a87ea3d8853c08b86e4c36a7979c826b | 34.268293 | 85 | 0.660788 | 3.983471 | false | false | false | false |
materialsvirtuallab/monty | monty/logging.py | 1 | 2224 | #!/usr/bin/env python
"""
Logging tools
"""
import argparse
import datetime
import functools
import logging
logger = logging.getLogger(__name__)
def logged(level=logging.DEBUG):
"""
Useful logging decorator. If a method is logged, the beginning and end of
the method call will be logged at a pre-specifi... | mit | 835c309b0d13eb3a82b2270523a696ba | 26.121951 | 104 | 0.594424 | 4.483871 | false | false | false | false |
getnikola/nikola | nikola/plugins/task/page_index.py | 1 | 4438 | # -*- coding: utf-8 -*-
# Copyright © 2012-2022 Roberto Alsina and others.
# Permission is hereby granted, free of charge, to any
# person obtaining a copy of this software and associated
# documentation files (the "Software"), to deal in the
# Software without restriction, including without limitation
# the rights t... | mit | b47adaf9ab6a2b40a5c20a7d8939d0f8 | 38.972973 | 106 | 0.659004 | 4.154494 | false | false | false | false |
machow/siuba | docs/conf.py | 1 | 3376 | #!/usr/bin/env python3
# -*- coding: utf-8 -*-
# Copied from https://github.com/spatialaudio/nbsphinx/blob/0.2.7/doc/conf.py
# Select nbsphinx and, if needed, add a math extension (mathjax or pngmath):
extensions = [
'nbsphinx',
'sphinx.ext.autodoc',
'sphinx.ext.autosummary',
'sphinx.ext.napoleon',
... | mit | d3de219830005e90c8045a17156d3f91 | 25.582677 | 223 | 0.625889 | 3.40666 | false | false | false | false |
getnikola/nikola | tests/test_slugify.py | 1 | 2219 | """Test slugify."""
import pytest
import nikola.utils
@pytest.mark.parametrize(
"title, language, expected_slug",
[
pytest.param("hello", "en", "hello", id="ASCII"),
pytest.param("hello-world", "en", "hello-world", id="ASCII with dashes"),
pytest.param("hello world", "en", "hello-wor... | mit | 63b6bcb06347c6dd395d9f0670b041fe | 28.534247 | 85 | 0.560297 | 2.833114 | false | true | false | false |
postlund/pyatv | pyatv/protocols/raop/__init__.py | 1 | 20847 | """Support for audio streaming using Remote Audio Output Protocol (RAOP)."""
import asyncio
import io
import logging
import math
from os import path
from typing import Any, Dict, Generator, Mapping, Optional, Set, Tuple, Union, cast
from pyatv import const, exceptions
from pyatv.auth.hap_pairing import Authentication... | mit | bfc1cad2dc8bd8f809402065269e1fd7 | 33.861204 | 88 | 0.629491 | 4.130573 | false | false | false | false |
pre-commit/pre-commit | pre_commit/languages/dotnet.py | 1 | 2616 | from __future__ import annotations
import contextlib
import os.path
from typing import Generator
from typing import Sequence
import pre_commit.constants as C
from pre_commit.envcontext import envcontext
from pre_commit.envcontext import PatchesT
from pre_commit.envcontext import Var
from pre_commit.hook import Hook
f... | mit | 36d76866c0812fe12aa1c35dc4f025df | 29.068966 | 78 | 0.61315 | 3.780347 | false | false | false | false |
pre-commit/pre-commit | pre_commit/languages/all.py | 1 | 6488 | from __future__ import annotations
from typing import Callable
from typing import NamedTuple
from typing import Sequence
from pre_commit.hook import Hook
from pre_commit.languages import conda
from pre_commit.languages import coursier
from pre_commit.languages import dart
from pre_commit.languages import docker
from ... | mit | 7604d7832ba80a6fe130fb6e02321649 | 91.685714 | 290 | 0.779131 | 3.303462 | false | false | false | false |
pre-commit/pre-commit | pre_commit/envcontext.py | 1 | 1612 | from __future__ import annotations
import contextlib
import enum
import os
from typing import Generator
from typing import MutableMapping
from typing import NamedTuple
from typing import Tuple
from typing import Union
_Unset = enum.Enum('_Unset', 'UNSET')
UNSET = _Unset.UNSET
class Var(NamedTuple):
name: str
... | mit | 587b1bd18c0e49900c9820d9b27157ef | 24.587302 | 78 | 0.617866 | 3.740139 | false | false | false | false |
tiangolo/fastapi | tests/test_tutorial/test_events/test_tutorial001.py | 1 | 2763 | from fastapi.testclient import TestClient
from docs_src.events.tutorial001 import app
openapi_schema = {
"openapi": "3.0.2",
"info": {"title": "FastAPI", "version": "0.1.0"},
"paths": {
"/items/{item_id}": {
"get": {
"responses": {
"200": {
... | mit | edfeac9bd118b5662e1357c01996bd70 | 33.974684 | 86 | 0.354687 | 5.079044 | false | true | false | false |
tiangolo/fastapi | tests/test_exception_handlers.py | 1 | 1918 | import pytest
from fastapi import FastAPI, HTTPException
from fastapi.exceptions import RequestValidationError
from fastapi.testclient import TestClient
from starlette.responses import JSONResponse
def http_exception_handler(request, exception):
return JSONResponse({"exception": "http-exception"})
def request_v... | mit | d644596c5022059943847dc83c84a6c5 | 27.626866 | 79 | 0.729406 | 4.037895 | false | true | false | false |
tiangolo/fastapi | tests/test_starlette_urlconvertors.py | 1 | 1371 | from fastapi import FastAPI, Path
from fastapi.testclient import TestClient
app = FastAPI()
@app.get("/int/{param:int}")
def int_convertor(param: int = Path()):
return {"int": param}
@app.get("/float/{param:float}")
def float_convertor(param: float = Path()):
return {"float": param}
@app.get("/path/{para... | mit | 4189c767b3b3756144a13e925e1d670e | 25.882353 | 91 | 0.654267 | 3.32767 | false | true | false | false |
tiangolo/fastapi | tests/test_tuples.py | 1 | 9118 | from typing import List, Tuple
from fastapi import FastAPI, Form
from fastapi.testclient import TestClient
from pydantic import BaseModel
app = FastAPI()
class ItemGroup(BaseModel):
items: List[Tuple[str, str]]
class Coordinate(BaseModel):
x: float
y: float
@app.post("/model-with-tuple/")
def post_m... | mit | fa1dac293853dc03a5d15029e222dceb | 33.407547 | 90 | 0.375082 | 4.824339 | false | false | false | false |
tiangolo/fastapi | tests/test_tutorial/test_bigger_applications/test_main.py | 1 | 17262 | import pytest
from fastapi.testclient import TestClient
from docs_src.bigger_applications.app.main import app
client = TestClient(app)
openapi_schema = {
"openapi": "3.0.2",
"info": {"title": "FastAPI", "version": "0.1.0"},
"paths": {
"/users/": {
"get": {
"tags": ["us... | mit | 0f2f05d5d38f80e68cbebcaa15dc0a29 | 34.156823 | 86 | 0.322964 | 5.190018 | false | false | false | false |
tiangolo/fastapi | tests/test_additional_responses_custom_model_in_callback.py | 1 | 4810 | from fastapi import APIRouter, FastAPI
from fastapi.testclient import TestClient
from pydantic import BaseModel, HttpUrl
from starlette.responses import JSONResponse
class CustomModel(BaseModel):
a: int
app = FastAPI()
callback_router = APIRouter(default_response_class=JSONResponse)
@callback_router.get(
... | mit | 129ddd849b8e9bbc0f681cd8e7f1b882 | 33.855072 | 94 | 0.330561 | 5.632319 | false | false | false | false |
tiangolo/fastapi | tests/test_security_api_key_header_optional.py | 1 | 2023 | from typing import Optional
from fastapi import Depends, FastAPI, Security
from fastapi.security import APIKeyHeader
from fastapi.testclient import TestClient
from pydantic import BaseModel
app = FastAPI()
api_key = APIKeyHeader(name="key", auto_error=False)
class User(BaseModel):
username: str
def get_curre... | mit | cdeabbdb03e8c29438453d43fffa0d57 | 26.337838 | 80 | 0.579832 | 3.746296 | false | true | false | false |
tiangolo/fastapi | fastapi/dependencies/utils.py | 1 | 27462 | import dataclasses
import inspect
from contextlib import contextmanager
from copy import deepcopy
from typing import (
Any,
Callable,
Coroutine,
Dict,
ForwardRef,
List,
Mapping,
Optional,
Sequence,
Tuple,
Type,
Union,
cast,
)
import anyio
from fastapi import params
f... | mit | 85e0818738971f58b518c88c6b145dc2 | 35.277411 | 88 | 0.630071 | 3.99099 | false | false | false | false |
alphagov/backdrop | features/support/tests/test_stagecraft.py | 1 | 4100 | import requests
from requests.exceptions import ConnectionError
from nose.tools import assert_raises
from hamcrest import assert_that, is_
from ..stagecraft import StagecraftService, \
create_or_update_stagecraft_service, stop_stagecraft_service_if_running
class StubContext(object):
def __init__(self):
... | mit | 4c892553e1345461320cbda3878e4b97 | 29.597015 | 87 | 0.634634 | 3.717135 | false | true | false | false |
alphagov/backdrop | backdrop/transformers/tasks/mapping.py | 1 | 1830 | import re
from .util import group_by
def compile_mappings(mappings):
compiled = {}
for mapping, patterns in mappings.iteritems():
compiled[mapping] = map(re.compile, patterns)
return compiled
def match_mapping(values, mappings):
for mapping, re_list in mappings.iteritems():
if all... | mit | 6402a99cdb204317aa73fea41bb26ad8 | 28.516129 | 87 | 0.590164 | 4.14966 | false | false | false | false |
alphagov/backdrop | backdrop/contrib/evl_volumetrics.py | 1 | 2681 | from datetime import datetime
import re
from backdrop.core.timeutils import as_utc
def extract_column_header(sheet):
HEADER_INDEX = 3
return sheet[HEADER_INDEX]
def extract_transaction_rows(sheet):
TRANSACTION_INDEXES = {
4: ["Assisted Digital", "Relicensing"],
5: ["Assisted Digital", "R... | mit | 9803a8de7ad16e93cb7bf04e05f33cf0 | 29.123596 | 72 | 0.564342 | 3.584225 | false | false | false | false |
chromaway/ngcccbase | ngcccbase/p2ptrade/protocol_objects.py | 4 | 4722 | import time
from coloredcoinlib import IncompatibleTypesError
from ngcccbase.txcons import RawTxSpec
from utils import make_random_id
from utils import CommonEqualityMixin
class EOffer(CommonEqualityMixin):
"""
A is the offer side's ColorValue
B is the replyer side's ColorValue
"""
def __init__(... | mit | bfebc5eb6a8163b99caaea18c265fe7b | 31.791667 | 78 | 0.55845 | 3.441691 | false | false | false | false |
chromaway/ngcccbase | ui/wallet.py | 4 | 7007 | from ngcccbase.pwallet import PersistentWallet
from ngcccbase.wallet_controller import WalletController
from ngcccbase.asset import AssetDefinition
from ngcccbase.p2ptrade.ewctrl import EWalletController
from ngcccbase.p2ptrade.agent import EAgent
from ngcccbase.p2ptrade.comm import HTTPComm, ThreadedComm
from ngcccba... | mit | 17e64c7365c816f9a2b2c93d3b584bbe | 34.933333 | 81 | 0.618096 | 3.647579 | false | false | false | false |
chromaway/ngcccbase | coloredcoinlib/txspec.py | 4 | 5703 | """ Transaction specification language """
from blockchain import CTxIn
from colorvalue import ColorValue, SimpleColorValue
class InvalidColorIdError(Exception):
pass
class ZeroSelectError(Exception):
pass
class ColorTarget(object):
def __init__(self, address, colorvalue):
self.address = addr... | mit | 271c7455fa01b52ee160ffe5dd277102 | 31.775862 | 82 | 0.60512 | 3.890177 | false | false | false | false |
chromaway/ngcccbase | ngcccbase/txcons.py | 3 | 15270 | """
txcons.py
Transaction Constructors for the blockchain.
"""
from collections import defaultdict
from asset import AssetTarget
from coloredcoinlib import (ColorSet, ColorTarget, SimpleColorValue,
ComposedTxSpec, OperationalTxSpec,
UNCOLORED_MARKER, OBColorDefi... | mit | 1154a06f78a6b79f1fb789889bc2e904 | 37.560606 | 89 | 0.614604 | 3.967264 | false | false | false | false |
rlworkgroup/metaworld | metaworld/envs/mujoco/sawyer_xyz/v2/sawyer_drawer_open_v2.py | 1 | 4519 | import numpy as np
from gym.spaces import Box
from metaworld.envs import reward_utils
from metaworld.envs.asset_path_utils import full_v2_path_for
from metaworld.envs.mujoco.sawyer_xyz.sawyer_xyz_env import SawyerXYZEnv, _assert_task_is_set
class SawyerDrawerOpenEnvV2(SawyerXYZEnv):
def __init__(self):
... | mit | 2d0921ad76e4bdafa25c1bee9c52c43c | 31.746377 | 93 | 0.561407 | 3.339985 | false | false | false | false |
rlworkgroup/metaworld | metaworld/policies/sawyer_drawer_open_v1_policy.py | 1 | 1555 | import numpy as np
from metaworld.policies.action import Action
from metaworld.policies.policy import Policy, assert_fully_parsed, move
class SawyerDrawerOpenV1Policy(Policy):
@staticmethod
@assert_fully_parsed
def _parse_obs(obs):
return {
'hand_pos': obs[:3],
'drwr_pos'... | mit | 62e6dd9318c873caaf1c20c43e273642 | 31.395833 | 74 | 0.550482 | 3.351293 | false | false | false | false |
rlworkgroup/metaworld | metaworld/envs/mujoco/sawyer_xyz/v1/sawyer_handle_press_side.py | 1 | 3890 | import numpy as np
from gym.spaces import Box
from metaworld.envs.asset_path_utils import full_v1_path_for
from metaworld.envs.mujoco.sawyer_xyz.sawyer_xyz_env import SawyerXYZEnv, _assert_task_is_set
class SawyerHandlePressSideEnv(SawyerXYZEnv):
def __init__(self):
hand_low = (-0.5, 0.40, 0.05)
... | mit | db9d5ac66b2bbfeb9ae4dcc1b788e9d9 | 30.12 | 117 | 0.562982 | 3.119487 | false | false | false | false |
rlworkgroup/metaworld | metaworld/policies/sawyer_button_press_topdown_wall_v2_policy.py | 1 | 1069 | import numpy as np
from metaworld.policies.action import Action
from metaworld.policies.policy import Policy, assert_fully_parsed, move
class SawyerButtonPressTopdownWallV2Policy(Policy):
@staticmethod
@assert_fully_parsed
def _parse_obs(obs):
return {
'hand_pos': obs[:3],
... | mit | d9822c083a8d14942e076a9fe25ba4c2 | 25.725 | 89 | 0.540692 | 3.299383 | false | false | false | false |
rlworkgroup/metaworld | metaworld/envs/mujoco/sawyer_xyz/v2/sawyer_push_back_v2.py | 1 | 8128 | import numpy as np
from gym.spaces import Box
from scipy.spatial.transform import Rotation
from metaworld.envs import reward_utils
from metaworld.envs.asset_path_utils import full_v2_path_for
from metaworld.envs.mujoco.sawyer_xyz.sawyer_xyz_env import SawyerXYZEnv, _assert_task_is_set
class SawyerPushBackEnvV2(Sawye... | mit | 183f55d9340a093f49b44ede51ded5ca | 36.981308 | 104 | 0.563484 | 3.187451 | false | false | false | false |
rlworkgroup/metaworld | metaworld/policies/sawyer_handle_press_side_v2_policy.py | 1 | 1056 | import numpy as np
from metaworld.policies.action import Action
from metaworld.policies.policy import Policy, assert_fully_parsed, move
class SawyerHandlePressSideV2Policy(Policy):
@staticmethod
@assert_fully_parsed
def _parse_obs(obs):
return {
'hand_pos': obs[:3],
'grip... | mit | 5311e0bd4f2f1c89514743e0cc1fd148 | 25.4 | 89 | 0.536932 | 3.28972 | false | false | false | false |
rlworkgroup/metaworld | metaworld/policies/sawyer_pick_place_wall_v2_policy.py | 1 | 2569 | import numpy as np
from metaworld.policies.action import Action
from metaworld.policies.policy import Policy, move, assert_fully_parsed
class SawyerPickPlaceWallV2Policy(Policy):
@staticmethod
@assert_fully_parsed
def _parse_obs(obs):
return {
'hand_pos': obs[:3],
'unused... | mit | 7a9525c2c0b623034708145b4427f8fc | 35.183099 | 103 | 0.51849 | 3.195274 | false | false | false | false |
rlworkgroup/metaworld | metaworld/envs/mujoco/sawyer_xyz/v2/sawyer_push_v2.py | 1 | 5849 | import numpy as np
from gym.spaces import Box
from scipy.spatial.transform import Rotation
from metaworld.envs import reward_utils
from metaworld.envs.asset_path_utils import full_v2_path_for
from metaworld.envs.mujoco.sawyer_xyz.sawyer_xyz_env import SawyerXYZEnv, _assert_task_is_set
class SawyerPushEnvV2(SawyerXYZ... | mit | d7786bd68cf9b9c3272791a1cad02f84 | 32.232955 | 96 | 0.535647 | 3.30452 | false | false | false | false |
rlworkgroup/metaworld | tests/metaworld/envs/mujoco/sawyer_xyz/test_obs_space_hand.py | 1 | 1831 | import numpy as np
import pytest
from metaworld.envs.mujoco.sawyer_xyz.sawyer_xyz_env import SawyerXYZEnv
from metaworld.envs.mujoco.env_dict import ALL_V2_ENVIRONMENTS
from metaworld.policies.policy import Policy, move
from metaworld.policies.action import Action
class SawyerRandomReachPolicy(Policy):
def __ini... | mit | 7b0d68e69ccdeed216422de0ac00f3d9 | 26.328358 | 79 | 0.627526 | 3.287253 | false | false | false | false |
rlworkgroup/metaworld | metaworld/policies/sawyer_pick_place_v2_policy.py | 1 | 1963 | import numpy as np
from metaworld.policies.action import Action
from metaworld.policies.policy import Policy, assert_fully_parsed, move
class SawyerPickPlaceV2Policy(Policy):
@staticmethod
@assert_fully_parsed
def _parse_obs(obs):
return {
'hand_pos': obs[:3],
'gripper_di... | mit | 0e18cdbf7d43da1455bf5b1404e4a3aa | 31.196721 | 90 | 0.540499 | 3.166129 | false | false | false | false |
rlworkgroup/metaworld | tests/metaworld/envs/mujoco/sawyer_xyz/test_scripted_policies.py | 1 | 14279 | import pytest
from metaworld.envs.mujoco.env_dict import ALL_V1_ENVIRONMENTS, ALL_V2_ENVIRONMENTS
from metaworld.policies import *
from tests.metaworld.envs.mujoco.sawyer_xyz.utils import trajectory_summary
test_cases_old_nonoise = [
# This should contain configs where a V2 policy is running in a V1 env.
# n... | mit | aabc5411de81ac4b9bc1236daf9f85f1 | 53.708812 | 91 | 0.654037 | 2.564936 | false | true | false | false |
adamewing/bamsurgeon | bin/bamsurgeon/mutation.py | 1 | 11184 | #!/usr/bin/env python
from bamsurgeon.common import *
from collections import OrderedDict as od
import subprocess
import logging
FORMAT = '%(levelname)s %(asctime)s %(message)s'
logging.basicConfig(format=FORMAT)
logger = logging.getLogger(__name__)
logger.setLevel(logging.INFO)
def countBaseAtPos(bamfile,chrom,pos... | mit | 8cd69ad873e39db4471e19eb4e0bf2c1 | 38.800712 | 241 | 0.54873 | 3.660884 | false | false | false | false |
cablehead/python-consul | consul/aio.py | 1 | 2424 | from __future__ import absolute_import
import sys
import asyncio
import warnings
import aiohttp
from consul import base
__all__ = ['Consul']
PY_341 = sys.version_info >= (3, 4, 1)
class HTTPClient(base.HTTPClient):
"""Asyncio adapter for python consul using aiohttp library"""
def __init__(self, *args, loo... | mit | e4228141f3a29da8d57319959542a954 | 32.205479 | 76 | 0.600248 | 3.8784 | false | false | false | false |
adamewing/bamsurgeon | bin/addsv.py | 1 | 46537 | #!/usr/bin/env python
#from __future__ import print_function
import re
import os
import sys
import random
import subprocess
import argparse
import pysam
import bamsurgeon.replace_reads as rr
import bamsurgeon.asmregion as ar
import bamsurgeon.mutableseq as ms
import bamsurgeon.aligners as aligners
import bamsurgeon.m... | mit | 5a5d6a2ad4a66b78d29e8e4feaf4072b | 40.001762 | 213 | 0.594409 | 3.274947 | false | false | false | false |
adamewing/bamsurgeon | scripts/postprocess.py | 1 | 10607 | #!/usr/bin/env python
import argparse
import pysam
import sys
import logging
from subprocess import call
from re import sub
from os.path import basename
from os import remove, rename
from uuid import uuid4
def getRG(tags):
''' fetch RG, tags is from a pysam.AlignedRead.tags, returns RG name '''
for tag, va... | mit | 09cdc7671392ba479cc86c85df24b28e | 35.078231 | 152 | 0.537852 | 3.561786 | false | false | false | false |
wemake-services/wemake-django-template | {{cookiecutter.project_name}}/docs/conf.py | 1 | 4080 | # wemake-django-template documentation build configuration file, created by
# sphinx-quickstart on Sat Sep 30 12:42:34 2017.
#
# 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 configur... | mit | 4beeaa3e9dc0b3ff52cdd5226c070929 | 30.875 | 79 | 0.699265 | 3.827392 | false | true | false | false |
scitran/core | tests/integration_tests/python/test_access_log.py | 2 | 11998 | import time
from api.web.request import AccessType
# NOTE these tests assume they are not running in parallel w/ other tests
# by relying on the last entry in the logs
def test_access_log_succeeds(data_builder, as_admin, log_db):
project = data_builder.create_project()
session = data_builder.create_session(... | mit | 307a5616e9834f4966e037c267a59916 | 30.994667 | 119 | 0.61702 | 3.369278 | false | true | false | false |
xesscorp/skidl | docs/files/a-taste-of-hierarchy/intfc_brd.py | 2 | 4256 | from skidl import *
@SubCircuit
def osc(osc1, osc2, gnd,
crystal = Part("Device", 'Crystal', footprint='Crystal:Crystal_HC49-U_Vertical', dest=TEMPLATE),
cap = Part("Device", 'C', value='10pf', footprint='Capacitors_SMD:C_0603', dest=TEMPLATE) ):
'''Attach a crystal and two caps to the osc1 and o... | mit | 238830559b964cdcf7563b9ab2a9f145 | 37.690909 | 105 | 0.639333 | 2.502058 | false | false | false | false |
xesscorp/skidl | skidl/libs/stm8_sklib.py | 1 | 8126 | from skidl import SKIDL, TEMPLATE, Part, Pin, SchLib
SKIDL_lib_version = '0.0.1'
stm8 = SchLib(tool=SKIDL).add_parts(*[
Part(name='STM8L051F3P',dest=TEMPLATE,tool=SKIDL,keywords='STM8L Microcontroller Value Line Low Power',description='16MHz, 8K Flash, 1k RAM, 256 EEPROM, RTC, USART, I2C, SPI, ADC, TSSOP20',r... | mit | b627596d8531d2dd2be256f6d093e271 | 79.455446 | 279 | 0.602141 | 2.252842 | false | false | true | false |
scitran/core | bin/integrity_check.py | 2 | 3067 | # Print list of rules with invalid algs
import argparse
import logging
import sys
from api import config
from api.dao import APINotFoundException
from api.jobs.gears import get_gear_by_name
# Methods should return true if all integrity checks passed
INTEGRITY_CHECKS = {
"rule_alg" : "Confirm alg keys in r... | mit | af85c11ebfa5038613e115fee81e2be8 | 29.979798 | 126 | 0.558526 | 4.189891 | false | false | false | false |
scitran/core | tests/unit_tests/python/test_dataexplorer.py | 2 | 19300 | import copy
import json
import elasticsearch
import api.handlers.dataexplorerhandler as deh
class TestTransportError(elasticsearch.TransportError):
def __str__(self):
return 'TestTransportError'
def test_search(as_public, as_drone, es):
# try to search w/o login
r = as_public.post('/dataexplore... | mit | 92995a6b9c2c32039e55dc52514bbc94 | 39.292276 | 150 | 0.528912 | 3.694487 | false | false | false | false |
pytest-dev/pytest | testing/test_setuponly.py | 12 | 8161 | import sys
import pytest
from _pytest.config import ExitCode
from _pytest.pytester import Pytester
@pytest.fixture(params=["--setup-only", "--setup-plan", "--setup-show"], scope="module")
def mode(request):
return request.param
def test_show_only_active_fixtures(
pytester: Pytester, mode, dummy_yaml_custom... | mit | a662ac43d01762ca758bb141b793c97f | 24.663522 | 88 | 0.537557 | 3.994616 | false | true | false | false |
pytest-dev/pytest | src/_pytest/pathlib.py | 1 | 25096 | import atexit
import contextlib
import fnmatch
import importlib.util
import itertools
import os
import shutil
import sys
import uuid
import warnings
from enum import Enum
from errno import EBADF
from errno import ELOOP
from errno import ENOENT
from errno import ENOTDIR
from functools import partial
from os.path import ... | mit | 7edb1db3344d0f33aedf4a7893058c12 | 32.550802 | 102 | 0.632571 | 3.886033 | false | false | false | false |
pytest-dev/pytest | src/_pytest/compat.py | 1 | 12820 | """Python version compatibility code."""
import enum
import functools
import inspect
import os
import sys
from inspect import Parameter
from inspect import signature
from pathlib import Path
from typing import Any
from typing import Callable
from typing import Generic
from typing import NoReturn
from typing import Opti... | mit | 6e965772337c30e99b3cebfe41d59b6b | 29.743405 | 102 | 0.650234 | 3.88132 | false | false | false | false |
pytest-dev/pytest | src/_pytest/_py/path.py | 1 | 49158 | """local path implementation."""
from __future__ import annotations
import atexit
import fnmatch
import importlib.util
import io
import os
import posixpath
import sys
import uuid
import warnings
from contextlib import contextmanager
from os.path import abspath
from os.path import dirname
from os.path import exists
fro... | mit | 18b9720980eb46abfa413330fc00d127 | 32.327458 | 103 | 0.521197 | 4.449493 | false | false | false | false |
pytest-dev/pytest | testing/test_doctest.py | 2 | 49020 | import inspect
import sys
import textwrap
from pathlib import Path
from typing import Callable
from typing import Optional
import pytest
from _pytest.doctest import _get_checker
from _pytest.doctest import _is_main_py
from _pytest.doctest import _is_mocked
from _pytest.doctest import _is_setup_py
from _pytest.doctest ... | mit | 1c2987329e6cbc9de2744899da2c3375 | 29.662703 | 109 | 0.458254 | 4.348509 | false | true | false | false |
tweepy/tweepy | tests/config.py | 2 | 1118 | import os
import unittest
import vcr
from tweepy.api import API
from tweepy.auth import OAuth1UserHandler
user_id = os.environ.get('TWITTER_USER_ID', '1072250532645998596')
username = os.environ.get('TWITTER_USERNAME', 'TweepyDev')
bearer_token = os.environ.get('BEARER_TOKEN', '')
consumer_key = os.environ.get('CON... | mit | 97058c773f64462c61c36ad2b7eb3a1f | 26.95 | 72 | 0.690519 | 3.140449 | false | true | false | false |
tweepy/tweepy | setup.py | 2 | 2523 | #!/usr/bin/env python
import re
from setuptools import find_packages, setup
VERSION_FILE = "tweepy/__init__.py"
with open(VERSION_FILE) as version_file:
match = re.search(r"^__version__ = ['\"]([^'\"]*)['\"]",
version_file.read(), re.MULTILINE)
if match:
version = match.group(1)
else:
... | mit | ee208b4876f191d9ee0872d7273629ad | 30.5375 | 75 | 0.550535 | 3.475207 | false | false | false | false |
tweepy/tweepy | tweepy/streaming.py | 2 | 38949 | # Tweepy
# Copyright 2009-2022 Joshua Roesslein
# See LICENSE for details.
# Appengine users: https://developers.google.com/appengine/docs/python/sockets/#making_httplib_use_sockets
from collections import namedtuple
import json
import logging
from math import inf
from platform import python_version
import ssl
import... | mit | 70683ca59c2ef1b205606f27d2f9ef35 | 36.624155 | 224 | 0.576513 | 4.607312 | false | false | false | false |
cleverhans-lab/cleverhans | cleverhans_v3.1.0/examples/imagenet_featadvs/model.py | 1 | 1273 | # pylint: disable=missing-docstring
import functools
import tensorflow as tf
from cleverhans.initializers import HeReLuNormalInitializer
from cleverhans.model import Model
class ModelImageNetCNN(Model):
def __init__(self, scope, nb_classes=1000, **kwargs):
del kwargs
Model.__init__(self, scope, n... | mit | 0362c955f9e4b15e70fb0f062a2636b0 | 31.641026 | 88 | 0.595444 | 3.478142 | false | false | false | false |
cleverhans-lab/cleverhans | cleverhans_v3.1.0/cleverhans/attacks/sparse_l1_descent.py | 1 | 14083 | """
The SparseL1Descent attack.
"""
import warnings
from distutils.version import LooseVersion
import tensorflow as tf
from cleverhans.attacks.attack import Attack
from cleverhans import utils_tf
from cleverhans.utils_tf import clip_eta, random_lp_vector
from cleverhans.compat import reduce_max, reduce_sum, softmax_... | mit | ccbdf5b48b1315b83230451ecc106ad3 | 37.583562 | 88 | 0.602215 | 3.840469 | false | false | false | false |
cleverhans-lab/cleverhans | cleverhans/utils.py | 2 | 12028 | """
Generic utility functions useful for writing Python code in general
"""
from __future__ import absolute_import
from __future__ import division
from __future__ import print_function
from __future__ import unicode_literals
from collections import OrderedDict
import warnings
import logging
import os
import re
import ... | mit | e547c828dfd6051cdcd3048d74f6f654 | 30.241558 | 84 | 0.643748 | 3.824483 | false | false | false | false |
cleverhans-lab/cleverhans | cleverhans_v3.1.0/cleverhans/attacks_tf.py | 1 | 8442 | # pylint: disable=missing-docstring
from __future__ import absolute_import
from __future__ import division
from __future__ import print_function
from __future__ import unicode_literals
import warnings
import numpy as np
from cleverhans.attacks.carlini_wagner_l2 import (
CWL2 as CarliniWagnerL2,
) # pylint: disa... | mit | 0163e047683a373755dde21b596cfc78 | 33.740741 | 80 | 0.673656 | 3.643505 | false | false | false | false |
cleverhans-lab/cleverhans | cleverhans_v3.1.0/examples/multigpu_advtrain/make_model.py | 1 | 1889 | # pylint: disable=missing-docstring
from model import Conv2D, ReLU, Flatten, Linear, Softmax, MLP
from model import MLPnGPU
from model import Conv2DnGPU
from model import LinearnGPU
from model import MaxPool
from resnet_tf import ResNetTF
def make_basic_cnn(nb_filters=64, nb_classes=10, input_shape=(None, 28, 28, 1)... | mit | d4cf8a10af5ce678e9e5589dda23e793 | 26.376812 | 80 | 0.574907 | 3.081566 | false | false | false | false |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.