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
pyomo
pyomo/contrib/solver/solvers/knitro/engine.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...
541
20,318
mkdocs-material
material/plugins/tags/structure/mapping/storage/__init__.py
.py
# Copyright (c) 2016-2025 Martin Donath <martin.donath@squidfunk.com> # Permission is hereby granted, free of charge, to any person obtaining a copy # of this software and associated documentation files (the "Software"), to # deal in the Software without restriction, including without limitation the # rights to use, c...
212
6,407
saleor
saleor/core/tests/test_view.py
.py
import functools from pathlib import Path import jwt import pytest from django.http import FileResponse, Http404 from django.test import RequestFactory from jwt import PyJWK from ..jwt_manager import get_jwt_manager from ..views import serve_media_view @pytest.fixture def dummy_media_file_request(media_root: str): ...
85
2,393
biopython
Bio/SeqIO/_index.py
.py
# Copyright 2009-2011 by Peter Cock. All rights reserved. # # This file is part of the Biopython distribution and governed by your # choice of the "Biopython License Agreement" or the "BSD 3-Clause License". # Please see the LICENSE file that should have been included as part of this # package. """Dictionary like inde...
719
27,642
django-cms
cms/test_utils/project/sampleapp/urls2.py
.py
from django.urls import re_path from . import views urlpatterns = [ re_path(r'^$', views.sample_view, {'message': 'sample apphook2 root page', }, name='sample2-root'), ]
8
176
flit
flit_core/flit_core/wheel.py
.py
from __future__ import annotations import argparse from base64 import urlsafe_b64encode import contextlib import csv from datetime import datetime, timezone import hashlib from io import StringIO import logging import os import os.path as osp import stat import tempfile from pathlib import Path from types import Simple...
260
9,279
sphinx
tests/test_directives/test_directive_productionlist.py
.py
"""Tests the productionlist directive.""" from __future__ import annotations import pytest from docutils import nodes from sphinx.addnodes import pending_xref from sphinx.testing import restructuredtext from sphinx.testing.util import SphinxTestApp, assert_node, etree_parse TYPE_CHECKING = False if TYPE_CHECKING: ...
154
7,343
black
tests/data/cases/preview_long_strings__edge_case.py
.py
# flags: --unstable some_variable = "This string is long but not so long that it needs to be split just yet" some_variable = 'This string is long but not so long that it needs to be split just yet' some_variable = "This string is long, just long enough that it needs to be split, u get?" some_variable = 'This string is ...
142
6,556
beam
sdks/python/apache_beam/testing/benchmarks/nexmark/queries/query12.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...
50
2,039
scikit-bio
skbio/diversity/tests/test_block.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. # --------------------------------------------...
208
8,333
openvino
tests/layer_tests/pytorch_tests/test_vstack.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, skip_if_export class aten_vstack(torch.nn.Module): def forward(self, x): return torch.vstack(self.prepare_input(x)) de...
87
3,100
pyomo
doc/OnlineDocs/src/data/table6.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...
18
694
beam
sdks/python/apache_beam/ml/rag/ingestion/alloydb_it_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...
1,038
39,182
structlog
tests/test_threadlocal.py
.py
# SPDX-License-Identifier: MIT OR Apache-2.0 # This file is dual licensed under the terms of the Apache License, Version # 2.0, and the MIT License. See the LICENSE file in the root of this # repository for complete details. import inspect import threading import pytest import structlog from structlog import get_l...
506
13,821
hatch
tests/index/test_core.py
.py
import json import platform import httpx2 import pytest from hatch._version import __version__ from hatch.index.core import PackageIndex from hatch.utils.linehaul import get_linehaul_component class TestRepo: def test_normalization(self): index = PackageIndex("Https://Foo.Internal/z/../a/b/") a...
131
4,859
saleor
saleor/graphql/core/types/event.py
.py
from graphene.types.objecttype import ObjectTypeOptions from ..doc_category import DOC_CATEGORY_MAP from ..types import BaseObjectType # Rewrite original map to use model to category mapping, with the app name skipped, # so that it can be used with root_type from SubscriptionObjectType. DOC_CATEGORY_MODEL_MAP = { ...
44
1,313
biopython
Tests/test_AlignIO.py
.py
# Copyright 2008 by Peter Cock. All rights reserved. # 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 AlignIO module.""" import unittest import warnings from io import StringIO from Bio...
1,417
60,280
openvino
src/bindings/python/tests/test_graph/test_detection_output.py
.py
# -*- coding: utf-8 -*- # Copyright (C) 2018-2026 Intel Corporation # SPDX-License-Identifier: Apache-2.0 import numpy as np import openvino.opset8 as ov import pytest np_types = [np.float32, np.int32] integral_np_types = [ np.int8, np.int16, np.int32, np.int64, np.uint8, np.uint16, np.uin...
119
4,262
wagtail
wagtail/contrib/search_promotions/wagtail_hooks.py
.py
from django.contrib.auth.models import Permission from django.urls import include, path, reverse from django.utils.translation import gettext_lazy as _ from wagtail import hooks from wagtail.admin.admin_url_finder import ( ModelAdminURLFinder, register_admin_url_finder, ) from wagtail.admin.menu import AdminOn...
75
2,238
scikit-bio
skbio/stats/distance/tests/test_util.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. # --------------------------------------------...
147
4,409
beam
sdks/python/apache_beam/yaml/yaml_ml_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...
242
8,925
mlflow
mlflow/genai/discovery/pipeline.py
.py
from __future__ import annotations import json import logging import time from collections.abc import Callable from concurrent.futures import ThreadPoolExecutor, as_completed from dataclasses import dataclass import pydantic import mlflow from mlflow.entities.assessment_source import AssessmentSource, AssessmentSour...
855
30,896
bazel
third_party/py/abseil/absl/flags/_flagvalues.py
.py
# Copyright 2017 The Abseil 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 ...
1,419
51,333
probability
tensorflow_probability/python/bijectors/gumbel_cdf_test.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...
78
3,071
mlflow
mlflow/gateway/providers/xai.py
.py
from mlflow.gateway.config import _OpenAICompatibleConfig from mlflow.gateway.providers.openai_compatible import OpenAICompatibleProvider class XAIProvider(OpenAICompatibleProvider): DISPLAY_NAME = "xAI" CONFIG_TYPE = _OpenAICompatibleConfig DEFAULT_API_BASE = "https://api.x.ai/v1"
9
297
beam
sdks/python/apache_beam/yaml/yaml_combine.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...
224
7,751
returns
returns/contrib/mypy/_consts.py
.py
from typing import Final # Constant fullnames for typechecking # =================================== #: Used for typed ``partial`` function. TYPED_PARTIAL_FUNCTION: Final = 'returns.curry.partial' #: Used for typed ``curry`` decorator. TYPED_CURRY_FUNCTION: Final = 'returns.curry.curry' #: Used for typed ``flow`` c...
37
1,205
hydra
examples/plugins/example_generic_plugin/setup.py
.py
# Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved # type: ignore from setuptools import find_namespace_packages, setup with open("README.md") as fh: LONG_DESC = fh.read() setup( name="hydra-example-generic-plugin", version="1.0.0", author="Omry Yadan", autho...
39
1,611
qutip
qutip/solver/mcsolve.py
.py
# Required for Sphinx to follow autodoc_type_aliases from __future__ import annotations __all__ = ['mcsolve', "MCSolver"] from ..core.numpy_backend import np from numpy.typing import ArrayLike from numpy.random import SeedSequence from time import time from typing import Any import warnings from .. import settings f...
986
39,590
tqdm
tests/tests_itertools.py
.py
""" Tests for `tqdm.contrib.itertools`. """ import itertools as it import pytest from tqdm.contrib import itertools as tit def no_len(iterable): yield from iterable def test_chain(capsys): """Test contrib.itertools.chain""" a = range(9) assert list(tit.chain(a, a)) == list(it.chain(a, a)) asse...
118
3,877
saleor
saleor/graphql/account/mutations/account/utils.py
.py
ADDRESS_UPDATE_FIELDS = { "city", "city_area", "company_name", "country", "country_area", "first_name", "last_name", "metadata", "phone", "postal_code", "private_metadata", "street_address_1", "street_address_2", "validation_skipped", } ACCOUNT_UPDATE_FIELDS = {...
25
395
wandb
tests/system_tests/test_functional/dspy/dspy_callback_completions.py
.py
import dspy import wandb from dspy.evaluate.evaluate import EvaluationResult # type: ignore class MinimalProgram(dspy.Module): def __init__(self) -> None: super().__init__() self.predict = dspy.Predict("question: str -> answer: str") class DummyCompletions: """Minimal stand-in for dspy.Comp...
54
1,559
pyomo
examples/pyomobook/python-ch/iterate.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...
28
854
gunicorn
tests/test_dirty_errors.py
.py
# # This file is part of gunicorn released under the MIT license. # See the NOTICE for more information. """Tests for dirty errors module.""" import pytest from gunicorn.dirty.errors import ( DirtyError, DirtyNoWorkersAvailableError, ) class TestDirtyNoWorkersAvailableError: """Tests for DirtyNoWorkers...
77
2,679
metrics
src/torchmetrics/regression/tweedie_deviance.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...
154
5,919
onnx
onnx/reference/ops/op_string_normalizer.py
.py
# Copyright (c) ONNX Project Contributors # SPDX-License-Identifier: Apache-2.0 from __future__ import annotations import locale as pylocale import unicodedata import warnings import numpy as np from onnx.reference.op_run import OpRun, RuntimeTypeError class StringNormalizer(OpRun): """The operator is not rea...
150
4,941
biopython
Bio/AlignIO/StockholmIO.py
.py
# Copyright 2006-2016 by Peter Cock. All rights reserved. # Revisions copyright 2015 by Ben Woodcroft. All rights reserved. # # This file is part of the Biopython distribution and governed by your # choice of the "Biopython License Agreement" or the "BSD 3-Clause License". # Please see the LICENSE file that should ha...
621
26,397
ipython
tests/test_autocall.py
.py
"""These kinds of tests are less than ideal, but at least they run. This was an old test that was being run interactively in the top-level tests/ directory, which we are removing. For now putting this here ensures at least we do run the test, though ultimately this functionality should all be tested with better-isola...
158
4,198
openvino
tests/layer_tests/tensorflow_tests/test_tf_AddN.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 # Testing operation AddN # Documentation: https://www.tensorflow.org/api_docs/python/tf/raw_ops/AddN class TestAddN(Comm...
97
3,856
onnxruntime
onnxruntime/test/testdata/test_evil_weights.py
.py
import onnx def create_exp_model(): inputs = [] nodes = [] tensors = [] outputs = [] input_ = onnx.helper.make_tensor_value_info("input", onnx.TensorProto.INT64, [None, None]) inputs.append(input_) evil_tensor = onnx.helper.make_tensor( name="evil_weights", data_type=onnx...
50
1,507
clearml
clearml/config/remote.py
.py
from typing import Optional from .defs import TASK_ID_ENV_VAR running_remotely_task_id = TASK_ID_ENV_VAR.get() def override_current_task_id(task_id: Optional[str]) -> None: """ Overrides the current task id to simulate remote running with a specific task. Use for testing and debug only. :param tas...
24
625
pyro
pyro/contrib/gp/kernels/periodic.py
.py
# Copyright (c) 2017-2019 Uber Technologies, Inc. # SPDX-License-Identifier: Apache-2.0 import math import torch from torch.distributions import constraints from pyro.contrib.gp.kernels.isotropic import Isotropy from pyro.contrib.gp.kernels.kernel import Kernel from pyro.nn.module import PyroParam class Cosine(Iso...
79
2,424
bazel
third_party/py/concurrent/futures/__init__.py
.py
# Copyright 2009 Brian Quinlan. All Rights Reserved. # Licensed to PSF under a Contributor Agreement. """Execute computations asynchronously using threads or processes.""" __author__ = 'Brian Quinlan (brian@sweetapp.com)' from third_party.py.concurrent.futures._base import (FIRST_COMPLETED, ...
19
965
saleor
saleor/thumbnail/tests/test_utils.py
.py
from unittest import mock from unittest.mock import MagicMock, patch import graphene import pytest from django.core.files import File from PIL.JpegImagePlugin import JpegImageFile from .. import FILE_NAME_MAX_LENGTH, ThumbnailFormat from ..models import Thumbnail from ..utils import ( ProcessedImage, get_file...
229
6,842
wandb
wandb/sdk/__init__.py
.py
"""W&B SDK module.""" __all__ = ( "Config", "Settings", "Summary", "Artifact", "AlertLevel", "init", "setup", "_attach", "_sync", "login", "require", "finish", "teardown", "_watch", "_unwatch", "sweep", "controller", "helper", ) from . import wan...
37
783
httpie
httpie/legacy/v3_2_0_session_header_format.py
.py
from typing import Any, Type, List, Dict, TYPE_CHECKING if TYPE_CHECKING: from httpie.sessions import Session OLD_HEADER_STORE_WARNING = '''\ Outdated layout detected for the current session. Please consider updating it, in order to use the latest features regarding the header layout. For fixing the current ses...
74
2,078
luigi
test/date_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...
189
6,916
mlflow
tests/telemetry/conftest.py
.py
from unittest.mock import Mock, patch import pytest import mlflow.telemetry.utils from mlflow.telemetry.client import ( TelemetryClient, _fetch_server_info, _set_telemetry_client, get_telemetry_client, ) from mlflow.utils.server_info import _clear_server_info_cache from mlflow.version import VERSION ...
110
3,397
readthedocs.org
readthedocs/rtd_tests/tests/test_version_querysets.py
.py
from django.contrib.auth.models import User from django.test import TestCase from django_dynamic_fixture import get from readthedocs.builds.constants import EXTERNAL, INTERNAL, LATEST from readthedocs.builds.models import Version from readthedocs.projects.constants import PRIVATE, PUBLIC from readthedocs.projects.mode...
364
11,868
cvxpy
cvxpy/tests/test_dgp2dcp.py
.py
import numpy as np import pytest import cvxpy import cvxpy.error as error import cvxpy.reductions.dgp2dcp.canonicalizers as dgp_atom_canon from cvxpy.atoms.affine.add_expr import AddExpression from cvxpy.reductions import solution from cvxpy.settings import SOLVER_ERROR from cvxpy.tests.base_test import BaseTest SOLV...
660
27,402
openvino
tests/layer_tests/pytorch_tests/test_hardtanh.py
.py
# Copyright (C) 2018-2026 Intel Corporation # SPDX-License-Identifier: Apache-2.0 import pytest import torch from pytorch_layer_test_class import PytorchLayerTest class TestHardtanh(PytorchLayerTest): def _prepare_input(self, input_dtype="float32", input_shape=(1, 3, 10, 10)): return (self.random.unifor...
41
1,779
gunicorn
tests/requests/invalid/rfc9112_smuggle_cl_list_form_01.py
.py
# # This file is part of gunicorn released under the MIT license. # See the NOTICE for more information. # RFC 9112 section 6.3 allows Content-Length list form when all values # match, but gunicorn takes the safer strict view and rejects any list # form outright to avoid proxy/origin desync. PortSwigger HTTP Desync, #...
11
409
saleor
saleor/payment/tests/fixtures/transaction_item.py
.py
import uuid from decimal import Decimal import pytest from ...models import TransactionItem from ...transaction_item_calculations import recalculate_transaction_amounts from ...utils import create_manual_adjustment_events @pytest.fixture def transaction_item_generator(): def create_transaction( order_id...
114
3,322
probability
spinoffs/inference_gym/inference_gym/targets/stochastic_volatility_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...
105
4,274
mlflow
mlflow/system_metrics/__init__.py
.py
"""System metrics logging module.""" from mlflow.environment_variables import ( MLFLOW_ENABLE_SYSTEM_METRICS_LOGGING, MLFLOW_SYSTEM_METRICS_NODE_ID, MLFLOW_SYSTEM_METRICS_SAMPLES_BEFORE_LOGGING, MLFLOW_SYSTEM_METRICS_SAMPLING_INTERVAL, ) def disable_system_metrics_logging(): """Disable system met...
62
2,080
coremltools
coremltools/converters/mil/frontend/tensorflow2/tf_graph_pass/__init__.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 from .rewrite_control_flow_functions import (flatten_sub_graph_namespaces, ...
8
371
deap
doc/code/tutorials/part_3/3_6_using_the_toolbox.py
.py
## 3.6 Using the Toolbox from deap import base from deap import tools toolbox = base.Toolbox() def evaluateInd(individual): # Do some computation result = sum(individual) return result, toolbox.register("mate", tools.cxTwoPoint) toolbox.register("mutate", tools.mutGaussian, mu=0, sigma=1, indpb=0.2) tool...
56
1,907
funcy
tests/test_funcmakers.py
.py
from collections import defaultdict import pytest from funcy.funcmakers import * def test_callable(): assert make_func(lambda x: x + 42)(0) == 42 def test_int(): assert make_func(0)('abc') == 'a' assert make_func(2)([1,2,3]) == 3 assert make_func(1)({1: 'a'}) == 'a' with pytest.raises(IndexErro...
43
993
beam
sdks/python/apache_beam/testing/benchmarks/nexmark/models/auction_bid.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...
58
1,963
openvino
tests/layer_tests/tensorflow_tests/test_tf_UnsortedSegmentMax.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(56234) class TestUnsortedSegmentMax(CommonTFLayerTest): def _prepare_input(self, inputs_...
81
4,073
jupytext
docs/conf.py
.py
# Minimal Sphinx configuration — serves HTTP redirects from jupytext.readthedocs.io # to the new jupytext.org site via sphinx-reredirects. # The actual documentation now lives in website/ (Astro + Starlight). project = "Jupytext" extensions = ["myst_parser", "sphinx_reredirects"] source_suffix = {".md": "markdown"} r...
32
1,596
django-cms
cms/admin/forms.py
.py
from django import forms from django.apps import apps from django.contrib.auth import get_permission_codename, get_user_model from django.contrib.auth.models import Permission from django.contrib.contenttypes.models import ContentType from django.contrib.sites.models import Site from django.core.exceptions import Objec...
1,562
57,015
clearml
examples/router/multi_endpoints.py
.py
""" Minimal example showing how to request multiple external endpoints for a Task. This script assumes you already have local services bound to ports 8000 and 8001. You can reuse `simple_webserver.py` for the primary endpoint and launch any other service on the secondary port before running this example. """ from cle...
24
933
gunicorn
tests/requests/invalid/001.py
.py
# # This file is part of gunicorn released under the MIT license. # See the NOTICE for more information. from gunicorn.http.errors import NoMoreData request = NoMoreData
6
170
coremltools
coremltools/optimize/torch/quantization/modules/__init__.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
5
218
pyomo
pyomo/contrib/pyros/master_problem_methods.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...
943
33,910
openvino
tests/layer_tests/tensorflow2_keras_tests/test_tf2_keras_lstm_cell.py
.py
# Copyright (C) 2018-2026 Intel Corporation # SPDX-License-Identifier: Apache-2.0 import pytest import tensorflow as tf from common.tf2_layer_test_class import CommonTF2LayerTest class TestKerasLSTMCell(CommonTF2LayerTest): def create_keras_lstmcell_net(self, input_names, input_shapes, input_type, units, activa...
60
2,913
cvxpy
cvxpy/reductions/dgp2dcp/canonicalizers/prod_canon.py
.py
from cvxpy.atoms.affine.sum import sum as sum_func def prod_canon(expr, args): return sum_func(args[0], axis=expr.axis, keepdims=expr.keepdims), []
6
154
probability
tensorflow_probability/python/math/psd_kernels/matern_test.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...
453
14,596
probability
tensorflow_probability/python/layers/distribution_layer.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...
2,034
79,352
pyomo
examples/pyomobook/abstract-ch/set5.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...
23
791
lemur
config-default.py
.py
import os _basedir = os.path.abspath(os.path.dirname(__file__))
3
64
openvino
tests/layer_tests/pytorch_tests/test_bernoulli.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 TestBernoulli(PytorchLayerTest): def _prepare_input(self, input, input_type, out): model_inputs = [input.astype(inpu...
107
4,210
mlflow
examples/gateway/mistral/example.py
.py
from mlflow.deployments import get_deploy_client def main(): client = get_deploy_client("http://localhost:7000") print(f"Mistral endpoints: {client.list_endpoints()}\n") print(f"Mistral completions endpoint info: {client.get_endpoint(endpoint='completions')}\n") # Completions request response_co...
35
1,037
black
src/blib2to3/pgen2/tokenize.py
.py
# Copyright (c) 2001, 2002, 2003, 2004, 2005, 2006 Python Software Foundation. # All rights reserved. # mypy: allow-untyped-defs, allow-untyped-calls """Tokenization help for Python programs. generate_tokens(readline) is a generator that breaks a stream of text into Python tokens. It accepts a readline-like method ...
278
9,037
httpie
tests/test_errors.py
.py
import pytest import socket from unittest import mock from pytest import raises from requests import Request from requests.exceptions import ConnectionError from httpie.status import ExitStatus from .utils import HTTP_OK, http @mock.patch('httpie.core.program') def test_error(program): exc = ConnectionError('Con...
77
2,392
saleor
saleor/graphql/order/tests/mutations/test_utils.py
.py
import graphene import pytest from django.core.exceptions import ValidationError from .....account.models import User from .....order.error_codes import OrderBulkCreateErrorCode from ...bulk_mutations.utils import get_instance USER_KEY_MAP = { "user_id": "id", "user_email": "email", } def test_get_instance(...
84
2,711
onnxruntime
onnxruntime/python/tools/profile_explorer/profile_explorer.py
.py
#!/usr/bin/python import argparse import fnmatch import json import subprocess as sp from collections import defaultdict import pandas as pd def _demangle(name, demangler="c++filt"): try: with sp.Popen([demangler, name], stdin=sp.PIPE, stdout=sp.PIPE) as proc: out, _ = proc.communicate() ...
330
11,595
hatch
tests/cli/config/test_explore.py
.py
def test_call(hatch, config_file, mocker): mock = mocker.patch("click.launch") result = hatch("config", "explore") assert result.exit_code == 0, result.output mock.assert_called_once_with(str(config_file.path), locate=True)
7
241
onnx
onnx/backend/test/case/test_case.py
.py
# Copyright (c) ONNX Project Contributors # SPDX-License-Identifier: Apache-2.0 from __future__ import annotations from dataclasses import dataclass from typing import TYPE_CHECKING if TYPE_CHECKING: from collections.abc import Sequence import numpy as np import onnx @dataclass class TestCase: na...
30
625
clearml
clearml/automation/__init__.py
.py
from .job import ClearmlJob from .controller import PipelineController, PipelineDecorator from .optimization import GridSearch, RandomSearch, HyperParameterOptimizer, Objective from .parameters import ( UniformParameterRange, DiscreteParameterRange, UniformIntegerParameterRange, ParameterSet, LogUni...
30
779
hatch
scripts/release_github.py
.py
import argparse import subprocess import sys import webbrowser from urllib.parse import urlencode from utils import get_latest_release def main(): parser = argparse.ArgumentParser() parser.add_argument("project", choices=["hatch", "hatchling"]) args = parser.parse_args() version, notes = get_latest_...
41
1,076
metrics
tests/unittests/image/test_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...
87
3,325
pyomo
pyomo/contrib/mpc/data/__init__.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...
22
960
cvxpy
cvxpy/reductions/solvers/conic_solvers/xpress_conif.py
.py
""" Copyright 2013 Steven Diamond, 2017 Robin Verschueren 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...
570
21,983
python-prompt-toolkit
src/prompt_toolkit/input/defaults.py
.py
from __future__ import annotations import io import sys from contextlib import AbstractContextManager from typing import TextIO from .base import DummyInput, Input, PipeInput __all__ = [ "create_input", "create_pipe_input", ] def create_input(stdin: TextIO | None = None, always_prefer_tty: bool = False) ->...
81
2,538
onnx
onnx/backend/test/case/node/sequenceinsert.py
.py
# Copyright (c) ONNX Project Contributors # # SPDX-License-Identifier: Apache-2.0 from __future__ import annotations from typing import Any import numpy as np import onnx from onnx.backend.test.case.base import Base from onnx.backend.test.case.node import expect def sequence_insert_reference_implementation( se...
76
2,589
kombu
t/unit/test_compression.py
.py
from __future__ import annotations import sys import pytest from kombu import compression class test_compression: def test_encoders__gzip(self): assert 'application/x-gzip' in compression.encoders() def test_encoders__bz2(self): pytest.importorskip('bz2') assert 'application/x-bz2...
94
2,978
django-cms
cms/tests/test_toolbar.py
.py
import datetime import re from types import SimpleNamespace from unittest.mock import patch import iptools from django.conf import settings from django.contrib import admin from django.contrib.admin import site from django.contrib.auth.models import AnonymousUser, Permission from django.contrib.contenttypes.models imp...
2,975
132,389
biopython
Tests/test_KEGG_online.py
.py
# Copyright 2014 by Kevin Wu. # Copyright 2014 by Peter Cock. # All rights reserved. # 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 online functionality of the KEGG module.""" # Builti...
278
10,641
saleor
saleor/core/telemetry/tests/test_trace.py
.py
from unittest.mock import MagicMock, patch from opentelemetry.trace import INVALID_SPAN, Span, SpanKind from .. import saleor_attributes, tracer from ..trace import Tracer, TracerProxy from ..utils import Scope @patch("saleor.core.telemetry.trace.get_tracer") def test_tracer_initialization(mock_get_tracer): # g...
272
7,717
saleor
saleor/payment/gateways/stripe/plugin.py
.py
import logging from typing import TYPE_CHECKING from django.core.exceptions import ValidationError from django.http import HttpResponse, HttpResponseNotFound from django.http.request import split_domain_port from ....core.utils import get_domain from ....graphql.core import SaleorContext from ....graphql.core.enums i...
608
23,510
astropy
astropy/visualization/tests/test_stretch.py
.py
# Licensed under a 3-clause BSD style license - see LICENSE.rst import numpy as np import pytest from numpy.testing import assert_allclose, assert_equal from astropy.visualization.stretch import ( AsinhStretch, ContrastBiasStretch, HistEqStretch, InvertedHistEqStretch, InvertedLogStretch, Inve...
170
5,722
probability
tensorflow_probability/python/stats/sample_stats_test.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...
724
28,148
beam
sdks/python/apache_beam/examples/snippets/transforms/elementwise/regex_find_all.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");...
62
1,972
openvino
src/frontends/paddle/tests/test_models/gen_scripts/generate_pool2d.py
.py
# Copyright (C) 2018-2026 Intel Corporation # SPDX-License-Identifier: Apache-2.0 # # pool2d paddle model generator # import numpy as np import sys from save_model import saveModel data_type = "float32" def pool2d(name: str, x, attrs: dict): import paddle paddle.enable_static() with paddle.static.prog...
304
10,103
black
tests/data/cases/empty_lines.py
.py
"""Docstring.""" # leading comment def f(): NO = '' SPACE = ' ' DOUBLESPACE = ' ' t = leaf.type p = leaf.parent # trailing comment v = leaf.value if t in ALWAYS_NO_SPACE: pass if t == token.COMMENT: # another trailing comment return DOUBLESPACE assert p is no...
188
4,597
coveragepy
ci/session.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 """Help make a requests Session with proper authentication.""" import os import sys import requests _SESSIONS = {} def get_session(env="GITHUB_TOKEN"): "...
34
927
cvxpy
cvxpy/atoms/affine/vec.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...
45
1,409
probability
tensorflow_probability/python/experimental/mcmc/snaper_hmc_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...
875
30,350