label stringlengths 1 61 | code stringlengths 4k 8k | code_compressed null |
|---|---|---|
set up class | # python-holidays
# ---------------
# A fast, efficient Python library for generating country, province and state
# specific sets of holidays on the fly. It aims to make determining whether a
# specific date is a holiday as fast and flexible as possible.
#
# Authors: dr-prodigy <dr.prodigy.github@gmail.com> (c) 2... | null |
str indent | import re, inspect, textwrap, pydoc
from docscrape import NumpyDocString, FunctionDoc, ClassDoc
from six import iteritems
class SphinxDocString(NumpyDocString):
# string conversion routines
def _str_header(self, name, symbol='`'):
return ['.. rubric:: ' + name, '']
def _str_field_list(self, name):... | null |
set mkl envs | #!/usr/bin/python
from __future__ import absolute_import
from __future__ import division
from __future__ import print_function
import json
import os
import sys
import subprocess as sp
DEFAULT_SEASTAR_PORT="3333"
JEMALLOC_244 = "libjemalloc.so.2.4.4"
JEMALLOC_251 = "libjemalloc.so.2.5.1"
def gen_cluster_info(worksp... | null |
asym enc | # Copyright (c) 2023, NVIDIA CORPORATION. All rights reserved.
#
# 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 appli... | null |
test monitors pg | import os
import json
from bgpcfgd.template import TemplateFabric
from bgpcfgd.config import ConfigMgr
from .util import load_constants_dir_mappings
TEMPLATE_PATH = os.path.abspath('../../dockers/docker-fpm-frr/frr')
def load_tests(peer_type, template_name):
constants = load_constants_dir_mappings()
path ... | null |
webhook payment gateway initialize tokenization response | import json
import graphene
import mock
import pytest
from ....core.models import EventDelivery
from ....payment.interface import (
PaymentGatewayInitializeTokenizationRequestData,
PaymentGatewayInitializeTokenizationResponseData,
PaymentGatewayInitializeTokenizationResult,
)
from ....settings import WEBH... | null |
test mobile get unauthenticated user | """
Tests for reset deadlines endpoint.
"""
import datetime
import ddt
from django.urls import reverse
from django.utils import timezone
from edx_toggles.toggles.testutils import override_waffle_flag
from common.djangoapps.course_modes.models import CourseMode
from common.djangoapps.student.models import CourseEnroll... | null |
run test | #
# This script needs to be run on startup
# qemu -kernel ${KERNEL} -s -S
# and then:
# gdb ${KERNEL}.vmlinux -x ${QEMU_SRC}/tests/guest-debug/test-gdbstub.py
import gdb
failcount = 0
def report(cond, msg):
"Report success/fail of test"
if cond:
print ("PASS: %s" % (msg))
else:
print ("F... | null |
fp16 to fp32 | #!/usr/bin/env python3
# Copyright (c) Meta Platforms, Inc. and affiliates.
# All rights reserved.
#
# This source code is licensed under the BSD-style license found in the
# LICENSE file in the root directory of this source tree.
import logging
import torch
logger: logging.Logger = logging.getLogger()
try:
# p... | null |
get six digit naics count | from rest_framework.request import Request
from rest_framework.response import Response
from rest_framework.views import APIView
from django.db.models.functions import Length
from django.db.models import Q
from usaspending_api.common.cache_decorator import cache_response
from usaspending_api.common.validator.tinyshiel... | null |
test ties broken alphabetically | # These tests are auto-generated with test data from:
# https://github.com/exercism/problem-specifications/tree/main/exercises/tournament/canonical-data.json
# File last updated on 2023-07-19
import unittest
from tournament import (
tally,
)
class TournamentTest(unittest.TestCase):
def test_just_the_header_... | null |
get severity level | # Copyright (c) Microsoft Corporation. All rights reserved.
# Licensed under the MIT License.
import logging
from typing import Sequence, Any
from opentelemetry._logs.severity import SeverityNumber
from opentelemetry.semconv.trace import SpanAttributes
from opentelemetry.sdk._logs import LogData
from opentelemetry.sdk... | null |
delete empty color blocks | # Authors: see git history
#
# Copyright (c) 2010 Authors
# Licensed under the GNU GPL version 3.0 or later. See the file LICENSE for details.
from sys import exit
from typing import List
from inkex import errormsg
from ..i18n import _
from ..svg import PIXELS_PER_MM
from ..utils.geometry import Point
from ..utils.... | null |
test print topic help with devel for | # -*- Mode:Python; indent-tabs-mode:nil; tab-width:4 -*-
#
# Copyright (C) 2015-2018 Canonical Ltd
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License version 3 as
# published by the Free Software Foundation.
#
# This program is distributed in ... | null |
test type raises for unknown type of | import pytest
from h import models
from h.models.group import AUTHORITY_PROVIDED_ID_MAX_LENGTH, ReadableBy, WriteableBy
def test_init_sets_given_attributes():
group = models.Group(name="My group", authority="example.com", enforce_scope=False)
assert group.name == "My group"
assert group.authority == "ex... | null |
prep param lists | import torch
import torch.nn as nn
from torch.autograd import Variable
from torch._utils import _flatten_dense_tensors, _unflatten_dense_tensors
class tofp16(nn.Module):
"""
Utility module that implements::
def forward(self, input):
return input.half()
"""
def __init__(self):
... | null |
test results display | import pytest
from grandchallenge.components.models import (
ComponentInterface,
ComponentInterfaceValue,
)
from grandchallenge.evaluation.models import Evaluation, Phase
from grandchallenge.evaluation.tasks import calculate_ranks
from tests.evaluation_tests.factories import EvaluationFactory, PhaseFactory
fro... | null |
nptensor2np | from typing import Tuple, Type
import numpy as np
from ..image_utils import MAX_VALUES_BY_DTYPE, as_3d
def np_denorm(x: np.ndarray, min_max: Tuple[float, float] = (-1.0, 1.0)) -> np.ndarray:
"""Denormalize from [-1,1] range to [0,1]
formula: xi' = (xi - mu)/sigma
Example: "out = (x + 1.0) / 2.0" for den... | null |
simple policy | """Test the flask oso plugin."""
from pathlib import Path
import pytest
from flask import Flask
from oso import Oso, OsoError
from werkzeug.exceptions import Forbidden
from flask_oso import FlaskOso, authorize, skip_authorization
@pytest.fixture
def flask_app():
return Flask("test")
@pytest.fixture
def oso():... | null |
slice | #!/usr/bin/env python3
# Copyright (c) Facebook, Inc. and its affiliates.
# All rights reserved.
#
# The following code has been taken from
# https://github.com/facebookresearch/DPR, which is CC-BY-NC 4.0
# licensed as of now. More details on the license can be found
# at https://github.com/facebookresearch/DPR/blob/m... | null |
build | from conan import ConanFile
from conan.errors import ConanInvalidConfiguration
from conan.tools.files import apply_conandata_patches, chdir, collect_libs, copy, export_conandata_patches, get, replace_in_file, rm, rmdir
from conan.tools.microsoft import is_msvc
from conan.tools.scm import Version
from conans import Auto... | null |
main | # Developed for module tiericide, this script will quickly print out a market
# conversion map based on patch notes, as well as database conversion mapping.
import argparse
import os.path
import sqlite3
import sys
# Add eos root path to sys.path so we can import ourselves
path = os.path.dirname(__file__)
sys.path.app... | null |
test set api key | import json
from pathlib import Path
from unittest.mock import MagicMock, Mock, patch
from urllib.parse import unquote_plus
import pytest
from tribler.gui.utilities import TranslatedString, compose_magnetlink, create_api_key, dict_item_is_any_of, \
duration_to_string, format_api_key, get_i18n_file_path, get_langu... | null |
test writing and reading registers | """Tests for Alazar DLL API
This suite of tests is expected to be executed on a Windows PC with a single
Alazar board installed.
"""
import gc
import logging
import os
from weakref import WeakValueDictionary
import pytest
from pytest import LogCaptureFixture
from qcodes.instrument_drivers.AlazarTech.ATS import Alaz... | null |
test empty play | # (c) 2012-2014, Michael DeHaan <michael.dehaan@gmail.com>
#
# This file is part of Ansible
#
# Ansible is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) an... | null |
roi align common | # Licensed to the Apache Software Foundation (ASF) under one
# or more contributor license agreements. See the NOTICE file
# distributed with this work for additional information
# regarding copyright ownership. The ASF licenses this file
# to you under the Apache License, Version 2.0 (the
# "License"); you may not u... | null |
test main | """Test suite for the cProfile module."""
import sys
from test.test_support import run_unittest, TESTFN, unlink
# rip off all interesting stuff from test_profile
import cProfile
from test.test_profile import ProfileTest, regenerate_expected_output
class CProfileTest(ProfileTest):
profilerclass = cProfile.Profile... | null |
get statistics | # -*- coding: utf-8 -*-
#
# http://www.privacyidea.org
#
# 2018-08-01 Cornelius Kölbel, <cornelius.koelbel@netknights.it>
# Initial writeup
#
# This code is free software; you can redistribute it and/or
# modify it under the terms of the GNU AFFERO GENERAL PUBLIC LICENSE
# License as published by the Free So... | null |
on attachment revision post save | import os
from django.conf import settings as django_settings
from django.db import models
from django.db.models import signals
from django.utils.translation import gettext
from django.utils.translation import gettext_lazy as _
from wiki import managers
from wiki.decorators import disable_signal_for_loaddata
from wiki... | null |
End of preview. Expand in Data Studio
README.md exists but content is empty.
- Downloads last month
- 5