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 |
|---|---|---|---|---|---|
readthedocs.org | readthedocs/allauth/providers/githubapp/urls.py | .py | """Copied from allauth.socialaccount.providers.github.urls."""
from allauth.socialaccount.providers.oauth2.urls import default_urlpatterns
from readthedocs.allauth.providers.githubapp.provider import GitHubAppProvider
urlpatterns = default_urlpatterns(GitHubAppProvider)
| 9 | 275 |
probability | spinoffs/fun_mc/fun_mc/smc.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... | 775 | 25,089 |
saleor | saleor/tests/e2e/orders/discounts/test_order_voucher_usage_is_released_when_voucher_is_removed.py | .py | import pytest
from ... import DEFAULT_ADDRESS
from ...product.utils.preparing_product import prepare_product
from ...shop.utils.preparing_shop import prepare_shop
from ...utils import assign_permissions
from ...vouchers.utils import (
create_voucher,
create_voucher_channel_listing,
get_voucher,
)
from ..ut... | 146 | 4,468 |
metrics | src/torchmetrics/functional/regression/js_divergence.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... | 103 | 4,237 |
flit | tests/samples/ns1-pkg-mod/ns1/module.py | .py | """An example single file module in a namespace package
"""
__version__ = '0.1'
| 5 | 81 |
hydra | tests/test_apps/app_with_cfg_decorated/my_app.py | .py | # Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved
from omegaconf import DictConfig
import hydra
from tests.test_apps.app_with_cfg_decorated.decorators.inner_decorator import (
inner_decorator,
)
from tests.test_apps.app_with_cfg_decorated.decorators.outer_decorator import (
data,
oute... | 26 | 578 |
mlflow | dev/flavors/tests/test_update.py | .py | from datetime import datetime, timedelta, timezone
from pathlib import Path
from unittest import mock
import pytest
from flavors import _update
from flavors._update import VersionInfo
from pypi import Package
def _iso8601(dt: datetime) -> str:
return (dt if dt.tzinfo else dt.replace(tzinfo=timezone.utc)).isoform... | 238 | 5,712 |
pyomo | pyomo/devel/initialization/examples/init_polynomial_ex.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... | 61 | 1,938 |
astropy | astropy/coordinates/transformations/function.py | .py | # Licensed under a 3-clause BSD style license - see LICENSE.rst
"""Function-based coordinate transformations.
These are transformations that cannot be represented as an affine transformation.
"""
from warnings import warn
from astropy import units as u
from astropy.coordinates.representation import (
CartesianD... | 245 | 10,292 |
probability | tensorflow_probability/python/math/integration_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... | 201 | 8,329 |
gunicorn | tests/requests/valid/pp_03.py | .py | #
# This file is part of gunicorn released under the MIT license.
# See the NOTICE for more information.
from gunicorn.config import Config
cfg = Config()
cfg.set("proxy_protocol", True)
request = {
"method": "GET",
"uri": uri("/no/proxy/header"),
"version": (1, 1),
"headers": [
("HOST", "exa... | 20 | 389 |
sqlmap | tests/test_sgmllib.py | .py | #!/usr/bin/env python
"""
Copyright (c) 2006-2026 sqlmap developers (https://sqlmap.org)
See the file 'LICENSE' for copying permission
Tests for lib/utils/sgmllib.py -- the SGML/HTML parser used internally by
sqlmap for page content analysis. Exercises the parser with valid SGML/HTML
constructs and verifies the event... | 279 | 9,197 |
saleor | saleor/graphql/shipping/tests/benchmark/test_shipping_methods.py | .py | import graphene
import pytest
from ....tests.utils import get_graphql_content
SHIPPING_METHODS_QUERY = """
query GetShippingMethods($channel: String) {
shippingZones(first: 10, channel: $channel) {
edges {
node {
shippingMethods {
id
name
minimumOrderWeight {
... | 251 | 7,030 |
readthedocs.org | readthedocs/search/api/v2/urls.py | .py | from django.urls import path
from readthedocs.search.api.v2.views import PageSearchAPIView
urlpatterns = [
path("", PageSearchAPIView.as_view(), name="search_api"),
]
| 9 | 174 |
metrics | tests/unittests/regression/test_r2.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... | 164 | 6,520 |
sqlmap | lib/techniques/hql/inject.py | .py | #!/usr/bin/env python
"""
Copyright (c) 2006-2026 sqlmap developers (https://sqlmap.org)
See the file 'LICENSE' for copying permission
"""
import re
import time
from collections import namedtuple
from lib.core.common import beep
from lib.core.common import randomStr
from lib.core.convert import getUnicode
from lib.... | 646 | 28,360 |
beam | sdks/python/apache_beam/ml/inference/agent_development_kit_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... | 345 | 12,177 |
scikit-optimize | examples/plots/partial-dependence-plot.py | .py | """
========================
Partial Dependence Plots
========================
Sigurd Carlsen Feb 2019
Holger Nahrstaedt 2020
.. currentmodule:: skopt
Plot objective now supports optional use of partial dependence as well as
different methods of defining parameter values for dependency plots.
"""
print(__doc__)
impo... | 116 | 4,460 |
beam | sdks/python/apache_beam/yaml/json_utils_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... | 282 | 9,710 |
onnxruntime | onnxruntime/python/tools/transformers/models/sam2/image_decoder.py | .py | # -------------------------------------------------------------------------
# Copyright (R) Microsoft Corporation. All rights reserved.
# Licensed under the MIT License.
# --------------------------------------------------------------------------
import logging
import warnings
import torch
import torch.nn.functional ... | 273 | 10,821 |
saleor | saleor/graphql/account/mutations/account/__init__.py | .py | from .account_address_create import AccountAddressCreate
from .account_address_delete import AccountAddressDelete
from .account_address_update import AccountAddressUpdate
from .account_delete import AccountDelete
from .account_register import AccountRegister
from .account_request_deletion import AccountRequestDeletion
... | 28 | 966 |
openvino | tests/layer_tests/pytorch_tests/test_randperm.py | .py | # Copyright (C) 2018-2026 Intel Corporation
# SPDX-License-Identifier: Apache-2.0
import pytest
import torch
import numpy as np
from pytorch_layer_test_class import PytorchLayerTest
class TestSortedRandperm(PytorchLayerTest):
def _prepare_input(self):
return (np.arange(self.n, dtype=np.int64),)
def c... | 50 | 1,921 |
jupytext | tests/functional/others/test_jupytext_errors.py | .py | import pytest
from nbformat.v4.nbbase import new_notebook
import jupytext
from jupytext.formats import JupytextFormatError
def test_read_wrong_ext(tmpdir, nb_file="notebook.ext"):
nb_file = tmpdir.join(nb_file)
nb_file.write("{}")
with pytest.raises(JupytextFormatError):
jupytext.read(str(nb_file... | 19 | 516 |
mamba | micromamba/tests/test_constructor.py | .py | """
Tests for micromamba constructor command.
Includes tests for:
- Basic package extraction
- URL-derived metadata handling (issue #4095)
- Consistent field presence (depends/constrains arrays)
"""
import glob
import hashlib
import json
import os
import shutil
import subprocess
import tarfile
from pathlib import Pat... | 375 | 14,347 |
coremltools | coremltools/test/ml_program/experimental/test_perf_utils.py | .py | # Copyright (c) 2025, 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 platform
from typing import Optional
import numpy as np
import pytest
import torch
import co... | 298 | 10,482 |
lemur | lemur/plugins/lemur_acme/cloudflare.py | .py | import time
import CloudFlare
from flask import current_app
def cf_api_call():
cf_key = current_app.config.get("ACME_CLOUDFLARE_KEY", "")
cf_email = current_app.config.get("ACME_CLOUDFLARE_EMAIL", "")
return CloudFlare.CloudFlare(email=cf_email, token=cf_key)
def find_zone_id(host):
elements = host... | 82 | 2,188 |
pyfilesystem2 | tests/test_enums.py | .py | import os
import unittest
from fs import enums
class TestEnums(unittest.TestCase):
def test_enums(self):
self.assertEqual(enums.Seek.current, os.SEEK_CUR)
self.assertEqual(enums.Seek.end, os.SEEK_END)
self.assertEqual(enums.Seek.set, os.SEEK_SET)
self.assertEqual(enums.ResourceTyp... | 13 | 334 |
luigi | test/instance_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... | 95 | 2,675 |
openvino | src/frontends/tensorflow_lite/tests/test_models/gen_scripts/generate_bad_buffer_size.py | .py | # Copyright (C) 2018-2026 Intel Corporation
# SPDX-License-Identifier: Apache-2.0
import os
import struct
import sys
class FlatBufferBuilder:
"""Minimal FlatBuffer builder for crafting test .tflite files."""
def __init__(self, initial_size=8192):
self.buf = bytearray(initial_size)
self.head ... | 363 | 11,996 |
astropy | astropy/cosmology/_src/default.py | .py | """Default Cosmology."""
# Licensed under a 3-clause BSD style license - see LICENSE.rst
__all__ = ("default_cosmology",)
from typing import ClassVar
from astropy.utils.state import ScienceState
# isort: split
from astropy.cosmology._src.core import Cosmology
class default_cosmology(ScienceState):
"""The def... | 110 | 2,991 |
probability | spinoffs/inference_gym/inference_gym/backends/tensorflow_integration_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... | 34 | 1,190 |
conda | tests/common/test_serialize.py | .py | # Copyright (C) 2012 Anaconda, Inc
# SPDX-License-Identifier: BSD-3-Clause
from __future__ import annotations
from contextlib import nullcontext
from functools import partial
from io import StringIO
from typing import TYPE_CHECKING
import pytest
from conda.base.constants import SafetyChecks
from conda.common import ... | 219 | 3,938 |
mlflow | mlflow/store/tracking/utils/sql_trace_metrics_utils.py | .py | import json
from dataclasses import dataclass
from datetime import datetime, timezone
from sqlalchemy import Column, Float, and_, case, distinct, exists, func, literal_column, true
from sqlalchemy.orm import aliased
from sqlalchemy.orm.query import Query
from mlflow.entities.entity_type import EntityAssociationType
f... | 906 | 38,213 |
deap | deap/__init__.py | .py | # This file is part of DEAP.
#
# DEAP is free software: you can redistribute it and/or modify
# it under the terms of the GNU Lesser General Public License as
# published by the Free Software Foundation, either version 3 of
# the License, or (at your option) any later version.
#
# DEAP is distributed ... | 18 | 761 |
readthedocs.org | readthedocs/organizations/tests/test_orgs.py | .py | from unittest import mock
import django_dynamic_fixture as fixture
from django.contrib.auth.models import User
from django.test import TestCase, override_settings
from django.urls import reverse
from django_dynamic_fixture import get
from readthedocs.builds.models import Build, Version
from readthedocs.invitations.mo... | 465 | 16,780 |
scikit-bio | skbio/io/format/gff3.py | .py | """GFF3 format (:mod:`skbio.io.format.gff3`)
=========================================
.. currentmodule:: skbio.io.format.gff3
GFF3 (Generic Feature Format version 3) is a standard file format for
describing features for biological sequences. It contains lines of
text, each consisting of 9 tab-delimited columns [1]_.... | 558 | 18,798 |
coremltools | deps/protobuf/python/google/protobuf/internal/python_message.py | .py | # Protocol Buffers - Google's data interchange format
# Copyright 2008 Google Inc. All rights reserved.
# https://developers.google.com/protocol-buffers/
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions are
# met:
#
# * Redi... | 1,540 | 58,146 |
saleor | saleor/graphql/tax/tests/queries/test_tax_configurations.py | .py | import graphene
from .....tax.models import TaxConfiguration
from ....tests.utils import assert_no_permission, get_graphql_content
from ..fragments import TAX_CONFIGURATION_FRAGMENT
QUERY = (
"""
query TaxConfiguration($filter: TaxConfigurationFilterInput) {
taxConfigurations(first: 100, filter: $filt... | 77 | 2,117 |
openvino | tests/layer_tests/pytorch_tests/test_listunpack.py | .py | # Copyright (C) 2018-2026 Intel Corporation
# SPDX-License-Identifier: Apache-2.0
import numpy as np
import pytest
import torch
from pytorch_layer_test_class import PytorchLayerTest
class TestListUnpack(PytorchLayerTest):
def _prepare_input(self):
return (
self.random.randn(8, 3, 512, 512),... | 348 | 11,201 |
mlflow | tests/utils/test_git_utils.py | .py | import pytest
from mlflow.utils.git_utils import _strip_credentials_from_url
@pytest.mark.parametrize(
("url", "expected"),
[
# HTTPS with username + password (token)
("https://user:token@github.com/foo/bar.git", "https://github.com/foo/bar.git"),
# HTTPS with token-only userinfo (Git... | 38 | 1,577 |
django-cms | cms/tests/test_toolbar_enabled_models.py | .py | from unittest.mock import Mock, patch
from django.apps import apps
from django.contrib.contenttypes.models import ContentType
from django.core.exceptions import ImproperlyConfigured
from django.http import Http404
from cms.api import create_page
from cms.app_registration import get_cms_config_apps, get_cms_extension_... | 184 | 7,723 |
coremltools | coremltools/converters/mil/mil/passes/tests/test_reduce_transposes_pass.py | .py | # Copyright (c) 2020, 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 unittest
import numpy as np
import pytest
from coremltools.converters.mil.mil import Builder... | 1,968 | 78,845 |
cvxpy | cvxpy/tests/test_base_classes.py | .py | import inspect
import numpy as np
import pytest
from cvxpy.atoms.affine.affine_atom import AffAtom
from cvxpy.atoms.atom import Atom
from cvxpy.constraints.constraint import Constraint
from cvxpy.expressions.expression import Expression
from cvxpy.expressions.leaf import Leaf
from cvxpy.interface.base_matrix_interfac... | 76 | 2,473 |
pyomo | pyomo/repn/tests/test_util.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... | 884 | 33,561 |
mlflow | tests/utils/test_python_env.py | .py | from unittest import mock
import pytest
from mlflow.utils import PYTHON_VERSION
from mlflow.utils.environment import _PythonEnv
def test_constructor_argument_validation():
with pytest.raises(TypeError, match="`python` must be a string"):
_PythonEnv(python=1)
with pytest.raises(TypeError, match="`bu... | 147 | 3,577 |
pyomo | examples/pyomo/draft/api.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... | 629 | 14,733 |
mlflow | tests/tracking/test_span_links_client.py | .py | from mlflow.entities import Link
from mlflow.tracking.client import MlflowClient
from tests.tracing.helper import get_traces
def test_client_start_trace_with_links():
client = MlflowClient()
links = [
Link(trace_id="tr-0123456789abcdef0123456789abcdef", span_id="0123456789abcdef"),
]
root = ... | 49 | 1,398 |
sphinx | tests/test_environment/test_environment.py | .py | """Test the BuildEnvironment class."""
from __future__ import annotations
import shutil
from pathlib import Path
from typing import TYPE_CHECKING
import pytest
from sphinx._cli.util.errors import strip_escape_sequences
from sphinx.builders.html import StandaloneHTMLBuilder
from sphinx.builders.latex import LaTeXBui... | 234 | 7,647 |
beam | sdks/python/apache_beam/transforms/validate_runner_xlang_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... | 399 | 15,966 |
coremltools | coremltools/optimize/torch/_utils/metadata_utils.py | .py | # Copyright (c) 2024, 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
from enum import Enum
from typing import Dict as _Dict
from typing import List as _List
from typing i... | 145 | 6,075 |
jupytext | tests/functional/simple_notebooks/test_read_simple_nomarker.py | .py | import os
import pytest
from nbformat.v4.nbbase import new_code_cell, new_markdown_cell, new_notebook
from jupytext import reads, write, writes
from jupytext.cli import jupytext as jupytext_cli
from jupytext.combine import combine_inputs_with_outputs
from jupytext.compare import compare
def test_write_reload_simple... | 65 | 1,944 |
kombu | t/skip.py | .py | from __future__ import annotations
import sys
import pytest
if_pypy = pytest.mark.skipif(
getattr(sys, 'pypy_version_info', None),
reason='PyPy not supported.'
)
if_win32 = pytest.mark.skipif(
sys.platform.startswith('win32'),
reason='Does not work on Windows'
)
| 16 | 283 |
openvino | tests/utils/proc_utils.py | .py | #!/usr/bin/env python3
# Copyright (C) 2018-2026 Intel Corporation
# SPDX-License-Identifier: Apache-2.0
""" Common utilities for working with processes.
"""
import logging
import subprocess
def cmd_exec(args, timeout=None, env=None, log=None, verbose=True, shell=False):
""" Run cmd using subprocess with loggi... | 47 | 1,220 |
probability | tensorflow_probability/python/experimental/mcmc/sequential_monte_carlo_kernel.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... | 374 | 16,992 |
cvxpy | cvxpy/reductions/reduction.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... | 305 | 9,884 |
probability | tensorflow_probability/python/math/gram_schmidt.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... | 86 | 3,485 |
lemur | lemur/dns_providers/service.py | .py | import json
from flask import current_app
from lemur import database
from lemur.dns_providers.models import DnsProvider
from lemur.logs import service as log_service
def render(args):
"""
Helper that helps us render the REST Api responses.
:param args:
:return:
"""
query = database.session_q... | 144 | 4,048 |
gunicorn | gunicorn/dirty/__init__.py | .py | #
# This file is part of gunicorn released under the MIT license.
# See the NOTICE for more information.
"""
Dirty Arbiters - Separate process pool for long-running operations.
Dirty Arbiters provide a separate process pool for executing long-running,
blocking operations (AI model loading, heavy computation) without ... | 82 | 2,017 |
hydra | tests/test_overrides_parser.py | .py | # Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved
import builtins
import math
import re
from contextlib import nullcontext
from dataclasses import dataclass
from typing import Any, Callable, Dict, List, Union
try:
from _pytest.raises import RaisesExc as RaisesContext
except ImportError:
fr... | 2,395 | 79,934 |
hydra | examples/tutorials/structured_configs/4_defaults/my_app.py | .py | # Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved
from dataclasses import dataclass, field
from typing import Any, List
from omegaconf import MISSING, OmegaConf # Do not confuse with dataclass.MISSING
import hydra
from hydra.core.config_store import ConfigStore
@dataclass
class MySQLConfig:
... | 58 | 1,314 |
coveragepy | tests/test_bytecode.py | .py | # Licensed under the Apache License: http://www.apache.org/licenses/LICENSE-2.0
# For details: https://github.com/coveragepy/coveragepy/blob/main/NOTICE.txt
"""Tests for coverage.py's bytecode analysis."""
from __future__ import annotations
import dis
from textwrap import dedent
from tests.coveragetest import Cove... | 47 | 1,424 |
clearml | clearml/external/kerastuner.py | .py | from logging import getLogger
from typing import Optional, Any
from ..task import Task
_logger = getLogger("clearml.external.kerastuner")
try:
import pandas as pd
except ImportError:
pd = None
_logger.warning("Pandas is not installed, summary table reporting will be skipped.")
try:
from kerastuner i... | 124 | 5,178 |
mlflow | mlflow/genai/judges/tools/search_traces.py | .py | """
Search traces tool for MLflow GenAI judges.
This module provides a tool for searching and retrieving traces from an MLflow experiment
based on filter criteria, ordering, and result limits. It enables judges to analyze
traces within the same experiment context.
"""
import logging
import mlflow
from mlflow.entitie... | 269 | 11,277 |
onnx | onnx/reference/ops/op_atanh.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 Atanh(OpRunUnaryNum):
def _run(self, x):
return (np.arctanh(x),)
| 14 | 271 |
mlflow | tests/genai/judges/test_search_trace_regex_tool.py | .py | import json
import pytest
from mlflow.entities.trace import Trace
from mlflow.entities.trace_data import TraceData
from mlflow.entities.trace_info import TraceInfo
from mlflow.entities.trace_location import TraceLocation
from mlflow.entities.trace_state import TraceState
from mlflow.genai.judges.tools.search_trace_re... | 307 | 11,174 |
onnxruntime | tools/python/util/check_onnx_model_mobile_usability.py | .py | # Copyright (c) Microsoft Corporation. All rights reserved.
# Licensed under the MIT License.
import argparse
import logging
import pathlib
# need this before the mobile helper imports for some reason
logging.basicConfig(format="%(levelname)s: %(message)s")
from .mobile_helpers import usability_checker # noqa: E40... | 48 | 1,670 |
coremltools | coremltools/optimize/torch/quantization/_qconfig_mapping.py | .py | # Copyright (c) 2024, 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 logging as _logging
from typing import Any as _Any
from typing import Callable as _Callable
fr... | 394 | 15,517 |
pymc | tests/sampling/test_forward.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... | 2,379 | 94,473 |
onnxruntime | orttraining/orttraining/test/python/test_train_script.py | .py | # Copyright (c) Microsoft Corporation. All rights reserved.
# Licensed under the MIT License.
import importlib.util
import shlex
from pathlib import Path
from unittest.mock import patch
def load_train_module():
train_script = Path(__file__).resolve().parents[4] / "orttraining/tools/scripts/train.py"
spec = i... | 41 | 1,384 |
openvino | tests/e2e_tests/pipelines/pipeline_templates/pytorch_to_onnx_converter_template.py | .py | # Copyright (C) 2018-2026 Intel Corporation
# SPDX-License-Identifier: Apache-2.0
def convert_pytorch_to_onnx(model_name=None,
weights=None,
input_shapes=None,
output_file=None,
model_path=None,
... | 34 | 1,359 |
pyomo | pyomo/contrib/pynumero/sparse/tests/test_mpi_block_matrix.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,460 | 53,511 |
probability | tensorflow_probability/python/stats/ranking_test.py | .py | # Copyright 2019 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... | 97 | 3,631 |
astropy | astropy/io/misc/tests/test_parquet.py | .py | # Licensed under a 3-clause BSD style license - see LICENSE.rst
from io import FileIO
import numpy as np
import pytest
from numpy.testing import assert_array_equal
from astropy import units as u
from astropy.coordinates import (
Angle,
CartesianRepresentation,
EarthLocation,
Latitude,
Longitude,
... | 1,051 | 30,990 |
textual | tests/test_message_pump.py | .py | import threading
import pytest
from textual._dispatch_key import dispatch_key
from textual.app import App, ComposeResult
from textual.errors import DuplicateKeyHandlers
from textual.events import Key
from textual.message import Message
from textual.widget import Widget
from textual.widgets import Button, Input, Label... | 193 | 5,367 |
django-cms | cms/tests/test_menu_utils.py | .py | from urllib.parse import urlencode
from django.http import HttpResponse
from cms.api import create_page, create_page_content
from cms.test_utils.testcases import CMSTestCase
from cms.test_utils.util.mock import AttributeObject
from cms.toolbar.toolbar import CMSToolbar
from cms.utils.i18n import get_language_list
fro... | 180 | 7,428 |
hydra | tests/test_examples/test_tutorials_basic.py | .py | # Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved
import os
import re
import subprocess
from pathlib import Path
from textwrap import dedent
from typing import Any, List
try:
from _pytest.raises import RaisesExc as RaisesContext
except ImportError:
from _pytest.python_api import RaisesCont... | 349 | 10,533 |
readthedocs.org | readthedocs/embed/v3/tests/examples/default/conf.py | .py | # conf.py to run tests
master_doc = "index"
extensions = [
"sphinx.ext.autosectionlabel",
"sphinxcontrib.bibtex",
]
bibtex_bibfiles = ["refs.bib"]
def setup(app):
app.add_object_type(
"confval", # directivename
"confval", # rolename
"pair: %s; configuration value", # indextemp... | 18 | 331 |
jupytext | tests/functional/cli/test_source_is_newer.py | .py | """
Here we test the --check-source-is-newer option of the jupytext CLI
"""
import os
from jupytext import cli
from jupytext import write
import pytest
def test_check_source_is_newer_when_using_jupytext_to(tmp_path, python_notebook):
tmp_ipynb = tmp_path / "notebook.ipynb"
tmp_py = tmp_path / "notebook.py"
... | 71 | 3,127 |
pyomo | pyomo/common/tests/test_multithread.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... | 144 | 4,417 |
openvino | docs/articles_en/assets/snippets/torchvision_preprocessing.py | .py | # Copyright (C) 2018-2026 Intel Corporation
# SPDX-License-Identifier: Apache-2.0
def main():
#! [torchvision_preprocessing]
import torch.nn.functional as f
import openvino as ov
import numpy as np
import torchvision
import torch
import os
from openvino.preprocess.torchvision import ... | 66 | 2,361 |
sphinx | tests/test_extensions/test_ext_githubpages.py | .py | """Test sphinx.ext.githubpages extension."""
from __future__ import annotations
from typing import TYPE_CHECKING
import pytest
from sphinx.testing.util import SphinxTestApp
if TYPE_CHECKING:
from sphinx.testing.util import SphinxTestApp
@pytest.mark.sphinx('html', testroot='ext-githubpages')
def test_githubp... | 42 | 1,158 |
jupytext | src/jupytext/reraise.py | .py | """Raise the given error at evaluation time"""
def reraise(error):
"""Return a function that raises the given error when evaluated"""
def local_function(*args, **kwargs):
raise error
return local_function
| 11 | 229 |
pymc | tests/logprob/test_censoring.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... | 486 | 16,817 |
probability | tensorflow_probability/python/sts/components/local_linear_trend.py | .py | # Copyright 2018 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... | 428 | 18,227 |
openvino | src/bindings/python/tests/test_graph/test_affix_ops.py | .py | # -*- coding: utf-8 -*-
# Copyright (C) 2018-2026 Intel Corporation
# SPDX-License-Identifier: Apache-2.0
import numpy as np
import pytest
import re
import openvino.opset13 as ov
from openvino import Type
@pytest.mark.parametrize("op_name", [
"ABC",
"Fakeee",
"123456",
"FakeQuantize",
])
def test_af... | 151 | 4,648 |
astropy | astropy/coordinates/tests/test_earth.py | .py | # Licensed under a 3-clause BSD style license - see LICENSE.rst
"""Test initialization of angles not already covered by the API tests"""
import pickle
import numpy as np
import pytest
from astropy import constants
from astropy import units as u
from astropy.coordinates import Latitude, Longitude
from astropy.coordi... | 412 | 16,723 |
wagtail | wagtail/admin/views/pages/move.py | .py | import swapper
from django.conf import settings
from django.core.exceptions import PermissionDenied
from django.shortcuts import get_object_or_404, redirect
from django.urls import reverse
from django.utils.translation import gettext as _
from django.views.generic.base import TemplateView
from django.views.generic.edit... | 180 | 7,216 |
wagtail | wagtail/images/views/multiple.py | .py | import os.path
from django.template.loader import render_to_string
from django.urls import reverse
from django.utils.text import capfirst
from django.utils.translation import gettext_lazy
from wagtail.admin.views.generic.base import WagtailAdminTemplateMixin
from wagtail.admin.views.generic.multiple_upload import Add... | 179 | 6,041 |
wagtail | wagtail/admin/views/generic/models.py | .py | from django.contrib.admin.utils import label_for_field, quote, unquote
from django.contrib.contenttypes.models import ContentType
from django.core.exceptions import (
FieldDoesNotExist,
ImproperlyConfigured,
PermissionDenied,
)
from django.db import models, transaction
from django.db.models.constants import... | 1,753 | 61,308 |
readthedocs.org | readthedocs/core/mixins.py | .py | """Common mixin classes for views."""
from django.contrib import messages
from django.contrib.auth.mixins import LoginRequiredMixin
from django.http import HttpResponseRedirect
from vanilla import DeleteView
from vanilla import ListView
from readthedocs.core.tasks import delete_object
from readthedocs.proxito.cache i... | 103 | 3,396 |
onnx | onnx/reference/ops/op_sequence_map.py | .py | # Copyright (c) ONNX Project Contributors
# SPDX-License-Identifier: Apache-2.0
from __future__ import annotations
from onnx.reference.op_run import OpRun
class SequenceMap(OpRun):
def _run(self, input_sequence, *additional_inputs, body=None, attributes=None):
if len(additional_inputs) == 1 and isinstan... | 34 | 1,245 |
probability | tensorflow_probability/python/mcmc/nuts.py | .py | # Copyright 2019 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... | 1,109 | 45,152 |
clearml | clearml/binding/args.py | .py | """ Argparse utilities"""
import argparse
import sys
import warnings
from argparse import ArgumentParser, Namespace
from copy import copy
from typing import Optional, List, Union, Dict, Tuple, Callable, Type, Any
try:
from argparse import _SubParsersAction
except ImportError:
_SubParsersAction = type(None)
c... | 317 | 12,879 |
lemur | lemur/plugins/lemur_acme/tests/test_acme_http.py | .py | import unittest
from unittest.mock import patch, Mock
from acme import challenges
from flask import Flask
from lemur.plugins.lemur_acme import plugin
from lemur.tests.vectors import (
ACME_CHAIN_LONG_STR,
SAN_CERT_STR,
ACME_CHAIN_X1_STR
)
class TestAcmeHttp(unittest.TestCase):
def setUp(self):
... | 189 | 8,309 |
hatch | tests/helpers/templates/wheel/standard_default_license_single.py | .py | from hatch.template import File
from hatch.utils.fs import Path
from hatchling.__about__ import __version__
from hatchling.metadata.spec import DEFAULT_METADATA_VERSION
from ..new.default import get_files as get_template_files
from .utils import update_record_file_contents
def get_files(**kwargs):
metadata_direc... | 50 | 1,290 |
clearml | clearml/hyperdatasets/data_view.py | .py | import logging
import queue
import threading
from math import ceil
from queue import Queue
from typing import (
Any,
List,
Mapping,
Optional,
Tuple,
Union,
Sequence,
Iterable,
)
from clearml.backend_api import Session
from clearml.backend_api.services import dataviews as _dataviews
from... | 1,755 | 69,544 |
beam | sdks/python/apache_beam/testing/datatype_inference_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... | 193 | 6,164 |
probability | tensorflow_probability/python/experimental/bijectors/highway_flow.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... | 407 | 15,610 |
pyro | examples/mixed_hmm/seal_data.py | .py | # Copyright (c) 2017-2019 Uber Technologies, Inc.
# SPDX-License-Identifier: Apache-2.0
import os
from urllib.request import urlopen
import pandas as pd
import torch
MISSING = 1e-6
def download_seal_data(filename):
"""download the preprocessed seal data and save it to filename"""
url = "https://github.com/... | 76 | 2,560 |
pdm | src/pdm/formats/__init__.py | .py | from __future__ import annotations
from typing import TYPE_CHECKING, cast
from pdm.formats import flit, pipfile, poetry, requirements, setup_py
from pdm.formats.base import MetaConvertError as MetaConvertError
if TYPE_CHECKING:
from argparse import Namespace
from collections.abc import Iterable, Mapping
... | 40 | 1,250 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.