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 |
|---|---|---|---|---|---|
biopython | Tests/test_PDB_Dice.py | .py | # Copyright 2019 by Sergio Valqui. 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.
"""Unit tests for the Bio.PD... | 61 | 2,184 |
sphinx | tests/test_builders/test_build_linkcheck.py | .py | """Test the build process with manpage builder with the test root."""
from __future__ import annotations
import json
import re
import sys
import textwrap
import time
import wsgiref.handlers
from base64 import b64encode
from http.server import BaseHTTPRequestHandler
from io import StringIO
from queue import Queue
from... | 1,525 | 49,866 |
pyomo | pyomo/contrib/solver/common/factory.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... | 119 | 3,570 |
sphinx | tests/roots/test-ext-autodoc/autodoc_dummy_bar.py | .py | from bug2437.autodoc_dummy_foo import Foo
class Bar:
"""Dummy class Bar with alias."""
my_name = Foo
| 8 | 112 |
jupytext | tests/data/notebooks/outputs/ipynb_to_percent/nteract_with_parameter.py | .py | # ---
# jupyter:
# kernel_info:
# name: python3
# kernelspec:
# display_name: Python 3
# language: python
# name: python3
# ---
# %% inputHidden=false outputHidden=false tags=["parameters"]
param = 4
# %% inputHidden=false outputHidden=false
import pandas as pd
# %% inputHidden=false outputHidden... | 25 | 526 |
mlflow | dev/flavors/src/flavors/_matrix.py | .py | """
Generate the cross-version test matrix from `mlflow/ml-package-versions.yml`.
# Usage
```
# Test all items
flavors matrix
# Exclude items for dev versions
flavors matrix --no-dev
# Test items affected by config file updates
flavors matrix --ref-versions-yaml /path/to/ref-versions.yml
# Test items affected by f... | 660 | 23,611 |
saleor | saleor/graphql/payment/tests/mutations/test_transaction_update.py | .py | from decimal import Decimal
from unittest.mock import patch
import graphene
import pytest
from freezegun import freeze_time
from .....checkout import CheckoutAuthorizeStatus, CheckoutChargeStatus
from .....checkout.calculations import fetch_checkout_data
from .....checkout.complete_checkout import create_order_from_c... | 3,823 | 116,470 |
saleor | saleor/graphql/order/mutations/fulfillment_return_products.py | .py | from typing import Any
import graphene
from ....order import FulfillmentStatus
from ....order import models as order_models
from ....order.actions import create_fulfillments_for_returned_products
from ....order.error_codes import OrderErrorCode
from ....payment import PaymentError
from ....permission.enums import Ord... | 263 | 9,841 |
mlflow | tests/tracing/processor/test_otel_processor.py | .py | from unittest import mock
from opentelemetry.sdk.trace.export import SpanExportResult
from mlflow.entities.trace_info import TraceInfo, TraceLocation, TraceState
from mlflow.tracing.constant import TRACE_SCHEMA_VERSION_KEY, SpanAttributeKey
from mlflow.tracing.processor.otel import OtelSpanProcessor
from mlflow.traci... | 115 | 4,142 |
django-cms | cms/tests/test_no_i18n.py | .py | from unittest.mock import patch
from django.contrib.auth import get_user_model
from django.template import Template
from django.test.utils import override_settings
from django.urls import clear_url_caches
from django.utils.translation import trans_null
from cms.api import create_page
from cms.constants import TEMPLAT... | 157 | 6,834 |
marshmallow | src/marshmallow/experimental/context.py | .py | """Helper API for setting serialization/deserialization context.
Example usage:
.. code-block:: python
import typing
from marshmallow import Schema, fields
from marshmallow.experimental.context import Context
class UserContext(typing.TypedDict):
suffix: str
UserSchemaContext = Contex... | 74 | 2,040 |
saleor | saleor/tax/__init__.py | .py | class TaxCalculationStrategy:
FLAT_RATES = "FLAT_RATES"
TAX_APP = "TAX_APP"
CHOICES = [(FLAT_RATES, "Flat rates"), (TAX_APP, "Tax app")]
class TaxableObjectDiscountType:
SUBTOTAL = "SUBTOTAL"
SHIPPING = "SHIPPING"
CHOICES = [(SUBTOTAL, "Subtotal"), (SHIPPING, "Shipping")]
| 13 | 301 |
pyomo | doc/OnlineDocs/src/scripting/abstract2piecebuild.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... | 76 | 2,449 |
mlflow | mlflow/server/auth/entities.py | .py | from mlflow.exceptions import MlflowException
from mlflow.server.auth.permissions import get_permission
from mlflow.utils.workspace_utils import DEFAULT_WORKSPACE_NAME, resolve_entity_workspace_name
class User:
def __init__(
self,
id_,
username,
password_hash,
is_admin,
... | 574 | 13,943 |
pyomo | examples/dae/disease_DAE.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... | 334 | 9,341 |
pyomo | pyomo/contrib/pynumero/linalg/ma57.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... | 222 | 8,511 |
astropy | astropy/table/tests/test_groups.py | .py | # Licensed under a 3-clause BSD style license - see LICENSE.rst
import numpy as np
import pytest
from hypothesis import given
from hypothesis.extra.numpy import arrays
from hypothesis.strategies import integers
from astropy import coordinates, time
from astropy import units as u
from astropy.table import Column, Nda... | 787 | 24,771 |
probability | tensorflow_probability/python/distributions/student_t_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... | 998 | 37,338 |
biopython | Bio/Graphics/GenomeDiagram/_CircularDrawer.py | .py | # Copyright 2003-2008 by Leighton Pritchard. All rights reserved.
# Revisions copyright 2008-2017 by Peter Cock.
#
# 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 incl... | 1,732 | 68,783 |
beam | sdks/python/apache_beam/io/gcp/pubsub_io_perf_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... | 221 | 7,583 |
mlflow | mlflow/pyspark/__init__.py | .py | from mlflow.pyspark import ml
__all__ = ["ml"]
| 4 | 48 |
onnxruntime | orttraining/orttraining/python/training/onnxblock/_graph_utils.py | .py | # Copyright (c) Microsoft Corporation. All rights reserved.
# Licensed under the MIT License.
import onnx
def get_output_from_output_name(onnx_model: onnx.ModelProto, output_name: str) -> onnx.ValueInfoProto:
"""Returns the graph output for the given output name"""
for go in onnx_model.graph.output:
... | 105 | 3,455 |
clearml | clearml/backend_config/config.py | .py | from __future__ import print_function
import functools
import json
import logging
import os
import warnings
from fnmatch import fnmatch
from os.path import expanduser
from typing import Any, Optional, List, Union
from pathlib2 import Path
from pyparsing import (
ParseFatalException,
ParseException,
Recurs... | 421 | 14,665 |
deap | deap/algorithms.py | .py | # This file is part of DEAP.
#
# DEAP is free software: you can redistribute it and/or modify
# it under the terms of the GNU Lesser General Public License as
# published by the Free Software Foundation, either version 3 of
# the License, or (at your option) any later version.
#
# DEAP is distributed ... | 504 | 23,000 |
coremltools | coremltools/models/ml_program/experimental/perf_utils.py | .py | # Copyright (c) 2025, Apple Inc. All rights reserved.
#
# Use of this source code is governed by a BSD-3-clause license that can be
# found in the LICENSE.txt file or at https://opensource.org/licenses/BSD-3-Clause
import gc
import random
import string
from dataclasses import dataclass
from typing import Any, Dict, Li... | 485 | 16,703 |
onnx | onnx/reference/ops/op_if.py | .py | # Copyright (c) ONNX Project Contributors
# SPDX-License-Identifier: Apache-2.0
from __future__ import annotations
from typing import TYPE_CHECKING
from onnx.reference.op_run import OpRun
if TYPE_CHECKING:
import numpy as np
class If(OpRun):
def __init__(self, onnx_node, run_params):
OpRun.__init... | 73 | 2,578 |
luigi | test/worker_scheduler_com_test.py | .py | # -*- coding: utf-8 -*-
#
# Copyright 2012-2017 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... | 187 | 6,893 |
httpie | httpie/cli/argparser.py | .py | import argparse
import errno
import os
import re
import sys
from argparse import RawDescriptionHelpFormatter
from textwrap import dedent
from urllib.parse import urlsplit
from requests.utils import get_netrc_auth
from .argtypes import (
AuthCredentials, SSLCredentials, KeyValueArgType,
PARSED_DEFAULT_FORMAT_O... | 614 | 23,136 |
saleor | saleor/checkout/utils.py | .py | """Checkout-related utility functions."""
from collections.abc import Iterable
from decimal import Decimal
from typing import TYPE_CHECKING, Optional, cast
from uuid import UUID
import graphene
from django.conf import settings
from django.core.exceptions import ValidationError
from django.db import transaction
from d... | 1,069 | 37,396 |
sphinx | tests/test_pycode/test_pycode.py | .py | """Test pycode."""
from __future__ import annotations
import sys
from importlib.machinery import SourceFileLoader
from pathlib import Path
import pytest
import sphinx
from sphinx.errors import PycodeError
from sphinx.pycode import ModuleAnalyzer
SPHINX_MODULE_PATH = Path(sphinx.__file__).resolve().with_suffix('.py... | 196 | 6,464 |
pyomo | examples/kernel/suffixes.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... | 37 | 1,086 |
textual | tests/test_win_sleep.py | .py | import asyncio
import time
import sys
import pytest
from textual.app import App
pytestmark = pytest.mark.skipif(
sys.platform != "win32", reason="We only need to test this on Windows."
)
def test_win_sleep_timer_is_cancellable():
"""Regression test for https://github.com/Textualize/textual/issues/2711.
... | 42 | 1,204 |
wagtail | wagtail/contrib/frontend_cache/backends/cloudfront.py | .py | import logging
import uuid
from collections import defaultdict
from urllib.parse import urlparse
from django.core.exceptions import ImproperlyConfigured
from .base import BaseBackend
logger = logging.getLogger("wagtail.frontendcache")
__all__ = ["CloudfrontBackend"]
class CloudfrontBackend(BaseBackend):
def ... | 77 | 2,527 |
saleor | saleor/graphql/order/tests/utils.py | .py | import graphene
from ....order import OrderStatus
def assert_order_and_payment_ids(content, payment):
data = content["data"]["orderByToken"]
expected_order_id = graphene.Node.to_global_id("Order", payment.order.pk)
assert data["id"] == expected_order_id
expected_payment_id = graphene.Node.to_global_... | 22 | 742 |
pyro | tests/pyroapi/test_pyroapi.py | .py | # Copyright (c) 2017-2019 Uber Technologies, Inc.
# SPDX-License-Identifier: Apache-2.0
import pytest
from pyroapi import pyro_backend
from pyroapi.tests import * # noqa F401
pytestmark = pytest.mark.stage("unit")
@pytest.fixture(params=["pyro", "minipyro"])
def backend(request):
with pyro_backend(request.para... | 15 | 338 |
mlflow | mlflow/store/db_migrations/versions/90e64c465722_migrate_user_column_to_tags.py | .py | """migrate user column to tags
Create Date: 2019-05-29 10:43:52.919427
"""
from alembic import op
from sqlalchemy import Column, ForeignKey, Integer, PrimaryKeyConstraint, String, orm
from sqlalchemy.orm import backref, declarative_base, relationship
from mlflow.utils.mlflow_tags import MLFLOW_USER
# revision iden... | 63 | 1,596 |
wagtail | wagtail/admin/rich_text/converters/markdown_db.py | .py | """
ContentState-mediated conversion between Markdown and Wagtail's database-HTML
rich text format, for the API's `db_markdown` / `markdown` rich text formats.
Internal object references travel in Markdown as `wagtail://` URLs in link /
image destinations (see `REFERENCE_SCHEME`), resolved to Draft.js entities by
`sch... | 312 | 10,627 |
kafka | tests/kafkatest/tests/core/replica_scale_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 ... | 148 | 7,456 |
pyro | pyro/optim/horovod.py | .py | # Copyright Contributors to the Pyro project.
# SPDX-License-Identifier: Apache-2.0
from typing import List, Union, ValuesView
from torch.optim import Optimizer
import pyro
from .optim import PyroOptim
class HorovodOptimizer(PyroOptim):
r"""
Distributed wrapper for a :class:`~pyro.optim.optim.PyroOptim` o... | 56 | 1,906 |
sphinx | utils/bump_version.py | .py | #!/usr/bin/env python3
from __future__ import annotations
import argparse
import dataclasses
import re
import sys
import time
from contextlib import contextmanager
from pathlib import Path
from typing import TYPE_CHECKING
if TYPE_CHECKING:
from collections.abc import Iterator, Sequence
from typing import Lit... | 210 | 6,574 |
wagtail | wagtail/test/middleware.py | .py | from django.http import Http404, HttpResponse, HttpResponseForbidden
try:
from django.middleware import MiddlewareMixin
except ImportError: # DJANGO_VERSION < (6, 2)
from django.utils.deprecation import MiddlewareMixin
from wagtail.test.utils import Page
from wagtail.views import serve
class BlockDodgyUser... | 36 | 1,506 |
ipython | examples/Embedding/embed_class_short.py | .py | """Quick code snippets for embedding IPython into other programs.
See embed_class_long.py for full details, this file has the bare minimum code for
cut and paste use once you understand how to use the system."""
#---------------------------------------------------------------------------
# This code loads IPython but... | 46 | 1,674 |
saleor | saleor/graphql/account/tests/mutations/utils.py | .py | import json
import graphene
from django.utils.functional import SimpleLazyObject
from .....core.utils.json_serializer import CustomJsonEncoder
from .....webhook.payloads import generate_meta, generate_requestor
def generate_address_webhook_call_args(address, event, requestor, webhook):
return [
json.dum... | 31 | 950 |
mlflow | tests/tracking/default_experiment/test_registry.py | .py | from importlib import reload
from unittest import mock
import pytest
import mlflow.tracking.default_experiment.registry
from mlflow.tracking.default_experiment.databricks_notebook_experiment_provider import (
DatabricksNotebookExperimentProvider,
)
from mlflow.tracking.default_experiment.registry import (
Def... | 166 | 5,733 |
mlflow | mlflow/entities/span_status.py | .py | from __future__ import annotations
from dataclasses import dataclass
from enum import Enum
from opentelemetry import trace as trace_api
from opentelemetry.proto.trace.v1.trace_pb2 import Status as OtelStatus
from mlflow.exceptions import MlflowException
from mlflow.protos.databricks_pb2 import INVALID_PARAMETER_VALU... | 153 | 5,466 |
beam | sdks/python/apache_beam/runners/worker/statesampler.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... | 172 | 5,264 |
probability | spinoffs/autobnn/autobnn/training_util.py | .py | # Copyright 2023 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... | 436 | 14,529 |
metrics | src/torchmetrics/clustering/homogeneity_completeness_v_measure.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... | 330 | 12,969 |
probability | spinoffs/fun_mc/fun_mc/prefab.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... | 1,065 | 39,698 |
saleor | saleor/core/http_client.py | .py | import requests_hardened
from django.conf import settings
from .. import user_agent_version
HTTPConfig = requests_hardened.Config(
ip_filter_enable=settings.HTTP_IP_FILTER_ENABLED,
ip_filter_allow_loopback_ips=settings.HTTP_IP_FILTER_ALLOW_LOOPBACK_IPS,
never_redirect=True,
default_timeout=settings.CO... | 15 | 441 |
mlflow | mlflow/utils/name_utils.py | .py | import random
import uuid
_EXPERIMENT_ID_FIXED_WIDTH = 18
def _generate_unique_integer_id():
"""Utility function for generating a random fixed-length integer
Returns:
a fixed-width integer
"""
random_int = uuid.uuid4().int
# Cast to string to get a fixed length
random_str = str(rand... | 343 | 5,763 |
beam | playground/infrastructure/test_datastore_client.py | .py | # Licensed to the Apache Software Foundation (ASF) under one or more
# contributor license agreements. See the NOTICE file distributed with
# this work for additional information regarding copyright ownership.
# The ASF licenses this file to You under the Apache License, Version 2.0
# (the "License"); you may not use ... | 137 | 4,893 |
saleor | saleor/graphql/order/tests/mutations/test_order_confirm.py | .py | from unittest.mock import ANY, call, patch
import graphene
from django.test import override_settings
from .....core.models import EventDelivery
from .....core.notification.utils import get_site_context
from .....core.notify import NotifyEventType
from .....core.prices import quantize_price
from .....core.tests.utils ... | 726 | 25,153 |
saleor | saleor/warehouse/webhooks/stock_events.py | .py | from collections.abc import Iterable
from functools import partial
from typing import TYPE_CHECKING
from ...account.models import User
from ...app.models import App
from ...webhook.event_types import WebhookEventAsyncType
from ...webhook.transport.asynchronous.transport import (
WebhookPayloadData,
trigger_web... | 98 | 2,805 |
mlflow | tests/genai/judges/optimizers/memalign/test_utils.py | .py | import json
from unittest.mock import MagicMock, patch
import dspy
import pytest
import mlflow
from mlflow.genai.judges.optimizers.memalign.utils import (
Guideline,
Guidelines,
_build_strict_response_format,
_count_tokens,
_create_batches,
_extract_json_object,
distill_guidelines,
get... | 833 | 30,210 |
kombu | kombu/log.py | .py | """Logging Utilities."""
from __future__ import annotations
import logging
import numbers
import os
import sys
from logging.handlers import WatchedFileHandler
from typing import TYPE_CHECKING
from .utils.encoding import safe_repr, safe_str
from .utils.functional import maybe_evaluate
from .utils.objects import cache... | 144 | 4,163 |
cvxpy | doc/sphinxext/numpydoc.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... | 190 | 6,250 |
hatch | tests/utils/test_runner.py | .py | from __future__ import annotations
import pytest
from hatch.utils.runner import parse_matrix_variables, select_environments
class TestParseMatrixVariables:
def test_empty(self):
assert parse_matrix_variables(()) == {}
def test_single(self):
assert parse_matrix_variables(("py=3.9",)) == {"py... | 101 | 4,067 |
beam | sdks/python/apache_beam/ml/inference/tensorrt_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... | 473 | 18,748 |
mlflow | mlflow/langchain/autolog.py | .py | import logging
from mlflow.langchain.constant import FLAVOR_NAME
from mlflow.telemetry.events import AutologgingEvent
from mlflow.telemetry.track import _record_event
from mlflow.utils.autologging_utils import autologging_integration
from mlflow.utils.autologging_utils.config import AutoLoggingConfig
from mlflow.utils... | 163 | 6,507 |
cvxpy | cvxpy/tests/test_problem_form.py | .py | """
Copyright, the CVXPY authors
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
... | 373 | 15,451 |
probability | tensorflow_probability/python/distributions/mvn_diag_plus_low_rank_covariance.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... | 224 | 8,348 |
conda | conda/models/dist.py | .py | # Copyright (C) 2012 Anaconda, Inc
# SPDX-License-Identifier: BSD-3-Clause
"""(Legacy) Low-level implementation of a Channel."""
import re
from logging import getLogger
from typing import NamedTuple
from .. import CondaError
from ..auxlib.entity import Entity, EntityType, IntegerField, StringField
from ..base.constan... | 376 | 12,093 |
python-prompt-toolkit | src/prompt_toolkit/key_binding/bindings/emacs.py | .py | # pylint: disable=function-redefined
from __future__ import annotations
from prompt_toolkit.application.current import get_app
from prompt_toolkit.buffer import Buffer, indent, unindent
from prompt_toolkit.completion import CompleteEvent
from prompt_toolkit.filters import (
Condition,
emacs_insert_mode,
em... | 564 | 19,634 |
textual | docs/examples/guide/styles/border_title.py | .py | from textual.app import App, ComposeResult
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 it... | 30 | 971 |
onnx | onnx/backend/test/case/node/rangeop.py | .py | # Copyright (c) ONNX Project Contributors
#
# SPDX-License-Identifier: Apache-2.0
from __future__ import annotations
import ml_dtypes
import numpy as np
import onnx
from onnx.backend.test.case.base import Base
from onnx.backend.test.case.node import expect
class Range(Base):
@staticmethod
def export_range_f... | 103 | 2,828 |
mlflow | mlflow/genai/simulators/prompts.py | .py | DEFAULT_PERSONA = "You are an inquisitive user having a natural conversation."
INITIAL_USER_PROMPT = """Instructions:
You are role-playing as a real user interacting with an AI assistant.
- Write like a human user, not like an assistant or expert. Do not act as the helper or expert:
NEVER answer the goal yourself, e... | 133 | 6,609 |
saleor | saleor/graphql/checkout/tests/mutations/test_checkout_complete_with_payment.py | .py | import datetime
from decimal import Decimal
from unittest.mock import ANY, patch
import graphene
import pytest
from django.conf import settings
from django.contrib.sites.models import Site
from django.db.models.aggregates import Sum
from django.test import override_settings
from django.utils import timezone
from sale... | 6,390 | 214,225 |
saleor | saleor/graphql/account/mutations/authentication/refresh_token.py | .py | import graphene
from django.core.exceptions import ValidationError
from .....account.error_codes import AccountErrorCode
from .....core.jwt import (
JWT_REFRESH_TOKEN_COOKIE_NAME,
JWT_REFRESH_TYPE,
create_access_token,
)
from ....core import ResolveInfo
from ....core.doc_category import DOC_CATEGORY_AUTH
f... | 146 | 5,086 |
hypercorn | src/hypercorn/run.py | .py | from __future__ import annotations
import platform
import signal
import time
from multiprocessing import get_context
from multiprocessing.connection import wait
from multiprocessing.context import BaseContext
from multiprocessing.process import BaseProcess
from multiprocessing.synchronize import Event as EventType
fro... | 152 | 4,840 |
biopython | Tests/test_SeqIO_SffIO.py | .py | # Copyright 2012 by Jeff Hussmann. All rights reserved.
# Revisions copyright 2013-2016 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 SffIO module... | 579 | 21,773 |
pyro | pyro/contrib/util.py | .py | # Copyright (c) 2017-2019 Uber Technologies, Inc.
# SPDX-License-Identifier: Apache-2.0
import weakref
from collections import OrderedDict
import torch
import pyro
def get_indices(labels, sizes=None, tensors=None):
indices = []
start = 0
if sizes is None:
sizes = OrderedDict([(l, t.shape[0]) fo... | 98 | 2,800 |
openvino | tests/layer_tests/onnx_tests/test_flatten.py | .py | # Copyright (C) 2018-2026 Intel Corporation
# SPDX-License-Identifier: Apache-2.0
import pytest
from common.onnx_layer_test_class import OnnxRuntimeLayerTest, onnx_make_model
class TestFlatten(OnnxRuntimeLayerTest):
def create_flatten_net(self, axis, input_shape, dim, ir_version, opset=None):
"""
... | 305 | 12,244 |
beam | sdks/python/apache_beam/ml/inference/tensorrt_inference.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... | 355 | 12,115 |
biopython | BioSQL/BioSeqDatabase.py | .py | # Copyright 2002 by Andrew Dalke. All rights reserved.
# Revisions 2007-2016 copyright by Peter Cock. All rights reserved.
# Revisions 2009 copyright by Cymon J. Cox. All rights reserved.
# Revisions 2013-2014 copyright by Tiago Antao. All rights reserved.
#
# This file is part of the Biopython distribution and gov... | 805 | 30,127 |
onnxruntime | onnxruntime/python/tools/transformers/fusion_simplified_layernorm.py | .py | import logging
from fusion_base import Fusion
from fusion_skiplayernorm import FusionSkipLayerNormalization
from onnx import helper
from onnx_model import OnnxModel
logger = logging.getLogger(__name__)
class FusionSimplifiedLayerNormalization(Fusion):
def __init__(self, model: OnnxModel):
super().__init... | 166 | 7,666 |
pyomo | pyomo/core/tests/unit/test_sos_v2.py | .py | # ____________________________________________________________________________________
#
# Pyomo: Python Optimization Modeling Objects
# Copyright (c) 2008-2026 National Technology and Engineering Solutions of Sandia, LLC
# Under the terms of Contract DE-NA0003525 with National Technology and Engineering
# Solutions of... | 1,111 | 34,068 |
conda | conda/cli/main_list.py | .py | # Copyright (C) 2012 Anaconda, Inc
# SPDX-License-Identifier: BSD-3-Clause
"""CLI implementation for `conda list`.
Lists all packages installed into an environment.
"""
from __future__ import annotations
import logging
import re
from os.path import isdir, isfile
from typing import TYPE_CHECKING
from .. import __ver... | 440 | 12,851 |
wagtail | wagtail/images/tasks.py | .py | from django.apps import apps
from django_tasks import task
@task()
def set_image_focal_point_task(app_label, model_name, pk):
model = apps.get_model(app_label, model_name)
instance = model.objects.get(pk=pk)
instance.set_focal_point(instance.get_suggested_focal_point())
instance.save(
update_... | 19 | 470 |
metrics | src/torchmetrics/aggregation.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... | 741 | 28,384 |
beam | sdks/python/apache_beam/io/gcp/bigquery_change_history_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... | 210 | 7,725 |
scikit-bio | skbio/stats/distance/_utils.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.
# --------------------------------------------... | 199 | 5,241 |
probability | tensorflow_probability/python/optimizer/lbfgs_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... | 587 | 23,068 |
wagtail | wagtail/images/exceptions.py | .py | class InvalidFilterSpecError(ValueError):
pass
class UnknownOutputImageFormatError(ValueError):
"""
Exception thrown when an unknown output format is requested for an image conversion
"""
pass
| 11 | 216 |
probability | tensorflow_probability/python/distributions/distribution_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... | 1,125 | 42,300 |
hatch | src/hatch/cli/run/__init__.py | .py | from __future__ import annotations
from typing import TYPE_CHECKING
import click
if TYPE_CHECKING:
from hatch.cli.application import Application
@click.command(
short_help="Run commands within project environments",
context_settings={"help_option_names": [], "ignore_unknown_options": True},
)
@click.ar... | 164 | 5,866 |
textual | src/textual/layouts/grid.py | .py | from __future__ import annotations
from fractions import Fraction
from typing import TYPE_CHECKING, Iterable
from textual._resolve import resolve
from textual.css.scalar import Scalar
from textual.geometry import NULL_OFFSET, Region, Size, Spacing
from textual.layout import ArrangeResult, Layout, WidgetPlacement
from... | 377 | 13,661 |
scikit-optimize | skopt/sampler/halton.py | .py | """
Inspired by https://github.com/jonathf/chaospy/blob/master/chaospy/
distributions/sampler/sequences/halton.py
"""
import numpy as np
from .base import InitialPointGenerator
from ..space import Space
from sklearn.utils import check_random_state
class Halton(InitialPointGenerator):
"""Creates `Halton` sequence ... | 183 | 5,949 |
cvxpy | cvxpy/reductions/eliminate_pwl/canonicalizers/minimum_canon.py | .py | """
Copyright 2018 Akshay Agrawal
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... | 29 | 971 |
python-prompt-toolkit | src/prompt_toolkit/key_binding/bindings/open_in_editor.py | .py | """
Open in editor key bindings.
"""
from __future__ import annotations
from prompt_toolkit.filters import emacs_mode, has_selection, vi_navigation_mode
from ..key_bindings import KeyBindings, KeyBindingsBase, merge_key_bindings
from .named_commands import get_by_name
__all__ = [
"load_open_in_editor_bindings",... | 53 | 1,356 |
hydra | tools/landscape/test_build_public_landscape.py | .py | # Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved
import json
from pathlib import Path
import build_public_landscape as landscape
import pytest
def included_decision(**overrides: object) -> dict[str, object]:
decision: dict[str, object] = {
"repo": "example/project",
"decisi... | 93 | 3,014 |
onnx | onnx/fuzz/fuzz_model_loader.py | .py | # Copyright (c) ONNX Project Contributors
# SPDX-License-Identifier: Apache-2.0
from __future__ import annotations
import sys
import atheris
with atheris.instrument_imports():
import onnx
def TestOneInput(data):
try:
model = onnx.load_model_from_string(data)
_ = len(model.graph.node)
... | 32 | 635 |
wagtail | wagtail/api/rich_text.py | .py | from collections.abc import Callable
from typing import Any, Literal, cast
from django.conf import settings
from django.core.exceptions import ImproperlyConfigured
from wagtail.rich_text import expand_db_html
RichTextOutputFormat = Literal["db_html", "html", "db_markdown", "markdown"]
RichTextInputFormat = Literal["... | 238 | 8,953 |
readthedocs.org | readthedocs/telemetry/collectors.py | .py | """Data collectors."""
import json
import os
import dparse
import structlog
from readthedocs.config.models import PythonInstallRequirements
from readthedocs.core.utils.filesystem import safe_open
log = structlog.get_logger(__name__)
class BuildDataCollector:
"""
Build data collector.
Collect data fr... | 371 | 12,354 |
django-cms | cms/test_utils/project/placeholder_relation_field_app/admin.py | .py | from django.contrib import admin
from cms.admin.placeholderadmin import FrontendEditableAdminMixin
from .models import FancyPoll
class FancyPollAdmin(FrontendEditableAdminMixin, admin.ModelAdmin):
pass
admin.site.register(FancyPoll, FancyPollAdmin)
| 13 | 259 |
textual | docs/blog/snippets/2022-12-07-responsive-app-background-task/nonblocking01.py | .py | import asyncio
from random import randint
from textual.app import App, ComposeResult
from textual.color import Color
from textual.containers import Grid, VerticalScroll
from textual.widget import Widget
from textual.widgets import Footer, Label
class ColourChanger(Widget):
def on_click(self) -> None:
sel... | 45 | 1,072 |
pyomo | pyomo/core/base/label.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... | 221 | 6,995 |
deap | deap/gp.py | .py | # This file is part of DEAP.
#
# DEAP is free software: you can redistribute it and/or modify
# it under the terms of the GNU Lesser General Public License as
# published by the Free Software Foundation, either version 3 of
# the License, or (at your option) any later version.
#
# DEAP is distributed ... | 1,354 | 52,433 |
hydra | examples/experimental/rerun/my_app.py | .py | # Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved
import logging
from omegaconf import DictConfig
import hydra
from hydra.core.hydra_config import HydraConfig
from hydra.utils import target_whitelist
log = logging.getLogger(__name__)
@hydra.main(config_path=".", config_name="config")
def my_a... | 23 | 558 |
pyomo | pyomo/contrib/solver/solvers/knitro/callback.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... | 90 | 2,989 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.