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
flav-io/flavio
flavio/physics/bdecays/bll.py
1
10206
r"""Functions for the branching ratios and effective lifetimes of the leptonic decays $B_q \to \ell^+\ell^-$, where $q=d$ or $s$ and $\ell=e$, $\mu$. or $\tau$.""" from math import pi,sqrt from flavio.physics import ckm from flavio.physics.running import running from flavio.physics.bdecays.common import meson_quark, l...
mit
f702a8ce021f96690773c9731560968b
37.954198
127
0.552714
2.524988
false
false
false
false
flav-io/flavio
flavio/plots/plotfunctions.py
1
39693
from collections import OrderedDict import matplotlib import matplotlib.pyplot as plt import matplotlib.patches as patches import numpy as np import flavio from flavio.statistics.functions import delta_chi2, confidence_level import scipy.optimize import scipy.interpolate import scipy.stats from numbers import Number fr...
mit
43482d98cdbfaee869f2ed7ccb8b3e04
43.103333
146
0.622553
3.65161
false
false
false
false
flav-io/flavio
flavio/physics/bdecays/formfactors/b_p/bcl.py
1
3568
from math import sqrt import numpy as np import flavio from flavio.physics.bdecays.formfactors.common import z from flavio.physics.bdecays.formfactors.b_p.isgurwise import isgur_wise def pole(ff, mres, q2): if mres == 0 or mres is None: return 1 return 1/(1-q2/mres**2) # the following dict maps transi...
mit
e496204b2464168e699fc9aa5f157593
40.011494
84
0.554372
2.328982
false
false
false
false
flav-io/flavio
flavio/physics/higgs/width.py
1
1589
r"""Functions for the total Higgs width.""" from . import decay from math import pi # SM Higgs BRs, taken from Higgs XSWG for m_h=125.10 GeV BR_SM = { 'bb': 0.5807, 'WW': 0.2154, 'ZZ': 0.02643, 'gg': 0.08179, 'tautau': 0.06256, } # SM total width over Higgs mass Gamma_rel_SM = 4.101e-3 / 125.10...
mit
a53858bb3577898590d090dbb76ed94e
30.78
78
0.596602
2.679595
false
false
false
false
bugsnag/bugsnag-python
example/django31/todo/settings.py
1
3237
# flake8: noqa """ Django settings for todo project. Generated by 'django-admin startproject' using Django 3.0.8. For more information on this file, see https://docs.djangoproject.com/en/3.1/topics/settings/ For the full list of settings and their values, see https://docs.djangoproject.com/en/3.1/ref/settings/ """ ...
mit
8e27196f688fec5da83fe12c51eac9bd
24.690476
91
0.684584
3.476907
false
false
false
false
flav-io/flavio
flavio/physics/edms/paraedm.py
1
2479
"""Functions for EDMs of paramagnetic atoms and molecules.""" import flavio from flavio.physics.edms.common import edm_f from flavio.physics.edms.slcouplings import CS from math import pi, sqrt atoms = { 'Tl': { 'Z': 3, 'N': 4, 'tex': r'\text{Tl}', 'name': 'Thallium' }, } molecules = { 'YbF': {...
mit
8a3d0af490874179a7a9819960f9e2fb
31.618421
113
0.594595
2.620507
false
false
false
false
pythonindia/wye
tests/functional/test_forgot_password_flow.py
4
1705
import re from .. import factories as f def test_forgot_password_flow(base_url, browser, outbox): f.create_usertype(slug='tutor', display_name='tutor') user = f.UserFactory() # Forgot password link must be present on login page url = base_url + '/accounts/login/' browser.visit(url) forgot_pas...
mit
d7dee1bcd23d31f5d26f9982cddce32b
37.75
74
0.676833
3.479592
false
false
false
false
bugsnag/bugsnag-python
bugsnag/legacy.py
1
4636
from typing import Dict, Any, Tuple, Type import types import sys from bugsnag.breadcrumbs import BreadcrumbType, OnBreadcrumbCallback from bugsnag.configuration import RequestConfiguration from bugsnag.client import Client default_client = Client() configuration = default_client.configuration logger = configuration....
mit
1bb50ad2a91050eba18add116d73be54
27.617284
78
0.636324
4
false
true
false
false
flav-io/flavio
flavio/statistics/probability.py
1
79875
"""Probability distributions and auxiliary functions to deal with them.""" import numpy as np import scipy.stats from scipy.interpolate import interp1d, RegularGridInterpolator import scipy.signal import math from flavio.math.functions import normal_logpdf, normal_pdf from flavio.statistics.functions import confidence...
mit
ab438957d979a76439404a7bb83d079e
41.759636
131
0.615937
4.093215
false
false
false
false
flav-io/flavio
flavio/physics/kdecays/kpipi.py
1
7624
r"""Functions for observables in $K\to\pi\pi$ decays, in particular $\epsilon'/\epsilon$.""" import flavio from flavio.classes import Prediction, Observable from flavio.config import config from flavio.physics import ckm from flavio.physics.kdecays.wilsoncoefficients import wilsoncoefficients_sm_fourquark from math im...
mit
90ef45424b0bfd7cbb203a09099a973f
40.423913
106
0.534112
2.44687
false
false
false
false
flav-io/flavio
flavio/physics/zdecays/gammaz.py
1
7028
r"""$Z$ pole observables beyond the SM.""" import flavio from flavio.physics.zdecays import gammazsm, smeftew from math import sqrt, pi def GammaZ_NP(par, Nc, gV_SM, d_gV, gA_SM, d_gA): GF, mZ = par['GF'], par['m_Z'] return ( sqrt(2) * GF * mZ**3 / (3 * pi) * Nc * ( 2*(gV_SM*d_gV).real +...
mit
dde0f76c1e91f5876fb37c63e566e3b6
35.041026
117
0.574986
2.412633
false
false
false
false
bugsnag/bugsnag-python
bugsnag/utils.py
1
14034
from functools import wraps, partial import inspect from json import JSONEncoder from threading import local as threadlocal from typing import AnyStr, Tuple, Optional import warnings import copy import logging from datetime import datetime, timedelta from urllib.parse import urlparse, urlunsplit, parse_qs MAX_PAYLOAD_...
mit
926b75c9897f81e0be8413b3a78cc452
31.188073
79
0.591706
4.199282
false
false
false
false
flav-io/flavio
flavio/physics/kdecays/wilsoncoefficients.py
1
2016
r"""Functions for SM Wilson coefficients in kaon decays.""" import scipy.interpolate import flavio from flavio.physics import ckm # Table 1 of 1507.06345: Wilson coefficients at 1.3 GeV # for alpha_s = [0.1179, 0.1185, 0.1191] _yz = [[-0.4036, -0.4092, -0.4150], [1.2084, 1.2120, 1.2157], [0.0275, 0.0280, 0.0285], [-...
mit
f774029d5596dd1308f6bef2ebcb4873
36.333333
90
0.612599
2.391459
false
false
false
false
catalyst-cooperative/pudl
src/pudl/output/epacems.py
1
6538
"""Routines that provide user-friendly access to the partitioned EPA CEMS dataset.""" from itertools import product from pathlib import Path from typing import Iterable, List, Optional, Sequence, Tuple, Union import dask.dataframe as dd import pandas as pd import pudl from pudl.settings import EpaCemsSettings # TOD...
mit
8fcdd3df6bd610ac7d391b1606d8179a
36.147727
88
0.683695
3.763961
false
false
false
false
catalyst-cooperative/pudl
src/pudl/metadata/enums.py
1
5641
"""Enumerations of valid field values.""" from typing import Dict, List US_STATES: Dict[str, str] = { "AK": "Alaska", "AL": "Alabama", "AR": "Arkansas", "AZ": "Arizona", "CA": "California", "CO": "Colorado", "CT": "Connecticut", "DE": "Delaware", "FL": "Florida", "GA": "Georgia"...
mit
6e8b3e8fbb7f51778af563df697a9799
25.111111
91
0.578369
2.712843
false
false
false
false
catalyst-cooperative/pudl
src/pudl/analysis/epa_crosswalk.py
1
10658
"""Use the EPA crosswalk to connect EPA units to EIA generators and other data. A major use case for this dataset is to identify subplants within plant_ids, which are the smallest coherent units for aggregation. Despite the name, plant_id refers to a legal entity that often contains multiple distinct power plants, eve...
mit
799a28a64b53c210d36c60ff593e5148
39.524715
137
0.711766
3.542041
false
false
false
false
catalyst-cooperative/pudl
src/pudl/transform/ferc1.py
1
112928
"""Routines for transforming FERC Form 1 data before loading into the PUDL DB. This module provides a variety of functions that are used in cleaning up the FERC Form 1 data prior to loading into our database. This includes adopting standardized units and column names, standardizing the formatting of some string values...
mit
306ab25fe2adadd7e2ced0fe65b323da
34.509434
133
0.55279
3.603638
false
false
false
false
frigg/frigg-hq
tests/helpers/test_github.py
1
1420
from django.test import TestCase from frigg.builds.models import Build, BuildResult, Project from frigg.helpers.github import _get_status_from_build, get_pull_request_url class GithubHelpersTestCase(TestCase): def test__get_status_from_build(self): error = RuntimeError() build = Build.objects.cr...
mit
30c5d8a629a2fdc465dc963131c63d5a
44.806452
94
0.666901
3.604061
false
true
false
false
frigg/frigg-hq
frigg/deployments/models.py
1
2932
import json from datetime import timedelta import redis from django.conf import settings from django.db import models from django.utils.timezone import now from frigg.helpers import github from .managers import PRDeploymentManager class PRDeployment(models.Model): build = models.OneToOneField('builds.Build', r...
mit
3ab6e444c7f8f11a55023c3ff890a890
28.32
93
0.614939
4.027473
false
false
false
false
frigg/frigg-hq
frigg/projects/views.py
1
1336
from django.http import Http404, HttpResponse from django.shortcuts import get_object_or_404, redirect, render from django.views.decorators.cache import never_cache from django.views.decorators.csrf import csrf_exempt from .models import Project @never_cache @csrf_exempt def build_badge(request, owner, name, branch=...
mit
89f5782cc6177b42b5d8e8bad8135274
32.4
88
0.710329
3.731844
false
false
false
false
csparpa/pyowm
tests/unit/utils/test_measurables.py
1
4964
#!/usr/bin/env python # -*- coding: utf-8 -*- import unittest from pyowm.utils import measurables class TestMeasurablesUtils(unittest.TestCase): def test_kelvin_dict_to(self): kelvin_dict = {'a': 301.0, 'b': 280} celsius_dict = {'a': 27.85, 'b': 6.85} fahrenheit_dict = {'a': 82.13, 'b': ...
mit
d54c6febe3a39b3fe9960d21f394ccfb
31.24026
86
0.494762
3.349528
false
true
false
false
csparpa/pyowm
pyowm/utils/geo.py
1
13168
#!/usr/bin/env python # -*- coding: utf-8 -*- import geojson import json import math EARTH_RADIUS_KM = 6378.1 # utilities def assert_is_lat(val): """ Checks it the given value is a feasible decimal latitude :param val: value to be checked :type val: int of float :returns: `None` :raises:...
mit
d77db0c88fde53af9af5387174a918d3
34.302949
132
0.620216
3.795907
false
false
false
false
csparpa/pyowm
pyowm/commons/http_client.py
1
14255
#!/usr/bin/env python # -*- coding: utf-8 -*- import json import requests from requests.adapters import HTTPAdapter from requests.packages.urllib3.util.retry import Retry from pyowm.commons import exceptions from pyowm.commons.enums import ImageTypeEnum class HttpRequestBuilder: URL_TEMPLATE_WITH_SUBDOMAINS = ...
mit
76d06f7bdb74fd1b8b11bbc2eff93928
43.546875
129
0.607226
4.252685
false
true
false
false
peterhinch/micropython-async
v3/as_drivers/nec_ir/art.py
1
1557
# art.py Test program for IR remote control decoder aremote.py # Supports Pyboard and ESP8266 # Author: Peter Hinch # Copyright Peter Hinch 2017 Released under the MIT license # Run this to characterise a remote. # import as_drivers.nec_ir.art from sys import platform import uasyncio as asyncio ESP32 = platform == '...
mit
2c5578040be00bcd3014f3f5f1f5ed71
27.833333
81
0.637765
3.414474
false
true
false
false
luispedro/jug
jug/subcommands/check.py
1
2974
#!/usr/bin/python # -*- coding: utf-8 -*- # Copyright (C) 2008-2019, Luis Pedro Coelho <luis@luispedro.org> # vim: set ts=4 sts=4 sw=4 expandtab smartindent: # # Permission is hereby granted, free of charge, to any person obtaining a copy # of this software and associated documentation files (the "Software"), to deal ...
mit
ded2ceee4974a6bbe7d572e1d9d6700f
28.445545
80
0.646604
4.002692
false
false
false
false
peterhinch/micropython-async
v2/sock_nonblock.py
1
4430
# sock_nonblock.py Illustration of the type of code required to use nonblocking # sockets. It is not a working demo and probably has silly errors. # It is intended as an outline of requirements and also to illustrate some of the # nasty hacks required on current builds of ESP32 firmware. Platform detection is # done at...
mit
2962d408ed996e038c9e0b8d31f5e9bd
39.272727
86
0.61693
3.728956
false
false
false
false
peterhinch/micropython-async
v3/as_drivers/as_GPS/as_GPS_utils.py
1
1725
# as_GPS_utils.py Extra functionality for as_GPS.py # Put in separate file to minimise size of as_GPS.py for resource constrained # systems. # Copyright (c) 2018 Peter Hinch # Released under the MIT License (MIT) - see LICENSE file from .as_GPS import MDY, DMY, LONG _DIRECTIONS = ('N', 'NNE', 'NE', 'ENE', 'E', 'ESE',...
mit
ce03208096f0d55b72ec5a9e6dac6c15
34.916667
77
0.580046
3.25283
false
false
false
false
peterhinch/micropython-async
v2/i2c/asi2c_i.py
1
5636
# asi2c_i.py A communications link using I2C slave mode on Pyboard. # Initiator class # The MIT License (MIT) # # Copyright (c) 2018 Peter Hinch # # 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 Soft...
mit
5d8e569c6cfcc5a11d64082bfc90c1a7
38.690141
79
0.596345
3.727513
false
false
false
false
peterhinch/micropython-async
v3/as_drivers/syncom/syncom.py
2
9641
# syncom.py Synchronous communication channel between two MicroPython # platforms. 4 June 2017 # Uses uasyncio. # The MIT License (MIT) # # Copyright (c) 2017-2021 Peter Hinch # # Permission is hereby granted, free of charge, to any person obtaining a copy # of this software and associated documentation files (the "So...
mit
59bd78cad46de45a35cae32aae39de5e
39.338912
98
0.563946
4.052543
false
false
false
false
luispedro/jug
jug/backends/redis_store.py
1
6093
#-*- coding: utf-8 -*- # Copyright (C) 2009-2022, Luis Pedro Coelho <luis@luispedro.org> # vim: set ts=4 sts=4 sw=4 expandtab smartindent: # # 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 ...
mit
9aa50bac68725441ecbd4a48f649d9d4
24.282158
88
0.581815
3.977154
false
false
false
false
luispedro/jug
jug/tests/test_lock.py
1
3139
from jug.backends.file_store import file_store, file_based_lock, file_keepalive_based_lock from jug.backends.dict_store import dict_store from jug.tests.utils import tmp_file_store from .task_reset import task_reset_at_exit, task_reset from jug.backends import memoize_store from jug import Task from time import sleep ...
mit
700a9b207ec88448e8172dea2a294edf
23.912698
90
0.636827
3.434354
false
true
false
false
peterhinch/micropython-async
v2/check_async_code.py
1
7687
#! /usr/bin/python3 # -*- coding: utf-8 -*- # check_async_code.py # A simple script to identify a common error which causes silent failures under # MicroPython (issue #3241). # This is where a task is declared with async def and then called as if it were # a regular function. # Copyright Peter Hinch 2017 # Issued under...
mit
395d0e78d2354482bf3b160a499e9f49
36.315534
111
0.557565
4.115096
false
false
false
false
peterhinch/micropython-async
v2/gps/as_GPS_utils.py
1
1724
# as_GPS_utils.py Extra functionality for as_GPS.py # Put in separate file to minimise size of as_GPS.py for resource constrained # systems. # Copyright (c) 2018 Peter Hinch # Released under the MIT License (MIT) - see LICENSE file from as_GPS import MDY, DMY, LONG _DIRECTIONS = ('N', 'NNE', 'NE', 'ENE', 'E', 'ESE', ...
mit
8c54ccb79797237558c00e2386aebdaf
34.895833
77
0.580383
3.257089
false
false
false
false
dedupeio/dedupe
dedupe/blocking.py
1
7454
#!/usr/bin/python # -*- coding: utf-8 -*- from __future__ import annotations import logging import time from collections import defaultdict from typing import TYPE_CHECKING if TYPE_CHECKING: from typing import ( Any, Callable, DefaultDict, Generator, Iterable, List,...
mit
24aa74f331c319c2594832599c338ea2
33.995305
88
0.565334
4.62694
false
false
false
false
peterhinch/micropython-async
v3/as_drivers/hd44780/alcd.py
1
4911
# LCD class for Micropython and uasyncio. # Author: Peter Hinch # Copyright Peter Hinch 2017 Released under the MIT license # V1.1 24 Apr 2020 Updated for uasyncio V3 # V1.0 13 May 2017 # Assumes an LCD with standard Hitachi HD44780 controller chip wired using four data lines # Code has only been tested on two line LC...
mit
888cc125bd602810ab35e594e87df4b1
45.301887
120
0.623268
3.331976
false
false
false
false
peterhinch/micropython-async
v3/as_drivers/client_server/userver.py
1
1936
# userver.py Demo of simple uasyncio-based echo server # Released under the MIT licence # Copyright (c) Peter Hinch 2019-2020 import usocket as socket import uasyncio as asyncio import uselect as select import ujson from heartbeat import heartbeat # Optional LED flash class Server: def __init__(self, host='0.0...
mit
65a1e1938e6581b20f73432f5c5cd29d
30.737705
101
0.596074
4.110403
false
false
false
false
peterhinch/micropython-async
v2/fast_io/fast_can_test.py
1
1871
# fast_can_test.py Test of cancellation of tasks which call sleep # Copyright (c) Peter Hinch 2019 # Released under the MIT licence import uasyncio as asyncio import sys ermsg = 'This test requires the fast_io version of uasyncio V2.4 or later.' try: print('Uasyncio version', asyncio.version) if not isinstanc...
mit
b49db5913eec3c61c3fc36a801f3fed9
26.925373
75
0.663282
3.22031
false
false
false
false
dedupeio/dedupe
dedupe/variables/string.py
1
3255
from typing import Callable, Iterable, Sequence, Type from affinegap import normalizedAffineGapDistance as affineGap from highered import CRFEditDistance from simplecosine.cosine import CosineTextSimilarity from dedupe import predicates from dedupe._typing import VariableDefinition from dedupe.variables.base import F...
mit
3a4321bef459354ef925d2ba1fd52c51
29.420561
96
0.70384
3.979218
false
false
false
false
dedupeio/dedupe
benchmarks/benchmarks/canonical_matching.py
1
2796
import os import time import dedupe from benchmarks import common def get_true_dupes(data): data_1, data_2 = data all_data = data_1.copy() all_data.update(data_2) return common.get_true_dupes(all_data) def make_report(data, clustering): true_dupes = get_true_dupes(data) predicted_dupes = se...
mit
84166ee71675ba650ea7f81dcf9fafe0
28.125
84
0.590129
3.430675
false
false
false
false
dedupeio/dedupe
dedupe/canopy_index.py
1
2603
from __future__ import annotations import logging import math from typing import Iterable import numpy from BTrees.Length import Length from zope.index.text.cosineindex import CosineIndex from zope.index.text.lexicon import Lexicon from zope.index.text.setops import mass_weightedUnion from zope.index.text.textindex i...
mit
c0172e04fbd2ec3db9f48ca0415f49d0
28.579545
83
0.576642
3.630404
false
false
false
false
virtool/virtool
virtool/downloads/db.py
2
3097
""" Functions for working with the database to provide file downloads. All functions are currently related to OTUs and their child models. """ from typing import Tuple import virtool.downloads.utils import virtool.errors import virtool.otus.utils async def generate_isolate_fasta(db, otu_id: str, isolate_id: str) ->...
mit
1d793744cf86ec856b934e236b20ace9
29.362745
120
0.647078
3.437292
false
false
false
false
virtool/virtool
virtool/otus/utils.py
2
6728
from copy import deepcopy from typing import List, Optional, Tuple, Union from virtool.types import Document from virtool.utils import base_processor def evaluate_changes(data: dict, document: dict) -> Tuple[str, str, Document]: name = data.get("name") abbreviation = data.get("abbreviation") schema = dat...
mit
b86196873f3efc7497f3e1e3aaa1b05f
28.125541
88
0.65324
4.028743
false
false
false
false
virtool/virtool
virtool/tasks/runner.py
2
1274
import asyncio import logging import virtool.tasks.task from virtool.pg.utils import get_row_by_id from virtool.tasks.models import Task class TaskRunner: def __init__(self, channel, app): self._channel = channel self.app = app async def run(self): logging.info("Started task runner")...
mit
8dc3fb36d9b2305f0c7ea743338808c8
26.106383
71
0.573783
3.825826
false
false
false
false
virtool/virtool
tests/fixtures/client.py
2
6341
import json from typing import Optional import aiohttp import pytest from aiohttp.web_routedef import RouteTableDef from virtool_core.models.session import Session import virtool.app import virtool.jobs.main from virtool.api.custom_json import dumps from virtool.config.cls import Config from virtool.mongo.identifier ...
mit
4c51106e04fe68eb269f02ad4de940e1
26.331897
103
0.547075
4.117532
false
true
false
false
virtool/virtool
tests/tasks/test_api.py
2
2129
import pytest from sqlalchemy.ext.asyncio import AsyncEngine, AsyncSession from virtool.tasks.models import Task async def test_find(spawn_client, pg: AsyncEngine, snapshot, static_time): """ Test that a ``GET /tasks`` return a complete list of tasks. """ client = await spawn_client(authorize=True, ...
mit
04d8d09a62ba629dde91c7dbf909a751
25.283951
89
0.549554
4.102119
false
true
false
false
virtool/virtool
virtool/blast/transform.py
2
1496
from typing import Any from sqlalchemy import select from sqlalchemy.ext.asyncio import AsyncEngine, AsyncSession from virtool.blast.models import NuVsBlast from virtool.mongo.transforms import AbstractTransform from virtool.types import Document class AttachNuVsBLAST(AbstractTransform): """ Attach BLAST re...
mit
4a78a3a4680f28859b2c6507945892f0
30.829787
86
0.544786
4.25
false
false
false
false
virtool/virtool
virtool/references/api.py
2
17274
from typing import Union, List, Optional from aiohttp.web_exceptions import ( HTTPBadGateway, HTTPBadRequest, HTTPConflict, HTTPNoContent, ) from aiohttp_pydantic import PydanticView from aiohttp_pydantic.oas.typing import r200, r201, r202, r204, r400, r403, r404, r502 from virtool_core.models.enums im...
mit
d939004394f797d69f96545d98c16a71
28.377551
87
0.585909
4.372058
false
false
false
false
virtool/virtool
virtool/analyses/db.py
2
3799
""" Work with analyses in the database. """ from typing import Any, Dict, List, Optional from sqlalchemy import select from sqlalchemy.ext.asyncio import AsyncEngine, AsyncSession import virtool.mongo.utils import virtool.utils from virtool.analyses.models import AnalysisFile from virtool.mongo.transforms import Abs...
mit
7a2a988d15600ee106c0a1b8ab9d51f9
26.729927
86
0.623322
3.957292
false
false
false
false
virtool/virtool
virtool/account/oas.py
2
9266
from typing import Union, Optional from pydantic import BaseModel, constr, Field, root_validator, validator from virtool_core.models.enums import QuickAnalyzeWorkflow from virtool_core.models.account import Account, AccountSettings, check_email, APIKey from virtool_core.models.validators import prevent_none from virto...
mit
41d4f360bd57286effa0d7f301fc1a39
29.175896
97
0.492444
4.508029
false
false
false
false
virtool/virtool
virtool/blast/utils.py
2
5098
import io import json import re from logging import getLogger from typing import Tuple from zipfile import ZipFile import aiohttp import virtool.errors logger = getLogger("blast") #: The URL to send BLAST requests to. BLAST_URL = "https://blast.ncbi.nlm.nih.gov/Blast.cgi" def extract_blast_info(html: str) -> Tup...
mit
f952a8e45a864435eb7514a485096daf
25.010204
84
0.60102
3.520718
false
false
false
false
virtool/virtool
tests/indexes/test_checks.py
2
1141
import pytest from virtool.data.errors import ResourceConflictError from virtool.indexes.checks import check_fasta_file_uploaded, check_index_files_uploaded from virtool.indexes.db import FILES @pytest.mark.parametrize("error", [None, 409]) async def test_check_fasta_file_uploaded(error): results = {"file1": "g...
mit
b766206305db7cfd7708a5362746264a
30.694444
88
0.68624
3.633758
false
true
false
false
danielyule/hearthbreaker
hearthbreaker/cards/spells/warrior.py
3
9859
import copy from hearthbreaker.cards.base import SpellCard from hearthbreaker.tags.action import Damage, Draw, RemoveFromHand from hearthbreaker.tags.base import AuraUntil, Buff, Effect, ActionTag from hearthbreaker.tags.card_source import Same from hearthbreaker.tags.condition import GreaterThan, IsDamaged from hearth...
mit
5643d795590136d2abc53142aed49b4f
34.981752
112
0.621564
3.529896
false
false
false
false
danielyule/hearthbreaker
tests/power_tests.py
7
7968
import random import unittest from hearthbreaker.agents.basic_agents import PredictableAgent, DoNothingAgent from hearthbreaker.cards.minions.hunter import SteamwheedleSniper from hearthbreaker.cards.minions.neutral import StonetuskBoar from hearthbreaker.cards.minions.priest import ProphetVelen from hearthbreaker.car...
mit
65c2dabd596ce8518c29a1eaa295a218
37.679612
113
0.664659
3.345088
false
true
false
false
danielyule/hearthbreaker
hearthbreaker/cards/minions/rogue.py
3
7301
from hearthbreaker.cards.base import MinionCard from hearthbreaker.cards.minions.neutral import Nerubian from hearthbreaker.cards.spells.neutral import GallywixsCoin from hearthbreaker.game_objects import Minion from hearthbreaker.tags.action import Kill, Bounce, Summon, Give, Damage, ChangeTarget, AddCard, IncreaseWea...
mit
68a09936317f4b050e15c801968852de
44.347826
120
0.592796
3.670689
false
false
false
false
astanin/python-tabulate
test/test_output.py
1
106667
"""Test output of the various forms of tabular data.""" import tabulate as tabulate_module from common import assert_equal, raises, skip from tabulate import tabulate, simple_separated_format, SEPARATING_LINE # _test_table shows # - coercion of a string to a number, # - left alignment of text, # - decimal point al...
mit
cd3b766ef9b4388a312efecb1c504f10
30.815462
121
0.420925
3.044811
false
true
false
false
chicagopython/chipy.org
chipy_org/apps/meetings/utils.py
1
3730
from __future__ import unicode_literals import logging import requests from django.core.exceptions import ObjectDoesNotExist, ValidationError from .models import RSVP, Meeting logger = logging.getLogger(__name__) def get_rsvp(meeting, meetup_member): """ Handles getting the rsvp instance to update from Me...
mit
a776dfba7ce02952b22516df9ad96b46
32.909091
96
0.613673
3.583093
false
false
false
false
chicagopython/chipy.org
chipy_org/libs/middleware.py
1
1030
# -*- coding: utf-8 -*- import traceback from django.contrib import messages from django.shortcuts import redirect from social_core.exceptions import SocialAuthBaseException from social_django.middleware import SocialAuthExceptionMiddleware class ChipySocialAuthExceptionMiddleware(SocialAuthExceptionMiddleware): ...
mit
57f0333ff8fc229db18ea01c9c6a816f
32.225806
81
0.679612
4.618834
false
false
false
false
chicagopython/chipy.org
chipy_org/apps/job_board/forms.py
1
1619
from django import forms from django.contrib.auth.models import User from django.forms import Textarea from .models import JobPost class JobPostForm(forms.ModelForm): def __init__(self, *args, **kwargs): super().__init__(*args, **kwargs) self.fields["agree_to_terms"].required = True class Me...
mit
7cf8f6692941a7b1e037d494931058e4
24.698413
91
0.46819
4.352151
false
false
false
false
moble/quaternion
src/quaternion/__init__.py
1
33974
# -*- coding: utf-8 -*- # Copyright (c) 2021, Michael Boyle # See LICENSE file for details: <https://github.com/moble/quaternion/blob/main/LICENSE> __version__ = "2022.4.2" __doc_title__ = "Quaternion dtype for NumPy" __doc__ = "Adds a quaternion dtype to NumPy." __all__ = ['quaternion', 'as_quat_array', '...
mit
614504dc9bd1dd339027983ba41d1266
37.694761
124
0.595308
3.484513
false
false
false
false
pythondigest/pythondigest
digest/migrations/0011_auto_20150730_0556.py
1
1234
# -*- coding: utf-8 -*- from __future__ import unicode_literals from django.db import migrations, models class Migration(migrations.Migration): dependencies = [('digest', '0010_auto_20150730_0553'), ] operations = [ migrations.AlterField( model_name='parsingrules', name='then...
mit
963ecbb7715f9ee335d95ff1e601e26e
36.393939
123
0.535656
3.505682
false
false
false
false
open2c/cooltools
cooltools/sandbox/pairs_scaling_functions.py
1
1921
################################### # # several functions for calculating scalings using pairs # they used to reside in cooltools.expected module # #################################### import numpy as np from ..lib import numutils def _contact_areas(distbins, scaffold_length): distbins = distbins.astype(float) ...
mit
2721ff477e3679f85d288066045fafa7
29.492063
88
0.57418
3.295026
false
false
false
false
open2c/cooltools
cooltools/lib/plotting.py
1
3091
""" Migrated from :mod:`mirnylib.plotting`. """ from matplotlib.cm import register_cmap import matplotlib as mpl import matplotlib.pyplot as plt import numpy as np PALETTES = { "fall": np.array( ( (255, 255, 255), (255, 255, 204), (255, 237, 160), (254, 217...
mit
ad9b4d5eb9db04e7e3097f9c23f02361
22.067164
78
0.459722
3.216441
false
false
false
false
thouska/spotpy
src/spotpy/database/sql.py
1
2744
import sqlite3 import sys import numpy as np from .base import database class PickalableSWIG: def __setstate__(self, state): self.__init__(*state["args"]) def __getstate__(self): return {"args": self.args} class PickalableSQL3Connect(sqlite3.Connection, PickalableSWIG): def __init__(s...
mit
1e7c66a77d323c15c3b9e126d56b475c
26.717172
97
0.525875
3.875706
false
false
false
false
thouska/spotpy
src/spotpy/algorithms/abc.py
1
8953
# -*- coding: utf-8 -*- """ Copyright (c) 2018 by Tobias Houska This file is part of Statistical Parameter Optimization Tool for Python(SPOTPY). :author: Patrick Lauer """ import random import numpy as np from . import _algorithm class abc(_algorithm): """ This class holds the Artificial Bee Colony (ABC) a...
mit
d3609282f1b9edd13bb6a2fd2d06ac83
39.328829
264
0.497822
4.185601
false
false
false
false
znick/anytask
anytask/common/ordered_dict.py
2
8806
# Backport of OrderedDict() class that runs on Python 2.4, 2.5, 2.6, 2.7 and pypy. # Passes Python2.7's test suite and incorporates all the latest updates. try: from thread import get_ident as _get_ident except ImportError: from dummy_thread import get_ident as _get_ident try: from _abcoll import KeysView...
mit
b76ba8c47937a84fbc73f7204a7d1977
33
87
0.546446
3.982813
false
false
false
false
znick/anytask
anytask/users/migrations/0003_auto_20210228_1721.py
1
2111
# -*- coding: utf-8 -*- # Generated by Django 1.11.29 on 2021-02-28 14:21 from __future__ import unicode_literals from django.db import migrations, models class Migration(migrations.Migration): dependencies = [ ('users', '0002_auto_20200416_1732'), ] operations = [ migrations.AlterField...
mit
1ffb13c0d599709eed2d4607191b6865
37.381818
123
0.604453
4.407098
false
false
false
false
znick/anytask
anytask/mail/views.py
1
10115
# -*- coding: utf-8 -*- import json from django.conf import settings from django.contrib.auth.decorators import login_required from django.http import HttpResponseForbidden, HttpResponse from django.shortcuts import render from django.utils import timezone from django.utils.translation import ugettext as _ from djang...
mit
9d8be5f1a2b6f0aa5a2a63355bc32719
33.288136
117
0.606228
3.735229
false
false
false
false
znick/anytask
anytask/invites/migrations/0001_initial.py
1
1308
# -*- coding: utf-8 -*- from __future__ import unicode_literals from django.db import models, migrations import django.utils.timezone from django.conf import settings class Migration(migrations.Migration): dependencies = [ migrations.swappable_dependency(settings.AUTH_USER_MODEL), ('groups', '00...
mit
d505e3cf4c5e08f1013083214473dd8c
39.875
134
0.611621
4.074766
false
false
false
false
znick/anytask
dependencies/django-registration/registration/backends/default/__init__.py
1
5257
from django.conf import settings from django.contrib.sites.shortcuts import get_current_site from registration import signals from registration.forms import RegistrationForm from registration.models import RegistrationProfile class DefaultBackend(object): """ A registration backend which follows a simple wor...
mit
33f4d7abccf8f78641ac469072219f65
37.654412
92
0.642382
5.225646
false
false
false
false
python-attrs/attrs
src/attr/__init__.py
2
1952
# SPDX-License-Identifier: MIT import sys import warnings from functools import partial from . import converters, exceptions, filters, setters, validators from ._cmp import cmp_using from ._config import get_run_validators, set_run_validators from ._funcs import asdict, assoc, astuple, evolve, has, resolve_types fro...
mit
09be19a54fa7f6c319eab80948fffd2e
19.989247
79
0.607582
3.297297
false
false
false
false
znick/anytask
anytask/admission/views.py
1
7238
# -*- coding: utf-8 -*- from django.utils.translation import ugettext as _ from django.views.decorators.cache import never_cache from django.views.decorators.csrf import csrf_exempt from django.views.decorators.http import require_POST, require_GET from django.http import HttpResponse, HttpResponseForbidden, HttpRespo...
mit
4b01fe9a249818449e974f1d1eb0d870
33.757282
113
0.629609
3.549826
false
true
false
false
grokzen/pykwalify
pykwalify/errors.py
2
6209
# -*- coding: utf-8 -*- """ pyKwalify - errors.py """ # python stdlib from pykwalify.compat import basestring retcodes = { # PyKwalifyExit 0: 'noerror', # UnknownError 1: 'unknownerror', # SchemaError # e.g. when a rule or the core finds an error 2: 'schemaerror', # CoreError #...
mit
1f0804968e105c8aa62ac5a1c28ff334
25.198312
93
0.523112
4.05817
false
false
false
false
django-admin-tools/django-admin-tools
admin_tools/menu/views.py
1
3319
from django.contrib.admin.views.decorators import staff_member_required from django.http import HttpResponse, HttpResponseRedirect from django.shortcuts import get_object_or_404, render from django.contrib import messages try: from django.views.decorators.csrf import csrf_exempt except ImportError: from django...
mit
b1af1cc48f0efac7d7c5160fea5111e6
32.525253
79
0.610124
4.24968
false
false
false
false
django-admin-tools/django-admin-tools
admin_tools/menu/menus.py
1
3921
""" Module where admin tools menu classes are defined. """ try: # we use django.urls import as version detection as it will fail on django 1.11 and thus we are safe to use # gettext_lazy instead of ugettext_lazy instead from django.urls import reverse from django.utils.translation import gettext_lazy a...
mit
d6ea70fa39f33d0e03c64cf7274bd632
33.095652
111
0.590666
4.667857
false
false
false
false
django-admin-tools/django-admin-tools
admin_tools/dashboard/views.py
1
1564
from django.contrib.admin.views.decorators import staff_member_required from django.http import HttpResponse from django.shortcuts import render from django.contrib import messages try: from django.views.decorators.csrf import csrf_exempt except ImportError: from django.contrib.csrf.middleware import csrf_exem...
mit
855751e6af77f3906931ef86d0a24a1a
30.28
78
0.662404
4.430595
false
false
false
false
django-admin-tools/django-admin-tools
admin_tools/dashboard/migrations/0001_initial.py
1
1079
# -*- coding: utf-8 -*- from __future__ import unicode_literals from django.db import models, migrations from django.conf import settings class Migration(migrations.Migration): dependencies = [ migrations.swappable_dependency(settings.AUTH_USER_MODEL), ] operations = [ migrations.Create...
mit
075f95a4bc5995b7dc6f7de06e6cba05
31.69697
114
0.565338
4.630901
false
false
false
false
django-admin-tools/django-admin-tools
admin_tools/dashboard/management/commands/customdashboard.py
1
1043
import os from django.core.management.base import BaseCommand, CommandError from django.template.loader import render_to_string DEFAULT_FILE = "dashboard.py" class Command(BaseCommand): help = ( "Creates a template file containing the base code to get you " "started with your custom dashboard." ...
mit
e60a9811039dfb28504d494fe51d9f97
32.645161
70
0.619367
3.891791
false
false
false
false
grokzen/pykwalify
pykwalify/cli.py
1
3248
# -*- coding: utf-8 -*- """ pyKwalify - cli.py """ # python std lib import logging import logging.config import sys # 3rd party imports from docopt import docopt def parse_cli(): """ The outline of this function needs to be like this: 1. parse arguments 2. validate arguments only, dont go into oth...
mit
deb0b70e193dec53a2bb89ce6ed3339b
32.142857
123
0.595135
4.251309
false
false
false
false
kytos/python-openflow
tests/unit/v0x01/test_controller2switch/test_packet_out.py
1
2854
"""Packet out message tests.""" from pyof.foundation.exceptions import ValidationError from pyof.v0x01.common.action import ActionOutput from pyof.v0x01.common.phy_port import Port from pyof.v0x01.controller2switch.packet_out import PacketOut from tests.unit.test_struct import TestStruct class TestPacketOut(TestStruc...
mit
9dd9e730b373622ada28d9f43c94b2ad
38.638889
79
0.627891
3.488998
false
true
false
false
kytos/python-openflow
pyof/v0x01/controller2switch/common.py
1
16355
"""Defines common structures and enums for controller2switch.""" # System imports from enum import IntEnum from pyof.foundation.base import GenericMessage, GenericStruct from pyof.foundation.basic_types import ( BinaryData, Char, Pad, UBInt8, UBInt16, UBInt32, UBInt64) from pyof.foundation.constants import ( ...
mit
006d8ce662e5e13cf631448da2e27485
33.723992
79
0.603057
3.781503
false
false
false
false
kytos/python-openflow
pyof/foundation/basic_types.py
1
26514
"""Basic types used in structures and messages.""" # System imports import struct from copy import deepcopy # Local source tree imports from pyof.foundation import exceptions from pyof.foundation.base import GenericStruct, GenericType, UBIntBase __all__ = ('BinaryData', 'Char', 'ConstantTypeList', 'FixedTypeList', ...
mit
fe96064fc63e2e05a1cf05858e2c65aa
29.095346
79
0.548503
4.399204
false
false
false
false
wradlib/wradlib
wradlib/__init__.py
3
1147
#!/usr/bin/env python # Copyright (c) 2011-2020, wradlib developers. # Distributed under the MIT License. See LICENSE.txt for more info. """ wradlib ======= """ # Make sure that deprecation warnings get printed by default import warnings as _warnings _warnings.filterwarnings("always", category=DeprecationWarning, mo...
mit
28babfb38ac155906403d4863df33f47
25.674419
81
0.699215
3.584375
false
false
false
false
wradlib/wradlib
wradlib/trafo.py
3
10505
#!/usr/bin/env python # -*- coding: UTF-8 -*- # Copyright (c) 2011-2020, wradlib developers. # Distributed under the MIT License. See LICENSE.txt for more info. """ Data Transformation ^^^^^^^^^^^^^^^^^^^ Module <trafo> transforms data e.g. from RVP-units to dBZ-values to Z-values and vice versa. .. currentmodule:: ...
mit
e36f9038bb78e666af079eff6da4b9f2
20.786307
79
0.459004
3.241049
false
false
false
false
prkumar/uplink
uplink/converters/__init__.py
1
5621
# Local imports from uplink._extras import installer, plugin from uplink.compat import abc from uplink.converters import keys from uplink.converters.interfaces import Factory, ConverterFactory, Converter from uplink.converters.register import ( get_default_converter_factories, register_default_converter_factory...
mit
10b8c0186d2376c6adb28bc3782b4902
32.064706
77
0.682085
4.377726
false
false
false
false
theonion/betty-cropper
betty/cropper/dssim.py
1
5775
try: import numpy as np import scipy.ndimage except ImportError: pass from betty.conf.app import settings import io import math from PIL import Image MIN_UNIQUE_COLORS = 4096 COLOR_DENSITY_RATIO = 0.11 QUALITY_IN_MIN = 82 ERROR_THRESHOLD = 1.3 ERROR_THRESHOLD_INACCURACY = 0.01 def compute_ssim(im1,...
mit
4e4d1e9568ee843732c1994a0464204a
27.448276
95
0.592727
3.224456
false
false
false
false
prkumar/uplink
uplink/converters/marshmallow_.py
1
3461
""" This module defines a converter that uses :py:mod:`marshmallow` schemas to deserialize and serialize values. """ # Local imports from uplink import utils from uplink.converters import interfaces, register_default_converter_factory class MarshmallowConverter(interfaces.Factory): """ A converter that seria...
mit
67b2c5f5cb43ca27e9ef0377f68c52b7
32.278846
78
0.636232
4.251843
false
false
false
false
prkumar/uplink
examples/async-requests/asyncio_example.py
1
1165
""" Example of using Uplink with aiohttp for non-blocking HTTP requests. This should work on Python 3.7 and above. """ import asyncio import uplink # Local imports from github import BASE_URL, GitHub async def get_contributors(full_name): print("Getting GitHub repository `{}`".format(full_name)) response = a...
mit
7cd28f82c5efa193fb617495b7bc96bc
31.361111
71
0.695279
3.844884
false
false
false
false
prkumar/uplink
docs/source/conf.py
1
6483
# -*- coding: utf-8 -*- # # Uplink documentation build configuration file, created by # sphinx-quickstart on Sun Sep 24 19:40:30 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. # # Al...
mit
83d61c26d7cfc681b60f30ddd06f3a1c
30.779412
81
0.660342
3.795667
false
true
false
false
prkumar/uplink
uplink/utils.py
1
2899
# Standard library imports import collections import inspect try: # Python 3.2+ from inspect import signature except ImportError: # pragma: no cover # Python 2.7 from inspect import getcallargs as get_call_args, getargspec as _getargspec def signature(_): raise ImportError def get_ar...
mit
38988879600fae9075ecb8bb7ab953a0
26.349057
79
0.602967
4.232117
false
false
false
false
prkumar/uplink
tests/unit/test_arguments.py
1
17177
import pytest # Local imports from uplink import hooks, arguments from uplink.converters import keys inject_args = pytest.mark.parametrize("args", (["arg1", "arg2", "arg3"],)) @pytest.fixture def argument_mock(mocker): return mocker.Mock(spec=arguments.ArgumentAnnotation) @pytest.fixture def named_argument_m...
mit
d0b4f6a52abb1061cb8c04b80aa6a047
36.422658
80
0.680794
4.116223
false
true
false
false
theonion/betty-cropper
betty/cropper/tasks.py
1
2450
from __future__ import absolute_import import io from celery import shared_task from PIL import Image as PILImage from betty.conf.app import settings from .dssim import detect_optimal_quality try: # Legacy check: Try import here to determine if we should enable IMGMIN import numpy # NOQA import scipy ...
mit
ea4b6400425bc259bc3385527c862f10
28.518072
91
0.645714
4.036244
false
false
false
false
stevearc/pypicloud
pypicloud/util.py
1
10262
""" Utilities """ import logging import os import re import time import unicodedata from typing import ( IO, Any, AnyStr, Callable, Dict, ItemsView, Iterator, KeysView, List, Optional, Tuple, Union, ) from distlib.locators import Locator from distlib.util import split_fi...
mit
ab26508a8cc17b29ff4377dcbae8e72b
28.404011
88
0.554668
4.101519
false
false
false
false
stevearc/pypicloud
pypicloud/storage/files.py
1
4250
""" Store packages as files on disk """ import json import os from binascii import hexlify from pyramid.response import FileResponse from pypicloud.dateutil import utcfromtimestamp from pypicloud.models import Package from pypicloud.util import stream_file from .base import IStorage class FileStorage(IStorage): ...
mit
2b2d175bff52036669312905c8bf3e89
34.123967
81
0.584941
4.233068
false
false
false
false
stevearc/pypicloud
pypicloud/storage/object_store.py
1
3871
""" Store packages in S3 """ import logging from binascii import hexlify from hashlib import md5 from pyramid.httpexceptions import HTTPFound from pyramid.settings import asbool from smart_open import open as _open from pypicloud.models import Package from .base import IStorage LOG = logging.getLogger(__name__) c...
mit
6c9131375dd7fb144d965f5dfd96c4e1
32.95614
88
0.632653
4.230601
false
true
false
false
stevearc/pypicloud
pypicloud/storage/gcs.py
1
8067
""" Store packages in GCS """ import json import logging import os import posixpath from datetime import timedelta from google.auth import compute_engine from google.auth.transport import requests from google.cloud import storage from pyramid.settings import asbool from smart_open import open as _open from pypicloud....
mit
c4c9464262e8f12496e133d6a47c59e3
33.32766
95
0.59167
4.41302
false
false
false
false
stevearc/pypicloud
pypicloud/access/ldap_.py
1
12920
"""LDAP authentication plugin for pypicloud.""" import logging from collections import namedtuple from functools import wraps from pyramid.settings import asbool, aslist from pypicloud.util import TimedCache from .base import IAccessBackend from .config import ConfigAccessBackend try: import ldap except ImportE...
mit
5242187a11eac0ee5c94148d613e3075
34.108696
87
0.564628
4.21396
false
false
false
false
stevearc/pypicloud
pypicloud/scripts.py
1
9897
""" Commandline scripts """ import argparse import getpass import gzip import json import logging import os import sys from base64 import b64encode import transaction from jinja2 import Template from pkg_resources import resource_string # pylint: disable=E0611 from pyramid.paster import bootstrap from pypicloud.acce...
mit
145319f2742699491a9889eea30a2d34
28.990909
88
0.606547
3.881176
false
true
false
false
poliastro/poliastro
contrib/satgpio.py
1
2511
""" Author: Juan Luis Cano Rodríguez Code to read GP data from Celestrak using the HTTP API and python-sgp4. Requires some extra dependencies: $ pip install httpx sgp4 """ import io import json import xml.etree.ElementTree as ET import httpx from sgp4 import exporter, omm from sgp4.api import Satrec def _gene...
mit
5ce6ee1c9206851d05cad2a4bfbb7e55
24.1
86
0.63506
3.51049
false
false
false
false
poliastro/poliastro
src/poliastro/spheroid_location.py
1
5009
import astropy.units as u import numpy as np from poliastro.core.spheroid_location import ( N as N_fast, cartesian_cords as cartesian_cords_fast, cartesian_to_ellipsoidal as cartesian_to_ellipsoidal_fast, distance as distance_fast, f as f_fast, is_visible as is_visible_fast, radius_of_curva...
mit
2208906843eb464159d77f133697c578
30.503145
125
0.54442
3.534933
false
false
false
false
poliastro/poliastro
src/poliastro/twobody/thrust/change_ecc_quasioptimal.py
1
1419
"""Quasi optimal eccentricity-only change, with formulas developed by Pollard. References ---------- * Pollard, J. E. "Simplified Approach for Assessment of Low-Thrust Elliptical Orbit Transfers", 1997. """ import numpy as np from astropy import units as u from numba import njit from numpy import cross from polias...
mit
871fc55218a9d8b42f2ff0c321a8821e
27.38
78
0.644116
2.809901
false
false
false
false