code stringlengths 1 25.8M | language stringclasses 18
values | source stringclasses 4
values | repo stringclasses 78
values | path stringlengths 0 268 |
|---|---|---|---|---|
import collections
import gc
import logging
import os
import re
import sys
import time
import warnings
from contextlib import contextmanager
from functools import wraps
from inspect import iscoroutinefunction
from io import StringIO
from itertools import chain
from types import SimpleNamespace
from unittest import Test... | python | github | https://github.com/django/django | django/test/utils.py |
# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
from __future__ import annotations
from typing_extensions import Literal, Required, TypedDict
__all__ = ["ToolChoiceFunctionParam"]
class ToolChoiceFunctionParam(TypedDict, total=False):
"""Use this option to force the model t... | python | github | https://github.com/openai/openai-python | src/openai/types/responses/tool_choice_function_param.py |
#!/usr/bin/env python
# pylint: disable=missing-docstring
#
# Copyright 2017 Red Hat, Inc. and/or its affiliates
# and other contributors as indicated by the @author tags.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obt... | unknown | codeparrot/codeparrot-clean | ||
# Copyright 2024 The HuggingFace Team. 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 applicabl... | python | github | https://github.com/huggingface/transformers | src/transformers/models/conditional_detr/__init__.py |
# Copyright 2010 Michael Murr
#
# This file is part of LibForensics.
#
# LibForensics 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 ver... | unknown | codeparrot/codeparrot-clean | ||
# Copyright 2015 Google Inc. 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 applicable law or a... | unknown | codeparrot/codeparrot-clean | ||
# Copyright (c) 2010 Olivier Grisel <olivier.grisel@ensta.org>
# License: BSD 3 clause
"""Glue code to load http://mlcomp.org data as a scikit.learn dataset"""
import os
import numbers
from sklearn.datasets.base import load_files
def _load_document_classification(dataset_path, metadata, set_=None, **kwargs):
if s... | unknown | codeparrot/codeparrot-clean | ||
# -*- coding: utf-8 -*-
# Unit and doctests for specific database backends.
from __future__ import with_statement, absolute_import
import datetime
import threading
from django.conf import settings
from django.core.management.color import no_style
from django.core.exceptions import ImproperlyConfigured
from django.db ... | unknown | codeparrot/codeparrot-clean | ||
package kotlinx.coroutines.test
import kotlinx.coroutines.*
import kotlinx.coroutines.testing.*
import kotlin.test.*
import kotlin.test.assertFailsWith
@Suppress("DEPRECATION", "DEPRECATION_ERROR")
class TestRunBlockingTest {
@Test
fun delay_advancesTimeAutomatically() = runBlockingTest {
assertRunsF... | kotlin | github | https://github.com/Kotlin/kotlinx.coroutines | kotlinx-coroutines-test/jvm/test/migration/TestRunBlockingTest.kt |
#!/usr/bin/env python
# ----------------------------------------------------------------------
# Numenta Platform for Intelligent Computing (NuPIC)
# Copyright (C) 2014, Numenta, Inc. Unless you have an agreement
# with Numenta, Inc., for a separate license for this software code, the
# following terms and conditions ... | unknown | codeparrot/codeparrot-clean | ||
from lib.common import helpers
class Module:
def __init__(self, mainMenu, params=[]):
self.info = {
'Name': 'Restore-ServiceEXE',
'Author': ['@harmj0y'],
'Description': ("Restore a backed up service binary."),
'Background' : True,
'OutputExt... | unknown | codeparrot/codeparrot-clean | ||
# Copyright (C) 2015 The Debsources developers <info@sources.debian.net>.
# See the AUTHORS file at the top-level directory of this distribution and at
# https://anonscm.debian.org/gitweb/?p=qa/debsources.git;a=blob;f=AUTHORS;hb=HEAD
#
# This file is part of Debsources. Debsources is free software: you can
# redistrib... | unknown | codeparrot/codeparrot-clean | ||
from django.db.models import Value as V
from django.db.models.functions import Lower, StrIndex, Substr, Upper
from django.test import TestCase
from ..models import Author
class SubstrTests(TestCase):
def test_basic(self):
Author.objects.create(name="John Smith", alias="smithj")
Author.objects.crea... | python | github | https://github.com/django/django | tests/db_functions/text/test_substr.py |
/* Copyright 2023 The TensorFlow Authors. 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 applicable law or a... | c | github | https://github.com/tensorflow/tensorflow | tensorflow/core/tfrt/stubs/model_config_stub.h |
name: PR (Base)
# All PRs touching code will run tests on ubuntu/node/chromium
on:
pull_request:
paths-ignore:
- ".changeset/**"
- "decisions/**"
- "docs/**"
- "examples/**"
- "jest/**"
- "scripts/**"
- "tutorial/**"
- "contributors.yml"
- "**/*.md"
concurr... | unknown | github | https://github.com/remix-run/react-router | .github/workflows/integration-pr-ubuntu.yml |
// Copyright 2011 Google Inc. All Rights Reserved.
//
// Use of this source code is governed by a BSD-style license
// that can be found in the COPYING file in the root of the source
// tree. An additional intellectual property rights grant can be found
// in the file PATENTS. All contributing project authors may
// be... | c | github | https://github.com/opencv/opencv | 3rdparty/libwebp/src/dsp/upsampling.c |
use std::io;
use actix_codec::Framed;
use actix_http::{body::BodySize, h1, ws, Error, HttpService, Request, Response};
use actix_http_test::test_server;
use actix_utils::future::ok;
use bytes::Bytes;
use futures_util::{SinkExt as _, StreamExt as _};
async fn ws_service(req: ws::Frame) -> Result<ws::Message, io::Error... | rust | github | https://github.com/actix/actix-web | awc/tests/test_ws.rs |
"""Contains various types of button widgets."""
from pygame.locals import *
from .const import *
from . import widget, surface
from . import basic
class _button(widget.Widget):
# The underlying 'value' accessed by the getter and setters below
_value = None
def __init__(self,**params):
widget.Wid... | unknown | codeparrot/codeparrot-clean | ||
#
# Copyright 2010-2012 Free Software Foundation, Inc.
#
# This file is part of GNU Radio
#
# GNU Radio 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, or (at your option)
# any later version... | unknown | codeparrot/codeparrot-clean | ||
<?php
namespace Symfony\Bundle\FrameworkBundle\Tests\Fixtures;
class DeclaredClass
{
} | php | github | https://github.com/symfony/symfony | src/Symfony/Bundle/FrameworkBundle/Tests/Fixtures/DeclaredClass.php |
/*
* Version information
*
* Copyright The Mbed TLS Contributors
* SPDX-License-Identifier: Apache-2.0 OR GPL-2.0-or-later
*/
#include "common.h"
#if defined(MBEDTLS_VERSION_C)
#include "mbedtls/version.h"
#include <string.h>
unsigned int mbedtls_version_get_number(void)
{
return MBEDTLS_VERSION_NUMBER;... | c | github | https://github.com/nodejs/node | deps/LIEF/third-party/mbedtls/library/version.c |
# -*- coding: utf-8 -*-
# This file is part of beets.
# Copyright 2016, Adrian Sampson.
#
# Permission is hereby granted, free of charge, to any person obtaining
# a copy of this software and associated documentation files (the
# "Software"), to deal in the Software without restriction, including
# without limitation t... | unknown | codeparrot/codeparrot-clean | ||
from adherents.models import Adherent, Subscription, SubscriptionType
from adherents.serializers import (AdherentSerializer, AdherentShortSerializer,
SubscribeSerializer, SubscriptionSerializer,
SubscriptionTypeSerializer)
from django.contrib.auth im... | unknown | codeparrot/codeparrot-clean | ||
// This file is part of ICU4X. For terms of use, please see the file
// called LICENSE at the top level of the ICU4X source tree
// (online at: https://github.com/unicode-org/icu4x/blob/main/LICENSE ).
use crate::LanguageIdentifier;
use databake::*;
impl Bake for LanguageIdentifier {
fn bake(&self, env: &CrateEnv... | rust | github | https://github.com/nodejs/node | deps/crates/vendor/icu_locale_core/src/databake.rs |
# -*- coding: utf-8 -*-
from south.utils import datetime_utils as datetime
from south.db import db
from south.v2 import SchemaMigration
from django.db import models
class Migration(SchemaMigration):
def forwards(self, orm):
# Adding model 'InCourseReverificationConfiguration'
db.create_table('veri... | unknown | codeparrot/codeparrot-clean | ||
//// [tests/cases/conformance/types/typeRelationships/assignmentCompatibility/callSignatureAssignabilityInInheritance2.ts] ////
//// [callSignatureAssignabilityInInheritance2.ts]
// checking subtype relations for function types as it relates to contextual signature instantiation
class Base { foo: string; }
class Deri... | javascript | github | https://github.com/microsoft/TypeScript | tests/baselines/reference/callSignatureAssignabilityInInheritance2.js |
from __future__ import absolute_import
# Base Exceptions
class HTTPError(Exception):
"Base exception used by this module."
pass
class HTTPWarning(Warning):
"Base warning used by this module."
pass
class PoolError(HTTPError):
"Base exception for errors caused within a pool."
def __init__(self,... | unknown | codeparrot/codeparrot-clean | ||
"""
Support for functionality to download files.
For more details about this component, please refer to the documentation at
https://home-assistant.io/components/downloader/
"""
import logging
import os
import re
import threading
import requests
import voluptuous as vol
from homeassistant.helpers import validate_con... | unknown | codeparrot/codeparrot-clean | ||
import time
from pageobjects.environments import Environments, Wizard
from pageobjects.networks import Networks, NeutronParameters
from pageobjects.nodes import Nodes
from pageobjects.settings import Settings
from pageobjects.tabs import Tabs
from settings import OPENSTACK_CENTOS, OPENSTACK_RELEASE_CENTOS
from tests.ba... | unknown | codeparrot/codeparrot-clean | ||
# Copyright (c) 2013 by Gilbert Ramirez <gram@alumni.rice.edu>
#
# This program 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 2
# of the License, or (at your option) any later version.
#
# Thi... | unknown | codeparrot/codeparrot-clean | ||
# -*- coding: utf-8 -*-
# Copyright 2015, Dario Blanco
"""
This module tests capablanca.piece
"""
from capablanca import piece
def test_king_positions():
"""Should return proper threat positions when moving a King"""
king = piece.King(3, 3)
assert king.get_threats((1, 1)) == set([
(0, 0), (1, 0),... | unknown | codeparrot/codeparrot-clean | ||
from curio import run, spawn
from curio.socket import *
async def echo_server(address):
sock = socket(AF_INET, SOCK_STREAM)
sock.setsockopt(SOL_SOCKET, SO_REUSEADDR, 1)
sock.bind(address)
sock.listen(5)
print('Server listening at', address)
async with sock:
while True:
clien... | unknown | codeparrot/codeparrot-clean | ||
#! /usr/bin/env python3
import unittest
from test import support
import __future__
GOOD_SERIALS = ("alpha", "beta", "candidate", "final")
features = __future__.all_feature_names
class FutureTest(unittest.TestCase):
def test_names(self):
# Verify that all_feature_names appears correct.
given_feat... | unknown | codeparrot/codeparrot-clean | ||
#!/usr/bin/env python
import sys
from netmiko import ConnectHandler
import re
import time
from getpass import getpass
def send_command(rconn,cmd,my_prompt):
rconn.sendline(cmd)
rconn.expect(my_prompt)
return rconn.before
def main():
password = getpass()
py_router_1 = {
'device_ty... | unknown | codeparrot/codeparrot-clean | ||
from __future__ import unicode_literals
from django.db import models
from django.db.migrations.operations.base import Operation
from django.db.migrations.state import ModelState
from django.db.models.options import normalize_together
from django.utils import six
from django.utils.functional import cached_property
fro... | unknown | codeparrot/codeparrot-clean | ||
use core::f32;
use super::sqrtf;
#[cfg_attr(all(test, assert_no_panic), no_panic::no_panic)]
pub fn hypotf(mut x: f32, mut y: f32) -> f32 {
let x1p90 = f32::from_bits(0x6c800000); // 0x1p90f === 2 ^ 90
let x1p_90 = f32::from_bits(0x12800000); // 0x1p-90f === 2 ^ -90
let mut uxi = x.to_bits();
let mut... | rust | github | https://github.com/nodejs/node | deps/crates/vendor/libm/src/math/hypotf.rs |
# -*- coding: utf-8 -*-
#
# Copyright 2017 F5 Networks Inc.
#
# 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) a... | unknown | codeparrot/codeparrot-clean | ||
import numpy as np
import pytest
import pandas.util._test_decorators as td
import pandas as pd
from pandas import (
DataFrame,
Index,
Series,
date_range,
isna,
)
import pandas._testing as tm
class TestDataFrameCov:
def test_cov(self, float_frame, float_string_frame):
# min_periods no ... | python | github | https://github.com/pandas-dev/pandas | pandas/tests/frame/methods/test_cov_corr.py |
def ascii_decode(*args,**kw):
pass
def ascii_encode(*args,**kw):
pass
def charbuffer_encode(*args,**kw):
pass
def charmap_build(*args,**kw):
pass
def charmap_decode(*args,**kw):
pass
def charmap_encode(*args,**kw):
pass
def decode(*args,**kw):
"""decode(obj, [encoding[,errors]]) -> obj... | unknown | codeparrot/codeparrot-clean | ||
// 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... | json | github | https://github.com/apache/kafka | clients/src/main/resources/common/message/HeartbeatRequest.json |
# Used by Makefile and configure for building Ruby.
# See common.mk and Makefile.in for details.
class File
sep = ("\\" if RUBY_PLATFORM =~ /mswin|bccwin|mingw/)
if sep != ALT_SEPARATOR
remove_const :ALT_SEPARATOR
ALT_SEPARATOR = sep
end
end
[[libpathenv, "."], [preloadenv, libruby_so]].each do |env, pa... | ruby | github | https://github.com/ruby/ruby | tool/fake.rb |
import termios
import tty
import re
class Cbreak(object):
def __init__(self, stream):
self.stream = stream
def __enter__(self):
self.original_stty = termios.tcgetattr(self.stream)
tty.setcbreak(self.stream, termios.TCSANOW)
return Termmode(self.stream, self.original_stty)
... | unknown | codeparrot/codeparrot-clean | ||
# coding=utf-8
# Copyright 2015 Pants project contributors (see CONTRIBUTORS.md).
# Licensed under the Apache License, Version 2.0 (see LICENSE).
from __future__ import absolute_import, division, print_function, unicode_literals
import queue
import sys
import threading
import traceback
from builtins import map, objec... | unknown | codeparrot/codeparrot-clean | ||
# coding=utf-8
# --------------------------------------------------------------------------
# Copyright (c) Microsoft Corporation. All rights reserved.
# Licensed under the MIT License. See License.txt in the project root for license information.
# Code generated by Microsoft (R) AutoRest Code Generator.
# Changes may ... | unknown | codeparrot/codeparrot-clean | ||
---
navigation_title: "Stemmer override"
mapped_pages:
- https://www.elastic.co/guide/en/elasticsearch/reference/current/analysis-stemmer-override-tokenfilter.html
---
# Stemmer override token filter [analysis-stemmer-override-tokenfilter]
Overrides stemming algorithms, by applying a custom mapping, then protecting... | unknown | github | https://github.com/elastic/elasticsearch | docs/reference/text-analysis/analysis-stemmer-override-tokenfilter.md |
'use strict';
const common = require('../common');
const fs = require('fs');
const path = require('path');
const bench = common.createBenchmark(main, {
n: [10],
dir: [ 'lib', 'test/parallel'],
withFileTypes: ['true', 'false'],
});
function main({ n, dir, withFileTypes }) {
withFileTypes = withFileTypes === '... | javascript | github | https://github.com/nodejs/node | benchmark/fs/bench-readdir.js |
/** @import { Expression } from 'estree' */
/** @import { AST } from '#compiler' */
/** @import { ComponentContext } from '../types.js' */
import * as b from '#compiler/builders';
/**
* @param {AST.DebugTag} node
* @param {ComponentContext} context
*/
export function DebugTag(node, context) {
context.state.templat... | javascript | github | https://github.com/sveltejs/svelte | packages/svelte/src/compiler/phases/3-transform/server/visitors/DebugTag.js |
#!/usr/bin/python
# 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) any later version.
#
# Ansible is distributed... | unknown | codeparrot/codeparrot-clean | ||
import unittest
import Tkinter
import ttk
from test.test_support import requires, run_unittest
import support
requires('gui')
class StyleTest(unittest.TestCase):
def setUp(self):
self.style = ttk.Style()
def test_configure(self):
style = self.style
style.configure('TButton', backgro... | unknown | codeparrot/codeparrot-clean | ||
"""Machine limits for Float32 and Float64 and (long double) if available...
"""
__all__ = ['finfo', 'iinfo']
import warnings
from .machar import MachAr
from .overrides import set_module
from . import numeric
from . import numerictypes as ntypes
from .numeric import array, inf
from .umath import log10, exp2
from . im... | unknown | codeparrot/codeparrot-clean | ||
# Module 'ntpath' -- common operations on WinNT/Win95 pathnames
"""Common pathname manipulations, WindowsNT/95 version.
Instead of importing this module directly, import os and refer to this
module as os.path.
"""
import os
import stat
import sys
__all__ = ["normcase","isabs","join","splitdrive","split","splitext",
... | unknown | codeparrot/codeparrot-clean | ||
"""
Defines arguments manipulation utilities, like checking if an argument is iterable, flattening a nested arguments list, etc.
These utility functions can be used by other util modules and are imported in util's main namespace for use by other pymel modules
"""
from collections import deque as _deque
import sys
impo... | unknown | codeparrot/codeparrot-clean | ||
# frozen_string_literal: true
module ActionText
class Editor::Configurator # :nodoc:
attr_reader :configurations
def initialize(configurations)
@configurations = configurations
end
def build(editor_name)
editor_class = resolve(editor_name.to_s)
options = config_for(editor_name.to_... | ruby | github | https://github.com/rails/rails | actiontext/lib/action_text/editor/configurator.rb |
#
# Copyright (C) 2007, Mark Lee
#
#http://rl-glue-ext.googlecode.com/
#
# 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 b... | unknown | codeparrot/codeparrot-clean | ||
"""
### Usage: ctdoc [-w]
### Options:
-h, --help show this help message and exit
-w, --web build web docs
-a, --auto use auto mode (even with a plugin)
-o, --omit omit any files from autodoc?
Run from cantools root (contains setup.py, cantools/, README.md, etc), from root
of a CT plugin, or from... | unknown | codeparrot/codeparrot-clean | ||
package command
import (
"context"
"crypto/tls"
"encoding/json"
"fmt"
"net"
"net/http"
"os"
"path/filepath"
"runtime"
"slices"
"strings"
"sync"
"time"
containerddefaults "github.com/containerd/containerd/v2/defaults"
"github.com/containerd/containerd/v2/pkg/tracing"
"github.com/containerd/log"
"githu... | go | github | https://github.com/moby/moby | daemon/command/daemon.go |
from django.contrib.webdesign.lorem_ipsum import words, paragraphs
from django import template
register = template.Library()
class LoremNode(template.Node):
def __init__(self, count, method, common):
self.count, self.method, self.common = count, method, common
def render(self, context):
try:
... | unknown | codeparrot/codeparrot-clean | ||
#!/usr/bin/python
#
# Copyright 2020 Google LLC
#
# 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 ag... | unknown | codeparrot/codeparrot-clean | ||
from __future__ import absolute_import
from typing import Any, Optional, Tuple, List, Set, Iterable, Mapping, Callable, Dict
from django.utils.translation import ugettext as _
from django.conf import settings
from django.db import transaction
from django.http import HttpRequest, HttpResponse
from zerver.lib.request i... | unknown | codeparrot/codeparrot-clean | ||
from __future__ import unicode_literals
import os
import re
from .common import InfoExtractor
from ..compat import (
compat_urllib_parse_unquote,
compat_urllib_parse_unquote_plus,
compat_urllib_parse_urlparse,
compat_urllib_request,
)
from ..utils import (
ExtractorError,
str_to_int,
)
from ..... | unknown | codeparrot/codeparrot-clean | ||
#
# formatter.py
#
# Convert parsed content blocks to a structured document (library file).
#
# Copyright 2002, 2004, 2007, 2008, 2014 by
# David Turner.
#
# This file is part of the FreeType project, and may only be used,
# modified, and distributed under the terms of the FreeType project
# license, LICENSE.T... | unknown | codeparrot/codeparrot-clean | ||
# Copyright (c) 2013, Web Notes Technologies Pvt. Ltd. and Contributors
# License: GNU General Public License v3. See license.txt
from __future__ import unicode_literals
import webnotes
from webnotes.utils import cint
class DocType:
def __init__(self,doc,doclist):
self.doc,self.doclist = doc,doclist
def validat... | unknown | codeparrot/codeparrot-clean | ||
#!/usr/bin/env bash
# Copyright 2015 The Kubernetes 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 applica... | unknown | github | https://github.com/kubernetes/kubernetes | cluster/gce/upgrade.sh |
// DUMP_CODE
// MODULE: context
// FILE: context.kt
inline fun <reified T> bar(x: Int, y: Int): Int {
<caret_context>return 1
}
fun main() {
<caret_stack_0>bar<Int>(bar<String>(
1,
2
),
bar<Any>(
3,
4
)
)
}
// MODULE: main
// MODULE... | kotlin | github | https://github.com/JetBrains/kotlin | analysis/analysis-api/testData/components/compilerFacility/compilation/codeFragments/reifiedTypeParams/multilineCall.kt |
{
"MYID": {
"summary": "Returns the ID of a node.",
"complexity": "O(1)",
"group": "cluster",
"since": "3.0.0",
"arity": 2,
"container": "CLUSTER",
"function": "clusterCommand",
"command_flags": [
"STALE"
],
"reply_schema": ... | json | github | https://github.com/redis/redis | src/commands/cluster-myid.json |
"""Tests for HomematicIP Cloud alarm control panel."""
from homeassistant.components.alarm_control_panel import (
DOMAIN as ALARM_CONTROL_PANEL_DOMAIN,
)
from homeassistant.components.homematicip_cloud import DOMAIN as HMIPC_DOMAIN
from homeassistant.const import (
STATE_ALARM_ARMED_AWAY,
STATE_ALARM_ARMED_... | unknown | codeparrot/codeparrot-clean | ||
class GraphNode:
"""Simple representation of a node in a graph. The graph itself would be a set of these graph nodes.
The graph can be either directed or undirected, depending on if two connected nodes contain the edge for each other
or not.
"""
def __init__(self, node_id):
self._node_id = ... | unknown | codeparrot/codeparrot-clean | ||
"""
Desired syntax:
gaurdian = MaxDepth(10) & HasAttr('__dict__')
if gaurdian(current, path):
# ....
walker(obj, gaurd=MaxDepth(10) & HasAttr('__dict__'))
@note: I put example wrapper decorators at the bottom.
@todo: Come up with simple-ish logical structure alternative to the wrapper decorator... | unknown | codeparrot/codeparrot-clean | ||
# -*- coding: utf-8 -*-
from __future__ import unicode_literals
import json
from datetime import datetime
from django.contrib.admin.models import ADDITION, CHANGE, DELETION, LogEntry
from django.contrib.admin.utils import quote
from django.contrib.auth.models import User
from django.contrib.contenttypes.models import... | unknown | codeparrot/codeparrot-clean | ||
""" stack.py tester
thomas moll 2015
"""
import unittest
import stack
class TestStack(unittest.TestCase):
def setUp(self):
pass
def test_push(self):
test_stack = stack.Stack()
with self.assertRaises(ValueError):
test_stack.peek()
test_value = 22
test_... | unknown | codeparrot/codeparrot-clean | ||
import os
from Cookie import SimpleCookie
from pprint import pformat
from urllib import urlencode, quote
from django.utils.datastructures import MultiValueDict
RESERVED_CHARS="!*'();:@&=+$,/?%#[]"
try:
# The mod_python version is more efficient, so try importing it first.
from mod_python.util import parse_qsl... | unknown | codeparrot/codeparrot-clean | ||
# -*- coding: utf-8 -*-
"""Invite Institution Handler."""
from google.appengine.ext import ndb
import json
from util import login_required
from . import BaseHandler
from custom_exceptions import NotAuthorizedException
from utils import json_response
from utils import Utils
__all__ = ['InviteInstitutionHandler']
cla... | unknown | codeparrot/codeparrot-clean | ||
#!/usr/bin/env python
# Copyright 2011 Google Inc.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or ... | unknown | codeparrot/codeparrot-clean | ||
# -*- coding: utf-8 -*-
# © 2014 Numérigraphe SARL
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
from openerp import models, fields, api
from openerp.addons import decimal_precision as dp
class ProductTemplate(models.Model):
_inherit = 'product.template'
@api.multi
@api.depends('pr... | unknown | codeparrot/codeparrot-clean | ||
# Copyright (c) 2015, Frappe Technologies Pvt. Ltd. and Contributors
# MIT License. See license.txt
from __future__ import unicode_literals
import frappe, os
from frappe import _
import frappe.modules.import_file
@frappe.whitelist()
def get_data_keys():
return frappe._dict({
"data_separator": _('Start en... | unknown | codeparrot/codeparrot-clean | ||
{
"compilerOptions": {
"target": "es5",
"lib": ["dom", "dom.iterable", "esnext"],
"allowJs": true,
"skipLibCheck": true,
"strict": false,
"forceConsistentCasingInFileNames": true,
"noEmit": true,
"esModuleInterop": true,
"module": "esnext",
"moduleResolution": "node",
"reso... | json | github | https://github.com/vercel/next.js | examples/cms-agilitycms/tsconfig.json |
from sympy.core.mul import Mul
from sympy.core.basic import S
from sympy.core.cache import cacheit
from sympy.functions import factorial
from sympy.utilities import all, any
def monomials(variables, degree):
"""Generate a set of monomials of the given total degree or less.
Given a set of variables V and a... | unknown | codeparrot/codeparrot-clean | ||
"""An internal script to process `new_failures_with_bad_commit.json` produced by `utils/check_bad_commit.py`.
This is used by `.github/workflows/check_failed_model_tests.yml` to produce a slack report of the following form
```
<{url}|New failed tests>
{
"GH_ydshieh": {
"vit": 1
}
}
```
"""
import json
i... | python | github | https://github.com/huggingface/transformers | utils/process_bad_commit_report.py |
/*
* Copyright 2002-present the original author or 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 b... | java | github | https://github.com/spring-projects/spring-framework | spring-context/src/main/java/org/springframework/jmx/export/annotation/ManagedNotification.java |
# Copyright 2013 10gen Inc.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to... | unknown | codeparrot/codeparrot-clean | ||
def min_Num(arr,n):
odd = 0
for i in range(n):
if (arr[i] % 2):
odd += 1
if (odd % 2):
return 1
return 2 | unknown | mbpp | ||
#!/usr/bin/python
__author__ = "James Sams <sams.james@gmail.com>"
import unittest
from gdata import test_data
import gdata.books
import atom
class BookEntryTest(unittest.TestCase):
def testBookEntryFromString(self):
entry = gdata.books.Book.FromString(test_data.BOOK_ENTRY)
self.assert_(isinstan... | unknown | codeparrot/codeparrot-clean | ||
<?php declare(strict_types=1);
/*
* This file is part of Composer.
*
* (c) Nils Adermann <naderman@naderman.de>
* Jordi Boggiano <j.boggiano@seld.be>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace Composer\Json;
... | php | github | https://github.com/composer/composer | src/Composer/Json/JsonValidationException.php |
// Copyright 2019 The Cockroach Authors.
//
// Use of this software is governed by the CockroachDB Software License
// included in the /LICENSE file.
package clusterversion
import (
"fmt"
"testing"
"github.com/cockroachdb/cockroach/pkg/build"
"github.com/cockroachdb/cockroach/pkg/roachpb"
"github.com/cockroachd... | go | github | https://github.com/cockroachdb/cockroach | pkg/clusterversion/cockroach_versions_test.go |
#!/usr/bin/env python
####################################################################################################
# @file http.py
# @package
# @author Olivier Derpierre
# @date 2009/01/12
# @version 0.1
#
# @mainpage
#
############################################################################################... | unknown | codeparrot/codeparrot-clean | ||
from __future__ import print_function
__author__ = "Martin Felder, felder@in.tum.de"
try:
from svm import svm_model, svm_parameter, svm_problem, cross_validation #@UnresolvedImport
from svm import C_SVC, NU_SVC, ONE_CLASS, EPSILON_SVR, NU_SVR #@UnresolvedImport @UnusedImport
from svm import LINEAR, POLY, ... | unknown | codeparrot/codeparrot-clean | ||
// Copyright 2021 The Cockroach Authors.
//
// Use of this software is governed by the CockroachDB Software License
// included in the /LICENSE file.
package server_test
import (
"context"
"fmt"
"regexp"
"testing"
"github.com/cockroachdb/cockroach/pkg/base"
"github.com/cockroachdb/cockroach/pkg/server/serverpb... | go | github | https://github.com/cockroachdb/cockroach | pkg/server/status_ext_test.go |
from jpype import *
import time
NUMMSGS = 10
def pyPublisher (javaNamingFactory="weblogic.jndi.WLInitialContextFactory",
javaNamingProvider="t3://158.188.40.21:7001",
connectionFactory="weblogic.jms.ConnectionFactory",
topicName="defaultTopic"):
return messaging.... | unknown | codeparrot/codeparrot-clean | ||
// Copyright 2015 The etcd 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 t... | go | github | https://github.com/etcd-io/etcd | server/etcdserver/api/snap/message.go |
'''
Copyright (c) 2014 Pivotal Software, Inc. 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 applicable law or ag... | unknown | codeparrot/codeparrot-clean | ||
#ifndef CAFFE2_UTILS_THREADPOOL_COMMON_H_
#define CAFFE2_UTILS_THREADPOOL_COMMON_H_
#ifdef __APPLE__
#include <TargetConditionals.h>
#endif
// caffe2 depends upon NNPACK, which depends upon this threadpool, so
// unfortunately we can't reference core/common.h here
// This is copied from core/common.h's definition of... | c | github | https://github.com/pytorch/pytorch | caffe2/utils/threadpool/ThreadPoolCommon.h |
{
"components": {
"schemas": {
"io.k8s.api.autoscaling.v1.CrossVersionObjectReference": {
"description": "CrossVersionObjectReference contains enough information to let you identify the referred resource.",
"properties": {
"apiVersion": {
"description": "apiVersion is t... | json | github | https://github.com/kubernetes/kubernetes | api/openapi-spec/v3/apis__autoscaling__v1_openapi.json |
import re
import warnings
from pathlib import Path
from typing import Any
import pytest
from packaging import version
from pydantic import ValidationError
from syrupy.assertion import SnapshotAssertion
from langchain_core.load import dumpd, load
from langchain_core.messages import (
AIMessage,
BaseMessage,
... | python | github | https://github.com/langchain-ai/langchain | libs/core/tests/unit_tests/prompts/test_chat.py |
#!/usr/bin/python
from __future__ import (absolute_import, division, print_function)
# Copyright 2018 Fortinet, Inc.
#
# This program 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 Lic... | unknown | codeparrot/codeparrot-clean | ||
# -*- coding: utf-8 -*-
import pytest
from raiden.utils import make_address, get_contract_path, privatekey_to_address
from raiden.network.discovery import ContractDiscovery
@pytest.mark.timeout(60)
@pytest.mark.parametrize('number_of_nodes', [1])
@pytest.mark.parametrize('poll_timeout', [80])
def test_endpointregistr... | unknown | codeparrot/codeparrot-clean | ||
# coding: utf-8
#
# Copyright 2020 The Oppia Authors. 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 requi... | unknown | codeparrot/codeparrot-clean | ||
from sympy import (
adjoint, conjugate, DiracDelta, Heaviside, nan, oo, pi, sign, sqrt,
symbols, transpose, Symbol, Piecewise, I, S, Eq
)
from sympy.utilities.pytest import raises
from sympy.core.function import ArgumentIndexError
x, y = symbols('x y')
def test_DiracDelta():
assert DiracDelta(1) == 0
... | unknown | codeparrot/codeparrot-clean | ||
from __future__ import unicode_literals
import datetime
import re
from datetime import date
from decimal import Decimal
from django import forms
from django.core.exceptions import ImproperlyConfigured
from django.db import models
from django.forms.models import (
BaseModelFormSet, _get_foreign_key, inlineformset_... | unknown | codeparrot/codeparrot-clean | ||
#!/usr/bin/env python
# Copyright (c) 2013 The Chromium Authors. All rights reserved.
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.
""" Lexer for PPAPI IDL
The lexer uses the PLY library to build a tokenizer which understands both
WebIDL and Pepper tokens.
WebI... | unknown | codeparrot/codeparrot-clean | ||
#!/usr/bin/env python
#Copyright ReportLab Europe Ltd. 2000-2012
#see license.txt for license details
"""Runs all test files in all subfolders.
"""
__version__=''' $Id$ '''
import os, glob, sys, traceback, unittest
#we need to ensure 'tests' is on the path. It will be if you
#run 'setup.py tests', but won't be if you... | unknown | codeparrot/codeparrot-clean |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.