repo_name stringlengths 7 65 | path stringlengths 5 186 | copies stringlengths 1 4 | size stringlengths 4 6 | content stringlengths 941 973k | license stringclasses 14
values | hash stringlengths 32 32 | line_mean float64 5 100 | line_max int64 26 999 | alpha_frac float64 0.25 0.93 | ratio float64 1.5 7.35 | autogenerated bool 1
class | config_or_test bool 2
classes | has_no_keywords bool 2
classes | has_few_assignments bool 1
class |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
codeeu/coding-events | mailer/event_report_mailer.py | 1 | 1996 | #!/usr/bin/python
# -*- coding: utf-8 -*-
from django.core.mail import send_mail
from django.template import loader, Context
from django.conf import settings
from web.processors.user import get_ambassadors_for_country
'''
Generates and sends event report to ambassadors users
'''
def send_event_report_email(user, ev... | mit | 814a9cc065af0bab525c66da7724374a | 32.266667 | 90 | 0.616232 | 3.723881 | false | false | false | false |
skoczen/will | will/backends/execution/best_score.py | 5 | 1926 | import imp
import logging
import traceback
import requests
import warnings
from will import settings
from will.decorators import require_settings
from will.utils import Bunch
from .base import ExecutionBackend
class BestScoreBackend(ExecutionBackend):
def _publish_fingerprint(self, option, message):
if ... | mit | 2a4a19a0a05ed63a72816d3e7cf9ae2d | 34.018182 | 112 | 0.515057 | 4.875949 | false | false | false | false |
skoczen/will | will/mixins/storage.py | 5 | 2730 | import importlib
import logging
import dill as pickle
from will import settings
from will.abstractions import Person, Event, Channel, Message
class StorageMixin(object):
def bootstrap_storage(self):
if not hasattr(self, "storage"):
if hasattr(self, "bot") and hasattr(self.bot, "storage"):
... | mit | 9e28d9b17159bbfae547074b60ac1965 | 31.5 | 83 | 0.556044 | 4.468085 | false | false | false | false |
skoczen/will | will/main.py | 1 | 51006 | # -*- coding: utf-8 -*-
import copy
import datetime
import imp
from importlib import import_module
import inspect
import logging
from multiprocessing import Process, Queue
import operator
import os
from os.path import abspath, dirname
import re
import signal
import sys
import threading
import time
import traceback
try... | mit | a1fc584f572ed3b509e89c18691f9224 | 45.396724 | 149 | 0.451794 | 5.080203 | false | false | false | false |
agdsn/sipa | sipa/utils/__init__.py | 1 | 8242 | """
General utilities
"""
import dataclasses
import http.client
import json
import logging
import time
import typing
from datetime import date, datetime, timedelta
from functools import wraps
from itertools import chain
from operator import itemgetter
from zoneinfo import ZoneInfo
import icalendar
import markdown
imp... | mit | b13d726b0ca92ffdf3a4c3031a1b22f0 | 28.120141 | 96 | 0.638757 | 3.811748 | false | false | false | false |
agdsn/sipa | sipa/utils/graph_utils.py | 1 | 3212 | import pygal
from flask_babel import gettext
from pygal import Graph
from pygal.colors import hsl_to_rgb
from pygal.style import Style
from sipa.units import (format_as_traffic, max_divisions,
reduce_by_base)
from sipa.utils.babel_utils import get_weekday
def rgb_string(r, g, b):
return f... | mit | 4384ff3f2120f078b413350f3eeba431 | 32.810526 | 88 | 0.606476 | 3.814727 | false | false | false | false |
agdsn/sipa | sipa/units.py | 1 | 3619 | from functools import wraps
from math import log, floor
#: 0 divisions mean the unit stays being `KiB`.
#: **Usage**: unit = UNIT_LIST[divisions]
UNIT_LIST = ["KiB", "MiB", "GiB"]
#: The format string for traffic values. Rounds to two digits and
#: appends the unit.
TRAFFIC_FORMAT_STRING = "{0:.2f} {1}"
#: The forma... | mit | cd2596285c7a9ff6e2dfca9b30aa2c98 | 29.567797 | 82 | 0.64957 | 3.636089 | false | false | false | false |
agdsn/sipa | tests/model/test_model.py | 2 | 5114 | import re
from base64 import urlsafe_b64encode
from os import urandom
from typing import cast
from unittest import TestCase
from unittest.mock import MagicMock
from ipaddress import IPv4Network
from flask import Flask
from sipa.backends import Backends, DataSource, Dormitory, InitContextCallable
class TestBackendIn... | mit | e3c82619efed8becb32595edb11380e0 | 32.854305 | 78 | 0.611894 | 3.858113 | false | true | false | false |
indico/indico-plugins | ursh/indico_ursh/util.py | 1 | 2272 | # This file is part of the Indico plugins.
# Copyright (C) 2002 - 2022 CERN
#
# The Indico plugins are free software; you can redistribute
# them and/or modify them under the terms of the MIT License;
# see the LICENSE file for more details.
import json
import posixpath
import requests
from werkzeug.exceptions import... | mit | 493ce1435bf80587ebb45d7987e98cfe | 32.910448 | 111 | 0.685739 | 3.463415 | false | false | false | false |
indico/indico-plugins | citadel/indico_citadel/models/id_map.py | 1 | 5827 | # This file is part of the Indico plugins.
# Copyright (C) 2002 - 2022 CERN
#
# The Indico plugins are free software; you can redistribute
# them and/or modify them under the terms of the MIT License;
# see the LICENSE file for more details.
from indico.core.db import db
from indico.core.db.sqlalchemy import PyIntEnum... | mit | 13d432284d5d14f292a227a74f16ef9a | 27.286408 | 108 | 0.595847 | 3.687975 | false | false | false | false |
indico/indico-plugins | storage_s3/indico_storage_s3/storage.py | 1 | 11357 | # This file is part of the Indico plugins.
# Copyright (C) 2002 - 2022 CERN
#
# The Indico plugins are free software; you can redistribute
# them and/or modify them under the terms of the MIT License;
# see the LICENSE file for more details.
import hashlib
import hmac
import threading
from base64 import b64encode
from... | mit | 2e0da39375f98766051fbe751560cf7a | 39.41637 | 120 | 0.617505 | 4.001762 | false | false | false | false |
indico/indico-plugins | storage_s3/indico_storage_s3/plugin.py | 1 | 4568 | # This file is part of the Indico plugins.
# Copyright (C) 2002 - 2022 CERN
#
# The Indico plugins are free software; you can redistribute
# them and/or modify them under the terms of the MIT License;
# see the LICENSE file for more details.
import sys
import click
from markupsafe import Markup
from wtforms.fields im... | mit | 1ff4d3b8be0c1a65ebfcb4f8b4dcb96e | 39.424779 | 119 | 0.614054 | 4.405014 | false | false | false | false |
indico/indico-plugins | livesync/indico_livesync/cli.py | 1 | 10196 | # This file is part of the Indico plugins.
# Copyright (C) 2002 - 2022 CERN
#
# The Indico plugins are free software; you can redistribute
# them and/or modify them under the terms of the MIT License;
# see the LICENSE file for more details.
import os
import sys
import time
import traceback
import click
from flask_pl... | mit | eaa6374d05620ef512ca18850a5e4555 | 40.112903 | 120 | 0.640938 | 3.788926 | false | false | false | false |
indico/indico-plugins | citadel/indico_citadel/result_schemas.py | 1 | 3366 | # This file is part of the Indico plugins.
# Copyright (C) 2002 - 2022 CERN
#
# The Indico plugins are free software; you can redistribute
# them and/or modify them under the terms of the MIT License;
# see the LICENSE file for more details.
import math
from marshmallow import fields, pre_load
from indico.modules.se... | mit | adbfcb90aab449a34d6d4554f550ee78 | 33.346939 | 109 | 0.628342 | 4.065217 | false | false | false | false |
indico/indico-plugins | vc_zoom/indico_vc_zoom/forms.py | 1 | 6046 | # This file is part of the Indico plugins.
# Copyright (C) 2020 - 2022 CERN and ENEA
#
# The Indico plugins are free software; you can redistribute
# them and/or modify them under the terms of the MIT License;
# see the LICENSE file for more details.
from flask import session
from flask_pluginengine import current_plu... | mit | 01719678d887e1c884da5747c2590134 | 45.868217 | 114 | 0.554582 | 4.899514 | false | false | false | false |
indico/indico-plugins | livesync/indico_livesync/migrations/20201023_1224_6ef9616e57cb_add_note_id_and_update_constraints.py | 1 | 5227 | """Add note_id and update constraints
Revision ID: 6ef9616e57cb
Revises: aa0dbc6c14aa
Create Date: 2020-10-23 12:24:51.648130
"""
import sqlalchemy as sa
from alembic import op
# revision identifiers, used by Alembic.
revision = '6ef9616e57cb'
down_revision = 'aa0dbc6c14aa'
branch_labels = None
depends_on = None
... | mit | 5d8a36b4d00c62a2bb6632112a2e2997 | 86.116667 | 282 | 0.710733 | 3.329299 | false | false | false | false |
indico/indico-plugins | piwik/indico_piwik/plugin.py | 1 | 4542 | # This file is part of the Indico plugins.
# Copyright (C) 2002 - 2022 CERN
#
# The Indico plugins are free software; you can redistribute
# them and/or modify them under the terms of the MIT License;
# see the LICENSE file for more details.
from urllib.parse import urlparse
from flask import request, session
from fl... | mit | 19ee55e02e429b1dc89c73625cc3160a | 43.097087 | 114 | 0.638045 | 3.735197 | false | false | false | false |
indico/indico-plugins | livesync/indico_livesync/models/agents.py | 1 | 1764 | # This file is part of the Indico plugins.
# Copyright (C) 2002 - 2022 CERN
#
# The Indico plugins are free software; you can redistribute
# them and/or modify them under the terms of the MIT License;
# see the LICENSE file for more details.
from sqlalchemy.dialects.postgresql import JSON
from indico.core.db.sqlalche... | mit | bcabdae98b69d35a5f74ee1f6437443c | 23.5 | 78 | 0.624717 | 3.92 | false | false | false | false |
daler/gffutils | gffutils/test/test.py | 1 | 41466 | import warnings
from textwrap import dedent
from . import expected
from gffutils import example_filename, create, parser, feature
import gffutils
import gffutils.helpers as helpers
import gffutils.gffwriter as gffwriter
import gffutils.inspect as inspect
import gffutils.iterators as iterators
import sys
import os
impor... | mit | 072c5809cfc9c68cdb340dbf47086118 | 32.279294 | 187 | 0.58677 | 3.388022 | false | true | false | false |
daler/gffutils | gffutils/gffwriter.py | 1 | 5947 | ##
## GFF Writer (writer): serializing gffutils records as GFF text files.
##
import six
import tempfile
import shutil
from time import strftime, localtime
from gffutils.version import version
class GFFWriter:
"""
Simple GFF writer class for serializing gffutils
records to a file.
Parameters:
---... | mit | 19a53e0330ceb455d5c53b986ea02b19 | 33.777778 | 86 | 0.568354 | 3.977926 | false | false | false | false |
daler/gffutils | gffutils/test/attr_test_cases.py | 1 | 6202 | """
Test cases used for the nosetest generator over in parser_test.py.
Each item is a 3-tuple. The first two items are the attribute string and the
expected parsed dictionary. The third, if not None, is a reconstructed string
that is acceptable -- this is needed for cases like this:
name "fgenesh1_pg.C_chr_1000... | mit | 4e20559714ebbfd316fd45003bd66691 | 33.265193 | 85 | 0.517575 | 2.906279 | false | false | false | false |
conjure-up/conjure-up | tools/mockups/add_ons_list.py | 3 | 1409 | #!/usr/bin/env python
from ubuntui.utils import Color
from ubuntui.widgets.buttons import menu_btn
from urwid import Text
from base import MockupView
class TestView(MockupView):
title = 'Add-Ons'
subtitle = ('Would you like to deploy any additional '
'workloads to your Canonical Kubernetes d... | mit | 3fd56ba6c2778bef43719eb251558405 | 27.18 | 71 | 0.476934 | 4.634868 | false | false | false | false |
conjure-up/conjure-up | conjureup/ui/views/steps.py | 3 | 2277 | from ubuntui.widgets.hr import HR
from urwid import Columns, Pile, Text
from conjureup.app_config import app
from conjureup.consts import spell_types
from conjureup.ui.views.base import BaseView
from conjureup.ui.widgets.step import StepResult
class ShowStepsView(BaseView):
title = "Configure Spell"
subtitle... | mit | badd36a3f979801cfa9b64d462276c1a | 31.070423 | 73 | 0.570487 | 3.96 | false | false | false | false |
conjure-up/conjure-up | conjureup/ui/views/interstitial.py | 3 | 2812 | import asyncio
import random
import unicodedata
from pathlib import Path
from ubuntui.utils import Padding
from urwid import Columns, Text
from conjureup import events
from conjureup.app_config import app
from conjureup.ui.views.base import BaseView
class InterstitialView(BaseView):
body_valign = 'middle'
i... | mit | a951ba8f88ba7d545cd4bfb443aa0c50 | 32.47619 | 74 | 0.536273 | 3.938375 | false | false | false | false |
conjure-up/conjure-up | conjureup/ui/views/credentials.py | 3 | 1327 | from ubuntui.utils import Padding
from ubuntui.widgets.hr import HR
from conjureup.app_config import app
from conjureup.ui.views.base import BaseView, SchemaFormView
from conjureup.ui.widgets.selectors import MenuSelectButtonList
class NewCredentialView(SchemaFormView):
title = "New Credential Creation"
def... | mit | ad9e0a3a03252a488b97b84937d77971 | 33.025641 | 73 | 0.671439 | 3.937685 | false | false | false | false |
conjure-up/conjure-up | conjureup/controllers/juju/regions/common.py | 3 | 2029 | from conjureup import controllers, juju
from conjureup.app_config import app
from conjureup.models.provider import load_schema
class BaseRegionsController:
def __init__(self):
# can't just determine these during __init__ because the controller
# instance is cached and the BACK button means we can ... | mit | 6748505f8e0e4352849e09bea441dd63 | 40.408163 | 77 | 0.591424 | 4.488938 | false | false | false | false |
conjure-up/conjure-up | conjureup/controllers/juju/clouds/gui.py | 3 | 4414 | import asyncio
from juju.utils import run_with_interrupt
from conjureup import controllers, errors, events, juju, utils
from conjureup.app_config import app
from conjureup.consts import CUSTOM_PROVIDERS, cloud_types
from conjureup.models.provider import Localhost as LocalhostProvider
from conjureup.models.provider im... | mit | a5612be53846b4a03e5bc7a5114ef1db | 36.40678 | 78 | 0.593566 | 4.387674 | false | false | false | false |
conjure-up/conjure-up | conjureup/controllers/juju/clouds/tui.py | 3 | 1366 | from conjureup import controllers, events, juju, utils
from conjureup.app_config import app
from conjureup.consts import cloud_types
from .common import BaseCloudController
class CloudsController(BaseCloudController):
def __controller_exists(self, controller):
return juju.get_controller(controller) is no... | mit | 433d6ec60928376575cfa97bf16001f7 | 34.025641 | 73 | 0.628111 | 4.164634 | false | false | false | false |
conjure-up/conjure-up | test/controllers_juju/test_controllers_deploy_common.py | 3 | 1848 | #!/usr/bin/env python
#
# tests controllers/deploy/common.py
#
# Copyright 2016 Canonical, Ltd.
import asyncio
import unittest
from unittest.mock import MagicMock, patch
from conjureup.controllers.juju.deploy import common
from .helpers import AsyncMock, test_loop
class DeployCommonDoDeployTestCase(unittest.TestC... | mit | 146eccea6fa761bdb7ca8a48dbdc4bef | 31.421053 | 78 | 0.63961 | 3.609375 | false | true | false | false |
stripe/stripe-python | tests/api_resources/test_file_link.py | 1 | 1503 | from __future__ import absolute_import, division, print_function
import stripe
TEST_RESOURCE_ID = "link_123"
class TestFileLink(object):
def test_is_listable(self, request_mock):
resources = stripe.FileLink.list()
request_mock.assert_requested("get", "/v1/file_links")
assert isinstance(... | mit | ce8061b6e08c3951f52ee18ca38166c7 | 33.953488 | 64 | 0.638723 | 3.612981 | false | true | false | false |
okfn/website | foundation/organisation/migrations/0003_add_nowdoing_field.py | 2 | 1222 | # -*- coding: utf-8 -*-
from __future__ import unicode_literals
from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
('organisation', '0002_sidebarextension'),
]
operations = [
migrations.CreateModel(
name='NowDoing',
f... | mit | c2d0806d449ca9dbaba695a81fa977dd | 36.030303 | 236 | 0.570376 | 3.967532 | false | false | false | false |
stripe/stripe-python | stripe/api_resources/abstract/custom_method.py | 1 | 2354 | from __future__ import absolute_import, division, print_function
from stripe import util
from stripe.six.moves.urllib.parse import quote_plus
def custom_method(name, http_verb, http_path=None, is_streaming=False):
if http_verb not in ["get", "post", "delete"]:
raise ValueError(
"Invalid http_... | mit | a7502c5aa1bb4f459798a136754000f9 | 36.365079 | 78 | 0.565421 | 4.211091 | false | false | false | false |
stripe/stripe-python | stripe/multipart_data_generator.py | 1 | 2745 | from __future__ import absolute_import, division, print_function
import random
import io
import stripe
class MultipartDataGenerator(object):
def __init__(self, chunk_size=1028):
self.data = io.BytesIO()
self.line_break = "\r\n"
self.boundary = self._initialize_boundary()
self.chu... | mit | 07a463afb756bb649ca2b4f9985e8683 | 32.072289 | 78 | 0.53224 | 4.178082 | false | false | false | false |
stripe/stripe-python | stripe/api_resources/subscription_schedule.py | 1 | 2538 | # -*- coding: utf-8 -*-
# File generated from our OpenAPI spec
from __future__ import absolute_import, division, print_function
from stripe import util
from stripe.api_resources.abstract import CreateableAPIResource
from stripe.api_resources.abstract import ListableAPIResource
from stripe.api_resources.abstract import... | mit | ba17091b1261e983ad33755aecd60455 | 29.214286 | 124 | 0.598897 | 4.195041 | false | false | false | false |
okfn/website | foundation/organisation/cms_apps.py | 2 | 1919 | from cms.app_base import CMSApp
from cms.apphook_pool import apphook_pool
from django.utils.translation import ugettext_lazy as _
from .cms_menus import ProjectMenu, ThemeMenu
class UnitsAppHook(CMSApp):
name = _("Units")
def get_urls(self, page=None, language=None, **kwargs):
return ["foundation.org... | mit | 25f6ca6ea55635922a5c75960dfcac1f | 22.9875 | 61 | 0.709745 | 3.495446 | false | false | false | false |
stripe/stripe-python | tests/api_resources/abstract/test_nested_resource_class_methods.py | 1 | 2798 | from __future__ import absolute_import, division, print_function
import stripe
class TestNestedResourceClassMethods(object):
@stripe.api_resources.abstract.nested_resource_class_methods(
"nested", operations=["create", "retrieve", "update", "delete", "list"]
)
class MainResource(stripe.api_resour... | mit | b988f371af8cc8da37fcd9ad13281ad9 | 35.815789 | 79 | 0.566833 | 3.745649 | false | true | false | false |
okfn/website | aldryn_quote/migrations/0001_initial.py | 2 | 1446 | # -*- coding: utf-8 -*-
from __future__ import unicode_literals
from django.db import migrations, models
import django.utils.timezone
class Migration(migrations.Migration):
dependencies = [
('cms', '0013_urlconfrevision'),
]
operations = [
migrations.CreateModel(
name='Quote... | mit | 01567a6c08a4ec7932544c2d38025c4c | 37.052632 | 151 | 0.528354 | 4.532915 | false | false | false | false |
python-provy/provy | provy/core/utils.py | 1 | 1612 | #!/usr/bin/python
# -*- coding: utf-8 -*-
'''
Core utilities.
Provides the :class:`AskFor` class, which is used to prompt for a password.
'''
from getpass import getpass
import os
def provyfile_path_from(args):
if args:
path = args[0]
if not os.path.exists(path):
raise IOError('prov... | mit | ee250c2604f479536aaf4f6843e705f6 | 28.851852 | 140 | 0.634615 | 3.647059 | false | false | false | false |
python-provy/provy | provy/more/debian/web/rails.py | 1 | 7911 | #!/usr/bin/python
# -*- coding: utf-8 -*-
'''
Roles in this namespace are meant to provide `Ruby on Rails <http://rubyonrails.org/>`_ applications utility methods for Debian distributions.
'''
from provy.core import Role
from provy.more.debian.package.aptitude import AptitudeRole
from provy.more.debian.package.gem im... | mit | b7c00fc5dd986df2a7f91659819c4baa | 32.95279 | 142 | 0.583744 | 4.025954 | false | false | false | false |
python-provy/provy | tests/unit/more/debian/web/test_nginx.py | 1 | 5240 | from nose.tools import istest
from provy.more.debian import AptitudeRole, NginxRole
from tests.unit.tools.helpers import ProvyTestCase
class NginxRoleTest(ProvyTestCase):
def setUp(self):
super(NginxRoleTest, self).setUp()
self.role = NginxRole(prov=None, context={'owner': 'some-owner'})
@is... | mit | 0cee63486e8283e6d4fb5d95770ece5b | 33.933333 | 149 | 0.641794 | 3.613793 | false | true | false | false |
python-provy/provy | docs.py | 1 | 4490 | #!/usr/bin/env python
# -*- coding: utf-8 -*-
from os.path import exists, join, abspath, sep, splitext, dirname
from json import dumps
from provy.core import Role
import os
import fnmatch
import inspect
class RoleDoc(object):
def __init__(self, role, name, module, docs):
self.role = role
self.n... | mit | 8f5987ad7c39d23c9393aa74e8d0689d | 30.619718 | 102 | 0.502227 | 4.255924 | false | false | false | false |
python-provy/provy | tests/unit/more/centos/utils/test_hostname.py | 1 | 2828 | from mock import patch, call
from nose.tools import istest
from provy.more.centos import HostNameRole
from provy.more.centos.utils import hostname
from tests.unit.tools.helpers import ProvyTestCase
class HostNameRoleTest(ProvyTestCase):
def setUp(self):
super(HostNameRoleTest, self).setUp()
self.... | mit | 02d72184e3f5b25699300f74e6ba2e4b | 40.588235 | 120 | 0.62058 | 3.92233 | false | true | false | false |
python-provy/provy | provy/more/debian/users/passwd_utils.py | 1 | 1465 | # -*- coding: utf-8 -*-
import crypt
from random import SystemRandom
def random_salt_function(salt_len=12):
"""
Creates random salt for password.
:param salt_len: Length of salt. Default :data:`12`
:type param: :class:`int`
:return: Computed salt
:rtype: str
"""
charset = "abcdefghi... | mit | b5730739eb997001cd85790b05b4ab03 | 27.173077 | 83 | 0.645051 | 3.690176 | false | false | false | false |
python-provy/provy | provy/more/centos/messaging/rabbitmq.py | 1 | 8622 | #!/usr/bin/python
# -*- coding: utf-8 -*-
'''
Roles in this namespace are meant to provide `RabbitMQ <http://www.rabbitmq.com/>`_ utilities methods within CentOS distributions.
'''
from provy.core import Role
from provy.more.centos.package.yum import YumRole
from fabric.utils import warn
GUEST_USER_WARNING = ('It ... | mit | c06d66f9484b4c012da0c62ef03b24ea | 31.908397 | 130 | 0.53955 | 4.222331 | false | false | false | false |
drj11/pypng | code/texttopng.py | 1 | 5164 | #!/usr/bin/env python
# Script to render text as a PNG image.
# texttopng
# Example (all ASCII glyphs):
"""
printf $(printf '\\%s' $(seq 40 176 | grep -v '[89]')) |
fold -w 32 |
python3 texttopng.py > ascii.png
"""
import binascii
import itertools
import png
def usage(fil):
fil.write("texttopng [-h|--help... | mit | ac94945005f7f672f4e56b83a943fcc6 | 24.564356 | 70 | 0.613091 | 2.880089 | false | false | false | false |
drj11/pypng | code/exnumpy.py | 1 | 3400 | #!/usr/bin/env python
"""
Example code integrating RGB PNG files, PyPNG and NumPy
(abstracted from Mel Raab's functioning code)
"""
import numpy
import png
import pngsuite
"""
Reading from PNG file into numpy array.
If you have a PNG file for an RGB image,
and want to create a numpy array of data from it.
"""
# H... | mit | 6418af3c1a9093f6f0182104c5f2322e | 32.663366 | 79 | 0.683824 | 3.336605 | false | false | false | false |
psf/black | tests/data/simple_cases/composition_no_trailing_comma.py | 1 | 11196 | class C:
def test(self) -> None:
with patch("black.out", print):
self.assertEqual(
unstyle(str(report)), "1 file reformatted, 1 file failed to reformat."
)
self.assertEqual(
unstyle(str(report)),
"1 file reformatted, 1 file ... | mit | 7cd5f7f3edd5f38d898c386c4c159be9 | 29.506812 | 88 | 0.426224 | 4.036049 | false | false | false | false |
psf/black | src/black/nodes.py | 1 | 24059 | """
blib2to3 Node/Leaf transformation-related utility functions.
"""
import sys
from typing import Generic, Iterator, List, Optional, Set, Tuple, TypeVar, Union
if sys.version_info >= (3, 8):
from typing import Final
else:
from typing_extensions import Final
if sys.version_info >= (3, 10):
from typing imp... | mit | bcb131a42b5632d7c579e6b9b4f174b0 | 27.304706 | 88 | 0.592336 | 3.757457 | false | false | false | false |
psf/black | scripts/migrate-black.py | 1 | 2987 | #!/usr/bin/env python3
# check out every commit added by the current branch, blackify them,
# and generate diffs to reconstruct the original commits, but then
# blackified
import logging
import os
import sys
from subprocess import PIPE, Popen, check_output, run
def git(*args: str) -> str:
return check_output(["gi... | mit | d92c0ec1b8d78b27b828582d053888b4 | 30.114583 | 85 | 0.54235 | 3.884265 | false | false | false | false |
psf/black | tests/data/simple_cases/torture.py | 2 | 2279 | importA;() << 0 ** 101234234242352525425252352352525234890264906820496920680926538059059209922523523525 #
assert sort_by_dependency(
{
"1": {"2", "3"}, "2": {"2a", "2b"}, "3": {"3a", "3b"},
"2a": set(), "2b": set(), "3a": set(), "3b": set()
}
) == ["2a", "2b", "2", "3a", "3b", "3", "1"]
import... | mit | f53030802e2e919eb5af6d94116ca7fa | 24.043956 | 132 | 0.554629 | 2.95974 | false | false | false | false |
psf/black | tests/data/simple_cases/remove_parens.py | 2 | 3493 | x = (1)
x = (1.2)
data = (
"xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"
).encode()
async def show_status():
while True:
try:
if report_host:
data = (
f"xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx... | mit | 1448482c9e7a0a46f05d0e38cc1ef8fc | 23.598592 | 165 | 0.549671 | 4.739484 | false | false | false | false |
psf/black | tests/data/miscellaneous/debug_visitor.py | 2 | 1193 | @dataclass
class DebugVisitor(Visitor[T]):
tree_depth: int = 0
def visit_default(self, node: LN) -> Iterator[T]:
indent = ' ' * (2 * self.tree_depth)
if isinstance(node, Node):
_type = type_repr(node.type)
out(f'{indent}{_type}', fg='yellow')
self.tree_depth ... | mit | c8dde7054e9a0c392e152abf4082de80 | 36.28125 | 75 | 0.536463 | 3.693498 | false | false | false | false |
kaste/mockito-python | mockito/invocation.py | 1 | 17040 | # Copyright (c) 2008-2016 Szczepan Faber, Serhiy Oplakanets, Herr Kaste
#
# 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... | mit | 3e72c5df6d840f24a544be1acd1ebc24 | 32.34638 | 79 | 0.598063 | 4.268537 | false | false | false | false |
kaste/mockito-python | mockito/mockito.py | 1 | 14256 | # Copyright (c) 2008-2016 Szczepan Faber, Serhiy Oplakanets, Herr Kaste
#
# 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... | mit | 0202564a6a1bf8b7380217151645ccf2 | 31.847926 | 79 | 0.656004 | 3.963303 | false | false | false | false |
pydata/numexpr | bench/vml_timing2.py | 1 | 1472 | # References:
#
# http://software.intel.com/en-us/intel-mkl
# https://github.com/pydata/numexpr/wiki/NumexprMKL
from __future__ import print_function
import datetime
import sys
import numpy as np
import numexpr as ne
from time import time
N = int(2**26)
x = np.linspace(0, 1, N)
y = np.linspace(0, 1, N)
z = np.empty(... | mit | f58fdaeac0fb1201ea33a28feba631f9 | 26.259259 | 122 | 0.620924 | 2.347687 | false | false | false | false |
wireservice/agate | agate/tableset/bar_chart.py | 3 | 1348 | #!/usr/bin/env python
# pylint: disable=W0212
import leather
def bar_chart(self, label=0, value=1, path=None, width=None, height=None):
"""
Render a lattice/grid of bar charts using :class:`leather.Lattice`.
:param label:
The name or index of a column to plot as the labels of the chart.
... | mit | 0045f49fea0e36ef74d56a506e9c8ba4 | 31.878049 | 74 | 0.649852 | 3.633423 | false | false | false | false |
wireservice/agate | agate/table/bins.py | 3 | 3367 | #!/usr/bin/env python
# pylint: disable=W0212
try:
from cdecimal import Decimal
except ImportError: # pragma: no cover
from decimal import Decimal
from babel.numbers import format_decimal
from agate import utils
from agate.aggregations import Max, Min
def bins(self, column_name, count=10, start=None, end=... | mit | 785b0eee6348692252737f1c75ca4636 | 29.0625 | 84 | 0.62578 | 3.887991 | false | false | false | false |
kalaspuff/tomodachi | tests/services/decorated_functions_service.py | 1 | 2522 | import asyncio
from typing import Any
from aiohttp import web
import tomodachi
from tomodachi.transport.http import http
@tomodachi.decorator
async def count_invocations_1(self: Any, *args: Any, **kwargs: Any) -> None:
self.invocation_count += 1
@tomodachi.decorator()
async def count_invocations_2(self: Any, ... | mit | 49292b14614027b2d09ff60d7d22b685 | 27.337079 | 87 | 0.620143 | 3.301047 | false | false | false | false |
wireservice/agate | agate/table/column_chart.py | 3 | 1287 | #!/usr/bin/env python
# pylint: disable=W0212
import leather
def column_chart(self, label=0, value=1, path=None, width=None, height=None):
"""
Render a column chart using :class:`leather.Chart`.
:param label:
The name or index of a column to plot as the labels of the chart.
Defaults to t... | mit | 54ae8a4987894f62f07bc596b53bc019 | 30.390244 | 77 | 0.645688 | 3.698276 | false | false | false | false |
kalaspuff/tomodachi | tests/services/aws_sns_sqs_service_dead_letter_queue.py | 1 | 3371 | import asyncio
import os
import uuid as uuid_
from typing import Any
import tomodachi
from tomodachi.transport.aws_sns_sqs import AWSSNSSQSInternalServiceError, aws_sns_sqs, aws_sns_sqs_publish
data_uuid = str(uuid_.uuid4())
@tomodachi.service
class AWSSNSSQSService(tomodachi.Service):
name = "test_aws_sns_sqs_... | mit | c5ac439959738aa0569128b2f1c5831a | 35.641304 | 107 | 0.599822 | 3.28878 | false | true | false | false |
kalaspuff/tomodachi | tests/test_invalid_services.py | 1 | 1329 | from typing import Any
import pytest
from run_test_service_helper import start_service
def test_invalid_filename(monkeypatch: Any, capsys: Any, loop: Any) -> None:
with pytest.raises(SystemExit):
services, future = start_service("tests/services/no_service_existing.py", monkeypatch, loop=loop)
out, ... | mit | 1657b8d892a42685e5d3eeffc9b16c9c | 34.918919 | 106 | 0.714071 | 3.651099 | false | true | false | false |
wireservice/agate | agate/table/print_bars.py | 3 | 7803 | #!/usr/bin/env python
# -*- coding: utf8 -*-
# pylint: disable=W0212
from collections import OrderedDict
try:
from cdecimal import Decimal
except ImportError: # pragma: no cover
from decimal import Decimal
import sys
import six
from babel.numbers import format_decimal
from agate import config, utils
from ... | mit | 5f7dcf3fca1c4540f13e354f09223048 | 30.46371 | 117 | 0.591696 | 3.780523 | false | false | false | false |
wireservice/agate | agate/tableset/column_chart.py | 3 | 1357 | #!/usr/bin/env python
# pylint: disable=W0212
import leather
def column_chart(self, label=0, value=1, path=None, width=None, height=None):
"""
Render a lattice/grid of column charts using :class:`leather.Lattice`.
:param label:
The name or index of a column to plot as the labels of the chart.
... | mit | 30b7ff3f71839e0c7b3622ca18e1c5f1 | 32.097561 | 77 | 0.652174 | 3.667568 | false | false | false | false |
wireservice/agate | agate/data_types/boolean.py | 3 | 2138 | #!/usr/bin/env python
try:
from cdecimal import Decimal
except ImportError: # pragma: no cover
from decimal import Decimal
import six
from agate.data_types.base import DEFAULT_NULL_VALUES, DataType
from agate.exceptions import CastError
#: Default values which will be automatically cast to :code:`True`.
DE... | mit | 55315dfe5087ed8df613cd805c6183d1 | 29.542857 | 90 | 0.59261 | 4.003745 | false | false | false | false |
kalaspuff/tomodachi | tests/services/http_service.py | 1 | 6577 | import asyncio
from typing import Any, Callable, Dict, Tuple, Union
from aiohttp import web
import tomodachi
from tomodachi.discovery.dummy_registry import DummyRegistry
from tomodachi.transport.http import RequestHandler, Response, http, http_error, http_static, websocket
async def middleware_function(
func: C... | mit | 0fc240b7167d82d0c71affb89f4f186a | 35.926966 | 111 | 0.627111 | 3.578116 | false | true | false | false |
kalaspuff/tomodachi | tomodachi/options/definitions.py | 1 | 11612 | from __future__ import annotations
import platform
from typing import Any, Dict, List, Mapping, Optional, Tuple, Type, TypeVar, Union, cast
from .interface import OptionsInterface
T = TypeVar("T")
def DEFAULT(cls: Type[T]) -> T:
return cast(T, type("DEFAULT", (type(cls),), {"_default": True}))
class _HTTP(Op... | mit | 88ea2138d63607da63e949e006cacfdd | 34.839506 | 116 | 0.59826 | 3.128233 | false | false | false | false |
wireservice/agate | agate/table/line_chart.py | 3 | 1182 | #!/usr/bin/env python
# pylint: disable=W0212
import leather
def line_chart(self, x=0, y=1, path=None, width=None, height=None):
"""
Render a line chart using :class:`leather.Chart`.
:param x:
The name or index of a column to plot as the x-axis. Defaults to the
first column in the table.... | mit | 4882ca3683f1acbf653881bbc82da45f | 27.829268 | 76 | 0.617597 | 3.416185 | false | false | false | false |
wireservice/agate | agate/computations/slug.py | 3 | 2082 | #!/usr/bin/env python
from agate.aggregations.has_nulls import HasNulls
from agate.computations.base import Computation
from agate.data_types import Text
from agate.exceptions import DataTypeError
from agate.utils import issequence, slugify
class Slug(Computation):
"""
Convert text values from one or more co... | mit | 9fd31e1c66e69fa27ca9081d5d3af2e4 | 32.047619 | 88 | 0.615274 | 4.223124 | false | false | false | false |
wireservice/agate | agate/aggregations/mean.py | 3 | 1224 | #!/usr/bin/env python
from agate.aggregations.base import Aggregation
from agate.aggregations.has_nulls import HasNulls
from agate.aggregations.sum import Sum
from agate.data_types import Number
from agate.exceptions import DataTypeError
from agate.warns import warn_null_calculation
class Mean(Aggregation):
"""
... | mit | 9758ca11c387cbb692cfb3b48efc4678 | 28.853659 | 94 | 0.658497 | 3.910543 | false | false | false | false |
cyanfish/heltour | heltour/tournament/migrations/0030_loneplayerpairing_teamplayerpairing.py | 1 | 2106 | # -*- coding: utf-8 -*-
# Generated by Django 1.9.7 on 2016-07-28 05:05
from django.db import migrations, models
import django.db.models.deletion
class Migration(migrations.Migration):
dependencies = [
('tournament', '0029_auto_20160727_0214'),
]
operations = [
migrations.CreateModel(
... | mit | 2ac3b53c8616fbb268a0087052d17504 | 45.8 | 151 | 0.584046 | 4.003802 | false | false | false | false |
cyanfish/heltour | heltour/tournament/models.py | 1 | 113929 | from django.db import models, transaction
from django.utils.crypto import get_random_string
from ckeditor_uploader.fields import RichTextUploadingField
from django.core.validators import RegexValidator
from datetime import timedelta
from django.utils import timezone
from django import forms as django_forms
from collect... | mit | 83dc18fdab0392a66916584f412ed15d | 40.901067 | 193 | 0.585584 | 3.979218 | false | false | false | false |
cyanfish/heltour | heltour/tournament/admin.py | 1 | 118395 | from django.contrib import admin, messages
from django.utils import timezone
from heltour.tournament import lichessapi, slackapi, views, forms, signals, simulation
from heltour.tournament.models import *
from reversion.admin import VersionAdmin
from django.conf.urls import url
from django.shortcuts import render, redir... | mit | 78482b97a936f18c89fc8ffa5c4ff233 | 44.309989 | 175 | 0.538325 | 4.277585 | false | false | false | false |
cyanfish/heltour | heltour/tournament/migrations/0110_scheduledevent.py | 1 | 1419 | # -*- coding: utf-8 -*-
# Generated by Django 1.9.7 on 2016-11-08 18:16
from django.db import migrations, models
import django.db.models.deletion
class Migration(migrations.Migration):
dependencies = [
('tournament', '0109_auto_20161108_0128'),
]
operations = [
migrations.CreateModel(
... | mit | dab9698f2c59a060bc2ddd7f6836338c | 42 | 138 | 0.590557 | 4.054286 | false | false | false | false |
cyanfish/heltour | heltour/tournament/migrations/0069_auto_20160816_0138.py | 1 | 1850 | # -*- coding: utf-8 -*-
# Generated by Django 1.9.7 on 2016-08-16 01:38
from django.db import migrations, models
import django.db.models.deletion
class Migration(migrations.Migration):
dependencies = [
('tournament', '0068_auto_20160815_2256'),
]
operations = [
migrations.CreateModel(
... | mit | 0e50d064ed95cc8abdc866bbabdd8967 | 40.111111 | 126 | 0.587027 | 4.214123 | false | false | false | false |
cyanfish/heltour | heltour/api_worker/worker.py | 1 | 2326 | import queue
import threading
import websocket
import json
import time
from django.utils import timezone
from datetime import timedelta
def _run_worker():
while True:
_, fn, args = _work_queue.get()
try:
fn(*args)
except:
pass
_work_queue = queue.PriorityQueue()
_... | mit | 5a50d440e9261438f12a408fd4b0a009 | 25.134831 | 94 | 0.540413 | 3.769854 | false | false | false | false |
cyanfish/heltour | heltour/tournament/automod.py | 1 | 17435 | from heltour import settings
from heltour.tournament.models import *
from django.db.models.signals import post_save
from django.dispatch.dispatcher import receiver
from heltour.tournament.tasks import pairings_published
import reversion
import time
logger = logging.getLogger(__name__)
@receiver(post_save, sender=Mod... | mit | d38d95fced37d29d84c4e391fd600948 | 45.002639 | 107 | 0.638142 | 3.958002 | false | false | false | false |
cyanfish/heltour | heltour/settings_default.py | 1 | 8438 | '''
Django settings for heltour project.
Generated by 'django-admin startproject' using Django 1.9.7.
For more information on this file, see
https://docs.djangoproject.com/en/1.9/topics/settings/
For the full list of settings and their values, see
https://docs.djangoproject.com/en/1.9/ref/settings/
'''
import os
fr... | mit | b75c54193d1a79888bee4e768129d390 | 26.131833 | 91 | 0.652287 | 3.159116 | false | false | false | false |
cyanfish/heltour | heltour/tournament/workflows.py | 1 | 31501 | import logging
import reversion
from django.contrib import messages
from heltour.tournament.models import *
from heltour.tournament import pairinggen, signals, slackapi
from smtplib import SMTPException
from django.template.loader import render_to_string
from django.core.mail import send_mail
from heltour import settin... | mit | 5389faefbfcd0c7b24c02057af689241 | 49.482372 | 138 | 0.529793 | 4.441139 | false | false | false | false |
cyanfish/heltour | heltour/tournament/alternates_manager.py | 1 | 16756 | from heltour.tournament.models import *
from django.urls import reverse
import reversion
import time
from heltour.tournament.workflows import UpdateBoardOrderWorkflow
_min_bucket_update_interval = timedelta(hours=1)
def current_round(season):
if not season.alternates_manager_enabled():
return None
# ... | mit | 4bbee4239d3b755441ee9b1d75e7a4d3 | 54.483444 | 150 | 0.567259 | 4.696188 | false | false | false | false |
cyanfish/heltour | heltour/tournament/migrations/0042_auto_20160801_2309.py | 1 | 1612 | # -*- coding: utf-8 -*-
# Generated by Django 1.9.7 on 2016-08-01 23:09
from django.db import migrations, models
import django.db.models.deletion
class Migration(migrations.Migration):
dependencies = [
('tournament', '0041_auto_20160801_2116'),
]
operations = [
migrations.CreateModel(
... | mit | 1432d91a1a84b26cc1ce33765156f64b | 36.488372 | 155 | 0.565136 | 4.112245 | false | false | false | false |
cyanfish/heltour | heltour/tournament/migrations/0158_auto_20170801_0133.py | 1 | 2286 | # -*- coding: utf-8 -*-
# Generated by Django 1.9.7 on 2017-08-01 01:33
from django.db import migrations, models
import django.db.models.deletion
import select2.fields
class Migration(migrations.Migration):
dependencies = [
('tournament', '0157_playerpresence'),
]
operations = [
migrat... | mit | a83db393424fa4c6767998cf0c71aa16 | 54.756098 | 514 | 0.631671 | 4.017575 | false | false | false | false |
nanograv/enterprise | tests/test_utils.py | 2 | 7057 | #!/usr/bin/env python
# -*- coding: utf-8 -*-
"""
test_utils
----------------------------------
Tests for `utils` module.
"""
import unittest
import numpy as np
import enterprise.constants as const
from enterprise.pulsar import Pulsar
from enterprise.signals import anis_coefficients as anis
from enterprise.signals... | mit | 3ddc905ac8883230e9738eb043e0312a | 34.641414 | 118 | 0.565679 | 2.916116 | false | true | false | false |
nanograv/enterprise | enterprise/signals/white_signals.py | 2 | 9663 | # white_signals.py
"""Contains class factories for white noise signals. White noise signals are
defined as the class of signals that only modifies the white noise matrix `N`.
"""
import numpy as np
import scipy.sparse
from enterprise.signals import parameter, selections, signal_base, utils
from enterprise.signals.pa... | mit | 2305828cd978ff0b1e5a3e6eda535a71 | 36.30888 | 114 | 0.611094 | 3.669958 | false | false | false | false |
nanograv/enterprise | enterprise/signals/utils.py | 2 | 32558 | # utils.py
"""
Utilities module containing various useful
functions for use in other modules.
"""
import logging
import numpy as np
import scipy.linalg as sl
import scipy.sparse as sps
import scipy.special as ss
from pkg_resources import Requirement, resource_filename
from scipy.integrate import odeint
from scipy.int... | mit | 5d3553808e1d862cc9dfaf7488c24dfd | 28.017825 | 116 | 0.559985 | 3.062553 | false | false | false | false |
pytest-dev/pytest-bdd | tests/library/test_parent.py | 1 | 11449 | """Test givens declared in the parent conftest and plugin files.
Check the parent givens are collected and overridden in the local conftest.
"""
import textwrap
from pytest_bdd.utils import collect_dumped_objects
def test_parent(pytester):
"""Test parent given is collected.
Both fixtures come from the pare... | mit | 0c38c40dceb5089193ed6191dfea1964 | 27.199507 | 115 | 0.538912 | 4.184576 | false | true | false | false |
neuropoly/spinalcordtoolbox | testing/api/test_reports.py | 1 | 6073 | #!/usr/bin/env python
# -*- coding: utf-8
# pytest unit tests for spinalcordtoolbox.reports
import os
import logging
import pytest
import numpy as np
from spinalcordtoolbox.image import Image
from spinalcordtoolbox.reports.slice import Sagittal
from spinalcordtoolbox.utils import sct_test_path
import spinalcordtoolb... | mit | 93a526181c7d3f35e0d8f448d7d4b974 | 34.723529 | 107 | 0.648938 | 2.902964 | false | true | false | false |
neuropoly/spinalcordtoolbox | spinalcordtoolbox/resampling.py | 1 | 7336 | #########################################################################################
#
# Resample data using nibabel.
#
# ---------------------------------------------------------------------------------------
# Copyright (c) 2014 Polytechnique Montreal <www.neuro.polymtl.ca>
# Authors: Julien Cohen-Adad, Sara Dup... | mit | 61e8edd57010d94913274357f8b89375 | 41.900585 | 124 | 0.600327 | 3.543961 | false | false | false | false |
neuropoly/spinalcordtoolbox | install/create_package.py | 1 | 5697 | #!/usr/bin/env python
# -*- coding: utf-8 -*-
#
# Create package with appropriate version number.
#
# Author: Julien Cohen-Adad, Benjamin De Leener, P-O Quirion
#
# TODO: remove quick fix with folder_sct_temp
DEBUG = False
import getopt
import os
import platform
import shutil
import sys
import tarfile
import tempfil... | mit | e609c97cb45bc3358d84533e24cebaf7 | 28.365979 | 125 | 0.579779 | 3.101252 | false | false | false | false |
neuropoly/spinalcordtoolbox | spinalcordtoolbox/utils/sys.py | 1 | 16528 | #!/usr/bin/env python
# -*- coding: utf-8
# System related utilities
import io
import sys
import os
import logging
import subprocess
import time
import shlex
import atexit
import smtplib
from email.mime.multipart import MIMEMultipart
from email.mime.text import MIMEText
from email.mime.base import MIMEBase
from email ... | mit | 8360bb8bd17d46a206dea2d4c9db48cc | 30.969052 | 174 | 0.600073 | 3.65179 | false | false | false | false |
neuropoly/spinalcordtoolbox | spinalcordtoolbox/scripts/sct_flatten_sagittal.py | 1 | 3136 | #!/usr/bin/env python
#########################################################################################
#
# Flatten spinal cord in sagittal plane.
#
# ---------------------------------------------------------------------------------------
# Copyright (c) 2013 Polytechnique Montreal <www.neuro.polymtl.ca>
# Auth... | mit | f636c0560fac1067c8a67db8448c32a5 | 28.584906 | 118 | 0.588648 | 3.792019 | false | false | false | false |
neuropoly/spinalcordtoolbox | spinalcordtoolbox/centerline/optic.py | 1 | 4827 | #!/usr/bin/env python
# -*- coding: utf-8
# Functions dealing with centerline detection and manipulation
import os
import datetime
import logging
import numpy as np
from spinalcordtoolbox.image import Image
from spinalcordtoolbox.utils.sys import sct_dir_local_path, run_proc
from spinalcordtoolbox.utils.fs import ex... | mit | 0e4084ae81f5b259daf0b1720af2ff9c | 35.293233 | 95 | 0.612803 | 3.354413 | false | false | false | false |
neuropoly/spinalcordtoolbox | spinalcordtoolbox/scripts/sct_analyze_texture.py | 1 | 14764 | #!/usr/bin/env python
# Analyse texture
#
# Copyright (c) 2017 Polytechnique Montreal <www.neuro.polymtl.ca>
# Author: Charley
# Modified: 2017-06-22
#
# About the license: see the file LICENSE.TXT
import os
import sys
import itertools
import numpy as np
from skimage.feature import greycomatrix, greycoprops
from sp... | mit | 65dcc94d4199663ac8a2dee6f0835816 | 40.125348 | 209 | 0.596383 | 3.624847 | false | false | false | false |
neuropoly/spinalcordtoolbox | spinalcordtoolbox/deepseg/models.py | 1 | 7724 | # coding: utf-8
"""
Deals with models for deepseg module. Available models are listed under MODELS.
"""
import os
import json
import logging
import colored
import spinalcordtoolbox as sct
import spinalcordtoolbox.download
logger = logging.getLogger(__name__)
# List of models. The convention for model names is: (s... | mit | 74025400fb78c404d05082d04c9828f3 | 35.262911 | 124 | 0.608364 | 3.372926 | false | false | false | false |
neuropoly/spinalcordtoolbox | spinalcordtoolbox/scripts/sct_label_utils.py | 1 | 15830 | #!/usr/bin/env python
#########################################################################################
#
# All sort of utilities for labels.
#
# ---------------------------------------------------------------------------------------
# Copyright (c) 2015 Polytechnique Montreal <www.neuro.polymtl.ca>
# Author: B... | mit | d0935e0cfa87ae99a6cbc3c55d6cf26f | 37.236715 | 187 | 0.623752 | 3.80346 | false | false | false | false |
bethgelab/foolbox | tests/test_distances.py | 2 | 2239 | from typing import Tuple, Any, Dict, Callable, TypeVar
import numpy as np
import pytest
import foolbox as fbn
import eagerpy as ep
distances = {
0: fbn.distances.l0,
1: fbn.distances.l1,
2: fbn.distances.l2,
ep.inf: fbn.distances.linf,
}
data: Dict[str, Callable[..., Tuple[ep.Tensor, ep.Tensor]]] = {}... | mit | 4d6d96659e3cf8a0b82b3ddc3a7f4cdb | 26.9875 | 87 | 0.666369 | 3.025676 | false | true | false | false |
bethgelab/foolbox | foolbox/attacks/fast_minimum_norm.py | 1 | 21024 | import math
from abc import abstractmethod, ABC
from typing import Union, Optional, Any, Tuple
import eagerpy as ep
from eagerpy.astensor import T
from .base import MinimizationAttack, raise_if_kwargs, get_criterion, get_is_adversarial
from .gradient_descent_base import (
uniform_l1_n_balls,
normalize_lp_norm... | mit | 9c7d807260d833216f744eda6030fa46 | 37.505495 | 89 | 0.580337 | 3.707937 | false | false | false | false |
bethgelab/foolbox | foolbox/attacks/gen_attack.py | 1 | 9060 | from typing import Optional, Any, Tuple, Union
import numpy as np
import eagerpy as ep
from ..devutils import atleast_kd
from ..models import Model
from ..criteria import TargetedMisclassification
from ..distances import linf
from .base import FixedEpsilonAttack
from .base import T
from .base import get_channel_ax... | mit | 3bf0bfa7e55deddff5b9f8f94d017e62 | 33.188679 | 88 | 0.518212 | 3.994709 | false | false | false | false |
bethgelab/foolbox | examples/single_attack_tensorflow_resnet50.py | 1 | 2326 | #!/usr/bin/env python3
import tensorflow as tf
import eagerpy as ep
from foolbox import TensorFlowModel, accuracy, samples, Model
from foolbox.attacks import LinfPGD
def main() -> None:
# instantiate a model (could also be a TensorFlow or JAX model)
model = tf.keras.applications.ResNet50(weights="imagenet")
... | mit | 7c5fbc1f211f0b4bef232405efa3d5ed | 33.656716 | 87 | 0.61671 | 3.336207 | false | false | false | false |
bethgelab/foolbox | examples/substituion_model_pytorch_resnet18.py | 1 | 3383 | #!/usr/bin/env python3
# mypy: no-disallow-untyped-defs
"""
Sometimes one wants to replace the gradient of a model with a different gradient
from another model to make the attack more reliable. That is, the forward pass
should go through model 1, but the backward pass should go through model 2.
This example shows how t... | mit | 8cf92fbb4b4d880a73566d5936dd1264 | 36.131868 | 88 | 0.634211 | 3.4871 | false | false | false | false |
bethgelab/foolbox | foolbox/attacks/base.py | 1 | 14731 | from typing import Callable, TypeVar, Any, Union, Optional, Sequence, List, Tuple, Dict
from typing_extensions import final, overload
from abc import ABC, abstractmethod
from collections.abc import Iterable
import eagerpy as ep
from ..models import Model
from ..criteria import Criterion
from ..criteria import Misclas... | mit | c2624d9eeee7004411753c1d59ee2c94 | 28.521042 | 95 | 0.546467 | 3.832206 | false | false | false | false |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.