source string | points list | n_points int64 | path string | repo string |
|---|---|---|---|---|
import pytest
import mymath.calculator
from mymath.calculator import add, div, filesum, fileconcat, approx_eq
# Simple tests
# ----------------------------------------------------
def test_add():
assert add(1, 2) == 3
def test_div():
assert div(4, 2) == 2
assert div(0, 2) == 0
# Catching excep... | [
{
"point_num": 1,
"id": "no_function_exceeds_5_params",
"question": "Does every function in this file take 5 or fewer parameters (excluding self/cls)?",
"answer": true
},
{
"point_num": 2,
"id": "all_function_names_snake_case",
"question": "Are all function names in this file written... | 3 | tests/test_calculator.py | amard33p/minimal-pytest-project |
"""Some nn utilities."""
import torch
from abstract import ParametricFunction
def copy_buffer(net: ParametricFunction, target_net: ParametricFunction):
"""Copy all buffers from net to target_net."""
with torch.no_grad():
for target_buf, buf in zip(target_net.buffers(), net.buffers()): # type: ignore
... | [
{
"point_num": 1,
"id": "every_function_under_20_lines",
"question": "Is every function in this file shorter than 20 lines?",
"answer": true
},
{
"point_num": 2,
"id": "all_params_annotated",
"question": "Does every function parameter in this file have a type annotation (excluding se... | 3 | code/nn.py | arjunchandra/continuous-rl |
from flask.ext.tuktuk.helpers import DotExpandedDict, Attribute
class User(DotExpandedDict):
"""
:type login: str
:type id: int
"""
def __init__(self, login=None, id=None):
super(User, self).__init__(login=login, id=id)
login = Attribute('login')
id = Attribute('id')
class Projec... | [
{
"point_num": 1,
"id": "more_functions_than_classes",
"question": "Does this file define more functions than classes?",
"answer": false
},
{
"point_num": 2,
"id": "all_function_names_snake_case",
"question": "Are all function names in this file written in snake_case?",
"answer":... | 3 | tests/testapp/app/helpers.py | aromanovich/flask-tuktuk |
import numpy as np
Om = 0.3
Ol = 0.7
H0 = 70 # km s^-1 Mpc^-1
c = 3e5 # km s^-1
DH = c / H0 # Mpc
Mpc_to_cm = 3.086e24
m_to_cm = 100
yr_to_s = 3.154e7
def xx(z):
"""
Helper function for the computation of
:py:func:`icecube_tools.cosmology.luminosity_distance`.
"""
return ((1 - Om) / Om) / po... | [
{
"point_num": 1,
"id": "all_function_names_snake_case",
"question": "Are all function names in this file written in snake_case?",
"answer": false
},
{
"point_num": 2,
"id": "every_function_has_docstring",
"question": "Does every function in this file have a docstring?",
"answer"... | 3 | icecube_tools/cosmology.py | cescalara/icecube_tools |
import subprocess
import time
import os
TEST_TYPE = os.getenv("TEST_TYPE", "bdd")
def before_scenario(context, scenario):
if f"{TEST_TYPE}" == "bdd":
proc = subprocess.Popen(["make", "start"])
time.sleep(4)
context.proc = proc
context.root_url = "http://localhost:5000"
else:
... | [
{
"point_num": 1,
"id": "no_function_exceeds_5_params",
"question": "Does every function in this file take 5 or fewer parameters (excluding self/cls)?",
"answer": true
},
{
"point_num": 2,
"id": "all_params_annotated",
"question": "Does every function parameter in this file have a ty... | 3 | features/environment.py | abhisheksr01/zero-2-hero-python-flask-microservice |
from django.shortcuts import render, render_to_response
from django.http import Http404
from django.http import HttpResponse, HttpResponseRedirect
from django.template import RequestContext
from django.views.decorators.http import require_GET, require_POST, require_http_methods
from models import *
from forms import *
... | [
{
"point_num": 1,
"id": "every_class_has_docstring",
"question": "Does every class in this file have a docstring?",
"answer": false
},
{
"point_num": 2,
"id": "has_multiple_inheritance",
"question": "Does any class in this file use multiple inheritance?",
"answer": false
},
{... | 3 | calendar_events/views.py | alexkyllo/django-calendar-events |
#
# Copyright 2019 The FATE 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 appl... | [
{
"point_num": 1,
"id": "has_nested_function_def",
"question": "Does this file contain any function defined inside another function?",
"answer": false
},
{
"point_num": 2,
"id": "every_function_has_docstring",
"question": "Does every function in this file have a docstring?",
"ans... | 3 | python/federatedml/components/homo_lr.py | QuantumA/FATE |
import math
class MaxHeapify(object):
def __init__(self, array):
self.array = array
def build(self):
array = self.array
size = len(array)
for key in reversed(range(math.ceil(size/2))):
self.max(array, key)
return array
def max(self, array=None,... | [
{
"point_num": 1,
"id": "every_function_under_20_lines",
"question": "Is every function in this file shorter than 20 lines?",
"answer": true
},
{
"point_num": 2,
"id": "more_functions_than_classes",
"question": "Does this file define more functions than classes?",
"answer": true
... | 3 | src/heap/max_heapify.py | dmvieira/algs |
import hashlib
# 生成 api 签名
class ApiSign:
def __init__(self, app_key: str = '', app_secret: str = ''):
self.app_key = app_key
self.app_secret = app_secret
def get_sign(self, user_token = "", **params):
# user_token: 用户 token 参数 (可选)
# params: request dict
# 删除 sign
... | [
{
"point_num": 1,
"id": "every_function_has_docstring",
"question": "Does every function in this file have a docstring?",
"answer": false
},
{
"point_num": 2,
"id": "every_function_under_20_lines",
"question": "Is every function in this file shorter than 20 lines?",
"answer": fal... | 3 | zw_api_sign/_api_sign.py | zwglass/zw_libs |
import json
class FileUtil(object):
TOKENS_FOLDER_PATH = 'tokens'
@staticmethod
def getJSONContents(filePath):
with open(filePath, 'r', encoding='utf-8') as f:
return json.loads(f.read().encode(encoding='utf-8'))
@staticmethod
def writeJSONContents(filePath, obj):
wit... | [
{
"point_num": 1,
"id": "has_nested_function_def",
"question": "Does this file contain any function defined inside another function?",
"answer": false
},
{
"point_num": 2,
"id": "has_multiple_inheritance",
"question": "Does any class in this file use multiple inheritance?",
"answ... | 3 | file_util.py | LucasMolander/Factorio |
import os
import torch
from collections import OrderedDict
import glob
class Saver(object):
def __init__(self, args):
self.args = args
self.directory = os.path.join('run', args.train_dataset, args.checkname)
self.runs = sorted(glob.glob(os.path.join(self.directory, 'experiment_*')))
... | [
{
"point_num": 1,
"id": "has_multiple_inheritance",
"question": "Does any class in this file use multiple inheritance?",
"answer": false
},
{
"point_num": 2,
"id": "no_function_exceeds_5_params",
"question": "Does every function in this file take 5 or fewer parameters (excluding self... | 3 | utils/saver.py | dumpmemory/Transformer-Explainability |
"""
Revision ID: 0204_service_data_retention
Revises: 0203_fix_old_incomplete_jobs
Create Date: 2018-07-10 11:22:01.761829
"""
import sqlalchemy as sa
from alembic import op
from sqlalchemy.dialects import postgresql
revision = "0204_service_data_retention"
down_revision = "0203_fix_old_incomplete_jobs"
def upgrad... | [
{
"point_num": 1,
"id": "has_nested_function_def",
"question": "Does this file contain any function defined inside another function?",
"answer": false
},
{
"point_num": 2,
"id": "every_function_has_docstring",
"question": "Does every function in this file have a docstring?",
"ans... | 3 | migrations/versions/0204_service_data_retention.py | cds-snc/notifier-api |
import pytest
from GraphModels.graphmodels.graphmodel import GraphModel
nodes_1 = {
'In_1': {'type': 'input',
'unit': '1',
'name': 'Input 1'},
'Par_1': {'type': 'parameter',
'unit': '1',
'name': 'Parameter 1'},
'Var_1': {'type': 'variable',
... | [
{
"point_num": 1,
"id": "has_nested_function_def",
"question": "Does this file contain any function defined inside another function?",
"answer": false
},
{
"point_num": 2,
"id": "all_return_types_annotated",
"question": "Does every function in this file have a return type annotation?... | 3 | tests/test_model_function.py | simonzabrocki/GraphModels |
def test_positive_guess(patched_hangman):
decision = patched_hangman.guess("e")
assert decision is True
def test_negative_guess(patched_hangman):
decision = patched_hangman.guess("r")
assert decision is False
def test_none_guess(patched_hangman):
patched_hangman.guess("e")
decision = patched... | [
{
"point_num": 1,
"id": "all_function_names_snake_case",
"question": "Are all function names in this file written in snake_case?",
"answer": true
},
{
"point_num": 2,
"id": "all_params_annotated",
"question": "Does every function parameter in this file have a type annotation (excludi... | 3 | tests/test_hangman.py | julia-shenshina/hangman |
""" A BlogController Module """
from masonite.controllers import Controller
from masonite.request import Request
from app.Blog import Blog
class BlogController(Controller):
def __init__(self, request: Request):
self.request = request
def show(self):
id = self.request.param("id")
retur... | [
{
"point_num": 1,
"id": "more_functions_than_classes",
"question": "Does this file define more functions than classes?",
"answer": true
},
{
"point_num": 2,
"id": "every_function_under_20_lines",
"question": "Is every function in this file shorter than 20 lines?",
"answer": true
... | 3 | app/http/controllers/BlogController.py | kerlinlopes/kerlin-blog-backend |
from rest_framework import generics, authentication, permissions
from rest_framework.authtoken.views import ObtainAuthToken
from rest_framework.settings import api_settings
from user.serializers import AuthTokenSerializer, UserSerializer
class CreateUserView(generics.CreateAPIView):
"""Create a new user in the s... | [
{
"point_num": 1,
"id": "every_class_has_docstring",
"question": "Does every class in this file have a docstring?",
"answer": true
},
{
"point_num": 2,
"id": "more_functions_than_classes",
"question": "Does this file define more functions than classes?",
"answer": false
},
{
... | 3 | app/user/views.py | isaacpedroza/recipe-app-api |
# -*- coding:utf-8 -*-
from __future__ import unicode_literals
from django.utils.translation import ugettext_lazy as _
from yepes import forms
from yepes.fields.char import CharField
from yepes.validators import PostalCodeValidator
from yepes.utils.deconstruct import clean_keywords
class PostalCodeField(CharField)... | [
{
"point_num": 1,
"id": "more_functions_than_classes",
"question": "Does this file define more functions than classes?",
"answer": true
},
{
"point_num": 2,
"id": "all_function_names_snake_case",
"question": "Are all function names in this file written in snake_case?",
"answer": ... | 3 | yepes/fields/postal_code.py | samuelmaudo/yepes |
# Copyright (c) 2021 PaddlePaddle 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 appli... | [
{
"point_num": 1,
"id": "every_function_under_20_lines",
"question": "Is every function in this file shorter than 20 lines?",
"answer": false
},
{
"point_num": 2,
"id": "every_function_has_docstring",
"question": "Does every function in this file have a docstring?",
"answer": fal... | 3 | lite/tests/unittest_py/op/common/test_unique_with_counts_op_base.py | 714627034/Paddle-Lite |
#!/usr/bin/env python3
# Copyright (c) 2016-2017 The Bitcoin Core developers
# Distributed under the MIT software license, see the accompanying
# file COPYING or http://www.opensource.org/licenses/mit-license.php.
"""Test using named arguments for RPCs."""
from test_framework.test_framework import AltcoinTestFramework... | [
{
"point_num": 1,
"id": "every_function_under_20_lines",
"question": "Is every function in this file shorter than 20 lines?",
"answer": true
},
{
"point_num": 2,
"id": "has_nested_function_def",
"question": "Does this file contain any function defined inside another function?",
"... | 3 | test/functional/rpc_named_arguments.py | wizz13150/gapcoin-core |
#!/usr/bin/env python3
# Copyright (c) 2018 The Worldcoin Core developers
# Distributed under the MIT software license, see the accompanying
# file COPYING or http://www.opensource.org/licenses/mit-license.php.
"""Test RPC help output."""
from test_framework.test_framework import WorldcoinTestFramework
from test_frame... | [
{
"point_num": 1,
"id": "every_function_under_20_lines",
"question": "Is every function in this file shorter than 20 lines?",
"answer": false
},
{
"point_num": 2,
"id": "more_functions_than_classes",
"question": "Does this file define more functions than classes?",
"answer": true... | 3 | test/functional/rpc_help.py | bugls/worldcoin |
# pylint: disable=redefined-outer-name
from unittest import mock
import pytest
from fastapi.testclient import TestClient
from app.common import cache
@pytest.fixture(autouse=True, scope="function")
def clear_cache():
# pylint: disable=protected-access
cache._redis_cli.flushall() # noqa
@pytest.fixture
d... | [
{
"point_num": 1,
"id": "every_function_has_docstring",
"question": "Does every function in this file have a docstring?",
"answer": false
},
{
"point_num": 2,
"id": "all_params_annotated",
"question": "Does every function parameter in this file have a type annotation (excluding self/... | 3 | app/tests/conftest.py | isayakhov/duty-schedule-bot |
import pytest
import requests
from unittest.mock import patch
def test_token_auth_wrong_token(
client, settings, mocked_token_auth, not_auth_response):
"""Assert that on authentication error the handle_auth_exception method
of TokenAuth gets called."""
client.settings = settings
client.aut... | [
{
"point_num": 1,
"id": "all_function_names_snake_case",
"question": "Are all function names in this file written in snake_case?",
"answer": true
},
{
"point_num": 2,
"id": "every_function_has_docstring",
"question": "Does every function in this file have a docstring?",
"answer":... | 3 | tests/token_auth_test.py | ephes/pythonista_api_client |
from mock import call
from nose.tools import istest
from provy.more.debian import AptitudeRole, RedisRole
from tests.unit.tools.helpers import ProvyTestCase
class RedisRoleTest(ProvyTestCase):
def setUp(self):
super(RedisRoleTest, self).setUp()
self.role = RedisRole(prov=None, context={})
@i... | [
{
"point_num": 1,
"id": "more_functions_than_classes",
"question": "Does this file define more functions than classes?",
"answer": true
},
{
"point_num": 2,
"id": "every_function_under_20_lines",
"question": "Is every function in this file shorter than 20 lines?",
"answer": true
... | 3 | tests/unit/more/debian/database/test_redis.py | timgates42/provy |
from typing import Any
from selenium.webdriver.remote.webelement import WebElement
from ..MicrosoftFormComponent import MicrosoftFormComponent
class Radio(MicrosoftFormComponent):
"""Create a Microsoft form Radio (select with no dropdown) component
Paramaters
----------
web_element: `'WebElement'`, ... | [
{
"point_num": 1,
"id": "has_multiple_inheritance",
"question": "Does any class in this file use multiple inheritance?",
"answer": false
},
{
"point_num": 2,
"id": "more_functions_than_classes",
"question": "Does this file define more functions than classes?",
"answer": true
},... | 3 | auto_events/form/microsoft/components/Radio.py | fedecech/form_automator |
def day22_part1(instructions):
grid = {}
for instruction in instructions:
if instruction["x_from"] < -50 or instruction["x_to"] > 50 \
or instruction["y_from"] < -50 or instruction["y_to"] > 50 \
or instruction["z_from"] < -50 or instruction["z_to"] > 50:
cont... | [
{
"point_num": 1,
"id": "every_function_under_20_lines",
"question": "Is every function in this file shorter than 20 lines?",
"answer": false
},
{
"point_num": 2,
"id": "every_function_has_docstring",
"question": "Does every function in this file have a docstring?",
"answer": fal... | 3 | Day 22/day22.py | ChristosHadjichristofi/advent-of-code |
"""
Logistic regression implemented using the nn.module class
"""
import torch
import torch.nn as nn
from sklearn import datasets
class Model(nn.Module):
def __init__(self, n_input_features=10):
super().__init__()
self.linear1 = nn.Linear(n_input_features, 30)
self.linear2 = nn.Linear(30,... | [
{
"point_num": 1,
"id": "more_functions_than_classes",
"question": "Does this file define more functions than classes?",
"answer": true
},
{
"point_num": 2,
"id": "has_multiple_inheritance",
"question": "Does any class in this file use multiple inheritance?",
"answer": false
},... | 3 | syllabus/classes/class5/neural_network_as_nnmodule.py | KiriKoppelgaard/NLP-E21 |
from argparse import Action, Namespace
from typing import (List)
from .switch_config import SwitchConfigCLI
from ..switch import SwitchChip
class EraseConfigCLI(SwitchConfigCLI):
"""
The "erase" action that removes all stored items from the EEPROM memory.
"""
def __init__(self, subparsers: Action, sw... | [
{
"point_num": 1,
"id": "all_return_types_annotated",
"question": "Does every function in this file have a return type annotation?",
"answer": true
},
{
"point_num": 2,
"id": "all_function_names_snake_case",
"question": "Are all function names in this file written in snake_case?",
... | 3 | botblox_config/data_manager/erase.py | ararobotique/botblox-manager-software |
#!/usr/bin/env python
# -*- coding: utf-8 -*-
# @Time : 5/15/20 4:49 PM
# @File : grover.py
# qubit number=4
# total number=8
import cirq
import cirq.google as cg
from typing import Optional
import sys
from math import log2
import numpy as np
#thatsNoCode
from cirq.contrib.svg import SVGCircuit
# Symbols for ... | [
{
"point_num": 1,
"id": "all_params_annotated",
"question": "Does every function parameter in this file have a type annotation (excluding self/cls)?",
"answer": false
},
{
"point_num": 2,
"id": "every_function_has_docstring",
"question": "Does every function in this file have a docst... | 3 | data/p4VQE/R2/benchmark/startCirq22.py | UCLA-SEAL/QDiff |
import numpy as np
import cv2 as cv
from psnr import psnr_numpy
def create_low_res_images(images: np.ndarray) -> np.ndarray:
images_low_res = tuple(create_low_res_image(image) for image in images)
return np.array(images_low_res)
def create_low_res_image(image: np.ndarray) -> np.ndarray:
return resize_up(resize_do... | [
{
"point_num": 1,
"id": "every_function_has_docstring",
"question": "Does every function in this file have a docstring?",
"answer": false
},
{
"point_num": 2,
"id": "all_params_annotated",
"question": "Does every function parameter in this file have a type annotation (excluding self/... | 3 | images_utils.py | Githubowy-Juliusz/SRCNN |
'''Test code.
'''
# pylint: disable=import-error
import unittest
from Chapter3_CodeTesting.UnitTesting.vector import Vector2D
class VectorTests(unittest.TestCase):
def setUp(self):
self.v1 = Vector2D(0, 0)
self.v2 = Vector2D(-1, 1)
self.v3 = Vector2D(2.5, -2.5)
def test_equality(self... | [
{
"point_num": 1,
"id": "more_functions_than_classes",
"question": "Does this file define more functions than classes?",
"answer": true
},
{
"point_num": 2,
"id": "has_multiple_inheritance",
"question": "Does any class in this file use multiple inheritance?",
"answer": false
},... | 3 | Chapter3_CodeTesting/UnitTesting/test_vector.py | franneck94/UdemyPythonProEng |
import os
from conda_build import api
# god-awful hack to get data from the test recipes
import sys
_thisdir = os.path.dirname(__file__)
sys.path.append(os.path.dirname(_thisdir))
from tests.utils import metadata_dir
variant_dir = os.path.join(metadata_dir, '..', 'variants')
def time_simple_render():
api.rend... | [
{
"point_num": 1,
"id": "every_function_has_docstring",
"question": "Does every function in this file have a docstring?",
"answer": false
},
{
"point_num": 2,
"id": "all_function_names_snake_case",
"question": "Are all function names in this file written in snake_case?",
"answer"... | 3 | benchmarks/time_render.py | bdice/conda-build |
from torch.distributed.rpc import RRef
from hearthstone.simulator.agent import AnnotatingAgent, Annotation, DiscoverChoiceAction, StandardAction, \
RearrangeCardsAction, HeroChoiceAction
class RemoteAgent(AnnotatingAgent):
def __init__(self, remote_agent: RRef):
self.remote_agent = remote_agent
... | [
{
"point_num": 1,
"id": "more_functions_than_classes",
"question": "Does this file define more functions than classes?",
"answer": true
},
{
"point_num": 2,
"id": "has_nested_function_def",
"question": "Does this file contain any function defined inside another function?",
"answe... | 3 | hearthstone/training/pytorch/worker/distributed/remote_agent.py | JDBumgardner/stone_ground_hearth_battles |
# GENERATED BY KOMAND SDK - DO NOT EDIT
import komand
import json
class Component:
DESCRIPTION = "Lists all snapshots belonging to the account"
class Input:
pass
class Output:
SNAPSHOTS = "snapshots"
class ListSnapshotsInput(komand.Input):
schema = json.loads("""
{}
""")
def __ini... | [
{
"point_num": 1,
"id": "has_multiple_inheritance",
"question": "Does any class in this file use multiple inheritance?",
"answer": false
},
{
"point_num": 2,
"id": "more_functions_than_classes",
"question": "Does this file define more functions than classes?",
"answer": false
}... | 3 | plugins/digitalocean/komand_digitalocean/actions/list_snapshots/schema.py | lukaszlaszuk/insightconnect-plugins |
#!/usr/bin/python3
"""
Fabric script based on the file 2-do_deploy_web_static.py that creates and
distributes an archive to the web servers
"""
from fabric.api import env, local, put, run
from datetime import datetime
from os.path import exists, isdir
env.hosts = ['142.44.167.228', '144.217.246.195']
def do_pack():
... | [
{
"point_num": 1,
"id": "all_function_names_snake_case",
"question": "Are all function names in this file written in snake_case?",
"answer": true
},
{
"point_num": 2,
"id": "every_function_has_docstring",
"question": "Does every function in this file have a docstring?",
"answer":... | 3 | 3-deploy_web_static.py | ralexrivero/AirBnB_clone_v3 |
#!/usr/bin/env python
#coding:utf-8
# Purpose: provide class mixins
# Created: 11.12.11
# Copyright (C) 2011, Manfred Moitzi
# License: MIT License
__author__ = "mozman <mozman@gmx.at>"
class SubscriptAttributes(object):
def __getitem__(self, item):
if hasattr(self, item):
return getattr(self... | [
{
"point_num": 1,
"id": "all_function_names_snake_case",
"question": "Are all function names in this file written in snake_case?",
"answer": true
},
{
"point_num": 2,
"id": "all_params_annotated",
"question": "Does every function parameter in this file have a type annotation (excludi... | 3 | dxfwrite/mixins.py | martinhansdk/DXFFaces |
import pytest
from pact import MessageProvider
def document_created_handler():
return {
"event": "ObjectCreated:Put",
"documentName": "document.doc",
"creator": "TP",
"documentType": "microsoft-word"
}
def document_deleted_handler():
return {
"event": "ObjectCreat... | [
{
"point_num": 1,
"id": "every_function_has_docstring",
"question": "Does every function in this file have a docstring?",
"answer": false
},
{
"point_num": 2,
"id": "all_function_names_snake_case",
"question": "Are all function names in this file written in snake_case?",
"answer"... | 3 | examples/message/tests/provider/test_message_provider.py | fresto32/pact-python |
import sys
from exotel import Exotel
from requests import RequestException
from elastalert.alerts import Alerter
from elastalert.util import EAException, elastalert_logger
class ExotelAlerter(Alerter):
""" Sends an exotel alert """
required_options = frozenset(['exotel_account_sid', 'exotel_auth_token', 'ex... | [
{
"point_num": 1,
"id": "has_multiple_inheritance",
"question": "Does any class in this file use multiple inheritance?",
"answer": false
},
{
"point_num": 2,
"id": "every_function_under_20_lines",
"question": "Is every function in this file shorter than 20 lines?",
"answer": true... | 3 | elastalert/alerters/exotel.py | perceptron01/elastalert2 |
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
# Submission file for the python difference_of_squares exercise.
#
# v2: Using "x*x" instead of the slower "x**2" and remove left over
# "pass" statement in difference()
# v1: Using sum(), abs(), range() and "**2"
def difference(length):
"""
Return the (abso... | [
{
"point_num": 1,
"id": "all_function_names_snake_case",
"question": "Are all function names in this file written in snake_case?",
"answer": true
},
{
"point_num": 2,
"id": "all_params_annotated",
"question": "Does every function parameter in this file have a type annotation (excludi... | 3 | python/difference-of-squares/difference_of_squares.py | sqrt/exercism-assignments |
#!/usr/bin/env python3
import importlib.machinery as imm
import logging
import pathlib
import re
import configargparse
class ModuleInfo:
def __init__(self, path):
self.path = pathlib.Path(path)
name = str(self.path.parent / self.path.stem)
name = name.replace("/", ".")
self.name =... | [
{
"point_num": 1,
"id": "every_function_has_docstring",
"question": "Does every function in this file have a docstring?",
"answer": false
},
{
"point_num": 2,
"id": "more_functions_than_classes",
"question": "Does this file define more functions than classes?",
"answer": true
}... | 3 | doc/argparse2rst.py | Hertin/espnet |
# Copyright (c) 2019-2020, NVIDIA CORPORATION. All rights reserved.
# See file LICENSE for terms.
import contextlib
import logging
@contextlib.contextmanager
def log_errors(reraise_exception=False):
try:
yield
except BaseException as e:
logging.exception(e)
if reraise_exception:
... | [
{
"point_num": 1,
"id": "has_multiple_inheritance",
"question": "Does any class in this file use multiple inheritance?",
"answer": false
},
{
"point_num": 2,
"id": "every_class_has_docstring",
"question": "Does every class in this file have a docstring?",
"answer": false
},
{... | 3 | ucp/exceptions.py | madsbk/ucx-py |
import defcon
import sys
sys.path.append("..")
from kernFeatureWriter import *
def read_file(path):
'''
Read a file, split lines into a list, close the file.
'''
with open(path, 'r', encoding='utf-8') as f:
data = f.read().splitlines()
return data
def test_WhichApp():
assert WhichA... | [
{
"point_num": 1,
"id": "all_function_names_snake_case",
"question": "Are all function names in this file written in snake_case?",
"answer": false
},
{
"point_num": 2,
"id": "every_function_has_docstring",
"question": "Does every function in this file have a docstring?",
"answer"... | 3 | tests/test_kernFeatureWriter.py | adobe-type-tools/python-modules |
import numpy as np
from chesscog.core.coordinates import from_homogenous_coordinates, to_homogenous_coordinates
def test_from_homogenous_coordinates():
coords = np.array([2., 4., 2.])
expected = np.array([1., 2.])
assert np.allclose(from_homogenous_coordinates(coords), expected)
def test_to_homogenous_... | [
{
"point_num": 1,
"id": "every_function_has_docstring",
"question": "Does every function in this file have a docstring?",
"answer": false
},
{
"point_num": 2,
"id": "every_function_under_20_lines",
"question": "Is every function in this file shorter than 20 lines?",
"answer": tru... | 3 | tests/core/test_coordinates.py | MarinusHeindl/chesscog |
import time, os, sys, logging
from subprocess import Popen, PIPE, STDOUT
TRACK_PROCESS_SPAWNS = True if (os.getenv('EM_BUILD_VERBOSE') and int(os.getenv('EM_BUILD_VERBOSE')) >= 3) else False
def timeout_run(proc, timeout=None, note='unnamed process', full_output=False):
start = time.time()
if timeout is not None:... | [
{
"point_num": 1,
"id": "has_nested_function_def",
"question": "Does this file contain any function defined inside another function?",
"answer": false
},
{
"point_num": 2,
"id": "no_function_exceeds_5_params",
"question": "Does every function in this file take 5 or fewer parameters (... | 3 | tools/jsrun.py | apportable/emscripten |
# Definition for a binary tree node.
# class TreeNode:
# def __init__(self, val=0, left=None, right=None):
# self.val = val
# self.left = left
# self.right = right
class Solution:
def rob(self, root: TreeNode) -> int:
def helper(node):
# return [rob this node, not rob... | [
{
"point_num": 1,
"id": "every_function_under_20_lines",
"question": "Is every function in this file shorter than 20 lines?",
"answer": true
},
{
"point_num": 2,
"id": "has_nested_function_def",
"question": "Does this file contain any function defined inside another function?",
"... | 3 | Leetcoding-Actions/Explore-Monthly-Challenges/2020-11/23-House-Robber-iii.py | shoaibur/SWE |
def hexstr_to_binstr(hex):
return f"{int(hex, 16):0>{len(hex)*4}b}"
def decode_packet(packet):
# cosume packet version
p_version = int(packet[:3], 2)
p_version_sum = p_version
packet = packet[3:]
# consume packet type
p_type = int(packet[:3], 2)
packet = packet[3:]
# literal val... | [
{
"point_num": 1,
"id": "every_function_under_20_lines",
"question": "Is every function in this file shorter than 20 lines?",
"answer": false
},
{
"point_num": 2,
"id": "any_function_over_40_lines",
"question": "Is any function in this file longer than 40 lines?",
"answer": true
... | 3 | day_16/task_1.py | Korred/advent_of_code_2021 |
import unittest
from context import parser
class TVShowFileParserTests(unittest.TestCase):
def setUp(self):
self.filename = parser.Parser("S.W.A.T.s01E01.1080p.avi")
def tearDown(self):
self.filename = None
def testObjValuesSet(self):
self.assertEqual(self.filename._showName, "S... | [
{
"point_num": 1,
"id": "every_function_under_20_lines",
"question": "Is every function in this file shorter than 20 lines?",
"answer": false
},
{
"point_num": 2,
"id": "has_multiple_inheritance",
"question": "Does any class in this file use multiple inheritance?",
"answer": fals... | 3 | tests/Parser/560clean_SWAT_test.py | Bas-Man/TVShowFile |
# installer for PiSenseHat data acquisition service
# Copyright 2021-
# Distributed under the terms of the MIT License
from bin.user.PiSense import PiSensewx
from weecfg.extension import ExtensionInstaller
def loader():
return PiSenseHatInstaller()
class PiSenseHatInstaller(ExtensionInstaller):
def __init__... | [
{
"point_num": 1,
"id": "every_function_has_docstring",
"question": "Does every function in this file have a docstring?",
"answer": false
},
{
"point_num": 2,
"id": "more_functions_than_classes",
"question": "Does this file define more functions than classes?",
"answer": true
}... | 3 | install.py | sbsrouteur/weewx-PiSenseHat |
from flask import Flask
app = Flask(__name__)
@app.route("/test-resource-1", methods=["GET"])
def question_random():
"""Returns a random question."""
return {"data": "test-resource-1"}
@app.route("/tests/<resource_id>", methods=["GET"])
def get_question(resource_id):
"""Returns a question by id."""
... | [
{
"point_num": 1,
"id": "every_function_has_docstring",
"question": "Does every function in this file have a docstring?",
"answer": true
},
{
"point_num": 2,
"id": "has_nested_function_def",
"question": "Does this file contain any function defined inside another function?",
"answ... | 3 | tests/api_server/app.py | grishasergii/generic-api-wrapper |
# -*- coding: utf-8 -*-
from tornado import locale as t_locale
import os
import os.path
import gettext
class WebtoolsTranslation(gettext.GNUTranslations):
def __init__(self, *args, **kwargs):
super(WebtoolsTranslation, self).__init__(*args, **kwargs)
self.set_output_charset('utf-8')
def mer... | [
{
"point_num": 1,
"id": "all_params_annotated",
"question": "Does every function parameter in this file have a type annotation (excluding self/cls)?",
"answer": false
},
{
"point_num": 2,
"id": "has_multiple_inheritance",
"question": "Does any class in this file use multiple inherita... | 3 | webtools/utils/locale.py | niwinz/tornado-webtools |
import cv2;
class Display(object):
def __init__(self):
pass;
def showFrame(self, frame, windowName = "frame"):
cv2.namedWindow(windowName, cv2.WINDOW_NORMAL);
cv2.imshow(windowName, frame);
def end(self):
cv2.destroyAllWindows(); | [
{
"point_num": 1,
"id": "has_multiple_inheritance",
"question": "Does any class in this file use multiple inheritance?",
"answer": false
},
{
"point_num": 2,
"id": "has_nested_function_def",
"question": "Does this file contain any function defined inside another function?",
"answ... | 3 | EyeTracker/display.py | PoweredByME/SSVEP_FYP |
#!/usr/bin/env python
import marlo
from marlo import MarloEnvBuilderBase
from marlo import MalmoPython
import os
from pathlib import Path
class MarloEnvBuilder(MarloEnvBuilderBase):
"""
TODO: Add Env Description Here
"""
def __init__(self, extra_params={}):
super(MarloEnvBuilder, self)._... | [
{
"point_num": 1,
"id": "has_multiple_inheritance",
"question": "Does any class in this file use multiple inheritance?",
"answer": false
},
{
"point_num": 2,
"id": "every_function_has_docstring",
"question": "Does every function in this file have a docstring?",
"answer": false
... | 3 | marlo/envs/FindTheGoal/main.py | spMohanty/marlo |
import logging
from django.contrib.auth.models import User
from unplugged import RelatedPluginField, Schema, fields
from wampyre.realm import realm_manager
from ...plugins import NotifierPlugin
logger = logging.getLogger(__name__)
class MultiNotifierSchema(Schema):
notifiers = fields.List(
RelatedPlugi... | [
{
"point_num": 1,
"id": "every_class_has_docstring",
"question": "Does every class in this file have a docstring?",
"answer": false
},
{
"point_num": 2,
"id": "has_multiple_inheritance",
"question": "Does any class in this file use multiple inheritance?",
"answer": false
},
{... | 3 | tridentstream/notifiers/multinotifier/handler.py | tridentstream/mediaserver |
#!/usr/bin/python3
# -*- coding: utf8 -*-
# Copyright (c) 2020 Baidu, 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... | [
{
"point_num": 1,
"id": "every_function_under_20_lines",
"question": "Is every function in this file shorter than 20 lines?",
"answer": true
},
{
"point_num": 2,
"id": "every_class_has_docstring",
"question": "Does every class in this file have a docstring?",
"answer": true
},
... | 3 | QCompute/QuantumPlatform/ProcedureParams.py | rickyHong/Qcompute-repl |
#from Instrucciones.instruccion import Instruccion
from Compi2RepoAux.team21.Analisis_Ascendente.Instrucciones.instruccion import Instruccion
#from storageManager.jsonMode import *
from Compi2RepoAux.team21.Analisis_Ascendente.storageManager.jsonMode import *
#import Tabla_simbolos.TablaSimbolos as ts
import Compi2Repo... | [
{
"point_num": 1,
"id": "all_params_annotated",
"question": "Does every function parameter in this file have a type annotation (excluding self/cls)?",
"answer": false
},
{
"point_num": 2,
"id": "more_functions_than_classes",
"question": "Does this file define more functions than clas... | 3 | parser/team21/Analisis_Ascendente/Instrucciones/Alter/alterDatabase.py | itsmjoe/tytus |
#!/usr/bin/python
################################################################################
# 268f62b2-5cc5-11e4-af55-00155d01fe08
#
# Justin Dierking
# justindierking@hardbitsolutions.com
# phnomcobra@gmail.com
#
# 10/24/2014 Original Construction
################################################################... | [
{
"point_num": 1,
"id": "has_multiple_inheritance",
"question": "Does any class in this file use multiple inheritance?",
"answer": false
},
{
"point_num": 2,
"id": "more_functions_than_classes",
"question": "Does this file define more functions than classes?",
"answer": true
},... | 3 | pcat2py/class/268f62b2-5cc5-11e4-af55-00155d01fe08.py | phnomcobra/PCAT2PY |
"""
Assertion helpers for offsets tests
"""
def assert_offset_equal(offset, base, expected):
actual = offset + base
actual_swapped = base + offset
actual_apply = offset.apply(base)
try:
assert actual == expected
assert actual_swapped == expected
assert actual_apply ... | [
{
"point_num": 1,
"id": "no_function_exceeds_5_params",
"question": "Does every function in this file take 5 or fewer parameters (excluding self/cls)?",
"answer": true
},
{
"point_num": 2,
"id": "all_params_annotated",
"question": "Does every function parameter in this file have a ty... | 3 | venv/Lib/site-packages/pandas/tests/tseries/offsets/common.py | Jos33y/student-performance-knn |
"""Add genres back
Revision ID: 1d393bb338a4
Revises: 126ecfb9a15e
Create Date: 2020-08-23 12:21:59.354200
"""
from alembic import op
import sqlalchemy as sa
# revision identifiers, used by Alembic.
revision = '1d393bb338a4'
down_revision = '126ecfb9a15e'
branch_labels = None
depends_on = None
def upgrade():
... | [
{
"point_num": 1,
"id": "all_return_types_annotated",
"question": "Does every function in this file have a return type annotation?",
"answer": false
},
{
"point_num": 2,
"id": "has_nested_function_def",
"question": "Does this file contain any function defined inside another function?... | 3 | migrations/versions/1d393bb338a4_add_genres_back.py | pavponn/fyyur |
from pathlib import Path
from test.testutils import stub_commit_mapper, stub_task
from bohr.config.pathconfig import PathConfig
from bohr.dvc.stages import ApplyHeuristicsCommand, ParseLabelsCommand
def test_parse_labels_command():
command = ParseLabelsCommand(
PathConfig(Path("/project_root"), Path("/so... | [
{
"point_num": 1,
"id": "every_function_under_20_lines",
"question": "Is every function in this file shorter than 20 lines?",
"answer": false
},
{
"point_num": 2,
"id": "every_function_has_docstring",
"question": "Does every function in this file have a docstring?",
"answer": fal... | 3 | test/dvc/test_stages.py | giganticode/bohr-framework |
#--------Hopping-------#
import sys
import os
sys.path.append(os.getcwd()+"/_Core Functions_")
import Hop
#----CUSTOM CLASSES-----#
Hop.set_project_path()
Hop.go_to_core()
from Painter import*
Hop.go_to_home()
def average_approach(NUM_TESTS):
sys.path.append(os.getcwd()+"/-Averaged Approach-")
import Averaged_... | [
{
"point_num": 1,
"id": "has_nested_function_def",
"question": "Does this file contain any function defined inside another function?",
"answer": false
},
{
"point_num": 2,
"id": "every_function_has_docstring",
"question": "Does every function in this file have a docstring?",
"ans... | 3 | _Run_Approaches_.py | PortfolioCollection/Character-Recogniser |
# Python Template Project
# @Author:
# @version: 1.0
try:
from configparser import ConfigParser
except ImportError:
from ConfigParser import ConfigParser # ver. < 3.0
class Config:
def __init__(self, context):
self.context = context
@staticmethod
def get_stage_file(self):
funct... | [
{
"point_num": 1,
"id": "more_functions_than_classes",
"question": "Does this file define more functions than classes?",
"answer": true
},
{
"point_num": 2,
"id": "has_multiple_inheritance",
"question": "Does any class in this file use multiple inheritance?",
"answer": false
},... | 3 | templates/lambda-template-python/components/config.py | rkothapalli/jazz |
import boto3
import json
class SQSClient:
def __init__(self, profile, queue):
session = boto3.Session(profile_name=profile)
self.queue = session.resource(
'sqs').get_queue_by_name(QueueName=queue)
def recieve(self):
return self.queue.receive_messages(MaxNumberOfMessages=1,... | [
{
"point_num": 1,
"id": "no_function_exceeds_5_params",
"question": "Does every function in this file take 5 or fewer parameters (excluding self/cls)?",
"answer": true
},
{
"point_num": 2,
"id": "all_params_annotated",
"question": "Does every function parameter in this file have a ty... | 3 | SQSClient.py | bork1n/ihelper |
import pytest
import mal_tier_list_bbcode_gen.exceptions as exceptions
from mal_tier_list_bbcode_gen.image import Image
def test_source_direct_url():
image_url = 'example.com/test.png'
image = Image('direct URL', image_url)
assert image.image_url == image_url
def test_source_google_drive_file_id():
... | [
{
"point_num": 1,
"id": "every_function_under_20_lines",
"question": "Is every function in this file shorter than 20 lines?",
"answer": true
},
{
"point_num": 2,
"id": "all_function_names_snake_case",
"question": "Are all function names in this file written in snake_case?",
"answ... | 3 | tests/test_image.py | juliamarc/mal-tier-list-bbcode-gen |
#!/usr/bin/env python3
import os
from datetime import datetime
import TEST
class bcolors:
RED = "\033[1;31m"
GREEN = "\033[1;32m"
BLUE = "\033[1;34m"
RESET = "\033[0;0m"
def setup_log(test_name):
if not os.path.isdir(TEST.log_dir):
os.mkdir(TEST.log_dir)
if TEST.log_dir[-1] != "/":... | [
{
"point_num": 1,
"id": "no_function_exceeds_5_params",
"question": "Does every function in this file take 5 or fewer parameters (excluding self/cls)?",
"answer": true
},
{
"point_num": 2,
"id": "all_function_names_snake_case",
"question": "Are all function names in this file written... | 3 | test/system/spor/TEST_LOG.py | so931/poseidonos |
# Copyright (C) 2018 SignalFx, Inc. All rights reserved.
from bson import json_util as json
from opentracing.ext import tags
import pymongo.monitoring
from six import text_type
import opentracing
class CommandTracing(pymongo.monitoring.CommandListener):
_scopes = {}
def __init__(self, tracer=None, span_tags... | [
{
"point_num": 1,
"id": "has_multiple_inheritance",
"question": "Does any class in this file use multiple inheritance?",
"answer": false
},
{
"point_num": 2,
"id": "every_function_under_20_lines",
"question": "Is every function in this file shorter than 20 lines?",
"answer": true... | 3 | pymongo_opentracing/tracing.py | khvn26/python-pymongo |
# -*- coding: utf-8 -*-
class AbstractUploadBackend(object):
BUFFER_SIZE = 10485760 # 10MB
def __init__(self, **kwargs):
self.__dict__.update(kwargs)
def setup(self, request, filename, *args, **kwargs):
"""Responsible for doing any pre-processing needed before the upload
starts.... | [
{
"point_num": 1,
"id": "more_functions_than_classes",
"question": "Does this file define more functions than classes?",
"answer": true
},
{
"point_num": 2,
"id": "all_params_annotated",
"question": "Does every function parameter in this file have a type annotation (excluding self/cl... | 3 | fineuploader/ajaxuploader/backends/base.py | bashu/django-photouploader |
class PNChannelGroupsAddChannelResult(object):
pass
class PNChannelGroupsRemoveChannelResult(object):
pass
class PNChannelGroupsRemoveGroupResult(object):
pass
class PNChannelGroupsListResult(object):
def __init__(self, channels):
self.channels = channels
| [
{
"point_num": 1,
"id": "has_multiple_inheritance",
"question": "Does any class in this file use multiple inheritance?",
"answer": false
},
{
"point_num": 2,
"id": "every_class_has_docstring",
"question": "Does every class in this file have a docstring?",
"answer": false
},
{... | 3 | pubnub/models/consumer/channel_group.py | 17media/pubnub-python |
# generator class and iterators
class FirstHundredNumbers:
def __init__(self):
self.numbers = 0
def __next__(self):
if self.numbers < 100:
current = self.numbers
self.numbers += 1
return current
else:
raise StopIteration()
my_gen = Firs... | [
{
"point_num": 1,
"id": "every_function_under_20_lines",
"question": "Is every function in this file shorter than 20 lines?",
"answer": true
},
{
"point_num": 2,
"id": "has_multiple_inheritance",
"question": "Does any class in this file use multiple inheritance?",
"answer": false... | 3 | Season 09 - Advanced built-in functions in Python/Episode 02 - Generators class and iterators.py | Pythobit/Python-tutorial |
import os
from os import path
from base import BaseTest
from keystore import KeystoreBase
class TestKeystore(KeystoreBase):
"""
Test Keystore variable replacement
"""
def setUp(self):
super(BaseTest, self).setUp()
self.keystore_path = self.working_dir + "/data/keystore"
if p... | [
{
"point_num": 1,
"id": "every_function_has_docstring",
"question": "Does every function in this file have a docstring?",
"answer": false
},
{
"point_num": 2,
"id": "all_function_names_snake_case",
"question": "Are all function names in this file written in snake_case?",
"answer"... | 3 | vendor/github.com/elastic/beats/libbeat/tests/system/test_keystore.py | jiangjunjian/countbeat |
class Solution:
def validPalindrome(self, s: str) -> bool:
left, right = self.twopointer(0, len(s) - 1, s)
if left >= right :
return True
return self.valid(left + 1, right, s) or self.valid(left, right - 1, s)
def valid(self, left, right, s) :
l, r = self.twopoin... | [
{
"point_num": 1,
"id": "all_params_annotated",
"question": "Does every function parameter in this file have a type annotation (excluding self/cls)?",
"answer": false
},
{
"point_num": 2,
"id": "no_function_exceeds_5_params",
"question": "Does every function in this file take 5 or fe... | 3 | 680_Valid_Palindrome_II.py | yuqingchen/Leetcode |
"""
Utility functions for the btcpayserver client
"""
import pickle
from app.db import get_db
from config import Config
def get_client():
"""
Loads the serialized client from database
"""
db = get_db()
pickled_client = db.execute(
"SELECT pickled_client FROM btc_pay_server_client ORDER BY ... | [
{
"point_num": 1,
"id": "every_function_has_docstring",
"question": "Does every function in this file have a docstring?",
"answer": true
},
{
"point_num": 2,
"id": "all_params_annotated",
"question": "Does every function parameter in this file have a type annotation (excluding self/c... | 3 | app/btcpayserver_helper.py | psqnt/flask-btcpay-example |
from pages.checks import page_templates_loading_check
from django.test import TestCase
from django.core.checks import Warning
from django.template import TemplateSyntaxError
class PageTemplatesLoadingCheckTestCase(TestCase):
def test_check_detects_unexistant_template(self):
unexistant = ('does_not_exists... | [
{
"point_num": 1,
"id": "has_multiple_inheritance",
"question": "Does any class in this file use multiple inheritance?",
"answer": false
},
{
"point_num": 2,
"id": "all_function_names_snake_case",
"question": "Are all function names in this file written in snake_case?",
"answer":... | 3 | pages/tests/test_checks.py | timbortnik/django-page-cms |
from yacs.config import CfgNode as CN
import yaml
_C = CN()
_C.DATA = CN()
_C.DATA.DATASET = 'Cifar10'
_C.DATA.BATCH_SIZE = 128
_C.MODEL = CN()
_C.MODEL.NUM_CLASSES = 1000
_C.MODEL.TRANS = CN()
_C.MODEL.TRANS.EMBED_DIM = 96
_C.MODEL.TRANS.DEPTHS = [2, 2, 6, 2]
_C.MODEL.TRANS.QKV_BIAS = False
def _update_config_fr... | [
{
"point_num": 1,
"id": "all_function_names_snake_case",
"question": "Are all function names in this file written in snake_case?",
"answer": true
},
{
"point_num": 2,
"id": "no_function_exceeds_5_params",
"question": "Does every function in this file take 5 or fewer parameters (exclu... | 3 | edu/class8/config.py | h1063135843/PaddleViT |
import numpy as np
def accuracy(predictions,ground_truths):
return np.sum(predictions==ground_truths)/len(ground_truths)
def sensitivity(predictions,ground_truths):
'''
Here it is assumed:
0=negative
1=positive
'''
return 1-len(predictions[(predictions==0)*(ground_truths==1)])/le... | [
{
"point_num": 1,
"id": "all_params_annotated",
"question": "Does every function parameter in this file have a type annotation (excluding self/cls)?",
"answer": false
},
{
"point_num": 2,
"id": "no_function_exceeds_5_params",
"question": "Does every function in this file take 5 or fe... | 3 | src/Eukaryotic_Promoters_Classification/mouse_tata_deepromoter/Metrics.py | Shujun-He/Nucleic-Transformer |
class Solution:
def __init__(self, N):
self.n = N
# Auxilary DS to store left/right occupied room for a given occupied room
# Useful in updating heap when book() or leave() is called
self.left_occupied = {}
self.right_occupied = {}
# root element stores longest fre... | [
{
"point_num": 1,
"id": "has_nested_function_def",
"question": "Does this file contain any function defined inside another function?",
"answer": false
},
{
"point_num": 2,
"id": "all_function_names_snake_case",
"question": "Are all function names in this file written in snake_case?",... | 3 | Miscellaneous/findbookleave.py | jan25/code_sorted |
from operator import eq
def assert_contains(collection, *items, **kwargs):
"""Check that each item in `items` is in `collection`.
Parameters
----------
collection : list
*items : list
Query items.
count : int, optional
The number of times each item should occur in `collection`... | [
{
"point_num": 1,
"id": "every_function_has_docstring",
"question": "Does every function in this file have a docstring?",
"answer": true
},
{
"point_num": 2,
"id": "no_function_exceeds_5_params",
"question": "Does every function in this file take 5 or fewer parameters (excluding self... | 3 | pyout/tests/utils.py | vsoch/pyout |
'''
Created on 28 Jul 2017
@author: julianporter
'''
import unittest
import traceback
VERBOSE=False
class TestFramework(unittest.TestCase):
testName='test'
def setUp(self):
self.nTests=1000
self.errors=[]
self.good=0
self.count=0
self.crashes=0
d... | [
{
"point_num": 1,
"id": "every_function_has_docstring",
"question": "Does every function in this file have a docstring?",
"answer": false
},
{
"point_num": 2,
"id": "has_multiple_inheritance",
"question": "Does any class in this file use multiple inheritance?",
"answer": false
... | 3 | python/test/baseTest.py | EdwardBetts/OSGridConverter |
import torch
def validate_tensor_shape_2d_4d(t):
shape = t.shape
if len(shape) not in (2, 4):
raise ValueError(
"Only 2D and 4D tensor shapes are supported. Found "
"Found tensor of shape {} with {} dims".format(shape, len(shape))
)
def pad_inner_dims(t, pad_to):
... | [
{
"point_num": 1,
"id": "every_function_has_docstring",
"question": "Does every function in this file have a docstring?",
"answer": false
},
{
"point_num": 2,
"id": "all_function_names_snake_case",
"question": "Are all function names in this file written in snake_case?",
"answer"... | 3 | prune/pruning_method_utils.py | itayhubara/AcceleratedSparseNeuralTraining |
# -*- coding: utf-8 -*-
from __future__ import unicode_literals, division, print_function, absolute_import
import os
import dsnparse
from .compat import *
from .config import DsnConnection, Connection
from . import decorators
from .interface import get_interface, set_interface, get_interfaces
from .message import Mes... | [
{
"point_num": 1,
"id": "every_function_has_docstring",
"question": "Does every function in this file have a docstring?",
"answer": true
},
{
"point_num": 2,
"id": "has_nested_function_def",
"question": "Does this file contain any function defined inside another function?",
"answ... | 3 | morp/__init__.py | firstopinion/morp |
import json
from schematics import Model
from schematics.types import StringType, FloatType
from slim.utils.schematics_ext import JSONListType, JSONDictType, JSONType
def test_json_list():
class MyModel(Model):
a = JSONListType(StringType)
a = MyModel({'a': [1, 2, 3]})
a.validate()
b = MyM... | [
{
"point_num": 1,
"id": "all_function_names_snake_case",
"question": "Are all function names in this file written in snake_case?",
"answer": true
},
{
"point_num": 2,
"id": "has_multiple_inheritance",
"question": "Does any class in this file use multiple inheritance?",
"answer": ... | 3 | tests/utils_tests/test_schematics_ext.py | fy0/mapi |
from typing import List
from setuptools import find_packages, setup
def get_install_requires() -> List[str]:
return open("docker/requirements_pip.txt").read().splitlines()
def get_readme() -> str:
return open("README.md").read()
setup(
name="mvtec",
version="0.0.1",
description="Toolbox for U... | [
{
"point_num": 1,
"id": "all_return_types_annotated",
"question": "Does every function in this file have a return type annotation?",
"answer": true
},
{
"point_num": 2,
"id": "every_function_has_docstring",
"question": "Does every function in this file have a docstring?",
"answer... | 3 | setup.py | bilzard/mvtec-utils |
import pytest
from rlo import factory
@pytest.mark.parametrize("use_subtree_match_edges", [True, False])
@pytest.mark.parametrize("loss", ["pinball=0.6", "huber"])
def test_torch_model_from_config(use_subtree_match_edges, loss):
# Check we can construct a Model
config = {
"num_embeddings": 3,
... | [
{
"point_num": 1,
"id": "every_function_has_docstring",
"question": "Does every function in this file have a docstring?",
"answer": false
},
{
"point_num": 2,
"id": "no_function_exceeds_5_params",
"question": "Does every function in this file take 5 or fewer parameters (excluding sel... | 3 | rlo/test/rlo/test_factory.py | tomjaguarpaw/knossos-ksc |
# -*- coding: utf-8 -*-
'''Implementation for `Vows.async_topic` decorator. (See `core`
module).
'''
# pyVows testing engine
# https://github.com/heynemann/pyvows
# Licensed under the MIT license:
# http://www.opensource.org/licenses/mit-license
# Copyright (c) 2011 Bernardo Heynemann heynemann@gmail.com
import sy... | [
{
"point_num": 1,
"id": "every_function_under_20_lines",
"question": "Is every function in this file shorter than 20 lines?",
"answer": true
},
{
"point_num": 2,
"id": "every_class_has_docstring",
"question": "Does every class in this file have a docstring?",
"answer": false
},... | 3 | pyvows/async_topic.py | wking/pyvows |
import multiprocessing
import traceback
class Process(multiprocessing.Process):
def __init__(self, *args, **kwargs):
multiprocessing.Process.__init__(self, *args, **kwargs)
self._pconn, self._cconn = multiprocessing.Pipe()
self._exception = None
def run(self):
try:
... | [
{
"point_num": 1,
"id": "every_class_has_docstring",
"question": "Does every class in this file have a docstring?",
"answer": false
},
{
"point_num": 2,
"id": "all_function_names_snake_case",
"question": "Are all function names in this file written in snake_case?",
"answer": true... | 3 | NetLogoDOE/src/util/Runner.py | robinfaber97/NetLogoDOE |
# Copyright 2016-2018 Dirk Thomas
# Copyright 2018 Mickael Gaillard
# Licensed under the Apache License, Version 2.0
from pathlib import Path
import sys
def test_copyright_licence():
missing = check_files([Path(__file__).parents[1]])
assert not len(missing), \
'In some files no copyright / license li... | [
{
"point_num": 1,
"id": "has_nested_function_def",
"question": "Does this file contain any function defined inside another function?",
"answer": false
},
{
"point_num": 2,
"id": "every_function_has_docstring",
"question": "Does every function in this file have a docstring?",
"ans... | 3 | test/test_copyright_license.py | Theosakamg/colcon-ros-bazel |
from .conftest import GoProCameraTest
from socket import timeout
from urllib import error
class GpControlSetTest(GoProCameraTest):
def test_gp_control_set(self):
# on success, this is an empty json blob
self.responses['/gp/gpControl/setting/foo/bar'] = '{}'
assert '{}' == self.goprocam.gp... | [
{
"point_num": 1,
"id": "more_functions_than_classes",
"question": "Does this file define more functions than classes?",
"answer": true
},
{
"point_num": 2,
"id": "has_multiple_inheritance",
"question": "Does any class in this file use multiple inheritance?",
"answer": false
},... | 3 | tests/test_gpcontrolset.py | waider/gopro-py-api |
"""Scraper for Maryland Supreme Court Oral Argument Audio
This scraper has an interesting history. It was briefly running on the live
site, but we realized shortly after starting it that the scraper was
downloading video, not audio!
Seeing that we weren't ready for video, we disabled this scraper and deleted
any trac... | [
{
"point_num": 1,
"id": "every_function_has_docstring",
"question": "Does every function in this file have a docstring?",
"answer": false
},
{
"point_num": 2,
"id": "every_function_under_20_lines",
"question": "Is every function in this file shorter than 20 lines?",
"answer": tru... | 3 | juriscraper/oral_args/united_states/state/md.py | EvandoBlanco/juriscraper |
from datetime import datetime
from recurrence import Recurrence, Rule
import recurrence
def test_truthiness_with_single_rrule():
rule = Rule(
recurrence.DAILY
)
object = Recurrence(
rrules=[rule]
)
assert bool(object)
def test_truthiness_with_single_exrule():
rule = Rule(
... | [
{
"point_num": 1,
"id": "all_function_names_snake_case",
"question": "Are all function names in this file written in snake_case?",
"answer": true
},
{
"point_num": 2,
"id": "every_function_under_20_lines",
"question": "Is every function in this file shorter than 20 lines?",
"answ... | 3 | tests/test_magic_methods.py | GeeWee/django-recurrence |
import decimal
from waldur_core.logging.loggers import EventLogger, event_logger
class InvoiceLogger(EventLogger):
month = int
year = int
customer = 'structure.Customer'
class Meta:
event_types = (
'invoice_created',
'invoice_paid',
'invoice_canceled',
... | [
{
"point_num": 1,
"id": "all_function_names_snake_case",
"question": "Are all function names in this file written in snake_case?",
"answer": true
},
{
"point_num": 2,
"id": "no_function_exceeds_5_params",
"question": "Does every function in this file take 5 or fewer parameters (exclu... | 3 | src/waldur_mastermind/invoices/log.py | geant-multicloud/MCMS-mastermind |
class ReplayBuffer(object):
def __init__(self, rand_state, capacity=1e6):
self._capacity = capacity
self._rand_state = rand_state
self._next_idx = 0
self._memory = []
def append(self, transition):
if self._next_idx >= len(self._memory):
self._memory.append(tr... | [
{
"point_num": 1,
"id": "all_function_names_snake_case",
"question": "Are all function names in this file written in snake_case?",
"answer": true
},
{
"point_num": 2,
"id": "more_functions_than_classes",
"question": "Does this file define more functions than classes?",
"answer": ... | 3 | SOFT_M2TD3/replay_buffer.py | anonymous-rev/review |
"""The tests for the mochad light platform."""
import unittest.mock as mock
import pytest
from openpeerpower.components import light
from openpeerpower.components.mochad import light as mochad
from openpeerpower.setup import async_setup_component
@pytest.fixture(autouse=True)
def pymochad_mock():
"""Mock pymoc... | [
{
"point_num": 1,
"id": "all_params_annotated",
"question": "Does every function parameter in this file have a type annotation (excluding self/cls)?",
"answer": false
},
{
"point_num": 2,
"id": "all_function_names_snake_case",
"question": "Are all function names in this file written ... | 3 | tests/components/mochad/test_light.py | pcaston/core |
# Copyright (c) Microsoft Corporation.
# Licensed under the MIT license.
import torch
class Stage5(torch.nn.Module):
def __init__(self):
super(Stage5, self).__init__()
self.layer1 = torch.nn.Conv2d(64, 128, kernel_size=(3, 3), stride=(1, 1), padding=(1, 1))
self._initialize_weights()
... | [
{
"point_num": 1,
"id": "has_nested_function_def",
"question": "Does this file contain any function defined inside another function?",
"answer": false
},
{
"point_num": 2,
"id": "every_function_has_docstring",
"question": "Does every function in this file have a docstring?",
"ans... | 3 | runtime/image_classification/models/vgg16/gpus=16_straight/stage5.py | NestLakerJasonLIN/pipedream |
from django.urls import resolve
from django.test import TestCase
from django.http import HttpRequest
from lists.views import home_page
class HomePageTest(TestCase):
"""Тест домашней страницы"""
def test_root_url_resolve_to_home_page_view(self):
"""Тест: корневой url преобразуется в представление дом... | [
{
"point_num": 1,
"id": "every_function_under_20_lines",
"question": "Is every function in this file shorter than 20 lines?",
"answer": true
},
{
"point_num": 2,
"id": "every_function_has_docstring",
"question": "Does every function in this file have a docstring?",
"answer": true... | 3 | src/lists/tests/test_home_page.py | dmitricus/django-docker |
from mimesis.providers.base import BaseProvider
from .helpers import generate
class MPANProvider(BaseProvider):
class Meta:
name = "mpan"
@staticmethod
def generate() -> str:
return generate()
| [
{
"point_num": 1,
"id": "every_class_has_docstring",
"question": "Does every class in this file have a docstring?",
"answer": false
},
{
"point_num": 2,
"id": "has_multiple_inheritance",
"question": "Does any class in this file use multiple inheritance?",
"answer": false
},
{... | 3 | mpan/generation/mimesis.py | limejump/mpan |
"""Dummy backend for testing basic interaction of projects and backends"""
from annif.suggestion import SubjectSuggestion, ListSuggestionResult
from . import backend
class DummyBackend(backend.AnnifLearningBackend):
name = "dummy"
initialized = False
uri = 'http://example.org/dummy'
label = 'dummy'
... | [
{
"point_num": 1,
"id": "every_function_under_20_lines",
"question": "Is every function in this file shorter than 20 lines?",
"answer": true
},
{
"point_num": 2,
"id": "all_params_annotated",
"question": "Does every function parameter in this file have a type annotation (excluding se... | 3 | annif/backend/dummy.py | ooduor/Annif |
import os
import errno
import tensorflow as tf
from keras import backend as K
def safe_mkdir(dir_to_make: str) -> None:
'''
Attempts to make a directory following the Pythonic EAFP strategy which prevents race conditions.
:param dir_to_make: The directory path to attempt to make.
:return: None
''... | [
{
"point_num": 1,
"id": "has_nested_function_def",
"question": "Does this file contain any function defined inside another function?",
"answer": true
},
{
"point_num": 2,
"id": "all_function_names_snake_case",
"question": "Are all function names in this file written in snake_case?",
... | 3 | utils.py | lalonderodney/D-Caps |
import urllib
import platform
import random
import requests
import os
from flask import Flask, render_template, url_for, request
from flask import jsonify
app = Flask(__name__)
event_text = 'Demo app for ECS'
print(event_text)
@app.route('/')
def index():
images = [
url_for('static', filename='beachops... | [
{
"point_num": 1,
"id": "every_function_has_docstring",
"question": "Does every function in this file have a docstring?",
"answer": false
},
{
"point_num": 2,
"id": "all_function_names_snake_case",
"question": "Are all function names in this file written in snake_case?",
"answer"... | 3 | app/app.py | dubbracer/demo-app-ecs |
import re
def basic_cleaning(input_path='data/haiku.txt', output_path='data/haiku_cleaned.txt', threshold=50):
'''
Ignore lines that exceeds threshold length for poem,
and lines starting with non alphabet
'''
with open(input_path, 'r') as fsrc:
with open(output_path, 'w') as fdest:
... | [
{
"point_num": 1,
"id": "no_function_exceeds_5_params",
"question": "Does every function in this file take 5 or fewer parameters (excluding self/cls)?",
"answer": true
},
{
"point_num": 2,
"id": "every_function_under_20_lines",
"question": "Is every function in this file shorter than... | 3 | utils/data_cleaner.py | rayding24/First-Principles-Transformers |
import random
import numpy as np
import torch
def set_random_seed(seed):
if seed < 0:
return
random.seed(seed)
np.random.seed(seed)
torch.manual_seed(seed)
torch.cuda.manual_seed(seed)
torch.cuda.manual_seed_all(seed)
torch.backends.cudnn.deterministic = True
torch.backends.cud... | [
{
"point_num": 1,
"id": "has_nested_function_def",
"question": "Does this file contain any function defined inside another function?",
"answer": false
},
{
"point_num": 2,
"id": "every_function_has_docstring",
"question": "Does every function in this file have a docstring?",
"ans... | 3 | FusionTransformer/common/utils/torch_util.py | aliabdelkader/FusionTransformer |
from django.db import models
from django.utils import timezone
from django.dispatch import receiver
from django.db.models import signals
class LabCode(models.Model):
"""
Lab Code. This will be used to match the responses to a laboratory session.
"""
code = models.CharField(max_length=50, blank=False, unique=... | [
{
"point_num": 1,
"id": "more_functions_than_classes",
"question": "Does this file define more functions than classes?",
"answer": true
},
{
"point_num": 2,
"id": "every_class_has_docstring",
"question": "Does every class in this file have a docstring?",
"answer": false
},
{
... | 3 | lab/models.py | bernardobgam/edtech_experiment |
# -*- coding: utf-8 -*-
"""
Common utility functions for the reclass adapters
http://reclass.pantsfullofunix.net
"""
from __future__ import absolute_import, print_function, unicode_literals
import os
# Import python libs
import sys
def prepend_reclass_source_path(opts):
source_path = opts.get("reclass_source_pa... | [
{
"point_num": 1,
"id": "all_function_names_snake_case",
"question": "Are all function names in this file written in snake_case?",
"answer": true
},
{
"point_num": 2,
"id": "every_function_has_docstring",
"question": "Does every function in this file have a docstring?",
"answer":... | 3 | salt/utils/reclass.py | magenta-aps/salt |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.