source string | points list | n_points int64 | path string | repo string |
|---|---|---|---|---|
'''
实验名称:【我的学习系统】之OLED中文显示(I2C总线)
版本:v1.0
日期:2021.6.5
作者:kaixindelele
'''
from machine import SoftI2C,Pin #从machine模块导入I2C、Pin子模块
from ssd1306 import SSD1306_I2C #从ssd1306模块中导入SSD1306_I2C子模块
class OLED_Show:
def __init__(self, sda_pin=18, scl_pin=23):
# 初始化I2C,设定好端口
self.i2c =... | [
{
"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 | oled_class.py | kaixindelele/ssd1306OLED--MicroPython-ESP32----GB2312- |
from api.component import Component
from api.shapes import Rectangle as Rect
class Rectangle(Component):
def defParameters(self):
self.newParameter("l")
self.newParameter("w")
def defInterfaces(self):
self.newInterface("t")
self.newInterface("b")
self.newInterface("l")
self.newInterface("... | [
{
"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 | resources/mechanics_lib/Rectangle.py | PRECISE/ROSLab |
from flask import Flask, request, jsonify
from flask_jsonrpc import JSONRPC
# import json_to_db
import psycopg2
import sys
from obs import *
import config
app = Flask(__name__)
app.config.from_object(config.DevelopmentMaxConfig)
jsonrpc = JSONRPC(app,'/api')
sys.path.insert(0,app.config['SQL_PATH'])
from sql_method... | [
{
"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 | server_data_tmp/app/local_server.py | ilvivl/Python_Project |
# uncompyle6 version 2.9.10
# Python bytecode 2.7 (62211)
# Decompiled from: Python 3.6.0b2 (default, Oct 11 2016, 05:27:10)
# [GCC 6.2.0 20161005]
# Embedded file name: iso2022_jp_3.py
import _codecs_iso2022
import codecs
import _multibytecodec as mbc
codec = _codecs_iso2022.getcodec('iso2022_jp_3')
class Codec(code... | [
{
"point_num": 1,
"id": "every_class_has_docstring",
"question": "Does every class 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 | Leak #5 - Lost In Translation/windows/Resources/Python/Core/Lib/encodings/iso2022_jp_3.py | bidhata/EquationGroupLeaks |
from paramak import RotateStraightShape
class VacuumVessel(RotateStraightShape):
"""A cylindrical vessel volume with constant thickness.
Arguments:
height (float): height of the vessel.
inner_radius (float): the inner radius of the vessel.
thickness (float): thickness of the vessel
... | [
{
"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": "more_functions_than_classes",
"question": "Does this file define more functions than cla... | 3 | paramak/parametric_components/vacuum_vessel.py | generein/paramak |
import socket
from logging import getLogger
from .abs import AddressProviderAbs, AddressProviderException
logger = getLogger(__name__)
class AddressProviderHostName(AddressProviderAbs):
@property
def name(self):
return "hostname"
def _detect_ip_address(self) -> None:
try:
da... | [
{
"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 | ddns_clienter_core/runtimes/address_providers/host_name.py | rexzhang/ddns-clienter |
# coding: utf-8
"""
Kubernetes
No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator) # noqa: E501
OpenAPI spec version: v1.13.5
Generated by: https://openapi-generator.tech
"""
from __future__ import absolute_import
import unittest
import kube... | [
{
"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_under_20_lines",
"question": "Is every function in this file shorter than 20 lines?",
"ans... | 3 | kubernetes_asyncio/test/test_v1_azure_file_persistent_volume_source.py | PidgeyBE/kubernetes_asyncio |
# coding: utf-8
from message.api import MessageService
from thrift.transport import TSocket
from thrift.transport import TTransport
from thrift.protocol import TBinaryProtocol
from thrift.server import TServer
import smtplib
from email.mime.text import MIMEText
from email.header import Header
sender = 'imoocd@163.com... | [
{
"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 | message-thrift-python-service/message/message_service.py | xiaocong123/microservice |
# Copyright (c) 2013 The Johns Hopkins University/Applied Physics Laboratory
# 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/... | [
{
"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 | jacket/tests/compute/unit/keymgr/test_key_mgr.py | bopopescu/jacket |
import math
def mod(x, y):
return x - y * math.trunc(x / y)
"""(a + b * 10 + c * 100) * (d + e * 10 + f * 100) =
a * d + a * e * 10 + a * f * 100 +
10 * (b * d + b * e * 10 + b * f * 100)+
100 * (c * d + c * e * 10 + c * f * 100) =
a * d + a * e * 10 + a * f * 100 +
b * d * 10 + b * e * 100 + b * f * 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": "every_function_under_20_lines",
"question": "Is every function in this file shorter than... | 3 | out/euler04.py | Melyodas/metalang |
from flask import Flask
from flask import request, redirect, render_template
from fastai.learner import load_learner
import pathlib
from fastai.vision.core import PILImage
import platform
import ensign_multicat as utils
application = Flask(__name__)
application.config['MAX_CONTENT_LENGTH'] = 12 * 1024 * 1024
MIN_STAND... | [
{
"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 | application.py | phoughton/ensign_multicat |
from django.db import models
class OsebaManager(models.Manager):
def create_oseba(self, priimek=None, ime=None, status=None, kvalifikacije=None, podjetje=None):
if not podjetje:
raise ValueError("Izbrati moraš podjetje")
oseba = self.model(
priimek=priimek,
ime=... | [
{
"point_num": 1,
"id": "every_class_has_docstring",
"question": "Does every class 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": true
},... | 3 | eda5/partnerji/managers.py | vasjapavlovic/eda5 |
"""empty message
Revision ID: 4dd64e951c80
Revises:
Create Date: 2020-09-16 12:37:40.312182
"""
from alembic import op
import sqlalchemy as sa
# revision identifiers, used by Alembic.
revision = '4dd64e951c80'
down_revision = None
branch_labels = None
depends_on = None
def upgrade():
# ### commands auto gene... | [
{
"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 | migrations/versions/4dd64e951c80_.py | jb3rndt/flask-wol-api |
import sys
import argparse
from opennebula_gc import clean_opennebula
def cli():
parser = argparse.ArgumentParser(
prog="Clean OpenNebula Resources",
description="CLI tool to clean outdated resources in OpenNebula")
commands = parser.add_subparsers(
title="Commands",
dest="co... | [
{
"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 | opennebula_gc/cli.py | cloudlinux/opennebula-gc |
from datetime import datetime
from app.ModelTrainer import ModelTrainer
class Pipeline:
model_trainer = ModelTrainer()
def execute(self):
target_predictor = self.model_trainer.train()
print("Start predicting values:")
print(datetime.now())
target_predictor.calculate_prediction_accuracies()
def... | [
{
"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 | app/Pipeline.py | rojinva/music-recommendations_Hybrid |
# nlantau, 2021-01-17
INT_MIN=-32422
def cut_log(p,n):
r = [0 for _ in range(n+1)]
r[0] = 0
for j in range(1,n+1):
q = INT_MIN
for i in range(1,j+1):
q = max(q, p[i] + r[j-i])
r[j] = q
return r[n]
# Clever solutions
def cl(p,n):
l = [0]
for _ in range(n)... | [
{
"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_under_20_lines",
"question": "Is every function in this file shorter than ... | 3 | Codewars_Python/memoized_log_cutting.py | nlantau/Codewars_2020_2021 |
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
from nodal.core.nodes import BaseNode
class NoOp(BaseNode):
@property
def output_type(self) -> object:
if not self.has_input(0):
return self._output_type
return self.input(0).output_type
def _execute(self):
if not self.h... | [
{
"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 | nodal/nodes/noop.py | thimic/PyFlow |
from django import forms
from core.utils import horizontal_form_helper
from enrollment.models import Enrollment
class EnrollmentForm(forms.ModelForm):
def __init__(self, *args, **kwargs):
super(EnrollmentForm, self).__init__(*args, **kwargs)
self.helper = horizontal_form_helper()
for fie... | [
{
"point_num": 1,
"id": "every_class_has_docstring",
"question": "Does every class 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 | events/ropeconjvp2021/forms.py | con2/kompassi |
class Point():
def __init__(self, x, y):
self.x = x
self.y = y
def __repr__(self):
return f"({self.x}, {self.y})"
points_a = [Point(0,0), Point(9,-2)]
points_b = [Point(-1,5), Point(3,4), Point(9,3)]
i, j = 0, 0
flag = True
xd, yd, min_dist = float('Inf'), float('Inf'), float(... | [
{
"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 | computational_geometry/staircase_closest_pair.py | suleymanaslan/bilkent-coursework |
import unittest
import coopy
from coopy.symbolic.types.primitives import SymbolicReal
class TestNoConcretization(unittest.TestCase):
def setUp(self):
coopy.reset()
coopy.solver.disable_concretization()
def tearDown(self):
coopy.solver.enable_concretization()
def test_reals(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": "all_function_names_snake_case",
"question": "Are all function names in this file written in snake_case?",
"answer"... | 3 | test/noconcretize.py | abarreal/coopy |
from functools import wraps
def multiply_by(multiplier):
def decorator(func):
@wraps(func)
def wrapper(*args, **kwargs):
func_name = func.__name__
print(f'Calling "{func_name}({args[0]}, {args[1]})" function')
print(f'"{func_name}" function is multiplied by {mul... | [
{
"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": "no_function_exceeds_5_params",
"question": "Does every function in this file take 5 or fewer parameters (e... | 3 | materials/decorator_with_args.py | vyahello/python-decorators-cheetsheet |
import secrets
import time
class Utils:
_instance = None
def __init__(self) -> None:
pass
@staticmethod
def generateRandomId():
"""
Generates a random hexicdecimal string
Returns:
`str`: string with hexidecimal values
>>>
"""
toke... | [
{
"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 | odds/common/utils.py | conrad-evans/sports_betting_api |
from __future__ import absolute_import
from __future__ import division
from __future__ import print_function
import pandas as pd
class Index(object):
def __init__(self, idx):
self.idx = idx
@classmethod
def to_pandas(indices):
if isinstance(indices[0], pd.RangeIndex):
merged... | [
{
"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 | python/ray/dataframe/index.py | cathywu/ray |
import binascii
import datetime
import inspect
import logging
import os
from pathlib import Path
from . import exceptions
logger = logging.getLogger(__name__)
def generate_token(n=24, *args, **kwargs):
return str(binascii.hexlify(os.urandom(n)), "utf-8")
def build_claim_iss(attr, *args, **kwargs):
return... | [
{
"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 | sanic_jwt/utils.py | Gdeon1337/sanic-jwt |
# Copyright (c) 2019 - The Procedural Generation for Gazebo authors
# For information on the respective copyright owner see the NOTICE file
#
# 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
#
#... | [
{
"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 | pcg_libraries/src/pcg_gazebo/parsers/sdf/kd.py | boschresearch/pcg_gazebo_pkgs |
import logging
import threading
import time
from typing import Any
class SetInterval:
def __init__(self, interval: float, action: Any) -> None:
"""コンストラクタ
Args:
interval (float): 呼び出し間隔
action (Any): 呼ぶ出す関数
"""
logging.info("init")
self.interval = i... | [
{
"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 | src/util/SetInterval.py | gekkyo/dendai_ict |
import operator
from functools import reduce
from django.db import models
from django.db.models import Q
class AuditTrailManager(models.Manager):
def get_queryset(self):
return super(AuditTrailManager, self).get_queryset().filter(
version_superseded_time=None)
class OutletQuerySet(models.Que... | [
{
"point_num": 1,
"id": "more_functions_than_classes",
"question": "Does this file define more functions than classes?",
"answer": false
},
{
"point_num": 2,
"id": "has_multiple_inheritance",
"question": "Does any class in this file use multiple inheritance?",
"answer": false
}... | 3 | cashup/managers.py | remarkablerocket/cashup |
import websockets
from wsocket.wcthread import WCThread
class WSoClient:
def __init__(self, **kwargs):
self._cli = WCThread(**kwargs)
self._flag_running = False
def connect(self):
self._cli.start()
self._flag_running = True
def close(self):
self._cli.stop_client()
... | [
{
"point_num": 1,
"id": "has_multiple_inheritance",
"question": "Does any class in this file use multiple inheritance?",
"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 | wsocket/wsoclient.py | LegallGuillaume/wSocket |
from __future__ import absolute_import, unicode_literals
from django.core.urlresolvers import reverse_lazy
from django.views.generic import ListView, DeleteView
from braces.views import LoginRequiredMixin
from ..models import AccessToken
class AuthorizedTokensListView(LoginRequiredMixin, ListView):
"""
Sho... | [
{
"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 | oauth2_provider/views/token.py | resulto/django-oauth-toolkit |
#
# Copyright (c) 2020, Gabriel Linder <linder.gabriel@gmail.com>
#
# Permission to use, copy, modify, and/or distribute this software for any
# purpose with or without fee is hereby granted, provided that the above
# copyright notice and this permission notice appear in all copies.
#
# THE SOFTWARE IS PROVIDED "AS IS"... | [
{
"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_under_20_lines",
"question": "Is every function in this file shorter than ... | 3 | dargor/colored_tracebacks.py | dargor/dargor-py |
# -*- coding: utf-8 -*-
# Authors: Binh Nguyen <tuan-binh.nguyen@inria.fr>
from hidimstat.knockoffs.data_simulation import simu_data
from hidimstat.knockoffs.gaussian_knockoff import (
_estimate_distribution, gaussian_knockoff_generation)
SEED = 42
fdr = 0.1
def test_estimate_distribution():
n = 100
p =... | [
{
"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 | hidimstat/knockoffs/tests/test_generate_knockoff.py | GuillaumeFavelier/hidimstat |
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""Tests for the MD5 hasher."""
import unittest
from plaso.analyzers.hashers import md5
from tests.analyzers.hashers import test_lib
class MD5Test(test_lib.HasherTestCase):
"""Tests the MD5 hasher."""
def testFileHashMatchesEmptyFile(self):
"""Tests that hash... | [
{
"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/analyzers/hashers/md5.py | cugu-stars/plaso |
# Ejercicio 1
def sumArray1(array): #* Solución 1
# Escribir una función que tenga como parámetro de entrada un array y retorne la suma de los mismos
return sum(array)
def sumArray2(array): #* Solución 2
# Escribir una función que tenga como parámetro de entrada un array y retorne la suma de los mism... | [
{
"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 | Laboratorio 1 (07-09-2021)/p1_funcion_que_retorne_la_suma_de_los_elementos_de_un_array.py | ItaloCcosccoAlvis/Laboratorio-ADA---Italo-Ccoscco-Alvis |
import json
class BaseSerializable:
basicTypes = [str, int, float, bool]
def toJson(self, indent=None):
'''Convert to JSON'''
return json.dumps(self.toDict(), indent=indent)
def toDict(self):
'''Internal use method'''
diccionario = {}
for attr, value in self.__dict__.items():
tipo = type(self.__dict_... | [
{
"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 | src/serialiJSON/serialiJSON.py | matias-alejandro/serialiJSON |
'''
Created on May 7, 2021
@author: mballance
'''
import cocotb
from fwnoc_tests.fwnoc.fwnoc_test_base import FwnocTestBase
from fwnoc_bfms.fwnoc_channel_bfm import FwNocPacket
class SingleInflightP2P(FwnocTestBase):
async def run(self):
pkt = FwNocPacket()
pkt.src_tile_x = 0
pkt.src_... | [
{
"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 | verilog/dv/common/python/fwnoc_tests/fwnoc/single_inflight_00_01_sz_zero.py | Featherweight-IP/fwnoc |
import re
import typing
EXPANSION_PATTERN = re.compile(r"(\d*)\(([^()]*)\)")
def solve(st: str) -> str:
def expand(match: typing.Match) -> str:
if match.group(1):
return match.group(2)*int(match.group(1))
else:
return match.group(2)
old = None
while old != st:
... | [
{
"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_return_types_annotated",
"question": "Does every function in this file have a return type annotation?",
"an... | 3 | 5_kyu/Simple_string_expansion.py | UlrichBerntien/Codewars-Katas |
"""All config load functions."""
import os
import sys
import yaml
class config():
"""Create pia config class."""
def __init__(self):
super(config, self).__init__()
def config_read(self, config_file="~/.pia.conf"):
"""Read config in yaml format."""
try:
with open(os.pat... | [
{
"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 | src/fhs_pia_wireguard_netns/pia_class/config.py | foxhunt72/fhs-pia-wireguard-netns |
def new_put_operation(key, val):
return {'operation': 'put', 'key': key, 'val': val}
def new_get_operation(key):
return {'operation': 'get', 'key': key}
def new_append_operation(key, val):
return {'operation': 'append', 'key': key, 'val': val}
def new_slice_operation(key, slice_):
return {'operati... | [
{
"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 | src/operation.py | abhisheksp/byzantine-chain-replication |
import os
import logging
import pandas as pd
from datetime import date
from shioaji import Shioaji
class Session(Shioaji):
def __init__(self, simulation: bool = False, timeout: int = 10000) -> None:
"""
Args:
simulation:
timeout:
Notes: The ID of test account ran... | [
{
"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 | stockbot/ticker/sinotrade/session.py | tanlin2013/stockbot |
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
__author__ = 'ipetrash'
from timeit import default_timer
class TimeThis:
def __init__(self, title="TimeThis"):
self.title = title
self.start_time = None
def __enter__(self):
self.start_time = default_timer()
return self
de... | [
{
"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 | time_this_using_with.py | DazEB2/SimplePyScripts |
from shexer.core.instances.annotators.strategy_mode.base_strategy_mode import BaseStrategyMode
from shexer.core.instances.pconsts import _S, _P, _O
class AllClasesMode(BaseStrategyMode):
def __init__(self, annotator_ref):
super().__init__(annotator_ref)
def is_relevant_triple(self, a_triple):
... | [
{
"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 | shexer/core/instances/annotators/strategy_mode/all_classes_mode.py | DaniFdezAlvarez/shexerp3 |
"""
Created on 20 Jan 2021
@author: Bruno Beloff (bruno.beloff@southcoastscience.com)
https://realpython.com/python-logging/
"""
import logging
import sys
# --------------------------------------------------------------------------------------------------------------------
# noinspection PyPep8Naming
class Loggin... | [
{
"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 | src/scs_core/sys/logging.py | south-coast-science/scs_core |
import asyncio
async def worker(name, queue):
print('start worker: ', name)
while True:
await asyncio.sleep(1)
s = await queue.get()
print(s, end='', flush=True)
queue.task_done()
async def cr1():
print('[f1]')
queue = asyncio.Queue()
queue.put_nowait('a')
queue.put_nowait('b')
queue.... | [
{
"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 | ed/l/python/examples/async/queue.py | cn007b/stash |
import numpy as np
from graphidx.idx import BiAdjacent
def square():
head = np.array([0, 0, 1, 2])
tail = np.array([1, 2, 3, 3])
return BiAdjacent(head, tail)
def test_sqare():
neigh = square()
assert repr(neigh) == "BiAdjacent[m = 4, n = 4]"
assert set(neigh[0]) == {1, 2}
assert set(nei... | [
{
"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 | python/test/test_biadjacent.py | EQt/graphidx |
# Copyright 2019 Google LLC. All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or a... | [
{
"point_num": 1,
"id": "more_functions_than_classes",
"question": "Does this file define more functions than classes?",
"answer": true
},
{
"point_num": 2,
"id": "all_return_types_annotated",
"question": "Does every function in this file have a return type annotation?",
"answer"... | 3 | tfx/utils/channel.py | yongsheng268/tfx |
import random
from model.contact import Contact
def test_delete_some_contact(app, db, check_ui):
if len(db.get_contacts_list()) == 0:
app.form.create(Contact(first_name="VVVVVVV"))
old_contacts_list = db.get_contacts_list()
user = random.choice(old_contacts_list)
app.form.delete_contact_by_id(... | [
{
"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 | test/test_del_contact.py | AlsuKhalva/zombi_training |
from django.db import models
from django.utils.translation import ugettext_lazy as _
from wagtail.core.models import Page
from wagtail.admin.edit_handlers import FieldPanel
from wagtailtextanalysis.text_analysis import (
TextAnalysis,
KeyPhrasesField,
SentimentField,
)
class ArticlePage(Page, TextAnalysi... | [
{
"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_nested_function_def",
"question": "Does this file contain any function defined inside another function?",
"answer": ... | 3 | wagtailtextanalysis/tests/demosite/models.py | marteinn/wagtail-text-analysis |
import frappe
def validate(doc, event):
update_expense_account(doc)
validate_expense_account(doc)
def on_cancel(doc, event):
cancel_sle(doc)
cancel_commission_invoice(doc)
def cancel_sle(doc):
filters = {
"voucher_type": "Purchase Invoice",
"voucher_no": doc.name,
"docstatus": 1
}
for name, in frappe.g... | [
{
"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 | tzdealer/hook/purchase_invoice.py | Lewinta/tzdealer |
from hipchat import HipChatManager
import time
import configparser
_MAX_SLEEP_TIME = 5
_MIN_SLEEP_TIME = 2
_SPAM_EODBOT_URL = 3500
class HipChatMonitor:
def __init__(self, eodBotParser):
print("Initializing HipChatMonitor with eodBotParser: ",eodBotParser)
self.sleepTime = _MIN_SLEEP_TIME
self.lastIdChecked = ... | [
{
"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 | client/hipchat/HipChatMonitor.py | xEoDx/eodbot |
def get_workout(day):
if day == 'Monday':
return 'Chest+biceps'
elif day == 'Tuesday':
return 'Back+triceps'
elif day == 'Wednesday':
return 'Core'
elif day == 'Thursday':
return 'Legs'
elif day == 'Friday':
return 'Shoulders'
elif day in ('Saturday', 'Su... | [
{
"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 | days/34-36-refactoring/refactoring_yo.py | pruty20/100daysofcode-with-python-course |
"""Find Least Common Multiple."""
# https://en.wikipedia.org/wiki/Least_common_multiple
def find_lcm(num_1, num_2):
"""Find the least common multiple of two numbers.
>>> find_lcm(5,2)
10
>>> find_lcm(12,76)
228
"""
if num_1>=num_2:
max_num=num_1
else:
max_n... | [
{
"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 | maths/find_lcm.py | KirilBangachev/Python |
#! python3
"""
Unit tests for confluenceclient.
"""
import pytest
from confluenceexport.confluenceclient import ConfluenceClient
def test_create_confluence_client_with_empty_url() -> None:
"""
Confluence client creation with invalid url must raise an exception.
"""
with pytest.raises(Exception):
... | [
{
"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 | tests/test_confluenceclient.py | cledouarec/confluence-extractor |
import numpy as np
import sys
sys.path.insert(0, 'embedding/')
NORMALIZATION = 'individual' # 'individual', 'once', or 'none'
EPSILON = 1e-5 # only to prevent division by zero
from fasttext_web_table_embeddings import FastTextWebTableModel
class WebTableMultiEmbeddingModel:
def __init__(self, filenames):
... | [
{
"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 | deco_classifier/web_table_multi_embedding_model.py | guenthermi/table-embeddings |
# coding: utf-8
"""
여보세요 Service Reddit
"""
# std lib
from __future__ import unicode_literals
from django.conf import settings
from logging import getLogger
# external lib
from praw import Reddit as RedditAPI
# yeoboseyo
from yeoboseyo.services import Service
# create logger
logger = getLogger(__name__)
__all__ = ... | [
{
"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 | yeoboseyo/services/reddit.py | foxmask/yeoboseyo-django |
from yowsup.structs import ProtocolEntity, ProtocolTreeNode
class AckProtocolEntity(ProtocolEntity):
'''
<ack class="{{receipt | message | ?}}" id="{{message_id}}">
</ack>
'''
def __init__(self, _id, _class):
super(AckProtocolEntity, self).__init__("ack")
self._id = _id
sel... | [
{
"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 | libs/yowsup/yowsup/yowsup/layers/protocol_acks/protocolentities/ack.py | akshitpradhan/TomHack |
#!/usr/bin/env python
import argparse
import exceptions
import glob
import os
import subprocess
import sys
import shutil
def _find_sandbox_root(start_dir):
dir = start_dir
parent = os.path.abspath(os.path.join(dir, '..'))
while parent != dir:
if os.path.isfile(os.path.join(dir, 'sand... | [
{
"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 | reset-build-dir.py | jasonivey/scripts |
# -*- coding: utf-8 -*-
# PLEASE DO NOT EDIT THIS FILE, IT IS GENERATED AND WILL BE OVERWRITTEN:
# https://github.com/ccxt/ccxt/blob/master/CONTRIBUTING.md#how-to-contribute-code
from ccxt.binance import binance
class binanceus(binance):
def describe(self):
return self.deep_extend(super(binanceus, self... | [
{
"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 | python/ccxt/binanceus.py | npomfret/ccxt |
import inspect
class _D:
def _m(self): pass
class _C:
def _m(self): pass
_x = _C()
_x2 = _D()
a=121111
r = input('hahah')
print(r)
raise AttributeError('Provider test already registered')
print (type(_C),_x.__class__,dir(_x),"------------")
import types
###print (dir(types))
print (type(inspect))
... | [
{
"point_num": 1,
"id": "every_class_has_docstring",
"question": "Does every class 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 | tests/test_python3_dbb.py | bopopescu/NovalIDE |
from typing import Any, Dict, List, Mapping
def replace_placeholders_with_files(
operations: Dict[str, Any],
files_map: Dict[str, List[str]],
files: Mapping[str, Any],
) -> Dict[str, Any]:
path_to_key_iter = (
(value.split("."), key)
for (key, values) in files_map.items()
for v... | [
{
"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": "no_function_exceeds_5_params",
"question": "Does every function in this file take 5 or fewer parameters (excluding ... | 3 | strawberry/file_uploads/data.py | nyejon/strawberry |
"""Module for making a key based on a master key, a salt, and a passphrase
"""
import dataclasses
import os
import pbkdf2
DEFAULT_ENTRY_KEY_SIZE = 256 // 8
DEFAULT_ENTRY_SALT_SIZE = 128 // 8
DEFAULT_SALT_SIZE = 64 // 8
@dataclasses.dataclass(frozen=True)
class KeyCipher:
"""Can generate a new key, and recreate a... | [
{
"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/pbkdvault/keycipher.py | KalleDK/py-pbkdvault |
import os
from norc.settings import NORC_LOG_DIR, BACKUP_SYSTEM
if BACKUP_SYSTEM == 'AmazonS3':
from norc.norc_utils.aws import set_s3_key
from norc.settings import (AWS_ACCESS_KEY_ID,
AWS_SECRET_ACCESS_KEY, AWS_BUCKET_NAME)
def s3_backup(fp, target):
NUM_TRIES = 3
for i in range(NUM_TRIES)... | [
{
"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_under_20_lines",
"question": "Is every function in this file shorter than ... | 3 | norc_utils/backup.py | Smarsh/norc |
# Copyright 2020 Pants project contributors (see CONTRIBUTORS.md).
# Licensed under the Apache License, Version 2.0 (see LICENSE).
import re
from pants.testutil.pants_integration_test import (
ensure_daemon,
run_pants_with_workdir,
temporary_workdir,
)
from pants.util.contextutil import overwrite_file_con... | [
{
"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": "every_function_under_20_lines",
"question": "Is every function in this file shorter than 20 lines?",
"... | 3 | src/python/pants/core/goals/fmt_integration_test.py | thamenato/pants |
import sys
def modexp(M, s, n):
'''calculate s**n % M'''
assert n >= 0
assert M > 2
s %= M
def loop(k):
if k == 0:
return 1
elif k == 1:
return s
h = loop(k // 2)
if k % 2 == 0:
return h * h % M
else:
return h ... | [
{
"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 | 2020/25/ans1.py | chirsz-ever/aoc |
import os
from django.conf import settings
import requests
def get_packet_file_path():
return os.path.join(settings.PROJECT_ROOT, 'static', settings.SPONSORSHIP_PACKET_FILE) if settings.SPONSORSHIP_PACKET_FILE else None
def fetch_packet():
if settings.SPONSORSHIP_PACKET_FILE and settings.SPONSORSHIP_PACKET_UR... | [
{
"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 | shared/packet.py | Tookmund/hackerforce |
# Copyright 1997 - 2018 by IXIA Keysight
#
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"),
# to deal in the Software without restriction, including without limitation
# the rights to use, copy, modify, merge, 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": "all_function_names_snake_case",
"question": "Are all function names in this file written in snake_case?",... | 3 | RestPy/ixnetwork_restpy/testplatform/sessions/ixnetwork/vport/protocols/bgp/cluster.py | ralfjon/IxNetwork |
import pandas as pd
import os.path
import matplotlib.pyplot as plt
def makeTimeSeries(df):
ts = pd.to_datetime(df.dt)
df.index = ts
return df.drop('dt', axis=1)
def differenciate(X):
diff = list()
for i in range(1, len(X)):
value = X[i] - X[i - 1]
diff.append(value)
X_diff=pd.D... | [
{
"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_under_20_lines",
"question": "Is every function in this file shorter than ... | 3 | project/reports/global_warming/myutils.py | vinceHardy/learning |
# -*- coding: utf-8 -*-
#
# Meta testing tests
from __future__ import absolute_import
from pmdarima.utils.testing import assert_raises
def test_assert_raises():
def raise_value_error():
raise ValueError()
def raise_type_error():
raise TypeError()
def innocuous_function():
pass... | [
{
"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 | pmdarima/utils/tests/test_testing.py | Juanlu001/pmdarima |
"""
Landscape omnikeeper REST API
No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator) # noqa: E501
The version of the OpenAPI document: v1
Generated by: https://openapi-generator.tech
"""
import sys
import unittest
import okclient
from okclien... | [
{
"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 | test/test_relation_state.py | max-bytes/omnikeeper-client-python |
from marshmallow import INCLUDE, Schema, fields, post_load, pre_load
class Dates:
def __init__(self, on_sale=None, foc=None, unlimited=None, **kwargs):
self.on_sale = on_sale
self.foc = foc
self.unlimited = unlimited
self.unknown = kwargs
class DatesSchema(Schema):
onsaleDate... | [
{
"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 | marvelous/dates.py | rkuykendall/marvelous |
import os
from ....utils import catkin_success
from ....utils import in_temporary_directory
from ....utils import redirected_stdio
from ....workspace_assertions import assert_no_warnings
from ....workspace_assertions import assert_warning_message
from ....workspace_assertions import assert_workspace_initialized
@in_... | [
{
"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 | tests/system/verbs/catkin_init/test_init.py | lucasw/catkin_tools |
import numpy as np
# Nonlinearity functions (Numpy implementation)
nl_linear = lambda x: x
nl_tanh = lambda x: np.tanh(x)
nl_sigmoid = lambda x: 1./(1+np.exp(-x))
nl_rect = lambda x: np.clip(x, 0, np.inf)
#nl_rect = lambda x: np.clip(x, -np.inf, np.inf)
nl_shallow_rect = lambda x: np.clip(0.1*x, 0, np.inf)
nl_clip =... | [
{
"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 | network_model/tools/bn_tools_t.py | b3ttin4/network_simulation_and_analysis |
# This example requires the 'message_content' privileged intent to function.
import random
import discord
from discord.ext import commands
class MyContext(commands.Context):
async def tick(self, value):
# reacts to the message with an emoji
# depending on whether value is True or False
... | [
{
"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_class_has_docstring",
"question": "Does every class in this file have a docstring?"... | 3 | examples/custom_context.py | Ryomen-Sukuna/discord.py |
# -*- coding:utf-8 -*-
from .bean import Bean
class Metric(Bean):
_tbl = 'metric'
_id = 'id'
_cols = 'id, name, update_at'
def __init__(self, _id, name, update_at):
self.id = _id
self.name = name
self.update_at = update_at
@classmethod
def query(cls, page, limit, que... | [
{
"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 | rrd/model/metric.py | mia0x75/dashboard |
#!/usr/bin/env python
"""Create two randomly generated matrices, of the specified sizes and write them
to JSON files.
"""
import json
import numpy as np
def read(path):
with open(path, 'rb') as f:
matrix = np.fromfile(f, dtype=np.float32)
return matrix
def write(path, matrix):
with open(path, 'wb') as f:
... | [
{
"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 | web/node_modules/weblas/test/data/binary_matrix.py | egornagornov3tf4k/Zeta36y |
from prismriver.plugin.common import Plugin
from prismriver.struct import Song
class LyrsterPlugin(Plugin):
ID = 'lyrster'
def __init__(self, config):
super(LyrsterPlugin, self).__init__('Lyrster', config)
def search_song(self, artist, title):
to_delete = ["'", '!', '(', ')', '[', ']']
... | [
{
"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 | prismriver/plugin/lyrster.py | anlar/prismriver-lyrics |
""" User account models """
from django.db import models
from django.contrib.auth.models import PermissionsMixin
from django.contrib.auth.models import AbstractUser
from django.contrib.auth.base_user import BaseUserManager
class UserManager(BaseUserManager):
use_in_migrations = True
def _create_user(self, use... | [
{
"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 | tradebook/users/models.py | isuryanarayanan/tradebook-backend |
from node import Node
class ListDinamic:
def __init__(self):
self.__node = None
self.__length = 0
def length(self):
return self.__length
def add(self, value):
if self.__node is None:
self.__node = Node(value)
else:
self.__node.add(value)
... | [
{
"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 | listDinamic.py | thiagorocha503/data-struture |
"""Test case that checks the working of the utils/command/gen_uml.py module."""
from utils.model.gen_uml import generate
import importlib_metadata
class PseudoFile:
def __init__(self):
self.data = ""
def write(self, data):
self.data += data
def close(self):
pass
def test_loadi... | [
{
"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 | tests/test_gen_uml.py | MarianelaSena/gaphor |
from copy import deepcopy
from typing import Dict, List
from prepnet.executor.converter_array import ConverterArray
class ConfigurationContextBase:
def __init__(self, columns: List[str]):
self.columns: List[str] = columns
self.converters = []
def to_converter_array(self)->ConverterArray:
... | [
{
"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 | prepnet/functional/configuration_context_base.py | elda27/prepnet |
import paddle
import paddle.nn as nn
class DiceLoss(nn.Layer):
def __init__(self, loss_weight=1.0):
super(DiceLoss, self).__init__()
self.loss_weight = loss_weight
def forward(self, input, target, mask, reduce=True):
batch_size = input.shape[0]
input = nn.functional.sigmoid(in... | [
{
"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 | models/loss/dice_loss.py | JennyVanessa/PANet-Paddle |
import tensorflow as tf
def masked_softmax_cross_entropy(preds, labels, mask):
"""Softmax cross-entropy loss with masking."""
loss = tf.nn.softmax_cross_entropy_with_logits(logits=preds, labels=labels)
mask = tf.cast(mask, dtype=tf.float32)
mask /= tf.reduce_mean(mask)
loss *= mask
return ... | [
{
"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_function_names_snake_case",
"question": "Are all function names in this file written in snake_case?",
"answer":... | 3 | eslearn/machine_learning/test/GCNNCourseCodes/metrics.py | dongmengshi/easylearn |
from torch.utils.data import Dataset
from typing import List
import torch
from .. import SentenceTransformer
from ..readers.InputExample import InputExample
class SentencesDataset(Dataset):
"""
Dataset for smart batching, that is each batch is only padded to its longest sequence instead of padding all
sequ... | [
{
"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 | sentence_transformers/datasets/SentencesDataset.py | dd-dos/sentence-transformers |
import re
import numpy as np
from pathlib import Path
from scipy.stats.mstats import gmean
from src.ema import ModelEma
def initialize_amp(model,
opt_level='O1',
keep_batchnorm_fp32=None,
loss_scale='dynamic'):
from apex import amp
model.nn_module, mod... | [
{
"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 | src/utils.py | lRomul/argus-bengali-ai |
# Time: O(m * n)
# Space: O(m * n)
class Solution(object):
def numEnclaves(self, A):
"""
:type A: List[List[int]]
:rtype: int
"""
directions = [(0, -1), (0, 1), (-1, 0), (1, 0)]
def dfs(A, i, j):
if not (0 <= i < len(A) and 0 <= j < len(A[0]) and A[i][j]... | [
{
"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 | Algo and DSA/LeetCode-Solutions-master/Python/number-of-enclaves.py | Sourav692/FAANG-Interview-Preparation |
"""Consistent Hash CacheNode class"""
class CacheNode:
"""CacheNode, record cache node info and send cache method"""
def __init__(self, ip):
self._ip = ip
@property
def ip(self):
return self._ip
@ip.setter
def ip(self, value: str):
self._ip = value
def send(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 | week05/CacheNode.py | tonylixu/architect-001 |
# -*- coding: utf-8 -*-
# Define here the models for your spider middleware
#
# See documentation in:
# http://doc.scrapy.org/en/latest/topics/spider-middleware.html
from scrapy import signals
class RedditCrawlerSpiderMiddleware(object):
# Not all methods need to be defined. If a method is not defined,
# sc... | [
{
"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 | unit3/spiders/p5_handson/reddit_crawler/middlewares.py | nulearn3296/scrapy-training |
from typing import Dict, Any
from xmltodict import parse # type: ignore # hints missing...
from xml.parsers.expat import ExpatError
from mds_logging import getLogger, timed
from gateway_request_environment_plugin import GatewayRequestEnvironment
from agw_request import AGWRequestResponse
from service_exception_handl... | [
{
"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": "more_functions_than_classes",
"question": "Does this file define more functions than classes?",
"answer"... | 3 | agw/processors/xml_to_json.py | MyDataShare/access-gateway |
#!/usr/bin/env python
# coding=utf-8
"""
This experiment showcases the concept of commands in Sacred.
By just using the ``@ex.command`` decorator we can add additional commands to
the command-line interface of the experiment::
$ ./05_my_commands.py greet
INFO - my_commands - Running command 'greet'
WARNING - my_... | [
{
"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 | examples/05_my_commands.py | michaelwand/sacred |
#!/usr/bin/env python3.8
"""Entrypoint into the base nari cli client"""
from argparse import ArgumentParser, Namespace
from logging import basicConfig, getLogger, Logger, CRITICAL, INFO
from typing import List
from nari.io.reader.actlog import ActLogReader
from nari.io.reader import Reader
from nari.cli.fightlist imp... | [
{
"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 | nari/cli/client.py | lunarrize/nari |
import re
def atoi(text):
return int(text) if text.isdigit() else text
def natural_keys(text):
"""
alist.sort(key=natural_keys) sorts in human order
http://nedbatchelder.com/blog/200712/human_sorting.html
(See Toothy's implementation in the comments)
"""
return [atoi(c) for ... | [
{
"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 | deepdanbooru/extra/__init__.py | GreenManSK/DeepDanbooru |
from lektor.constants import PRIMARY_ALT
from lektor.i18n import get_i18n_block
from lektor.types.base import Type
class FakeType(Type):
def value_from_raw(self, raw):
return None
def to_json(self, pad, record=None, alt=PRIMARY_ALT):
rv = Type.to_json(self, pad, record, alt)
rv["is_fa... | [
{
"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 | lektor/types/fake.py | yagebu/lektor |
import requests
import amsfodconfig as cfg
import json
#Get the Authentication token
def getToken():
headers = {"Content-Type": "application/x-www-form-urlencoded"}
params = {"grant_type": "client_credentials", "scope": "https://hpfod.com/tenant", "client_id": cfg.apiKey, "client_secret": cfg.secret}
... | [
{
"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 | fod_token.py | DarthDobber/FOD-API-Wrapper |
#
# Copyright (c) 2013 Juniper Networks, Inc. All rights reserved.
#
import os
from setuptools import setup, find_packages, Command
class RunTestsCommand(Command):
description = "Test command to run testr in virtualenv"
user_options = []
def initialize_options(self):
self.cwd = None
def fina... | [
{
"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 | src/config/vnc_openstack/setup.py | madkiss/contrail-controller |
import json
from loader.KITTI15Mask import KITTI15Mask
from loader.SceneflowMask import SceneflowMask
from loader.DrivingStereoMask import DrivingStereoMask
from loader.MiddleburyMask import MiddleburyMask
def get_loader(name):
"""get_loader
:param name:
"""
print(name.lower())
return {
'... | [
{
"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 | loader/__init__.py | YaoChengTang/DecNet |
from asyncio import Future
import pytest
from jeepney.routing import Router
from jeepney.wrappers import new_method_return, new_error, DBusErrorResponse
from jeepney.bus_messages import message_bus
def test_message_reply():
router = Router(Future)
call = message_bus.Hello()
future = router.outgoing(call)
... | [
{
"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 | .venv/lib/python3.8/site-packages/jeepney/tests/test_routing.py | RivtLib/replit01 |
from keras.models import Sequential
from keras.layers import Dense
from keras.layers import LSTM
from matplotlib import pyplot
from pandas import DataFrame
from numpy import array
# return training data
def get_train():
seq = [[0.0, 0.1], [0.1, 0.2], [0.2, 0.3], [0.3, 0.4], [0.4, 0.5]]
seq = array(seq)
X, y = seq[:... | [
{
"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 | Resources/books/long_short_term_memory_networks_with_python/code/lesson_12/tune_batch_size.py | gdepalma93/bright-athlete-academy |
"""Utility code for running native pytorch distributed"""
import os
import torch.distributed as dist
def init_workers_file():
rank = int(os.environ['SLURM_PROCID'])
n_ranks = int(os.environ['SLURM_NTASKS'])
sync_file = 'file:///tmp/%s_%s_pytorch_sync' % (
os.environ['USER'], os.environ['SLURM_JOB... | [
{
"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 | GraphLearning/src/distributed/torch.py | caditi97/exatrkx-ctd2020 |
#%%
def ich_haette_gerne_so_viele_katzen(anzahl: int) -> str:
text = "Ich hätte gerne {} Katze".format(anzahl)
if anzahl > 1:
text += "n"
return text
# %%
# Damit können wir schon ein kleines Spiel bauen.
# Hier wird eine Zufallszahl zwischen 1 und 20 gewählt:
import random
zufallszahl = random.ran... | [
{
"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 | pyventskalender/tag04_loesung.py | kopp/pyventskalender |
import os
import platform as p
import sys
import json
from os.path import join
def read_json(path):
try:
with open(path) as f:
output = json.loads(f.read())
return output
except:
try:
with open(join("..","..", path)) as f:
output = json.loads(f.re... | [
{
"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 | common/myUtils.py | AlexandreMPDias/build-setup |
from __future__ import absolute_import
# NaughtyAmerica plugin by AliAbdul
from .Podcast import Podcast
##################################################
class NaughtyAmerica(Podcast):
def __init__(self):
Podcast.__init__(self, "Naughty America", "NaughtyAmerica.png", "http://www.naughtyamerica.com/one_minclip_ar... | [
{
"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 | porncenter/src/Additions/NaughtyAmerica.py | builder08/enigma2-plugins |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.