repo stringclasses 454
values | file_path stringlengths 5 201 | extension stringclasses 1
value | content stringlengths 8 509k | num_lines int64 3 16.9k | size_bytes int64 8 511k |
|---|---|---|---|---|---|
probability | tensorflow_probability/python/sts/regularization_test.py | .py | # Copyright 2021 The TensorFlow Probability Authors.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law o... | 216 | 9,925 |
textual | docs/examples/styles/outline.py | .py | from textual.app import App
from textual.widgets import Label
TEXT = """I must not fear.
Fear is the mind-killer.
Fear is the little-death that brings total obliteration.
I will face my fear.
I will permit it to pass over me and through me.
And when it has gone past, I will turn the inner eye to see its path.
Where th... | 23 | 553 |
metrics | src/torchmetrics/functional/image/scc.py | .py | # Copyright The Lightning team.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writin... | 221 | 8,610 |
luigi | test/list_parameter_test.py | .py | # -*- coding: utf-8 -*-
#
# Copyright 2012-2015 Spotify AB
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law... | 130 | 4,457 |
saleor | saleor/graphql/meta/tests/mutations/test_delete_metadata.py | .py | import base64
import graphene
from .....core.error_codes import MetadataErrorCode
from .....core.models import ModelWithMetadata
from .....tests import race_condition
from ....tests.utils import get_graphql_content
from . import PUBLIC_KEY, PUBLIC_KEY2, PUBLIC_VALUE, PUBLIC_VALUE2
from .test_update_metadata import it... | 237 | 6,447 |
saleor | saleor/graphql/core/tests/test_converters.py | .py | import graphene
import pytest
from django import forms
from ..types.converter import convert_form_field, get_form_field_description
nonempty_text = "Some text"
@pytest.fixture
def mockfield():
class Field:
pass
return Field()
def test_get_form_field_description_empty_help_text(mockfield):
# g... | 93 | 2,403 |
black | tests/data/cases/pattern_matching_generic.py | .py | # flags: --minimum-version=3.10
re.match()
match = a
with match() as match:
match = f"{match}"
re.match()
match = a
with match() as match:
match = f"{match}"
def get_grammars(target_versions: Set[TargetVersion]) -> List[Grammar]:
if not target_versions:
# No target_version specified, so try all g... | 109 | 3,098 |
saleor | saleor/webhook/payloads.py | .py | import json
import uuid
from collections import defaultdict
from collections.abc import Iterable
from dataclasses import asdict
from decimal import Decimal
from typing import TYPE_CHECKING, Any, Optional, Union
import graphene
from django.contrib.sites.models import Site
from django.db.models import F, QuerySet, Sum
... | 1,302 | 42,548 |
loguru | tests/exceptions/source/backtrace/chained_expression_indirect.py | .py | import sys
from loguru import logger
logger.remove()
logger.add(sys.stderr, format="", colorize=False, backtrace=True, diagnose=False)
def a():
try:
1 / 0
except ZeroDivisionError:
raise ValueError("NOK")
@logger.catch
def b():
a()
b()
with logger.catch():
a()
try:
a()
exce... | 30 | 360 |
kafka | tests/kafkatest/tests/kafka_test.py | .py | # Licensed to the Apache Software Foundation (ASF) under one or more
# contributor license agreements. See the NOTICE file distributed with
# this work for additional information regarding copyright ownership.
# The ASF licenses this file to You under the Apache License, Version 2.0
# (the "License"); you may not use ... | 47 | 1,928 |
astropy | astropy/tests/test_logger.py | .py | # Licensed under a 3-clause BSD style license - see LICENSE.rst
import importlib
import locale
import logging
import sys
import warnings
import pytest
from astropy import log
from astropy.logger import _WITHIN_IPYTHON, LoggingError, conf
from astropy.utils.exceptions import AstropyUserWarning, AstropyWarning
# Save... | 504 | 15,770 |
sqlmap | thirdparty/chardet/universaldetector.py | .py | ######################## BEGIN LICENSE BLOCK ########################
# The Original Code is Mozilla Universal charset detector code.
#
# The Initial Developer of the Original Code is
# Netscape Communications Corporation.
# Portions created by the Initial Developer are Copyright (C) 2001
# the Initial Developer. All R... | 287 | 12,503 |
wagtail | wagtail/admin/rich_text/editors/draftail/features.py | .py | from django.forms import Media
from wagtail.admin.staticfiles import versioned_static
# Feature objects: these are mapped to feature identifiers within the rich text
# feature registry (wagtail.rich_text.features). Each one implements
# a `construct_options` method which modifies an options dict as appropriate to
# e... | 95 | 2,593 |
mlflow | mlflow/cli/scorers.py | .py | import json
from typing import Literal
import click
from mlflow.environment_variables import MLFLOW_EXPERIMENT_ID
from mlflow.genai.judges import make_judge
from mlflow.genai.scorers import get_all_scorers
from mlflow.genai.scorers import list_scorers as list_scorers_api
from mlflow.mcp.decorator import mlflow_mcp
fr... | 251 | 8,041 |
sphinx | tests/roots/test-ext-napoleon/mypackage/typehints.py | .py | def hello(x: int, *args: int, **kwargs: int) -> None:
"""Parameters
----------
x
X
*args
Additional arguments.
**kwargs
Extra arguments.
"""
| 11 | 189 |
deap | doc/code/tutorials/part_2/2_2_2_permutation.py | .py | ## 2.2.2 Permutation
import random
from deap import base
from deap import creator
from deap import tools
creator.create("FitnessMin", base.Fitness, weights=(-1.0,))
creator.create("Individual", list, fitness=creator.FitnessMin)
IND_SIZE=10
toolbox = base.Toolbox()
toolbox.register("indices", random.sample, range(IN... | 17 | 443 |
pyomo | pyomo/common/download.py | .py | # ____________________________________________________________________________________
#
# Pyomo: Python Optimization Modeling Objects
# Copyright (c) 2008-2026 National Technology and Engineering Solutions of Sandia, LLC
# Under the terms of Contract DE-NA0003525 with National Technology and Engineering
# Solutions of... | 480 | 17,327 |
pyro | tests/distributions/test_projected_normal.py | .py | # Copyright Contributors to the Pyro project.
# SPDX-License-Identifier: Apache-2.0
import pytest
import torch
import pyro.distributions as dist
from tests.common import default_dtype
@pytest.mark.parametrize("strength", [0, 1, 10, 100, 1000])
@pytest.mark.parametrize("dim", [2, 3, 4])
@pytest.mark.parametrize("dty... | 25 | 826 |
biopython | Bio/Sequencing/Phd.py | .py | # Copyright 2004 by Cymon J. Cox and Frank Kauff. All rights reserved.
# Copyright 2008 by Michiel de Hoon. All rights reserved.
# Revisions copyright 2009 by Cymon J. Cox. All rights reserved.
# Revisions copyright 2009 by Peter Cock. All rights reserved.
#
# This file is part of the Biopython distribution and gov... | 205 | 5,684 |
gunicorn | tests/requests/valid/rfc9112_chunked_size_leading_zeros_01.py | .py | #
# This file is part of gunicorn released under the MIT license.
# See the NOTICE for more information.
# RFC 9112 section 7.1: chunk-size is 1*HEXDIG. Leading zeros are permitted
# but have been used in smuggling vectors; fixture pins accepted behavior.
request = {
"method": "POST",
"uri": uri("/upload"),
... | 17 | 464 |
beam | sdks/python/apache_beam/examples/cookbook/group_with_coder.py | .py | #
# Licensed to the Apache Software Foundation (ASF) under one or more
# contributor license agreements. See the NOTICE file distributed with
# this work for additional information regarding copyright ownership.
# The ASF licenses this file to You under the Apache License, Version 2.0
# (the "License"); you may not us... | 121 | 4,703 |
wandb | tests/unit_tests/test_launch/test_util.py | .py | import random
import pytest
from wandb.docker import DockerError
from wandb.sdk.launch.errors import LaunchError
from wandb.sdk.launch.runner.local_container import get_docker_command
from wandb.sdk.launch.utils import (
diff_pip_requirements,
load_wandb_config,
macro_sub,
make_k8s_label_safe,
pars... | 675 | 21,923 |
saleor | saleor/graphql/account/mutations/authentication/password_change.py | .py | from typing import cast
import graphene
from django.contrib.auth import password_validation
from django.contrib.auth.hashers import make_password
from django.core.exceptions import ValidationError
from .....account import events as account_events
from .....account import models
from .....account.error_codes import Ac... | 77 | 2,856 |
onnxruntime | onnxruntime/python/tools/transformers/models/bert/eval_squad.py | .py | # -------------------------------------------------------------------------
# Copyright (c) Microsoft Corporation. All rights reserved.
# Licensed under the MIT License.
# --------------------------------------------------------------------------
#
# This script evaluates accuracy of ONNX models for question-answering... | 330 | 12,026 |
openvino | tools/ovc/openvino/tools/ovc/moc_frontend/type_utils.py | .py | # Copyright (C) 2018-2026 Intel Corporation
# SPDX-License-Identifier: Apache-2.0
import sys
import numpy as np
import openvino as ov
from openvino import Type
def is_type(val):
if isinstance(val, (type, Type)):
return True
if 'tensorflow' in sys.modules:
import tensorflow as tf # pylint: d... | 83 | 2,753 |
django-cms | cms/plugin_base.py | .py | import fnmatch
import json
import re
from collections.abc import Callable
from functools import lru_cache
from django import forms
from django.contrib import admin, messages
from django.core.exceptions import ImproperlyConfigured, ObjectDoesNotExist, ValidationError
from django.http import HttpRequest, HttpResponse
fr... | 932 | 40,045 |
gunicorn | tests/requests/invalid/rfc9112_target_authority_non_connect_01.py | .py | #
# This file is part of gunicorn released under the MIT license.
# See the NOTICE for more information.
# RFC 9112 section 3.2.3: authority-form ("host:port") is only valid with
# the CONNECT method. Any other method carrying it must be rejected.
from gunicorn.http.errors import InvalidRequestLine
request = InvalidRe... | 9 | 330 |
black | src/black/__main__.py | .py | from black import patched_main
patched_main()
| 4 | 47 |
mlflow | examples/tracing/multithreading.py | .py | """
This example demonstrates how to create a trace to track the execution of a multi-threaded application.
To trace a multi-threaded operation, you need to use the low-level MLflow client APIs to create a trace and spans, because the high-level fluent APIs are not thread-safe.
"""
import contextvars
from concurrent.... | 65 | 1,818 |
wandb | wandb/sdk/artifacts/exceptions.py | .py | """Artifact exceptions."""
from __future__ import annotations
from typing import TYPE_CHECKING, TypeVar
from wandb import errors
from wandb._strutils import nameof
if TYPE_CHECKING:
from wandb.sdk.artifacts.artifact import Artifact
ArtifactT = TypeVar("ArtifactT", bound=Artifact)
class ArtifactStatusErro... | 73 | 2,323 |
kombu | examples/delayed_infra.py | .py | from __future__ import annotations
from kombu import Connection, Exchange, Queue
from kombu.transport.native_delayed_delivery import (
bind_queue_to_native_delayed_delivery_exchange, calculate_routing_key,
declare_native_delayed_delivery_exchanges_and_queues, level_name)
with Connection('amqp://guest:guest@lo... | 24 | 1,060 |
coremltools | coremltools/test/ml_program/experimental/test_async_wrapper.py | .py | # Copyright (c) 2025, Apple Inc. All rights reserved.
import gc
import os
import coremltools as ct
from coremltools.converters.mil import Builder as mb
import pytest
from coremltools.models.ml_program.experimental.async_wrapper import (
MLModelAsyncWrapper,
)
class TestMLModelAsyncWrapper:
@staticmethod
... | 44 | 1,392 |
onnx | onnx/reference/ops/op_regex_full_match.py | .py | # Copyright (c) ONNX Project Contributors
# SPDX-License-Identifier: Apache-2.0
from __future__ import annotations
import re
import numpy as np
from onnx.reference.op_run import OpRun
_acceptable_str_dtypes = ("U", "O")
class RegexFullMatch(OpRun):
def _run(self, x, pattern=None):
# Note: The ONNX sp... | 37 | 1,292 |
saleor | saleor/graphql/checkout/dataloaders/problems.py | .py | from collections import defaultdict
from collections.abc import Iterable
from promise import Promise
from ....checkout.models import CheckoutDelivery
from ....checkout.problems import (
CHANNEL_SLUG,
CHECKOUT_LINE_PROBLEM_TYPE,
CHECKOUT_PROBLEM_TYPE,
COUNTRY_CODE,
PRODUCT_ID,
VARIANT_ID,
g... | 212 | 7,730 |
openvino | src/frontends/onnx/tests/tests_python/test_ops_nonlinear.py | .py | # -*- coding: utf-8 -*-
# Copyright (C) 2018-2026 Intel Corporation
# SPDX-License-Identifier: Apache-2.0
import numpy as np
import onnx
import pytest
from tests.tests_python.utils import run_node
def import_and_compute(op_type, input_data, **node_attrs):
data_inputs = [np.array(input_data)]
node = onnx.hel... | 109 | 4,335 |
hydra | tests/test_config_repository.py | .py | # Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved
import copy
import re
import zipfile
from typing import Any, List
from pytest import mark, param, raises
from hydra._internal.config_repository import CachingConfigRepository, ConfigRepository
from hydra._internal.config_search_path_impl import Co... | 286 | 9,910 |
biopython | Tests/test_Align_format_matrix.py | .py | # Tests/test_format_matrix_unittest.py
"""Unit tests for Alignment.format() with substitution matrices.
These tests cover the behavior of pretty-printed alignments when a
substitution matrix (e.g., from Bio.Align.substitution_matrices) is
supplied directly or via a PairwiseAligner object.
Conventions being tested:
* ... | 154 | 5,173 |
coremltools | coremltools/converters/sklearn/_k_neighbors_classifier.py | .py | # Copyright (c) 2019, Apple Inc. All rights reserved.
#
# Use of this source code is governed by a BSD-3-clause license that can be
# found in the LICENSE.txt file or at https://opensource.org/licenses/BSD-3-Clause
import coremltools
from coremltools import proto
from ..._deps import _HAS_SCIPY, _HAS_SKLEARN
from ...... | 290 | 9,498 |
scikit-bio | skbio/util/tests/test_plotting.py | .py | # ----------------------------------------------------------------------------
# Copyright (c) 2013--, scikit-bio development team.
#
# Distributed under the terms of the Modified BSD License.
#
# The full license is in the file LICENSE.txt, distributed with this software.
# --------------------------------------------... | 81 | 2,284 |
mlflow | mlflow/genai/judges/tools/constants.py | .py | """
Constants for MLflow GenAI judge tools.
This module contains constant values used across the judge tools system,
providing a single reference point for tool names and other constants.
"""
# Tool names
class ToolNames:
"""Registry of judge tool names."""
GET_TRACE_INFO = "get_trace_info"
GET_ROOT_SPA... | 22 | 658 |
textual | src/textual/box_model.py | .py | from __future__ import annotations
from fractions import Fraction
from typing import NamedTuple
from textual.geometry import Spacing
class BoxModel(NamedTuple):
"""The result of `get_box_model`."""
# Content + padding + border
width: Fraction
height: Fraction
margin: Spacing # Additional margi... | 16 | 322 |
lemur | lemur/domains/schemas.py | .py | """
.. module: lemur.domains.schemas
:platform: unix
:copyright: (c) 2018 by Netflix Inc., see AUTHORS for more
:license: Apache, see LICENSE for more details.
.. moduleauthor:: Kevin Glisson <kglisson@netflix.com>
"""
from marshmallow import fields
from lemur.common.schema import LemurInputSchema, LemurOu... | 38 | 1,143 |
mlflow | mlflow/store/model_registry/dbmodels/models.py | .py | import sqlalchemy as sa
from cryptography.fernet import Fernet
from sqlalchemy import (
BigInteger,
Column,
ForeignKey,
ForeignKeyConstraint,
Index,
Integer,
PrimaryKeyConstraint,
String,
Text,
TypeDecorator,
)
from sqlalchemy.orm import backref, relationship
from mlflow.entitie... | 385 | 12,284 |
sqlmap | lib/request/basicauthhandler.py | .py | #!/usr/bin/env python
"""
Copyright (c) 2006-2026 sqlmap developers (https://sqlmap.org)
See the file 'LICENSE' for copying permission
"""
from thirdparty.six.moves import urllib as _urllib
class SmartHTTPBasicAuthHandler(_urllib.request.HTTPBasicAuthHandler):
"""
Reference: http://selenic.com/hg/rev/6c51a50... | 39 | 1,383 |
ipython | docs/autogen_shortcuts.py | .py | from __future__ import annotations
from dataclasses import dataclass
from inspect import getsource
from pathlib import Path
from typing import cast
from html import escape as html_escape
import re
from prompt_toolkit.keys import KEY_ALIASES
from prompt_toolkit.key_binding import KeyBindingsBase
from prompt_toolkit.fi... | 230 | 6,816 |
textual | src/textual/widgets/_toast.py | .py | """Widgets for showing notification messages in toasts."""
from __future__ import annotations
from typing import ClassVar
from textual import on
from textual.containers import Container
from textual.content import Content
from textual.css.query import NoMatches
from textual.events import Click, Mount
from textual.no... | 207 | 5,976 |
clearml | clearml/binding/frameworks/tensorflow_bind.py | .py | import base64
import json
import logging
import os
import sys
import threading
from collections import defaultdict
from functools import partial
from io import BytesIO
from mimetypes import guess_extension
from tempfile import mkstemp
from typing import Union, List, Dict, Optional, Iterable, Tuple, Callable, Any
impor... | 2,760 | 115,053 |
saleor | saleor/webhook/transport/asynchronous/tests/test_transport.py | .py | from unittest.mock import MagicMock, patch
import botocore.exceptions
import celery
import google.api_core.exceptions
import google.cloud.pubsub_v1.publisher
import pytest
from celery.exceptions import Retry as CeleryTaskRetryError
from opentelemetry.trace import StatusCode
from .....core.models import EventDelivery,... | 312 | 10,781 |
pyro | tests/ops/test_ssm_gp.py | .py | # Copyright (c) 2017-2019 Uber Technologies, Inc.
# SPDX-License-Identifier: Apache-2.0
import pytest
import torch
from pyro.ops.ssm_gp import MaternKernel
from tests.common import assert_equal
@pytest.mark.parametrize("num_gps", [1, 2, 3])
@pytest.mark.parametrize("nu", [0.5, 1.5, 2.5])
def test_matern_kernel(num_... | 36 | 1,153 |
textual | docs/examples/guide/styles/margin01.py | .py | from textual.app import App, ComposeResult
from textual.widgets import Static
TEXT = """I must not fear.
Fear is the mind-killer.
Fear is the little-death that brings total obliteration.
I will face my fear.
I will permit it to pass over me and through me.
And when it has gone past, I will turn the inner eye to see i... | 33 | 980 |
bazel | src/test/py/bazel/bzlmod/bazel_fetch_test.py | .py | # pylint: disable=g-backslash-continuation
# Copyright 2023 The Bazel Authors. All rights reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICEN... | 463 | 16,263 |
probability | tensorflow_probability/python/experimental/mcmc/preconditioned_hmc_test.py | .py | # Copyright 2020 The TensorFlow Probability Authors.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law o... | 899 | 36,006 |
mlflow | mlflow/mismatch.py | .py | from __future__ import annotations
import importlib.metadata
import warnings
def _get_version(package_name: str) -> str | None:
try:
return importlib.metadata.version(package_name)
except importlib.metadata.PackageNotFoundError:
return None
def _check_version_mismatch() -> None:
"""
... | 43 | 1,335 |
django-cms | cms/test_utils/project/urls_no18n.py | .py | from django.conf import settings
from django.contrib import admin
from django.contrib.staticfiles.urls import staticfiles_urlpatterns
from django.urls import include, re_path
from django.views.i18n import JavaScriptCatalog
from django.views.static import serve
from cms.test_utils.project.placeholderapp.views import ex... | 28 | 918 |
clearml | examples/frameworks/megengine/megengine_mnist.py | .py | import argparse
import os
import sys
from tempfile import gettempdir
import numpy as np
try:
import megengine as mge
import megengine.functional as F
import megengine.module as M
from megengine.autodiff import GradManager
from megengine.data import DataLoader, RandomSampler
from megengine.data... | 143 | 4,115 |
openvino | docs/articles_en/assets/snippets/ov_auto_batching.py | .py | # Copyright (C) 2018-2026 Intel Corporation
# SPDX-License-Identifier: Apache-2.0
#
import openvino as ov
from utils import get_model
def main():
core = ov.Core()
model = get_model()
if "GPU" not in core.available_devices:
return 0
# [compile_model]
import openvino.properties as props
... | 56 | 2,160 |
probability | tensorflow_probability/python/distributions/sigmoid_beta_test.py | .py | # Copyright 2020 The TensorFlow Probability Authors.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law o... | 284 | 11,089 |
probability | spinoffs/fun_mc/fun_mc/sga_hmc.py | .py | # Copyright 2021 The TensorFlow Probability Authors.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law o... | 785 | 28,495 |
astropy | astropy/coordinates/transformations/__init__.py | .py | """Coordinate transformations.
This module contains a general framework for defining graphs of transformations
between coordinates, suitable for either spatial coordinates or more generalized
coordinate systems.
The fundamental idea is that each class is a node in the transformation graph,
and transitions from one no... | 29 | 946 |
cvxpy | doc/sphinxext/docscrape.py | .py | """
Copyright 2013 Steven Diamond
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software... | 524 | 16,006 |
beam | sdks/python/apache_beam/internal/test_data/module_1.py | .py | #
# Licensed to the Apache Software Foundation (ASF) under one or more
# contributor license agreements. See the NOTICE file distributed with
# this work for additional information regarding copyright ownership.
# The ASF licenses this file to You under the Apache License, Version 2.0
# (the "License"); you may not us... | 28 | 1,035 |
metrics | src/torchmetrics/text/__init__.py | .py | # Copyright The Lightning team.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writin... | 52 | 1,819 |
beam | sdks/python/apache_beam/examples/snippets/transforms/elementwise/map_side_inputs_singleton.py | .py | # coding=utf-8
#
# Licensed to the Apache Software Foundation (ASF) under one or more
# contributor license agreements. See the NOTICE file distributed with
# this work for additional information regarding copyright ownership.
# The ASF licenses this file to You under the Apache License, Version 2.0
# (the "License");... | 65 | 1,941 |
beam | sdks/python/apache_beam/runners/dask/overrides.py | .py | #
# Licensed to the Apache Software Foundation (ASF) under one or more
# contributor license agreements. See the NOTICE file distributed with
# this work for additional information regarding copyright ownership.
# The ASF licenses this file to You under the Apache License, Version 2.0
# (the "License"); you may not us... | 156 | 5,698 |
wandb | wandb/sdk/lib/settings_file.py | .py | """Reading and writing W&B settings files.
There is usually a "global" settings file at ~/.config/wandb/settings.
A "local" settings file, also referred to as "workspace settings", is created
by the `wandb init` CLI command at ./wandb/settings. Any settings defined in
the local file override settings in the global fil... | 197 | 6,595 |
clearml | examples/hyperdatasets/legacy/data-ingestion/dataview_example_singleframe.py | .py | """
How to access and go over data
The general flow:
- Create new dataview.
- Query your dataview.
- Two ways to go over the frames:
- dataview.get_iterator()
- dataview.to_list()
"""
from allegroai import Task, DataView
task = Task.init(project_name="examples", task_name="dataview example")
# simple query
... | 39 | 1,255 |
beam | sdks/python/apache_beam/typehints/row_type_test.py | .py | #
# Licensed to the Apache Software Foundation (ASF) under one or more
# contributor license agreements. See the NOTICE file distributed with
# this work for additional information regarding copyright ownership.
# The ASF licenses this file to You under the Apache License, Version 2.0
# (the "License"); you may not us... | 199 | 6,787 |
wagtail | wagtail/images/apps.py | .py | from django.apps import AppConfig
from django.db.models import ForeignKey
from django.utils.translation import gettext_lazy as _
from . import checks, get_image_model, get_permission_policy # NOQA: F401
class WagtailImagesAppConfig(AppConfig):
name = "wagtail.images"
label = "wagtailimages"
verbose_name... | 63 | 1,955 |
saleor | saleor/graphql/giftcard/filters.py | .py | from uuid import UUID
import django_filters
import graphene
from django.db.models import Exists, OuterRef, Q
from graphql.error import GraphQLError
from ...account import models as account_models
from ...giftcard import models
from ...order import models as order_models
from ...product import models as product_models... | 227 | 7,065 |
conda | conda/gateways/disk/test.py | .py | # Copyright (C) 2012 Anaconda, Inc
# SPDX-License-Identifier: BSD-3-Clause
"""Disk utility functions testing path properties (e.g., writable, hardlinks, softlinks, etc.)."""
from functools import cache
from logging import getLogger
from os import W_OK, access
from os.path import basename, dirname, isdir, isfile, join
... | 90 | 3,174 |
mlflow | mlflow/webhooks/types.py | .py | """Type definitions for MLflow webhook payloads.
This module contains class definitions for all webhook event payloads
that are sent when various model registry events occur.
"""
from typing import Literal, TypeAlias, TypedDict
from mlflow.entities.webhook import WebhookAction, WebhookEntity, WebhookEvent
class Re... | 590 | 15,358 |
saleor | saleor/plugins/user_email/tests/test_plugin.py | .py | from dataclasses import asdict
from smtplib import SMTPNotSupportedError
from unittest.mock import MagicMock, Mock, patch
import pytest
from django.core.exceptions import ValidationError
from django.core.mail.backends.smtp import EmailBackend
from django.test import override_settings
from ....core.notify import Notif... | 427 | 13,108 |
pymc | pymc/distributions/__init__.py | .py | # Copyright 2024 - present The PyMC Developers
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable... | 209 | 4,282 |
mlflow | tests/test_environment_variables.py | .py | import os
import pytest
from mlflow.environment_variables import _BooleanEnvironmentVariable, _EnvironmentVariable
@pytest.mark.parametrize("value", [0, 1, "0", "1", "TRUE", "FALSE"])
def test_boolean_environment_variable_invalid_default_value(value):
with pytest.raises(ValueError, match=r"must be one of \[True... | 91 | 3,104 |
astropy | astropy/units/cgs.py | .py | # Licensed under a 3-clause BSD style license - see LICENSE.rst
"""
This package defines the CGS units. They are also available in
(and should be used through) the `astropy.units` namespace.
"""
# avoid ruff complaints about undefined names defined by def_unit
# ruff: noqa: F821
from fractions import Fraction
import... | 193 | 4,076 |
pyomo | pyomo/network/tests/test_arc.py | .py | # ____________________________________________________________________________________
#
# Pyomo: Python Optimization Modeling Objects
# Copyright (c) 2008-2026 National Technology and Engineering Solutions of Sandia, LLC
# Under the terms of Contract DE-NA0003525 with National Technology and Engineering
# Solutions of... | 1,992 | 87,349 |
metrics | src/torchmetrics/functional/classification/sensitivity_specificity.py | .py | # Copyright The Lightning team.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writin... | 448 | 22,197 |
wagtail | wagtail/snippets/tests/test_delete_view.py | .py | from io import StringIO
from django.contrib.admin.utils import quote
from django.contrib.auth.models import Permission
from django.core import management
from django.http import HttpRequest, HttpResponse
from django.test import TestCase
from django.test.utils import override_settings
from django.urls import reverse
f... | 226 | 8,220 |
astropy | astropy/coordinates/angles/core.py | .py | # Licensed under a 3-clause BSD style license - see LICENSE.rst
"""
This module contains the fundamental classes used for representing
coordinates in astropy.
"""
import functools
from typing import NamedTuple
import numpy as np
from astropy import units as u
from astropy.units import SpecificTypeQuantity
from . i... | 742 | 27,882 |
qutip | qutip/wigner.py | .py | __all__ = [
'wigner', 'qfunc', 'QFunc', 'spin_q_function', 'spin_wigner',
'wigner_transform',
]
import numpy as np
import warnings
from numpy import (
zeros, array, arange, exp, real, conj, pi, copy, sqrt, meshgrid, cos, sin,
)
import scipy.sparse as sp
import scipy.fftpack as ft
import scipy.linalg as la
... | 1,111 | 38,676 |
pymc | tests/sampling/test_parallel.py | .py | # Copyright 2024 - present The PyMC Developers
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable... | 288 | 9,533 |
more-itertools | tests/test_recipes.py | .py | from collections import Counter
from decimal import Decimal
from doctest import DocTestSuite
from fractions import Fraction
from functools import reduce
from itertools import (
combinations,
count,
groupby,
permutations,
islice,
)
from operator import mul, eq
from math import comb, prod, factorial
f... | 1,712 | 56,509 |
mlflow | mlflow/gemini/__init__.py | .py | """
The ``mlflow.gemini`` module provides an API for tracing the interaction with Gemini models.
"""
from mlflow.gemini.autolog import (
async_patched_class_call,
patched_class_call,
patched_module_call,
)
from mlflow.telemetry.events import AutologgingEvent
from mlflow.telemetry.track import _record_event... | 99 | 2,967 |
wagtail | wagtail/contrib/search_promotions/views/settings.py | .py | from django.core.paginator import InvalidPage, Paginator
from django.db import transaction
from django.db.models import Sum, functions
from django.http import Http404
from django.shortcuts import redirect
from django.template.response import TemplateResponse
from django.utils.functional import cached_property
from djan... | 276 | 10,110 |
loguru | tests/exceptions/source/others/zerodivisionerror_without_traceback.py | .py | import sys
from loguru import logger
def test(diagnose, backtrace):
logger.remove()
logger.add(sys.stderr, format="", diagnose=diagnose, backtrace=backtrace, colorize=True)
try:
1 / 0
except ZeroDivisionError:
type_, value, _ = sys.exc_info()
logger.opt(exception=(type_, valu... | 21 | 414 |
lemur | lemur/plugins/__init__.py | .py | from lemur.plugins.base import * # noqa
from lemur.plugins.bases import * # noqa
| 3 | 83 |
bazel | src/test/py/bazel/query_test.py | .py | # pylint: disable=g-bad-file-header
# Copyright 2018 The Bazel Authors. All rights reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
... | 75 | 2,727 |
dirty-equals | tests/test_list_tuple.py | .py | import pytest
from dirty_equals import AnyThing, Contains, HasLen, IsInt, IsList, IsListOrTuple, IsNegative, IsTuple
@pytest.mark.parametrize(
'other,dirty',
[
([], IsList),
((), IsTuple),
([], IsList()),
([1], IsList(length=1)),
((), IsTuple()),
([1, 2, 3], Is... | 125 | 4,387 |
jupytext | tests/functional/others/test_nbformat_version.py | .py | import pytest
from nbformat import writes as nbformat_writes
from nbformat.v3.nbbase import new_code_cell, new_notebook, new_text_cell, new_worksheet
from nbformat.v4.nbbase import new_markdown_cell
from nbformat.v4.nbbase import new_notebook as new_notebook_v4
from jupytext import reads, writes
from jupytext.jupytext... | 57 | 1,873 |
pyomo | pyomo/solvers/plugins/solvers/GUROBI_RUN.py | .py | # ____________________________________________________________________________________
#
# Pyomo: Python Optimization Modeling Objects
# Copyright (c) 2008-2026 National Technology and Engineering Solutions of Sandia, LLC
# Under the terms of Contract DE-NA0003525 with National Technology and Engineering
# Solutions of... | 355 | 13,327 |
saleor | saleor/graphql/translations/mutations/shop_settings_translate.py | .py | import graphene
from ....core.tracing import traced_atomic_transaction
from ....permission.enums import SitePermissions
from ....site.models import SiteSettings
from ...core import ResolveInfo
from ...core.doc_category import DOC_CATEGORY_SHOP
from ...core.enums import LanguageCodeEnum
from ...core.mutations import Ba... | 60 | 2,192 |
beam | learning/katas/python/Streaming/Triggers/Window Accumulation Modes/tests/test_task.py | .py | #
# Licensed to the Apache Software Foundation (ASF) under one
# or more contributor license agreements. See the NOTICE file
# distributed with this work for additional information
# regarding copyright ownership. The ASF licenses this file
# to you under the Apache License, Version 2.0 (the
# "License"); you may not... | 55 | 2,955 |
openvino | tests/layer_tests/pytorch_tests/test_fake_quantize.py | .py | # Copyright (C) 2018-2026 Intel Corporation
# SPDX-License-Identifier: Apache-2.0
import platform
import pytest
import torch
from pytorch_layer_test_class import PytorchLayerTest, skip_check
class TestFakeQuantizePerTensorAffine(PytorchLayerTest):
def _prepare_input(self):
return (self.random.randn(3, ... | 170 | 6,601 |
sqlmap | thirdparty/chardet/charsetgroupprober.py | .py | ######################## BEGIN LICENSE BLOCK ########################
# The Original Code is Mozilla Communicator client code.
#
# The Initial Developer of the Original Code is
# Netscape Communications Corporation.
# Portions created by the Initial Developer are Copyright (C) 1998
# the Initial Developer. All Rights R... | 108 | 3,839 |
pyro | pyro/distributions/nanmasked.py | .py | # Copyright Contributors to the Pyro project.
# SPDX-License-Identifier: Apache-2.0
import torch
from .torch import MultivariateNormal, Normal
class NanMaskedNormal(Normal):
"""
Wrapper around :class:`~pyro.distributions.Normal` to allow partially
observed data as specified by NAN elements in :meth:`log... | 100 | 3,381 |
biopython | Tests/test_PAML_yn00.py | .py | # Copyright (C) 2011, 2019 by Brandon Invergo (b.invergo@gmail.com)
# This code is part of the Biopython distribution and governed by its
# license. Please see the LICENSE file that should have been included
# as part of this package.
"""Tests for PAML yn00 module."""
import glob
import os
import os.path
import unitt... | 179 | 7,165 |
wandb | tests/system_tests/test_core/test_wandb_integration.py | .py | """Test the full stack by launching a real backend server.
You won't get credit for coverage of the backend logic in these tests. See
test_sender.py for testing specific backend logic, or wandb_test.py for testing frontend
logic.
Be sure to use `test_settings` or an isolated directory
"""
import importlib
import os... | 178 | 6,009 |
sphinx | tests/roots/test-directive-code/target.py | .py | # Literally included file using Python highlighting
foo = 'Including Unicode characters: üöä'
class Foo:
pass
class Bar:
def baz():
pass
# comment after Bar class definition
def bar(): pass
def block_start_with_comment():
# Comment
return 1
def block_start_with_blank():
return 1
... | 32 | 360 |
beam | learning/tour-of-beam/learning-content/core-transforms/motivating-challenge-1/python-challenge/task.py | .py | # Licensed to the Apache Software Foundation (ASF) under one
# or more contributor license agreements. See the NOTICE file
# distributed with this work for additional information
# regarding copyright ownership. The ASF licenses this file
# to you under the Apache License, Version 2.0 (the
# "License"); y... | 62 | 2,117 |
beam | sdks/python/apache_beam/runners/direct/sdf_direct_runner.py | .py | #
# Licensed to the Apache Software Foundation (ASF) under one or more
# contributor license agreements. See the NOTICE file distributed with
# this work for additional information regarding copyright ownership.
# The ASF licenses this file to You under the Apache License, Version 2.0
# (the "License"); you may not us... | 558 | 21,144 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.