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 |
|---|---|---|---|---|---|
conda | tests/shell/test_posix.py | .py | # Copyright (C) 2012 Anaconda, Inc
# SPDX-License-Identifier: BSD-3-Clause
from __future__ import annotations
import sys
from functools import cache
from logging import getLogger
from pathlib import Path
from typing import TYPE_CHECKING
import pytest
from conda import CONDA_PACKAGE_ROOT
from conda import __version__... | 362 | 13,133 |
coveragepy | tests/modules/process_test/try_execfile.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
"""Test file for run_python_file.
This file is executed two ways::
$ coverage run try_execfile.py
and::
$ python try_execfile.py
The output is compar... | 128 | 3,543 |
coveragepy | tests/test_version.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 of version.py."""
from __future__ import annotations
import coverage
from coverage.version import _make_version
from tests.coveragetest import Coverag... | 34 | 1,280 |
mlflow | dev/clint/src/clint/rules/mlflow_class_name.py | .py | from clint.rules.base import Rule
class MlflowClassName(Rule):
def _message(self) -> str:
return "Should use `Mlflow` in class name, not `MLflow` or `MLFlow`."
| 7 | 174 |
ipython | tools/retar.py | .py | """
Un-targz and retargz a targz file to ensure reproducible build.
usage:
$ export SOURCE_DATE_EPOCH=$(date +%s)
# or
$ export SOURCE_DATE_EPOCH=$(git show -s --format=%ct HEAD)
...
$ python retar.py <tarfile.gz>
The process of creating an sdist can be non-reproducible:
- directory created dur... | 88 | 2,060 |
black | tests/data/cases/skip_magic_trailing_comma_generic_wrap.py | .py | # flags: --minimum-version=3.12 --skip-magic-trailing-comma
def plain[T, B](a: T, b: T) -> T:
return a
def arg_magic[T, B](a: T, b: T,) -> T:
return a
def type_param_magic[T, B,](a: T, b: T) -> T:
return a
def both_magic[T, B,](a: T, b: T,) -> T:
return a
def plain_multiline[
T,
B
](
a:... | 164 | 2,150 |
astropy | astropy/visualization/wcsaxes/coordinates_map.py | .py | # Licensed under a 3-clause BSD style license - see LICENSE.rst
from collections import OrderedDict
from textwrap import indent
from .coordinate_helpers import CoordinateHelper
from .coordinate_range import find_coordinate_range
from .frame import RectangularFrame, RectangularFrame1D
class CoordinatesMap:
"""
... | 200 | 7,643 |
biopython | Tests/test_Align_Alignment.py | .py | # 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 the Alignment class in Bio.Align."""
import os
import unittest
from io import StringIO
try:
import numpy as np
except ImportError:
... | 3,673 | 149,690 |
textual | tests/test_selection.py | .py | import pytest
from textual.app import App, ComposeResult
from textual.containers import VerticalScroll
from textual.geometry import Offset
from textual.selection import Selection
from textual.widgets import Static
@pytest.mark.parametrize(
"text,selection,expected",
[
("Hello", Selection(None, None),... | 228 | 8,203 |
astropy | astropy/coordinates/transformations/base.py | .py | # Licensed under a 3-clause BSD style license - see LICENSE.rst
"""Coordinate transformations base class.
This module contains the abstract base class for coordinate transformations. For
concrete implementations, see the submodules
:mod:`~astropy.coordinates.transformations.affine`,
:mod:`~astropy.coordinates.transfo... | 110 | 4,056 |
openvino | src/bindings/python/src/openvino/experimental/__init__.py | .py | # Copyright (C) 2018-2026 Intel Corporation
# SPDX-License-Identifier: Apache-2.0
"""
Package: openvino
This module provides access to experimental functionality that is subject to change without prior notice.
"""
# flake8: noqa
from openvino._pyopenvino.experimental import evaluate_as_partial_shape
from openvino._p... | 15 | 496 |
pyomo | examples/pyomobook/blocks-ch/blocks_lotsizing.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... | 72 | 2,168 |
ipython | tests/test_tips.py | .py | from IPython.core.tips import _tips
import importlib
import importlib.util
import os
import sys
import types
from datetime import datetime
import pytest
import IPython.core.tips as tips_mod
all_tips = _tips["random"] + list(_tips["every_year"].values())
@pytest.mark.skipif(os.name != "nt", reason="Windows console... | 99 | 3,373 |
metrics | tests/unittests/bases/test_ddp.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... | 345 | 11,886 |
black | tests/data/cases/tupleassign.py | .py | # This is a standalone comment.
sdfjklsdfsjldkflkjsf, sdfjsdfjlksdljkfsdlkf, sdfsdjfklsdfjlksdljkf, sdsfsdfjskdflsfsdf = 1, 2, 3
# This is as well.
this_will_be_wrapped_in_parens, = struct.unpack(b"12345678901234567890")
(a,) = call()
# output
# This is a standalone comment.
(
sdfjklsdfsjldkflkjsf,
sdfjsdf... | 23 | 510 |
openvino | src/frontends/paddle/tests/test_models/gen_scripts/generate_log.py | .py | # Copyright (C) 2018-2026 Intel Corporation
# SPDX-License-Identifier: Apache-2.0
#
# log paddle model generator
#
import numpy as np
from save_model import saveModel
import paddle
import sys
def log(name: str, x, data_type='float32'):
paddle.enable_static()
with paddle.static.program_guard(paddle.static.Pr... | 46 | 1,214 |
onnx | onnx/reference/ops/op_sequence_insert.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
from onnx.reference.op_run import OpRun
def sequence_insert_reference_implementation(
sequence: list[Any] | np.ndarray,
tensor: np.ndarray,
posit... | 53 | 1,796 |
pyomo | pyomo/repn/linear.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... | 895 | 30,418 |
mlflow | examples/multistep_workflow/etl_data.py | .py | """
Converts the raw CSV form to a Parquet form with just the columns we want
"""
import os
import tempfile
import click
import pyspark
import mlflow
@click.command(
help="Given a CSV file (see load_raw_data), transforms it into Parquet "
"in an mlflow artifact called 'ratings-parquet-dir'"
)
@click.option... | 45 | 1,412 |
saleor | saleor/graphql/discount/tests/deprecated/test_discount.py | .py | import warnings
from .....channel.utils import DEPRECATION_WARNING_MESSAGE
from .....discount.models import Promotion, Voucher, VoucherCode
from ....tests.utils import get_graphql_content
QUERY_SALES_WITH_SORTING_AND_FILTERING = """
query($sortBy: SaleSortingInput){
sales (first: 10, sortBy: $sortBy) {
... | 152 | 4,403 |
pdm | src/pdm/utils.py | .py | """
Utility functions
"""
from __future__ import annotations
import atexit
import contextlib
import errno
import functools
import importlib.metadata
import inspect
import json
import os
import re
import shutil
import subprocess
import sys
import sysconfig
import tempfile
import warnings
from collections.abc import Ma... | 622 | 20,302 |
probability | tensorflow_probability/python/vi/mutual_information_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... | 218 | 9,372 |
cvxpy | cvxpy/reductions/solvers/qp_solvers/cplex_qpif.py | .py | import numpy as np
import cvxpy.interface as intf
import cvxpy.settings as s
from cvxpy.reductions.solution import Solution, failure_solution
from cvxpy.reductions.solvers import utilities
from cvxpy.reductions.solvers.conic_solvers.cplex_conif import (
get_status,
hide_solver_output,
set_parameters,
)
fro... | 210 | 7,044 |
wagtail | wagtail/tests/permission_policies/test_page_permission_policies.py | .py | from django.contrib.auth.models import AnonymousUser, Group, Permission
from django.test import TestCase
from wagtail.models import GroupPagePermission, get_default_page_content_type
from wagtail.permission_policies.pages import PagePermissionPolicy
from wagtail.test.utils import Page, WagtailTestUtils
from wagtail.te... | 524 | 18,019 |
beam | sdks/python/apache_beam/runners/interactive/options/capture_limiters.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... | 148 | 5,078 |
qutip | qutip/tests/solver/test_options.py | .py | import pytest
import qutip
import numpy as np
from qutip.solver.options import _SolverOptions
default = {
"opt1": False,
"opt2": True,
"opt3": None,
}
def test_default():
opt = _SolverOptions(default)
assert opt
assert default.keys() == opt.keys()
assert opt["opt1"] is False
assert o... | 145 | 4,030 |
hydra | hydra/core/global_hydra.py | .py | # Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved
from typing import Any, Optional
from hydra._internal.hydra import Hydra
from hydra.core.config_loader import ConfigLoader
from hydra.core.singleton import Singleton
class GlobalHydra(metaclass=Singleton):
def __init__(self) -> None:
... | 39 | 1,324 |
astropy | astropy/nddata/tests/test_utils.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_array_equal
from packaging.version import Version
from astropy import units as u
from astropy.coordinates import SkyCoord
from astropy.io import fits
from astropy.nddata i... | 810 | 26,962 |
lemur | lemur/plugins/lemur_jks/tests/test_jks.py | .py | import pytest
from jks import KeyStore, TrustedCertEntry, PrivateKeyEntry
from lemur.tests.vectors import (
INTERNAL_CERTIFICATE_A_STR,
SAN_CERT_STR,
INTERMEDIATE_CERT_STR,
ROOTCA_CERT_STR,
SAN_CERT_KEY,
)
def test_export_truststore(app):
from lemur.plugins.base import plugins
p = plugin... | 106 | 3,175 |
metrics | src/torchmetrics/text/perplexity.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... | 132 | 5,019 |
pyomo | pyomo/contrib/mindtpy/tests/test_mindtpy_global.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... | 102 | 3,793 |
mlflow | tests/sklearn/test_sklearn_autolog_without_matplotlib.py | .py | from unittest import mock
import pytest
from sklearn.datasets import load_breast_cancer
from sklearn.ensemble import RandomForestClassifier
import mlflow
from mlflow import MlflowClient
from tests.helper_functions import AnyStringWith
def is_matplotlib_installed():
try:
import matplotlib # noqa: F401
... | 46 | 1,293 |
beam | sdks/python/apache_beam/ml/anomaly/univariate/quantile.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... | 215 | 7,332 |
qutip | qutip/solver/integrator/tsit5.py | .py | """
Tsitouras's 5/4 order Runge-Kutta method
Runge–Kutta pairs of order 5(4) satisfying only the first column
simplifying assumption,
Ch. Tsitouras,
Computers & Mathematics with Applications, Vol 62, Issue 2, 770-775
Jan 2011
"""
__all__ = ["tsit5_coeff"]
import numpy as np
order = 5
rk_step = 7
a = np.zeros((rk_ste... | 104 | 2,241 |
pyfilesystem2 | tests/test_mode.py | .py | from __future__ import unicode_literals
import unittest
from six import text_type
from fs.mode import Mode, check_readable, check_writable
class TestMode(unittest.TestCase):
def test_checks(self):
self.assertTrue(check_readable("r"))
self.assertTrue(check_readable("r+"))
self.assertTrue(... | 50 | 1,588 |
beam | sdks/python/apache_beam/ml/inference/tensorflow_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... | 449 | 17,537 |
pyomo | pyomo/contrib/mpc/data/find_nearest_index.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... | 130 | 4,806 |
python-prompt-toolkit | examples/dialogs/yes_no_dialog.py | .py | #!/usr/bin/env python
"""
Example of confirmation (yes/no) dialog window.
"""
from prompt_toolkit.shortcuts import yes_no_dialog
def main():
result = yes_no_dialog(
title="Yes/No dialog example", text="Do you want to confirm?"
).run()
print(f"Result = {result}")
if __name__ == "__main__":
... | 19 | 327 |
textual | src/textual/layouts/horizontal.py | .py | from __future__ import annotations
from fractions import Fraction
from typing import TYPE_CHECKING
from textual._resolve import resolve_box_models
from textual.geometry import NULL_OFFSET, Region, Size
from textual.layout import ArrangeResult, Layout, WidgetPlacement
if TYPE_CHECKING:
from textual.geometry impor... | 121 | 3,867 |
pyomo | pyomo/core/tests/examples/pmedian.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... | 79 | 1,870 |
probability | spinoffs/inference_gym/setup.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... | 65 | 2,660 |
saleor | saleor/graphql/checkout/tests/deprecated/test_checkout_email_update.py | .py | import graphene
from .....checkout.error_codes import CheckoutErrorCode
from ....tests.utils import get_graphql_content
CHECKOUT_EMAIL_UPDATE_MUTATION = """
mutation checkoutEmailUpdate($checkoutId: ID, $token: UUID, $email: String!) {
checkoutEmailUpdate(checkoutId: $checkoutId, token: $token, email: $em... | 96 | 3,101 |
beam | sdks/python/apache_beam/runners/interactive/options/interactive_options.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... | 48 | 1,696 |
openvino | tests/layer_tests/pytorch_tests/test_pad.py | .py | # Copyright (C) 2018-2026 Intel Corporation
# SPDX-License-Identifier: Apache-2.0
import pytest
from pytorch_layer_test_class import PytorchLayerTest
class TestPad(PytorchLayerTest):
def _prepare_input(self, ndim=4, dtype="float32"):
import numpy as np
input_5d_shape = [1, 3, 14, 14, 18]
... | 244 | 10,548 |
beam | sdks/python/apache_beam/ml/inference/__init__.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... | 29 | 1,296 |
onnxruntime | onnxruntime/test/testdata/ort_github_issue_17000.py | .py | import numpy as np
import onnx
from onnx import TensorProto, helper, numpy_helper
def order_repeated_field(repeated_proto, key_name, order):
order = list(order)
repeated_proto.sort(key=lambda x: order.index(getattr(x, key_name)))
def make_node(op_type, inputs, outputs, name=None, doc_string=None, domain=Non... | 78 | 3,053 |
beam | sdks/python/apache_beam/testing/synthetic_pipeline_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... | 260 | 9,433 |
kafka | tests/kafkatest/services/trogdor/round_trip_workload.py | .py | # Licensed to the Apache Software Foundation (ASF) under one or more
# contributor license agreements. See the NOTICE file distributed with
# this work for additional information regarding copyright ownership.
# The ASF licenses this file to You under the Apache License, Version 2.0
# (the "License"); you may not use ... | 50 | 1,996 |
saleor | saleor/graphql/order/tests/mutations/test_order_lines_create.py | .py | import datetime
from datetime import timedelta
from decimal import Decimal
from unittest.mock import ANY, patch
import graphene
import pytest
from django.db.models import Sum
from django.test import override_settings
from django.utils import timezone
from freezegun import freeze_time
from .....core.models import Even... | 2,249 | 84,296 |
attrs | typing_tests/pyrefly.py | .py | # SPDX-License-Identifier: MIT
"""
Typing examples that rely on Pyrefly's advanced attrs integration.
"""
from __future__ import annotations
import copy
import re
import sys
from typing import Any
import attrs
@attrs.define
class C:
a: int = attrs.field()
cc = C(1)
C(a=1)
if sys.version_info >= (3, 13):
... | 400 | 8,247 |
pyomo | pyomo/core/tests/unit/test_con.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... | 2,112 | 64,318 |
confluent-kafka-python | tests/schema_registry/_async/test_proto_serdes.py | .py | #!/usr/bin/env python
# -*- coding: utf-8 -*-
#
# Copyright 2024 Confluent Inc.
#
# 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 requi... | 959 | 36,459 |
beam | sdks/python/apache_beam/examples/cookbook/bigquery_side_input.py | .py | #
# Licensed to the Apache Software Foundation (ASF) under one or more
# contributor license agreements. See the NOTICE file distributed with
# this work for additional information regarding copyright ownership.
# The ASF licenses this file to You under the Apache License, Version 2.0
# (the "License"); you may not us... | 121 | 4,340 |
kafka | committer-tools/refresh_collaborators.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 u... | 151 | 5,271 |
beam | sdks/python/apache_beam/yaml/yaml_io.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,041 | 39,667 |
mamba | libmamba/data/bin2header.py | .py | # Modified from bin2array, https://github.com/Jamesits/bin2array
# Distributed under MIT License:
# MIT License
# Copyright (c) 2017 James Swineson <github@public.swineson.me>
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "So... | 64 | 2,667 |
gunicorn | tests/requests/invalid/002.py | .py | #
# This file is part of gunicorn released under the MIT license.
# See the NOTICE for more information.
from gunicorn.http.errors import InvalidRequestLine
request = InvalidRequestLine
| 7 | 187 |
pyomo | examples/pyomo/radertext/Ex2_2.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... | 52 | 1,563 |
pyro | pyro/distributions/transforms/cholesky.py | .py | # Copyright (c) 2017-2019 Uber Technologies, Inc.
# SPDX-License-Identifier: Apache-2.0
import math
import warnings
import torch
from torch.distributions.transforms import CorrCholeskyTransform, Transform
from .. import constraints
class CorrLCholeskyTransform(CorrCholeskyTransform): # DEPRECATED
def __init__... | 69 | 2,117 |
openvino | docs/openvino_sphinx_theme/openvino_sphinx_theme/directives/code.py | .py | # Copyright (C) 2018-2026 Intel Corporation
# SPDX-License-Identifier: Apache-2.0
import os.path
from sphinx.directives.code import LiteralInclude, LiteralIncludeReader, container_wrapper
from sphinx.util import logging
from docutils.parsers.rst import Directive, directives
from docutils.nodes import Node
from docutil... | 189 | 8,736 |
hatch | src/hatch/cli/lock_cmd.py | .py | """Top-level ``hatch lock`` — forwards to the same workflow as ``hatch dep lock``."""
from __future__ import annotations
from typing import TYPE_CHECKING
import click
from hatch.cli.env.lock import dependency_lock_click_options, run_dep_lock
if TYPE_CHECKING:
from hatch.cli.application import Application
@cl... | 40 | 1,030 |
pyro | tests/infer/test_elbo_mapdata.py | .py | # Copyright (c) 2017-2019 Uber Technologies, Inc.
# SPDX-License-Identifier: Apache-2.0
import logging
import pytest
import torch
import pyro
import pyro.distributions as dist
import pyro.optim as optim
from pyro.infer import SVI, TraceGraph_ELBO
from tests.common import assert_equal
logger = logging.getLogger(__na... | 130 | 4,196 |
deap | doc/code/tutorials/part_2/2_2_6_funky_one.py | .py | ## 2.2.6 Funky one
import random
from deap import base
from deap import creator
from deap import tools
creator.create("FitnessMax", base.Fitness, weights=(1.0, 1.0))
creator.create("Individual", list, fitness=creator.FitnessMax)
toolbox = base.Toolbox()
INT_MIN, INT_MAX = 5, 10
FLT_MIN, FLT_MAX = -0.2, 0.8
N_CYCLES... | 21 | 587 |
openvino | docs/scripts/articles_helper.py | .py | # Copyright (C) 2018-2026 Intel Corporation
# SPDX-License-Identifier: Apache-2.0
import argparse
import logging
import os
import shutil
from pathlib import Path
def copy_directory_structure(input_dir, output_dir):
"""
Recursively find files and process them accordingly
"""
try:
shutil.copyt... | 46 | 1,506 |
beam | sdks/python/apache_beam/runners/dataflow/internal/names.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... | 41 | 1,633 |
conda | conda/common/path/windows.py | .py | # Copyright (C) 2012 Anaconda, Inc
# SPDX-License-Identifier: BSD-3-Clause
"""Common Windows path utilities."""
from __future__ import annotations
import ntpath
import os
import posixpath
import re
import subprocess
from logging import getLogger
from pathlib import Path
from shutil import which
from typing import TYP... | 170 | 5,444 |
saleor | saleor/graphql/tests/test_middleware.py | .py | import pytest
from django.test import override_settings
@override_settings(GRAPHQL_MIDDLEWARE=["saleor.graphql.middleware.NonExisting"])
def test_middleware_invalid_name(api_client):
with pytest.raises(ImportError):
api_client.post_graphql("")
| 9 | 258 |
onnxruntime | onnxruntime/core/flatbuffers/ort_flatbuffers_py/fbs/MapType.py | .py | # automatically generated by the FlatBuffers compiler, do not modify
# namespace: fbs
import flatbuffers
from flatbuffers.compat import import_numpy
np = import_numpy()
class MapType(object):
__slots__ = ['_tab']
@classmethod
def GetRootAs(cls, buf, offset=0):
n = flatbuffers.encode.Get(flatbuff... | 72 | 2,123 |
onnxruntime | onnxruntime/test/testdata/transform/fusion/fast_gelu3_with_casts.py | .py | import numpy as np
import onnx
from onnx import OperatorSetIdProto, TensorProto, helper, numpy_helper
# Gelu formula: x * 0.5 * (1.0 + tanh((sqrt(2 / pi) * (x + 0.044715 * pow(x, 3)))))
X = helper.make_tensor_value_info("input", TensorProto.FLOAT, ["batch", "seqlen", 64])
Y = helper.make_tensor_value_info("output", T... | 98 | 3,424 |
clearml | clearml/backend_interface/session.py | .py | from abc import ABC, abstractmethod
from typing import Any
class SendError(Exception):
"""A session send() error class"""
@property
def result(self) -> Any:
return self._result
def __init__(self, result: Any, *args: Any, **kwargs: Any) -> None:
super(SendError, self).__init__(*args, ... | 34 | 769 |
probability | tensorflow_probability/python/math/psd_kernels/psd_kernel_properties_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... | 254 | 9,526 |
mlflow | mlflow/store/db_migrations/versions/c1d2e3f4a5b6_add_span_experiment_start_time_index.py | .py | """add span experiment and start time index
Revision ID: c1d2e3f4a5b6
Revises: a8b9c0d1e2f3
Create Date: 2026-07-10 00:00:00.000000
"""
from alembic import op
# revision identifiers, used by Alembic.
revision = "c1d2e3f4a5b6"
down_revision = "a8b9c0d1e2f3"
branch_labels = None
depends_on = None
# The composite in... | 54 | 1,690 |
beam | sdks/python/apache_beam/io/gcp/gcsfilesystem.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... | 381 | 12,186 |
pyomo | pyomo/solvers/tests/checks/test_MOSEKDirect.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... | 374 | 13,785 |
metrics | src/torchmetrics/retrieval/__init__.py | .py | # Copyright The Lightning team.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writin... | 38 | 1,566 |
probability | tensorflow_probability/python/optimizer/sgld.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... | 295 | 12,327 |
beam | sdks/python/apache_beam/runners/direct/executor.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... | 720 | 25,909 |
mlflow | tests/tracing/test_span_links_api.py | .py | import mlflow
from mlflow.entities import Link
from mlflow.entities.span import NoOpSpan
from mlflow.tracing.fluent import start_span_no_context
from tests.tracing.helper import get_traces
# --- Integration tests for start_span with links ---
def test_start_span_with_links():
links = [
Link(trace_id="tr... | 131 | 3,791 |
metrics | src/torchmetrics/functional/text/sacre_bleu.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... | 556 | 20,151 |
confluent-kafka-python | src/confluent_kafka/aio/producer/_kafka_batch_executor.py | .py | # Copyright 2025 Confluent Inc.
#
# 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, s... | 142 | 6,355 |
onnx | tests/python/data_propagation_test.py | .py | # Copyright (c) ONNX Project Contributors
# SPDX-License-Identifier: Apache-2.0
from __future__ import annotations
import pytest
from shape_inference_test import TestShapeInferenceHelper
import onnx.parser
from onnx import TensorProto
from onnx.helper import make_node, make_tensor, make_tensor_value_info
class Te... | 335 | 12,236 |
saleor | saleor/page/tests/fixtures/page_translation.py | .py | import pytest
from ....tests.utils import dummy_editorjs
from ...models import PageTranslation
@pytest.fixture
def page_translation_fr(page):
return PageTranslation.objects.create(
language_code="fr",
page=page,
title="French page title",
content=dummy_editorjs("French page conten... | 15 | 332 |
saleor | saleor/checkout/actions.py | .py | from decimal import Decimal
from typing import TYPE_CHECKING, Optional
from ..core.taxes import zero_money
from ..core.utils.events import (
call_event,
)
from ..payment.models import TransactionItem
from ..webhook.event_types import WebhookEventAsyncType
from ..webhook.utils import get_webhooks_for_multiple_event... | 225 | 7,763 |
openvino | src/frontends/paddle/tests/test_models/gen_scripts/nms.py | .py | # Copyright (C) 2018-2026 Intel Corporation
# SPDX-License-Identifier: Apache-2.0
#
# helper for multiclass/matrix_nms paddle model generator
#
import os
import numpy as np
import copy # deepcopy
import sys
import paddle
from save_model import saveModel, exportModel, print_alike
if paddle.__version__ >= '2.6.0':
... | 139 | 6,732 |
onnx | onnx/backend/test/case/node/causal_conv_with_state.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
from onnx.reference.ops.op_causal_conv_with_state import (
CausalConvWithS... | 336 | 11,846 |
saleor | saleor/graphql/core/tests/garbage_collection/test_oauth2.py | .py | import gc
import pytest
from authlib.integrations.requests_client import OAuth2Session
from .utils import (
clean_up_after_garbage_collection_test,
disable_gc_for_garbage_collection_test,
)
# Group all tests that require garbage collection so that they do not run concurrently.
# This is necessary to ensure ... | 37 | 1,379 |
sphinx | tests/roots/test-maxlistdepth/conf.py | .py | exclude_patterns = ['_build']
latex_elements = {
'maxlistdepth': '10',
}
| 6 | 78 |
cvxpy | cvxpy/tests/test_monotonicity.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... | 89 | 2,948 |
marshmallow | tests/base.py | .py | """Test utilities and fixtures."""
import datetime as dt
import functools
import typing
import uuid
from enum import Enum, IntEnum
from zoneinfo import ZoneInfo
import simplejson
from marshmallow import Schema, fields, missing, post_load, validate
from marshmallow.exceptions import ValidationError
central = ZoneInf... | 291 | 7,343 |
biopython | Bio/motifs/pfm.py | .py | # Copyright 2015 by Gert Hulselmans. 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.
"""Parse various positio... | 424 | 17,229 |
onnxruntime | onnxruntime/python/tools/transformers/models/whisper/whisper_inputs.py | .py | # -------------------------------------------------------------------------
# Copyright (c) Microsoft Corporation. All rights reserved.
# Licensed under the MIT License. See License.txt in the project root for
# license information.
# --------------------------------------------------------------------------
import ... | 381 | 15,661 |
beam | sdks/python/apache_beam/runners/interactive/pipeline_instrument.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... | 792 | 31,710 |
pyro | pyro/distributions/transforms/spline.py | .py | # Copyright Contributors to the Pyro project.
# Copyright (c) 2020 Hadi M. Dolatabadi, Sarah Erfani, Christopher Leckie
# Copyright (c) 2019 Conor Durkan, Artur Bekasov, Iain Murray, George Papamakarios
# Copyright (c) 2019 Tony Duan
# SPDX-License-Identifier: MIT
# This implementation is adapted in part from:
# * htt... | 646 | 24,458 |
textual | src/textual/widgets/_content_switcher.py | .py | """Provides a widget for switching between the display of its immediate children."""
from __future__ import annotations
from typing import Optional
from textual.await_complete import AwaitComplete
from textual.containers import Container
from textual.css.query import NoMatches
from textual.events import Mount
from t... | 133 | 4,326 |
pyomo | examples/doc/samples/case_studies/rosen/Rosenbrock.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 | 890 |
onnxruntime | onnxruntime/test/testdata/dummy_t5_model_generator.py | .py | """Script to generate a dummy ONNX model emulating T5 model with BeamSearch op."""
import argparse
import numpy as np
import onnx
import onnxruntime as ort
from onnxruntime.transformers.convert_generation import move_initializers
def create_model(
vocab_size: int,
embed_dim: int,
num_heads: int,
he... | 378 | 16,008 |
mlflow | tests/store/db/test_utils.py | .py | from pathlib import Path
from unittest import mock
import pytest
from sqlalchemy.pool import NullPool
from sqlalchemy.pool.impl import QueuePool
from mlflow.exceptions import MlflowException
from mlflow.store.db import utils
def test_create_sqlalchemy_engine_inject_pool_options(monkeypatch):
monkeypatch.setenv(... | 193 | 7,671 |
mlflow | tests/openai/test_openai_model_export.py | .py | import importlib
import json
from unittest import mock
import numpy as np
import openai
import pandas as pd
import pytest
import yaml
from pyspark.sql import SparkSession
import mlflow
import mlflow.pyfunc.scoring_server as pyfunc_scoring_server
from mlflow.models.signature import ModelSignature
from mlflow.models.ut... | 707 | 21,151 |
pyro | pyro/contrib/gp/models/vgp.py | .py | # Copyright (c) 2017-2019 Uber Technologies, Inc.
# SPDX-License-Identifier: Apache-2.0
import torch
from torch.distributions import constraints
from torch.nn import Parameter
import pyro
import pyro.distributions as dist
from pyro.contrib.gp.models.model import GPModel
from pyro.contrib.gp.util import conditional
fr... | 181 | 6,859 |
onnx | onnx/reference/ops/op_eyelike.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.onnx_pb import TensorProto
from onnx.reference.op_run import OpRun
class EyeLike(OpRun):
def _run(self, data, *args, d... | 32 | 991 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.