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 |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
metoppv/improver | improver_tests/lightning/test_LightningFromCapePrecip.py | 3 | 8796 | # -*- coding: utf-8 -*-
# -----------------------------------------------------------------------------
# (C) British Crown copyright. The Met Office.
# All rights reserved.
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions are me... | bsd-3-clause | bbb16a2d45b947260c8fd94d9446068b | 37.748899 | 97 | 0.68156 | 3.590204 | false | true | false | false |
metoppv/improver | improver_tests/generate_ancillaries/test_GenerateTimezoneMask.py | 3 | 16860 | # -*- coding: utf-8 -*-
# -----------------------------------------------------------------------------
# (C) British Crown copyright. The Met Office.
# All rights reserved.
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions are me... | bsd-3-clause | 1f1dcbc7485cb9ae6feee9412578ac92 | 35.180258 | 88 | 0.59306 | 3.631273 | false | true | false | false |
metoppv/improver | improver/cube_combiner.py | 1 | 27549 | # -*- coding: utf-8 -*-
# -----------------------------------------------------------------------------
# (C) British Crown copyright. The Met Office.
# All rights reserved.
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions are me... | bsd-3-clause | 62117a6d93c4ebac76d9abc72b16fef7 | 38.468481 | 100 | 0.598534 | 4.473693 | false | false | false | false |
astropy/astropy-helpers | docs/conf.py | 3 | 1470 | # -*- coding: utf-8 -*-
project = 'astropy-helpers'
copyright = '2014, The Astropy Developers'
author = 'The Astropy Developers'
# We need to get the version number from the package
import sys # noqa
sys.path.insert(0, '..')
import astropy_helpers # noqa
version = astropy_helpers.__version__
release = astropy_helpe... | bsd-3-clause | 58d1e162b739a208b054ef53ca4c6e21 | 27.269231 | 75 | 0.706122 | 3.475177 | false | false | false | false |
astropy/astropy-helpers | astropy_helpers/commands/build_sphinx.py | 2 | 8176 |
import os
import pkgutil
import re
import shutil
import subprocess
import sys
from distutils.version import LooseVersion
from distutils import log
from sphinx.setup_command import BuildDoc as SphinxBuildDoc
SUBPROCESS_TEMPLATE = """
import os
import sys
{build_main}
os.chdir({srcdir!r})
{sys_path_inserts}
for b... | bsd-3-clause | 90a056f5e1fb62b138b72849395844f6 | 33.791489 | 115 | 0.586595 | 4.194972 | false | false | false | false |
pvlib/pvlib-python | pvlib/iotools/crn.py | 3 | 5336 | """Functions to read data from the US Climate Reference Network (CRN).
"""
import pandas as pd
import numpy as np
HEADERS = [
'WBANNO', 'UTC_DATE', 'UTC_TIME', 'LST_DATE', 'LST_TIME', 'CRX_VN',
'LONGITUDE', 'LATITUDE', 'AIR_TEMPERATURE', 'PRECIPITATION',
'SOLAR_RADIATION', 'SR_FLAG', 'SURFACE_TEMPERATURE... | bsd-3-clause | 772d5f6f51a14da745b3df69fbf0fee7 | 37.114286 | 79 | 0.649175 | 3.181872 | false | false | false | false |
pvlib/pvlib-python | pvlib/soiling.py | 4 | 8778 | """
This module contains functions for soiling models
"""
import datetime
import numpy as np
import pandas as pd
from scipy.special import erf
from pvlib.tools import cosd
def hsu(rainfall, cleaning_threshold, tilt, pm2_5, pm10,
depo_veloc=None, rain_accum_period=pd.Timedelta('1h')):
"""
Calculates ... | bsd-3-clause | 36f228e2c871d87a85dbfacb7d3ea9f2 | 39.638889 | 79 | 0.667578 | 3.652934 | false | false | false | false |
pvlib/pvlib-python | benchmarks/benchmarks/irradiance.py | 4 | 2710 | """
ASV benchmarks for irradiance.py
"""
import pandas as pd
from pvlib import irradiance, location
class Irradiance:
def setup(self):
self.times = pd.date_range(start='20180601', freq='1min',
periods=14400)
self.days = pd.date_range(start='20180601', freq='d',... | bsd-3-clause | 506c94cc3e7c889d7d4fe92eaebb9761 | 38.852941 | 78 | 0.544649 | 3.822285 | false | false | false | false |
pvlib/pvlib-python | benchmarks/benchmarks/location.py | 4 | 1596 | """
ASV benchmarks for location.py
"""
import pandas as pd
import pvlib
from pkg_resources import parse_version
def set_solar_position(obj):
obj.location = pvlib.location.Location(32, -110, altitude=700,
tz='Etc/GMT+7')
obj.times = pd.date_range(start='20180601', fr... | bsd-3-clause | a8ea51ebf509686c7a94f62ac2e35e74 | 30.294118 | 70 | 0.593358 | 3.602709 | false | false | false | false |
pytorch/vision | torchvision/prototype/datasets/_builtin/country211.py | 1 | 2657 | import pathlib
from typing import Any, Dict, List, Tuple, Union
from torchdata.datapipes.iter import Filter, IterDataPipe, Mapper
from torchvision.prototype.datasets.utils import Dataset, EncodedImage, HttpResource, OnlineResource
from torchvision.prototype.datasets.utils._internal import (
hint_sharding,
hint... | bsd-3-clause | 0d220ea768006c9768bf80582f411671 | 31.802469 | 100 | 0.62213 | 3.547397 | false | false | false | false |
pytorch/vision | test/test_prototype_transforms_functional.py | 1 | 46207 | import inspect
import math
import os
import re
from typing import get_type_hints
import numpy as np
import PIL.Image
import pytest
import torch
from common_utils import cache, cpu_and_gpu, needs_cuda, set_rng_seed
from prototype_common_utils import assert_close, make_bounding_boxes, make_image, parametrized_error_me... | bsd-3-clause | e693dcc8ec18c86a65f6042af5e6be63 | 37.282519 | 122 | 0.616032 | 3.347848 | false | true | false | false |
pytorch/vision | torchvision/ops/ps_roi_align.py | 1 | 3625 | import torch
import torch.fx
from torch import nn, Tensor
from torch.nn.modules.utils import _pair
from torchvision.extension import _assert_has_ops
from ..utils import _log_api_usage_once
from ._utils import check_roi_boxes_shape, convert_boxes_to_roi_format
@torch.fx.wrap
def ps_roi_align(
input: Tensor,
b... | bsd-3-clause | c128e29e89d3408acefcd611d9792c2b | 39.277778 | 106 | 0.61931 | 3.702758 | false | false | false | false |
pytorch/vision | torchvision/extension.py | 1 | 3914 | import ctypes
import os
import sys
from warnings import warn
import torch
from ._internally_replaced_utils import _get_extension_path
_HAS_OPS = False
def _has_ops():
return False
try:
# On Windows Python-3.8.x has `os.add_dll_directory` call,
# which is called to configure dll search path.
# To... | bsd-3-clause | a13f101ace5f9955ca1f8a64d32b400d | 35.579439 | 100 | 0.62928 | 3.727619 | false | false | false | false |
pytorch/vision | torchvision/prototype/datasets/utils/_internal.py | 1 | 6563 | import csv
import functools
import pathlib
import pickle
from typing import Any, BinaryIO, Callable, Dict, IO, Iterator, List, Sequence, Sized, Tuple, TypeVar, Union
import torch
import torch.distributed as dist
import torch.utils.data
from torchdata.datapipes.iter import IoPathFileLister, IoPathFileOpener, IterDataPi... | bsd-3-clause | ab742da5a4d46dfe31aa14ce6ebed82f | 32.829897 | 116 | 0.645284 | 3.463325 | false | false | false | false |
pytorch/vision | references/depth/stereo/transforms.py | 1 | 25981 | import random
from typing import Callable, List, Optional, Sequence, Tuple, Union
import numpy as np
import PIL.Image
import torch
import torchvision.transforms as T
import torchvision.transforms.functional as F
from torch import Tensor
T_FLOW = Union[Tensor, np.ndarray, None]
T_MASK = Union[Tensor, np.ndarray, None]... | bsd-3-clause | f662d1b3dba09026db481c4f84fe01ae | 39.218266 | 119 | 0.59709 | 3.386029 | false | false | false | false |
pytorch/vision | .github/process_commit.py | 1 | 2470 | """
This script finds the merger responsible for labeling a PR by a commit SHA. It is used by the workflow in
'.github/workflows/pr-labels.yml'. If there exists no PR associated with the commit or the PR is properly labeled,
this script is a no-op.
Note: we ping the merger only, not the reviewers, as the reviewers can... | bsd-3-clause | 8df7576776a7c828e826938d194953eb | 29.493827 | 114 | 0.668421 | 3.383562 | false | false | false | false |
pytorch/vision | test/preprocess-bench.py | 1 | 2402 | import argparse
import os
from timeit import default_timer as timer
import torch
import torch.utils.data
import torchvision
import torchvision.datasets as datasets
import torchvision.transforms as transforms
from torch.utils.model_zoo import tqdm
parser = argparse.ArgumentParser(description="PyTorch ImageNet Trainin... | bsd-3-clause | 1b3f62a6a54e631810790940e9704a56 | 35.393939 | 118 | 0.646128 | 3.411932 | false | false | false | false |
automl/auto-sklearn | autosklearn/ensemble_building/manager.py | 1 | 15177 | from __future__ import annotations
from typing import Any, Dict, Sequence, Type
import logging.handlers
import time
import traceback
import dask.distributed
import numpy as np
from sklearn.utils.validation import check_random_state
from smac.callbacks import IncorporateRunResultCallback
from smac.optimizer.smbo impo... | bsd-3-clause | b21e5301ccb990eac7b01a68f78da6e9 | 37.618321 | 88 | 0.586545 | 4.596305 | false | false | false | false |
automl/auto-sklearn | examples/60_search/example_parallel_n_jobs.py | 1 | 1775 | # -*- encoding: utf-8 -*-
"""
===================================
Parallel Usage on a single machine
===================================
*Auto-sklearn* uses
`dask.distributed <https://distributed.dask.org/en/latest/index.html`>_
for parallel optimization.
This example shows how to start *Auto-sklearn* to use multipl... | bsd-3-clause | 3556149e5162bbe3b45768352a00c5fc | 31.87037 | 76 | 0.604507 | 3.760593 | false | true | false | false |
automl/auto-sklearn | test/test_pipeline/components/data_preprocessing/test_one_hot_encoding.py | 1 | 3571 | import numpy as np
from scipy import sparse
from autosklearn.pipeline.components.data_preprocessing.categorical_encoding.no_encoding import ( # noqa: E501
NoEncoding,
)
from autosklearn.pipeline.components.data_preprocessing.categorical_encoding.one_hot_encoding import ( # noqa: E501
OneHotEncoder,
)
from au... | bsd-3-clause | 64bb7b33ec9c4cafe39fd75925fc12bf | 37.815217 | 116 | 0.629236 | 4.085812 | false | true | false | false |
automl/auto-sklearn | autosklearn/ensembles/ensemble_selection.py | 1 | 14007 | from __future__ import annotations
from typing import Dict, List, Sequence, Tuple, Union
import random
import warnings
from collections import Counter
import numpy as np
from sklearn.utils import check_random_state
from autosklearn.automl_common.common.utils.backend import Backend
from autosklearn.constants import ... | bsd-3-clause | f7f9485cf35185a613697d29fc33b628 | 34.460759 | 89 | 0.560862 | 4.3125 | false | false | false | false |
automl/auto-sklearn | examples/60_search/example_parallel_manual_spawning_cli.py | 1 | 7869 | # -*- encoding: utf-8 -*-
"""
======================================================
Parallel Usage: Spawning workers from the command line
======================================================
*Auto-sklearn* uses
`dask.distributed <https://distributed.dask.org/en/latest/index.html>`_
for parallel optimization.
This... | bsd-3-clause | 85675f7655593216faab413aadc6c322 | 33.362445 | 96 | 0.63693 | 4.141579 | false | false | false | false |
automl/auto-sklearn | autosklearn/util/disk.py | 1 | 2506 | from __future__ import annotations
from typing import Any
import math
import shutil
import tempfile
import uuid
from pathlib import Path
sizes = {
"B": 0,
"KB": 1,
"MB": 2,
"GB": 3,
"TB": 4,
}
def sizeof(path: Path | str, unit: str = "B") -> float:
"""Get the size of some path object
P... | bsd-3-clause | bf5bc57c62fa5a444817bfa6a0d9c15b | 23.330097 | 78 | 0.569433 | 3.774096 | false | false | false | false |
automl/auto-sklearn | scripts/04_create_aslib_files.py | 1 | 5742 | from argparse import ArgumentParser
import itertools
import os
import arff
from autosklearn.constants import *
from autosklearn.metrics import CLASSIFICATION_METRICS, REGRESSION_METRICS
if __name__ == "__main__":
parser = ArgumentParser()
parser.add_argument("--working-directory", type=str, required=True)
... | bsd-3-clause | 5abd95de3a4cda7765410225793de8ec | 38.875 | 87 | 0.576977 | 4.004184 | false | false | false | false |
mozilla/kitsune | kitsune/announcements/models.py | 1 | 3271 | from datetime import datetime
from django.contrib.auth.models import User, Group
from django.db import models
from django.db.models import Q
from django.db.models.signals import post_save
from kitsune.sumo.templatetags.jinja_helpers import wiki_to_html
from kitsune.sumo.models import ModelBase
from kitsune.wiki.model... | bsd-3-clause | ee4f4732066f757d4a4b50c4b8a2d428 | 34.554348 | 96 | 0.656374 | 3.861865 | false | false | false | false |
mozilla/kitsune | scripts/cron.py | 1 | 8102 | import datetime
import os
import sys
from subprocess import check_call
import babis
from apscheduler.schedulers.blocking import BlockingScheduler
from django.conf import settings
from django.utils import timezone
MANAGE = os.path.join(settings.ROOT, "manage.py")
schedule = BlockingScheduler()
def call_command(comma... | bsd-3-clause | 719721b540179bb34fd48d14d22249c2 | 21.505556 | 99 | 0.638361 | 3.156213 | false | false | false | false |
mozilla/kitsune | kitsune/tidings/utils.py | 1 | 3654 | from importlib import import_module
from zlib import crc32
from django.conf import settings
from django.core.exceptions import ImproperlyConfigured
from django.urls import reverse as django_reverse
from django.utils.module_loading import import_string
def collate(*iterables, **kwargs):
"""Return an iterable orde... | bsd-3-clause | 696bae4799e5a480b8c96a0c04af4b9e | 33.471698 | 80 | 0.67734 | 4.119504 | false | false | false | false |
mozilla/kitsune | kitsune/notifications/migrations/0001_initial.py | 1 | 2362 | # -*- coding: utf-8 -*-
from __future__ import unicode_literals
from django.db import models, migrations
import datetime
from django.conf import settings
class Migration(migrations.Migration):
dependencies = [
('actstream', '__first__'),
migrations.swappable_dependency(settings.AUTH_USER_MODEL),... | bsd-3-clause | 51dc8cf5d11ba4dd434b607db02c6f67 | 39.033898 | 114 | 0.558848 | 4.677228 | false | false | false | false |
mozilla/kitsune | kitsune/kpi/management/commands/update_l10n_metric.py | 1 | 2630 | from datetime import date, timedelta
from django.conf import settings
from django.core.management.base import BaseCommand
from kitsune.kpi.management import utils
from kitsune.kpi.models import L10N_METRIC_CODE, Metric, MetricKind
from kitsune.sumo import googleanalytics
class Command(BaseCommand):
help = "Calc... | bsd-3-clause | 355034297cdc32e7e4993b457356c472 | 38.253731 | 96 | 0.620152 | 3.861968 | false | false | false | false |
mozilla/kitsune | kitsune/wiki/migrations/0010_change_locale_bn_BD_to_bn.py | 2 | 1573 | # -*- coding: utf-8 -*-
# Generated by Django 1.11.22 on 2019-08-16 16:54
from __future__ import unicode_literals
from django.db import migrations
from django.db.models import OuterRef, Exists
def change_locale_bn_bd_to_bn_forwards(apps, schema_editor):
Document = apps.get_model('wiki', 'Document')
DraftRevi... | bsd-3-clause | 57bcff2041fcfa324c91724b8b7fb91a | 36.452381 | 101 | 0.612842 | 3.616092 | false | false | false | false |
mozilla/kitsune | kitsune/sumo/tests/test_json_decorator.py | 1 | 2178 | import json
from django import http
from django.core.exceptions import PermissionDenied
from django.test import RequestFactory, TestCase
from kitsune.sumo.decorators import json_view
rf = RequestFactory()
JSON = "application/json"
class JsonViewTests(TestCase):
def test_object(self):
data = {
... | bsd-3-clause | df20faa3f02503c4a3e50628fe6ce56c | 26.923077 | 51 | 0.572084 | 3.917266 | false | true | false | false |
mozilla/kitsune | kitsune/kbadge/migrations/0004_auto_20200629_0826.py | 1 | 1098 | # Generated by Django 2.2.13 on 2020-06-29 08:26
from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
('kbadge', '0003_auto_20190816_1824'),
]
operations = [
migrations.AlterField(
model_name='award',
name='description'... | bsd-3-clause | 733bc1ff560f0f32f19cbf0204d57e3a | 32.272727 | 138 | 0.590164 | 4.159091 | false | false | false | false |
mozilla/kitsune | kitsune/upload/tests/test_models.py | 1 | 1333 | from django.contrib.contenttypes.models import ContentType
from django.core.files import File
from kitsune.questions.tests import QuestionFactory
from kitsune.sumo.tests import TestCase
from kitsune.upload.models import ImageAttachment
from kitsune.upload.tasks import generate_thumbnail
from kitsune.users.tests import... | bsd-3-clause | b07ca4c705d8344406a3bf81071a573a | 38.205882 | 83 | 0.705176 | 3.920588 | false | true | false | false |
mozilla/kitsune | kitsune/search/tests/test_views.py | 1 | 2661 | import json
from pyquery import PyQuery as pq
from kitsune.search.tests import Elastic7TestCase
from kitsune.sumo.urlresolvers import reverse
class TestSearchSEO(Elastic7TestCase):
"""Test SEO-related aspects of the SUMO search view."""
def test_simple_search(self):
"""
Test SEO-related res... | bsd-3-clause | 34515864ed6f3cbb930119e1dddb5688 | 42.622951 | 89 | 0.639985 | 3.790598 | false | true | false | false |
web2py/pydal | pydal/restapi.py | 1 | 22878 | import collections
import copy
import datetime
import fnmatch
import functools
import re
import traceback
__version__ = "0.1"
__all__ = ["RestAPI", "Policy", "ALLOW_ALL_POLICY", "DENY_ALL_POLICY"]
MAX_LIMIT = 1000
class PolicyViolation(ValueError):
pass
class InvalidFormat(ValueError):
pass
class NotFo... | bsd-3-clause | 2cbe6f608ae460dca8b3ea3103984f03 | 37.974446 | 94 | 0.508523 | 4.164179 | false | false | false | false |
web2py/pydal | pydal/helpers/classes.py | 1 | 16435 | # -*- coding: utf-8 -*-
import copy
import marshal
import struct
import threading
import time
import traceback
from .._compat import (PY2, copyreg, exists, implements_bool, iteritems,
iterkeys, itervalues, long, to_bytes)
from .._globals import THREAD_LOCAL
from .serializers import serializers
... | bsd-3-clause | ecc0a54e22c70d8f2f65a4b24e4dbea0 | 26.761824 | 151 | 0.567995 | 4.018337 | false | false | false | false |
openstates/billy | billy/web/public/views/region.py | 2 | 6017 | """
views that are specific to a region
"""
import re
import urllib
from collections import defaultdict
from django.shortcuts import redirect, render
from django.http import Http404
from billy.core import settings
from billy.models import db, Metadata, DoesNotExist, Bill
from ..forms import get_region_select_form... | bsd-3-clause | 5a5dc5297e53fe039e490c41ff86c7d5 | 31.524324 | 79 | 0.561243 | 3.716492 | false | false | false | false |
openstates/billy | billy/models/metadata.py | 2 | 6491 | import operator
import itertools
from django.core import urlresolvers
from billy.core import mdb as db, settings
from .base import (Document, RelatedDocument, RelatedDocuments, ListManager,
DictManager, AttrManager, DoesNotExist)
from ..utils import metadata as get_metadata
_distinct_subjects = {}... | bsd-3-clause | 43f43cbca38bd5121588c55210afe612 | 32.984293 | 93 | 0.578955 | 4.239713 | false | false | false | false |
openstates/billy | billy/importers/bills.py | 2 | 17884 | from __future__ import print_function
import os
import glob
import json
import logging
import datetime
from time import time
from collections import defaultdict
from billy.core import settings, db
from billy.utils import (metadata, term_for_session, fix_bill_id,
JSONEncoderPlus)
from billy.imp... | bsd-3-clause | eb0d76e068c9e98b4f84298e442c04c8 | 31.281588 | 78 | 0.576605 | 3.734391 | false | false | false | false |
openstates/billy | billy/web/api/emitters.py | 2 | 2154 | import json
import datetime
from billy.utils import chamber_name
from billy.core import settings
from django.template import defaultfilters
from piston.emitters import Emitter, JSONEmitter
class DateTimeAwareJSONEncoder(json.JSONEncoder):
# We wouldn't need this if django's stupid DateTimeAwareJSONEncoder
#... | bsd-3-clause | 8080cd5aeffa49acd967ffc1e1241768 | 31.149254 | 74 | 0.574745 | 4.240157 | false | false | false | false |
gautamkrishnar/socli | socli/socli.py | 1 | 18764 | """
# Stack Overflow CLI
# Created by
# Gautam Krishna R : www.github.com/gautamkrishnar
# And open source contributors at GitHub: https://github.com/gautamkrishnar/socli#contributors
"""
import os
import re
import sys
import logging
import requests
from bs4 import BeautifulSoup
import urwid
import urllib3
try:
i... | bsd-3-clause | 15749312a1efbd0432f17659721639cd | 38.25523 | 120 | 0.554519 | 4.223273 | false | false | false | false |
numpy/numpy | numpy/core/tests/test_getlimits.py | 5 | 5306 | """ Test functions for limits module.
"""
import warnings
import numpy as np
from numpy.core import finfo, iinfo
from numpy import half, single, double, longdouble
from numpy.testing import assert_equal, assert_, assert_raises
from numpy.core.getlimits import _discovered_machar, _float_ma
############################... | bsd-3-clause | 140ba4d48849b7e21804c64ff591df2d | 35.095238 | 75 | 0.570486 | 3.392583 | false | true | false | false |
numpy/numpy | numpy/ma/bench.py | 12 | 4859 | #!/usr/bin/env python3
import timeit
import numpy
###############################################################################
# Global variables #
###############################################################################
# Small arrays
xs = numpy... | bsd-3-clause | da1b107409d04ab6be2083feb0f869b6 | 36.369231 | 89 | 0.511733 | 3.16895 | false | false | false | false |
numpy/numpy | numpy/array_api/__init__.py | 6 | 10221 | """
A NumPy sub-namespace that conforms to the Python array API standard.
This submodule accompanies NEP 47, which proposes its inclusion in NumPy. It
is still considered experimental, and will issue a warning when imported.
This is a proof-of-concept namespace that wraps the corresponding NumPy
functions to give a c... | bsd-3-clause | efe4b22526c911b4114130324f91a491 | 26.111406 | 99 | 0.681832 | 3.796805 | false | false | false | false |
numpy/numpy | numpy/array_api/_array_object.py | 11 | 43226 | """
Wrapper class around the ndarray object for the array API standard.
The array API standard defines some behaviors differently than ndarray, in
particular, type promotion rules are different (the standard has no
value-based casting). The standard also specifies a more limited subset of
array methods and functionali... | bsd-3-clause | e79d7e93aeb471d42b97d0c40aedfd94 | 37.663685 | 151 | 0.556262 | 4.351319 | false | false | false | false |
django-oscar/django-oscar | src/oscar/management/commands/oscar_cleanup_alerts.py | 11 | 1727 | import logging
from datetime import timedelta
from django.core.management.base import BaseCommand
from django.utils.timezone import now
from oscar.core.loading import get_model
ProductAlert = get_model('customer', 'ProductAlert')
logger = logging.getLogger(__name__)
class Command(BaseCommand):
"""
Command... | bsd-3-clause | 406a6e2d47b0841679bf1ad08be12a7b | 30.4 | 68 | 0.605096 | 4.532808 | false | false | false | false |
django-oscar/django-oscar | src/oscar/apps/communication/notifications/views.py | 3 | 3424 | from django.conf import settings
from django.contrib import messages
from django.utils.html import strip_tags
from django.utils.timezone import now
from django.utils.translation import gettext_lazy as _
from django.utils.translation import ngettext
from django.views import generic
from oscar.core.loading import get_cl... | bsd-3-clause | 327e462e75abbfa63a8e9b9cfa0be1f1 | 31.923077 | 69 | 0.667348 | 4.211562 | false | false | false | false |
django-oscar/django-oscar | tests/integration/dashboard/test_voucher_views.py | 2 | 4803 | import pytest
from django.contrib.messages import get_messages
from django.urls import reverse
from oscar.apps.dashboard.vouchers import views
from oscar.core.loading import get_model
from oscar.test.factories import voucher
from oscar.test.factories.offer import ConditionalOfferFactory
from tests.fixtures import Requ... | bsd-3-clause | 94fcd0e42f7c368a38fe0654f6e18171 | 41.504425 | 118 | 0.647096 | 3.772977 | false | true | false | false |
django-oscar/django-oscar | src/oscar/apps/basket/admin.py | 31 | 1153 | from django.contrib import admin
from oscar.core.loading import get_model
Line = get_model('basket', 'line')
class LineInline(admin.TabularInline):
model = Line
readonly_fields = ('line_reference', 'product', 'price_excl_tax',
'price_incl_tax', 'price_currency', 'stockrecord')
class... | bsd-3-clause | 785068cff264f183edf9b3e12b0871f6 | 35.03125 | 76 | 0.619254 | 3.695513 | false | false | false | false |
django-oscar/django-oscar | src/oscar/apps/customer/apps.py | 3 | 10953 | from django.contrib.auth.decorators import login_required
from django.urls import path, re_path
from django.utils.translation import gettext_lazy as _
from django.views import generic
from oscar.core.application import OscarConfig
from oscar.core.loading import get_class
class CustomerConfig(OscarConfig):
label ... | bsd-3-clause | fa328c50b41ebde3e51c4e1fce11cf27 | 53.765 | 119 | 0.563681 | 4.201381 | false | false | false | false |
django-oscar/django-oscar | src/oscar/apps/checkout/applicator.py | 3 | 1544 | class SurchargeList(list):
@property
def total(self):
return sum([surcharge.price for surcharge in self])
class SurchargePrice():
surcharge = None
price = None
def __init__(self, surcharge, price):
self.surcharge = surcharge
self.price = price
class SurchargeApplicator()... | bsd-3-clause | ee5c7b696ef5f3a6aac3682db90f0a40 | 27.072727 | 102 | 0.57772 | 4.253444 | false | false | false | false |
django-oscar/django-oscar | src/oscar/apps/catalogue/receivers.py | 3 | 1340 | # -*- coding: utf-8 -*-
from django.conf import settings
from django.db.models.signals import post_delete, post_save
from django.dispatch import receiver
from oscar.core.loading import get_model
Category = get_model("catalogue", "Category")
if settings.OSCAR_DELETE_IMAGE_FILES:
from django.db import models
... | bsd-3-clause | 8409d48a012f43d9c605d150fc7bf3ee | 34.263158 | 78 | 0.693284 | 4 | false | false | false | false |
django-oscar/django-oscar | src/oscar/apps/catalogue/migrations/0003_data_migration_slugs.py | 62 | 1457 | # -*- coding: utf-8 -*-
from __future__ import unicode_literals
from django.db import models, migrations
from oscar.core.loading import get_model
# Django database migrations require us to fetch the category model
# via apps.get_model to get an instance of the model at this point
# in time of migrations. That snapsh... | bsd-3-clause | 9f22fd113f90fd3c688bcec60254de6e | 32.883721 | 76 | 0.719286 | 3.885333 | false | false | false | false |
django-oscar/django-oscar | src/oscar/apps/payment/migrations/0001_initial.py | 11 | 4917 | # -*- coding: utf-8 -*-
from __future__ import unicode_literals
from django.db import models, migrations
import oscar.models.fields.autoslugfield
from django.conf import settings
from decimal import Decimal
class Migration(migrations.Migration):
dependencies = [
('order', '0001_initial'),
migrat... | bsd-3-clause | 2d28076a30e0b416e6a554550015977c | 51.308511 | 242 | 0.576571 | 4.335979 | false | false | false | false |
django-oscar/django-oscar | src/oscar/apps/analytics/receivers.py | 3 | 4057 | import logging
from django.db import IntegrityError
from django.db.models import F
from django.dispatch import receiver
from oscar.apps.basket.signals import basket_addition
from oscar.apps.catalogue.signals import product_viewed
from oscar.apps.order.signals import order_placed
from oscar.apps.search.signals import ... | bsd-3-clause | c8806a8980f05340c1c9145d941a5199 | 35.881818 | 80 | 0.670446 | 3.830973 | false | false | false | false |
django-oscar/django-oscar | src/oscar/apps/dashboard/widgets.py | 5 | 3127 | import copy
import re
from django.forms import Widget
from django.urls import reverse
class RelatedFieldWidgetWrapper(Widget):
"""
This class is a wrapper to a given widget to add the add icon for the
Oscar dashboard.
"""
template_name = 'oscar/dashboard/widgets/related_widget_wrapper.html'
... | bsd-3-clause | 72e4856b5a65d7ede88a3c386ce224cb | 33.744444 | 107 | 0.622642 | 3.6875 | false | false | false | false |
django-oscar/django-oscar | src/oscar/apps/offer/queryset.py | 1 | 2778 | from django.db import models
from oscar.core.loading import get_class
ExpandUpwardsCategoryQueryset = get_class("catalogue.expressions", "ExpandUpwardsCategoryQueryset")
class RangeQuerySet(models.query.QuerySet):
"""
This queryset add ``contains_product`` which allows selecting the
ranges that contain ... | bsd-3-clause | 77e6d1b4d533de45ab3dfd143b2bff1a | 42.40625 | 110 | 0.651908 | 4.52443 | false | false | false | false |
django-oscar/django-oscar | src/oscar/apps/payment/forms.py | 2 | 9663 | import re
from calendar import monthrange
from datetime import date
from django import forms
from django.core import validators
from django.core.exceptions import ImproperlyConfigured
from django.utils.translation import gettext_lazy as _
from oscar.core.loading import get_class, get_model
from oscar.forms.mixins imp... | bsd-3-clause | 27063a445a4ba60da80f9174735356fa | 33.144876 | 79 | 0.575184 | 4.136558 | false | false | false | false |
django-oscar/django-oscar | tests/_site/myauth/models.py | 3 | 1632 | # -*- coding: utf-8 -*-
import re
from django.contrib.auth.models import BaseUserManager
from django.core import validators
from django.db import models
from django.utils.translation import gettext_lazy as _
from oscar.apps.customer.abstract_models import AbstractUser
class CustomUserManager(BaseUserManager):
... | bsd-3-clause | 36f519ef9e8fb11433a49873cf585322 | 27.631579 | 106 | 0.616422 | 4.142132 | false | false | false | false |
django-oscar/django-oscar | tests/unit/offer/test_reports.py | 2 | 1269 | from django.test import TestCase
from oscar.apps.offer.reports import OfferReportGenerator
from oscar.test.factories import (
ConditionalOfferFactory, OrderDiscountFactory, create_order)
class OfferReportGeneratorTestCase(TestCase):
def test_generator_queryset_and_annotation(self):
offer = Condition... | bsd-3-clause | d95ad0165c6346c97a37c6f7f7ea802c | 47.807692 | 102 | 0.704492 | 3.833837 | false | true | false | false |
django-oscar/django-oscar | src/oscar/apps/partner/strategy.py | 1 | 13435 | from collections import namedtuple
from decimal import Decimal as D
from oscar.core.loading import get_class
Unavailable = get_class('partner.availability', 'Unavailable')
Available = get_class('partner.availability', 'Available')
StockRequiredAvailability = get_class('partner.availability', 'StockRequired')
Unavaila... | bsd-3-clause | 1dd9c656eb12491da4fd2d6ac24ca82d | 34.262467 | 116 | 0.657611 | 4.585324 | false | false | false | false |
django-oscar/django-oscar | src/oscar/apps/dashboard/catalogue/apps.py | 3 | 8509 | from django.urls import path
from django.utils.translation import gettext_lazy as _
from oscar.core.application import OscarDashboardConfig
from oscar.core.loading import get_class
class CatalogueDashboardConfig(OscarDashboardConfig):
label = 'catalogue_dashboard'
name = 'oscar.apps.dashboard.catalogue'
... | bsd-3-clause | 12c9c05a0878aaa5d994a180de51b182 | 55.350993 | 115 | 0.548008 | 4.735114 | false | false | false | false |
django-oscar/django-oscar | src/oscar/apps/catalogue/migrations/0024_remove_duplicate_attributes.py | 2 | 5106 | # Generated by Django 3.2.9 on 2022-01-25 19:01
import logging
from django.db import migrations
from django.db.models import CharField, Count, Value
from django.db.models.functions import Concat
from oscar.core.loading import get_model
# Needed for calling _get_value, the historical model can't be used for that.
Non... | bsd-3-clause | 83c6042d78d9506fbbe7cca850b6fd3b | 48.105769 | 123 | 0.659616 | 4.534636 | false | false | false | false |
django-oscar/django-oscar | src/oscar/apps/partner/migrations/0001_initial.py | 24 | 6571 | # -*- coding: utf-8 -*-
from __future__ import unicode_literals
from django.db import models, migrations
import oscar.models.fields.autoslugfield
import oscar.models.fields
from django.conf import settings
class Migration(migrations.Migration):
dependencies = [
('catalogue', '0001_initial'),
('a... | bsd-3-clause | f8f077dea80b5299054ebf6f5a580d1e | 58.736364 | 179 | 0.588799 | 4.253074 | false | false | false | false |
django-oscar/django-oscar | src/oscar/defaults.py | 2 | 7714 | from django.urls import reverse_lazy
from django.utils.translation import gettext_lazy as _
OSCAR_SHOP_NAME = 'Oscar'
OSCAR_SHOP_TAGLINE = ''
OSCAR_HOMEPAGE = reverse_lazy('catalogue:index')
# Dynamic class loading
OSCAR_DYNAMIC_CLASS_LOADER = 'oscar.core.loading.default_class_loader'
# Basket settings
OSCAR_BASKET_... | bsd-3-clause | 787feee56e8ea938cc5e7afbd6317876 | 29.370079 | 94 | 0.542779 | 3.631827 | false | false | false | false |
django-oscar/django-oscar | tests/_site/apps/catalogue/migrations/0016_auto_20190327_0757.py | 6 | 1394 | # -*- coding: utf-8 -*-
# Generated by Django 1.11.20 on 2019-03-27 07:57
from __future__ import unicode_literals
from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
('catalogue', '0015_product_is_public'),
]
operations = [
migrations.AlterFi... | bsd-3-clause | 98c935daea128abe950df80b7dd259ea | 33.85 | 102 | 0.605452 | 4.315789 | false | false | false | false |
pandas-dev/pandas | pandas/core/_numba/kernels/min_max_.py | 2 | 1857 | """
Numba 1D min/max kernels that can be shared by
* Dataframe / Series
* groupby
* rolling / expanding
Mirrors pandas/_libs/window/aggregation.pyx
"""
from __future__ import annotations
import numba
import numpy as np
@numba.jit(nopython=True, nogil=True, parallel=False)
def sliding_min_max(
values: np.ndarray... | bsd-3-clause | 01458071bcd1c7ed0cedb55a585a8b6d | 25.528571 | 86 | 0.493807 | 3.413603 | false | false | false | false |
pandas-dev/pandas | pandas/tests/frame/methods/test_combine_first.py | 1 | 19110 | from datetime import datetime
import numpy as np
import pytest
from pandas.compat import pa_version_under7p0
from pandas.errors import PerformanceWarning
from pandas.core.dtypes.cast import find_common_type
from pandas.core.dtypes.common import is_dtype_equal
import pandas as pd
from pandas import (
DataFrame,
... | bsd-3-clause | bc949fbc4602355445e52666eeffda59 | 34.06422 | 88 | 0.514652 | 3.120509 | false | false | false | false |
pandas-dev/pandas | pandas/core/indexes/datetimelike.py | 1 | 24625 | """
Base and utility classes for tseries type pandas objects.
"""
from __future__ import annotations
from datetime import datetime
from typing import (
TYPE_CHECKING,
Any,
Callable,
Sequence,
TypeVar,
cast,
final,
)
import numpy as np
from pandas._libs import (
NaT,
Timedelta,
... | bsd-3-clause | 3341f3c1f51ca9d8277d2536b517aadd | 32.594816 | 87 | 0.557929 | 4.129633 | false | false | false | false |
pandas-dev/pandas | pandas/_config/config.py | 1 | 24603 | """
The config module holds package-wide configurables and provides
a uniform API for working with them.
Overview
========
This module supports the following requirements:
- options are referenced using keys in dot.notation, e.g. "x.y.option - z".
- keys are case-insensitive.
- functions should accept partial/regex k... | bsd-3-clause | d7e0eef3e82a39ea7a43c0ded1597739 | 25.976974 | 86 | 0.619233 | 3.855061 | false | false | false | false |
pandas-dev/pandas | pandas/tests/frame/methods/test_isin.py | 5 | 7323 | import numpy as np
import pytest
import pandas as pd
from pandas import (
DataFrame,
MultiIndex,
Series,
)
import pandas._testing as tm
class TestDataFrameIsIn:
def test_isin(self):
# GH#4211
df = DataFrame(
{
"vals": [1, 2, 3, 4],
"ids": ["... | bsd-3-clause | 2dc17fd398a7261fa0d02031f005cede | 32.438356 | 83 | 0.474669 | 3.240265 | false | true | false | false |
pandas-dev/pandas | asv_bench/benchmarks/strftime.py | 2 | 1818 | import numpy as np
import pandas as pd
from pandas import offsets
class DatetimeStrftime:
timeout = 1500
params = [1000, 10000]
param_names = ["obs"]
def setup(self, obs):
d = "2018-11-29"
dt = "2018-11-26 11:18:27.0"
self.data = pd.DataFrame(
{
"d... | bsd-3-clause | 9636d3138181946ea50967b0faafd712 | 27.40625 | 72 | 0.562156 | 3.252236 | false | false | false | false |
pandas-dev/pandas | pandas/core/common.py | 1 | 17076 | """
Misc tools for implementing data structures
Note: pandas.core.common is *not* part of the public API.
"""
from __future__ import annotations
import builtins
from collections import (
abc,
defaultdict,
)
import contextlib
from functools import partial
import inspect
from typing import (
TYPE_CHECKING,
... | bsd-3-clause | c0b958c9e4f22ca745845c5911b8c246 | 26.061807 | 88 | 0.618763 | 3.985994 | false | false | false | false |
pandas-dev/pandas | pandas/core/arrays/string_.py | 1 | 18543 | from __future__ import annotations
from typing import TYPE_CHECKING
import numpy as np
from pandas._config import get_option
from pandas._libs import (
lib,
missing as libmissing,
)
from pandas._libs.arrays import NDArrayBacked
from pandas._typing import (
AxisInt,
Dtype,
Scalar,
npt,
ty... | bsd-3-clause | 56b5725004ca4d0bf8d6c5f74435d718 | 30.751712 | 88 | 0.569595 | 4.221995 | false | false | false | false |
pandas-dev/pandas | pandas/tests/base/test_misc.py | 2 | 6231 | import sys
import numpy as np
import pytest
from pandas.compat import (
IS64,
PYPY,
)
from pandas.core.dtypes.common import (
is_categorical_dtype,
is_dtype_equal,
is_object_dtype,
)
import pandas as pd
from pandas import (
Index,
Series,
)
import pandas._testing as tm
def test_isnull_... | bsd-3-clause | 7f8d7427e299b865eb2d3c5e6e56a905 | 30.469697 | 85 | 0.636495 | 3.475181 | false | true | false | false |
pandas-dev/pandas | asv_bench/benchmarks/io/sql.py | 1 | 5553 | import sqlite3
import numpy as np
from sqlalchemy import create_engine
from pandas import (
DataFrame,
date_range,
read_sql_query,
read_sql_table,
)
from ..pandas_vb_common import tm
class SQL:
params = ["sqlalchemy", "sqlite"]
param_names = ["connection"]
def setup(self, connection):... | bsd-3-clause | db3e3f0a907d1250e73c6f84b357edf0 | 30.372881 | 74 | 0.512696 | 3.514557 | false | false | false | false |
pandas-dev/pandas | pandas/tests/reshape/test_union_categoricals.py | 2 | 15004 | import numpy as np
import pytest
from pandas.core.dtypes.concat import union_categoricals
import pandas as pd
from pandas import (
Categorical,
CategoricalIndex,
Series,
)
import pandas._testing as tm
class TestUnionCategoricals:
@pytest.mark.parametrize(
"a, b, combined",
[
... | bsd-3-clause | 7e5cd222622dd6f63ec02721872db3b9 | 40.333333 | 85 | 0.55152 | 3.354348 | false | true | false | false |
pandas-dev/pandas | pandas/core/array_algos/take.py | 1 | 20618 | from __future__ import annotations
import functools
from typing import (
TYPE_CHECKING,
cast,
overload,
)
import numpy as np
from pandas._libs import (
algos as libalgos,
lib,
)
from pandas._typing import (
ArrayLike,
AxisInt,
npt,
)
from pandas.core.dtypes.cast import maybe_promote
... | bsd-3-clause | 04489db793dc07d7c0e5964ed245ae4a | 34.005093 | 88 | 0.621981 | 3.108397 | false | false | false | false |
pandas-dev/pandas | pandas/tests/indexing/multiindex/test_chaining_and_caching.py | 2 | 2416 | import numpy as np
import pytest
from pandas.errors import SettingWithCopyError
import pandas.util._test_decorators as td
from pandas import (
DataFrame,
MultiIndex,
Series,
)
import pandas._testing as tm
def test_detect_chained_assignment(using_copy_on_write):
# Inplace ops, originally from:
# ... | bsd-3-clause | 7e5adcd511e83189919b06aa3bfefb87 | 29.2 | 118 | 0.607202 | 3.133593 | false | true | false | false |
pandas-dev/pandas | pandas/tests/tseries/offsets/test_month.py | 1 | 23728 | """
Tests for the following offsets:
- SemiMonthBegin
- SemiMonthEnd
- MonthBegin
- MonthEnd
"""
from __future__ import annotations
from datetime import datetime
import pytest
from pandas._libs.tslibs import Timestamp
from pandas._libs.tslibs.offsets import (
MonthBegin,
MonthEnd,
SemiMonthBegin,
Sem... | bsd-3-clause | 548cf56a992929edaceb446e315f63bf | 33.99705 | 74 | 0.488368 | 3.836378 | false | true | false | false |
pandas-dev/pandas | pandas/io/pytables.py | 1 | 171363 | """
High level interface to PyTables for reading and writing pandas data structures
to disk
"""
from __future__ import annotations
from contextlib import suppress
import copy
from datetime import (
date,
tzinfo,
)
import itertools
import os
import re
from textwrap import dedent
from types import TracebackType
... | bsd-3-clause | 5bb3bd0cf201a35df47d5820e6e67694 | 31.271751 | 104 | 0.548747 | 4.220764 | false | false | false | false |
pandas-dev/pandas | pandas/_testing/contexts.py | 1 | 5441 | from __future__ import annotations
from contextlib import contextmanager
import os
from pathlib import Path
import tempfile
from types import TracebackType
from typing import (
IO,
Any,
Generator,
)
import uuid
import numpy as np
from pandas import set_option
from pandas.io.common import get_handle
@c... | bsd-3-clause | d9ff9e9092e1744bcb761e8a8a6a3b4a | 22.759825 | 84 | 0.611836 | 4.12197 | false | false | false | false |
pandas-dev/pandas | pandas/core/arrays/_ranges.py | 1 | 7434 | """
Helper functions to generate range-like data for DatetimeArray
(and possibly TimedeltaArray/PeriodArray)
"""
from __future__ import annotations
import numpy as np
from pandas._libs.lib import i8max
from pandas._libs.tslibs import (
BaseOffset,
OutOfBoundsDatetime,
Timedelta,
Timestamp,
iNaT,
)... | bsd-3-clause | 9697f684e7081469c18ee76a7254c7be | 34.569378 | 88 | 0.622814 | 4.153073 | false | false | false | false |
pandas-dev/pandas | asv_bench/benchmarks/index_cached_properties.py | 1 | 2268 | import pandas as pd
class IndexCache:
number = 1
repeat = (3, 100, 20)
params = [
[
"CategoricalIndex",
"DatetimeIndex",
"Float64Index",
"IntervalIndex",
"Int64Index",
"MultiIndex",
"PeriodIndex",
"Ran... | bsd-3-clause | f56b666c4b89fc1b348b47e48628d509 | 30.5 | 81 | 0.545414 | 3.6 | false | false | false | false |
pandas-dev/pandas | asv_bench/benchmarks/io/hdf.py | 1 | 3987 | import numpy as np
from pandas import (
DataFrame,
HDFStore,
date_range,
read_hdf,
)
from ..pandas_vb_common import (
BaseIO,
tm,
)
class HDFStoreDataFrame(BaseIO):
def setup(self):
N = 25000
index = tm.makeStringIndex(N)
self.df = DataFrame(
{"float1"... | bsd-3-clause | 201e4a745c15b875e00e60702555ca84 | 27.891304 | 85 | 0.570855 | 3.281481 | false | false | false | false |
pandas-dev/pandas | pandas/_typing.py | 1 | 10358 | from __future__ import annotations
from datetime import (
datetime,
timedelta,
tzinfo,
)
from os import PathLike
from typing import (
TYPE_CHECKING,
Any,
Callable,
Dict,
Hashable,
Iterator,
List,
Literal,
Mapping,
Optional,
Protocol,
Sequence,
Tuple,
... | bsd-3-clause | 389b2aa9ef4d15a9abe0fa240ad6eba1 | 27.932961 | 88 | 0.697528 | 3.54362 | false | false | false | false |
pandas-dev/pandas | asv_bench/benchmarks/tslibs/timedelta.py | 2 | 1593 | """
Timedelta benchmarks that rely only on tslibs. See benchmarks.timedeltas for
Timedelta benchmarks that rely on other parts of pandas.
"""
import datetime
import numpy as np
from pandas import Timedelta
class TimedeltaConstructor:
def setup(self):
self.nptimedelta64 = np.timedelta64(3600)
sel... | bsd-3-clause | 46c7a89d67b497066e323e818f7a50f3 | 22.086957 | 76 | 0.627119 | 3.739437 | false | false | false | false |
pandas-dev/pandas | pandas/tests/indexes/period/test_formats.py | 6 | 6587 | import numpy as np
import pytest
import pandas as pd
from pandas import (
PeriodIndex,
Series,
)
import pandas._testing as tm
def test_to_native_types():
index = PeriodIndex(["2017-01-01", "2017-01-02", "2017-01-03"], freq="D")
# First, with no arguments.
expected = np.array(["2017-01-01", "2017... | bsd-3-clause | 2c78eac1fdd82a0bc40a7645a4cd0b79 | 32.100503 | 85 | 0.554577 | 3.00639 | false | false | false | false |
pandas-dev/pandas | asv_bench/benchmarks/attrs_caching.py | 1 | 1415 | import numpy as np
import pandas as pd
from pandas import DataFrame
try:
from pandas.core.construction import extract_array
except ImportError:
extract_array = None
class DataFrameAttributes:
def setup(self):
self.df = DataFrame(np.random.randn(10, 6))
self.cur_index = self.df.index
... | bsd-3-clause | 330ff5e4f41aa483a64e39679b54d932 | 26.745098 | 79 | 0.612721 | 3.609694 | false | false | false | false |
pandas-dev/pandas | pandas/core/reshape/tile.py | 1 | 21384 | """
Quantilization functions and related stuff
"""
from __future__ import annotations
from typing import (
Any,
Callable,
Literal,
)
import numpy as np
from pandas._libs import (
Timedelta,
Timestamp,
)
from pandas._libs.lib import infer_dtype
from pandas._typing import IntervalLeftRight
from pa... | bsd-3-clause | 41983585346fcf20157e17ba34495765 | 32.102167 | 88 | 0.600402 | 3.701575 | false | false | false | false |
pandas-dev/pandas | pandas/tests/extension/test_floating.py | 2 | 5416 | """
This file contains a minimal set of tests for compliance with the extension
array interface test suite, and should contain no other tests.
The test suite for the full functionality of the array is located in
`pandas/tests/arrays/`.
The tests in this file are inherited from the BaseExtensionTests, and only
minimal ... | bsd-3-clause | 0557829d264bebed44265c55ffeb153b | 24.074074 | 83 | 0.656573 | 3.469571 | false | true | false | false |
pandas-dev/pandas | pandas/tests/resample/test_resampler_grouper.py | 1 | 15621 | from textwrap import dedent
import numpy as np
import pytest
import pandas.util._test_decorators as td
from pandas.util._test_decorators import async_mark
import pandas as pd
from pandas import (
DataFrame,
Index,
Series,
TimedeltaIndex,
Timestamp,
)
import pandas._testing as tm
from pandas.core.... | bsd-3-clause | 35cbe4f1a3d4efaa1e4b05a47684cf18 | 29.098266 | 88 | 0.560271 | 3.157033 | false | true | false | false |
pandas-dev/pandas | pandas/tests/tseries/offsets/test_ticks.py | 1 | 10870 | """
Tests for offsets.Tick and subclasses
"""
from datetime import (
datetime,
timedelta,
)
from hypothesis import (
assume,
example,
given,
)
import numpy as np
import pytest
from pandas._libs.tslibs.offsets import delta_to_tick
from pandas import (
Timedelta,
Timestamp,
)
import pandas.... | bsd-3-clause | 8580dd3038ffd22b8f3709cfed2f7521 | 26.800512 | 88 | 0.59126 | 3.165405 | false | true | false | false |
pandas-dev/pandas | asv_bench/benchmarks/tslibs/fields.py | 3 | 1749 | import numpy as np
from pandas._libs.tslibs.fields import (
get_date_field,
get_start_end_field,
get_timedelta_field,
)
from .tslib import _sizes
class TimeGetTimedeltaField:
params = [
_sizes,
["days", "seconds", "microseconds", "nanoseconds"],
]
param_names = ["size", "fiel... | bsd-3-clause | c45c248ca844887cd11c6b19c80a6366 | 22.635135 | 83 | 0.509434 | 3.293785 | false | false | false | false |
pandas-dev/pandas | scripts/use_io_common_urlopen.py | 2 | 1677 | """
Check that pandas/core imports pandas.array as pd_array.
This makes it easier to grep for usage of pandas array.
This is meant to be run as a pre-commit hook - to run it manually, you can do:
pre-commit run use-io-common-urlopen --all-files
"""
from __future__ import annotations
import argparse
import ast... | bsd-3-clause | 6eb51b89146d82dee2439cacca41685c | 25.619048 | 78 | 0.621348 | 3.62203 | false | false | false | false |
pandas-dev/pandas | pandas/io/formats/excel.py | 1 | 32051 | """
Utilities for conversion to writer-agnostic Excel representation.
"""
from __future__ import annotations
from functools import (
lru_cache,
reduce,
)
import itertools
import re
from typing import (
Any,
Callable,
Hashable,
Iterable,
Mapping,
Sequence,
cast,
)
import warnings
im... | bsd-3-clause | a3de55fdec5ae06c52981cd235ae3da1 | 33.573894 | 88 | 0.522715 | 4.16775 | false | false | false | false |
pandas-dev/pandas | pandas/tests/io/test_spss.py | 8 | 2745 | from pathlib import Path
import numpy as np
import pytest
import pandas as pd
import pandas._testing as tm
pyreadstat = pytest.importorskip("pyreadstat")
@pytest.mark.parametrize("path_klass", [lambda p: p, Path])
def test_spss_labelled_num(path_klass, datapath):
# test file from the Haven project (https://hav... | bsd-3-clause | 72c37d26809dfe91ed4d47a207a6b089 | 35.065789 | 82 | 0.668734 | 3.059152 | false | true | false | false |
pandas-dev/pandas | pandas/tests/indexes/datetimes/test_unique.py | 3 | 2065 | from datetime import (
datetime,
timedelta,
)
from pandas import (
DatetimeIndex,
NaT,
Timestamp,
)
import pandas._testing as tm
def test_unique(tz_naive_fixture):
idx = DatetimeIndex(["2017"] * 2, tz=tz_naive_fixture)
expected = idx[:1]
result = idx.unique()
tm.assert_index_equ... | bsd-3-clause | 3611ec5d16b884c1d876acaab2205e95 | 25.818182 | 82 | 0.642615 | 3.413223 | false | true | false | false |
pandas-dev/pandas | pandas/core/arrays/sparse/accessor.py | 1 | 11914 | """Sparse accessor"""
from __future__ import annotations
from typing import TYPE_CHECKING
import numpy as np
from pandas.compat._optional import import_optional_dependency
from pandas.core.dtypes.cast import find_common_type
from pandas.core.accessor import (
PandasDelegate,
delegate_names,
)
from pandas.c... | bsd-3-clause | 71966b4b1e1701866c60ef75a672e088 | 29.162025 | 86 | 0.531056 | 3.971333 | false | false | false | false |
pandas-dev/pandas | pandas/core/indexers/objects.py | 2 | 12836 | """Indexer objects for computing start/end window bounds for rolling operations"""
from __future__ import annotations
from datetime import timedelta
import numpy as np
from pandas._libs.window.indexers import calculate_variable_window_bounds
from pandas.util._decorators import Appender
from pandas.core.dtypes.commo... | bsd-3-clause | e5694d70db3de8bb3028f415feae8d8d | 31.251256 | 88 | 0.572375 | 4.015014 | false | false | false | false |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.