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 |
|---|---|---|---|---|---|
mlflow | mlflow/store/artifact/azure_data_lake_artifact_repo.py | .py | import os
import posixpath
import re
import urllib.parse
import requests
from mlflow.azure.client import patch_adls_file_upload, patch_adls_flush, put_adls_file_creation
from mlflow.entities import FileInfo
from mlflow.environment_variables import (
MLFLOW_ARTIFACT_UPLOAD_DOWNLOAD_TIMEOUT,
MLFLOW_ENABLE_MULTI... | 300 | 12,543 |
pyomo | pyomo/common/tests/mod.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... | 16 | 643 |
openvino | docs/articles_en/assets/snippets/gpu/compile_model_gpu.py | .py | # Copyright (C) 2018-2026 Intel Corporation
# SPDX-License-Identifier: Apache-2.0
import openvino as ov
from snippets import get_model
def main():
model = get_model()
core = ov.Core()
if "GPU" not in core.available_devices:
return 0
#! [compile_model_default_gpu]
core = ov.Core()
c... | 58 | 1,542 |
django-cms | cms/tests/test_placeholder.py | .py | import warnings
from unittest.mock import patch
from django.conf import settings
from django.contrib.auth import get_user_model
from django.contrib.sites.models import Site
from django.core.exceptions import ImproperlyConfigured
from django.template import Template, TemplateSyntaxError, engines
from django.template.lo... | 1,780 | 79,005 |
gunicorn | tests/workers/test_ggevent.py | .py | #
# This file is part of gunicorn released under the MIT license.
# See the NOTICE for more information.
from unittest import mock
import pytest
try:
import gevent
HAS_GEVENT = True
except ImportError:
HAS_GEVENT = False
pytestmark = pytest.mark.skipif(not HAS_GEVENT, reason="gevent not installed")
de... | 217 | 8,018 |
readthedocs.org | readthedocs/storage/rclone.py | .py | """
Wrapper around the rclone command.
See https://rclone.org/docs.
"""
import os
import subprocess
import structlog
from django.utils._os import safe_join as safe_join_fs
from readthedocs.storage.utils import safe_join
log = structlog.get_logger(__name__)
class BaseRClone:
"""
RClone base class.
T... | 203 | 6,129 |
pyfilesystem2 | tests/test_multifs.py | .py | from __future__ import unicode_literals
import unittest
from fs import errors
from fs.memoryfs import MemoryFS
from fs.multifs import MultiFS
from fs.test import FSTestCases
class TestMultiFS(FSTestCases, unittest.TestCase):
"""Test OSFS implementation."""
def setUp(self):
fs = MultiFS()
me... | 140 | 4,424 |
saleor | saleor/graphql/plugins/sorters.py | .py | import graphene
from ..core.enums import OrderDirection
from ..core.types import SortInputObjectType
from .types import Plugin
def sort_active_key(plugin: Plugin, sort_reverse: bool):
if plugin.global_configuration:
active = plugin.global_configuration.active
name = plugin.name
else:
... | 60 | 1,826 |
sqlmap | lib/parse/configfile.py | .py | #!/usr/bin/env python
"""
Copyright (c) 2006-2026 sqlmap developers (https://sqlmap.org)
See the file 'LICENSE' for copying permission
"""
from lib.core.common import checkFile
from lib.core.common import getSafeExString
from lib.core.common import openFile
from lib.core.common import unArrayizeValue
from lib.core.co... | 101 | 3,660 |
saleor | saleor/graphql/product/tests/mutations/test_category_create.py | .py | import json
import os
from unittest.mock import patch
import graphene
import pytest
from django.utils.functional import SimpleLazyObject
from django.utils.text import slugify
from freezegun import freeze_time
from .....core.utils.json_serializer import CustomJsonEncoder
from .....product.error_codes import ProductErr... | 289 | 9,784 |
pyro | tests/poutine/conftest.py | .py | # Copyright (c) 2017-2019 Uber Technologies, Inc.
# SPDX-License-Identifier: Apache-2.0
import pytest
def pytest_collection_modifyitems(items):
for item in items:
if item.nodeid.startswith("tests/poutine"):
if "stage" not in item.keywords:
item.add_marker(pytest.mark.stage("un... | 14 | 434 |
wagtail | wagtail/admin/views/reports/locked_pages.py | .py | import datetime
import django_filters
import swapper
from django.conf import settings
from django.contrib.auth import get_user_model
from django.utils.translation import gettext_lazy as _
from wagtail.admin.filters import DateRangePickerWidget, WagtailFilterSet
from .base import PageReportView
Page = swapper.load_m... | 77 | 2,223 |
astropy | astropy/constants/astropyconst40.py | .py | # Licensed under a 3-clause BSD style license - see LICENSE.rst
"""
Astronomical and physics constants for Astropy v4.0.
See :mod:`astropy.constants` for a complete listing of constants defined
in Astropy.
"""
import warnings
from astropy.utils import find_current_module
from . import codata2018, iau2015
from . impo... | 71 | 2,028 |
bazel | examples/py_native/test.py | .py | """A tiny example binary for the native Python rules of Bazel."""
import unittest
from examples.py_native.lib import GetNumber
from fib import Fib
class TestGetNumber(unittest.TestCase):
def test_ok(self):
self.assertEqual(GetNumber(), 42)
def test_fib(self):
self.assertEqual(Fib(5), 8)
if __name__ ==... | 18 | 351 |
textual | docs/examples/styles/visibility_containers.py | .py | from textual.app import App
from textual.containers import Horizontal, VerticalScroll
from textual.widgets import Placeholder
class VisibilityContainersApp(App):
CSS_PATH = "visibility_containers.tcss"
def compose(self):
yield VerticalScroll(
Horizontal(
Placeholder(),
... | 35 | 828 |
kafka | tests/kafkatest/services/kafka/config_property.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 ... | 218 | 11,307 |
conda | conda/base/constants.py | .py | # Copyright (C) 2012 Anaconda, Inc
# SPDX-License-Identifier: BSD-3-Clause
"""
This file should hold most string literals and magic numbers used throughout the code base.
The exception is if a literal is specifically meant to be private to and isolated within a module.
Think of this as a "more static" source of configu... | 456 | 12,901 |
saleor | saleor/graphql/product/mutations/product/product_media_update.py | .py | import graphene
from django.core.exceptions import ValidationError
from .....permission.enums import ProductPermissions
from .....product import models
from .....product.error_codes import ProductErrorCode
from ....core import ResolveInfo
from ....core.context import ChannelContext
from ....core.doc_category import DO... | 66 | 2,518 |
jupyterlab | galata/update_snapshots.py | .py | # Copyright (c) Jupyter Development Team.
# Distributed under the terms of the Modified BSD License.
import argparse
import hashlib
import json
import shutil
from pathlib import Path
parser = argparse.ArgumentParser(description="Update Galata Snapshot images.")
parser.add_argument("report", help="Path to the galata-r... | 43 | 1,492 |
astropy | astropy/utils/shapes.py | .py | # Licensed under a 3-clause BSD style license - see LICENSE.rst
"""The ShapedLikeNDArray mixin class and shape-related functions."""
import abc
import numbers
from collections.abc import Sequence
from itertools import zip_longest
from math import prod
from types import EllipsisType
from typing import Self, TypeVar
im... | 529 | 19,074 |
mlflow | tests/pytest/test_plugin.py | .py | from __future__ import annotations
import os
import subprocess
import sys
from pathlib import Path
from mlflow.pytest import session as _session
from mlflow.tracking import MlflowClient
from mlflow.utils.mlflow_tags import MLFLOW_RUN_TYPE, MLFLOW_RUN_TYPE_TEST
# ------------------------------------------------------... | 244 | 7,345 |
pyomo | examples/pyomobook/abstract-ch/AbstractH.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... | 45 | 1,258 |
beam | sdks/python/apache_beam/testing/benchmarks/nexmark/queries/query10.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... | 150 | 5,496 |
coremltools | deps/protobuf/python/google/protobuf/text_encoding.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... | 111 | 4,728 |
jupytext | tests/functional/others/test_custom_language_magics.py | .py | import nbformat
from nbformat.v4.nbbase import new_code_cell, new_notebook
import jupytext
from jupytext.cli import jupytext as jupytext_cli
from jupytext.compare import compare_notebooks
def test_custom_language_magics_md_to_ipynb():
"""Code blocks in custom language magics should be converted to code cells"""
... | 108 | 2,880 |
hydra | examples/advanced/hydra_app_example/setup.py | .py | #!/usr/bin/env python
# Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved
from setuptools import find_packages, setup
setup(
name="hydra-app",
version="0.1",
packages=find_packages(include=["hydra_app"]),
entry_points={"console_scripts": ["hydra_app = hydra_app.main:main"]},
au... | 18 | 493 |
mamba | micromamba/tests/dump_proxy_connections.py | .py | """
mitmproxy connection dumper plugin
This script shouldn't be run or imported directly. Instead, it should be passed to mitmproxy as a script (-s).
It will then dump all request urls in the file specified by the outfile option.
We use this script instead of letting mitmdump do the dumping, because we only care abou... | 38 | 1,130 |
textual | docs/examples/widgets/progress_bar.py | .py | from textual.app import App, ComposeResult
from textual.containers import Center, VerticalScroll
from textual.widgets import Button, Header, Input, Label, ProgressBar
class FundingProgressApp(App[None]):
CSS_PATH = "progress_bar.tcss"
TITLE = "Funding tracking"
def compose(self) -> ComposeResult:
... | 41 | 1,169 |
saleor | saleor/webhook/tests/subscription_webhooks/test_create_deliveries_for_transaction_process_session.py | .py | import json
from decimal import Decimal
import graphene
from ....channel import TransactionFlowStrategy
from ....payment.interface import (
PaymentGatewayData,
TransactionProcessActionData,
TransactionSessionData,
)
from ...event_types import WebhookEventSyncType
from ...models import Webhook
from ...tran... | 398 | 11,520 |
saleor | saleor/giftcard/error_codes.py | .py | from enum import Enum
class GiftCardErrorCode(Enum):
ALREADY_EXISTS = "already_exists"
GRAPHQL_ERROR = "graphql_error"
INVALID = "invalid"
NOT_FOUND = "not_found"
REQUIRED = "required"
UNIQUE = "unique"
EXPIRED_GIFT_CARD = "expired_gift_card"
DUPLICATED_INPUT_ITEM = "duplicated_input_i... | 14 | 361 |
wandb | wandb/apis/public/teams.py | .py | """W&B Public API for managing teams and team members.
This module provides classes for managing W&B teams and their members.
Note:
This module is part of the W&B Public API and provides methods to manage
teams and their members. Team management operations require appropriate
permissions.
"""
from __futu... | 202 | 6,167 |
astropy | astropy/cosmology/_src/tests/funcs/test_funcs.py | .py | # Licensed under a 3-clause BSD style license - see LICENSE.rst
import inspect
import sys
from contextlib import nullcontext
from io import StringIO
import numpy as np
import pytest
from astropy import units as u
from astropy.cosmology import (
WMAP1,
WMAP3,
WMAP5,
WMAP7,
WMAP9,
CosmologyErro... | 427 | 13,206 |
probability | tensorflow_probability/python/distributions/joint_distribution_util_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... | 118 | 5,296 |
kombu | t/unit/test_messaging.py | .py | from __future__ import annotations
import pickle
import sys
from collections import defaultdict
from unittest.mock import ANY, Mock, patch
import pytest
from kombu import Connection, Consumer, Exchange, Producer, Queue
from kombu.exceptions import MessageStateError, OperationalError
from kombu.utils import json
from... | 733 | 27,133 |
beam | sdks/python/apache_beam/utils/annotations.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... | 195 | 6,465 |
mlflow | tests/tracking/context/test_default_context.py | .py | from unittest import mock
import pytest
from mlflow.entities import SourceType
from mlflow.tracking.context.default_context import DefaultRunContext
from mlflow.utils.mlflow_tags import MLFLOW_SOURCE_NAME, MLFLOW_SOURCE_TYPE, MLFLOW_USER
MOCK_SCRIPT_NAME = "/path/to/script.py"
@pytest.fixture
def patch_script_name... | 43 | 1,413 |
scikit-bio | skbio/io/format/_blast.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.
# --------------------------------------------... | 96 | 2,301 |
jupytext | tests/data/notebooks/outputs/ipynb_to_script/frozen_cell.py | .py | # ---
# jupyter:
# kernelspec:
# display_name: Python 3
# language: python
# name: python3
# ---
# This is an unfrozen cell. Works as usual.
print("I'm a regular cell so I run and print!")
# + deletable=false editable=false run_control={"frozen": true}
# # This is an frozen cell
# print("I'm frozen so I... | 15 | 340 |
onnxruntime | onnxruntime/python/tools/transformers/models/stable_diffusion/demo_utils.py | .py | # -------------------------------------------------------------------------
# Copyright (c) Microsoft Corporation. All rights reserved.
# Licensed under the MIT License.
# --------------------------------------------------------------------------
# Modified from TensorRT demo diffusion, which has the following license... | 779 | 28,598 |
onnx | onnx/backend/test/case/node/upsample.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 import helper
from onnx.backend.test.case.base import Base
from onnx.backend.test.case.node import expect
class Upsample(Base):
@staticmethod
def expo... | 59 | 1,372 |
sphinx | tests/test_util/test_util_typing.py | .py | """Tests util.typing functions."""
from __future__ import annotations
import ctypes
import dataclasses
import sys
import typing as t
import zipfile
from collections import abc
from contextvars import Context, ContextVar, Token
from enum import Enum
from io import (
BufferedRandom,
BufferedReader,
Buffered... | 1,030 | 40,472 |
textual | docs/examples/guide/dom3.py | .py | from textual.app import App, ComposeResult
from textual.containers import Container, Horizontal
from textual.widgets import Button, Footer, Header, Static
QUESTION = "Do you want to learn about Textual CSS?"
class ExampleApp(App):
def compose(self) -> ComposeResult:
yield Header()
yield Footer()
... | 26 | 667 |
beam | sdks/python/apache_beam/examples/matrix_power_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... | 69 | 2,120 |
textual | src/textual/dom.py | .py | """
The module contains `DOMNode`, the base class for any object within the Textual Document Object Model,
which includes all Widgets, Screens, and Apps.
"""
from __future__ import annotations
import re
import threading
from functools import lru_cache, partial
from inspect import getfile
from typing import (
TYP... | 1,945 | 64,878 |
mlflow | dev/clint/src/clint/rules/example_syntax_error.py | .py | from clint.rules.base import Rule
class ExampleSyntaxError(Rule):
def _message(self) -> str:
return "This example has a syntax error."
| 7 | 149 |
beam | sdks/python/apache_beam/transforms/util_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... | 3,144 | 120,863 |
ipython | IPython/extensions/storemagic.py | .py | """
%store magic for lightweight persistence.
Stores variables, aliases and macros in IPython's database.
To automatically restore stored variables at startup, add this to your
:file:`ipython_config.py` file::
c.StoreMagics.autorestore = True
"""
# Copyright (c) IPython Development Team.
# Distributed under the t... | 235 | 8,141 |
black | tests/data/cases/fmtskip2.py | .py | # flags: --no-preview-line-length-1
# l2 loses the comment with line-length=1 in preview mode
l1 = ["This list should be broken up", "into multiple lines", "because it is way too long"]
l2 = ["But this list shouldn't", "even though it also has", "way too many characters in it"] # fmt: skip
l3 = ["I have", "trailing co... | 21 | 708 |
onnxruntime | onnxruntime/python/tools/transformers/fusion_transpose.py | .py | # -------------------------------------------------------------------------
# Copyright (c) Microsoft Corporation. All rights reserved.
# Licensed under the MIT License.
# --------------------------------------------------------------------------
from logging import getLogger
from fusion_base import Fusion
from fusi... | 168 | 6,837 |
onnx | tests/python/inliner_test.py | .py | # Copyright (c) ONNX Project Contributors
# SPDX-License-Identifier: Apache-2.0
from __future__ import annotations
import pytest
from onnx import checker, inliner, parser
class TestInliner:
def test_basic(self):
model = parser.parse_model(
"""
<ir_version: 8, opset_import: [ "" ... | 141 | 4,810 |
metrics | src/torchmetrics/functional/classification/recall_fixed_precision.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... | 441 | 21,870 |
mlflow | examples/ray_serve/train_model.py | .py | from sklearn.datasets import load_iris
from sklearn.ensemble import GradientBoostingClassifier
from sklearn.metrics import mean_squared_error
from sklearn.utils import shuffle
import mlflow
if __name__ == "__main__":
# Enable auto-logging
mlflow.set_tracking_uri("sqlite:///mlruns.db")
mlflow.sklearn.autol... | 42 | 1,252 |
beam | sdks/python/apache_beam/examples/snippets/transforms/aggregation/count_globally.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");... | 54 | 1,638 |
wagtail | wagtail/admin/tests/api/test_pages.py | .py | import collections
import datetime
import json
import swapper
from django.contrib.auth import get_user_model
from django.contrib.auth.models import Group, Permission
from django.test import TestCase
from django.test.utils import override_settings
from django.urls import reverse
from django.utils import timezone
from ... | 2,107 | 76,493 |
mlflow | mlflow/langchain/utils/serialization.py | .py | import inspect
from pydantic import BaseModel
def convert_to_serializable(response):
"""
Convert the response to a JSON serializable format.
LangChain response objects often contains Pydantic objects, which causes an serialization
error when the model is served behind REST endpoint.
"""
# La... | 27 | 879 |
saleor | saleor/graphql/app/tests/mutations/test_app_problem_create_validation.py | .py | import datetime
from django.utils import timezone
from .....app.error_codes import AppProblemCreateErrorCode
from .....app.models import AppProblem
from ....tests.utils import get_graphql_content
APP_PROBLEM_CREATE_MUTATION = """
mutation AppProblemCreate($input: AppProblemCreateInput!) {
appProblemCreat... | 256 | 7,667 |
textual | docs/examples/styles/scrollbar_gutter.py | .py | from textual.app import App
from textual.widgets import Static
TEXT = """I must not fear.
Fear is the mind-killer.
Fear is the little-death that brings total obliteration.
I will face my fear.
I will permit it to pass over me and through me.
And when it has gone past, I will turn the inner eye to see its path.
Where t... | 23 | 595 |
probability | tensorflow_probability/python/experimental/sts_gibbs/__init__.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... | 31 | 1,429 |
biopython | Bio/Align/a2m.py | .py | # Copyright 2022 by Michiel de Hoon. 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.
"""Bio.Align support fo... | 122 | 4,523 |
probability | tensorflow_probability/python/bijectors/tanh_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... | 98 | 3,640 |
beam | sdks/python/apache_beam/transforms/trigger.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,757 | 57,607 |
wandb | wandb/apis/_generated/get_agent_runs.py | .py | # Generated by ariadne-codegen
# Source: tools/graphql_codegen/api/
from __future__ import annotations
from pydantic import Field
from wandb._pydantic import GQLResult
from .fragments import LightweightRunFragment, PageInfoFragment
class GetAgentRuns(GQLResult):
project: GetAgentRunsProject | None
class Get... | 45 | 1,114 |
biopython | Bio/NMR/xpktools.py | .py | # Copyright 2004 by Bob Bussell. 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.
"""Tools to manipulate data from nmrview .xpk peaklist files."""
HEADERLEN = 6
class XpkEntry:... | 314 | 9,274 |
gunicorn | gunicorn/sock.py | .py | #
# This file is part of gunicorn released under the MIT license.
# See the NOTICE for more information.
import errno
import os
import socket
import ssl
import stat
import struct
import sys
import time
from gunicorn import util
PLATFORM = sys.platform
class BaseSocket:
def __init__(self, address, conf, log, f... | 316 | 9,295 |
mlflow | tests/evaluate/logging/test_evaluation_entity.py | .py | from mlflow.entities import Metric
from mlflow.evaluation.assessment import AssessmentEntity, AssessmentSource
from mlflow.evaluation.evaluation import EvaluationEntity
from mlflow.evaluation.evaluation_tag import EvaluationTag
def test_evaluation_equality():
source_1 = AssessmentSource(source_type="HUMAN", sourc... | 185 | 6,161 |
probability | tensorflow_probability/python/bijectors/correlation_cholesky_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... | 330 | 12,832 |
pyro | pyro/nn/module.py | .py | # Copyright (c) 2017-2019 Uber Technologies, Inc.
# SPDX-License-Identifier: Apache-2.0
"""
Pyro includes a class :class:`~pyro.nn.module.PyroModule`, a subclass of
:class:`torch.nn.Module`, whose attributes can be modified by Pyro effects. To
create a poutine-aware attribute, use either the :class:`PyroParam` struct... | 977 | 40,779 |
biopython | Bio/SearchIO/InfernalIO/infernal_text.py | .py | # Copyright 2024 by Samuel Prince. 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.
"""Bio.SearchIO parser f... | 543 | 21,628 |
saleor | saleor/giftcard/__init__.py | .py | from dataclasses import dataclass
from typing import TYPE_CHECKING, Optional
if TYPE_CHECKING:
from ..order.models import FulfillmentLine, OrderLine
from ..product.models import ProductVariant
class GiftCardEvents:
"""The different gift card event types."""
ISSUED = "issued"
BOUGHT = "bought"
... | 55 | 2,051 |
scikit-bio | skbio/binaries/_distance.py | .py | # ----------------------------------------------------------------------------
# Copyright (c) 2025--, 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.
# --------------------------------------------... | 198 | 7,344 |
mlflow | tests/server/jobs/test_progress.py | .py | from unittest import mock
from mlflow.server.jobs.progress import (
JobTracker,
NoOpTracker,
_get_job_tracker,
_set_job_tracker,
update_status_details,
)
def test_job_tracker_writes_to_database():
job_id = "test-job-123"
tracker = JobTracker(job_id)
with mock.patch("mlflow.server.han... | 156 | 4,547 |
readthedocs.org | readthedocs/builds/models.py | .py | """Models for the builds app."""
import datetime
import json
import os.path
import re
from functools import partial
from io import BytesIO
import structlog
from django.conf import settings
from django.contrib.contenttypes.fields import GenericRelation
from django.db import models
from django.urls import reverse
from ... | 1,191 | 42,139 |
coremltools | coremltools/converters/mil/backend/mil/passes/insert_image_preprocessing_op.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 numpy as np
from coremltools.converters.mil import input_types as _input_types
from coremltoo... | 83 | 3,726 |
biopython | Bio/Align/psl.py | .py | # Copyright 2022 by Michiel de Hoon. 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.
"""Bio.Align support fo... | 542 | 22,119 |
jupytext | src/jupytext/version.py | .py | """Jupytext's version number"""
# Must match [N!]N(.N)*[{a|b|rc}N][.postN][.devN], cf. PEP 440
__version__ = "1.19.5"
| 5 | 119 |
openvino | src/frontends/onnx/tests/tests_python/test_ops_reduction.py | .py | # -*- coding: utf-8 -*-
# Copyright (C) 2018-2026 Intel Corporation
# SPDX-License-Identifier: Apache-2.0
import numpy as np
import onnx
import pytest
from tests import xfail_issue_99962
from tests.runtime import get_runtime
from tests.tests_python.utils import (
run_node,
import_onnx_model,
)
reduce_data = ... | 360 | 15,535 |
pyomo | examples/pyomobook/performance-ch/wl.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... | 224 | 6,268 |
jupytext | tests/data/notebooks/outputs/ipynb_to_script/Notebook with function and cell metadata 164.py | .py | # ---
# jupyter:
# kernelspec:
# display_name: Python 3
# language: python
# name: python3
# ---
1 + 1
# A markdown cell
# And below, the cell for function f has non trivial cell metadata. And the next cell as well.
# + attributes={"classes": [], "id": "", "n": "10"}
def f(x):
return x
# + attri... | 27 | 392 |
pyomo | pyomo/core/tests/unit/kernel/__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... | 12 | 576 |
saleor | saleor/order/tests/test_fetch_order_prices.py | .py | from decimal import Decimal
import graphene
import pytest
from ...core.prices import quantize_price
from ...core.taxes import zero_money
from ...discount import DiscountType, DiscountValueType, VoucherType
from ...discount.models import OrderDiscount, OrderLineDiscount, PromotionRule
from ...discount.utils.voucher im... | 2,042 | 78,666 |
python-prompt-toolkit | examples/prompts/custom-lexer.py | .py | #!/usr/bin/env python
"""
An example of a custom lexer that prints the input text in random colors.
"""
from prompt_toolkit.lexers import Lexer
from prompt_toolkit.shortcuts import prompt
from prompt_toolkit.styles.named_colors import NAMED_COLORS
class RainbowLexer(Lexer):
def lex_document(self, document):
... | 31 | 727 |
pyomo | pyomo/gdp/plugins/gdp_to_mip_transformation.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... | 324 | 13,677 |
pyro | pyro/contrib/timeseries/lgssm.py | .py | # Copyright (c) 2017-2019 Uber Technologies, Inc.
# SPDX-License-Identifier: Apache-2.0
import torch
import torch.nn as nn
from torch.distributions import MultivariateNormal, constraints
import pyro.distributions as dist
from pyro.contrib.timeseries.base import TimeSeriesModel
from pyro.nn import PyroParam, pyro_meth... | 157 | 6,439 |
kafka | tests/kafkatest/tests/streams/base_streams_test.py | .py | # Licensed to the Apache Software Foundation (ASF) under one or more
# contributor license agreements. See the NOTICE file distributed with
# this work for additional information regarding copyright ownership.
# The ASF licenses this file to You under the Apache License, Version 2.0
# (the "License"); you may not use ... | 141 | 6,643 |
kombu | kombu/transport/azurestoragequeues.py | .py | """Azure Storage Queues transport module for kombu.
More information about Azure Storage Queues:
https://azure.microsoft.com/en-us/services/storage/queues/
Features
========
* Type: Virtual
* Supports Direct: *Unreviewed*
* Supports Topic: *Unreviewed*
* Supports Fanout: *Unreviewed*
* Supports Priority: *Unreviewed*... | 264 | 8,878 |
saleor | saleor/graphql/product/tests/queries/test_collection_query.py | .py | import logging
from unittest.mock import MagicMock
import graphene
from django.core.files import File
from .....product.tests.utils import create_image
from .....thumbnail.models import Thumbnail
from ....core.enums import LanguageCodeEnum, ThumbnailFormatEnum
from ....tests.utils import get_graphql_content, get_grap... | 702 | 21,397 |
openvino | tests/layer_tests/tensorflow_tests/test_tf_AdjustHue.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(2323534)
class TestAdjustHue(CommonTFLayerTest):
def _prepare_input(self, inputs_info):
... | 54 | 2,312 |
pdm | src/pdm/environments/local.py | .py | from __future__ import annotations
import os
import re
import shlex
from functools import cached_property
from pathlib import Path
from pdm.environments.base import BaseEnvironment
from pdm.utils import pdm_scheme
def _get_shebang_path(executable: str, is_launcher: bool) -> bytes:
"""Get the interpreter path in... | 124 | 4,502 |
saleor | saleor/channel/tasks/saleor3_22.py | .py | from ....celeryconf import app
from ....core.db.connection import allow_writer
from ...models import Channel
@app.task
@allow_writer()
def set_automatic_completion_delay_task():
Channel.objects.filter(
automatically_complete_fully_paid_checkouts=True,
automatic_completion_delay__isnull=True,
)... | 13 | 358 |
python-prompt-toolkit | src/prompt_toolkit/shortcuts/utils.py | .py | from __future__ import annotations
from asyncio.events import AbstractEventLoop
from typing import TYPE_CHECKING, Any, TextIO
from prompt_toolkit.application import Application
from prompt_toolkit.application.current import get_app_or_none, get_app_session
from prompt_toolkit.application.run_in_terminal import run_in... | 240 | 6,950 |
biopython | Tests/test_AlignIO_MauveIO.py | .py | # Copyright 2006-2014 by Peter Cock. All rights reserved.
# Revisions copyright 2011 Brandon Invergo. 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 Bio.AlignIO.Mau... | 122 | 5,255 |
onnxruntime | onnxruntime/test/testdata/test_arbitrary_external_file.py | .py | import onnx
from onnx import TensorProto, helper
def create_exp_model():
inputs = []
nodes = []
tensors = []
outputs = []
# Create input tensor info
input_ = helper.make_tensor_value_info("input", TensorProto.INT64, [None])
inputs.append(input_)
# Create malicious tensor with externa... | 55 | 1,689 |
pdm | src/pdm/cli/utils.py | .py | from __future__ import annotations
import argparse
import dataclasses as dc
import importlib.resources
import json
import os
import re
import sys
from collections import OrderedDict
from collections.abc import Callable, Iterable, Mapping, MutableMapping
from fnmatch import fnmatch
from gettext import gettext as _
from... | 743 | 27,980 |
saleor | saleor/graphql/account/tests/mutations/staff/test_customer_create.py | .py | from unittest.mock import ANY, patch
from urllib.parse import urlencode
import graphene
from ......account import events as account_events
from ......account.error_codes import AccountErrorCode
from ......account.models import Address, User
from ......account.notifications import get_default_user_payload
from ......a... | 876 | 29,423 |
coremltools | deps/pybind11/tests/test_eval_call.py | .py | # This file is called from 'test_eval.py'
from __future__ import annotations
if "call_test2" in locals():
call_test2(y) # noqa: F821 undefined name
| 6 | 154 |
biopython | Bio/SearchIO/_model/hit.py | .py | # Copyright 2012 by Wibowo Arindrarto. 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.
"""Bio.SearchIO object ... | 465 | 17,396 |
sphinx | tests/test_util/test_util_importer.py | .py | """Test sphinx.util._importer."""
from __future__ import annotations
import pytest
from sphinx.errors import ExtensionError
from sphinx.util._importer import import_object
def test_import_object() -> None:
module = import_object('sphinx')
assert module.__name__ == 'sphinx'
module = import_object('sphi... | 29 | 880 |
openvino | src/bindings/python/src/openvino/frontend/onnx/__init__.py | .py | # Copyright (C) 2018-2026 Intel Corporation
# SPDX-License-Identifier: Apache-2.0
"""
Package: openvino
Low level wrappers for the FrontEnd C++ API.
"""
# flake8: noqa
try:
from openvino.frontend.onnx.py_onnx_frontend import ConversionExtensionONNX as ConversionExtension
from openvino.frontend.onnx.py_onnx_f... | 16 | 517 |
onnxruntime | onnxruntime/test/testdata/lora/two_params_lora_model.py | .py | # Copyright (c) Microsoft Corporation. All rights reserved.
# Licensed under the MIT License.
import os
import numpy as np
import onnx
import onnxruntime as ort
model_path = "two_params_lora_model.onnx"
adapter_path = "two_params_lora_model.onnx_adapter"
def create_model(model_path: os.PathLike):
#### Inputs
... | 157 | 5,076 |
mlflow | mlflow/pyfunc/dbconnect_artifact_cache.py | .py | import json
import os
import subprocess
import tarfile
from pathlib import Path
from mlflow.exceptions import MlflowException
from mlflow.utils.databricks_utils import is_in_databricks_runtime
from mlflow.utils.file_utils import check_tarfile_security, get_or_create_tmp_dir
_CACHE_MAP_FILE_NAME = "db_connect_artifact... | 166 | 6,672 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.