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
crowdresearch/daemo
crowdsourcing/crypto.py
3
1192
import base64 from Crypto import Random from Crypto.Cipher import AES from django.conf import settings from hashids import Hashids def to_hash(pk): id_hash = Hashids(salt=settings.SECRET_KEY, min_length=12) return id_hash.encode(pk) def to_pk(hash_string): id_hash = Hashids(salt=settings.SECRET_KEY, min...
mit
fb9da6bb03476531c94938b63c267b90
27.380952
69
0.637584
3.283747
false
false
false
false
crowdresearch/daemo
crowdsourcing/validators/utils.py
4
4377
from __future__ import unicode_literals from django.utils.translation import ugettext_lazy as _ from rest_framework.exceptions import ValidationError class EqualityValidator(object): message = _('The fields {field_names} must be equal.') missing_message = _('This field is required.') def __init__(self, f...
mit
a52fd5a24840e76ce67642d40323ba41
43.212121
106
0.614576
4.184512
false
false
false
false
jrkerns/pylinac
docs/source/code_snippets/trs398_class.py
1
1182
"""A script to calculate TRS-398 dose using pylinac classes and following the TRS-398 photon form""" from pylinac.calibration import trs398 ENERGY = 6 TEMP = 22.1 PRESS = trs398.mmHg2kPa(755.0) CHAMBER = '30013' # PTW K_ELEC = 1.000 ND_w = 5.443 # Gy/nC MU = 200 CLINICAL_PDD = 66.5 trs398_6x = trs398.TRS398Photon(...
mit
c38ba97644ebae5338b3a92622d2ea10
24.695652
120
0.678511
2.299611
false
false
false
false
graphql-python/graphql-core
src/graphql/validation/rules/unique_enum_value_names.py
1
2135
from collections import defaultdict from typing import Any, Dict from ...error import GraphQLError from ...language import SKIP, EnumTypeDefinitionNode, NameNode, VisitorAction from ...type import is_enum_type from . import SDLValidationContext, SDLValidationRule __all__ = ["UniqueEnumValueNamesRule"] class Unique...
mit
4fd4d8c14b24e5ab3214c26c5e1011ba
35.186441
82
0.581265
4.393004
false
false
false
false
graphql-python/graphql-core
tests/validation/test_variables_in_allowed_position.py
1
10191
from functools import partial from graphql.validation import VariablesInAllowedPositionRule from .harness import assert_validation_errors assert_errors = partial(assert_validation_errors, VariablesInAllowedPositionRule) assert_valid = partial(assert_errors, errors=[]) def describe_validate_variables_are_in_allow...
mit
f2588eb2edcaff5b77a3dac4693f58a6
26.844262
81
0.422628
4.899519
false
false
false
false
graphql-python/graphql-core
src/graphql/utilities/build_client_schema.py
1
17051
from itertools import chain from typing import Callable, Collection, Dict, List, Union, cast from ..language import DirectiveLocation, parse_value from ..pyutils import Undefined, inspect from ..type import ( GraphQLArgument, GraphQLDirective, GraphQLEnumType, GraphQLEnumValue, GraphQLField, Gr...
mit
01e2da3376c456d93c6a264a9063d7a8
39.025822
88
0.635505
4.617113
false
false
false
false
graphql-python/graphql-core
src/graphql/validation/validation_context.py
1
8712
from typing import Any, Callable, Dict, List, NamedTuple, Optional, Set, Union, cast from ..error import GraphQLError from ..language import ( DocumentNode, FragmentDefinitionNode, FragmentSpreadNode, OperationDefinitionNode, SelectionSetNode, VariableNode, Visitor, VisitorAction, v...
mit
6746f3b7556404997cfbafd803703208
32.898833
88
0.631772
4.274779
false
false
false
false
graphql-python/graphql-core
tests/utilities/test_type_comparators.py
1
3962
from graphql.type import ( GraphQLField, GraphQLFloat, GraphQLInt, GraphQLInterfaceType, GraphQLList, GraphQLNonNull, GraphQLObjectType, GraphQLOutputType, GraphQLSchema, GraphQLString, GraphQLUnionType, ) from graphql.utilities import is_equal_type, is_type_sub_type_of def...
mit
faf41ef019b6f19dbc50442da3f18e58
33.155172
88
0.552246
3.907298
false
true
false
false
graphql-python/graphql-core
src/graphql/validation/rules/known_directives.py
1
4458
from typing import Any, Dict, List, Optional, Tuple, Union, cast from ...error import GraphQLError from ...language import ( DirectiveDefinitionNode, DirectiveLocation, DirectiveNode, Node, OperationDefinitionNode, ) from ...type import specified_directives from . import ASTValidationRule, SDLValid...
mit
5a0546b084f1b4ee80b1e15cf683646f
36.15
87
0.666891
4.213611
false
false
false
false
graphql-python/graphql-core
src/graphql/language/ast.py
1
20944
from __future__ import annotations # Python < 3.10 from copy import copy, deepcopy from enum import Enum from typing import Any, Dict, List, Optional, Tuple, Union from ..pyutils import camel_to_snake from .source import Source from .token_kind import TokenKind try: from typing import TypeAlias except ImportEr...
mit
0a20baae720c395c5c2050be5b1d6d8b
24.666667
88
0.624141
4.047932
false
false
false
false
graphql-python/graphql-core
tests/star_wars_schema.py
1
7871
"""Star Wars GraphQL schema This is designed to be an end-to-end test, demonstrating the full GraphQL stack. We will create a GraphQL schema that describes the major characters in the original Star Wars trilogy. NOTE: This may contain spoilers for the original Star Wars trilogy. Using our shorthand to describe type...
mit
f1243ce4a3d3cf0cc74bfa098ec208e3
29.389961
87
0.614788
3.923729
false
false
false
false
graphql-python/graphql-core
tests/validation/test_possible_fragment_spreads.py
1
10022
from functools import partial from graphql.utilities import build_schema from graphql.validation import PossibleFragmentSpreadsRule from .harness import assert_validation_errors test_schema = build_schema( """ interface Being { name: String } interface Pet implements Being { name: Strin...
mit
6018b18db6e40d808d39eb3103dd1289
28.827381
86
0.496109
4.707374
false
false
false
false
graphql-python/graphql-core
src/graphql/utilities/get_introspection_query.py
1
7946
from textwrap import dedent from typing import Any, Dict, List, Optional, Union from ..language import DirectiveLocation try: from typing import Literal, TypedDict except ImportError: # Python < 3.8 from typing_extensions import Literal, TypedDict # type: ignore try: from typing import TypeAlias except...
mit
8acb12b20b0ae690563875dbb4713330
25.844595
85
0.638686
4.792521
false
false
false
false
graphql-python/graphql-core
src/graphql/validation/rules/overlapping_fields_can_be_merged.py
1
28442
from itertools import chain from typing import Any, Dict, List, Optional, Tuple, Union, cast from ...error import GraphQLError from ...language import ( FieldNode, FragmentDefinitionNode, FragmentSpreadNode, InlineFragmentNode, ObjectFieldNode, ObjectValueNode, SelectionSetNode, print_a...
mit
2bf67a9c54aca985f92e476920a226ba
36.227749
88
0.649216
4.276349
false
false
false
false
graphql-python/graphql-core
src/graphql/utilities/value_from_ast_untyped.py
1
3116
from math import nan from typing import Any, Callable, Dict, Optional, Union from ..language import ( BooleanValueNode, EnumValueNode, FloatValueNode, IntValueNode, ListValueNode, NullValueNode, ObjectValueNode, StringValueNode, ValueNode, VariableNode, ) from ..pyutils import U...
mit
3cf1fea2e474e10f0efb864387e3caf3
27.327273
88
0.613607
3.82801
false
false
false
false
graphql-python/graphql-core
tests/utilities/test_print_schema.py
1
26814
from typing import Any, Dict, cast from graphql.language import DirectiveLocation from graphql.type import ( GraphQLArgument, GraphQLBoolean, GraphQLDirective, GraphQLEnumType, GraphQLField, GraphQLFloat, GraphQLInputField, GraphQLInputObjectType, GraphQLInt, GraphQLInterfaceTyp...
mit
c4c83e4ea532e9b5656ad4a990b9c0f0
29.75
418
0.518684
4.864659
false
false
false
false
graphql-python/graphql-core
tests/error/test_located_error.py
1
1237
from typing import Any, cast from graphql.error import GraphQLError, located_error def describe_located_error(): def throws_without_an_original_error(): e = located_error([], [], []).original_error # type: ignore assert isinstance(e, TypeError) assert str(e) == "Unexpected error value: [...
mit
5984c4f50de502cfaf9d214a1f1ce286
32.432432
68
0.569927
3.93949
false
false
false
false
graphql-python/graphql-core
tests/test_docs.py
1
13482
"""Test all code snippets in the documentation""" from pathlib import Path from typing import Any, Dict, List from .utils import dedent try: from typing import TypeAlias except ImportError: # Python < 3.10 from typing_extensions import TypeAlias Scope: TypeAlias = Dict[str, Any] def get_snippets(source...
mit
93e5e21bd9d97d606e41a708f4ff7aa7
36.45
81
0.606512
3.906694
false
false
false
false
graphql-python/graphql-core
tests/language/test_print_string.py
1
2437
from graphql.language.print_string import print_string def describe_print_string(): def prints_a_simple_string(): assert print_string("hello world") == '"hello world"' def escapes_quotes(): assert print_string('"hello world"') == '"\\"hello world\\""' def escapes_backslashes(): a...
mit
83b25ff5f3745a90623e146e575a0dfe
44.981132
78
0.571194
2.211434
false
false
false
false
graphql-python/graphql-core
tests/validation/test_single_field_subscriptions.py
1
8228
from functools import partial from graphql.utilities import build_schema from graphql.validation import SingleFieldSubscriptionsRule from .harness import assert_validation_errors schema = build_schema( """ type Message { body: String sender: String } type SubscriptionRoot { import...
mit
5a9b1355388cd02f0f49e5b1bf751637
25.456592
83
0.421609
5.481679
false
false
false
false
graphql-python/graphql-core
tests/execution/test_execution_result.py
1
4559
from pytest import raises from graphql.error import GraphQLError from graphql.execution import ExecutionResult def describe_execution_result(): data = {"foo": "Some data"} error = GraphQLError("Some error") errors = [error] extensions = {"bar": "Some extension"} def initializes_properly(): ...
mit
6de819b02ed7725184e44b27edc20047
38.301724
81
0.586093
4.24093
false
false
false
false
opennode/waldur-mastermind
src/waldur_aws/management/commands/import_ami_catalog.py
2
3497
import argparse from csv import DictReader from django.core.management.base import BaseCommand, CommandError from ... import models class Command(BaseCommand): help = "Import catalog of Amazon images." def add_arguments(self, parser): parser.add_argument( 'file', type=argpar...
mit
11bf85790c7d7b675bb98a75acf554e4
33.97
87
0.544181
4.001144
false
false
false
false
opennode/waldur-mastermind
src/waldur_mastermind/invoices/migrations/0056_fill_quantity.py
1
2792
from calendar import monthrange from decimal import ROUND_UP, Decimal from django.db import migrations, models class Units: PER_MONTH = 'month' PER_HALF_MONTH = 'half_month' PER_DAY = 'day' PER_HOUR = 'hour' QUANTITY = 'quantity' def quantize_price(value): return value.quantize(Decimal('0.0...
mit
b1021f86de1cabb4a84c5322ddfe9f2b
29.347826
86
0.60351
3.485643
false
false
false
false
opennode/waldur-mastermind
src/waldur_mastermind/marketplace_openstack/migrations/0010_split_invoice_items.py
2
8094
import decimal from collections import defaultdict from datetime import timedelta from django.db import migrations from django.utils import timezone TENANT_TYPE = 'Packages.Template' RAM_TYPE = 'ram' CORES_TYPE = 'cores' STORAGE_TYPE = 'storage' component_factors = {STORAGE_TYPE: 1024, RAM_TYPE: 1024} def get_full...
mit
c8c5ba419e3f46230bf27cb012c96190
36.472222
88
0.618483
4.096154
false
false
false
false
getavalon/core
avalon/vendor/requests/packages/chardet/charsetprober.py
292
5110
######################## BEGIN LICENSE BLOCK ######################## # The Original Code is Mozilla Universal charset detector code. # # The Initial Developer of the Original Code is # Netscape Communications Corporation. # Portions created by the Initial Developer are Copyright (C) 2001 # the Initial Developer. All R...
mit
4818830e630907428f275d46470d3421
34.241379
80
0.608806
4.506173
false
false
false
false
opennode/waldur-mastermind
src/waldur_mastermind/booking/calendar.py
2
4800
from django.utils.functional import cached_property from waldur_mastermind.booking.utils import TimePeriod, get_offering_bookings from waldur_mastermind.google.backend import GoogleCalendar class SyncBookingsError(Exception): pass class SyncBookings: def __init__(self, offering): self.offering = of...
mit
cd498ff0bed771f155d0278d42aabaf1
32.802817
99
0.548542
4.289544
false
false
false
false
opennode/waldur-mastermind
src/waldur_core/core/monkeypatch.py
2
3181
""" TODO: drop patch when django-fsm package is updated. If model with FSM state field has other fields that access their field value via a property or a virtual Field, then creation of instances will fail. There is pending patch in upstream project: https://github.com/kmmbvnr/django-fsm/pull/171 """ __all__ = ['mon...
mit
9f33932a4eacfe1b17debeb07a92262a
30.186275
91
0.58818
4.19657
false
false
false
false
opennode/waldur-mastermind
src/waldur_vmware/backend.py
2
42600
import logging import ssl from urllib.parse import urlencode import pyVim.connect import pyVim.task from django.utils import timezone from django.utils.functional import cached_property from pyVmomi import vim from waldur_core.structure.backend import ServiceBackend, log_backend_action from waldur_core.structure.exce...
mit
68c34d03de223ab92666e263e3711e7d
33.975369
105
0.579319
4.190027
false
false
false
false
opennode/waldur-mastermind
src/waldur_mastermind/marketplace_script/tasks.py
2
1169
from celery import shared_task from django.conf import settings from waldur_mastermind.marketplace import models from waldur_mastermind.marketplace_script import PLUGIN_NAME, serializers, utils @shared_task(name='waldur_marketplace_script.pull_resources') def pull_resources(): for resource in models.Resource.obj...
mit
db268e7c0167ce9ae11281ffa5fa0989
35.53125
83
0.731394
3.807818
false
false
false
false
opennode/waldur-mastermind
src/waldur_core/core/management/commands/print_commands.py
1
1159
from argparse import ArgumentParser from django.core.management import get_commands, load_command_class from django.core.management.base import BaseCommand BLACK_LIST = [ 'print_commands', 'print_settings', 'print_features', 'print_schema', 'export_api_docs', 'print_events', 'print_templat...
mit
783962b0b8c8fe0f371fefc9b3897462
30.324324
74
0.553063
4.184116
false
false
false
false
getavalon/core
avalon/vendor/requests/packages/urllib3/util/request.py
189
3705
from __future__ import absolute_import from base64 import b64encode from ..packages.six import b, integer_types from ..exceptions import UnrewindableBodyError ACCEPT_ENCODING = 'gzip,deflate' _FAILEDTELL = object() def make_headers(keep_alive=None, accept_encoding=None, user_agent=None, basic_auth=...
mit
61aaa10ce3b5da58817a2bf6e86cf837
30.398305
85
0.607287
4.04918
false
false
false
false
getavalon/core
avalon/vendor/requests/packages/chardet/constants.py
2996
1335
######################## BEGIN LICENSE BLOCK ######################## # The Original Code is Mozilla Universal charset detector code. # # The Initial Developer of the Original Code is # Netscape Communications Corporation. # Portions created by the Initial Developer are Copyright (C) 2001 # the Initial Developer. All R...
mit
62207a1c313c12d640f08ce86194decc
33.230769
69
0.698876
4.224684
false
false
false
false
opennode/waldur-mastermind
src/waldur_openstack/openstack/urls.py
2
1139
from . import views def register_in(router): router.register(r'openstack-images', views.ImageViewSet, basename='openstack-image') router.register( r'openstack-flavors', views.FlavorViewSet, basename='openstack-flavor' ) router.register( r'openstack-volume-types', views.VolumeTy...
mit
abe4218c086dfb933d03728f95690b5d
32.5
88
0.681299
4.156934
false
false
false
false
opennode/waldur-mastermind
src/waldur_mastermind/invoices/migrations/0033_downtime_offering_and_resource.py
2
1087
# Generated by Django 2.2.10 on 2020-03-19 13:51 import django.db.models.deletion from django.db import migrations, models class Migration(migrations.Migration): dependencies = [ ('marketplace', '0013_increase_limit_range'), ('invoices', '0032_genericinvoiceitem_name'), ] operations = [...
mit
84fbb25fbc5ce6d71085ccb6b006608d
28.378378
62
0.532659
4.548117
false
false
false
false
opennode/waldur-mastermind
src/waldur_auth_social/migrations/0001_initial.py
2
1285
# Generated by Django 2.2.24 on 2021-08-09 12:51 import django.db.models.deletion from django.conf import settings from django.db import migrations, models class Migration(migrations.Migration): initial = True dependencies = [ migrations.swappable_dependency(settings.AUTH_USER_MODEL), ] op...
mit
3679217862011af2068e08643330d3b8
28.883721
68
0.451362
5.266393
false
false
false
false
opennode/waldur-mastermind
src/waldur_keycloak_rancher/tasks.py
1
1148
import logging from celery import shared_task from django.conf import settings from waldur_keycloak.models import ProjectGroup from waldur_rancher.enums import ClusterRoles from waldur_rancher.models import Cluster logger = logging.getLogger(__name__) @shared_task(name='waldur_keycloak_rancher.sync_groups') def sy...
mit
44ee67eac4eb2655403e15d16423442b
32.764706
85
0.614983
4.432432
false
false
false
false
opennode/waldur-mastermind
src/waldur_openstack/openstack_tenant/migrations/0006_error_traceback.py
2
1221
# Generated by Django 2.2.13 on 2020-10-07 11:12 from django.db import migrations, models class Migration(migrations.Migration): dependencies = [ ('openstack_tenant', '0005_internalip_allowed_address_pairs'), ] operations = [ migrations.AddField( model_name='backup', ...
mit
215153db030c5df01b287e9385eae423
27.395349
70
0.552007
4.660305
false
false
false
false
opennode/waldur-mastermind
src/waldur_mastermind/notifications/migrations/0001_initial.py
2
2134
# Generated by Django 2.2.13 on 2020-10-21 21:47 import django.contrib.postgres.fields.jsonb import django.db.models.deletion import django.utils.timezone import model_utils.fields from django.conf import settings from django.db import migrations, models import waldur_core.core.fields import waldur_core.core.validato...
mit
15ec61dc91198adc9e7adfc92f9f1bf0
30.382353
79
0.450328
5.295285
false
false
false
false
opennode/waldur-mastermind
src/waldur_core/quotas/tests/unittests/test_models.py
2
3811
import random from django.test import TestCase from waldur_core.quotas import exceptions from waldur_core.quotas.tests.models import GrandparentModel class QuotaModelMixinTest(TestCase): def test_default_quota_is_unlimited(self): instance = GrandparentModel.objects.create() self.assertEqual(inst...
mit
ca20b787c2032daf7a34bd5441154826
40.879121
88
0.640252
3.78827
false
true
false
false
opennode/waldur-mastermind
src/waldur_openstack/openstack_tenant/migrations/0020_create_or_update_security_group_rules.py
2
2671
from django.core.exceptions import MultipleObjectsReturned, ObjectDoesNotExist from django.db import migrations def create_or_update_security_group_rules(apps, schema_editor): SecurityGroupRuleResource = apps.get_model('openstack', 'SecurityGroupRule') SecurityGroupProperty = apps.get_model('openstack_tenant'...
mit
1377e7b8e1f6308c826924b99090fe59
40.092308
87
0.60277
4.795332
false
false
false
false
jorisroovers/gitlint
gitlint-core/gitlint/tests/config/test_config.py
1
13939
from unittest.mock import patch from gitlint import rules from gitlint.config import LintConfig, LintConfigError, LintConfigGenerator, GITLINT_CONFIG_TEMPLATE_SRC_PATH from gitlint import options from gitlint.tests.base import BaseTestCase class LintConfigTests(BaseTestCase): def test_set_rule_option(self): ...
mit
3f06da3b5e1f82db14d8ab03b9c5790a
43.025316
119
0.644192
3.973722
false
true
false
false
jorisroovers/gitlint
gitlint-core/gitlint/rules.py
1
17284
# pylint: disable=inconsistent-return-statements import copy import logging import re from gitlint.options import IntOption, BoolOption, StrOption, ListOption, RegexOption from gitlint.exception import GitlintError from gitlint.deprecation import Deprecation class Rule: """Class representing gitlint rules.""" ...
mit
304405d9f05d519deb6812a8bf10af59
34.345603
117
0.638567
3.924614
false
false
false
false
conan-io/conan
conans/test/integration/graph_lock/graph_lock_ci_test.py
1
53402
import json import os import textwrap import unittest from parameterized import parameterized import pytest from conans.model.graph_lock import LOCKFILE from conans.test.assets.genconanfile import GenConanfile from conans.test.utils.tools import TestClient, TestServer from conans.util.env_reader import get_env from c...
mit
18d50d8a2b02aed1f3894c333eb85a3a
50.947471
101
0.577544
3.285468
false
true
false
false
conan-io/conan
conans/client/generators/visualstudiolegacy.py
2
1518
from conans.model import Generator class VisualStudioLegacyGenerator(Generator): template = '''<?xml version="1.0" encoding="Windows-1252"?> <VisualStudioPropertySheet ProjectType="Visual C++" Version="8.00" Name="conanbuildinfo" > <Tool Name="VCCLCompilerTool" AdditionalOption...
mit
64e3eff28558c3f70afe8a8f851c470d
36.95
123
0.596838
3.973822
false
false
false
false
conan-io/conan
conans/test/integration/conanfile/generators_list_test.py
1
1976
import textwrap import unittest from conans.test.utils.tools import TestClient class ConanfileRepeatedGeneratorsTestCase(unittest.TestCase): def test_conanfile_txt(self): conanfile = textwrap.dedent(""" [generators] cmake CMakeDeps cmake """) ...
mit
96586e484fa151a69f0eda7f6d089004
29.875
72
0.555162
4.142558
false
true
false
false
conan-io/conan
conans/model/conan_file.py
1
18746
import os import platform from contextlib import contextmanager from pathlib import Path import six from six import string_types from conans.client import tools from conans.client.output import ScopedOutput from conans.client.subsystems import command_env_wrapper from conans.client.tools.env import environment_appen...
mit
4b4701655da69b09659e1c22e0e6c0fb
38.135699
101
0.636562
4.075217
false
false
false
false
choderalab/yank
Yank/cli.py
1
2974
#!/usr/local/bin/env python # ============================================================================================= # MODULE DOCSTRING # ============================================================================================= """ YANK command-line interface (cli) """ # =================================...
mit
c23240ecb4c89484f9721ccfdfc5a97d
35.716049
115
0.51883
5.06644
false
false
false
false
choderalab/yank
docs/sphinxext/notebook_sphinxext.py
1
5913
import os import shutil import glob from docutils import nodes from docutils.parsers.rst import directives, Directive from nbconvert.exporters import html, python from runipy.notebook_runner import NotebookRunner HERE = os.path.dirname(os.path.abspath(__file__)) IPYTHON_NOTEBOOK_DIR = "%s/../../examples" % HERE cl...
mit
840ac0e20be25f939823acda11ed2f3c
31.668508
115
0.616607
3.590164
false
false
false
false
choderalab/yank
Yank/commands/help.py
2
1644
#!/usr/local/bin/env python # ============================================================================================= # MODULE DOCSTRING # ============================================================================================= """ Print YANK help. """ # ==================================================...
mit
237481ee77403ac52ad485ce671704ba
28.357143
95
0.332117
6.447059
false
false
false
false
choderalab/yank
Yank/analyze.py
1
51715
#!/usr/local/bin/env python # ============================================================================== # MODULE DOCSTRING # ============================================================================== """ Analyze ======= YANK Specific analysis tools for YANK simulations from the :class:`yank.yank.AlchemicalP...
mit
e08ebfe427c742a10b4d5b815b11d2bb
42.024126
149
0.588978
4.213035
false
false
false
false
aleju/imgaug
checks/check_directed_edge_detect.py
2
1111
from __future__ import print_function, division from itertools import cycle import numpy as np from skimage import data import cv2 from imgaug import augmenters as iaa POINT_SIZE = 5 DEG_PER_STEP = 1 TIME_PER_STEP = 10 def main(): image = data.astronaut() cv2.namedWindow("aug", cv2.WINDOW_NORMAL) cv2....
mit
a193d846cdb7a942e739f737cc01a339
24.837209
103
0.612961
2.900783
false
false
false
false
aleju/imgaug
imgaug/external/opensimplex.py
3
79631
""" This is a copy of the OpenSimplex library, based on commit d861cb290531ad15825f21dc4cc35c5d4f407259 from 20.07.2017. """ # Based on: https://gist.github.com/KdotJPG/b1270127455a94ac5d19 import sys from ctypes import c_long from math import floor as _floor if sys.version_info[0] < 3: def floor(num): ...
mit
9b8d99bbd163dc159aa1585d40127aeb
40.17425
132
0.408107
3.089706
false
false
false
false
aliyun/aliyun-oss-python-sdk
examples/sign_v2.py
1
3178
# -*- coding: utf-8 -*- import os import oss2 import requests import datetime import time import hashlib import hmac # 下面的代码展示了使用OSS V2签名算法来对请求进行签名 # 首先,初始化AccessKeyId、AccessKeySecret和Endpoint. # 你可以通过设置环境变量来设置access_key_id等, 或者直接使用真实access_key_id替换'<Your AccessKeyId>'等 # # 以杭州(华东1)作为例子, endpoint应该是 # http://oss...
mit
b0493bb4e87ed73bf95385d45ed84abc
29.813187
129
0.702211
2.294599
false
false
false
false
aleju/imgaug
test/test_multicore.py
2
39854
from __future__ import print_function, division, absolute_import import time import multiprocessing import pickle from collections import defaultdict import warnings import sys # unittest only added in 3.4 self.subTest() if sys.version_info[0] < 3 or sys.version_info[1] < 4: import unittest2 as unittest else: ...
mit
5713d09dec56ac0ca0461b56fa614880
39.584521
81
0.565263
3.861448
false
true
false
false
aleju/imgaug
checks/check_multicore_pool.py
2
13915
from __future__ import print_function, division import time import multiprocessing import numpy as np from skimage import data import imgaug as ia import imgaug.multicore as multicore from imgaug import augmenters as iaa class PoolWithMarkedWorker(multicore.Pool): def __init__(self, *args, **kwargs): s...
mit
47f1bc1b9b173b232de0b3a5a1b4c7eb
36.007979
118
0.55839
3.455426
false
true
false
false
voc/voctomix
voctocore/lib/overlay.py
1
1937
#!/usr/bin/env python3 from gi.repository import Gst, GstController import logging import gi gi.require_version('GstController', '1.0') class Overlay: log = logging.getLogger('Overlay') def __init__(self, pipeline, location=None, blend_time=300): # get overlay element and config self.overlay ...
mit
7b986bf5aaf2940c00f2cbe2ec06d541
35.54717
110
0.621064
4.165591
false
false
false
false
voc/voctomix
voctocore/lib/sources/decklinkavsource.py
1
3283
#!/usr/bin/env python3 import logging import re from lib.config import Config from lib.sources.avsource import AVSource class DeckLinkAVSource(AVSource): timer_resolution = 0.5 def __init__(self, name, has_audio=True, has_video=True): super().__init__('DecklinkAVSource', name, has_audio, has_video,...
mit
0d3c6856f8cb1c1edfd4d95ef2e0e1bf
30.266667
93
0.521779
4.236129
false
true
false
false
voc/voctomix
example-scripts/voctolight/voctolight.py
1
2682
#!/usr/bin/env python3 import socket from lib.config import Config import time import re DO_GPIO = True try: import RPi.GPIO as GPIO GPIO.setmode(GPIO.BOARD) except ModuleNotFoundError: DO_GPIO = False class TallyHandling: def __init__(self, source, gpio_port, all_gpios=()): self.source = so...
mit
1130eae57c7a67265a159cb4d9953a11
25.82
103
0.530947
3.74581
false
true
false
false
voc/voctomix
vocto/config.py
1
17747
#!/usr/bin/env python3 import logging import re import os from gi.repository import Gst from configparser import SafeConfigParser from lib.args import Args from vocto.transitions import Composites, Transitions from vocto.audio_streams import AudioStreams from vocto import kind_has_audio, kind_has_video testPatternCou...
mit
575d86455506a276deb63977156f7f45
34.636546
128
0.606919
3.984508
false
false
false
false
simpeg/simpeg
tutorials/03-gravity/plot_inv_1b_gravity_anomaly_irls.py
1
14070
""" Sparse Norm Inversion of Gravity Anomaly Data ============================================= Here we invert gravity anomaly data to recover a density contrast model. We formulate the inverse problem as an iteratively re-weighted least-squares (IRLS) optimization problem. For this tutorial, we focus on the following...
mit
eb3600d9bdd97455546cad7f7438d87f
30.904762
123
0.650888
3.350798
false
false
false
false
simpeg/simpeg
SimPEG/fields.py
1
13551
import numpy as np from .simulation import BaseSimulation, BaseTimeSimulation from .utils import mkvc, validate_type class Fields: """Fancy Field Storage .. code::python fields = Fields( simulation=simulation, knownFields={"phi": "CC"} ) fields[:,'phi'] = phi print...
mit
bfd53309a8eca4207f60ed9b5f141930
31.890777
90
0.546676
4.1593
false
false
false
false
santoshphilip/eppy
eppy/idfreader.py
1
10391
# Copyright (c) 2012, 2022 Santosh Philip # Copyright (c) 2021 Dimitris Mantas # ======================================================================= # Distributed under the MIT License. # (See accompanying file LICENSE or copy at # http://opensource.org/licenses/MIT) # ==========================================...
mit
6aa6d4127023761d7e42701bc0064983
30.679878
82
0.587335
3.386897
false
false
false
false
simpeg/simpeg
tutorials/06-ip/plot_fwd_2_dcip2d.py
1
16333
# -*- coding: utf-8 -*- """ 2.5D Forward Simulation of a DCIP Line ====================================== Here we use the module *SimPEG.electromagnetics.static.resistivity* to predict DC resistivity data and the module *SimPEG.electromagnetics.static.induced_polarization* to predict IP data for a dipole-dipole survey...
mit
bb3db0e6311f9f079dc58fe614c0bbb1
30.349328
88
0.65536
3.224679
false
false
false
false
simpeg/simpeg
SimPEG/electromagnetics/frequency_domain/receivers.py
1
12700
from ... import survey from ...utils import validate_string, validate_type, validate_direction import warnings from discretize.utils import Zero class BaseRx(survey.BaseRx): """Base FDEM receivers class. Parameters ---------- locations : (n_loc, n_dim) numpy.ndarray Receiver locations. or...
mit
1a14dc7bfd7bbaeaa46d1b2268cfd785
30.75
91
0.570945
4.220671
false
false
false
false
simpeg/simpeg
SimPEG/_EM/Static/SP/ProblemSP.py
1
5508
from SimPEG import Problem, Utils, Maps, Mesh from SimPEG.EM.Base import BaseEMProblem from SimPEG.EM.Static.DC.FieldsDC import FieldsDC, Fields3DCellCentered from SimPEG.EM.Static.DC import Survey, BaseDCProblem, Simulation3DCellCentered from SimPEG.Utils import sdiag import numpy as np import scipy.sparse as sp from ...
mit
645ab8e77dbf761bd100fe6144ecc941
26.818182
79
0.544481
3.404203
false
false
false
false
simpeg/simpeg
tutorials/08-tdem/plot_fwd_2_tem_cyl.py
1
8158
""" 3D Forward Simulation for Transient Response on a Cylindrical Mesh ================================================================== Here we use the module *SimPEG.electromagnetics.time_domain* to simulate the transient response for borehole survey using a cylindrical mesh and a radially symmetric conductivity. ...
mit
689723a23111fc81dd166a164e54c68e
32.02834
104
0.646237
3.29483
false
false
false
false
willmcgugan/rich
examples/log.py
1
1943
""" A simulation of Rich console logging. """ import time from rich.console import Console from rich.style import Style from rich.theme import Theme from rich.highlighter import RegexHighlighter class RequestHighlighter(RegexHighlighter): base_style = "req." highlights = [ r"^(?P<protocol>\w+) (?P<me...
mit
6254b2fcfa434fff75ee01e27eb9b601
24.233766
95
0.530623
3.074367
false
false
false
false
willmcgugan/rich
rich/screen.py
1
1579
from typing import Optional, TYPE_CHECKING from .segment import Segment from .style import StyleType from ._loop import loop_last if TYPE_CHECKING: from .console import ( Console, ConsoleOptions, RenderResult, RenderableType, Group, ) class Screen: """A renderabl...
mit
ea219563ca6797cdcad0b208dd407479
28.240741
81
0.621279
4.048718
false
false
false
false
willmcgugan/rich
rich/_windows.py
1
2076
import sys from dataclasses import dataclass @dataclass class WindowsConsoleFeatures: """Windows features available.""" vt: bool = False """The console supports VT codes.""" truecolor: bool = False """The console supports truecolor.""" try: import ctypes from ctypes import wintypes ...
mit
0cc3c7e489d304262b208bbfa1f3d99d
27.054054
85
0.658478
4.325
false
false
false
false
willmcgugan/rich
rich/palette.py
1
3288
from math import sqrt from functools import lru_cache from typing import Sequence, Tuple, TYPE_CHECKING from .color_triplet import ColorTriplet if TYPE_CHECKING: from rich.table import Table class Palette: """A palette of available colors.""" def __init__(self, colors: Sequence[Tuple[int, int, int]]): ...
mit
22a3e4bade659d644f7c9a3b1a228790
31.86
82
0.532562
4.002436
false
false
false
false
willmcgugan/rich
rich/table.py
1
35052
from dataclasses import dataclass, field, replace from typing import ( Dict, TYPE_CHECKING, Iterable, List, NamedTuple, Optional, Sequence, Tuple, Union, ) from . import box, errors from ._loop import loop_first_last, loop_last from ._pick import pick_bool from ._ratio import ratio_...
mit
e4e86d7471968b74e28943061793f7b6
36.935065
171
0.553863
4.225169
false
false
false
false
danforthcenter/plantcv
plantcv/plantcv/transform/nonuniform_illumination.py
1
1443
# Correct for nonuniform illumination import os import cv2 import numpy as np from plantcv.plantcv import params from plantcv.plantcv import rgb2gray from plantcv.plantcv import gaussian_blur from plantcv.plantcv.transform import rescale from plantcv.plantcv._debug import _debug def nonuniform_illumination(img, ksiz...
mit
916e9e099bf28835096ad46864362a22
28.44898
126
0.702703
3.452153
false
false
false
false
danforthcenter/plantcv
plantcv/plantcv/analyze_thermal_values.py
1
3672
# Analyze signal data in Thermal image import os import numpy as np from plantcv.plantcv import deprecation_warning, params from plantcv.plantcv import outputs from plantcv.plantcv._debug import _debug from plantcv.plantcv.visualize import histogram from plotnine import labs def analyze_thermal_values(thermal_array,...
mit
8415a0d11d83f851b1988be479d8dc7b
44.9
116
0.668301
4.196571
false
false
false
false
danforthcenter/plantcv
plantcv/plantcv/cluster_contour_mask.py
1
2561
# cluster objects and split into masks def cluster_contour_mask(rgb_img, clusters_i, contours, hierarchies): """Outputs masks for the grouped clusters. Since there can be a variable number of clusters/masks the output is a list of arrays. Inputs: rgb_img = RGB image data clusters_i = clu...
mit
3bcb41c2206b2abe598cbc345f94cd3c
39.015625
122
0.591566
3.446837
false
false
false
false
danforthcenter/plantcv
tests/parallel/test_process_results.py
1
1903
import pytest import os from plantcv.parallel import process_results def test_process_results(parallel_test_data, tmpdir): """Test for PlantCV.""" # Create a test tmp directory and results file result_file = tmpdir.mkdir("sub").join("appended_results.json") # Run twice to create appended results p...
mit
038e59758c32ad2ea394314485b63b5e
43.255814
118
0.729375
3.695146
false
true
false
false
danforthcenter/plantcv
plantcv/plantcv/morphology/find_branch_pts.py
1
3836
# Find branch points from skeleton image import os import cv2 import numpy as np from plantcv.plantcv import params from plantcv.plantcv import dilate from plantcv.plantcv import outputs from plantcv.plantcv import find_objects from plantcv.plantcv._debug import _debug def find_branch_pts(skel_img, mask=None, label=...
mit
6bdd9206b1a385b940476b1c92bef827
34.518519
119
0.593587
3.178128
false
false
false
false
danforthcenter/plantcv
plantcv/plantcv/plot_image.py
1
1243
# Plot image to screen import cv2 import numpy import matplotlib from plantcv.plantcv import fatal_error, params from matplotlib import pyplot as plt def plot_image(img, cmap=None): """Plot an image to the screen. :param img: numpy.ndarray :param cmap: str :return: """ image_type = type(img) ...
mit
495a48364752a753da5940360b53ae23
27.906977
102
0.612228
3.789634
false
false
false
false
danforthcenter/plantcv
plantcv/learn/naive_bayes.py
1
9072
# Naive Bayes import os import cv2 import numpy as np from scipy import stats from matplotlib import pyplot as plt def naive_bayes(imgdir, maskdir, outfile, mkplots=False): """Naive Bayes training function Inputs: imgdir = Path to a directory of original 8-bit RGB images. maskdir = Path to a direct...
mit
5be86ec76611b8fd13cb483f93788fb9
47.255319
117
0.597663
4.071813
false
false
false
false
danforthcenter/plantcv
plantcv/plantcv/image_fusion.py
1
3547
# Fuse two images import os import numpy as np from skimage import img_as_ubyte from plantcv.plantcv import fatal_error from plantcv.plantcv import Spectral_data from plantcv.plantcv import params from plantcv.plantcv.hyperspectral.read_data import _make_pseudo_rgb from plantcv.plantcv._debug import _debug def image...
mit
403e7f7dcee90a667641a93d4227a007
34.47
119
0.634903
3.56841
false
false
false
false
danforthcenter/plantcv
plantcv/plantcv/hyperspectral/_avg_reflectance.py
1
1205
# Calculate masked average background reflectance import numpy as np def _avg_reflectance(spectral_data, mask): """Find average reflectance of masked hyperspectral data instance. This is useful for calculating a target signature (n_band x 1 - column array) which is required in various GatorSense hyperspe...
mit
403e0c526f0f09d64fe4411bf47c7e0b
32.472222
121
0.673029
3.899676
false
false
false
false
danforthcenter/plantcv
tests/plantcv/test_landmark_reference_pt_dist.py
1
1217
import pytest import numpy as np from plantcv.plantcv import landmark_reference_pt_dist, outputs @pytest.mark.parametrize("points,centroid,bline", [ [[(10, 1000)], (10, 10), (10, 10)], [[], (0, 0), (0, 0)], [[(0.0139, 0.2569), (0.2361, 0.2917), (0.3542, 0.3819), (0.3542, 0.4167), (0.375, 0.4236), (0.7431,...
mit
6b2bda21f9bb301fa0f1a4fed3708511
45.807692
113
0.604766
2.363107
false
true
false
false
danforthcenter/plantcv
plantcv/plantcv/transform/color_correction.py
1
34122
# Color Corrections Functions import os import cv2 import numpy as np from plantcv.plantcv import params from plantcv.plantcv import outputs from plantcv.plantcv.roi import circle from plantcv.plantcv import fatal_error from plantcv.plantcv._debug import _debug def get_color_matrix(rgb_img, mask): """Calculate t...
mit
cd84424f244a6797ba273c03fefccb1f
43.028387
120
0.634019
3.572236
false
false
false
false
danforthcenter/plantcv
plantcv/plantcv/morphology/segment_path_length.py
1
2068
# Find geodesic lengths of skeleton segments import os import cv2 from plantcv.plantcv import params from plantcv.plantcv import outputs from plantcv.plantcv._debug import _debug def segment_path_length(segmented_img, objects, label="default"): """Use segments to calculate geodesic distance per segment. Inp...
mit
7113aef2820287c9f088bde3db03f2a9
37.296296
119
0.66441
3.739602
false
false
false
false
danforthcenter/plantcv
plantcv/plantcv/output_mask_ori_img.py
1
1887
# Find NIR image import os from plantcv.plantcv import print_image from plantcv.plantcv import params from plantcv.plantcv._debug import _debug def output_mask(img, mask, filename, outdir=None, mask_only=False): """Prints ori image and mask to directories. Inputs: img = original image, read in with plan...
mit
3313d3d540e7b486e0d0ad0870d14dda
29.934426
102
0.671436
3.621881
false
false
false
false
danforthcenter/plantcv
plantcv/plantcv/morphology/segment_combine.py
1
2804
# Plot segment ID numbers after combining segments import os import cv2 import numpy as np from plantcv.plantcv import params from plantcv.plantcv import fatal_error from plantcv.plantcv import color_palette from plantcv.plantcv._debug import _debug def segment_combine(segment_list, objects, mask): """Combine us...
mit
c3d1f2b11124e1d28f42b0b341fcec90
35.415584
119
0.677247
3.641558
false
false
false
false
danforthcenter/plantcv
plantcv/plantcv/rgb2gray_cmyk.py
2
1727
# RGB -> CMYK -> Gray import cv2 import os from plantcv.plantcv._debug import _debug from plantcv.plantcv import fatal_error from plantcv.plantcv import params import numpy as np def rgb2gray_cmyk(rgb_img, channel): """Convert image from RGB colorspace to CMYK colorspace. Returns the specified subchannel as a gr...
mit
1a4c9998c3c87f85bc8825cbab8d1816
29.298246
116
0.583092
3.198148
false
false
false
false
chainer/chainercv
chainercv/evaluations/eval_instance_segmentation_coco.py
3
12753
import itertools import numpy as np import os import six from chainercv.evaluations.eval_detection_coco import _redirect_stdout from chainercv.evaluations.eval_detection_coco import _summarize try: import pycocotools.coco import pycocotools.cocoeval import pycocotools.mask as mask_tools _available = T...
mit
2b9d6c75e41e79e57e5ca1bc798f6013
41.939394
77
0.555085
3.105186
false
false
false
false
chainer/chainercv
chainercv/extensions/evaluator/semantic_segmentation_evaluator.py
3
4741
import copy import numpy as np from chainer import reporter import chainer.training.extensions from chainercv.evaluations import eval_semantic_segmentation from chainercv.utils import apply_to_iterator class SemanticSegmentationEvaluator(chainer.training.extensions.Evaluator): """An extension that evaluates a ...
mit
f37209ca1ec08979b6c64ad6a969ef80
38.840336
78
0.61949
4.031463
false
false
false
false
chainer/chainercv
chainercv/links/connection/conv_2d_bn_activ.py
3
4690
import chainer from chainer.functions import relu from chainer.links import BatchNormalization from chainer.links import Convolution2D try: from chainermn.links import MultiNodeBatchNormalization except ImportError: pass class Conv2DBNActiv(chainer.Chain): """Convolution2D --> Batch Normalization --> Act...
mit
75e9ee9b72280cd045269ea1a6e9ae1f
42.425926
79
0.625373
4.074718
false
false
false
false
chainer/chainercv
examples/classification/eval_imagenet.py
2
4065
import argparse import numpy as np import chainer import chainer.functions as F from chainer import iterators from chainercv.datasets import directory_parsing_label_names from chainercv.datasets import DirectoryParsingLabelDataset from chainercv.links import FeaturePredictor from chainercv.links import MobileNetV2 f...
mit
b1ae437c6249fe810d36df83a71d6003
34.043103
79
0.666913
3.50431
false
false
false
false
sixty-north/cosmic-ray
tests/resources/example_project/adam/adam_2.py
1
1630
"""adam.adam_2 """ # pylint: disable=C0111 import ctypes import functools import operator def trigger_infinite_loop(): result = None # When `break` becomes `continue`, this should enter an infinite loop. This # helps us test timeouts. # Any object which isn't None passes the truth value testing so h...
mit
e5c44ab41662333b2e49384f7aee069e
21.328767
79
0.648466
3.890215
false
false
false
false
spesmilo/electrum
electrum/gui/qml/qeinvoice.py
1
21812
import threading import asyncio from urllib.parse import urlparse from PyQt5.QtCore import pyqtProperty, pyqtSignal, pyqtSlot, QObject, Q_ENUMS from electrum import bitcoin from electrum import lnutil from electrum.i18n import _ from electrum.invoices import Invoice from electrum.invoices import (PR_UNPAID, PR_EXPIRE...
mit
875ed951a5fbff2cacffe6baa538841d
34.757377
138
0.59669
4.177744
false
false
false
false
spesmilo/electrum
electrum/gui/kivy/main_window.py
1
60400
import re import os import sys import time import datetime import traceback from decimal import Decimal import threading import asyncio from typing import TYPE_CHECKING, Optional, Union, Callable, Sequence from electrum.storage import WalletStorage, StorageReadWriteError from electrum.wallet_db import WalletDB from el...
mit
53462c8a9ca56f83cd37bf1c4c9e81ba
38.554682
156
0.596987
3.905088
false
false
false
false
spesmilo/electrum
electrum/dns_hacks.py
3
4577
# Copyright (C) 2020 The Electrum developers # Distributed under the MIT software license, see the accompanying # file LICENCE or http://www.opensource.org/licenses/mit-license.php import sys import socket import concurrent from concurrent import futures import ipaddress from typing import Optional import dns import ...
mit
538ab0a6ca2853239217fd803dbe5394
39.149123
106
0.630544
3.959343
false
false
false
false
spesmilo/electrum
electrum/wallet.py
1
152055
# Electrum - lightweight Bitcoin client # Copyright (C) 2015 Thomas Voegtlin # # Permission is hereby granted, free of charge, to any person # obtaining a copy of this software and associated documentation files # (the "Software"), to deal in the Software without restriction, # including without limitation the rights t...
mit
6e4d65a2043a2e44d535dcad074fbd2c
41.038983
150
0.586209
3.835027
false
false
false
false
spesmilo/electrum
electrum/plugins/keepkey/keepkey.py
1
20302
from binascii import hexlify, unhexlify import traceback import sys from typing import NamedTuple, Any, Optional, Dict, Union, List, Tuple, TYPE_CHECKING from electrum.util import bfh, bh2u, UserCancelled, UserFacingException from electrum.bip32 import BIP32Node from electrum import constants from electrum.i18n import...
mit
82792b109cf479dbf5b959804b6b998f
40.602459
122
0.591912
3.881093
false
false
false
false
spesmilo/electrum
electrum/synchronizer.py
2
13220
#!/usr/bin/env python # # Electrum - lightweight Bitcoin client # Copyright (C) 2014 Thomas Voegtlin # # 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...
mit
c00384fc13e7cc53c3ec959b0ee7355c
42.774834
122
0.639637
4.050245
false
false
false
false
spesmilo/electrum
electrum/plugins/keepkey/qt.py
1
23765
from functools import partial import threading from PyQt5.QtCore import Qt, QEventLoop, pyqtSignal, QRegExp from PyQt5.QtGui import QRegExpValidator from PyQt5.QtWidgets import (QVBoxLayout, QLabel, QGridLayout, QPushButton, QHBoxLayout, QButtonGroup, QGroupBox, QDialog, ...
mit
45124adb215441b7ea95f3f7e30e2fe3
40.402439
95
0.597686
4.033435
false
false
false
false
spesmilo/electrum
electrum/plugins/jade/qt.py
1
1301
from functools import partial from PyQt5.QtCore import pyqtSignal from PyQt5.QtWidgets import QLabel, QVBoxLayout from electrum.i18n import _ from electrum.plugin import hook from electrum.wallet import Standard_Wallet from electrum.gui.qt.util import WindowModalDialog from .jade import JadePlugin from ..hw_wallet.q...
mit
65f0e273682da96e8660a84e737d837d
30.731707
81
0.692544
3.574176
false
false
false
false
spesmilo/electrum
electrum/gui/qt/qrreader/qtmultimedia/crop_blur_effect.py
4
2982
#!/usr/bin/env python3 # # Electron Cash - lightweight Bitcoin client # Copyright (C) 2019 Axel Gembe <derago@gmail.com> # # Permission is hereby granted, free of charge, to any person # obtaining a copy of this software and associated documentation files # (the "Software"), to deal in the Software without restriction,...
mit
61dd3c2bd40569e24845651223814b3d
37.727273
87
0.705567
3.867704
false
false
false
false