source string | points list | n_points int64 | path string | repo string |
|---|---|---|---|---|
from aocd import get_data
def simulate(a, part2=False):
p = a.copy()
ip = 0
i = 0
while True:
if not 0 <= ip < len(p):
return i
prev_ip = ip
ip = ip + p[ip]
p[prev_ip] += 1 if not part2 or p[prev_ip] < 3 else -1
i += 1
def part1(a):
return simu... | [
{
"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 | 2017/05.py | bernikr/advent-of-code |
from ._util import get_app_id, create_app, get_app_info
from ._constants import *
def get_id(c):
"""
Find app-id by project name. Add id to config.
"""
app_name = c.config.project.name
app_id = get_app_id(c, app_name)
if not isinstance(app_id, str):
return app_id
c.config.data.app... | [
{
"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 | tasks/application.py | webtweakers/deploy |
# Copyright (c) 2017 Sony Corporation. All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicabl... | [
{
"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 | python/src/nnabla/utils/cli/utility.py | syoyo/nnabla |
import flask
from flask import Flask
from .database import Database
app = Flask(__name__)
DATABASE = '/tmp/kittens.db'
def get_db():
db = getattr(flask.g, '_database', None)
if not db:
db = flask.g._database = Database(DATABASE)
return db
@app.teardown_appcontext
def close_db(exception):
db... | [
{
"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 | kittenkollector/__init__.py | jedevc/hack-the-midlands |
# coding: utf-8
"""
Kubernetes
No description provided (generated by Swagger Codegen https://github.com/swagger-api/swagger-codegen)
OpenAPI spec version: v1.13.1
Generated by: https://github.com/swagger-api/swagger-codegen.git
"""
from __future__ import absolute_import
import os
import sys
i... | [
{
"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": "more_functions_than_classes",
"question": "Does this file define more functions than classes?",
"answer":... | 3 | kubernetes/test/test_v1beta1_custom_resource_definition_version.py | iguazio/python |
import functools
from torch.nn import functional as F
from torchsparse.sparse_tensor import *
__all__ = ['spact', 'sprelu', 'spleaky_relu']
def spact(inputs, act_funct=F.relu):
features = inputs.F
coords = inputs.C
cur_stride = inputs.s
output_features = act_funct(features)
output... | [
{
"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 | torchsparse/nn/functional/activation.py | ashawkey/torchsparse |
"""
@name: PyHouse_Install/src/Install/private.py
@author: D. Brian Kimmel
@contact: D.BrianKimmel@gmail.com
@copyright: (c) 2016-2016 by D. Brian Kimmel
@license: MIT License
@note: Created May 13, 2016
@Summary: Create .private
Create the /etc/pyhouse/.private.yaml file that will hold the secret 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": "every_class_has_docstring",
"question": "Does every class in this file have a docstring?",
"answer": false... | 3 | src/Install/private.py | DBrianKimmel/PyHouse_Install |
from crispy_forms.helper import FormHelper
from crispy_forms.layout import Layout, HTML, Submit
from django import forms
from django.contrib.auth.mixins import LoginRequiredMixin
from django.urls import reverse_lazy
from django.views.generic import UpdateView
from YtManagerApp.models import UserSettings
class Settin... | [
{
"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 | app/YtManagerApp/views/settings.py | Netrecov/ytsm |
import math
from ga import GA, Individual, IndividualMeta, Selector
from ga_codec import CodecPlugin
from ga_cm import CmPlugin
from ga_iter import StopIterPlugin
from ga_generate import GeneratePlugin
from ga_selector import Selector
def get_fitness(individual: Individual):
val = individual.phenotype.phenotype
... | [
{
"point_num": 1,
"id": "every_function_under_20_lines",
"question": "Is every function in this file shorter than 20 lines?",
"answer": false
},
{
"point_num": 2,
"id": "every_function_has_docstring",
"question": "Does every function in this file have a docstring?",
"answer": fal... | 3 | example/simple_ga/simple_ga.py | lipopo/ga |
import torch
from lab.configs import BaseConfigs
class DeviceInfo:
def __init__(self, *,
use_cuda: bool,
cuda_device: int):
self.use_cuda = use_cuda
self.cuda_device = cuda_device
self.cuda_count = torch.cuda.device_count()
self.is_cuda = self.us... | [
{
"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 | lab/helpers/pytorch/device.py | vidhiJain/lab |
from unittest.mock import MagicMock, patch, call
from tagtrain import data
from . import fake
from tagtrain.tagtrain.tt_remove import Remove
@patch('tagtrain.data.by_owner.remove_user_from_group')
def test_unknown_group(remove_user_from_group):
remove_user_from_group.side_effect = data.Group.DoesNotExist()
... | [
{
"point_num": 1,
"id": "every_function_under_20_lines",
"question": "Is every function in this file shorter than 20 lines?",
"answer": true
},
{
"point_num": 2,
"id": "all_function_names_snake_case",
"question": "Are all function names in this file written in snake_case?",
"answ... | 3 | tests/tagtrain/test_remove.py | c17r/TagTrain |
libpath = ""
def _set_lib_path(p_path):
global libpath
if libpath != "":
libpath += " -L%s" % p_path
else:
libpath += "-L%s" % p_path
def _get_lib_path():
return libpath
libs = ""
def _add_lib(p_lib):
global libs
if libs != "":
libs += " -l%s" % p_lib
else... | [
{
"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 | Config/libraries.py | HashzSoftware/YamlMake |
# coding: utf-8
"""
Algorithmia Management APIs
APIs for managing actions on the Algorithmia platform # noqa: E501
OpenAPI spec version: 1.0.1
Contact: support@algorithmia.com
Generated by: https://openapi-generator.tech
"""
from __future__ import absolute_import
import unittest
import algor... | [
{
"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 | env/Lib/site-packages/test/test_details.py | Vivek-Kamboj/Sargam |
import sys
from collections import defaultdict
def letter_counts(code):
counts = defaultdict(lambda: 0)
for c in code:
counts[c] += 1
return dict(counts)
def answer(path):
with open(path) as f:
codes = f.read().strip().split("\n")
n2, n3 = 0, 0
for code in codes:
cou... | [
{
"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 | 2018/day02.py | tcbegley/advent-of-code |
import json
from sanic import Sanic, text
from sanic.log import LOGGING_CONFIG_DEFAULTS, logger
LOGGING_CONFIG = {**LOGGING_CONFIG_DEFAULTS}
LOGGING_CONFIG["formatters"]["generic"]["format"] = "%(message)s"
LOGGING_CONFIG["loggers"]["sanic.root"]["level"] = "DEBUG"
app = Sanic("FakeServer", log_config=LOGGING_CONFI... | [
{
"point_num": 1,
"id": "all_function_names_snake_case",
"question": "Are all function names in this file written in snake_case?",
"answer": true
},
{
"point_num": 2,
"id": "every_function_under_20_lines",
"question": "Is every function in this file shorter than 20 lines?",
"answ... | 3 | tests/fake/server.py | Lin0818/sanic |
import logging
import base64
from abc import ABC, abstractmethod
logger = logging.getLogger(__name__)
class EncoderStrategy(ABC):
"""
interface that defines the way the encoding is done
"""
@abstractmethod
def encode(self, string):
"""
encode
"""
pass
@abstra... | [
{
"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 | EncoderStrategy.py | Samielleuch/PentboxClone |
# Copyright (c) 2016 Mirantis Inc.
#
# Licensed under the Apache License, Version 2.0 (the License);
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
# Unless required by applicable law or agreed to in writing, so... | [
{
"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 | cloudferry/tools/mark_volumes_deleted.py | SVilgelm/CloudFerry |
# Copyright 2019-2021 ETH Zurich and the DaCe authors. All rights reserved.
""" A test for the MapToForLoop transformation. """
import dace
import numpy as np
from dace.transformation.dataflow import MapExpansion, MapToForLoop
@dace.program
def map2for(A: dace.float64[20, 20, 20]):
for k in range(1, 19):
... | [
{
"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 | tests/transformations/maptoforloop_test.py | Walon1998/dace |
import os
import pandas as pd
from string import Template
import wget
csv_file_path = "https://docs.google.com/spreadsheets/d/1AlflVlTg1KmajQrWBOUBT2XeoAUqfjB9SCQfDIPvSXo/export?format=csv&gid=565678921"
project_card_path = "assets/templates/project_card.html"
projects_page_path = "assets/templates/template_projects.m... | [
{
"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 | populate_projects.py | anibalsolon/brainhack-donostia.github.io |
# Copyright (c) 2012-2018 SoftBank Robotics. All rights reserved.
# Use of this source code is governed by a BSD-style license that can be
# found in the COPYING file.
import qisys.sh
import qitoolchain.qipackage
import qisrc.svn
class SvnPackage(qitoolchain.qipackage.QiPackage): # pylint: disable=too-many-instance-... | [
{
"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 | python/qitoolchain/svn_package.py | vbarbaresi/qibuild |
import numpy as np
NW = (52.58363, 13.2035)
SE = (52.42755, 13.62648)
NE = (NW[0], SE[1])
SW = (SE[0], NW[1])
def flatten_list(irregularly_nested_list):
"""Generator which recursively flattens list of lists
:param irregularly_nested_list: iterable object containing iterable and non-iterable objects as elemen... | [
{
"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_nested_function_def",
"question": "Does this file contain any function defined insid... | 3 | backend_app/util.py | GGCarrotsBerlin/test |
from torch.distributions import constraints
from torch.distributions.transforms import AbsTransform
from pyro.distributions.torch import TransformedDistribution
class ReflectedDistribution(TransformedDistribution):
"""
Equivalent to ``TransformedDistribution(base_dist, AbsTransform())``,
but additionally... | [
{
"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 | pyro/distributions/reflected.py | ajrcampbell/pyro |
import torch
import torch.nn as nn
import torch.nn.functional as F
class GraphClassifier(nn.Module):
def __init__(self, hidden_dim: int, num_classes: int, pooling_op: str):
super(GraphClassifier, self).__init__()
# TODO: Define the graph classifier
# graph classifier can be an MLP
s... | [
{
"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 | src/modeling/tasks/graph_classification.py | Srijanb97/gcn_assignment |
#Copyright (c) 2020 Jan Kiefer
#THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
#IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
#FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
#AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES... | [
{
"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 | freggersbot/data/path.py | Jan000/Python-Freggers-Bot |
# Licensed under the Apache License, Version 2.0 (the "License"); you may
# not use this file except in compliance with the License. You may obtain
# a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# 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 | cinder/tests/unit/api/v3/stubs.py | bswartz/cinder |
from django.db.models.signals import post_save, post_delete
from django.dispatch import receiver
from django.contrib.auth.models import User
from .models import Profile
from django.core.mail import send_mail
from django.conf import settings
def createProfile(sender, instance, created, **kwargs):
if created:
... | [
{
"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 | users/signals.py | kiman121/ms-developers |
import numpy as np
from pddlgym.core import get_successor_states, InvalidAction
from pddlgym.inference import check_goal
def get_all_reachable(s, A, env, reach=None):
reach = {} if not reach else reach
reach[s] = {}
for a in A:
try:
succ = get_successor_states(s,
... | [
{
"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 | mdp.py | GCrispino/vi-pddlgym |
# coding: utf-8
from ac_engine.actions.abstract import AbstractAction
class AbstractStatistics(AbstractAction):
EXCLUSION_SET = ()
@property
def data_container_class(self):
return None
def prepare_data(self):
for offer in self.offers:
if offer:
self.offe... | [
{
"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 | app/ac_engine/actions/statistics.py | marwahaha/allecena |
from flask import Flask, request, jsonify
from flask import templating
from . import helper
from . import db
from .config import Config
app = Flask(__name__)
Config = Config()
@app.route("/")
def index():
return templating.render_template("index.html", maxlength=Config.url_length)
@app.route("/r/<token>")
def to... | [
{
"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 | URL_SHORTENER/app/__init__.py | NeonCrafter13/url_shortener |
# 多线程编程
# GIL锁在单cpu上只能执行一个,效率低
# 多进程可以在多个cpu上执行
# 多线程和多线程都能够并发为什么在IO操作是不使用多进程
# 进程切换比较耗时
# 1.对于耗cpu,多进程优于多线程
# 2.对于IO操作,多线程由于多进程
from concurrent.futures import ProcessPoolExecutor, ThreadPoolExecutor
import os
import time
# pid = os.fork() # 同时会存在两个进程,会拷贝父进程中的代码和数据到子进程中
#
# print("boby")
#
# if pid == 0:
# pr... | [
{
"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 | pythonBase/advancePyton/chapter11/process_test.py | cangchengkun/pythonbase |
##
# Copyright (c) 2007-2016 Apple Inc. All rights reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable l... | [
{
"point_num": 1,
"id": "more_functions_than_classes",
"question": "Does this file define more functions than classes?",
"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 | caldavclientlibrary/protocol/webdav/tests/test_head.py | LaudateCorpus1/ccs-caldavclientlibrary |
from django.contrib.auth.hashers import UNUSABLE_PASSWORD_PREFIX
from django.test import TestCase
from django_fire.hashers import (
FIRED_PASSWORD_PREFIX,
is_password_fired, make_fired_password,
)
class TestHashers(TestCase):
def test_is_password_fired(self):
# unusable password made by django_fi... | [
{
"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 | django_fire/tests/test_hashers.py | lordpeara/django-fire |
#!python
#!/usr/bin/env python
from kivy.app import App
from kivy.uix.bubble import Bubble
from kivy.animation import Animation
from kivy.uix.floatlayout import FloatLayout
from kivy.lang import Builder
from kivy.factory import Factory
from kivy.clock import Clock
from actilectrum.gui.kivy.i18n import _
Builder.load_... | [
{
"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 | actilectrum/gui/kivy/uix/context_menu.py | Actinium-project/Actilectrum |
from typing import Dict
from msrc.appconfig import from_argv
import pytest
from common import AllTypes, all_args, all_values, En
def test_argv():
loaded = from_argv(AllTypes, all_args)
assert loaded == all_values
def test_argv_unknown():
unknown = ["--unknown"]
loaded = from_argv(AllTypes, all_args+... | [
{
"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 | msrc-appconfig/tests/from_argv_test.py | microsoft/msrc-appconf |
def insertion_sort(array):
N = len(array)
# Outer for-loop, such that for each iteration, k elements from 0, ... k
# are to be assumed to be sorted or about to be sorted.
for k in range(1, N):
for j in range(k, 0, -1):
if (array[j - 1] > array[j]):
array[... | [
{
"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 | Voltron/Voltron/Algorithms/Sorting/insertion_sort.py | ernestyalumni/HrdwCCppCUDA |
__title__ = "simulation"
__author__ = "murlux"
__copyright__ = "Copyright 2019, " + __author__
__credits__ = (__author__, )
__license__ = "MIT"
__email__ = "murlux@protonmail.com"
# Local imorts
from playground.enums import RunMode
from playground.simulation.backtesting import BackTestingOperation
from playground.si... | [
{
"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 | playground/simulation/operations/types.py | murlokito/playground |
# -*- coding: utf-8 -*-
from enum import Enum
class LowerCaseNameEnum(Enum):
def str(self):
return self.name.lower()
class Case(LowerCaseNameEnum):
GENITIVE = 0
DATIVE = 1
ACCUSATIVE = 2
INSTRUMENTAL = 3
PREPOSITIONAL = 4
class Gender(LowerCaseNameEnum):
MALE = 0
FEMALE = ... | [
{
"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 | pytrovich/enums.py | alexeyev/pytrovich |
import re
def isNice(a):
if str(a).find("ab") > -1:
return False
if str(a).find("cd") > -1:
return False
if str(a).find("xy") > -1:
return False
if str(a).find("pq") > -1:
return False
ca = str(a).count("a")
ce = str(a).count("e")
ci = str(a).count("i")
... | [
{
"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 | day05/day05.py | binarygondola/adventofcode-2015 |
# Python program for implementation of MergeSort
def mergeSort(arr):
if len(arr) >1:
mid = len(arr)//2 # Finding the mid of the array
L = arr[:mid] # Dividing the array elements
R = arr[mid:] # into 2 halves
mergeSort(L) # Sorting the first half
mergeSort(R) # Sort... | [
{
"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 | Python/merge_sort.py | enrinal/-HACKTOBERFEST2K20 |
import pytest
from unittest import mock
from mitmproxy.test import tflow
from mitmproxy import io
from mitmproxy import exceptions
from mitmproxy.addons import clientplayback
from mitmproxy.test import taddons
def tdump(path, flows):
w = io.FlowWriter(open(path, "wb"))
for i in flows:
w.add(i)
cla... | [
{
"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 | test/mitmproxy/addons/test_clientplayback.py | nikofil/mitmproxy |
""" Tests the creation of tables, and the methods of the sql class
"""
from pyrate.repositories.sql import Table
from utilities import setup_database
class TestSql:
""" Tests the Sql class
"""
def test_get_list_of_columns(self, setup_database):
db = setup_database
rows = [{'unit': 'days',
... | [
{
"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/test_sql.py | vprakash-ucl/pyrate |
# coding: utf-8
import numpy as np
from PIL import Image, ImageDraw
from math import sin,cos
from numpngw import write_apng
W,H = 1024,1024
COLOR_BLACK = (0x00, 0x00, 0x00, 0x00)
COLOR_WHITE = (0xF0, 0xF0, 0xE0)
COLOR_BLUE = (0x0D, 0x36, 0xFF)
COLOR_BLYNK = (0x2E, 0xFF, 0xB9)
COLOR_RED = (0xFF, 0x10, 0x... | [
{
"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 | extras/gen-states.py | kayatmin/blynk-library |
import numpy as np
import os
import sys
# To import from sibling directory ../utils
sys.path.append(os.path.dirname(os.path.abspath(__file__)) + "/..")
from data_loader.load_utils import load_obj
from data_loader.load_utils import try_to_load_as_pickled_object
from sklearn.model_selection import train_test_split
from 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": "no_function_exceeds_5_params",
"question": "Does every function in this file take 5 or fewer parameters (excluding sel... | 3 | data_loader/baseline_generator.py | mmr12/DeepLearning18 |
import torchvision
from torchvision.models import resnet as vrn
import torch.utils.model_zoo as model_zoo
from .utils import register
class ResNet(vrn.ResNet):
'Deep Residual Network - https://arxiv.org/abs/1512.03385'
def __init__(self, layers=[3, 4, 6, 3], bottleneck=vrn.Bottleneck, outputs=[5], groups=1, ... | [
{
"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 | odtk/backbones/resnet.py | Mo5mami/retinanet-examples |
# -*- coding: utf-8 -*-
from keras_bert import Tokenizer
class TokenizerReturningSpace(Tokenizer):
"""
"""
def _tokenize(self, text):
R = []
for c in text:
if c in self._token_dict:
R.append(c)
elif self._is_space(c):
R.append('[un... | [
{
"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": true
},
{
... | 3 | nlp_tasks/bert_keras/tokenizer.py | l294265421/AC-MIMLLN |
from __future__ import absolute_import
from __future__ import division
from __future__ import print_function
class SubCommand(object):
name = NotImplementedError("Please add 'name' member in your SubCommand")
help = NotImplementedError("Please add 'help' member in your SubCommand")
def addParser(self, pa... | [
{
"point_num": 1,
"id": "has_nested_function_def",
"question": "Does this file contain any function defined inside another function?",
"answer": false
},
{
"point_num": 2,
"id": "has_multiple_inheritance",
"question": "Does any class in this file use multiple inheritance?",
"answ... | 3 | src/ppb/cli/sub_cmd/_sub_command.py | Stibbons/python-project-bootstrap |
import pytest
from selen.client.driver import Driver, DriverInstance
from selen.client.helper import Tools
@pytest.hookimpl(hookwrapper=True, tryfirst=True)
def pytest_runtest_makereport(item):
outcome = yield
rep = outcome.get_result()
setattr(item, "rep_" + rep.when, rep)
return rep
@pytest.fixtur... | [
{
"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 | tests/conftest.py | SatoDeNoor/selen |
import re
import httpx
from bs4 import BeautifulSoup
from convert_to_json import hash_id
from cleanup import delete_from_index
from connection import app_search, engine_name
from upload_to_appsearch import upload_dict
womakers_location_page = httpx.get("https://womakerscode.org/locations")
soup = BeautifulSoup(womak... | [
{
"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 | upload/scrapers/womakerscode.py | kjaymiller/diversity-orgs-tech-appsearch-demo |
import re
import time
from pyquery import PyQuery as pq
from policy_crawl.common.fetch import get,post
from policy_crawl.common.save import save
from policy_crawl.common.logger import alllog,errorlog
def parse_detail(html,url):
alllog.logger.info("云南省教育厅: %s"%url)
doc=pq(html)
data={}
data["title"]=d... | [
{
"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 | spiders/moe/all/yunnan.py | JJYYYY/policy_crawl |
import numpy as np
JPL_OBLIQUITY = np.deg2rad(84381.448 / 3600.0)
def icrf_to_jpl_ecliptic(x, y, z, vx, vy, vz):
return _apply_x_rotation(JPL_OBLIQUITY, x, y, z, vx, vy, vz)
def jpl_ecliptic_to_icrf(x, y, z, vx, vy, vz):
return _apply_x_rotation(-JPL_OBLIQUITY, x, y, z, vx, vy, vz)
def _apply_x_rotation(... | [
{
"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 | adam/astro_utils.py | moeyensj/adam_home |
import datetime
import pytest
from sepaxml import SepaDD
from sepaxml.validation import ValidationError
def test_name_too_long():
sdd = SepaDD({
"name": "TestCreditor",
"BIC": "BANKNL2A",
"IBAN": "NL50BANK1234567890",
"batch": True,
"creditor_id": "000000",
"curre... | [
{
"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 | tests/debit/test_validation.py | CaptainConsternant/python-sepaxml |
# This code is from
# Multi-Task Learning as Multi-Objective Optimization
# Ozan Sener, Vladlen Koltun
# Neural Information Processing Systems (NeurIPS) 2018
# https://github.com/intel-isl/MultiObjectiveOptimization
import numpy as np
from .min_norm_solvers_numpy import MinNormSolver
def moo_mtl_search(multi_obj_f... | [
{
"point_num": 1,
"id": "every_function_under_20_lines",
"question": "Is every function in this file shorter than 20 lines?",
"answer": false
},
{
"point_num": 2,
"id": "every_function_has_docstring",
"question": "Does every function in this file have a docstring?",
"answer": tru... | 3 | toy_experiments/solvers/moo_mtl.py | kelvin95/EPOSearch |
# don't mind me, I'm a quick and dirty python script
# I extract false positive rate from the output files of kbf
def lire(filemane):
TP, TN, FP, FN = 0, 0, 0, 0
with open(filemane, "r") as fichier:
for ligne in fichier:
cols = ligne.split()
if cols[1] == "0":
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": "every_function_under_20_lines",
"question": "Is every function in this file shorter than 20 lines?",
"answ... | 3 | analyse.py | lrobidou/kbf |
import logging
from env import ENDPOINT, ACCESS_ID, ACCESS_KEY, USERNAME, PASSWORD
from tuya_iot import (
TuyaOpenAPI,
AuthType,
TuyaOpenMQ,
TuyaDeviceManager,
TuyaHomeManager,
TuyaDeviceListener,
TuyaDevice,
TuyaTokenInfo,
TUYA_LOGGER
)
TUYA_LOGGER.setLevel(logging.DEBUG)
# Init
op... | [
{
"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 | example/device.py | andrzejressel/tuya-iot-python-sdk |
#tests
from calculus import finitesum
def test2_1():
exp=finitesum('2x^3y^4z^7')
assert(exp.derive('y')=='8x^3y^3z^7')
def test2_2():
exp2=finitesum('2x^2yz^3')
assert(exp2.derive('y')=='2x^2z^3')
def test2_3():
exp3=finitesum('y^3+2y')
assert(exp3.derive('y')=='2+3y^2')
def test2_4():
exp4=finitesum... | [
{
"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 | tests/test_2.py | georgercarder/calculus |
from flask import Flask
from flask.ext.sqlalchemy import SQLAlchemy
import os, socket
app = Flask(__name__)
app.config['SQLALCHEMY_DATABASE_URI'] = os.environ['DATABASE_URI']
db = SQLAlchemy(app)
hostname = socket.gethostname()
@app.route('/')
def index():
return 'Hello, from sunny %s!\n' % hostname
@app.route('/d... | [
{
"point_num": 1,
"id": "every_function_has_docstring",
"question": "Does every function in this file have a docstring?",
"answer": false
},
{
"point_num": 2,
"id": "has_nested_function_def",
"question": "Does this file contain any function defined inside another function?",
"ans... | 3 | demo/app/demo.py | xod442/ansible-stack2 |
from programy.parser.template.nodes.resetlearn import TemplateResetLearnNode
from programy.parser.template.nodes.base import TemplateNode
from programytest.parser.template.base import TemplateTestsBaseClass
class MockTemplateResetLearnNode(TemplateResetLearnNode):
def __init__(self):
TemplateResetLearnNod... | [
{
"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 | test/programytest/parser/template/node_tests/test_resetlearn.py | ItsPhant/program-y |
import asyncio
import aiohttp
import requests
from top_articles.models import Story
from django.core.exceptions import ObjectDoesNotExist
def check_db_story_ids(articlesID_list):
new_articleID_list = []
for id in articlesID_list:
try:
Story.objects.get(id=id)
except ObjectDoesNotEx... | [
{
"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 | top_articles/cron_articles.py | Ramesh7128/hacker-news-clone |
# Owner(s): ["oncall: fx"]
import torch
import torch.fx.experimental.fx_acc.acc_ops as acc_ops
import torch.nn as nn
from torch.testing._internal.common_fx2trt import AccTestCase
from parameterized import parameterized
class TestGetitemConverter(AccTestCase):
@parameterized.expand(
[
("slice_... | [
{
"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 | test/fx2trt/converters/acc_op/test_getitem.py | xiaohanhuang/pytorch |
class Helpers:
_cache = {}
@classmethod
def cached(cls, key, scope=None, func=None):
if scope is not None:
if scope not in cls._cache:
cls._cache[scope] = {}
if key in cls._cache[scope]:
return cls._cache[scope][key]
else:
... | [
{
"point_num": 1,
"id": "no_function_exceeds_5_params",
"question": "Does every function in this file take 5 or fewer parameters (excluding self/cls)?",
"answer": true
},
{
"point_num": 2,
"id": "every_function_under_20_lines",
"question": "Is every function in this file shorter than... | 3 | stackl/helpers.py | ArtOfCode-/stackl |
"""About and help services.
(help browser anyone?)
"""
import importlib
import importlib_metadata
from gi.repository import Gtk
from gaphor.abc import ActionProvider, Service
from gaphor.core import action
class HelpService(Service, ActionProvider):
def __init__(self, session):
self.session = session... | [
{
"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 | gaphor/services/helpservice/__init__.py | mrmonkington/gaphor |
#!/usr/bin/env python
# Copyright 2017 The Chromium Authors. All rights reserved.
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.
import argparse
import json
import shutil
import sys
import merge_api
def noop_merge(output_json, jsons_to_merge):
"""Use the firs... | [
{
"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 | testing/merge_scripts/noop_merge.py | zealoussnow/chromium |
# -*- coding: utf-8 -*-
# ----------------------------------------------------------------------
# AS discovery job
# ----------------------------------------------------------------------
# Copyright (C) 2007-2018 The NOC Project
# See LICENSE for details
# -------------------------------------------------------------... | [
{
"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 | services/discovery/jobs/as/job.py | xUndero/noc |
directions = ['up', 'down', 'left', 'right']
def get_air_distance_between_two_points(point1, point2):
x1 = point1['x']
y1 = point1['y']
x2 = point2['x']
y2 = point2['y']
distance = pow(pow((x2 - x1), 2) + pow((y2 - y1), 2), 0.5)
return distance
def not_deadly_location_on_board(goal, deadly_... | [
{
"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 | app/path_finder.py | RavioliGitHub/starter-snake-python1 |
# -*- coding: utf-8 -*-
import torch.nn as nn
from torch.nn import functional as F
import pytorch_ssim
class MSE_Loss(nn.Module):
def __init__(self):
super(MSE_Loss, self).__init__()
def forward(self, input, target):
return F.mse_loss(input, target, reduction='mean')
class SSIM_... | [
{
"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 | LDCT_Denoising/Neural_Network/Loss_Func.py | BennyZhang-Codes/LDCT-denoising-with-DL-Methods-and-Dicom-Viewer-by-Benny |
import time
import sys
class ShowProcess():
# """
# 显示处理进度的类
# 调用该类相关函数即可实现处理进度的显示
# """
i = 0 # 当前的处理进度
max_steps = 0 # 总共需要处理的次数
max_arrow = 50 #进度条的长度
infoDone = 'done'
# 初始化函数,需要知道总共的处理次数
def __init__(self, max_steps, infoDone = 'Done'):
self.max_steps = max_steps
... | [
{
"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 | ShowProcess.py | 4a5g0030/line_follow |
# Copyright (c) 2018, NVIDIA CORPORATION.
import os.path
import numpy as np
import pyarrow as pa
import pytest
from numba import cuda
from cudf import DataFrame, Series
from cudf.comm.gpuarrow import GpuArrowReader
from cudf.testing._utils import assert_eq
def read_data():
import pandas as pd
basedir = os.... | [
{
"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 | python/cudf/cudf/tests/test_sparse_df.py | Ahsantw/cudf |
#!/usr/bin/env python
# coding: utf-8
# In[4]:
def heapify(arr, n, i):
largest = i # Initialize largest as root
l = 2 * i + 1 # left = 2*i + 1
r = 2 * i + 2 # right = 2*i + 2
if l < n and arr[i] < arr[l]:
largest = l
if r < n and arr[largest] < arr[r]:
largest = r
if largest != i:
arr[i],ar... | [
{
"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 | heap sort.py | angelopassaro/Hacktoberfest-1 |
# -*- coding:utf-8 -*-
from __future__ import absolute_import, division, print_function, unicode_literals
import pytest
from botocore.stub import Stubber
from treehugger.kms import kms_agent
from treehugger.remote import s3_client
@pytest.fixture(scope='function', autouse=True)
def kms_stub():
kms_agent.reset()... | [
{
"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 | tests/conftest.py | adamchainz/treehugger |
#!/usr/bin/env python3
# Copyright (c) 2014-2016 The Bitcoin Core developers
# Distributed under the MIT software license, see the accompanying
# file COPYING or http://www.opensource.org/licenses/mit-license.php.
"""Test mempool limiting together/eviction with the wallet."""
from test_framework.test_framework import ... | [
{
"point_num": 1,
"id": "every_function_under_20_lines",
"question": "Is every function in this file shorter than 20 lines?",
"answer": false
},
{
"point_num": 2,
"id": "more_functions_than_classes",
"question": "Does this file define more functions than classes?",
"answer": true... | 3 | test/functional/mempool_limit.py | BlenderSleuth/schleems |
#!/usr/bin/env python3
"""
Test for local-subnet identifier
"""
import unittest
import netifaces
from base_test import PschedTestBase
from pscheduler.limitprocessor.identifier.localsubnet import *
DATA = {
}
class TestLimitprocessorIdentifierLocalSubnet(PschedTestBase):
"""
Test the Identifier
"""
... | [
{
"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-pscheduler/pscheduler/tests/limitprocessor_identifier_localsubnet_test.py | krihal/pscheduler |
from collections import OrderedDict
from typing import Dict, Generic, Mapping, TypeVar
CacheKey = TypeVar("CacheKey")
CacheValue = TypeVar("CacheValue")
class LRUCache(Generic[CacheKey, CacheValue], OrderedDict):
"""
A dictionary-like container that stores a given maximum items.
If an additional item i... | [
{
"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 | rich/_lru_cache.py | hultner-technologies/rich |
import cgi
import datetime
import urllib
import urlparse
from django.conf import settings
from django.template import defaultfilters
from django.utils.html import strip_tags
from jingo import register
import jinja2
from .urlresolvers import reverse
# Yanking filters from Django.
register.filter(strip_tags)
registe... | [
{
"point_num": 1,
"id": "every_function_has_docstring",
"question": "Does every function in this file have a docstring?",
"answer": true
},
{
"point_num": 2,
"id": "all_params_annotated",
"question": "Does every function parameter in this file have a type annotation (excluding self/c... | 3 | apps/commons/helpers.py | gene1wood/bugbro |
#Timers
# Execute code at timed intervals
import time
from threading import Timer
def display(msg):
print(msg + ' ' + time.strftime('%H:%M:%S'))
#Basic timer
def run_once():
display('Run Once : ')
t = Timer(5, display, ['Timeout:'])
t.start()
run_once()
print('Waiting ...')
#Inter... | [
{
"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 | Timers/timers__.py | nageshnnazare/Python-Advanced-Concepts |
# 1.装包
# 2.导包
from django.conf import settings
from itsdangerous import TimedJSONWebSignatureSerializer as Serializer
# 3.实例化
# 4.加密解密
class SecretOauth(object):
# 加密
def dumps(self, data):
s = Serializer(secret_key=settings.SECRET_KEY, expires_in=3600)
result = s.dumps(data)
return re... | [
{
"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 | meiduo_mall/utils/secret.py | liusudo123/meiduo_project |
#!/usr/bin/env python2
# -*- coding: utf-8 -*-
from hermes_python.hermes import Hermes
INTENT_HOW_ARE_YOU = "mikpan:how_are_you"
INTENT_GOOD = "bezzam:feeling_good"
INTENT_BAD = "bezzam:feeling_bad"
INTENT_ALRIGHT = "bezzam:feeling_alright"
INTENT_FILTER_FEELING = [INTENT_GOOD, INTENT_BAD, INTENT_ALRIGHT]
def main(... | [
{
"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 | V2_action-how-are-you.py | mikpan/amld19-snips-workshop |
##############################################################################
#
# Copyright (c) 2009 Zope Foundation and Contributors.
# All Rights Reserved.
#
# This software is subject to the provisions of the Zope Public License,
# Version 2.1 (ZPL). A copy of the ZPL should accompany this distribution.
# THIS SOF... | [
{
"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/zope/authentication/tests/utils.py | zopefoundation/zope.authentication |
from crypt import crypt
import sqlalchemy.exc
from typing import List
from error import DoesNotExist
from storage import UnixPasswordStorage
from password import UnixPassword
from .sqlite_api import (
Database,
DatabaseApi
)
from .password_schema import Password
def _fmt_password(password: Password) -> Unix... | [
{
"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 | src/unix_accounts/storage_sqlite/password_api.py | 1nfiniteloop/unix-accounts |
from typing import Union
import numpy as np
from numba import njit
from jesse.helpers import get_candle_source, slice_candles
def supersmoother(candles: np.ndarray, period: int = 14, source_type: str = "close", sequential: bool = False) -> Union[
float, np.ndarray]:
"""
Super Smoother Filter 2pole Butte... | [
{
"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 | jesse/indicators/supersmoother.py | noenfugler/jesse |
"""
SRTpy -- SRT (https://etk.srail.co.kr) wrapper for Python.
==========================================================
: copyright: (c) 2017 by Heena Kwag.
: URL: <http://github.com/dotaitch/SRTpy>
: license: BSD, see LICENSE for more details.
"""
import random
import requests
from xml.etree im... | [
{
"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 | SRTpy/utils.py | ChangWanHong/SRTpy |
from __future__ import print_function
from orphics import maps,io,cosmology
from pixell import enmap
import numpy as np
import os,sys
from soapack import interfaces as sints
def get_coadd(imaps,wts,axis):
# sum(w*m)/sum(w)
twt = np.sum(wts,axis=axis)
retmap = np.sum(wts*imaps,axis=axis)/twt
retmap[~np.... | [
{
"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 | bin/planck/verify_projection.py | ACTCollaboration/tilec |
from flask_jwt import JWT, jwt_required, current_identity
from werkzeug.security import safe_str_cmp
class User(object):
def __init__(self, id, username, password):
self.id = id
self.username = username
self.password = password
def __str__(self):
return "User(id='%s')" % self.... | [
{
"point_num": 1,
"id": "all_function_names_snake_case",
"question": "Are all function names in this file written in snake_case?",
"answer": true
},
{
"point_num": 2,
"id": "all_params_annotated",
"question": "Does every function parameter in this file have a type annotation (excludi... | 3 | application/user.py | AxelGard/secure-castle |
#!../bin/python3
# -*- coding:utf-8 -*-
"""
Copyright 2021 Jerome DE LUCCHI
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 ... | [
{
"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 | backend/builder/build_db_node_mode.py | blast-eu-com/blast.eu.com |
# Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
# SPDX-License-Identifier: MIT-0
import json
import boto3
import logger
from crhelper import CfnResource
helper = CfnResource()
try:
dynamodb = boto3.resource('dynamodb')
except Exception as e:
helper.init_failure(e)
@helper.creat... | [
{
"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": "no_function_exceeds_5_params",
"question": "Does every function in this file take 5 or fewer parameters (excluding... | 3 | server/custom_resources/update_settings_table.py | snetty/aws-saas-factory-ref-solution-serverless-saas |
# SPDX-License-Identifier: Apache-2.0
#
# Copyright (C) 2015, ARM Limited and contributors.
#
# 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
#
# ... | [
{
"point_num": 1,
"id": "has_nested_function_def",
"question": "Does this file contain any function defined inside another function?",
"answer": false
},
{
"point_num": 2,
"id": "has_multiple_inheritance",
"question": "Does any class in this file use multiple inheritance?",
"answ... | 3 | tests/eas/rfc.py | MIPS/external-lisa |
from .base_model import BaseModel
from . import networks
from .cycle_gan_model import CycleGANModel
class TestModel(BaseModel):
def name(self):
return 'TestModel'
@staticmethod
def modify_commandline_options(parser, is_train=True):
assert not is_train, 'TestModel cannot be used in train mode'
parser = Cycle... | [
{
"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 | models/test_model.py | yunyanxing/pairwise_xray_augmentation |
import numpy as np
#This is crafted especially for normal distribution for MLE.
class GradientDescentOptimizer:
def __init__(self, X, tolerance, learning_rate):
self.learning_rate = learning_rate
self.tolerance = tolerance
self.X = X
if(len(X.shape) == 1):
self.number_of... | [
{
"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": "no_function_exceeds_5_params",
"question": "Does every function in this file take 5 or fewer parameters (excluding... | 3 | utilities/mini_batch_gradient_descent.py | Puneethnaik/Generative-Adversarial-Networks |
import numpy as np
def regularization_cost(kwargs):
thetas = kwargs.get('thetas', np.array([0]))
return kwargs.get('reg_p', 0) * thetas.T.dot(thetas)
def regularization_cost_2(thetas, kwargs):
return kwargs.get('reg_p', 0) * thetas.T.dot(thetas)
def calc_cost_linear(m, **kwargs):
return kwargs['ers'].T.dot(... | [
{
"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 | Coursera/costs.py | nalkhish/MachineLearning |
# Copyright 2020 Zachary Frost
#
# 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, publish, distribut... | [
{
"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 | src/py2glsl/shader/statement/action/assign.py | zfzackfrost/py2glsl |
# qubit number=4
# total number=10
import pyquil
from pyquil.api import local_forest_runtime, QVMConnection
from pyquil import Program, get_qc
from pyquil.gates import *
import numpy as np
conn = QVMConnection()
def make_circuit()-> Program:
prog = Program() # circuit begin
prog += H(0) # number=1
pr... | [
{
"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_under_20_lines",
"question": "Is every function in this file shorter than 20 lines?",
"an... | 3 | data/p4VQE/R4/benchmark/startPyquil95.py | UCLA-SEAL/QDiff |
from __future__ import unicode_literals, print_function, division
from io import open
import unicodedata
import string
import re
import random
from random import shuffle
import torch
import torch.nn as nn
from torch.autograd import Variable
from torch import optim
import torch.nn.functional as F
import sys
import os
... | [
{
"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 | tasks.py | tommccoy1/tpdn |
import json
import numpy as np
import math
import numbers
def is_nan(x):
return (x is np.nan or x != x)
def convert_simple_numpy_type(obj):
if isinstance(obj, (np.int_, np.intc, np.intp, np.int8,
np.int16, np.int32, np.int64, np.uint8,
np.uint16, np.uint32, np.uint64)):
return int(obj... | [
{
"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 | a2ml/api/utils/json_utils.py | augerai/a2ml |
from typing import Type, List
from jivago.inject import typing_meta_helper
from jivago.lang.annotations import Override
from jivago.lang.stream import Stream
from jivago.serialization.deserialization_strategy import DeserializationStrategy, T
TYPES_WHICH_DESERIALIZE_TO_LISTS = ('List', 'Iterable', 'Collection')
cla... | [
{
"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 | jivago/serialization/deserialization/typed_list_deserialization_strategy.py | keotl/jivago |
from regression_tests import *
class TestBase(Test):
def test_c_contains_for_or_while_loop(self):
assert self.out_c.contains(r'(for|while) \(')
def test_c_contains_no_gotos(self):
assert not self.out_c.contains(r'goto .*;')
def test_c_contains_all_strings(self):
assert self.out_c.... | [
{
"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 | integration/for-loop/test.py | xbabka01/retdec-regression-tests |
import torch
import numpy
# codes of this function are borrowed from https://github.com/yanx27/Pointnet_Pointnet2_pytorch/blob/master/models/pointnet2_utils.py
def index_points(device, points, idx):
"""
Input:
points: input points data, [B, N, C]
idx: sample index data, [B, S]
Return:
... | [
{
"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 | Intra_MLP.py | suyukun666/UFO |
"""Integration tests for Glesys"""
from unittest import TestCase
import pytest
from lexicon.tests.providers.integration_tests import IntegrationTestsV1
# Hook into testing framework by inheriting unittest.TestCase and reuse
# the tests which *each and every* implementation of the interface must
# pass, by inheritanc... | [
{
"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 | lexicon/tests/providers/test_glesys.py | HelixEducation/lexicon |
from __future__ import unicode_literals
from dvc.command.base import CmdBase
class CmdCheckout(CmdBase):
def run(self):
if not self.args.targets:
self.project.checkout(force=self.args.force)
else:
for target in self.args.targets:
self.project.checkout(
... | [
{
"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 | dvc/command/checkout.py | yfarjoun/dvc |
"""SCons.Tool.suncc
Tool-specific initialization for Sun Solaris (Forte) CC and cc.
There normally shouldn't be any need to import this module directly.
It will usually be imported through the generic SCons.Tool.Tool()
selection method.
"""
#
# Copyright (c) 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010... | [
{
"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 | pdb2pqr-1.9.0/scons/scons-local-2.3.0/SCons/Tool/suncc.py | Acpharis/protein_prep |
class Graph(object):
def __init__(self):
self.children = {} # dictionnary giving the list of childrens for each node.
self.q = [] # configuration associated to each node.
self.connex = [] # ID of the connex component the node is belonging to.
self.nconnex = 0 #... | [
{
"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 | doc/d-practical-exercises/src/graph.py | thanhndv212/pinocchio |
# -*- coding: utf-8 -*-
from datetime import datetime
from flask import g, jsonify, request
from flask_httpauth import HTTPBasicAuth
from app import app, db
from app.models import User, Post
auth = HTTPBasicAuth()
@auth.verify_password
def verify_password(username, password):
user = db.session.query(User).filt... | [
{
"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/views/curl.py | daghan/MarkDownBlog |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.