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
numpy/numpy
numpy/core/tests/test_dtype.py
4
72106
import sys import operator import pytest import ctypes import gc import types from typing import Any import numpy as np from numpy.core._rational_tests import rational from numpy.core._multiarray_tests import create_custom_field_dtype from numpy.testing import ( assert_, assert_equal, assert_array_equal, assert_ra...
bsd-3-clause
066aab2e4d477ef0fd38230b3db16653
38.662266
96
0.519652
3.615423
false
true
false
false
numpy/numpy
benchmarks/benchmarks/bench_function_base.py
8
10349
from .common import Benchmark import numpy as np class Linspace(Benchmark): def setup(self): self.d = np.array([1, 2, 3]) def time_linspace_scalar(self): np.linspace(0, 10, 2) def time_linspace_array(self): np.linspace(self.d, 10, 10) class Histogram1D(Benchmark): def setup(...
bsd-3-clause
811cb6f2f797dc0d95da98e35a76d44f
26.523936
95
0.566721
3.31274
false
false
false
false
numpy/numpy
numpy/random/__init__.py
18
7506
""" ======================== Random Number Generation ======================== Use ``default_rng()`` to create a `Generator` and call its methods. =============== ========================================================= Generator --------------- --------------------------------------------------------- Generator ...
bsd-3-clause
7b1a0a887c799830a6bf1937a5f0b4e9
33.911628
81
0.493472
5.308345
false
false
false
false
numpy/numpy
doc/source/conf.py
6
15714
import os import re import sys import importlib # Minimum version, enforced by sphinx needs_sphinx = '4.3' # This is a nasty hack to use platform-agnostic names for types in the # documentation. # must be kept alive to hold the patched names _name_cache = {} def replace_scalar_type_names(): """ Rename numpy ty...
bsd-3-clause
8773690fc608036e0865e0dfe4a2f99d
29.872299
90
0.584002
3.753045
false
false
false
false
numpy/numpy
numpy/lib/_datasource.py
11
22643
"""A file interface for handling local and remote data files. The goal of datasource is to abstract some of the file system operations when dealing with data files so the researcher doesn't have to know all the low-level details. Through datasource, a researcher can obtain and use a file with one function call, regar...
bsd-3-clause
1d491084a85a1f296df2caf874d2f3a2
31.163352
80
0.584507
4.422461
false
false
false
false
numpy/numpy
numpy/random/_examples/cffi/parse.py
19
1829
import os def parse_distributions_h(ffi, inc_dir): """ Parse distributions.h located in inc_dir for CFFI, filling in the ffi.cdef Read the function declarations without the "#define ..." macros that will be filled in when loading the library. """ with open(os.path.join(inc_dir, 'random', 'bi...
bsd-3-clause
b94630937f555685364f426e314ffebd
32.254545
78
0.50082
4.43932
false
false
false
false
numpy/numpy
numpy/distutils/line_endings.py
24
2032
""" Functions for converting from DOS to UNIX line endings """ import os import re import sys def dos2unix(file): "Replace CRLF with LF in argument files. Print names of changed files." if os.path.isdir(file): print(file, "Directory!") return with open(file, "rb") as fp: data = ...
bsd-3-clause
f1c9e2bf20046479fe2938de5ff087d6
25.38961
76
0.57185
3.309446
false
false
false
false
numpy/numpy
numpy/core/_dtype_ctypes.py
24
3673
""" Conversion from ctypes to dtype. In an ideal world, we could achieve this through the PEP3118 buffer protocol, something like:: def dtype_from_ctypes_type(t): # needed to ensure that the shape of `t` is within memoryview.format class DummyStruct(ctypes.Structure): _fields_ = [('a',...
bsd-3-clause
8aabe9076accd3b6775dd593d381b6ed
30.393162
103
0.612034
3.886772
false
false
false
false
numpy/numpy
numpy/testing/_private/extbuild.py
7
7816
""" Build a c-extension module on-the-fly in tests. See build_and_import_extensions for usage hints """ import os import pathlib import sys import sysconfig __all__ = ['build_and_import_extension', 'compile_extension_module'] def build_and_import_extension( modname, functions, *, prologue="", build_dir=Non...
bsd-3-clause
5d501b25fadc8c618283de17bd4eff25
30.139442
79
0.597492
3.98369
false
false
false
false
numpy/numpy
numpy/core/code_generators/generate_umath_doc.py
12
1165
import sys import os import textwrap sys.path.insert(0, os.path.dirname(__file__)) import ufunc_docstrings as docstrings sys.path.pop(0) def normalize_doc(docstring): docstring = textwrap.dedent(docstring).strip() docstring = docstring.encode('unicode-escape').decode('ascii') docstring = docstring.replace...
bsd-3-clause
71464fde7b445a0c60554e4169453fc1
37.833333
74
0.63691
3.488024
false
false
false
false
numpy/numpy
numpy/lib/arraysetops.py
8
32951
""" Set operations for arrays based on sorting. Notes ----- For floating point arrays, inaccurate results may appear due to usual round-off and floating point comparison issues. Speed could be gained in some operations by an implementation of `numpy.sort`, that can provide directly the permutation vectors, thus avoi...
bsd-3-clause
0281cbdf0dae6fa1fbdd9f0ad63cf9cc
33.146114
83
0.598313
3.680853
false
false
false
false
numpy/numpy
tools/ci/push_docs_to_repo.py
5
2248
#!/usr/bin/env python3 import argparse import subprocess import tempfile import os import sys import shutil parser = argparse.ArgumentParser( description='Upload files to a remote repo, replacing existing content' ) parser.add_argument('dir', help='directory of which content will be uploaded') parser.add_argumen...
bsd-3-clause
1c35b1a1a14c29869c8f6f32d77a2fb9
32.058824
78
0.657473
3.50702
false
false
false
false
numpy/numpy
numpy/ma/mrecords.py
12
27232
""":mod:`numpy.ma..mrecords` Defines the equivalent of :class:`numpy.recarrays` for masked arrays, where fields can be accessed as attributes. Note that :class:`numpy.ma.MaskedArray` already supports structured datatypes and the masking of individual fields. .. moduleauthor:: Pierre Gerard-Marchant """ # We should ...
bsd-3-clause
fbf19899a3e2d1f35ccef07cb931218b
33.779055
82
0.553981
4.180534
false
false
false
false
r0x0r/pywebview
webview/platforms/edgehtml.py
1
6348
# -*- coding: utf-8 -*- """ (C) 2014-2019 Roman Sirokov and contributors Licensed under BSD license http://github.com/r0x0r/pywebview/ """ import os import sys import logging import json import shutil import tempfile import webbrowser from threading import Event, Semaphore from ctypes import windll from webview imp...
bsd-3-clause
638b46eda88ea7a145c322ef775d41af
32.946524
150
0.633743
3.682135
false
false
false
false
django-oscar/django-oscar
src/oscar/templatetags/image_tags.py
3
4212
import logging import re from django import template from django.conf import settings from django.db.models.fields.files import ImageFieldFile from django.utils.encoding import smart_str from django.utils.html import escape from oscar.core.thumbnails import get_thumbnailer register = template.Library() kw_pat = re.c...
bsd-3-clause
12bd648ef7432f8dadbb26640ad695be
29.085714
74
0.549383
4.105263
false
false
false
false
django-oscar/django-oscar
tests/integration/catalogue/test_attributes.py
1
8626
from datetime import date, datetime from django.core.exceptions import ValidationError from django.core.files.uploadedfile import SimpleUploadedFile from django.test import TestCase from oscar.apps.catalogue.models import Product, ProductAttribute, ProductClass from oscar.test import factories class TestContainer(T...
bsd-3-clause
a85dc86fe2838a12d3689727cfa35fd3
34.941667
103
0.676327
3.926263
false
true
false
false
django-oscar/django-oscar
src/oscar/apps/offer/abstract_models.py
1
41948
import csv import operator from decimal import ROUND_DOWN from decimal import Decimal as D from django.conf import settings from django.core import exceptions from django.db import models from django.db.models.query import Q from django.template.defaultfilters import date as date_filter from django.urls import reverse...
bsd-3-clause
bea37d1deac2ec0a9a498fd6a12b1e60
36.155004
112
0.602651
4.382823
false
false
false
false
django-oscar/django-oscar
src/oscar/apps/customer/forms.py
2
15245
import datetime import string from django import forms from django.conf import settings from django.contrib.auth import forms as auth_forms from django.contrib.auth.forms import AuthenticationForm from django.contrib.auth.password_validation import validate_password from django.contrib.sites.shortcuts import get_curre...
bsd-3-clause
2e73962b6f26761b8cc727d3803f9de3
36.457002
87
0.592194
4.453696
false
false
false
false
django/django
tests/migrations/test_multidb.py
17
7062
from django.db import connection, migrations, models from django.db.migrations.state import ProjectState from django.test import override_settings from .test_base import OperationTestBase class AgnosticRouter: """ A router that doesn't have an opinion regarding migrating. """ def allow_migrate(self,...
bsd-3-clause
6bc0ca7404a5414759ee03e01107562a
36.764706
86
0.640753
3.786595
false
true
false
false
django/django
django/contrib/gis/db/backends/base/operations.py
17
6778
from django.contrib.gis.db.models import GeometryField from django.contrib.gis.db.models.functions import Distance from django.contrib.gis.measure import Area as AreaMeasure from django.contrib.gis.measure import Distance as DistanceMeasure from django.db import NotSupportedError from django.utils.functional import cac...
bsd-3-clause
3fc1c61a26e067f41a57e2ec092be715
31.902913
85
0.604161
4.60775
false
false
false
false
django/django
tests/syndication_tests/feeds.py
14
7949
from functools import wraps from django.contrib.syndication import views from django.utils import feedgenerator from django.utils.timezone import get_fixed_timezone from .models import Article, Entry def wraps_decorator(f): @wraps(f) def wrapper(*args, **kwargs): value = f(*args, **kwargs) r...
bsd-3-clause
6964e1a67a42b7d5347f9b3c716c8088
24.155063
88
0.654925
3.717961
false
true
false
false
django/django
django/db/migrations/state.py
11
40654
import copy from collections import defaultdict from contextlib import contextmanager from functools import partial from django.apps import AppConfig from django.apps.registry import Apps from django.apps.registry import apps as global_apps from django.conf import settings from django.core.exceptions import FieldDoesN...
bsd-3-clause
b4f32ee299b9ec624a14f44d46f966cb
40.147773
88
0.580902
4.202833
false
false
false
false
django/django
tests/m2m_through/models.py
17
4645
from datetime import datetime from django.db import models # M2M described on one of the models class Person(models.Model): name = models.CharField(max_length=128) class Meta: ordering = ("name",) class PersonChild(Person): pass class Group(models.Model): name = models.CharField(max_leng...
bsd-3-clause
3530b473266ed2867948e5a16e80e288
28.585987
88
0.683961
3.829349
false
false
false
false
django/django
tests/nested_foreign_keys/tests.py
17
11248
from django.test import TestCase from .models import ( Event, Movie, Package, PackageNullFK, Person, Screening, ScreeningNullFK, ) # These are tests for #16715. The basic scheme is always the same: 3 models with # 2 relations. The first relation may be null, while the second is non-nullab...
bsd-3-clause
e3ffbd97b3799e49e841fba77714c8df
35.519481
88
0.589616
4.175204
false
true
false
false
django/django
tests/view_tests/generic_urls.py
17
1324
from django.contrib.auth import views as auth_views from django.urls import path from django.views.generic import RedirectView from . import views from .models import Article, DateArticle date_based_info_dict = { "queryset": Article.objects.all(), "date_field": "date_created", "month_format": "%m", } obj...
bsd-3-clause
4dde654649bdbfc10d28ad73475224ba
25.24
86
0.679878
3.381443
false
false
false
false
django/django
tests/auth_tests/models/with_many_to_many.py
17
1208
from django.contrib.auth.models import AbstractBaseUser, BaseUserManager from django.db import models class Organization(models.Model): name = models.CharField(max_length=255) class CustomUserWithM2MManager(BaseUserManager): def create_superuser(self, username, orgs, password): user = self.model(use...
bsd-3-clause
b45f2d02b9e6fa070b67bbfa66be5bee
29.2
80
0.740894
3.847134
false
false
false
false
django/django
django/contrib/admin/templatetags/admin_modify.py
15
4981
import json from django import template from django.template.context import Context from .base import InclusionAdminNode register = template.Library() def prepopulated_fields_js(context): """ Create a list of prepopulated_fields that should render JavaScript for the prepopulated fields for both the adm...
bsd-3-clause
d5ca9c38e413237120f14d9698521bb5
32.206667
86
0.59988
4.013699
false
false
false
false
riga/law
law/decorator.py
1
21080
# coding: utf-8 """ Helpful decorators to use with tasks. Example usage: .. code-block:: python class MyTask(law.Task): @log @safe_output(skip=KeyboardInterrupt) def run(self): ... The usage of a decorator without invocation (e.g. ``@log``) is equivalent to the one *with* i...
bsd-3-clause
a95d63c7e811e458bbbd9224d4af0171
36.845601
100
0.569687
4.533333
false
false
false
false
django/django
django/middleware/http.py
17
1616
from django.utils.cache import cc_delim_re, get_conditional_response, set_response_etag from django.utils.deprecation import MiddlewareMixin from django.utils.http import parse_http_date_safe class ConditionalGetMiddleware(MiddlewareMixin): """ Handle conditional GET operations. If the response has an ETag or...
bsd-3-clause
0afe28c4dac1db8730d0c3ee13349269
39.4
87
0.660272
4.355795
false
false
false
false
django/django
tests/modeladmin/models.py
17
1823
from django.contrib.auth.models import User from django.db import models class Band(models.Model): name = models.CharField(max_length=100) bio = models.TextField() sign_date = models.DateField() class Meta: ordering = ("name",) def __str__(self): return self.name class Song(mod...
bsd-3-clause
d010f48b7462f04a10e6046eb8214dcd
31.553571
88
0.673615
3.720408
false
true
false
false
django/django
tests/csrf_tests/tests.py
15
60414
import re from django.conf import settings from django.contrib.sessions.backends.cache import SessionStore from django.core.exceptions import ImproperlyConfigured from django.http import HttpRequest, HttpResponse, UnreadablePostError from django.middleware.csrf import ( CSRF_ALLOWED_CHARS, CSRF_SECRET_LENGTH, ...
bsd-3-clause
c5d4a0aec38975e75281719b4b313f39
38.639764
88
0.601927
3.844896
false
true
false
false
django/django
tests/migrate_signals/tests.py
9
6310
from io import StringIO from django.apps import apps from django.core import management from django.db import migrations from django.db.models import signals from django.test import TransactionTestCase, override_settings APP_CONFIG = apps.get_app_config("migrate_signals") SIGNAL_ARGS = [ "app_config", "verbos...
bsd-3-clause
30648b6a98b1c53994d16b81fd2fb9c1
36.117647
82
0.620127
4.232059
false
true
false
false
django/django
tests/delete_regress/models.py
9
3746
from django.contrib.contenttypes.fields import GenericForeignKey, GenericRelation from django.contrib.contenttypes.models import ContentType from django.db import models class Award(models.Model): name = models.CharField(max_length=25) object_id = models.PositiveIntegerField() content_type = models.Foreig...
bsd-3-clause
fe56e21df2598a5cd75b53f29e28a456
23.48366
86
0.716765
3.636893
false
false
false
false
django/django
django/contrib/gis/sitemaps/kml.py
17
2573
from django.apps import apps from django.contrib.gis.db.models import GeometryField from django.contrib.sitemaps import Sitemap from django.db import models from django.urls import reverse class KMLSitemap(Sitemap): """ A minimal hook to produce KML sitemaps. """ geo_format = "kml" def __init__(...
bsd-3-clause
a616e9e9376a4be9a28a78a7b412fd5c
31.987179
78
0.529343
4.578292
false
false
false
false
django/django
django/db/backends/sqlite3/introspection.py
13
17357
from collections import namedtuple import sqlparse from django.db import DatabaseError from django.db.backends.base.introspection import BaseDatabaseIntrospection from django.db.backends.base.introspection import FieldInfo as BaseFieldInfo from django.db.backends.base.introspection import TableInfo from django.db.mod...
bsd-3-clause
2e5269c80e17a28f52ec0261c73ee61d
38.993088
88
0.523017
4.708899
false
false
false
false
django/django
django/views/generic/base.py
9
9263
import asyncio import logging from django.core.exceptions import ImproperlyConfigured from django.http import ( HttpResponse, HttpResponseGone, HttpResponseNotAllowed, HttpResponsePermanentRedirect, HttpResponseRedirect, ) from django.template.response import TemplateResponse from django.urls impor...
bsd-3-clause
df3951eae365b284007ebbb8e7291da6
31.616197
88
0.582533
4.47056
false
false
false
false
django/django
tests/unmanaged_models/models.py
17
3240
""" Models can have a ``managed`` attribute, which specifies whether the SQL code is generated for the table on various manage.py operations. """ from django.db import models # All of these models are created in the database by Django. class A01(models.Model): f_a = models.CharField(max_length=10, db_index=Tru...
bsd-3-clause
39e72e517c4510c8f26233ffd2049439
26.226891
79
0.67963
3.468951
false
false
false
false
riga/law
law/target/base.py
1
2965
# coding: utf-8 """ Custom base target definition. """ __all__ = ["Target"] from abc import abstractmethod from law.config import Config import law.target.luigi_shims as shims from law.util import colored, create_hash from law.logger import get_logger logger = get_logger(__name__) class Target(shims.Target): ...
bsd-3-clause
b161438000be2ae41c851cd5f69c0a09
26.453704
98
0.599663
3.820876
false
false
false
false
django/django
django/contrib/admin/templatetags/log.py
17
2167
from django import template from django.contrib.admin.models import LogEntry register = template.Library() class AdminLogNode(template.Node): def __init__(self, limit, varname, user): self.limit, self.varname, self.user = limit, varname, user def __repr__(self): return "<GetAdminLog Node>" ...
bsd-3-clause
a96375f686b40396c5fb3bc11368fc3b
30.405797
85
0.595293
3.94
false
false
false
false
django/django
django/contrib/postgres/lookups.py
4
1991
from django.db.models import Transform from django.db.models.lookups import PostgresOperatorLookup from django.db.models.sql.query import Query from .search import SearchVector, SearchVectorExact, SearchVectorField class DataContains(PostgresOperatorLookup): lookup_name = "contains" postgres_operator = "@>" ...
bsd-3-clause
0e604d93a7d7e651b6237dd6d9185339
24.525641
70
0.691612
3.673432
false
true
false
false
django/django
django/contrib/staticfiles/management/commands/runserver.py
17
1373
from django.conf import settings from django.contrib.staticfiles.handlers import StaticFilesHandler from django.core.management.commands.runserver import Command as RunserverCommand class Command(RunserverCommand): help = ( "Starts a lightweight web server for development and also serves static files." ...
bsd-3-clause
cdd34e0aa06001a43d902c34db54130d
37.138889
87
0.641661
4.783972
false
false
false
false
django/django
tests/distinct_on_fields/models.py
17
1221
from django.db import models class Tag(models.Model): name = models.CharField(max_length=10) parent = models.ForeignKey( "self", models.SET_NULL, blank=True, null=True, related_name="children", ) class Meta: ordering = ["name"] def __str__(self): ...
bsd-3-clause
26fa4f35e8579c562483dc97af09da5e
21.611111
58
0.619165
3.644776
false
false
false
false
django/django
django/contrib/flatpages/migrations/0001_initial.py
17
2409
from django.db import migrations, models class Migration(migrations.Migration): dependencies = [ ("sites", "0001_initial"), ] operations = [ migrations.CreateModel( name="FlatPage", fields=[ ( "id", models.Au...
bsd-3-clause
3b72b4c3613df3140b3fafc60eb30bba
33.768116
88
0.374323
5.794686
false
false
false
false
django/django
tests/generic_views/urls.py
17
15120
from django.contrib.auth import views as auth_views from django.contrib.auth.decorators import login_required from django.urls import path, re_path from django.views.decorators.cache import cache_page from django.views.generic import TemplateView, dates from . import views from .models import Book urlpatterns = [ ...
bsd-3-clause
35e06fff672464357e70e8013732786b
38.889182
88
0.632822
3.415725
false
false
false
false
django/django
tests/raw_query/tests.py
15
15256
from datetime import date from decimal import Decimal from django.core.exceptions import FieldDoesNotExist from django.db.models.query import RawQuerySet from django.test import TestCase, skipUnlessDBFeature from .models import ( Author, Book, BookFkAsPk, Coffee, FriendlyAuthor, MixedCaseIDCol...
bsd-3-clause
4af9f921c380521fcbec2e3eddddebc0
35.410501
88
0.588162
4.073698
false
true
false
false
django/django
django/core/management/commands/shell.py
17
4613
import os import select import sys import traceback from django.core.management import BaseCommand, CommandError from django.utils.datastructures import OrderedSet class Command(BaseCommand): help = ( "Runs a Python interactive interpreter. Tries to use IPython or " "bpython, if one of them is av...
bsd-3-clause
a4ee419c6d650cacde9b9835f37348d2
32.18705
87
0.548667
4.965554
false
false
false
false
django/django
django/db/models/signals.py
17
1622
from functools import partial from django.db.models.utils import make_model_tuple from django.dispatch import Signal class_prepared = Signal() class ModelSignal(Signal): """ Signal subclass that allows the sender to be lazily specified as a string of the `app_label.ModelName` form. """ def _laz...
bsd-3-clause
d17f160f14ee23f2df47edf9f7c6b23a
29.037037
86
0.663379
3.880383
false
false
false
false
riga/law
law/contrib/telegram/notification.py
1
2570
# coding: utf-8 """ Telegram notifications. """ __all__ = ["notify_telegram"] import threading import six from law.config import Config from law.util import escape_markdown from law.logger import get_logger logger = get_logger(__name__) def notify_telegram(title, content, token=None, chat=None, mention_user=N...
bsd-3-clause
aa8e35b124a5a16604af7bf06c834ff0
27.241758
100
0.636187
3.917683
false
false
false
false
django/django
tests/prefetch_related/tests.py
9
78066
from unittest import mock from django.contrib.contenttypes.models import ContentType from django.core.exceptions import ObjectDoesNotExist from django.db import NotSupportedError, connection from django.db.models import Prefetch, QuerySet, prefetch_related_objects from django.db.models.query import get_prefetcher from...
bsd-3-clause
551c5b0d5d5a96b10317115b9243a931
38.32796
88
0.569902
3.920747
false
true
false
false
django/django
tests/template_tests/test_extends_relative.py
17
4455
import os from django.template import Context, Engine, TemplateSyntaxError from django.test import SimpleTestCase from .utils import ROOT RELATIVE = os.path.join(ROOT, "relative_templates") class ExtendsRelativeBehaviorTests(SimpleTestCase): def test_normal_extend(self): engine = Engine(dirs=[RELATIVE]...
bsd-3-clause
513b08e61da3d983af221f8bf024601e
38.078947
78
0.635017
3.921655
false
true
false
false
django/django
django/contrib/gis/db/models/proxy.py
17
3173
""" The SpatialProxy object allows for lazy-geometries and lazy-rasters. The proxy uses Python descriptors for instantiating and setting Geometry or Raster objects corresponding to geographic model fields. Thanks to Robert Coup for providing this functionality (see #4322). """ from django.db.models.query_utils import ...
bsd-3-clause
869a09c5f3a5243c6a6fa0d1ac9731ed
37.228916
79
0.599748
4.618632
false
false
false
false
django/django
tests/many_to_one/models.py
17
3528
""" Many-to-one relationships To define a many-to-one relationship, use ``ForeignKey()``. """ from django.db import models class Reporter(models.Model): first_name = models.CharField(max_length=30) last_name = models.CharField(max_length=30) email = models.EmailField() def __str__(self): ret...
bsd-3-clause
42c375ac8b3b71ef7a1d3d2d6ec62ce5
25.727273
87
0.700113
3.625899
false
false
false
false
django/django
tests/model_formsets_regress/tests.py
9
21350
from django import forms from django.forms.formsets import DELETION_FIELD_NAME, BaseFormSet from django.forms.models import ( BaseModelFormSet, inlineformset_factory, modelform_factory, modelformset_factory, ) from django.forms.utils import ErrorDict, ErrorList from django.test import TestCase from .mo...
bsd-3-clause
dbfd4c9aeb68b57374fd0c2574ff8027
35.433447
87
0.580281
3.849621
false
true
false
false
django/django
django/contrib/gis/db/backends/mysql/introspection.py
11
1602
from MySQLdb.constants import FIELD_TYPE from django.contrib.gis.gdal import OGRGeomType from django.db.backends.mysql.introspection import DatabaseIntrospection class MySQLIntrospection(DatabaseIntrospection): # Updating the data_types_reverse dictionary with the appropriate # type for Geometry fields. ...
bsd-3-clause
0d47d9abe3484001f038b0a60859cb96
47.545455
86
0.650437
4.425414
false
false
false
false
django/django
django/contrib/gis/gdal/raster/const.py
17
2981
""" GDAL - Constant definitions """ from ctypes import c_double, c_float, c_int16, c_int32, c_ubyte, c_uint16, c_uint32 # See https://gdal.org/api/raster_c_api.html#_CPPv412GDALDataType GDAL_PIXEL_TYPES = { 0: "GDT_Unknown", # Unknown or unspecified type 1: "GDT_Byte", # Eight bit unsigned integer 2: "GD...
bsd-3-clause
2ee9a32cd1478b8bff4a55e5f8c8fd68
33.264368
83
0.662529
2.812264
false
false
false
false
riga/law
law/contrib/lsf/job.py
1
16987
# coding: utf-8 """ LSF job manager. See https://www.ibm.com/support/knowledgecenter/en/SSETD4_9.1.3. """ __all__ = ["LSFJobManager", "LSFJobFileFactory"] import os import stat import time import re import subprocess import six from law.config import Config from law.job.base import BaseJobManager, BaseJobFileFact...
bsd-3-clause
6f24079abfaa71fd03cbacc081de40be
35.768398
100
0.556013
3.924908
false
false
false
false
django/django
tests/forms_tests/field_tests/test_timefield.py
17
2035
import datetime from django.core.exceptions import ValidationError from django.forms import TimeField from django.test import SimpleTestCase from . import FormFieldAssertionsMixin class TimeFieldTest(FormFieldAssertionsMixin, SimpleTestCase): def test_timefield_1(self): f = TimeField() self.asse...
bsd-3-clause
785d0c79bfde39a29fc349766e878e9d
44.222222
87
0.635872
3.460884
false
true
false
false
django/django
django/db/models/sql/subqueries.py
15
5935
""" Query subclasses which provide extra functionality beyond simple data retrieval. """ from django.core.exceptions import FieldError from django.db.models.sql.constants import CURSOR, GET_ITERATOR_CHUNK_SIZE, NO_RESULTS from django.db.models.sql.query import Query __all__ = ["DeleteQuery", "UpdateQuery", "InsertQue...
bsd-3-clause
24553f315f182035f1b6de77f1c9e65e
33.707602
87
0.589385
4.233238
false
false
false
false
django/django
django/contrib/gis/db/backends/oracle/adapter.py
17
2025
from cx_Oracle import CLOB from django.contrib.gis.db.backends.base.adapter import WKTAdapter from django.contrib.gis.geos import GeometryCollection, Polygon class OracleSpatialAdapter(WKTAdapter): input_size = CLOB def __init__(self, geom): """ Oracle requires that polygon rings are in prop...
bsd-3-clause
01c0bac70c5d50d40e4410dae8fbfe1d
31.66129
87
0.596543
4.236402
false
false
false
false
riga/law
examples/sequential_htcondor_at_cern/analysis/tasks.py
1
6583
# coding: utf-8 """ Law example tasks to demonstrate HTCondor workflows at CERN with sequential jobs that start eagerly once jobs running previous requirements succeeded. The actual payload of the tasks is rather trivial, however, the way the jobs are eagerly submitted is a bit more advanced. See the "htcondor_at_cer...
bsd-3-clause
e64ef66f4a65cfbb821a51bc67f7c820
42.026144
100
0.691022
4.299804
false
false
false
false
django/django
tests/i18n/test_compilation.py
17
10721
import gettext as gettext_module import os import stat import unittest from io import StringIO from pathlib import Path from subprocess import run from unittest import mock from django.core.management import CommandError, call_command, execute_from_command_line from django.core.management.commands.makemessages import ...
bsd-3-clause
2bbcee8d6e75d8a7fe8daf28d5e263d2
38.352941
88
0.63565
3.747899
false
true
false
false
riga/law
law/task/proxy.py
1
3742
# coding: utf-8 """ Proxy task definition and helpers. """ __all__ = ["ProxyTask", "ProxyCommand", "get_proxy_attribute"] from law.task.base import BaseTask, Task from law.parameter import TaskInstanceParameter from law.parser import global_cmdline_args from law.util import quote_cmd _forward_workflow_attributes ...
bsd-3-clause
e0974c17089f74598824dc8374da285a
32.410714
100
0.637894
3.901981
false
false
false
false
django/django
django/contrib/gis/geos/prototypes/errcheck.py
17
2788
""" Error checking functions for GEOS ctypes prototype functions. """ from ctypes import c_void_p, string_at from django.contrib.gis.geos.error import GEOSException from django.contrib.gis.geos.libgeos import GEOSFuncFactory # Getting the `free` routine used to free the memory allocated for # string pointers returne...
bsd-3-clause
59e86b88b41113796afe1ce784bc1a40
28.347368
85
0.656743
4.25
false
false
false
false
riga/law
law/target/formatter.py
1
10898
# coding: utf-8 """ Formatter classes for file targets. """ __all__ = ["AUTO_FORMATTER", "Formatter", "get_formatter", "find_formatters", "find_formatter"] import os import json import zipfile import gzip import tarfile from collections import OrderedDict import six from law.util import make_list, import_file fro...
bsd-3-clause
25607694d0706c9ca577e5d216b42044
28.217158
99
0.585704
3.889365
false
false
false
false
django/django
tests/validation/test_unique.py
15
7617
import datetime import unittest from django.apps.registry import Apps from django.core.exceptions import ValidationError from django.db import models from django.test import TestCase from .models import ( CustomPKModel, FlexibleDatePost, ModelToValidate, Post, UniqueErrorsModel, UniqueFieldsMo...
bsd-3-clause
cb670d3cb0c5ddff14e90ae8e26151e1
32.262009
86
0.528292
4.157751
false
true
false
false
django/django
tests/gis_tests/distapp/models.py
28
1400
from django.contrib.gis.db import models from ..utils import gisfield_may_be_null class NamedModel(models.Model): name = models.CharField(max_length=30) class Meta: abstract = True def __str__(self): return self.name class SouthTexasCity(NamedModel): "City model on projected coord...
bsd-3-clause
a7d047da5d81e793061c2661c47f3569
25.923077
71
0.724286
3.580563
false
false
false
false
riga/law
examples/htcondor_at_naf/analysis/tasks.py
1
3738
# coding: utf-8 """ Law example tasks to demonstrate HTCondor workflows at NAF. The actual payload of the tasks is rather trivial. """ import six import law # import our "framework" tasks from analysis.framework import Task, HTCondorWorkflow class CreateChars(Task, HTCondorWorkflow, law.LocalWorkflow): """ ...
bsd-3-clause
85149bb5a3e861b6726f99e09161c3c9
39.193548
99
0.674157
4.341463
false
false
false
false
django/django
django/db/migrations/executor.py
17
18923
from django.apps.registry import apps as global_apps from django.db import migrations, router from .exceptions import InvalidMigrationPlan from .loader import MigrationLoader from .recorder import MigrationRecorder from .state import ProjectState class MigrationExecutor: """ End-to-end migration execution - ...
bsd-3-clause
11a441259f40fb37f7f839ee13018184
45.153659
87
0.57771
4.936864
false
false
false
false
django/django
django/contrib/auth/base_user.py
13
4737
""" This module allows importing AbstractBaseUser even when django.contrib.auth is not in INSTALLED_APPS. """ import unicodedata import warnings from django.contrib.auth import password_validation from django.contrib.auth.hashers import ( check_password, is_password_usable, make_password, ) from django.db ...
bsd-3-clause
5f6ca4d80db32ed6bf004e6808360410
28.981013
88
0.622757
4.406512
false
false
false
false
riga/law
law/contrib/lsf/workflow.py
1
7059
# coding: utf-8 """ LSF remote workflow implementation. See https://www.ibm.com/support/knowledgecenter/en/SSETD4_9.1.3. """ __all__ = ["LSFWorkflow"] import os from abc import abstractmethod from collections import OrderedDict import luigi import six from law.workflow.remote import BaseRemoteWorkflow, BaseRemote...
bsd-3-clause
141bd96e09a4f33974dcfa4990453327
31.680556
100
0.634934
3.670827
false
false
false
false
django/django
tests/forms_tests/tests/test_forms.py
4
212044
import copy import datetime import json import uuid from django.core.exceptions import NON_FIELD_ERRORS from django.core.files.uploadedfile import SimpleUploadedFile from django.core.validators import MaxValueValidator, RegexValidator from django.forms import ( BooleanField, CharField, CheckboxSelectMultip...
bsd-3-clause
a9a049c02118c6928f8a32a7d083c5e8
40.567366
88
0.546827
3.960091
false
false
false
false
django/django
django/utils/termcolors.py
17
7386
""" termcolors.py """ color_names = ("black", "red", "green", "yellow", "blue", "magenta", "cyan", "white") foreground = {color_names[x]: "3%s" % x for x in range(8)} background = {color_names[x]: "4%s" % x for x in range(8)} RESET = "0" opt_dict = { "bold": "1", "underscore": "4", "blink": "5", "reve...
bsd-3-clause
30a508e4e2e368c87ec3b1693d44236e
32.420814
85
0.526807
3.670974
false
false
false
false
django/django
tests/db_functions/text/test_repeat.py
9
1276
from django.db import connection from django.db.models import Value from django.db.models.functions import Length, Repeat from django.test import TestCase from ..models import Author class RepeatTests(TestCase): def test_basic(self): Author.objects.create(name="John", alias="xyz") none_value = ( ...
bsd-3-clause
0257045708fc86b3fca3b6b4727b28f5
35.457143
86
0.573668
4.183607
false
true
false
false
django/django
tests/template_tests/filter_tests/test_floatformat.py
8
6387
from decimal import Decimal, localcontext from django.template.defaultfilters import floatformat from django.test import SimpleTestCase from django.utils import translation from django.utils.safestring import mark_safe from ..utils import setup class FloatformatTests(SimpleTestCase): @setup( { ...
bsd-3-clause
8d73fc2c2aaaf3f93e0ecde23afcc89e
40.732026
84
0.590133
3.68649
false
true
false
false
django/django
django/templatetags/cache.py
17
3545
from django.core.cache import InvalidCacheBackendError, caches from django.core.cache.utils import make_template_fragment_key from django.template import Library, Node, TemplateSyntaxError, VariableDoesNotExist register = Library() class CacheNode(Node): def __init__(self, nodelist, expire_time_var, fragment_nam...
bsd-3-clause
986724adcb08c0ff68f6b6fdafbd4764
34.45
88
0.585049
4.344363
false
false
false
false
django/django
django/contrib/sessions/middleware.py
2
3483
import time from importlib import import_module from django.conf import settings from django.contrib.sessions.backends.base import UpdateError from django.contrib.sessions.exceptions import SessionInterrupted from django.utils.cache import patch_vary_headers from django.utils.deprecation import MiddlewareMixin from dj...
bsd-3-clause
c87103616ebf7532291ab9cd093aeac7
44.233766
79
0.57594
5.069869
false
false
false
false
django/django
django/contrib/gis/gdal/raster/source.py
11
18394
import json import os import sys import uuid from ctypes import ( addressof, byref, c_buffer, c_char_p, c_double, c_int, c_void_p, string_at, ) from pathlib import Path from django.contrib.gis.gdal.driver import Driver from django.contrib.gis.gdal.error import GDALException from django....
bsd-3-clause
671bb27cf6071068d3dda62fffd49a6b
33
88
0.559693
4.14186
false
false
false
false
django/django
tests/generic_inline_admin/models.py
17
1693
from django.contrib.contenttypes.fields import GenericForeignKey, GenericRelation from django.contrib.contenttypes.models import ContentType from django.db import models class Episode(models.Model): name = models.CharField(max_length=100) length = models.CharField(max_length=100, blank=True) author = mode...
bsd-3-clause
a709e89b428e0d99d9fb9eda39dbf6f7
26.754098
84
0.689309
4.021378
false
false
false
false
django/django
django/template/engine.py
15
7733
import functools from django.core.exceptions import ImproperlyConfigured from django.utils.functional import cached_property from django.utils.module_loading import import_string from .base import Template from .context import Context, _builtin_context_processors from .exceptions import TemplateDoesNotExist from .lib...
bsd-3-clause
62644c73f5ba2cfbc7bc06dd13b73fdb
35.476415
81
0.603905
4.692354
false
false
false
false
django/django
django/db/migrations/operations/models.py
10
39515
from django.db import models from django.db.migrations.operations.base import Operation from django.db.migrations.state import ModelState from django.db.migrations.utils import field_references, resolve_relation from django.db.models.options import normalize_together from django.utils.functional import cached_property ...
bsd-3-clause
7f917df6bc9051a2a4e1781d2ffa498a
34.695574
88
0.544173
4.143771
false
false
false
false
django/django
tests/requests/tests.py
4
39155
import pickle from io import BytesIO from itertools import chain from urllib.parse import urlencode from django.core.exceptions import DisallowedHost from django.core.handlers.wsgi import LimitedStream, WSGIRequest from django.http import ( HttpHeaders, HttpRequest, RawPostDataException, UnreadablePost...
bsd-3-clause
cd9213640ee0efe53b8b5fa800e5bb56
35.095018
88
0.533928
4.15405
false
true
false
false
django/django
tests/handlers/tests_custom_error_handlers.py
17
1406
from django.core.exceptions import PermissionDenied from django.template.response import TemplateResponse from django.test import SimpleTestCase, modify_settings, override_settings from django.urls import path class MiddlewareAccessingContent: def __init__(self, get_response): self.get_response = get_resp...
bsd-3-clause
e1805dbc6222a208d4a0470ff260c803
29.565217
83
0.729018
4.492013
false
true
false
false
riga/law
law/contrib/root/util.py
1
4863
# coding: utf-8 """ ROOT-related utilities. """ __all__ = ["import_ROOT", "hadd_task"] import six from law.target.local import LocalFileTarget, LocalDirectoryTarget from law.util import map_verbose, make_list, interruptable_popen, human_bytes, quote_cmd _ROOT = None def import_ROOT(batch=True, ignore_cli=True,...
bsd-3-clause
8d77b11cdd59df742c9bda0d9a050be1
35.840909
100
0.610323
4.005766
false
false
false
false
django/django
tests/forms_tests/widget_tests/test_nullbooleanselect.py
15
5027
from django.forms import Form, NullBooleanField, NullBooleanSelect from django.utils import translation from .base import WidgetTest class NullBooleanSelectTest(WidgetTest): widget = NullBooleanSelect() def test_render_true(self): self.check_html( self.widget, "is_cool", ...
bsd-3-clause
40c1240d854090d212aa8b8685c5cff8
28.226744
77
0.457927
4.50852
false
true
false
false
django/django
django/views/generic/list.py
17
7941
from django.core.exceptions import ImproperlyConfigured from django.core.paginator import InvalidPage, Paginator from django.db.models import QuerySet from django.http import Http404 from django.utils.translation import gettext as _ from django.views.generic.base import ContextMixin, TemplateResponseMixin, View class...
bsd-3-clause
2f6720cfbf08d5590d09ceaeae8e0efa
35.059091
83
0.565108
4.436801
false
false
false
false
django/django
tests/custom_columns/models.py
17
1555
""" Custom column/table names If your database column name is different than your model attribute, use the ``db_column`` parameter. Note that you'll use the field's name, not its column name, in API usage. If your database table name is different than your model name, use the ``db_table`` Meta attribute. This has no ...
bsd-3-clause
36730b9b058a72cafe419ea2d884c943
30.1
78
0.680386
3.746988
false
false
false
false
django/django
tests/signals/tests.py
9
17731
from unittest import mock from django.apps.registry import Apps from django.db import models from django.db.models import signals from django.dispatch import receiver from django.test import SimpleTestCase, TestCase from django.test.utils import isolate_apps from .models import Author, Book, Car, Page, Person class...
bsd-3-clause
5251d9cdf1ad406226040000a757ef06
32.328947
88
0.52005
4.357582
false
false
false
false
django/django
tests/custom_columns/tests.py
9
3723
from django.core.exceptions import FieldError from django.test import TestCase from .models import Article, Author class CustomColumnsTests(TestCase): @classmethod def setUpTestData(cls): cls.a1 = Author.objects.create(first_name="John", last_name="Smith") cls.a2 = Author.objects.create(first...
bsd-3-clause
9d41409d1c08665ad2be4a42038ff541
32.241071
83
0.601665
3.939683
false
true
false
false
django/django
tests/gis_tests/relatedapp/models.py
17
1604
from django.contrib.gis.db import models class SimpleModel(models.Model): class Meta: abstract = True class Location(SimpleModel): point = models.PointField() def __str__(self): return self.point.wkt class City(SimpleModel): name = models.CharField(max_length=50) state = model...
bsd-3-clause
3d7a67720c27c1febcc2e145d2eab2df
24.0625
88
0.703865
3.670481
false
false
false
false
theislab/scvelo
scvelo/read_load.py
1
6681
import os import warnings from pathlib import Path from urllib.request import urlretrieve import numpy as np import pandas as pd from scvelo.core import clean_obs_names as _clean_obs_names from scvelo.core import get_df as _get_df from scvelo.core import merge as _merge from scvelo.core._anndata import obs_df as _obs...
bsd-3-clause
9946ae7271c5850014949e7b81ded5e1
29.506849
88
0.610238
3.369138
false
false
false
false
theislab/scvelo
scvelo/plotting/velocity_embedding_stream.py
1
8784
import numpy as np import matplotlib.pyplot as pl from matplotlib import rcParams from scvelo.tools.utils import groups_to_bool from scvelo.tools.velocity_embedding import velocity_embedding from .docs import doc_params, doc_scatter from .scatter import scatter from .utils import ( default_basis, default_colo...
bsd-3-clause
ae06d7c863dbd3e110461a3b5216b5b9
32.022556
88
0.565915
3.683019
false
false
false
false
theislab/scvelo
scvelo/core/_utils.py
1
1551
import warnings from functools import wraps from typing import Mapping # Modified from https://github.com/scverse/scanpy/blob/master/scanpy/_utils/__init__.py def deprecated_arg_names(arg_mapping: Mapping[str, str]): """ Decorator which marks a functions keyword arguments as deprecated. It will result in ...
bsd-3-clause
1d2fbcdbefe1c6a8de790b1653c514f7
35.928571
87
0.552547
5.239865
false
false
false
false
theislab/scvelo
scvelo/core/_anndata.py
1
23505
import re from typing import List, Optional, Union from typing_extensions import Literal import numpy as np import pandas as pd from numpy import ndarray from pandas import DataFrame from pandas.api.types import is_categorical_dtype from scipy.sparse import csr_matrix, issparse, spmatrix from anndata import AnnData ...
bsd-3-clause
f87b6e17e54e87dff42191229b756e81
28.790875
87
0.568773
3.70566
false
false
false
false
pandas-dev/pandas
pandas/tests/strings/test_find_replace.py
1
34294
from datetime import datetime import re import numpy as np import pytest from pandas.errors import PerformanceWarning import pandas as pd from pandas import ( Series, _testing as tm, ) # -------------------------------------------------------------------------------------- # str.contains # -----------------...
bsd-3-clause
4d4b6a17d2da78ffe845dca423821321
34.209446
88
0.5857
3.349678
false
true
false
false
pandas-dev/pandas
pandas/core/indexes/api.py
1
10088
from __future__ import annotations import textwrap from typing import cast import numpy as np from pandas._libs import ( NaT, lib, ) from pandas._typing import Axis from pandas.errors import InvalidIndexError from pandas.core.dtypes.cast import find_common_type from pandas.core.algorithms import safe_sort ...
bsd-3-clause
3b4a191b125cfb491c94d1ee8939c09b
25.617414
88
0.600912
4.077607
false
false
false
false
pandas-dev/pandas
pandas/core/internals/concat.py
1
25862
from __future__ import annotations import copy as cp import itertools from typing import ( TYPE_CHECKING, Sequence, cast, ) import numpy as np from pandas._libs import ( NaT, internals as libinternals, ) from pandas._libs.missing import NA from pandas._typing import ( ArrayLike, AxisInt, ...
bsd-3-clause
12986bf6b3a33b090b24a7342a18c0a6
32.850785
88
0.58441
3.849085
false
false
false
false
pandas-dev/pandas
asv_bench/benchmarks/pandas_vb_common.py
2
1755
from importlib import import_module import os import numpy as np import pandas as pd # Compatibility import for lib for imp in ["pandas._libs.lib", "pandas.lib"]: try: lib = import_module(imp) break except (ImportError, TypeError, ValueError): pass # Compatibility import for the test...
bsd-3-clause
576e0acf6e9f5bcf8f3595fadc5d0f95
20.9375
73
0.614245
3.588957
false
false
false
false
pandas-dev/pandas
pandas/core/arrays/sparse/array.py
1
63282
""" SparseArray data structure """ from __future__ import annotations from collections import abc import numbers import operator from typing import ( TYPE_CHECKING, Any, Callable, Literal, Sequence, TypeVar, cast, overload, ) import warnings import numpy as np from pandas._libs import...
bsd-3-clause
ab1995d39c07e42e9e192247269c9424
32.1146
88
0.54687
4.043578
false
false
false
false
pandas-dev/pandas
pandas/io/formats/printing.py
1
15691
""" Printing tools. """ from __future__ import annotations import sys from typing import ( Any, Callable, Dict, Iterable, Mapping, Sequence, TypeVar, Union, ) from pandas._config import get_option from pandas.core.dtypes.inference import is_sequence EscapeChars = Union[Mapping[str, s...
bsd-3-clause
dfda92dadb49780f5f0cbbee06664f55
29.948718
88
0.576764
3.792845
false
false
false
false
pandas-dev/pandas
doc/sphinxext/announce.py
1
4683
#!/usr/bin/env python3 """ Script to generate contributor and pull request lists This script generates contributor and pull request lists for release announcements using GitHub v3 protocol. Use requires an authentication token in order to have sufficient bandwidth, you can get one following the directions at `<https:/...
bsd-3-clause
120fb87de3c61d48df0fccda1b2f130e
28.086957
88
0.640829
3.497386
false
false
false
false