source string | points list | n_points int64 | path string | repo string |
|---|---|---|---|---|
from .base import GnuRecipe
from ..version import Versions
class OpenSSLRecipe(GnuRecipe):
def __init__(self, *args, **kwargs):
super(OpenSSLRecipe, self).__init__(*args, **kwargs)
self.sha256 = 'ec3f5c9714ba0fd45cb4e087301eb133' \
'6c317e0d20b575a125050470e8089e4d'
... | [
{
"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 | hardhat/recipes/openssl.py | stangelandcl/hardhat |
# -*- coding: utf-8 -*-
#
# Copyright © Spyder Project Contributors
# Licensed under the terms of the MIT License
# (see spyder/__init__.py for details)
"""Outline explorer, languages specific implementations."""
# Standard library imports
import re
#=====================================================... | [
{
"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 | spyder/plugins/outlineexplorer/languages.py | aglotero/spyder |
import torch, copy, random
import torch.utils.data as data
class SearchDataset(data.Dataset):
def __init__(self, name, data, train_split, valid_split, check=True):
self.datasetname = name
self.data = data
self.train_split = train_split.copy()
self.valid_split = valid_split.copy()
if chec... | [
{
"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 | lib/datasets/SearchDatasetWrap.py | shashank3959/Model-Distillation |
#!/usr/bin/env python3
import re
import numpy as np
import scipy.optimize
import sys
def moment(positions):
center_of_mass = np.average(positions, axis = 0)
return np.sum((positions - center_of_mass)**2)
def part_1(positions, velocities):
f = lambda i : moment(positions + i*velocities)
res = scipy.op... | [
{
"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 | 2018/day_10/main.py | Repiphany/AoC |
"""Addeding lessons taught to user
Revision ID: 1c697a5bd34f
Revises: 23aebf11a765
Create Date: 2014-01-04 13:13:39.599020
"""
# revision identifiers, used by Alembic.
revision = '1c697a5bd34f'
down_revision = '23aebf11a765'
from alembic import op
import sqlalchemy as sa
def upgrade():
### commands auto gener... | [
{
"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 | alembic/versions/1c697a5bd34f_addeding_lessons_tau.py | codeforamerica/bizfriendly-api |
import pytest
from app.calculation import add , sub, mul, div, BankAccount, InsufficientFund
## Creating a Fixture for our Bank account class
@pytest.fixture
def zero_bank_account():
return BankAccount()
@pytest.fixture
def bank_account():
return BankAccount(50)
@pytest.mark.parametrize(
"num1, num2, r... | [
{
"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 | tests/test_calculation.py | esak21/learnapi_beginners |
import os
from setuptools import find_packages, setup
def read(fname):
return open(os.path.join(os.path.dirname(__file__), fname)).read()
def requirements(fname):
return [line.strip()
for line in open(os.path.join(os.path.dirname(__file__), fname))]
setup(
name='mwviews',
version='0.1.... | [
{
"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": "every_function_has_docstring",
"question": "Does every function in this file have a docstring?",
"answe... | 3 | setup.py | danmichaelo/python-mwviews |
# Copyright 2019-2021 ETH Zurich and the DaCe authors. All rights reserved.
import math
import dace
import polybench
N = dace.symbol('N')
#datatypes = [dace.float64, dace.int32, dace.float32]
datatype = dace.float64
# Dataset sizes
sizes = [{N: 30}, {N: 90}, {N: 250}, {N: 1300}, {N: 2800}]
args = [([N, N], datatype... | [
{
"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_params_annotated",
"question": "Does every function parameter in this file have a type annotation (exc... | 3 | samples/polybench/gesummv.py | Walon1998/dace |
import os
from flask import Flask
from flask import render_template
from flask import request
import wiringpi
import signal
SERVO_PIN = 18 # BCM pin
FREQUENCY = 50 # hz
SINGLE_CYCLE = 1000.0 / FREQUENCY # ms
OFF_DUTY_CYCLE = (1.0 / SINGLE_CYCLE) * 100.0 # %
ON_DUTY_CYCLE = (2.1 / SINGLE_CYCLE) * 100.0 # %
app = F... | [
{
"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": fals... | 3 | src/main.py | wolfd/iot-notifier |
#!/usr/bin/env python
# -*- coding: utf-8 -*-
import json
from alipay.aop.api.response.AlipayResponse import AlipayResponse
class AlipayUserAntpaasUseridGetResponse(AlipayResponse):
def __init__(self):
super(AlipayUserAntpaasUseridGetResponse, self).__init__()
self._user_id = None
@property... | [
{
"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 | alipay/aop/api/response/AlipayUserAntpaasUseridGetResponse.py | snowxmas/alipay-sdk-python-all |
from abc import ABC, abstractmethod
from typing import Generic, TypeVar
H = TypeVar("H")
T = TypeVar("T")
class BaseHistory(Generic[H, T], ABC):
@abstractmethod
def add(self, entry: T) -> None:
pass
@abstractmethod
def retrieve(self) -> H:
pass
| [
{
"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_return_types_annotated",
"question": "Does every function in this file have a return type annotation?",
"answe... | 3 | mesa_behaviors/history/base_history.py | tokesim/mesa_behaviors |
##### Graph implementation list of adjacencies #####
import dataclasses
from typing import List, Any, Optional
@dataclasses.dataclass
class GraphNode:
value: int
edges: List['GraphNode'] = dataclasses.field(default_factory=list)
class Graph:
def __init__(self) -> None:
self.vertices: List[Graph... | [
{
"point_num": 1,
"id": "all_params_annotated",
"question": "Does every function parameter in this file have a type annotation (excluding self/cls)?",
"answer": true
},
{
"point_num": 2,
"id": "every_function_under_20_lines",
"question": "Is every function in this file shorter than 2... | 3 | src/graph/graph.py | JadielTeofilo/General-Algorithms |
# -*- coding: utf-8 -*-
# This code is part of Qiskit.
#
# (C) Copyright IBM 2020.
#
# This code is licensed under the Apache License, Version 2.0. You may
# obtain a copy of this license in the LICENSE.txt file in the root directory
# of this source tree or at http://www.apache.org/licenses/LICENSE-2.0.
#
# Any modif... | [
{
"point_num": 1,
"id": "every_function_has_docstring",
"question": "Does every function in this file have a docstring?",
"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 | qiskit/optimization/_logging.py | hushaohan/aqua |
'''graph1 = {
'A' : ['B','S'],
'B' : ['A'],
'C' : ['D','E','F','S'],
'D' : ['C'],
'E' : ['C','H'],
'F' : ['C','G'],
'G' : ['F','S'],
'H' : ['E','G'],
'S' : ['A','C','G']
}'''
def create_graph():
graph1={}
no_of_nodes = int(input("Enter the no. of nodes in the graph : "))
for i in range(0,no_of_nodes):
pr... | [
{
"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 | Artificial Intelligence/dfs.py | Candida18/AI_CSS_MC |
# -*- coding: utf-8 -*-
#import midiate
import tkinter
from tkinter import font
def choose_input(midiate):
inputs = midiate.enum_input()
def f(x):
if x in inputs: return x
return (f('UM-1') or f('MPKmini2') or f('CASIO USB-MIDI') or f('USB Oxygen 8 v2') or f('A-500S') or f('loopMIDI port') or
... | [
{
"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 | devel.py | PGkids/pyMidiate |
"""Producer."""
import asyncio
import random
async def produce(queue, n):
"""Produce item for consume."""
count = 0
for x in range(1, n + 1):
count += 1
# produce an item
print('produce|await\n-----producing {}/{}--{}'.format(x, n, count))
# simulate i/o operation using sle... | [
{
"point_num": 1,
"id": "every_function_has_docstring",
"question": "Does every function in this file have a docstring?",
"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 | example/2.3.py | anhlt59/Asyncio_crawl |
import warnings
def deprecated(message):
def deprecated_decorator(func):
def deprecated_func(*args, **kwargs):
warnings.warn("{} is a deprecated function. {}".format(func.__name__, message),
category=DeprecationWarning,
stacklevel=2)
warnings.... | [
{
"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 | watson_developer_cloud/utils.py | trishamoyer/python-sdk |
# pylint:disable=unused-variable
# pylint:disable=unused-argument
# pylint:disable=redefined-outer-name
import pytest
from models_library.basic_types import LogLevel
from simcore_service_director_v2.core.settings import (
AppSettings,
BootModeEnum,
DynamicSidecarProxySettings,
DynamicSidecarSettings,
... | [
{
"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 | services/director-v2/tests/unit/test_core_settings.py | ITISFoundation/osparc-simcore |
# main.py
#
# Copyright 2020 Ferdinand Macha
#
# 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 License, or
# (at your option) any later version.
#
# This program is distr... | [
{
"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 | src/main.py | FerdinandMacha/ui-template |
from . import decorators
import anndata as ad
import scanpy as sc
import scprep
import warnings
_scran = scprep.run.RFunction(
setup="library('scran')",
args="sce, min.mean=0.1",
body="""
sce <- computeSumFactors(sce, min.mean=min.mean, assay.type="X")
sizeFactors(sce)
""",
)
@decorators.nor... | [
{
"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_has_docstring",
"question": "Does every function in this file have a docs... | 3 | openproblems/tools/normalize.py | scottgigante-immunai/openproblems |
from kafka import KafkaProducer
from json import dumps as json_dumps, load as json_load
import time
class ProducerServer(KafkaProducer):
def __init__(self, input_file, topic, **kwargs):
super().__init__(**kwargs)
self.input_file = input_file
self.topic = topic
def generate_data(self)... | [
{
"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_nested_function_def",
"question": "Does this file contain any function defined inside another function?",
"ans... | 3 | producer_server.py | estarguars113/udacity-spark-project |
from django.shortcuts import render, get_object_or_404
from .models import Person
# Create your views here.
from django.http import HttpResponse
def index(request):
return HttpResponse("Hello, world. You're at Computation History project.")
def person(request, person_id):
person_obj = get_object_or_404(P... | [
{
"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 | djweb/dj_comp_hist/views.py | cminsky/computation_hist |
# -*- coding: utf-8 -*-
# Copyright 2017, IBM.
#
# This source code is licensed under the Apache License, Version 2.0 found in
# the LICENSE.txt file in the root directory of this source tree.
# pylint: disable=invalid-name
"""
Rotation around the y-axis.
"""
from qiskit.circuit import Gate
from qiskit.circuit impor... | [
{
"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 | qiskit/extensions/standard/ry.py | ismaila-at-za-ibm/qiskit-terra |
# -*- coding: utf-8 -*-
from __future__ import absolute_import
from __future__ import division
from __future__ import print_function
from __future__ import unicode_literals
from future import standard_library
standard_library.install_aliases()
from builtins import *
from builtins import object
READS_LOCATION = 'genest... | [
{
"point_num": 1,
"id": "more_functions_than_classes",
"question": "Does this file define more functions than classes?",
"answer": false
},
{
"point_num": 2,
"id": "every_class_has_docstring",
"question": "Does every class in this file have a docstring?",
"answer": false
},
{... | 3 | genestack_client/unaligned_reads.py | genestack/python-client |
from django_messages_framework.storage.base import BaseStorage
class SessionStorage(BaseStorage):
"""
Stores messages in the session (that is, django.contrib.sessions).
"""
session_key = '_messages'
def __init__(self, request, *args, **kwargs):
assert hasattr(request, 'session'), "The ses... | [
{
"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 | django_messages_framework/storage/session.py | none-da/zeshare |
from typing import Any, Type, Tuple, NamedTuple, IO, Iterable, get_type_hints
from torchglyph.formats.primitive import loads_type, dumps_type
__all__ = [
'loads_token', 'iter_sentence',
'dumps_token', 'dump_sentence',
]
Token = Tuple[Any, ...]
Sentence = Tuple[Tuple[Any, ...], ...]
def loads_token(s: str, ... | [
{
"point_num": 1,
"id": "all_params_annotated",
"question": "Does every function parameter in this file have a type annotation (excluding self/cls)?",
"answer": true
},
{
"point_num": 2,
"id": "no_function_exceeds_5_params",
"question": "Does every function in this file take 5 or few... | 3 | torchglyph/formats/conll.py | speedcell4/torchglyph |
from threading import Thread
from django.http import HttpResponse
from django.shortcuts import render
from Vizard.models import User, Task, TaskScheduler
from Vizard.settings import RESPONSE
from Analyzer.execution import execute_jmeter, execute_locust, execute_regressiontest
from source.util import dump
scheduler =... | [
{
"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 | Vizard/Analyzer/views.py | styinx/Vizard |
import sys
import typing
import numba as nb
import numpy as np
@nb.njit((nb.i8[:], ), cache=True)
def solve(a: np.ndarray) -> typing.NoReturn:
n = len(a)
prev = np.empty(n, np.int64)
last = np.zeros(26, np.int64)
for i in range(n):
prev[i] = last[a[i]]
last[a[i]] = i + 1... | [
{
"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 | jp.atcoder/abc214/abc214_f/26740844.py | kagemeka/atcoder-submissions |
import json
import logging
import subprocess
import re
from conf.config import VOLATILITY_PATH
class MemoryDump:
def __init__(self, dump_path):
self.profile = None
self.memory_path = dump_path
logging.info('Loaded memory dump: {}'.format(self.memory_path))
def identify_profile(self)... | [
{
"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 | lib/core/memory.py | mkorman90/VolatilityBot |
import pytest
from tests.helpers.run_command import run_command
from tests.helpers.runif import RunIf
"""
A couple of sanity checks to make sure the model doesn't crash with different running options.
"""
def test_fast_dev_run():
"""Test running for 1 train, val and test batch."""
command = ["train.py", "++... | [
{
"point_num": 1,
"id": "every_function_has_docstring",
"question": "Does every function in this file have a docstring?",
"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/shell/test_basic_commands.py | hn04147/pytorch-project-template |
"""Use TIMESTAMP column for latest submission
Revision ID: eff79a07a88d
Revises: 83e6b2a46191
Create Date: 2017-01-08 22:20:43.814375
"""
# revision identifiers, used by Alembic.
revision = 'eff79a07a88d'
down_revision = '83e6b2a46191'
from alembic import op
import sqlalchemy as sa
import libweasyl
from libweasyl.... | [
{
"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_nested_function_def",
"question": "Does this file contain any function defined inside another function?",
"ans... | 3 | libweasyl/libweasyl/alembic/versions/eff79a07a88d_use_timestamp_column_for_latest_.py | greysteil/wzl-test |
import flask
import hashlib
import logging
logger = logging.getLogger("app.func")
def redirect_login():
return flask.redirect(flask.url_for('login'))
def get_gravatar_url(email):
base_url = "https://www.gravatar.com/avatar/"
email_hash = hashlib.md5(email.lower()).hexdigest()
style = 'retro'
full_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": "has_nested_function_def",
"question": "Does this file contain any function defined inside another function?",
"... | 3 | src/template/func.py | MadRussian/flask-template |
import numpy as np
import pandas as pd
from scipy import stats
import tensorflow as tf
### TFRecords Functions ###
def _float_feature(value):
"""Returns a float_list from a float / double."""
return tf.train.Feature(float_list=tf.train.FloatList(value=value))
def _int64_feature(value):
"""Returns an int6... | [
{
"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 | get_features/tf_utils.py | kslin/miRNA_models |
import datetime
from moto.core import BaseBackend
from moto.core.utils import iso_8601_datetime
class Token(object):
def __init__(self, duration, name=None, policy=None):
now = datetime.datetime.now()
self.expiration = now + datetime.timedelta(seconds=duration)
self.name = name
sel... | [
{
"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": "all_params_annotated",
"question": "Does every function parameter in this file have a type annotation (exclud... | 3 | moto/sts/models.py | andrewgross/moto |
import click
import pandas as pd
from civic_jabber_ingest.external_services.newspaper import load_news
from civic_jabber_ingest.external_services.open_states import get_all_people
from civic_jabber_ingest.regs.va import load_va_regulations
from civic_jabber_ingest.utils.config import read_config
@click.group()
def ... | [
{
"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 | civic_jabber_ingest/cli.py | civic-jabber/data-ingest |
from thread_handler.thread_handler import ThreadHandler
def run_centre(l):
import centre
def run_check_net(l):
import check_net
handle = ThreadHandler()
handle.spawn_thread(run_centre, [None])
handle.spawn_thread(run_check_net, [None]) | [
{
"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": "every_function_has_docstring",
"question": "Does every function in this file have a docstring?",
"answe... | 3 | run.py | BhavyaSheth22/hackit-iot |
import tkinter as tk
from tkinter import ttk
import json
from dashboard.entities.InputField import InputField
from dashboard.entities.StatusField import StatusField
class Devices(ttk.Frame):
"""
Devices Frame for Settings
"""
def __init__(self, parent, settings):
"""
Constructs a Warni... | [
{
"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 | dashboard/entities/Devices.py | Hexagoons/GUI-Arduino-Weather-Station |
#!/usr/bin/env python3
import sys
from itertools import groupby
from operator import itemgetter
SEP = "\t"
# d. O vôo de maior distância de cada companhia
class Reducer(object):
def __init__(self, infile=sys.stdin, separator=SEP):
self.infile = infile
self.sep = separator
def emit(self, key, value):
sys.s... | [
{
"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 | big-data-processamento-distribuido/atividade-1/1.d/reducer.py | andredarcie/my-data-science-notebooks |
from aioanticaptcha.antinetworking import *
import asyncio
class geetestProxyon(antiNetworking):
js_api_domain = ""
gt = ""
challenge = ""
geetest_lib = ""
async def solve_and_return_solution(self):
if (
await self.create_task(
{
"clientKey... | [
{
"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_nested_function_def",
"question": "Does this file contain any function defined inside... | 3 | aioanticaptcha/geetestproxyon.py | andrersp/aioanticaptcha |
#Imports
import numpy as np
from PIL import Image
class RescaleImage(object):
'''
Rescales the image to a given size.
'''
def __init__(self, output_size):
'''
Arguments:
output_size (tuple or int): Desired output size. If tuple, output is
matched to outp... | [
{
"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 | my_package/data/transforms/rescale.py | Rohan-Raj-1729/myPackage |
import pytest
from ats.users.models import User
from ats.users.tests.factories import UserFactory
@pytest.fixture(autouse=True)
def media_storage(settings, tmpdir):
settings.MEDIA_ROOT = tmpdir.strpath
@pytest.fixture
def user() -> User:
return UserFactory()
| [
{
"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 | ats/conftest.py | MahmoudFarid/ats |
import numpy as np
import theano, theano.tensor as T
def He(shape, name, fan_in):
""" He initialization of parameters """
rng = np.random.RandomState(1)
W = rng.normal(0, np.sqrt(2. / fan_in), size=shape)
return theano.shared(W, borrow=True, name=name).astype('float32')
def ConstantInit(shape, name, v... | [
{
"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 | lib/inits.py | charles96322/conditional-image-generation |
# Copyright (C) 2020 GreenWaves Technologies, SAS
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU Affero General Public License as
# published by the Free Software Foundation, either version 3 of the
# License, or (at your option) any later version.
# This progr... | [
{
"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": true
}... | 3 | tools/nntool/importer/tflite2/handlers/backend/sin.py | 00-01/gap_sdk |
#! /usr/bin/env python3
# -*-coding:utf-8 -*-
# @Time : 2019/06/15 20:29:38
# @Author : che
# @Email : ch1huizong@gmail.com
# bug
import os
from sqlalchemy import create_engine
from sqlalchemy import Table, Column, Integer, String, MetaData, ForeignKey
from sqlalchemy.orm import mapper, sessionmaker
path = "/... | [
{
"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_has_docstring",
"question": "Does every function in this file have a docstring?",
"answer": false
}... | 3 | sys/admin/py/metadata_manager.py | ch1huizong/learning |
import os
import torch
from torchvision.utils import make_grid
from tensorboardX import SummaryWriter
from dataloaders.utils import decode_seg_map_sequence
class TensorboardSummary(object):
def __init__(self, directory):
self.directory = directory
def create_summary(self):
writer = SummaryWrit... | [
{
"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 | utils/summaries.py | lzhmarkk/pytorch-deeplab-xception |
import yaml, pytest
def pytest_collect_file(parent, path):
if path.ext == ".yml" and path.basename.startswith("test"):
return YamlFile.from_parent(parent, fspath=path)
class YamlException(Exception):
"""Custom exception for error reporting."""
class YamlFile(pytest.File):
def collect(self):
... | [
{
"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 | hooks/yaml_plugin/pytest_yamlsound.py | Mjboothaus/intro-to-pytest |
from flask import app
from rq import get_current_job
from app import db
from app.models import Task
import sys
import time
from app.models import User, Post
import json
from flask import render_template
from app.email import send_email
def _set_task_progress(progress):
job = get_current_job()
if job:
... | [
{
"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_nested_function_def",
"question": "Does this file contain any function defined inside another function?",
... | 3 | app/tasks.py | kudnx/microblog |
"""
A Sphinx theme for Open edX documentation.
"""
from __future__ import absolute_import, print_function, unicode_literals
import datetime
import os
import six
from six.moves.urllib.parse import quote # pylint: disable=wrong-import-order
# When you change this, also update the CHANGELOG.rst file, thanks.
__versio... | [
{
"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 | edx_theme/__init__.py | openedx/edx-sphinx-theme |
import json
# import requests
# from pathlib import Path
# import re
with open('fetch_poslowie_from_sejm_gov_pl.json') as fp:
sejm_content = json.load(fp)
with open('fetch.json') as fp:
target_content = json.load(fp)
def normalize_name(v):
parts = v.split(' ')
return f"{parts[0]} {parts[-1]}"
sejm_n... | [
{
"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 | merge.py | watchdogpolska/campaign-zwierzeta |
import json
import elasticsearch.helpers
from log_conf import Logger
from utils import elastic_connection
def enrich(movie):
""" Enrich for search purposes """
if 'title' in movie:
movie['title_sent'] = 'SENTINEL_BEGIN ' + movie['title']
def reindex(es_connection, analysis_settings=None, mapping_se... | [
{
"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 | demo/index_ml_tmdb.py | cxcx/elasticsearch-learning-to-rank |
#!/usr/bin/env python3
import sys
import os
import re
def error_search(log_file):
error = input("What is the error? ")
returned_errors = []
with open(log_file, mode='r',encoding='UTF-8') as file:
for log in file.readlines():
error_patterns = ["error"]
for i in range(len(error.split(' '))):
... | [
{
"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 | 2. Using Python to Interact with the Operating System/Week-4.py | indahpuspitaa17/IT-Automation-with-Python |
import math
def update_position(posr, posc, dirties):
nearest_dirt = []
for i in range(len(dirties)):
# Euclidean distance
result = math.sqrt(((dirties[i][0] - posr) ** 2) + ((dirties[i][1] - posc) ** 2))
nearest_dirt.append(result)
return [x for (y,x) in sorted(zip(nearest_dirt,dir... | [
{
"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 | BotClean_Large.py | Aditya148/Hackerrank-Artificial-Intelligence |
import pyperclip
import pandas as pd
from modulos.conecao import *
def copiar(objeto): # função para copiar os objetos para área de transferência
global copiar # para resolver o porblema UnboundLocalError: local variable 'copiar' referenced before assignment:
opcao = int(input('Deseja copiar para área de tr... | [
{
"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_nested_function_def",
"question": "Does this file contain any function defined inside another function?",
"ans... | 3 | modulos/utils.py | oliverfaustino/NRPG-DataManager |
#!/usr/bin/env python
# -*- coding: utf-8 -*-
import json
from alipay.aop.api.response.AlipayResponse import AlipayResponse
from alipay.aop.api.domain.RechargeBill import RechargeBill
class AlipayCommerceCityfacilitatorDepositQueryResponse(AlipayResponse):
def __init__(self):
super(AlipayCommerceCityfac... | [
{
"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 | alipay/aop/api/response/AlipayCommerceCityfacilitatorDepositQueryResponse.py | snowxmas/alipay-sdk-python-all |
import torch
import torch.nn as nn
import torch.nn.functional as F
class QNetwork(nn.Module):
""" QNetwork model"""
def __init__(self, state_size, action_size, seed=0):
"""Constructor for QNetwork model to initialize states, actions and random seed
Args:
state_size: number of stat... | [
{
"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_has_docstring",
"question": "Does every function in this file have a docs... | 3 | Navigation/Model.py | RussJH/udacity |
import datetime
from repachain import RepaBlock, InvalidBlockException
import pytest
def test_block_creation():
now = datetime.datetime.now()
block = RepaBlock(0, now, "test", "prevhash")
assert block.index == 0
assert block.timestamp == now
assert block.data == "test"
assert block.previous_... | [
{
"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_nested_function_def",
"question": "Does this file contain any function defined inside another function?",
"ans... | 3 | tests/test_block.py | dyuri/minblock |
import unittest
import numpy as np
from dpipe.im.preprocessing import *
class TestPrep(unittest.TestCase):
def setUp(self):
self.x = np.random.rand(3, 10, 10) * 2 + 3
def test_normalize_image(self):
x = normalize(self.x)
np.testing.assert_almost_equal(0, x.mean())
np.testing.... | [
{
"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 | dpipe/im/tests/test_preprocessing.py | neuro-ml/deep_pipe |
ERRCODE = {
'SUCCEED': 0,
'NO_DUPLICATED_EDGE': 4
}
class Node:
name = ''
next_name_list = {}
def __init__(self, name: str):
self.name = name
self.next_name_list = {}
def add_next(self, name: str):
if name in self.next_name_list.keys():
return ERRCODE['NO_... | [
{
"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 | compartment/Node.py | buaacjw/Epidemic-Modeling-survey |
# project/app/api/summaries.py
from fastapi import APIRouter, HTTPException
from app.api import crud
from app.models.pydantic import SummaryPayloadSchema, SummaryResponseSchema
from app.models.tortoise import SummarySchema
router = APIRouter()
@router.post("/", response_model=SummaryResponseSchema, status_code=2... | [
{
"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_return_types_annotated",
"question": "Does every function in this file have a return type annotation?",
"answe... | 3 | app/api/summaries.py | JN513/FAST_crud |
#
# Copyright (c) 2021 Citrix Systems, 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... | [
{
"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 | nssrc/com/citrix/netscaler/nitro/resource/config/router/routerdynamicrouting_args.py | guardicore/nitro-python |
import json
class OrderException(Exception):
pass
def first_step(event, context):
print(event)
if event.get('orderId') is None:
raise OrderException('No orderId was provided!')
if event['orderId'] != 'abc123':
raise OrderException(f'No record found for recordId: {event["orderId"]}')
... | [
{
"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 | second_crack/handler.py | travis-deshotels/step-function |
#!/usr/bin/env python
# -*- coding: utf-8 -*-
import simplejson as json
from alipay.aop.api.constant.ParamConstants import *
from alipay.aop.api.domain.Member import Member
class MybankCreditUserRoleQueryModel(object):
def __init__(self):
self._member = None
@property
def member(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": "every_function_under_20_lines",
"question": "Is every function in this file shorter than 20 lines?",
"answ... | 3 | alipay/aop/api/domain/MybankCreditUserRoleQueryModel.py | articuly/alipay-sdk-python-all |
#!/usr/bin/env python
# This example uses Uvicorn package that must be installed. However, it can be
# replaced with any other ASGI-compliant server.
#
# NOTE: Python 3.6 requires aiocontextvars package to be installed.
#
# Run: python app_global_request.py
import rollbar
import uvicorn
from rollbar.contrib.starlett... | [
{
"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_under_20_lines",
"question": "Is every function in this file shorter than 20 lines?",
... | 3 | rollbar/examples/starlette/app_global_request.py | jackton1/pyrollbar |
from __future__ import print_function
from ghelpers import *
from helpers import write_json_log
class GAppsManager(object):
def __init__(self, config):
admin_email = config['super_admin_email']
key_path = config['key_file_path']
scopes = [
'https://www.googleapis.com/auth/admin... | [
{
"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 | includes/GAppsManager.py | OpenResourceManager/google-apps-delegate |
###############################################################################
#
# Tests for XlsxWriter.
#
# Copyright (c), 2013-2015, John McNamara, jmcnamara@cpan.org
#
from ..excel_comparsion_test import ExcelComparisonTest
from ...workbook import Workbook
class TestCompareXLSXFiles(ExcelComparisonTest):
"""... | [
{
"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": "more_functions_than_classes",
"question": "Does this file define more functions than classes?",
"answ... | 3 | xlsxwriter/test/comparison/test_chart_axis17.py | shareablee/XlsxWriter |
# -*- coding: utf-8 -*-
from ._parser import parse, parser, parserinfo
from ._parser import DEFAULTPARSER, DEFAULTTZPARSER
from ._parser import UnknownTimezoneWarning
from ._parser import __doc__
from .isoparser import isoparser, isoparse
__all__ = ['parse', 'parser', 'parserinfo',
'isoparse', 'isoparser'... | [
{
"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_nested_function_def",
"question": "Does this file contain any function defined inside another function?",
... | 3 | contrib/python/dateutil/dateutil/parser/__init__.py | HeyLey/catboost |
import pytest
from returns.future import FutureResult, future_safe
from returns.io import IOResult, IOSuccess
@future_safe
async def _coro(arg: int) -> float:
return 1 / arg
@pytest.mark.anyio
async def test_future_safe_decorator():
"""Ensure that coroutine marked with ``@future_safe``."""
future_insta... | [
{
"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/test_future/test_future_result/test_future_result_decorator.py | ftruzzi/returns |
from __future__ import with_statement
from google.appengine.api import files
from google.appengine.api.images import get_serving_url
from google.appengine.ext.blobstore import delete as blobstore_delete, BlobReader, MAX_BLOB_FETCH_SIZE
MAX_SIZE_IN_BYTES = MAX_BLOB_FETCH_SIZE - 1 #1015807 bytes ~ 0.969MB
def delete(bl... | [
{
"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": fals... | 3 | storagebin/internal/blobstore.py | Vraid-Systems/storagebin |
import enum
from abc import ABC, abstractmethod
from .errors import FieldError, FormError
from .fields import UnboundField
LAMBDA = lambda:0
class JsonForm(ABC):
def __init__(self, data: dict = None):
self.fields = list()
for name, obj in self.__class__.__dict__.items():
if not isinst... | [
{
"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 | jsonform/form.py | Pix-00/jsonform |
# Stack 활용해서 풀기
N = int(input())
class Node(object):
def __init__(self, value=None, next=None):
self.value = value
self.next = next
class Stack(object):
def __init__(self):
self.head = None
self.count = 0
def is_empty(self):
return not bool(self.head)
def pus... | [
{
"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 | acmicpc/9093/9093-1.py | love-adela/algorithm |
import logging
from rhasspy_weather.data_types.request import WeatherRequest
from rhasspy_weather.parser import rhasspy_intent
from rhasspyhermes.nlu import NluIntent
log = logging.getLogger(__name__)
def parse_intent_message(intent_message: NluIntent) -> WeatherRequest:
"""
Parses any of the rhasspy weathe... | [
{
"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": fals... | 3 | rhasspy_weather/parser/nlu_intent.py | arniebarni/rhasspy_weather |
from typing import Any
from tortoise import fields
from tortoise.models import Model
from crimsobot.models import DiscordUser
from crimsobot.models.user import User
class WordleResults(Model):
uuid = fields.UUIDField(pk=True)
name = fields.TextField(default='wordle result')
user = fields.ForeignKeyFiel... | [
{
"point_num": 1,
"id": "more_functions_than_classes",
"question": "Does this file define more functions than classes?",
"answer": false
},
{
"point_num": 2,
"id": "all_params_annotated",
"question": "Does every function parameter in this file have a type annotation (excluding self/c... | 3 | crimsobot/models/wordle_results.py | h-anjru/crimsoBOT |
from pytest import raises as assert_raises
from bundlebuilder.constants import (
DESCRIPTION_MAX_LENGTH,
COLUMN_TYPE_CHOICES,
SHORT_DESCRIPTION_LENGTH,
)
from bundlebuilder.exceptions import ValidationError
from bundlebuilder.models import ColumnDefinition
def test_column_definition_validation_fails():
... | [
{
"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 | tests/unit/models/secondary/test_column_definition.py | CiscoSecurity/tr-05-ctim-bundle-builder |
# -*- coding: utf-8 -*-
from ctypes import POINTER, c_int, c_double, c_float, c_size_t, c_void_p
import numpy as np
from pyfr.backends.base import ComputeKernel
from pyfr.ctypesutil import LibWrapper
# Possible CLBlast exception types
CLBlastError = type('CLBlastError', (Exception,), {})
class CLBlastWrappers(Li... | [
{
"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 | pyfr/backends/opencl/clblast.py | YuWangTAMU/PyFR |
import imp
import numpy as np
from PIL import Image
from PyQt5.QtGui import QImage
def smart_crop_image(image, x1, y1, x2, y2):
"""智能图像crop
Args:
image (numpy): 输入图像
x1 (int): 左上角x坐标
y1 (int): 左上角y坐标
x2 (int): 右下角x坐标
y2 (int): 右下角y坐标
Returns:
numpy: crop得到... | [
{
"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_params_annotated",
"question": "Does every function parameter in this file have a type annotation (ex... | 3 | red0orange/image_helper.py | red0orange/red0orange |
"""
状态模式
"""
from __future__ import annotations
from abc import ABC, abstractmethod
class Context:
# 状态(状态模式的判断)
_state: State = None
def __init__(self, state: State) -> None:
self.transition_to(state)
def transition_to(self, state: State) -> None:
# 根据不同状态,切换上下文
self._state ... | [
{
"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": "has_multiple_inheritance",
"question": "Does any class in this file use multiple inherit... | 3 | PythonInterview/DesigPattern/BehaviorPattern/State.py | xtawfnhdx/PythonInterview |
import sys
import json
import datetime
from terminalplot import plot
from balsam.launcher.dag import BalsamJob
now = '_'.join(str(datetime.datetime.now(datetime.timezone.utc)).split(" "))
def max_list(l):
rl = [l[0]]
mx = l[0]
for i in range(1, len(l)):
mx = max(mx, l[i])
rl.append(mx)
... | [
{
"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": "all_function_names_snake_case",
"question": "Are all function names in this file written in snake_case?",
"ans... | 3 | nas4candle/nasapi/evaluator/process_data.py | scrlnas2019/nas4candle |
"""This module is common core functions for datalight."""
import sys
import logging
import pathlib
import configparser
from typing import Union
from os import getcwd
import yaml
logging.basicConfig(stream=sys.stdout, level=logging.INFO)
logger = logging.getLogger('datalight')
class DatalightException(Exception):
... | [
{
"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 | datalight/common.py | LightForm-group/datalight |
def heapify(heap, root):
newRoot = root
leftChild = 2*root+1
rightChild = 2*root+2
if leftChild < len(heap) and heap[leftChild] > heap[newRoot]:
newRoot = leftChild
if rightChild < len(heap) and heap[rightChild] > heap[newRoot]:
newRoot = rightChild
if root!=newRoot:
heap[root],heap[newRoot]=heap[newRoot],h... | [
{
"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_params_annotated",
"question": "Does every function parameter in this file have a type annotation (ex... | 3 | code/heap.py | philipmassouh/RoA |
#-*-Mode:python;coding:utf-8;tab-width:4;c-basic-offset:4;indent-tabs-mode:()-*-
# ex: set ft=python fenc=utf-8 sts=4 ts=4 sw=4 et:
try:
from setuptools import setup, Command
except ImportError:
from distutils.core import setup, Command
class PyTest(Command):
user_options = []
def initialize_options(s... | [
{
"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 | setup.py | tomkcook/erlang_py |
"""Unit tests for utility.py"""
import imp
import os
import sys
module_name = 'provisioner'
here_dir = os.path.dirname(os.path.abspath(__file__))
module_path = os.path.join(here_dir, '../../')
sys.path.append(module_path)
fp, pathname, description = imp.find_module(module_name)
provisioner = imp.load_module(module_na... | [
{
"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 | app/tests/unit/test_unit_utility.py | cloudpassage/halo-test-environment |
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""Tests for `pytopocomplexity.entropy`"""
from __future__ import (absolute_import, division, print_function,
unicode_literals)
from future.builtins import (ascii, bytes, chr, dict, filter, hex, input, int,
map, next, o... | [
{
"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/test_entropy.py | williamscales/pytopocomplexity |
# -*- coding: utf-8 -*-
# this made for python3
import logging, os
def is_debug(sysname='Darwin'):
""" for device debug """
return os.uname().sysname == sysname
def module_logger(modname):
logger = logging.getLogger(modname)
handler = logging.StreamHandler()
formatter = logging.Formatter('[%(ascti... | [
{
"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": fals... | 3 | script/python3/util/__init__.py | setminami/IrControl |
# -*- coding: utf-8 -*-
from typing import Union
class PortBindingGuest:
__slots__ = ("port", "protocol")
port: int
protocol: str
def __init__(self, port: Union[int, str], protocol: str):
if isinstance(port, int):
self.port = port
else:
self.port = int(port)... | [
{
"point_num": 1,
"id": "more_functions_than_classes",
"question": "Does this file define more functions than classes?",
"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 | core/recc/container/struct/port_binding_guest.py | bogonets/answer |
class BasicSettingsApiCredentialsBackend(object):
CLIENT_ERROR_MESSAGE = "Client implementations must define a `{0}` attribute"
CLIENT_SETTINGS_ERROR_MESSAGE = "Settings must contain a `{0}` attribute"
def __init__(self, client):
self.client = client
@property
def base_url(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": "has_multiple_inheritance",
"question": "Does any class in this file use multiple inheritance?",
"answer": ... | 3 | generic_request_signer/backend.py | imtapps/generic-request-signer |
from fastapi import FastAPI
app = FastAPI()
playerinfo = {}
@app.post("/send")
async def send_info(player:str, x: int, y:int):
print(player, x, y)
playerinfo.update({player : [x, y]})
return "ok"
@app.get("/pos")
async def get_info():
return playerinfo
@app.post("/del")
async def 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 | serverside.py | ThomasDLi/multiplayer-terminal-game |
import unittest
from Signature import Signature
class TestSignature(unittest.TestCase):
secret = "TWFGC9YBBsj8FaQ%N4v6hmfzjXK6yqR6rEsvHfkLfwIUKCk@ngvWZ7CqBfC7G4I"
def _emulate_get_request(self):
return {"frontend": "9aho8o1bv2r7uqdtbpt7kq0l91",
"signature": {
"signe... | [
{
"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 | python/SignatureTest.py | gouravnema/signature |
import retro
import gym
import Interactive as I
import pyglet
from pyglet import gl
from pyglet.window import key as keycodes
class RetroInteractive(I.Interactive):
'''
interactive setup for retro games
'''
def __init__(self, game, state, scenario):
env = retro.make(game=game, state=state, sce... | [
{
"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 | src/RetroInteractive.py | stevenwalton/Retro-Learner |
from unittest import TestCase, mock
from bulksms.sms import send_single, send_bulk
class BulkSMSTestCase(TestCase):
def test_send_single_sms(self):
# Mock send single sms function.
mock_send_single = mock.create_autospec(send_single, return_value='results')
mock_send_single('0831234567', ... | [
{
"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 | tests/unit/test_bulksms.py | tsotetsi/django-bulksms |
class Value:
def __init__(self):
self.amount = 0
def __get__(self, obj, obj_type):
return self.amount
def __set__(self, obj, value):
self.amount = value - value * obj.commission
class Account:
amount = Value()
def __init__(self, commission):
self.commission = com... | [
{
"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 | coursera/course1-diving-in-python/week4/assignment2/solution.py | akrisanov/python_notebook |
from django.contrib.auth.forms import AuthenticationForm, UserCreationForm
from django.contrib.auth.models import User
class LoginForm(AuthenticationForm):
def __init__(self, *args, **kwargs):
super().__init__(*args, **kwargs)
self.fields['username'].label = ""
self.fields['password'].labe... | [
{
"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 | authapp/forms.py | EvgenDEP1/exam |
# Copyright (c) 2020 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 app... | [
{
"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/tutorials/lesson5/ddpg/replay_memory.py | jkren6/PARL |
"""Test module for detecting uncollectable garbage in PyTables.
This test module *must* be loaded in the last place. It just checks for
the existence of uncollectable garbage in ``gc.garbage`` after running
all the tests.
"""
import gc
from tables.tests import common
class GarbageTestCase(common.PyTablesTestCase... | [
{
"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_multiple_inheritance",
"question": "Does any class in this file use multiple inheritance?",
"answer": false
}... | 3 | tables/tests/test_garbage.py | stjordanis/PyTables |
from django import forms
from .models import UserAccount
class UserCreationForm(forms.ModelForm):
"""
A form for creating new users. Includes all the required
fields, plus a repeated password.
"""
password1 = forms.CharField(label='Password', widget=forms.PasswordInput)
password2 = forms.Cha... | [
{
"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": false
... | 3 | apps/accounts/forms.py | cloudartisan/dojomaster |
import typing
import sys
import numpy as np
def set_val(
a: np.array,
i: int,
x: int,
) -> typing.NoReturn:
while i < a.size:
a[i] = max(a[i], x)
i += i & -i
def get_mx(
a: np.array,
i: int,
) -> int:
mx = 0
while i > 0:
mx = max(mx, a[i])
i -= i & -i
return mx
def solve(
... | [
{
"point_num": 1,
"id": "all_params_annotated",
"question": "Does every function parameter in this file have a type annotation (excluding self/cls)?",
"answer": true
},
{
"point_num": 2,
"id": "all_function_names_snake_case",
"question": "Are all function names in this file written i... | 3 | src/atcoder/dp/q/sol_4.py | kagemeka/competitive-programming |
"""
interact with vector to play complete a knock knock joke
"""
import threading
import anki_vector
from anki_vector.events import Events
from anki_vector.user_intent import UserIntent, UserIntentEvent
def main():
def on_user_intent(robot, event_type, event, done):
user_intent = UserIntent(event)
... | [
{
"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 | projects/knock_knock.py | KryoKorpz/Vector |
# coding: utf-8
"""
VAAS API
No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator) # noqa: E501
The version of the OpenAPI document: 0.0.1
Generated by: https://openapi-generator.tech
"""
from __future__ import absolute_import
import unittest
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 | test/test_inline_object3.py | vertica/vertica-accelerator-cli |
#!/usr/bin/env python3
import rospy
from std_msgs.msg import String
from geometry_msgs.msg import Twist
mag=0.0
dir=0.0
max_linear_speed = 1.0
max_rotational_speed = 2.5
def callback_vector(msg):
global mag, dir
mag,dir = float(msg.data.split(",")[0]),float(msg.data.split(",")[1])
def obs_avoider():
g... | [
{
"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 | scripts/Obstacle Avoidance using PointCloud/pcl_obstacle_avoidance.py | leander-dsouza/Gazebo |
#!/usr/bin/python
#
# create_package_removed.py
# automatically generate checks for removed packages
#
# NOTE: The file 'template_package_removed' should be located in the same working directory as this script. The
# template contains the following tags that *must* be replaced successfully in order for the checks to... | [
{
"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 | packages/scap-security-guide/scap-security-guide/RHEL6/input/checks/templates/create_package_removed.py | csmith-tresys/clip |
import logging
from chatterbot.logic import LogicAdapter
from sugaroid.brain.postprocessor import random_response
from sugaroid.brain.constants import IMITATE
from sugaroid.brain.ooo import Emotion
from sugaroid.brain.preprocessors import normalize
from sugaroid.core.statement import SugaroidStatement
class Imitate... | [
{
"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 | sugaroid/brain/imitate.py | blackxspade/sugaroid |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.