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
luigi
luigi/process.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...
121
3,446
pyro
pyro/contrib/gp/models/__init__.py
.py
# Copyright (c) 2017-2019 Uber Technologies, Inc. # SPDX-License-Identifier: Apache-2.0 from pyro.contrib.gp.models.gplvm import GPLVM from pyro.contrib.gp.models.gpr import GPRegression from pyro.contrib.gp.models.model import GPModel from pyro.contrib.gp.models.sgpr import SparseGPRegression from pyro.contrib.gp.mod...
19
546
wandb
tests/unit_tests/test_sagemaker_config_parse.py
.py
import io import json import os from unittest import mock from wandb.integration.sagemaker.config import parse_sm_config @mock.patch("os.path.exists") @mock.patch("os.getenv") @mock.patch("json.load") @mock.patch( "builtins.open", new_callable=mock.mock_open, read_data=json.dumps({"param1": "2022-04-01"}...
122
3,960
httpie
httpie/output/lexers/common.py
.py
def precise(lexer, precise_token, parent_token): # Due to a pygments bug*, custom tokens will look bad # on outside styles. Until it is fixed on upstream, we'll # convey whether the client is using pie style or not # through precise option and return more precise tokens # depending on it's value. ...
13
517
conda
tests/plugins/subcommands/doctor/health_checks/test_missing_files.py
.py
# Copyright (C) 2012 Anaconda, Inc # SPDX-License-Identifier: BSD-3-Clause """Tests for the missing files health check. Note: env_ok, env_missing_files fixtures are defined in tests/plugins/subcommands/conftest.py and shared with health fix tests. """ from __future__ import annotations from typing import TYPE_CHECKI...
54
1,843
black
tests/data/cases/comments_in_lambda_default.py
.py
help(lambda x=( # comment "bar", ): False) result = (lambda x=( # a standalone comment 1, 2, 3, ): x) # output help( lambda x=( # comment "bar", ): False, ) result = lambda x=( # a standalone comment 1, 2, 3, ): x
28
274
pyfilesystem2
fs/opener/registry.py
.py
# coding: utf-8 """`Registry` class mapping protocols and FS URLs to their `Opener`. """ from __future__ import absolute_import, print_function, unicode_literals import typing import collections import contextlib import pkg_resources from ..errors import ResourceReadOnly from .base import Opener from .errors import...
295
9,862
sphinx
sphinx/environment/collectors/metadata.py
.py
"""The metadata collector components for sphinx.environment.""" from __future__ import annotations from typing import TYPE_CHECKING, cast from docutils import nodes from sphinx.environment.collectors import EnvironmentCollector if TYPE_CHECKING: from collections.abc import Set from sphinx.application impo...
79
2,820
probability
tensorflow_probability/python/experimental/fastgp/schur_complement.py
.py
# Copyright 2024 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...
245
9,220
beam
sdks/python/apache_beam/coders/slow_coders_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...
49
1,751
attrs
tests/test_annotations.py
.py
# SPDX-License-Identifier: MIT """ Tests for PEP-526 type annotations. """ import sys import types import typing import pytest import attr import attrs from attr._make import _is_class_var from attr.exceptions import UnannotatedAttributeError def assert_init_annotations(cls, **annotations): """ Assert cl...
719
18,752
saleor
saleor/shipping/tests/fixtures/__init__.py
.py
from .shipping_method import * # noqa: F401, F403 from .shipping_method_data import * # noqa: F401, F403 from .shipping_method_translation import * # noqa: F401, F403 from .shipping_zone import * # noqa: F401, F403
5
219
httpie
tests/test_encoding.py
.py
""" Various encoding handling related tests. """ import pytest import responses from charset_normalizer.constant import TOO_SMALL_SEQUENCE from httpie.cli.constants import PRETTY_MAP from httpie.encoding import UTF8 from .utils import http, HTTP_OK, DUMMY_URL, MockEnvironment from .fixtures import UNICODE CHARSET_...
223
6,697
onnx
onnx/backend/test/case/node/regex_full_match.py
.py
# Copyright (c) ONNX Project Contributors # # SPDX-License-Identifier: Apache-2.0 from __future__ import annotations import numpy as np import onnx from onnx.backend.test.case.base import Base from onnx.backend.test.case.node import expect class RegexFullMatch(Base): @staticmethod def export_basic() -> None...
69
1,914
probability
spinoffs/autobnn/autobnn/__init__.py
.py
# Copyright 2024 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...
38
1,177
bazel
third_party/py/mock/setup.py
.py
#! /usr/bin/env python # Copyright (C) 2007-2012 Michael Foord & the mock team # E-mail: fuzzyman AT voidspace DOT org DOT uk # http://www.voidspace.org.uk/python/mock/ from mock import __version__ import os NAME = 'mock' MODULES = ['mock'] DESCRIPTION = 'A Python Mocking and Patching Library for Testing' URL = "...
73
2,134
probability
tensorflow_probability/python/distributions/numerical_properties_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...
294
11,912
mlflow
tests/entities/test_span_event.py
.py
import time import pytest from mlflow.entities import SpanEvent from mlflow.exceptions import MlflowException def test_default_timestamp_is_in_nanoseconds(): # Record the time before and after creating the event before_ns = int(time.time() * 1e9) event = SpanEvent(name="test_event") after_ns = int(t...
60
1,734
openvino
tests/layer_tests/tensorflow_tests/test_tf_Placeholder.py
.py
# Copyright (C) 2018-2026 Intel Corporation # SPDX-License-Identifier: Apache-2.0 import numpy as np import pytest import tensorflow as tf from common.tf_layer_test_class import CommonTFLayerTest rng = np.random.default_rng() class TestPlaceholder(CommonTFLayerTest): def _prepare_input(self, inputs_info): ...
55
2,560
sqlmap
lib/techniques/sparql/inject.py
.py
#!/usr/bin/env python """ Copyright (c) 2006-2026 sqlmap developers (https://sqlmap.org) See the file 'LICENSE' for copying permission """ """ SPARQL injection ('--sparql'). An application that concatenates user input into a SPARQL query hands over the whole graph pattern language, not just a value. The typical surf...
550
24,212
beam
sdks/python/apache_beam/io/gcp/internal/clients/bigquery/bigquery_v2_client.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...
1,420
66,797
onnx
onnx/reference/ops/_op_common_random.py
.py
# Copyright (c) ONNX Project Contributors # SPDX-License-Identifier: Apache-2.0 from __future__ import annotations import numpy as np from onnx.helper import tensor_dtype_to_np_dtype from onnx.reference.op_run import OpRun class _CommonRandom(OpRun): def __init__(self, onnx_node, run_params): OpRun.__i...
56
1,771
pyro
tests/infer/test_discrete.py
.py
# Copyright (c) 2017-2019 Uber Technologies, Inc. # SPDX-License-Identifier: Apache-2.0 import logging import math import warnings import pytest import torch from torch.autograd import grad import pyro import pyro.distributions as dist from pyro import poutine from pyro.infer import TraceEnum_ELBO from pyro.infer.di...
424
14,353
jupytext
tests/data/notebooks/outputs/ipynb_to_script_vscode_folding_markers/frozen_cell.py
.py
# --- # jupyter: # jupytext: # cell_markers: region,endregion # kernelspec: # display_name: Python 3 # language: python # name: python3 # --- # This is an unfrozen cell. Works as usual. print("I'm a regular cell so I run and print!") # region deletable=false editable=false run_control={"frozen": t...
18
408
mlflow
mlflow/llama_index/model.py
.py
import logging import os import tempfile from typing import Any import yaml import mlflow from mlflow import pyfunc from mlflow.entities.model_registry.prompt import Prompt from mlflow.exceptions import MlflowException from mlflow.llama_index.constant import FLAVOR_NAME from mlflow.llama_index.pyfunc_wrapper import c...
574
23,901
pyomo
doc/OnlineDocs/src/dataportal/param_initialization.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...
35
984
python-prompt-toolkit
examples/prompts/multiline-autosuggest.py
.py
#!/usr/bin/env python """ A more complex example of a CLI that demonstrates fish-style auto suggestion across multiple lines. This can typically be used for LLM that may return multi-line responses. Note that unlike simple autosuggest, using multiline autosuggest requires more care as it may shift the buffer layout, ...
155
5,955
wandb
wandb/sdk/internal/incremental_table_util.py
.py
from __future__ import annotations import time from typing import TYPE_CHECKING if TYPE_CHECKING: from wandb import Table from wandb.sdk.artifacts.artifact import Artifact from ..wandb_run import Run as LocalRun ART_TYPE = "wandb-run-incremental-table" def _get_artifact_name(run: LocalRun, key: str) -...
54
1,490
wandb
tests/system_tests/conftest.py
.py
from __future__ import annotations import contextlib from collections.abc import Callable, Generator from dataclasses import dataclass import pytest import wandb from tests.fixtures.wandb_backend_spy import ( WandbBackendProxy, WandbBackendSpy, spy_proxy, ) from .backend_fixtures import ( BackendFix...
252
7,503
colorama
colorama/tests/isatty_test.py
.py
# Copyright Jonathan Hartley 2013. BSD 3-Clause license, see LICENSE file. import sys from unittest import TestCase, main from ..ansitowin32 import StreamWrapper, AnsiToWin32 from .utils import pycharm, replace_by, replace_original_by, StreamTTY, StreamNonTTY def is_a_tty(stream): return StreamWrapper(stream, No...
58
1,866
openvino
tests/llm/conftest.py
.py
import os def pytest_addoption(parser): parser.addoption("--do_not_cleanup", action="store_true", default=False, help="Do not cleanup temporary files after test completion") parser.addoption("--gpu_suffix", action="store", default="0", help="Suffix to append to GPU device name (e.g., '1' for GPU.1)") parse...
20
874
saleor
saleor/graphql/account/tests/queries/test_account_events.py
.py
import graphene from django.db import models from .....account import events as account_events from .....account.models import User from ....tests.utils import get_graphql_content QUERY_CUSTOMER_EVENTS = """ query customerEvents($customerId: ID!) { user(id: $customerId) { id events { id type ...
341
10,163
scikit-bio
skbio/stats/__init__.py
.py
r"""Multivariate Statistics (:mod:`skbio.stats`) ============================================ .. currentmodule:: skbio.stats This module provides various statistical methods to support the analyses of high-dimensional biological data to uncover the relationships among samples, features and metadata. Examples include ...
72
1,465
openvino
tests/layer_tests/tensorflow_tests/test_tf_BlockLSTM.py
.py
# Copyright (C) 2018-2026 Intel Corporation # SPDX-License-Identifier: Apache-2.0 import numpy as np import pytest import tensorflow as tf from common.tf_layer_test_class import CommonTFLayerTest rng = np.random.default_rng(2024) class TestBlockLSTM(CommonTFLayerTest): def _prepare_input(self, inputs_info): ...
65
3,356
astropy
astropy/io/ascii/tests/test_connect.py
.py
# Licensed under a 3-clause BSD style license - see LICENSE.rst import numpy as np import pytest from astropy.table import Column, Table from astropy.table.table_helpers import simple_table from astropy.utils.compat.optional_deps import HAS_BS4 from astropy.utils.data import get_pkg_data_filename files = [ "data/...
147
3,802
django-cms
cms/templatetags/cms_tags.py
.py
# Standard library imports from collections import OrderedDict, namedtuple from copy import copy from datetime import datetime # Third-party imports from classytags.arguments import ( Argument, MultiKeywordArgument, MultiValueArgument, ) from classytags.core import Options, Tag from classytags.helpers impo...
988
36,471
django-cms
cms/test_utils/project/app_with_cms_feature/apps.py
.py
from django.apps import AppConfig class CMSFeatureConfig(AppConfig): name = 'cms.test_utils.project.app_with_cms_feature' label = 'app_with_cms_feature'
7
163
jupytext
tests/functional/simple_notebooks/test_read_simple_rmd.py
.py
import re from time import sleep import nbformat import pytest from nbformat.v4.nbbase import ( new_code_cell, new_markdown_cell, new_notebook, new_raw_cell, ) import jupytext from jupytext.cli import jupytext as jupytext_cli from jupytext.compare import compare, compare_cells, compare_notebooks def...
306
7,005
mlflow
mlflow/semantic_kernel/autolog.py
.py
import logging import threading from opentelemetry import trace as otel_trace from opentelemetry.context import Context from opentelemetry.sdk.trace import ReadableSpan as OTelReadableSpan from opentelemetry.sdk.trace import Span as OTelSpan from opentelemetry.sdk.trace import TracerProvider as SDKTracerProvider from ...
153
7,022
saleor
saleor/graphql/account/mutations/account/base.py
.py
import graphene from ....core.enums import LanguageCodeEnum from ....core.types import BaseInputObjectType class AccountBaseInput(BaseInputObjectType): first_name = graphene.String(description="Given name.") last_name = graphene.String(description="Family name.") language_code = graphene.Argument( ...
13
396
kombu
kombu/transport/memory.py
.py
"""In-memory transport module for Kombu. Simple transport using memory for storing messages. Messages can be passed only between threads. Features ======== * Type: Virtual * Supports Direct: Yes * Supports Topic: Yes * Supports Fanout: No * Supports Priority: No * Supports TTL: Yes Connection String ================...
107
2,404
mlflow
tests/server/auth/test_fail_closed_flag.py
.py
# Tests for the MLFLOW_BASIC_AUTH_FAIL_CLOSED flag: wiring, the decision predicates, # and the end-to-end 403 that _before_request returns when the flag is on. from mlflow.environment_variables import MLFLOW_BASIC_AUTH_FAIL_CLOSED from mlflow.server import auth as a class _Req: def __init__(self, path, method="G...
87
3,290
pyomo
pyomo/contrib/pynumero/interfaces/tests/test_dynamic_model.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...
738
23,100
django-cms
menus/apps.py
.py
from django.apps import AppConfig from django.utils.translation import gettext_lazy as _ class MenusConfig(AppConfig): name = 'menus' verbose_name = _("django CMS menus system") default_auto_field = 'django.db.models.AutoField'
9
242
pyomo
examples/kernel/mosek/geometric1.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...
86
2,961
returns
docs/conf.py
.py
# Configuration file for the Sphinx documentation builder. # # This file does only contain a selection of the most common options. For a # full list see the documentation: # http://www.sphinx-doc.org/en/master/config # -- Path setup -------------------------------------------------------------- # If extensions (or mo...
129
3,941
returns
returns/contrib/hypothesis/_entrypoint.py
.py
""" Used to register all our types as hypothesis strategies. See: https://hypothesis.readthedocs.io/en/latest/strategies.html But, beware that we only register concrete types here, interfaces won't be registered! """ from __future__ import annotations from collections.abc import Callable, Sequence from typing impo...
65
1,831
wagtail
wagtail/tests/test_workflow.py
.py
import datetime from unittest import mock, skip from django.conf import settings from django.contrib.auth import get_user_model from django.contrib.auth.models import Group from django.contrib.contenttypes.models import ContentType from django.core.exceptions import ValidationError from django.db.utils import Integrit...
579
25,391
cvxpy
cvxpy/atoms/affine/trace.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...
137
4,609
metrics
src/torchmetrics/functional/regression/explained_variance.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...
143
5,492
mlflow
mlflow/store/analytics/__init__.py
.py
""" Analytics modules for MLflow store operations. This package contains analytical algorithms and computations that operate on MLflow tracking store data, such as trace correlation analysis. """ from mlflow.store.analytics.trace_correlation import ( JEFFREYS_PRIOR, NPMIResult, TraceCorrelationCounts, ...
23
530
metrics
tests/unittests/classification/_inputs.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...
333
11,927
mlflow
mlflow/genai/judges/utils/invocation_utils.py
.py
"""Main invocation utilities for judge models.""" from __future__ import annotations import json import logging from typing import TYPE_CHECKING, Any import pydantic if TYPE_CHECKING: from mlflow.entities.trace import Trace from mlflow.types.llm import ChatMessage from mlflow.entities.assessment import Fee...
273
10,994
cvxpy
cvxpy/reductions/dcp2cone/canonicalizers/lambda_sum_largest_canon.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...
49
1,571
beam
sdks/python/apache_beam/runners/direct/direct_runner_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...
253
9,561
pyomo
pyomo/solvers/tests/checks/test_writers.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...
212
6,846
python-prompt-toolkit
src/prompt_toolkit/contrib/completers/system.py
.py
from __future__ import annotations from prompt_toolkit.completion.filesystem import ExecutableCompleter, PathCompleter from prompt_toolkit.contrib.regular_languages.compiler import compile from prompt_toolkit.contrib.regular_languages.completion import GrammarCompleter __all__ = [ "SystemCompleter", ] class Sys...
65
2,057
lemur
lemur/tests/test_ldap.py
.py
import pytest from lemur.auth.ldap import * # noqa from unittest.mock import patch, MagicMock class LdapPrincipalTester(LdapPrincipal): def __init__(self, args): super().__init__(args) self.ldap_server = "ldap://localhost" def bind_test(self): groups = [ ( ...
83
2,766
luigi
luigi/contrib/postgres.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...
460
15,874
saleor
saleor/graphql/attribute/dataloaders/attributes.py
.py
from collections import defaultdict from ....attribute.models import Attribute, AttributeValue from ...core.dataloaders import DataLoader class AttributeValuesByAttributeIdLoader(DataLoader[int, list[AttributeValue]]): context_key = "attributevalues_by_attribute" def batch_load(self, keys): attribut...
50
1,752
pyro
tests/contrib/tracking/test_distributions.py
.py
# Copyright (c) 2017-2019 Uber Technologies, Inc. # SPDX-License-Identifier: Apache-2.0 import pytest import torch from pyro.contrib.tracking.distributions import EKFDistribution from pyro.contrib.tracking.dynamic_models import NcpContinuous, NcvContinuous @pytest.mark.parametrize("Model", [NcpContinuous, NcvContin...
26
890
astropy
astropy/table/tests/test_df.py
.py
# Licensed under a 3-clause BSD style license - see LICENSE.rst import io import json import numpy as np import pytest from numpy.testing import assert_allclose, assert_array_equal from astropy import table from astropy import units as u from astropy.table import MaskedColumn, Table from astropy.time import Time, Tim...
751
28,294
mlflow
dev/clint/src/clint/rules/unknown_mlflow_arguments.py
.py
from clint.rules.base import Rule class UnknownMlflowArguments(Rule): def __init__(self, function_name: str, unknown_args: set[str]) -> None: self.function_name = function_name self.unknown_args = unknown_args def _message(self) -> str: args_str = ", ".join(f"`{arg}`" for arg in sorte...
15
518
pyomo
examples/pyomo/diet/diet-sqlite.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...
152
4,710
saleor
saleor/graphql/core/tests/test_scalars_decimals.py
.py
import decimal import pytest from graphql.language.ast import FloatValue, IntValue, ObjectValue, StringValue from ..scalars import Decimal, PositiveDecimal, PositiveInt # Decimals @pytest.mark.parametrize("invalid_value", ["NaN", "-Infinity", "1e-9999999", "-", "x"]) def test_decimal_scalar_invalid_value(invalid_v...
144
3,308
onnxruntime
onnxruntime/test/testdata/webgpu_pow_cast_test.py
.py
import onnx from onnx import TensorProto, helper # tests fix for precision error in florence2 model by using WebGPU built-in sqrt(x) function instead of pow(x, y) when the exponent is 0.5. # The sqrt(x) built-in is both faster and more stable than using pow(x, 0.5). # Example: # Cast: input = 576 (int), output = 576 (...
41
1,183
saleor
saleor/graphql/meta/tests/queries/test_gift_card.py
.py
import graphene from ....tests.utils import assert_no_permission, get_graphql_content from .utils import PRIVATE_KEY, PRIVATE_VALUE, PUBLIC_KEY, PUBLIC_VALUE QUERY_GIFT_CARD_PRIVATE_META = """ query giftCardMeta($id: ID!){ giftCard(id: $id){ privateMetadata{ key ...
174
4,989
httpie
httpie/output/streams.py
.py
from abc import ABCMeta, abstractmethod from itertools import chain from typing import Callable, Iterable, Optional, Union from .processing import Conversion, Formatting from ..context import Environment from ..encoding import smart_decode, smart_encode, UTF8 from ..models import HTTPMessage, OutputOptions from ..util...
255
8,155
bazel
third_party/py/concurrent/futures/thread.py
.py
# Copyright 2009 Brian Quinlan. All Rights Reserved. # Licensed to PSF under a Contributor Agreement. """Implements ThreadPoolExecutor.""" from __future__ import with_statement import atexit import threading import weakref import sys from third_party.py.concurrent.futures import _base try: import queue except I...
145
4,810
jupytext
tests/data/notebooks/outputs/ipynb_to_sphinx/cat_variable.py
.py
# --- # jupyter: # kernelspec: # display_name: Python 3 # language: python # name: python3 # --- cat = 42
10
121
probability
tensorflow_probability/python/internal/lazy_loader.py
.py
# Copyright 2020 The TensorFlow Probability 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 # # Unless require...
65
2,168
wagtail
wagtail/test/testapp/media_forms.py
.py
from django import forms from wagtail.admin.widgets import AdminDateTimeInput from wagtail.documents.forms import BaseDocumentForm from wagtail.images.forms import BaseImageForm class OverriddenWidget(forms.Widget): pass class AlternateImageForm(BaseImageForm): form_only_field = forms.DateTimeField() ...
33
798
pyomo
pyomo/dae/tests/test_integral.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...
257
8,654
beam
sdks/python/apache_beam/ml/anomaly/detectors/robust_zscore_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...
52
1,544
marshmallow
tests/test_serialization.py
.py
"""Tests for field serialization.""" import datetime as dt import decimal import ipaddress import itertools import math import uuid from collections import OrderedDict from typing import NamedTuple import pytest from marshmallow import Schema, fields from marshmallow import missing as missing_ from tests.base import...
1,003
37,608
mlflow
mlflow/langchain/utils/logging.py
.py
"""Utility functions for mlflow.langchain.""" import functools import importlib import json import logging import os import shutil import types from functools import lru_cache from importlib.util import find_spec from typing import Any, Callable, NamedTuple import cloudpickle import yaml from packaging.version import...
635
21,745
onnx
onnx/reference/ops/op_softplus.py
.py
# Copyright (c) ONNX Project Contributors # SPDX-License-Identifier: Apache-2.0 from __future__ import annotations import numpy as np from onnx.reference.ops._op import OpRunUnaryNum class Softplus(OpRunUnaryNum): def _run(self, X): tmp = np.asarray(np.exp(X), dtype=X.dtype) tmp += 1 np...
17
361
onnxruntime
onnxruntime/test/python/transformers/gqa_test_helper.py
.py
# ------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. # -------------------------------------------------------------------------- import math import numpy import torch from onnx import TensorProto, he...
632
24,608
pynacl
tests/test_secret.py
.py
# Copyright 2013-2018 Donald Stufft and individual contributors # # 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 applicabl...
313
9,554
pyro
tests/distributions/test_one_hot_categorical.py
.py
# Copyright (c) 2017-2019 Uber Technologies, Inc. # SPDX-License-Identifier: Apache-2.0 from unittest import TestCase import numpy as np import pytest import torch import pyro.distributions as dist from tests.common import assert_equal class TestOneHotCategorical(TestCase): """ Tests methods specific to th...
116
3,921
hydra
build_helpers/test_helpers.py
.py
# Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved import os.path from pathlib import Path from typing import List from pytest import mark, param from build_helpers.build_helpers import find, matches @mark.parametrize( "path,include_files,include_dirs,excludes,scan_exclude,expected", [ ...
132
3,382
pyomo
pyomo/contrib/appsi/solvers/tests/test_wntr_persistent.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...
191
7,372
onnx
onnx/backend/test/case/node/gathernd.py
.py
# Copyright (c) ONNX Project Contributors # # SPDX-License-Identifier: Apache-2.0 from __future__ import annotations import numpy as np import onnx from onnx.backend.test.case.base import Base from onnx.backend.test.case.node import expect def gather_nd_impl( data: np.ndarray, indices: np.ndarray, batch_dims: i...
122
4,041
beam
sdks/python/apache_beam/examples/snippets/transforms/aggregation/count_per_key.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");...
64
1,910
astropy
setup.py
.py
#!/usr/bin/env python # Licensed under a 3-clause BSD style license - see LICENSE.rst # NOTE: The configuration for the package, including the name, version, and # other information are set in the pyproject.toml file. import sys from pathlib import Path from setuptools import setup from setuptools.command.editable_w...
59
1,597
cvxpy
cvxpy/tests/nlp_tests/test_huber_sum_largest.py
.py
""" Copyright, the CVXPY 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 or agreed to in writing, software ...
138
4,649
sphinx
sphinx/ext/ifconfig.py
.py
"""Provides the ``ifconfig`` directive. The ``ifconfig`` directive enables writing documentation that is included depending on configuration variables. Usage:: .. ifconfig:: releaselevel in ('alpha', 'beta', 'rc') This stuff is only included in the built docs for unstable versions. The argument for ``if...
86
2,512
mlflow
mlflow/pyfunc/utils/environment.py
.py
import os from contextlib import contextmanager from mlflow.environment_variables import _MLFLOW_IS_IN_SERVING_ENVIRONMENT @contextmanager def _simulate_serving_environment(): """ Some functions (e.g. validate_serving_input) replicate the data transformation logic that happens in the model serving enviro...
23
824
ipython
IPython/utils/sysinfo.py
.py
""" Utilities for getting information about IPython and the system it's running in. """ from __future__ import annotations #----------------------------------------------------------------------------- # Copyright (C) 2008-2011 The IPython Development Team # # Distributed under the terms of the BSD License. The fu...
121
3,737
metrics
src/torchmetrics/functional/image/ergas.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...
122
4,167
mlflow
mlflow/tracking/_workspace/registry.py
.py
from __future__ import annotations import threading import warnings from functools import lru_cache, partial from mlflow.exceptions import MlflowException from mlflow.protos.databricks_pb2 import INVALID_PARAMETER_VALUE from mlflow.store.db.db_types import DATABASE_ENGINES from mlflow.tracking.registry import StoreRe...
113
4,270
openvino
src/plugins/intel_gpu/src/kernel_selector/primitive_db_gen.py
.py
# Copyright (C) 2018-2026 Intel Corporation # SPDX-License-Identifier: Apache-2.0 # To add new kernel please add a .cl file to kernels directory # the database name will be the part of the file name up to first '.' character # the trailing characters are a tag to allow multiple primitive implementations from __future...
301
12,711
onnxruntime
tools/ci_build/compile_triton.py
.py
# ------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. # -------------------------------------------------------------------------- import argparse import importlib.util import os import shutil import sub...
180
5,882
onnx
onnx/backend/test/case/node/acosh.py
.py
# Copyright (c) ONNX Project Contributors # # SPDX-License-Identifier: Apache-2.0 from __future__ import annotations import numpy as np import onnx from onnx.backend.test.case.base import Base from onnx.backend.test.case.node import expect class Acosh(Base): @staticmethod def export() -> None: node ...
29
797
scikit-optimize
skopt/sampler/lhs.py
.py
""" Lhs functions are inspired by https://github.com/clicumu/pyDOE2/blob/ master/pyDOE2/doe_lhs.py """ import numpy as np from sklearn.utils import check_random_state from scipy import spatial from ..space import Space, Categorical from .base import InitialPointGenerator def _random_permute_matrix(h, random_state=Non...
146
5,689
cvxpy
cvxpy/tests/nlp_tests/test_log_sum_exp.py
.py
""" Copyright, the CVXPY 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 or agreed to in writing, software ...
78
2,588
returns
returns/primitives/container.py
.py
from abc import ABC from typing import Any, TypeVar from typing_extensions import TypedDict from returns.interfaces.equable import Equable from returns.primitives.hkt import Kind1 from returns.primitives.types import Immutable _EqualType = TypeVar('_EqualType', bound=Equable) class _PickleState(TypedDict): """...
86
2,721
python-dotenv
src/dotenv/variables.py
.py
import re from abc import ABCMeta, abstractmethod from typing import Iterator, Mapping, Optional, Pattern _posix_variable: Pattern[str] = re.compile( r""" \$\{ (?P<name>[^\}:]*) (?::- (?P<default>[^\}]*) )? \} """, re.VERBOSE, ) class Atom(metaclass=ABCMeta): ...
87
2,348
scikit-bio
skbio/io/format/lsmat.py
.py
r"""Labeled square matrix format (:mod:`skbio.io.format.lsmat`) =========================================================== .. currentmodule:: skbio.io.format.lsmat The labeled square matrix file format (``lsmat``) stores numeric square matrix data relating a set of objects along each axis. The format also stores ide...
281
10,157
wagtail
wagtail/snippets/api/v3/__init__.py
.py
from .registry import register_content_types __all__ = [ "register_content_types", ]
6
90