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
probability
tensorflow_probability/python/sts/components/local_linear_trend_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...
180
6,815
biopython
Bio/Nexus/Trees.py
.py
# Copyright 2005-2008 by Frank Kauff & Cymon J. Cox. 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. """Tree...
995
40,281
saleor
saleor/graphql/account/mutations/customer_type/customer_type_update.py
.py
from collections import defaultdict import graphene from django.core.exceptions import ValidationError from .....account import models from .....permission.enums import CustomerTypePermissions from .....webhook.event_types import WebhookEventAsyncType from ....core import ResolveInfo from ....core.descriptions import...
90
3,245
kombu
t/unit/utils/test_uuid.py
.py
from __future__ import annotations from kombu.utils.uuid import uuid class test_UUID: def test_uuid4(self) -> None: assert uuid() != uuid() def test_uuid(self) -> None: i1 = uuid() i2 = uuid() assert isinstance(i1, str) assert i1 != i2
16
289
sqlmap
tamper/modsecurityzeroversioned.py
.py
#!/usr/bin/env python """ Copyright (c) 2006-2026 sqlmap developers (https://sqlmap.org) See the file 'LICENSE' for copying permission """ import os from lib.core.common import singleTimeWarnMessage from lib.core.enums import DBMS from lib.core.enums import PRIORITY __priority__ = PRIORITY.HIGHER def dependencies(...
49
1,200
pymc
pymc/dims/distributions/vector.py
.py
# Copyright 2025 - present The PyMC Developers # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable...
265
9,691
kafka
tests/kafkatest/services/performance/end_to_end_latency.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 ...
115
5,163
wandb
wandb/sdk/artifacts/_generated/artifact_collection_aliases.py
.py
# Generated by ariadne-codegen # Source: tools/graphql_codegen/artifacts/ from __future__ import annotations from typing import Literal from pydantic import Field from wandb._pydantic import GQLResult, Typename from .fragments import ArtifactAliasFragment, PageInfoFragment class ArtifactCollectionAliases(GQLResu...
41
1,250
jupyterlab
scripts/ensure_typedoc_links.py
.py
# Copyright (c) Jupyter Development Team. # Distributed under the terms of the Modified BSD License. """Provide consistent URL destinations for TypeDoc.""" import sys from pathlib import Path HERE = Path(__file__).parent.resolve() ROOT = HERE.parent #: a basic HTTP redirect REDIRECT = """<meta http-equiv="refresh" co...
67
2,066
lemur
lemur/exceptions.py
.py
""" .. module: lemur.exceptions :copyright: (c) 2018 by Netflix Inc., see AUTHORS for more :license: Apache, see LICENSE for more details. """ from flask import current_app class LemurException(Exception): def __init__(self, *args, **kwargs): current_app.logger.exception(self) class DuplicateErr...
66
1,511
coveragepy
lab/goals.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 """\ Check coverage goals. Use `coverage json` to get a coverage.json file, then run this tool to check goals for subsets of files. Patterns can use '**/foo*.py...
101
3,448
probability
tensorflow_probability/python/distributions/exponential.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...
176
6,679
saleor
saleor/graphql/order/tests/queries/test_order_events.py
.py
from copy import deepcopy import graphene from .....order import OrderEvents from .....order import events as order_events from .....order.events import order_replacement_created from .....order.models import OrderEvent, get_order_number from ....tests.utils import get_graphql_content ORDERS_FULFILLED_EVENTS = """ ...
401
12,921
astropy
astropy/timeseries/periodograms/lombscargle_multiband/tests/test_lombscargle_multiband.py
.py
import numpy as np import pytest from numpy.testing import assert_allclose from astropy import units as u from astropy.table import MaskedColumn from astropy.tests.helper import assert_quantity_allclose from astropy.time import Time, TimeDelta from astropy.timeseries import TimeSeries from astropy.timeseries.periodogr...
635
19,947
probability
tensorflow_probability/python/math/psd_kernels/exp_sin_squared_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...
132
4,940
wagtail
wagtail/contrib/styleguide/apps.py
.py
from django.apps import AppConfig from django.utils.translation import gettext_lazy as _ class WagtailStyleGuideAppConfig(AppConfig): name = "wagtail.contrib.styleguide" label = "wagtailstyleguide" verbose_name = _("Wagtail style guide")
9
252
onnx
onnx/reference/ops/op_rotary_embedding.py
.py
# Copyright (c) ONNX Project Contributors # # SPDX-License-Identifier: Apache-2.0 from __future__ import annotations import numpy as np from onnx.reference.op_run import OpRun def rotary_embedding( input: np.ndarray, cos_cache: np.ndarray, sin_cache: np.ndarray, position_ids: np.ndarray | None = Non...
120
4,316
django-cms
cms/test_utils/util/grouper.py
.py
def wo_content_permission(method): """Decorator to temporarily switch of write permissions to content""" def inner(self, *args, **kwargs): self.admin.change_content = False try: return_value = method(self, *args, **kwargs) except Exception: raise finally: ...
13
410
onnx
onnx/backend/test/case/node/trilu.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 def triu_reference_implementation(x, k=0): return np.triu(x, k) def tr...
454
12,514
openvino
tests/layer_tests/tensorflow_tests/test_tf_Softmax.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(54654675) class TestSoftmax(CommonTFLayerTest): def _prepare_input(self, inputs_info): ...
44
1,664
saleor
saleor/graphql/checkout/dataloaders/__init__.py
.py
from .checkout_infos import ( CheckoutInfoByCheckoutTokenLoader, CheckoutLinesInfoByCheckoutTokenLoader, ) from .models import ( CheckoutByTokenLoader, CheckoutByUserAndChannelLoader, CheckoutByUserLoader, CheckoutLineByIdLoader, CheckoutLinesByCheckoutTokenLoader, CheckoutMetadataByChec...
34
1,072
mlflow
tests/utils/test_class_utils.py
.py
import mlflow from mlflow.utils.class_utils import _get_class_from_string def test_get_class_from_string(): assert _get_class_from_string("mlflow.MlflowClient") == mlflow.MlflowClient
7
190
luigi
luigi/contrib/dataproc.py
.py
"""luigi bindings for Google Dataproc on Google Cloud""" import logging import os import time import luigi from luigi.contrib import gcp logger = logging.getLogger("luigi-interface") _dataproc_client = None try: import google.auth from googleapiclient import discovery from googleapiclient.errors import...
260
9,976
mlflow
mlflow/evaluation/utils.py
.py
""" THE 'mlflow.evaluation` MODULE IS LEGACY AND WILL BE REMOVED SOON. PLEASE DO NOT USE THESE CLASSES IN NEW CODE. INSTEAD, USE `mlflow/entities/assessment.py` FOR ASSESSMENT CLASSES. """ import pandas as pd from mlflow.evaluation.evaluation import EvaluationEntity as EvaluationEntity from mlflow.utils.annotations i...
202
6,375
kafka
tests/kafkatest/tests/streams/streams_broker_compatibility_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 ...
109
5,481
openvino
tests/layer_tests/pytorch_tests/test_divmod.py
.py
# Copyright (C) 2018-2026 Intel Corporation # SPDX-License-Identifier: Apache-2.0 import numpy.testing as npt import openvino as ov import pytest import torch from pytorch_layer_test_class import SeededRandom # do not test via PytorchLayerTest since PytorchLayerTest triggers own TorchScript tracing # this test vali...
83
3,668
deap
deap/benchmarks/tools.py
.py
"""Module containing tools that are useful when benchmarking algorithms """ from math import hypot, sqrt from functools import wraps from itertools import repeat try: import numpy numpy_imported = True except ImportError: numpy_imported = False try: import scipy.spatial scipy_imported = True except...
326
12,127
pyomo
pyomo/util/calc_var_value.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...
317
13,072
wandb
wandb/apis/public/const.py
.py
from __future__ import annotations import datetime # Only retry requests for 20 seconds in the public api RETRY_TIMEDELTA = datetime.timedelta(seconds=20)
7
157
textual
src/textual/_segment_tools.py
.py
""" Tools for processing Segments, or lists of Segments. """ from __future__ import annotations import re from functools import lru_cache from typing import Iterable from rich.segment import Segment from rich.style import Style from textual._cells import cell_len from textual.css.types import AlignHorizontal, Align...
308
8,708
astropy
astropy/coordinates/tests/test_pickle.py
.py
import pickle import numpy as np import pytest import astropy.units as u from astropy import coordinates as coord from astropy.coordinates import ( ICRS, Angle, Distance, DynamicMatrixTransform, Latitude, Longitude, StaticMatrixTransform, ) from astropy.tests.helper import check_pickling_r...
88
2,247
mlflow
mlflow/gateway/providers/__init__.py
.py
from mlflow.gateway.config import Provider from mlflow.gateway.providers.base import BaseProvider def get_provider(provider: Provider) -> type[BaseProvider]: from mlflow.gateway.provider_registry import provider_registry return provider_registry.get(provider)
9
271
rq
rq/scheduler.py
.py
from __future__ import annotations import logging import os import signal import socket import time import traceback from collections.abc import Iterable from datetime import datetime from enum import Enum from multiprocessing import Process, get_context from multiprocessing.process import BaseProcess from uuid import...
337
12,809
textual
src/textual/renderables/text_opacity.py
.py
import functools from typing import Iterable, Tuple, cast from rich.cells import cell_len from rich.color import Color from rich.console import Console, ConsoleOptions, RenderableType, RenderResult from rich.segment import Segment from rich.style import Style from rich.terminal_theme import TerminalTheme from textual...
160
5,827
deap
examples/coev/symbreg.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 ...
138
4,542
coremltools
coremltools/converters/mil/mil/passes/defs/optimize_activation.py
.py
# Copyright (c) 2023, 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.experimental.passes.generic_pass_infrastructure i...
694
26,138
pyomo
pyomo/contrib/parmest/tests/test_solver.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...
74
2,206
onnx
onnx/reference/ops/aionnx_preview_training/op_adagrad.py
.py
# Copyright (c) ONNX Project Contributors # SPDX-License-Identifier: Apache-2.0 from __future__ import annotations import numpy as np from onnx.reference.ops.aionnx_preview_training._op_run_training import OpRunTraining def _apply_adagrad(r, t, x, g, h, norm_coefficient, epsilon, decay_factor): # Compute adjus...
65
1,917
beam
sdks/python/apache_beam/runners/worker/worker_id_interceptor_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...
71
2,362
metrics
src/torchmetrics/functional/text/wer.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...
88
2,961
onnxruntime
orttraining/tools/scripts/nv_run_pretraining.py
.py
# Copyright (c) 2019 NVIDIA CORPORATION. All rights reserved. # Copyright 2018 The Google AI Language Team Authors and The HugginFace Inc. 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...
704
30,238
luigi
test/_test_ftp.py
.py
# -*- coding: utf-8 -*- # # Copyright 2012-2015 Spotify AB # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law...
232
7,293
astropy
astropy/cosmology/_src/tests/traits/test_trait_darkmatter.py
.py
import numpy as np import pytest from numpy.testing import assert_allclose from astropy.cosmology._src.traits.darkmatter import DarkMatterComponent from .helper import is_positional_only class DummyDarkMatter(DarkMatterComponent): Odm0 = 0.25 def inv_efunc(self, z): return np.ones_like(np.asarray(z...
26
631
saleor
saleor/webhook/tests/fixtures/webhook_event.py
.py
from itertools import cycle import pytest from ....webhook.models import WebhookEvent from .utils import ( prepare_async_and_sync_events, prepare_async_event, prepare_sync_event, ) @pytest.fixture def events_cycle(): return cycle( ( prepare_async_and_sync_events, prep...
34
703
mlflow
tests/store/tracking/sqlalchemy_store/test_sqlalchemy_store_review_queues.py
.py
import time from unittest import mock import pytest from sqlalchemy.exc import IntegrityError from sqlalchemy.orm import Session from mlflow.exceptions import MlflowException from mlflow.genai.label_schemas.label_schemas import InputPassFail from mlflow.genai.review_queues import ReviewItemType, ReviewQueueType, Revi...
1,115
50,578
cvxpy
cvxpy/reductions/eliminate_pwl/canonicalizers/dotsort_canon.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 https://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software...
46
1,542
django-cms
cms/tests/test_security.py
.py
from django.conf import settings from django.contrib.auth import get_user_model from django.http import QueryDict from cms.api import add_plugin, create_page from cms.models.pluginmodel import CMSPlugin from cms.test_utils.testcases import CMSTestCase class SecurityTests(CMSTestCase): """ Test security issue...
223
10,314
cvxpy
cvxpy/reductions/dcp2cone/canonicalizers/von_neumann_entr_canon.py
.py
""" Copyright 2022, 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, soft...
63
1,979
pyomo
doc/OnlineDocs/src/data/table4.py
.py
# ____________________________________________________________________________________ # # Pyomo: Python Optimization Modeling Objects # Copyright (c) 2008-2026 National Technology and Engineering Solutions of Sandia, LLC # Under the terms of Contract DE-NA0003525 with National Technology and Engineering # Solutions of...
22
777
mlflow
mlflow/telemetry/client.py
.py
import atexit import importlib import os import random import sys import threading import time import urllib.parse import uuid import warnings from dataclasses import asdict from functools import lru_cache from queue import Empty, Full, Queue from typing import Any, Callable, Literal import requests from mlflow.envir...
578
20,575
mlflow
examples/openai/completions.py
.py
import os import openai import mlflow from mlflow.models.signature import ModelSignature from mlflow.types.schema import ColSpec, ParamSchema, ParamSpec, Schema assert "OPENAI_API_KEY" in os.environ, " OPENAI_API_KEY environment variable must be set" print( """ # ************************************************...
57
1,869
mlflow
tests/spark/test_sparkml_param_integration.py
.py
from pyspark.ml.param import Param as SparkMLParam from pyspark.ml.util import Identifiable from mlflow.entities import Param def test_spark_integration(): key = SparkMLParam(Identifiable(), "name", "doc") value = 123 param = Param(key, value) assert param.key == "name" assert param.value == "123...
13
322
readthedocs.org
readthedocs/core/history.py
.py
from functools import partial import structlog from django import forms from django.db import models from django.utils.translation import gettext_lazy as _ from simple_history.admin import SimpleHistoryAdmin from simple_history.models import HistoricalRecords from simple_history.utils import update_change_reason log...
162
4,951
metrics
tests/integrations/conftest.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...
34
1,210
beam
sdks/python/apache_beam/tools/sideinput_microbenchmark.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 ...
81
2,776
ipython
IPython/core/display_functions.py
.py
"""Top-level display functions for displaying object in different formats.""" # Copyright (c) IPython Development Team. # Distributed under the terms of the Modified BSD License. from binascii import b2a_hex import os import sys __all__ = ['display', 'clear_output', 'publish_display_data', 'update_display', 'Displa...
371
12,399
gunicorn
tests/docker/asgi_framework_compat/frameworks/contract.py
.py
""" ASGI Framework Contract Definition This module defines the required endpoints that each framework must implement for compatibility testing with gunicorn's ASGI worker. """ # HTTP Endpoints Contract HTTP_ENDPOINTS = { "health": { "path": "/health", "method": "GET", "description": "Healt...
144
3,567
pyomo
examples/pyomobook/abstract-ch/param1.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...
29
997
python-prompt-toolkit
src/prompt_toolkit/eventloop/inputhook.py
.py
""" Similar to `PyOS_InputHook` of the Python API, we can plug in an input hook in the asyncio event loop. The way this works is by using a custom 'selector' that runs the other event loop until the real selector is ready. It's the responsibility of this event hook to return when there is input ready. There are two w...
194
6,148
probability
tensorflow_probability/python/experimental/fastgp/linalg_test.py
.py
# Copyright 2024 The TensorFlow Probability Authors. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law o...
89
2,943
wandb
tests/system_tests/test_functional/xgboost/regression.py
.py
import pathlib import numpy as np import pandas as pd import wandb import xgboost as xgb from sklearn.metrics import mean_squared_error from sklearn.model_selection import train_test_split from wandb.integration.xgboost import WandbCallback # Generated using: # # from sklearn.datasets import fetch_california_housin...
50
1,306
biopython
Bio/__init__.py
.py
# Copyright 1999-2003 by Jeffrey Chang. 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. """Collection of mod...
148
5,416
pyfilesystem2
fs/ftpfs.py
.py
"""Manage filesystems on remote FTP servers. """ from __future__ import print_function, unicode_literals import typing import array import calendar import datetime import io import itertools import socket import threading from collections import OrderedDict from contextlib import contextmanager from ftplib import FT...
909
30,138
kafka
tests/kafkatest/tests/core/snapshot_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 ...
260
12,814
sqlmap
lib/request/methodrequest.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.convert import getText from thirdparty.six.moves import urllib as _urllib class MethodRequest(_urllib.request.Request): """ Used to create HEAD/PUT/DELETE/....
21
589
readthedocs.org
readthedocs/rtd_tests/tests/test_resolver.py
.py
import django_dynamic_fixture as fixture from django.test import TestCase, override_settings from django_dynamic_fixture import get from readthedocs.builds.constants import EXTERNAL from readthedocs.builds.models import Version from readthedocs.core.resolver import Resolver from readthedocs.projects.constants import (...
1,094
41,122
openvino
tests/layer_tests/tensorflow_tests/test_tf_Cumsum.py
.py
# Copyright (C) 2018-2026 Intel Corporation # SPDX-License-Identifier: Apache-2.0 import numpy as np import pytest from common.tf_layer_test_class import CommonTFLayerTest # Testing Cumsum operation # Documentation: https://www.tensorflow.org/api_docs/python/tf/raw_ops/Cumsum class TestCumsum(CommonTFLayerTest): ...
112
4,230
beam
sdks/python/apache_beam/io/azure/blobstorageio_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...
92
3,211
mlflow
mlflow/genai/discovery/__init__.py
.py
from mlflow.genai.discovery.entities import DiscoverIssuesResult, Issue __all__ = ["DiscoverIssuesResult", "Issue"]
4
117
beam
sdks/python/apache_beam/testing/benchmarks/nexmark/queries/nexmark_query_util.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...
92
2,348
wagtail
wagtail/documents/admin.py
.py
from django.conf import settings from django.contrib import admin from wagtail.documents.models import Document if ( hasattr(settings, "WAGTAILDOCS_DOCUMENT_MODEL") and settings.WAGTAILDOCS_DOCUMENT_MODEL != "wagtaildocs.Document" ): # This installation provides its own custom document class; # to avo...
16
457
pyro
examples/lda.py
.py
# Copyright (c) 2017-2019 Uber Technologies, Inc. # SPDX-License-Identifier: Apache-2.0 """ This example implements amortized Latent Dirichlet Allocation [1], demonstrating how to marginalize out discrete assignment variables in a Pyro model. This model and inference algorithm treat documents as vectors of categorical...
171
6,848
mlflow
tests/tracing/otel/test_span_translation.py
.py
import json from typing import Any from unittest import mock import pytest from mlflow.entities.span import Span, SpanType from mlflow.tracing.constant import SpanAttributeKey, TokenUsageKey from mlflow.tracing.otel.translation import ( sanitize_attributes, translate_loaded_span, translate_span_type_from_...
943
32,345
hatch
src/hatch/utils/fs.py
.py
from __future__ import annotations import os import pathlib import sys from contextlib import contextmanager, suppress from functools import cached_property from typing import TYPE_CHECKING, Any from hatch.utils.structures import EnvVars if TYPE_CHECKING: from collections.abc import Generator from _typeshed...
159
4,377
kafka
release/templates.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...
308
13,752
openvino
src/frontends/paddle/tests/test_models/gen_scripts/generate_tile.py
.py
# Copyright (C) 2018-2026 Intel Corporation # SPDX-License-Identifier: Apache-2.0 # # tile paddle model generator # import numpy as np from save_model import saveModel import paddle import sys def paddle_tile(name: str, x, repeat_times, to_tensor=False, tensor_list=False): paddle.enable_static() with paddle...
95
2,820
astropy
astropy/units/format/cds_parsetab.py
.py
# Licensed under a 3-clause BSD style license - see LICENSE.rst # This file was automatically generated from ply. To re-generate this file, # remove it from this folder, then build astropy and run the tests in-place: # # python setup.py build_ext --inplace # pytest astropy/units # # You can then commit the changes...
62
5,102
astropy
astropy/units/tests/test_logarithmic.py
.py
# Licensed under a 3-clause BSD style license - see LICENSE.rst """ Test the Logarithmic Units and Quantities """ import pickle import numpy as np import pytest from numpy.testing import assert_allclose from astropy import constants as c from astropy import units as u from astropy.tests.helper import assert_quantity...
1,064
37,293
coremltools
coremltools/converters/mil/mil/types/get_type_info.py
.py
# Copyright (c) 2020, Apple Inc. All rights reserved. # # Use of this source code is governed by a BSD-3-clause license that can be # found in the LICENSE.txt file or at https://opensource.org/licenses/BSD-3-Clause from .type_spec import FunctionType, Type from .type_void import void def get_python_method_type(py...
60
2,123
onnx
onnx/reference/ops/op_sigmoid.py
.py
# Copyright (c) ONNX Project Contributors # SPDX-License-Identifier: Apache-2.0 from __future__ import annotations import numpy as np from onnx.reference.ops._op import OpRunUnaryNum def sigmoid(x: np.ndarray) -> np.ndarray: """Numerically stable sigmoid implementation that supports scalars and nd-arrays.""" ...
28
680
pyomo
pyomo/core/tests/unit/test_var_set_bounds.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...
263
10,502
coremltools
coremltools/converters/sklearn/_decision_tree_regressor.py
.py
# Copyright (c) 2017, Apple Inc. All rights reserved. # # Use of this source code is governed by a BSD-3-clause license that can be # found in the LICENSE.txt file or at https://opensource.org/licenses/BSD-3-Clause from ..._deps import _HAS_SKLEARN from ...models import MLModel as _MLModel from ._tree_ensemble import ...
55
1,530
django-cms
cms/test_utils/project/sampleapp/urls.py
.py
from django.urls import include, re_path from django.utils.translation import gettext_lazy as _ from . import views """ Also used in cms.tests.ApphooksTestCase """ urlpatterns = [ re_path(r'^$', views.sample_view, {'message': 'sample root page', }, name='sample-root'), re_path(r'^exempt/$', views.exempt_view,...
23
1,337
jupytext
tests/functional/others/test_trust_notebook.py
.py
""" A notebook is trusted when all its outputs are trusted. Hence, a trusted notebook that is updated using Jupytext should remain trusted, as no new outputs are added. """ import os import shutil import pytest from jupyter_server.utils import ensure_async from nbformat.v4.nbbase import new_code_cell, new_notebook, n...
321
10,954
colorama
demos/demo01.py
.py
#!/usr/bin/python # Copyright Jonathan Hartley 2013. BSD 3-Clause license, see LICENSE file. # print grid of all colors and brightnesses # uses stdout.write to write chars with no newline nor spaces between them # This should run more-or-less identically on Windows and Unix. import sys # Add parent dir to sys path, s...
48
2,019
readthedocs.org
readthedocs/search/api/v3/queryparser.py
.py
class TextToken: def __init__(self, text): self.text = text class ArgumentToken: def __init__(self, *, name, value, type): self.name = name self.value = value self.type = type class SearchQueryParser: """Simplified and minimal parser for ``name:value`` expressions.""" ...
77
2,370
gunicorn
gunicorn/http2/connection.py
.py
# -*- coding: utf-8 - # # This file is part of gunicorn released under the MIT license. # See the NOTICE for more information. """ HTTP/2 server connection implementation. Uses the hyper-h2 library for HTTP/2 protocol handling. """ from io import BytesIO from .errors import ( HTTP2Error, HTTP2ProtocolError, HTT...
664
22,596
biopython
Bio/PDB/parse_pdb_header.py
.py
#!/usr/bin/env python # Copyright 2004 Kristian Rother. # Revisions copyright 2004 Thomas Hamelryck. # Revisions copyright 2024 James Krieger. # # 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 fi...
373
13,618
structlog
src/structlog/_utils.py
.py
# SPDX-License-Identifier: MIT OR Apache-2.0 # This file is dual licensed under the terms of the Apache License, Version # 2.0, and the MIT License. See the LICENSE file in the root of this # repository for complete details. """ Generic utilities. """ from __future__ import annotations import sys from contextlib i...
31
933
saleor
saleor/asgi/tests/conftest.py
.py
import pytest from asgiref.typing import ( ASGI3Application, ASGIReceiveCallable, ASGISendCallable, HTTPResponseBodyEvent, HTTPResponseStartEvent, Scope, ) @pytest.fixture def asgi_app() -> ASGI3Application: async def fake_app( scope: Scope, receive: ASGIReceiveCallable, send: ASGI...
55
1,417
sqlmap
lib/core/compat.py
.py
#!/usr/bin/env python """ Copyright (c) 2006-2026 sqlmap developers (https://sqlmap.org) See the file 'LICENSE' for copying permission """ from __future__ import division import codecs import binascii import functools import io import math import os import random import re import sys import time import uuid class W...
420
12,167
metrics
src/torchmetrics/functional/text/ter.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...
599
23,280
biopython
Tests/test_Tutorial.py
.py
# Copyright 2011-2023 by Peter Cock. All rights reserved. # Revisions copyright 2019 by Anil Tuncel. 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. # # This script looks for e...
309
10,038
wagtail
wagtail/admin/widgets/slug.py
.py
import json import re from django.conf import settings from django.forms import widgets from wagtail.coreutils import get_js_regex class SlugInput(widgets.TextInput): """ Associates the input field with the Stimulus w-slug (CleanController). Slugifies content based on ``WAGTAIL_ALLOW_UNICODE_SLUGS`` and...
75
2,849
pyro
pyro/distributions/hmm.py
.py
# Copyright (c) 2017-2019 Uber Technologies, Inc. # SPDX-License-Identifier: Apache-2.0 import torch import torch.nn.functional as F from pyro.ops.gamma_gaussian import ( GammaGaussian, gamma_and_mvn_to_gamma_gaussian, gamma_gaussian_tensordot, matrix_and_mvn_to_gamma_gaussian, ) from pyro.ops.gaussia...
1,318
54,265
ipython
IPython/lib/guisupport.py
.py
""" Support for creating GUI apps and starting event loops. IPython's GUI integration allows interactive plotting and GUI usage in IPython session. IPython has two different types of GUI integration: 1. The terminal based IPython supports GUI event loops through Python's PyOS_InputHook. PyOS_InputHook is a hook th...
155
6,284
saleor
saleor/graphql/payment/mutations/transaction/transaction_update.py
.py
from typing import TYPE_CHECKING, Optional import graphene from django.core.exceptions import ValidationError from .....app.models import App from .....core.exceptions import PermissionDenied from .....order.events import transaction_event as order_transaction_event from .....payment import models as payment_models f...
269
9,842
onnx
tests/python/model_inference_test.py
.py
# Copyright (c) ONNX Project Contributors # SPDX-License-Identifier: Apache-2.0 from __future__ import annotations import typing import pytest import onnx import onnx.parser import onnx.shape_inference class TestModelInference: def _check(self, model_text: str, *expected: int): """Check that the model...
273
9,319
wagtail
wagtail/embeds/finders/facebook.py
.py
import json from urllib import request as urllib_request from urllib.error import HTTPError, URLError from urllib.parse import urlencode from urllib.request import Request from wagtail.embeds.exceptions import EmbedException, EmbedNotFoundException from .oembed import OEmbedFinder class AccessDeniedFacebookOEmbedEx...
104
3,853
clearml
examples/frameworks/pytorch/pytorch_tensorboardx.py
.py
# ClearML - Example of pytorch with tensorboardX # from __future__ import print_function import argparse import os from tempfile import gettempdir import torch import torch.nn as nn import torch.nn.functional as F import torch.optim as optim from tensorboardX import SummaryWriter from torch.autograd import Variable f...
210
6,165