hexsha string | size int64 | ext string | lang string | max_stars_repo_path string | max_stars_repo_name string | max_stars_repo_head_hexsha string | max_stars_repo_licenses list | max_stars_count int64 | max_stars_repo_stars_event_min_datetime string | max_stars_repo_stars_event_max_datetime string | max_issues_repo_path string | max_issues_repo_name string | max_issues_repo_head_hexsha string | max_issues_repo_licenses list | max_issues_count int64 | max_issues_repo_issues_event_min_datetime string | max_issues_repo_issues_event_max_datetime string | max_forks_repo_path string | max_forks_repo_name string | max_forks_repo_head_hexsha string | max_forks_repo_licenses list | max_forks_count int64 | max_forks_repo_forks_event_min_datetime string | max_forks_repo_forks_event_max_datetime string | content string | avg_line_length float64 | max_line_length int64 | alphanum_fraction float64 | qsc_code_num_words_quality_signal int64 | qsc_code_num_chars_quality_signal float64 | qsc_code_mean_word_length_quality_signal float64 | qsc_code_frac_words_unique_quality_signal float64 | qsc_code_frac_chars_top_2grams_quality_signal float64 | qsc_code_frac_chars_top_3grams_quality_signal float64 | qsc_code_frac_chars_top_4grams_quality_signal float64 | qsc_code_frac_chars_dupe_5grams_quality_signal float64 | qsc_code_frac_chars_dupe_6grams_quality_signal float64 | qsc_code_frac_chars_dupe_7grams_quality_signal float64 | qsc_code_frac_chars_dupe_8grams_quality_signal float64 | qsc_code_frac_chars_dupe_9grams_quality_signal float64 | qsc_code_frac_chars_dupe_10grams_quality_signal float64 | qsc_code_frac_chars_replacement_symbols_quality_signal float64 | qsc_code_frac_chars_digital_quality_signal float64 | qsc_code_frac_chars_whitespace_quality_signal float64 | qsc_code_size_file_byte_quality_signal float64 | qsc_code_num_lines_quality_signal float64 | qsc_code_num_chars_line_max_quality_signal float64 | qsc_code_num_chars_line_mean_quality_signal float64 | qsc_code_frac_chars_alphabet_quality_signal float64 | qsc_code_frac_chars_comments_quality_signal float64 | qsc_code_cate_xml_start_quality_signal float64 | qsc_code_frac_lines_dupe_lines_quality_signal float64 | qsc_code_cate_autogen_quality_signal float64 | qsc_code_frac_lines_long_string_quality_signal float64 | qsc_code_frac_chars_string_length_quality_signal float64 | qsc_code_frac_chars_long_word_length_quality_signal float64 | qsc_code_frac_lines_string_concat_quality_signal float64 | qsc_code_cate_encoded_data_quality_signal float64 | qsc_code_frac_chars_hex_words_quality_signal float64 | qsc_code_frac_lines_prompt_comments_quality_signal float64 | qsc_code_frac_lines_assert_quality_signal float64 | qsc_codepython_cate_ast_quality_signal float64 | qsc_codepython_frac_lines_func_ratio_quality_signal float64 | qsc_codepython_cate_var_zero_quality_signal bool | qsc_codepython_frac_lines_pass_quality_signal float64 | qsc_codepython_frac_lines_import_quality_signal float64 | qsc_codepython_frac_lines_simplefunc_quality_signal float64 | qsc_codepython_score_lines_no_logic_quality_signal float64 | qsc_codepython_frac_lines_print_quality_signal float64 | qsc_code_num_words int64 | qsc_code_num_chars int64 | qsc_code_mean_word_length int64 | qsc_code_frac_words_unique null | qsc_code_frac_chars_top_2grams int64 | qsc_code_frac_chars_top_3grams int64 | qsc_code_frac_chars_top_4grams int64 | qsc_code_frac_chars_dupe_5grams int64 | qsc_code_frac_chars_dupe_6grams int64 | qsc_code_frac_chars_dupe_7grams int64 | qsc_code_frac_chars_dupe_8grams int64 | qsc_code_frac_chars_dupe_9grams int64 | qsc_code_frac_chars_dupe_10grams int64 | qsc_code_frac_chars_replacement_symbols int64 | qsc_code_frac_chars_digital int64 | qsc_code_frac_chars_whitespace int64 | qsc_code_size_file_byte int64 | qsc_code_num_lines int64 | qsc_code_num_chars_line_max int64 | qsc_code_num_chars_line_mean int64 | qsc_code_frac_chars_alphabet int64 | qsc_code_frac_chars_comments int64 | qsc_code_cate_xml_start int64 | qsc_code_frac_lines_dupe_lines int64 | qsc_code_cate_autogen int64 | qsc_code_frac_lines_long_string int64 | qsc_code_frac_chars_string_length int64 | qsc_code_frac_chars_long_word_length int64 | qsc_code_frac_lines_string_concat null | qsc_code_cate_encoded_data int64 | qsc_code_frac_chars_hex_words int64 | qsc_code_frac_lines_prompt_comments int64 | qsc_code_frac_lines_assert int64 | qsc_codepython_cate_ast int64 | qsc_codepython_frac_lines_func_ratio int64 | qsc_codepython_cate_var_zero int64 | qsc_codepython_frac_lines_pass int64 | qsc_codepython_frac_lines_import int64 | qsc_codepython_frac_lines_simplefunc int64 | qsc_codepython_score_lines_no_logic int64 | qsc_codepython_frac_lines_print int64 | effective string | hits int64 |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
021d5769d36b572a0f2addec694597fefa3cfa6f | 158 | py | Python | Backend/order/urls.py | Bhavya0020/Readopolis | a0053e4fae97dc8291b50c746f3dc3e6b454ad95 | [
"MIT"
] | null | null | null | Backend/order/urls.py | Bhavya0020/Readopolis | a0053e4fae97dc8291b50c746f3dc3e6b454ad95 | [
"MIT"
] | null | null | null | Backend/order/urls.py | Bhavya0020/Readopolis | a0053e4fae97dc8291b50c746f3dc3e6b454ad95 | [
"MIT"
] | null | null | null | from django.urls import path
from . import views
urlpatterns = [
path('checkout/', views.checkout),
path('orders/', views.OrdersList.as_view()),
] | 19.75 | 50 | 0.677215 | 19 | 158 | 5.578947 | 0.631579 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0.170886 | 158 | 8 | 51 | 19.75 | 0.80916 | 0 | 0 | 0 | 0 | 0 | 0.100629 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | false | 0 | 0.333333 | 0 | 0.333333 | 0 | 1 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 0 | 0 | 3 |
022fd56061f4a128f54c059a42d1bbaadf434720 | 322 | py | Python | src/homework/models/__init__.py | nvo87/education-backend | 1f008bd396b5dde4483af611532826a9bca9fef5 | [
"MIT"
] | 62 | 2021-09-22T18:38:26.000Z | 2022-03-29T06:09:42.000Z | src/homework/models/__init__.py | nvo87/education-backend | 1f008bd396b5dde4483af611532826a9bca9fef5 | [
"MIT"
] | 50 | 2021-09-16T07:17:31.000Z | 2022-03-26T12:06:58.000Z | src/homework/models/__init__.py | nvo87/education-backend | 1f008bd396b5dde4483af611532826a9bca9fef5 | [
"MIT"
] | 16 | 2021-10-17T17:43:31.000Z | 2022-03-26T11:22:45.000Z | from homework.models.answer import Answer
from homework.models.answer_access_log_entry import AnswerAccessLogEntry
from homework.models.answer_cross_check import AnswerCrossCheck
from homework.models.question import Question
__all__ = [
'Answer',
'AnswerAccessLogEntry',
'AnswerCrossCheck',
'Question',
]
| 26.833333 | 72 | 0.801242 | 34 | 322 | 7.323529 | 0.411765 | 0.192771 | 0.289157 | 0.289157 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0.127329 | 322 | 11 | 73 | 29.272727 | 0.886121 | 0 | 0 | 0 | 0 | 0 | 0.15528 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | false | 0 | 0.4 | 0 | 0.4 | 0 | 0 | 0 | 0 | null | 0 | 1 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 0 | 0 | 3 |
024580a7ff506aa3cbda6d46122b84b1603a6c05 | 794 | py | Python | pywikibot/families/omegawiki_family.py | shizhao/pywikibot-core | 8441a1cd0e8dd5d3701f1c5e26077e40a40937ee | [
"MIT"
] | null | null | null | pywikibot/families/omegawiki_family.py | shizhao/pywikibot-core | 8441a1cd0e8dd5d3701f1c5e26077e40a40937ee | [
"MIT"
] | null | null | null | pywikibot/families/omegawiki_family.py | shizhao/pywikibot-core | 8441a1cd0e8dd5d3701f1c5e26077e40a40937ee | [
"MIT"
] | null | null | null | # -*- coding: utf-8 -*-
__version__ = '$Id: 024580a7ff506aa3cbda6d46122b84b1603a6c05 $'
from pywikibot import family
# Omegawiki, the Ultimate online dictionary
class Family(family.Family):
def __init__(self):
family.Family.__init__(self)
self.name = 'omegawiki'
self.langs['omegawiki'] = 'www.omegawiki.org'
# On most Wikipedias page names must start with a capital letter, but some
# languages don't use this.
self.nocapitalize = self.langs.keys()
def hostname(self,code):
return 'www.omegawiki.org'
def version(self, code):
return "1.16alpha"
def scriptpath(self, code):
return ''
def path(self, code):
return '/index.php'
def apipath(self, code):
return '/api.php'
| 22.685714 | 82 | 0.632242 | 92 | 794 | 5.326087 | 0.586957 | 0.081633 | 0.142857 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0.050676 | 0.254408 | 794 | 34 | 83 | 23.352941 | 0.777027 | 0.20529 | 0 | 0 | 0 | 0 | 0.201278 | 0.063898 | 0 | 0 | 0 | 0 | 0 | 1 | 0.333333 | false | 0 | 0.055556 | 0.277778 | 0.722222 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 0 | 1 | 1 | 0 | 0 | 3 |
02591a0ba3663c70495908f0fded2d81e95b4ceb | 474 | py | Python | Entities/element.py | JoseleSolis/Proceso-de-aprendizaje | 0c6ee3a64ad48501dd42d2abcb5bf8b4cbb4f370 | [
"MIT"
] | null | null | null | Entities/element.py | JoseleSolis/Proceso-de-aprendizaje | 0c6ee3a64ad48501dd42d2abcb5bf8b4cbb4f370 | [
"MIT"
] | null | null | null | Entities/element.py | JoseleSolis/Proceso-de-aprendizaje | 0c6ee3a64ad48501dd42d2abcb5bf8b4cbb4f370 | [
"MIT"
] | 2 | 2022-02-07T05:42:57.000Z | 2022-02-13T11:05:21.000Z | class Element:
dependencies = []
def __init__(self, name):
self.name = name
def add_dependencies(self, *elements):
for element in elements:
if not self.dependencies.__contains__(element):
self.dependencies.append(element)
def remove_dependencies(self, *elements):
for element in elements:
if self.dependencies.__contains__(element):
self.dependencies.remove(element)
| 19.75 | 59 | 0.622363 | 47 | 474 | 5.978723 | 0.340426 | 0.227758 | 0.170819 | 0.192171 | 0.661922 | 0.661922 | 0.327402 | 0.327402 | 0 | 0 | 0 | 0 | 0.293249 | 474 | 23 | 60 | 20.608696 | 0.838806 | 0 | 0 | 0.166667 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0.25 | false | 0 | 0 | 0 | 0.416667 | 0 | 0 | 0 | 0 | null | 1 | 0 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 3 |
025c55086785bd2358aa07697fa9e5ff75a7e9fe | 2,268 | py | Python | github/migrations/0007_auto_20201003_1239.py | h3nnn4n/git-o-matic-9k | d8241cc768591e0f41c02b2057d7b56697a4cc86 | [
"MIT"
] | null | null | null | github/migrations/0007_auto_20201003_1239.py | h3nnn4n/git-o-matic-9k | d8241cc768591e0f41c02b2057d7b56697a4cc86 | [
"MIT"
] | null | null | null | github/migrations/0007_auto_20201003_1239.py | h3nnn4n/git-o-matic-9k | d8241cc768591e0f41c02b2057d7b56697a4cc86 | [
"MIT"
] | null | null | null | # Generated by Django 3.1.2 on 2020-10-03 12:39
from django.db import migrations, models
import django.utils.timezone
class Migration(migrations.Migration):
dependencies = [
('github', '0006_repository_open_issues_count'),
]
operations = [
migrations.RenameField(
model_name='developer',
old_name='user_name',
new_name='login',
),
migrations.AddField(
model_name='developer',
name='bio',
field=models.TextField(blank=True),
),
migrations.AddField(
model_name='developer',
name='company',
field=models.TextField(blank=True),
),
migrations.AddField(
model_name='developer',
name='created_at',
field=models.DateTimeField(default=django.utils.timezone.now),
preserve_default=False,
),
migrations.AddField(
model_name='developer',
name='email',
field=models.TextField(blank=True),
),
migrations.AddField(
model_name='developer',
name='followers',
field=models.IntegerField(default=0),
),
migrations.AddField(
model_name='developer',
name='following',
field=models.IntegerField(default=0),
),
migrations.AddField(
model_name='developer',
name='location',
field=models.TextField(blank=True),
),
migrations.AddField(
model_name='developer',
name='name',
field=models.TextField(default=''),
preserve_default=False,
),
migrations.AddField(
model_name='developer',
name='public_gists',
field=models.IntegerField(default=0),
),
migrations.AddField(
model_name='developer',
name='public_repos',
field=models.IntegerField(default=0),
),
migrations.AddField(
model_name='developer',
name='updated_at',
field=models.DateTimeField(default=django.utils.timezone.now),
preserve_default=False,
),
]
| 29.076923 | 74 | 0.543651 | 196 | 2,268 | 6.158163 | 0.311224 | 0.089478 | 0.178956 | 0.246065 | 0.714167 | 0.714167 | 0.681027 | 0.671085 | 0.671085 | 0.588235 | 0 | 0.015447 | 0.343474 | 2,268 | 77 | 75 | 29.454545 | 0.795165 | 0.019841 | 0 | 0.676056 | 1 | 0 | 0.112562 | 0.014858 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | false | 0 | 0.028169 | 0 | 0.070423 | 0 | 0 | 0 | 0 | null | 0 | 0 | 1 | 0 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 3 |
02842784fc821e743357ee9efac57212bf1f6827 | 326 | py | Python | src/utils.py | fabiob/wwwsqldesigner-aws | 5518eae682e8228be30b094c6015054b3cddf8f3 | [
"MIT"
] | null | null | null | src/utils.py | fabiob/wwwsqldesigner-aws | 5518eae682e8228be30b094c6015054b3cddf8f3 | [
"MIT"
] | null | null | null | src/utils.py | fabiob/wwwsqldesigner-aws | 5518eae682e8228be30b094c6015054b3cddf8f3 | [
"MIT"
] | 1 | 2021-04-04T09:41:51.000Z | 2021-04-04T09:41:51.000Z | from .env import S3_PREFIX
def respond(body=None, mime="text/plain", code=200, headers={}):
h = {"Content-Type": mime}
h.update(headers)
return {"statusCode": code, "body": body, "headers": h}
def fn(keyword):
return f'{S3_PREFIX}{keyword}.xml'
def fix(filename):
return filename[len(S3_PREFIX):-4]
| 20.375 | 64 | 0.650307 | 47 | 326 | 4.446809 | 0.617021 | 0.114833 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0.025926 | 0.171779 | 326 | 15 | 65 | 21.733333 | 0.748148 | 0 | 0 | 0 | 0 | 0 | 0.205521 | 0.07362 | 0 | 0 | 0 | 0 | 0 | 1 | 0.333333 | false | 0 | 0.111111 | 0.222222 | 0.777778 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 0 | 1 | 1 | 0 | 0 | 3 |
65febfc830676365453c5d43b397d3e86ac87c5f | 471 | py | Python | invenio_flow/decorators.py | egabancho/invenio-flow | 583e55d17ab6aabd20bc4a46d098f034c0d0f693 | [
"MIT"
] | null | null | null | invenio_flow/decorators.py | egabancho/invenio-flow | 583e55d17ab6aabd20bc4a46d098f034c0d0f693 | [
"MIT"
] | null | null | null | invenio_flow/decorators.py | egabancho/invenio-flow | 583e55d17ab6aabd20bc4a46d098f034c0d0f693 | [
"MIT"
] | null | null | null | # -*- coding: utf-8 -*-
#
# Copyright (C) 2020 Esteban J. G. Gabancho.
#
# Invenio-Flow is free software; you can redistribute it and/or modify it
# under the terms of the MIT License; see LICENSE file for more details.
"""Useful decorators."""
from celery import shared_task
from .api import Task
def task(*args, **kwargs):
"""Wrapper around shared task to set default base class."""
kwargs.setdefault('base', Task)
return shared_task(*args, **kwargs)
| 23.55 | 73 | 0.694268 | 69 | 471 | 4.710145 | 0.768116 | 0.092308 | 0.086154 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0.012987 | 0.18259 | 471 | 19 | 74 | 24.789474 | 0.831169 | 0.596603 | 0 | 0 | 0 | 0 | 0.022989 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0.2 | true | 0 | 0.4 | 0 | 0.8 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 1 | 0 | 1 | 0 | 0 | 3 |
5a06baf447f7c7644ae324b314d4d848bee4ba67 | 12,225 | py | Python | app_api/serializers.py | pkucsie/SIEPServer | 00b0637eb8302135dfc772fccd18cd749a93e5c6 | [
"Apache-2.0"
] | 2 | 2021-02-12T10:02:42.000Z | 2021-03-15T13:08:04.000Z | app_api/serializers.py | pkucsie/SIEPServer | 00b0637eb8302135dfc772fccd18cd749a93e5c6 | [
"Apache-2.0"
] | null | null | null | app_api/serializers.py | pkucsie/SIEPServer | 00b0637eb8302135dfc772fccd18cd749a93e5c6 | [
"Apache-2.0"
] | null | null | null | import datetime
import time
from utils import utils
from rest_framework import serializers
from rest_framework.relations import StringRelatedField
from app_api.models import Album, Info, Order, Coupon, Integral, Notice, Lesson, Question, Cart, Setup, User, Bill, Address, Catalog, Log, \
ReadType, Teacher, Comment, \
Hot, Recharge, LabelFollow, Student, Navigation, Read, Article, History, Qa, ArticleType, UserNotice, Slider, \
UserLesson, Nav, LabelType, \
IntegralType, Label, Footer, CommonPathConfig, StudentType, LessonType, LessonHardType, Chapter, Term, QaType, \
RechargeAction, RechargePay, \
CouponRange, CouponStatus, OrderItem, OrderStatus, Consult, ReadChapterItem, ReadChapter, LogType, VipGuest, Judge, \
Organization, TaskTimeline, Project, Score, WXAdmin, WXUser
class ConsultSerializer(serializers.ModelSerializer):
class Meta:
model = Consult
fields = "__all__"
class OrderStatusSerializer(serializers.ModelSerializer):
class Meta:
model = OrderStatus
fields = ["text", "code"]
class OrderItemSerializer(serializers.ModelSerializer):
class Meta:
model = OrderItem
fields = "__all__"
class OrderWaySerializer(serializers.ModelSerializer):
class Meta:
model = RechargePay
fields = ["text", "code"]
class OrderListSerializer(serializers.ModelSerializer):
status = OrderStatusSerializer()
way = OrderWaySerializer()
list = OrderItemSerializer(many=True)
class Meta:
model = Order
fields = "__all__"
class OrderSerializer(serializers.ModelSerializer):
class Meta:
model = Order
fields = "__all__"
class OrderInfoSerializer(serializers.ModelSerializer):
list = OrderItemSerializer(many=True)
class Meta:
model = Order
fields = "__all__"
class CouponRangeSerializer(serializers.ModelSerializer):
class Meta:
model = CouponRange
fields = ["text", "code"]
class CouponStatusSerializer(serializers.ModelSerializer):
class Meta:
model = CouponStatus
fields = ["text", "code"]
class CouponSerializer(serializers.ModelSerializer):
range = CouponRangeSerializer()
status = CouponStatusSerializer()
starttime = serializers.DateTimeField(format="%Y.%m.%d")
endtime = serializers.DateTimeField(format="%Y.%m.%d")
class Meta:
model = Coupon
fields = "__all__"
class IntegralSerializer(serializers.ModelSerializer):
class Meta:
model = Integral
fields = "__all__"
class UserNoticeSerializer(serializers.ModelSerializer):
class Meta:
model = UserNotice
fields = "__all__"
class NoticeSerializer(serializers.ModelSerializer):
class Meta:
model = Notice
fields = "__all__"
class LabelTypeHomeSerializer(serializers.ModelSerializer):
class Meta:
model = LabelType
fields = ["code", "title"]
class LabelTypeSerializer(serializers.ModelSerializer):
text = serializers.CharField(source="title")
class Meta:
model = LabelType
fields = ["code", "text"]
class LessonTypeSerializer(serializers.ModelSerializer):
class Meta:
model = LessonType
fields = ["code", "text"]
class LabelSerializer(serializers.ModelSerializer):
type = LabelTypeSerializer()
class Meta:
model = Label
fields = "__all__"
class LabelInnerLessonSerializer(serializers.ModelSerializer):
class Meta:
model = Label
fields = ["title"]
class LessonHardTypeSerializer(serializers.ModelSerializer):
class Meta:
model = LessonHardType
fields = ["code", "text"]
class TaskTimelineSerializer(serializers.ModelSerializer):
class Meta:
model = TaskTimeline
fields = "__all__"
class OrganizationSerializer(serializers.ModelSerializer):
class Meta:
model = Organization
fields = "__all__"
class VipGuestSerializer(serializers.ModelSerializer):
class Meta:
model = VipGuest
fields = "__all__"
class JudgeSerializer(serializers.ModelSerializer):
class Meta:
model = Judge
fields = "__all__"
class ScoreSerializer(serializers.ModelSerializer):
class Meta:
model = Score
fields = "__all__"
class ProjectSerializer(serializers.ModelSerializer):
class Meta:
model = Project
fields = "__all__"
class TeacherSerializer(serializers.ModelSerializer):
class Meta:
model = Teacher
fields = "__all__"
class LessonSerializer(serializers.ModelSerializer):
category = LabelTypeSerializer()
type = LessonTypeSerializer()
labels = StringRelatedField(many=True)
teacher = TeacherSerializer()
class Meta:
model = Lesson
fields = "__all__"
class LessonInfoSerializer(serializers.ModelSerializer):
category = LabelTypeSerializer()
type = LessonTypeSerializer()
labels = StringRelatedField(many=True)
hard = LessonHardTypeSerializer()
teacher = TeacherSerializer()
class Meta:
model = Lesson
fields = "__all__"
class TermSerializer(serializers.ModelSerializer):
class Meta:
model = Term
fields = "__all__"
class ChapterSerializer(serializers.ModelSerializer):
term = TermSerializer(many=True)
class Meta:
model = Chapter
fields = "__all__"
class QuestionSerializer(serializers.ModelSerializer):
class Meta:
model = Question
fields = "__all__"
class CartSerializer(serializers.ModelSerializer):
class Meta:
model = Cart
fields = "__all__"
class UserSerializer(serializers.ModelSerializer):
class Meta:
model = User
fields = "__all__"
class AddressSerializer(serializers.ModelSerializer):
class Meta:
model = Address
fields = "__all__"
class CatalogSerializer(serializers.ModelSerializer):
class Meta:
model = Catalog
fields = "__all__"
class LogTypeSerializer(serializers.ModelSerializer):
class Meta:
model = LogType
fields = ["text", "code"]
class LogSerializer(serializers.ModelSerializer):
type = LogTypeSerializer()
class Meta:
model = Log
fields = "__all__"
class ReadTypeSerializer(serializers.ModelSerializer):
class Meta:
model = ReadType
fields = "__all__"
class CommentSerializer(serializers.ModelSerializer):
class Meta:
model = Comment
fields = "__all__"
class HotSerializer(serializers.ModelSerializer):
class Meta:
model = Hot
fields = "__all__"
class RechargeActionSerializer(serializers.ModelSerializer):
class Meta:
model = RechargeAction
fields = ["text", "code"]
class RechargePaySerializer(serializers.ModelSerializer):
action = RechargeActionSerializer
class Meta:
model = RechargePay
fields = ["text", "code"]
class RechargeListSerializer(serializers.ModelSerializer):
action = RechargeActionSerializer()
way = RechargePaySerializer()
class Meta:
model = Recharge
fields = "__all__"
class BillSerializer(serializers.ModelSerializer):
way = RechargePaySerializer()
orderno = serializers.SerializerMethodField()
class Meta:
model = Bill
fields = "__all__"
@staticmethod
def get_orderno(obj):
year = datetime.datetime.now().year
month = datetime.datetime.now().month
day = datetime.datetime.now().day
if month < 10:
month = f'0{month}'
if day < 10:
day = f'0{day}'
return f'{year}{month}{day}{int(time.time())}'
class RechargeSerializer(serializers.ModelSerializer):
class Meta:
model = Recharge
fields = "__all__"
class LabelFollowSerializer(serializers.ModelSerializer):
class Meta:
model = LabelFollow
fields = "__all__"
class StudentTypeSerializer(serializers.ModelSerializer):
class Meta:
model = StudentType
fields = ["code", "text"]
class StudentSerializer(serializers.ModelSerializer):
type = StudentTypeSerializer()
class Meta:
model = Student
fields = "__all__"
class NavigationSerializer(serializers.ModelSerializer):
class Meta:
model = Navigation
fields = "__all__"
class ReadChapterItemSerializer(serializers.ModelSerializer):
class Meta:
model = ReadChapterItem
fields = "__all__"
class ReadChapterSerializer(serializers.ModelSerializer):
data = ReadChapterItemSerializer(source="chapter_item", many=True)
class Meta:
model = ReadChapter
fields = "__all__"
class ReadSerializer(serializers.ModelSerializer):
author = TeacherSerializer()
tryRead = serializers.SerializerMethodField()
class Meta:
model = Read
fields = "__all__"
@staticmethod
def get_tryRead(obj):
chapters = ReadChapter.objects.filter(read=obj).values_list("id", flat=True)
chapter_items = ReadChapterItem.objects.filter(read_chapter_id__in=chapters, isTry=True).values_list("title", flat=True)
return chapter_items
class ReadInfoSerializer(serializers.ModelSerializer):
author = TeacherSerializer()
chapter = ReadChapterSerializer(many=True)
class Meta:
model = Read
fields = "__all__"
class ArticleSerializer(serializers.ModelSerializer):
type = serializers.IntegerField(source="type.code")
class Meta:
model = Article
fields = "__all__"
class HistorySerializer(serializers.ModelSerializer):
class Meta:
model = History
fields = "__all__"
class QaTypeSerializer(serializers.ModelSerializer):
class Meta:
model = QaType
fields = ["text", "code"]
class QaSerializer(serializers.ModelSerializer):
status = QaTypeSerializer(source="type")
class Meta:
model = Qa
fields = "__all__"
class ArticleTypeSerializer(serializers.ModelSerializer):
class Meta:
model = ArticleType
fields = "__all__"
class SliderSerializer(serializers.ModelSerializer):
class Meta:
model = Slider
fields = "__all__"
class UserLessonSerializer(serializers.ModelSerializer):
type = LessonTypeSerializer()
class Meta:
model = UserLesson
fields = "__all__"
class NavSerializer(serializers.ModelSerializer):
class Meta:
model = Nav
fields = "__all__"
class IntegralTypeSerializer(serializers.ModelSerializer):
class Meta:
model = IntegralType
fields = "__all__"
class FooterSerializer(serializers.ModelSerializer):
class Meta:
model = Footer
fields = "__all__"
class CommonPathConfigSerializer(serializers.ModelSerializer):
class Meta:
model = CommonPathConfig
fields = "__all__"
class AlbumSerializer(serializers.ModelSerializer):
class Meta:
model = Album
fields = "__all__"
class InfoSerializer(serializers.ModelSerializer):
class Meta:
model = Info
fields = "__all__"
class SetupSerializer(serializers.ModelSerializer):
class Meta:
model = Setup
fields = "__all__"
class WxuserSerializer(serializers.ModelSerializer):
def to_representation(self, instance):
"""Convert `username` to lowercase."""
ret = super().to_representation(instance)
ret['USER_LOGIN_TIME'] = utils.get_agostr(ret['USER_LOGIN_TIME'])
ret['USER_BIRTH'] = utils.get_age(ret['USER_BIRTH'])
return ret
class Meta:
model = WXUser
fields = "__all__"
class WxuserFullSerializer(serializers.ModelSerializer):
def to_representation(self, instance):
"""Convert `username` to lowercase."""
ret = super().to_representation(instance)
ret['USER_BIRTH'] = utils.get_ymd(ret['USER_BIRTH'])
return ret
class Meta:
model = WXUser
fields = "__all__"
class WxadminSerializer(serializers.ModelSerializer):
class Meta:
model = WXAdmin
fields = "__all__"
| 23.41954 | 140 | 0.674683 | 1,045 | 12,225 | 7.650718 | 0.207656 | 0.227642 | 0.122577 | 0.214509 | 0.418136 | 0.149468 | 0.126204 | 0.113071 | 0.102064 | 0.087555 | 0 | 0.000644 | 0.237873 | 12,225 | 521 | 141 | 23.464491 | 0.857465 | 0.005317 | 0 | 0.505682 | 0 | 0 | 0.05556 | 0.002963 | 0 | 0 | 0 | 0 | 0 | 1 | 0.011364 | false | 0 | 0.017045 | 0 | 0.536932 | 0 | 0 | 0 | 0 | null | 1 | 0 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 3 |
5a0b2d031fe808c99bfba67eaa85c3e839cc5992 | 197 | py | Python | tests/test_problem16.py | nolanwrightdev/blind-75-python | b92ef3449eb0143c760ddd339897a3f0a2972830 | [
"MIT"
] | 6 | 2020-02-01T23:29:51.000Z | 2022-02-20T20:46:56.000Z | tests/test_problem16.py | nolanwrightdev/blind-75-python | b92ef3449eb0143c760ddd339897a3f0a2972830 | [
"MIT"
] | null | null | null | tests/test_problem16.py | nolanwrightdev/blind-75-python | b92ef3449eb0143c760ddd339897a3f0a2972830 | [
"MIT"
] | null | null | null | import unittest
from problems.problem16 import solution
class Test(unittest.TestCase):
def test(self):
self.assertTrue(solution([2, 3, 1, 1, 4]))
self.assertFalse(solution([3, 2, 1, 0, 4]))
| 21.888889 | 45 | 0.71066 | 30 | 197 | 4.666667 | 0.6 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0.070588 | 0.137056 | 197 | 8 | 46 | 24.625 | 0.752941 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0.333333 | 1 | 0.166667 | false | 0 | 0.333333 | 0 | 0.666667 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 1 | 0 | 0 | 3 |
5a0e378937b9fd8ab97a5e345d693d92224ab800 | 4,333 | py | Python | src/past/types/oldstr.py | kianmeng/python-future | 80523f383fbba1c6de0551e19d0277e73e69573c | [
"MIT"
] | 908 | 2015-01-01T21:20:45.000Z | 2022-03-29T20:47:16.000Z | src/past/types/oldstr.py | kianmeng/python-future | 80523f383fbba1c6de0551e19d0277e73e69573c | [
"MIT"
] | 402 | 2015-01-04T01:30:19.000Z | 2022-03-24T11:56:38.000Z | src/past/types/oldstr.py | kianmeng/python-future | 80523f383fbba1c6de0551e19d0277e73e69573c | [
"MIT"
] | 305 | 2015-01-18T19:29:37.000Z | 2022-03-24T09:40:09.000Z | """
Pure-Python implementation of a Python 2-like str object for Python 3.
"""
from numbers import Integral
from past.utils import PY2, with_metaclass
if PY2:
from collections import Iterable
else:
from collections.abc import Iterable
_builtin_bytes = bytes
class BaseOldStr(type):
def __instancecheck__(cls, instance):
return isinstance(instance, _builtin_bytes)
def unescape(s):
r"""
Interprets strings with escape sequences
Example:
>>> s = unescape(r'abc\\def') # i.e. 'abc\\\\def'
>>> print(s)
'abc\def'
>>> s2 = unescape('abc\\ndef')
>>> len(s2)
8
>>> print(s2)
abc
def
"""
return s.encode().decode('unicode_escape')
class oldstr(with_metaclass(BaseOldStr, _builtin_bytes)):
"""
A forward port of the Python 2 8-bit string object to Py3
"""
# Python 2 strings have no __iter__ method:
@property
def __iter__(self):
raise AttributeError
def __dir__(self):
return [thing for thing in dir(_builtin_bytes) if thing != '__iter__']
# def __new__(cls, *args, **kwargs):
# """
# From the Py3 bytes docstring:
# bytes(iterable_of_ints) -> bytes
# bytes(string, encoding[, errors]) -> bytes
# bytes(bytes_or_buffer) -> immutable copy of bytes_or_buffer
# bytes(int) -> bytes object of size given by the parameter initialized with null bytes
# bytes() -> empty bytes object
#
# Construct an immutable array of bytes from:
# - an iterable yielding integers in range(256)
# - a text string encoded using the specified encoding
# - any object implementing the buffer API.
# - an integer
# """
#
# if len(args) == 0:
# return super(newbytes, cls).__new__(cls)
# # Was: elif isinstance(args[0], newbytes):
# # We use type() instead of the above because we're redefining
# # this to be True for all unicode string subclasses. Warning:
# # This may render newstr un-subclassable.
# elif type(args[0]) == newbytes:
# return args[0]
# elif isinstance(args[0], _builtin_bytes):
# value = args[0]
# elif isinstance(args[0], unicode):
# if 'encoding' not in kwargs:
# raise TypeError('unicode string argument without an encoding')
# ###
# # Was: value = args[0].encode(**kwargs)
# # Python 2.6 string encode() method doesn't take kwargs:
# # Use this instead:
# newargs = [kwargs['encoding']]
# if 'errors' in kwargs:
# newargs.append(kwargs['errors'])
# value = args[0].encode(*newargs)
# ###
# elif isinstance(args[0], Iterable):
# if len(args[0]) == 0:
# # What is this?
# raise ValueError('unknown argument type')
# elif len(args[0]) > 0 and isinstance(args[0][0], Integral):
# # It's a list of integers
# value = b''.join([chr(x) for x in args[0]])
# else:
# raise ValueError('item cannot be interpreted as an integer')
# elif isinstance(args[0], Integral):
# if args[0] < 0:
# raise ValueError('negative count')
# value = b'\x00' * args[0]
# else:
# value = args[0]
# return super(newbytes, cls).__new__(cls, value)
def __repr__(self):
s = super(oldstr, self).__repr__() # e.g. b'abc' on Py3, b'abc' on Py3
return s[1:]
def __str__(self):
s = super(oldstr, self).__str__() # e.g. "b'abc'" or "b'abc\\ndef'
# TODO: fix this:
assert s[:2] == "b'" and s[-1] == "'"
return unescape(s[2:-1]) # e.g. 'abc' or 'abc\ndef'
def __getitem__(self, y):
if isinstance(y, Integral):
return super(oldstr, self).__getitem__(slice(y, y+1))
else:
return super(oldstr, self).__getitem__(y)
def __getslice__(self, *args):
return self.__getitem__(slice(*args))
def __contains__(self, key):
if isinstance(key, int):
return False
def __native__(self):
return bytes(self)
__all__ = ['oldstr']
| 31.860294 | 95 | 0.558505 | 522 | 4,333 | 4.44636 | 0.333333 | 0.038776 | 0.038776 | 0.040931 | 0.090478 | 0.049117 | 0.028436 | 0.028436 | 0 | 0 | 0 | 0.01688 | 0.316409 | 4,333 | 135 | 96 | 32.096296 | 0.766712 | 0.593815 | 0 | 0.051282 | 0 | 0 | 0.019267 | 0 | 0 | 0 | 0 | 0.007407 | 0.025641 | 1 | 0.25641 | false | 0 | 0.102564 | 0.102564 | 0.666667 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 0 | 1 | 1 | 0 | 0 | 3 |
5a408ec9d28877bdb362b94265d0d74be34141c1 | 91 | py | Python | Code coach problems/Easy/Python/Skee-Ball.py | Djivs/sololearn-code-solutions | 7727dd97f79863a88841548770481f6f2abdc7bf | [
"MIT"
] | 1 | 2020-07-27T07:32:57.000Z | 2020-07-27T07:32:57.000Z | Code coach problems/Easy/Python/Skee-Ball.py | Djivs/sololearn-code-solutions | 7727dd97f79863a88841548770481f6f2abdc7bf | [
"MIT"
] | null | null | null | Code coach problems/Easy/Python/Skee-Ball.py | Djivs/sololearn-code-solutions | 7727dd97f79863a88841548770481f6f2abdc7bf | [
"MIT"
] | 1 | 2020-11-07T12:45:21.000Z | 2020-11-07T12:45:21.000Z | a = int(input())
b = int(input())
if a >=b*12:
print("Buy it!")
else:
print("Try again")
| 13 | 19 | 0.56044 | 17 | 91 | 3 | 0.705882 | 0.313725 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0.026667 | 0.175824 | 91 | 6 | 20 | 15.166667 | 0.653333 | 0 | 0 | 0 | 0 | 0 | 0.175824 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | false | 0 | 0 | 0 | 0 | 0.333333 | 1 | 0 | 0 | null | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 3 |
5a75c828e876ed3a1b7b9389dd4545aaaf2d9462 | 466 | py | Python | examples/panflute/myemph.py | jacobwhall/panflute | 281ddeaebd2c2c94f457f3da785037cadf69389e | [
"BSD-3-Clause"
] | 361 | 2016-04-26T18:23:30.000Z | 2022-03-24T20:58:18.000Z | examples/panflute/myemph.py | jacobwhall/panflute | 281ddeaebd2c2c94f457f3da785037cadf69389e | [
"BSD-3-Clause"
] | 164 | 2016-04-27T18:42:55.000Z | 2022-02-13T23:34:17.000Z | examples/panflute/myemph.py | jacobwhall/panflute | 281ddeaebd2c2c94f457f3da785037cadf69389e | [
"BSD-3-Clause"
] | 62 | 2016-06-15T13:33:54.000Z | 2021-11-20T07:33:07.000Z | #!/usr/bin/env python
import panflute as pf
"""
Pandoc filter that causes emphasis to be rendered using
the custom macro '\myemph{...}' rather than '\emph{...}'
in latex. Other output formats are unaffected.
"""
def latex(s):
return pf.RawInline(s, format='latex')
def myemph(e, doc):
if type(e)==pf.Emph and doc.format=='latex':
return pf.Span(latex('\\myemph{'), *e.items, latex('}'))
if __name__ == "__main__":
pf.toJSONFilter(myemph)
| 21.181818 | 64 | 0.654506 | 67 | 466 | 4.432836 | 0.686567 | 0.053872 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0.171674 | 466 | 21 | 65 | 22.190476 | 0.76943 | 0.042918 | 0 | 0 | 0 | 0 | 0.101083 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0.25 | false | 0 | 0.125 | 0.125 | 0.625 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 0 | 1 | 1 | 0 | 0 | 3 |
ce4b095948b8f81b5b5833c6dcab9d8f5bd587a5 | 290 | py | Python | advisor/api/urls.py | Sachin-c/api-test | c8242de24375149dcbc14e30b44d9a77d9771034 | [
"MIT",
"BSD-3-Clause"
] | null | null | null | advisor/api/urls.py | Sachin-c/api-test | c8242de24375149dcbc14e30b44d9a77d9771034 | [
"MIT",
"BSD-3-Clause"
] | null | null | null | advisor/api/urls.py | Sachin-c/api-test | c8242de24375149dcbc14e30b44d9a77d9771034 | [
"MIT",
"BSD-3-Clause"
] | null | null | null | from django.urls import path
from advisor.api.views import (
# api_advisor_view,
api_advisor_view_post,
)
app_name = 'advisor'
urlpatterns = [
path('admin/advisor/', api_advisor_view_post, name="post"),
# path('user/<int:id>/advisor/', api_advisor_view, name="detail"),
]
| 22.307692 | 70 | 0.7 | 40 | 290 | 4.8 | 0.45 | 0.208333 | 0.291667 | 0.1875 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0.151724 | 290 | 12 | 71 | 24.166667 | 0.780488 | 0.282759 | 0 | 0 | 0 | 0 | 0.121951 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | false | 0 | 0.25 | 0 | 0.25 | 0 | 0 | 0 | 0 | null | 1 | 1 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 3 |
ce5beb636533234d09e40c6e181344e4d00f51e7 | 371 | py | Python | sched_slack_bot/reminder/sender.py | Germandrummer92/SchedSlackBot | d211f7c0d78eb8ebbc1f22cc186c94fc61bad491 | [
"MIT"
] | null | null | null | sched_slack_bot/reminder/sender.py | Germandrummer92/SchedSlackBot | d211f7c0d78eb8ebbc1f22cc186c94fc61bad491 | [
"MIT"
] | null | null | null | sched_slack_bot/reminder/sender.py | Germandrummer92/SchedSlackBot | d211f7c0d78eb8ebbc1f22cc186c94fc61bad491 | [
"MIT"
] | null | null | null | import abc
from sched_slack_bot.model.reminder import Reminder
class ReminderSender(abc.ABC):
@abc.abstractmethod
def send_reminder(self, reminder: Reminder) -> None:
raise NotImplementedError("Not Implemented")
@abc.abstractmethod
def send_skip_message(self, reminder: Reminder) -> None:
raise NotImplementedError("Not Implemented")
| 24.733333 | 60 | 0.738544 | 41 | 371 | 6.560976 | 0.512195 | 0.04461 | 0.148699 | 0.178439 | 0.460967 | 0.460967 | 0.460967 | 0.460967 | 0 | 0 | 0 | 0 | 0.175202 | 371 | 14 | 61 | 26.5 | 0.879085 | 0 | 0 | 0.444444 | 0 | 0 | 0.080863 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0.222222 | false | 0 | 0.222222 | 0 | 0.555556 | 0 | 0 | 0 | 0 | null | 0 | 0 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 3 |
ce642e6e7a09fb0be794de1dfe62d3f787626a2a | 52 | py | Python | tests/django/__init__.py | estudio89/maestro-python | 331079cb3f0c10de2e19210cbade793544510f33 | [
"BSD-3-Clause"
] | null | null | null | tests/django/__init__.py | estudio89/maestro-python | 331079cb3f0c10de2e19210cbade793544510f33 | [
"BSD-3-Clause"
] | null | null | null | tests/django/__init__.py | estudio89/maestro-python | 331079cb3f0c10de2e19210cbade793544510f33 | [
"BSD-3-Clause"
] | null | null | null | default_app_config = "tests.django.apps.MyAppConfig" | 52 | 52 | 0.846154 | 7 | 52 | 6 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0.038462 | 52 | 1 | 52 | 52 | 0.84 | 0 | 0 | 0 | 0 | 0 | 0.54717 | 0.54717 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | false | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | null | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 3 |
ce827ac31d171b94c54c1e52af75d3c49aac0651 | 2,270 | py | Python | src/tables.py | tallywiesenberg/dating-data-dividend | 0a4f3d7784e9902631a79dce1efb12fc39e74963 | [
"MIT"
] | null | null | null | src/tables.py | tallywiesenberg/dating-data-dividend | 0a4f3d7784e9902631a79dce1efb12fc39e74963 | [
"MIT"
] | null | null | null | src/tables.py | tallywiesenberg/dating-data-dividend | 0a4f3d7784e9902631a79dce1efb12fc39e74963 | [
"MIT"
] | null | null | null | from flask_login import UserMixin
from werkzeug.security import generate_password_hash, check_password_hash
from .extensions import db
class User(UserMixin, db.Model):
id = db.Column(db.Integer, primary_key=True)
username = db.Column(db.String(80), unique=True, nullable=False)
password = db.Column(db.String(200), nullable=False)
address = db.Column(db.String(44), unique=True, nullable=False)
left_swipes_given = db.Column(db.Integer, nullable=False)
right_swipes_given = db.Column(db.Integer, nullable=False)
matches = db.Column(db.Integer, nullable=False)
bio = db.Column(db.String(240))
time_logged = db.Column(db.Float, nullable=False)
gender = db.Column(db.String(10), nullable=False)
gender_preference = db.Column(db.String(10), nullable=False)
def __repr__(self):
return f'{self.id} -- {self.username} -- {self.password} -- {self.address}'
def set_password(self, password):
'''Create hashed password'''
self.password = generate_password_hash(password, method='sha256')
def check_password(self, password):
return check_password_hash(self.password, password)
def set_address(self, address):
'''Set address from placeholder to real-deal after connecting with metamask'''
self.address = address
# class UserData(db.Model):
# id = db.Column(db.Integer, primary_key=True)
# left_swipes_given = db.Column(db.Integer, nullable=False)
# right_swipes_given = db.Column(db.Integer, nullable=False)
# matches = db.Column(db.Integer, nullable=False)
# bio = db.Column(db.String(240))
# path_to_photos = db.Column(db.String(20), nullable=False)
# user_id = db.Column(db.String(44),
# # db.ForeignKey('user_login.id'),
# nullable=False)
class Swipe(db.Model):
id = db.Column(db.Integer, primary_key=True)
timestamp = db.Column(db.DateTime, nullable=False)
decision = db.Column(db.Boolean, nullable=False)
#The user that swipes
front_user = db.Column(db.String(44),
# db.ForeignKey('user_login.id'),
nullable=False)
#The user that is swiped upon
back_user = db.Column(db.String(44),
# db.ForeignKey('user_login.id'),
nullable=False)
match = db.Column(db.Boolean, nullable=False) | 40.535714 | 84 | 0.697797 | 314 | 2,270 | 4.926752 | 0.254777 | 0.124111 | 0.155139 | 0.113769 | 0.486102 | 0.460246 | 0.421461 | 0.381383 | 0.381383 | 0.381383 | 0 | 0.014831 | 0.168282 | 2,270 | 56 | 85 | 40.535714 | 0.804555 | 0.290308 | 0 | 0.125 | 1 | 0.03125 | 0.044739 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0.125 | false | 0.21875 | 0.09375 | 0.0625 | 0.875 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 1 | 0 | 0 | 3 |
ce92edbc18e65275ac6f2bfc1a972e464010433f | 205 | py | Python | django_ecommerce/contact/admin.py | marshallhumble/Python_Web | d0d31647c882f30422f31aa62ecd61ae7ad87123 | [
"MIT"
] | null | null | null | django_ecommerce/contact/admin.py | marshallhumble/Python_Web | d0d31647c882f30422f31aa62ecd61ae7ad87123 | [
"MIT"
] | null | null | null | django_ecommerce/contact/admin.py | marshallhumble/Python_Web | d0d31647c882f30422f31aa62ecd61ae7ad87123 | [
"MIT"
] | null | null | null | from django.contrib import admin
from .models import ContactForm
class ContactFormAdmin(admin.ModelAdmin):
class Meta:
model = ContactForm
admin.site.register(ContactForm, ContactFormAdmin)
| 20.5 | 50 | 0.780488 | 22 | 205 | 7.272727 | 0.636364 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0.156098 | 205 | 9 | 51 | 22.777778 | 0.924855 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | false | 0 | 0.333333 | 0 | 0.666667 | 0 | 1 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 0 | 0 | 3 |
ce96c92938a6d505e9a78e6bd30465ac609c886c | 2,238 | py | Python | libs/dataset/pipeline.py | arnasRad/vits | c0e0689d8c24049a2531dd5d52fc96a594389db2 | [
"MIT"
] | null | null | null | libs/dataset/pipeline.py | arnasRad/vits | c0e0689d8c24049a2531dd5d52fc96a594389db2 | [
"MIT"
] | null | null | null | libs/dataset/pipeline.py | arnasRad/vits | c0e0689d8c24049a2531dd5d52fc96a594389db2 | [
"MIT"
] | null | null | null | import re
import string
from libs.dataset.core import SampleEntry, oov_replacement_vocabulary, letter_replacements
__word_start_regex = f'[ \t\n]|^|[{string.punctuation}]'
__word_end_regex = f'[ \t\n]|$|[{string.punctuation}]'
def does_not_have_numbers(s: SampleEntry):
return not any(char.isdigit() for char in s.text)
def waveform_not_longer_than(target_length):
def step(s: SampleEntry):
return s.duration < target_length
return step
def waveform_not_shorter_than(target_length):
def step(s: SampleEntry):
return s.duration > target_length
return step
def replace_oov(line):
for symbol, replacement in oov_replacement_vocabulary.items():
line = re.sub(fr"{symbol}", replacement, line)
line = re.sub(r"[ ]{2,}", ' ', line)
line = re.sub(r"\n\s*\n", r'\n', line)
return line
def test_replace_oov():
assert replace_oov("vien_as") == "vien as"
assert replace_oov("vien«as") == "vienas"
assert replace_oov("vien\xadas") == "vienas"
assert replace_oov("vien®as") == "vienas"
assert replace_oov("vien°as") == "vienas"
assert replace_oov("vien²as") == "vienas"
assert replace_oov("vien»as") == "vienas"
assert replace_oov("vienʼas") == "vien'as"
assert replace_oov("vien˚as") == "vienas"
assert replace_oov("vien‒as") == "vien-as"
assert replace_oov("vien–as") == "vien-as"
assert replace_oov("vien—as") == "vien-as"
assert replace_oov("vien‘as") == "vien'as"
assert replace_oov("vien’as") == "vien'as"
assert replace_oov("vien“as") == 'vien"as'
assert replace_oov("vien”as") == 'vien"as'
assert replace_oov("vien„as") == 'vien"as'
assert replace_oov("vien\\as") == "vienas"
assert replace_oov("vien,,as") == 'vien"as'
def replace_letter_to_sound(line):
for letter, sound in letter_replacements.items():
line = re.sub(fr"({__word_start_regex})[{letter.lower()}{letter.upper()}]+({__word_end_regex})", fr"\1{sound}\2", line)
return line
def test_replace_letter_to_sound():
assert replace_letter_to_sound("aAa b C d e f g h I J k L M n") == "aã bė̃ cė̃ dė̃ eẽ ef̃ gė̃ hãš iĩ jòt kã el̃ em̃ eñ"
assert replace_letter_to_sound("vienas du aaaa") == "vienas du aã"
| 34.430769 | 130 | 0.662645 | 348 | 2,238 | 4.103448 | 0.29023 | 0.147059 | 0.212885 | 0.238095 | 0.620448 | 0.471989 | 0.316527 | 0.257703 | 0.236695 | 0.236695 | 0 | 0.002159 | 0.172029 | 2,238 | 64 | 131 | 34.96875 | 0.759849 | 0 | 0 | 0.125 | 0 | 0.020833 | 0.247096 | 0.061215 | 0 | 0 | 0 | 0 | 0.4375 | 1 | 0.1875 | false | 0 | 0.0625 | 0.0625 | 0.395833 | 0 | 0 | 0 | 0 | null | 0 | 1 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 3 |
ce9e402973e2cfeb24237745cb68e27f8bb1a25f | 72 | py | Python | lxml2json/__init__.py | meteozond/lxml2json | 502b3512dcb0ae034469a2cedd7661a4801c4425 | [
"MIT"
] | null | null | null | lxml2json/__init__.py | meteozond/lxml2json | 502b3512dcb0ae034469a2cedd7661a4801c4425 | [
"MIT"
] | null | null | null | lxml2json/__init__.py | meteozond/lxml2json | 502b3512dcb0ae034469a2cedd7661a4801c4425 | [
"MIT"
] | null | null | null | #!/usr/bin/env python
from functions import convert
name = "convert"
| 18 | 30 | 0.722222 | 10 | 72 | 5.2 | 0.9 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0.166667 | 72 | 3 | 31 | 24 | 0.866667 | 0.277778 | 0 | 0 | 0 | 0 | 0.145833 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | false | 0 | 0.5 | 0 | 0.5 | 0 | 1 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 0 | 0 | 3 |
cec871b2942200cdc40d51b006698874939d3556 | 144 | py | Python | sutta_publisher/src/sutta_publisher/edition_parsers/__init__.py | suttacentral/publications | 878befcfeb7af7f2f511697f2769cd00441aec57 | [
"CC0-1.0"
] | 1 | 2022-02-16T09:02:58.000Z | 2022-02-16T09:02:58.000Z | sutta_publisher/src/sutta_publisher/edition_parsers/__init__.py | suttacentral/publications | 878befcfeb7af7f2f511697f2769cd00441aec57 | [
"CC0-1.0"
] | 43 | 2022-02-07T11:37:29.000Z | 2022-03-30T08:54:55.000Z | sutta_publisher/src/sutta_publisher/edition_parsers/__init__.py | suttacentral/publications | 878befcfeb7af7f2f511697f2769cd00441aec57 | [
"CC0-1.0"
] | null | null | null | from .epub import EpubEdition
from .html import HtmlEdition
from .pdf import PdfEdition
__all__ = ["EpubEdition", "HtmlEdition", "PdfEdition"]
| 24 | 54 | 0.777778 | 16 | 144 | 6.75 | 0.5625 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0.125 | 144 | 5 | 55 | 28.8 | 0.857143 | 0 | 0 | 0 | 0 | 0 | 0.222222 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | false | 0 | 0.75 | 0 | 0.75 | 0 | 1 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 0 | 0 | 3 |
0c6b6942a6015b98ac3474b28a14d6d14c8b2df9 | 121 | py | Python | G53IDS/run.py | jayBana/InventoryMan | 0826f9c98062fb6600f77a721311cbf27719e528 | [
"Apache-2.0"
] | null | null | null | G53IDS/run.py | jayBana/InventoryMan | 0826f9c98062fb6600f77a721311cbf27719e528 | [
"Apache-2.0"
] | null | null | null | G53IDS/run.py | jayBana/InventoryMan | 0826f9c98062fb6600f77a721311cbf27719e528 | [
"Apache-2.0"
] | null | null | null | from server.controller.app import app as webapp
# import Flask app so that it can be launched with gunicorn
app = webapp
| 30.25 | 59 | 0.793388 | 21 | 121 | 4.571429 | 0.761905 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0.173554 | 121 | 3 | 60 | 40.333333 | 0.96 | 0.471074 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | false | 0 | 0.5 | 0 | 0.5 | 0 | 1 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 0 | 0 | 3 |
0c7a5201b457dc27f7c1cc8f8c9c04dfe54b1dc5 | 12,423 | py | Python | test/unit/test_localdb.py | muchu1983/104_cameo | 8c7f78de198a5bd8d870589402e3b7e8b59f520a | [
"BSD-3-Clause"
] | null | null | null | test/unit/test_localdb.py | muchu1983/104_cameo | 8c7f78de198a5bd8d870589402e3b7e8b59f520a | [
"BSD-3-Clause"
] | null | null | null | test/unit/test_localdb.py | muchu1983/104_cameo | 8c7f78de198a5bd8d870589402e3b7e8b59f520a | [
"BSD-3-Clause"
] | null | null | null | # -*- coding: utf-8 -*-
"""
Copyright (C) 2015, MuChu Hsu
Contributed by Muchu Hsu (muchu1983@gmail.com)
This file is part of BSD license
<https://opensource.org/licenses/BSD-3-Clause>
"""
import unittest
import logging
from cameo.localdb import LocalDbForCurrencyApi
from cameo.localdb import LocalDbForTECHORANGE
from cameo.localdb import LocalDbForBNEXT
from cameo.localdb import LocalDbForPEDAILY
from cameo.localdb import LocalDbForINSIDE
from cameo.localdb import LocalDbForTECHCRUNCH
from cameo.localdb import LocalDbForJD
from cameo.localdb import LocalDbForCROWDCUBE
from cameo.localdb import LocalDbForCRUNCHBASE
"""
測試 本地端資料庫存取
"""
class LocalDbTest(unittest.TestCase):
#準備
def setUp(self):
logging.basicConfig(level=logging.INFO)
#收尾
def tearDown(self):
pass
"""
#測試 幣別轉換API 本地端資料庫存取
def test_localdb_for_currency_api(self):
self.db = LocalDbForCurrencyApi()
logging.info("LocalDbTest.test_getMongoDbClient")
self.assertIsNotNone(self.db.mongodb)
#測試 techorange 本地端資料庫存取
def test_localdb_for_techorange(self):
logging.info("LocalDbTest.test_localdb_for_techorange")
db = LocalDbForTECHORANGE()
db.clearTestData() #清除前次測試資料
db.insertTagIfNotExists(strTagName="tag_for_unit_test")
self.assertEquals(db.fetchallNotObtainedTagName()[0], "tag_for_unit_test")
db.updateTagStatusIsGot(strTagName="tag_for_unit_test")
self.assertEquals(db.fetchallCompletedObtainedTagName()[0], "tag_for_unit_test")
db.insertNewsUrlAndNewsTagMappingIfNotExists(strNewsUrl="http://news/for/unit/test", strTagName="tag_for_unit_test")
self.assertEquals(db.fetchallNewsUrlByTagName(strTagName="tag_for_unit_test")[0], "http://news/for/unit/test")
self.assertFalse(db.checkNewsIsGot(strNewsUrl="http://news/for/unit/test"))
db.updateNewsStatusIsGot(strNewsUrl="http://news/for/unit/test")
self.assertTrue(db.checkNewsIsGot(strNewsUrl="http://news/for/unit/test"))
db.updateNewsStatusIsNotGot(strNewsUrlPart="/for/unit")
self.assertFalse(db.checkNewsIsGot(strNewsUrl="http://news/for/unit/test"))
db.clearTestData() #清除本次測試資料
#測試 bnext 本地端資料庫存取
def test_localdb_for_bnext(self):
logging.info("LocalDbTest.test_localdb_for_bnext")
db = LocalDbForBNEXT()
db.clearTestData() #清除前次測試資料
db.insertTagIfNotExists(strTagName="tag_for_unit_test")
self.assertEquals(db.fetchallNotObtainedTagName()[0], "tag_for_unit_test")
db.updateTagStatusIsGot(strTagName="tag_for_unit_test")
self.assertEquals(db.fetchallCompletedObtainedTagName()[0], "tag_for_unit_test")
db.insertNewsUrlAndNewsTagMappingIfNotExists(strNewsUrl="http://news/for/unit/test", strTagName="tag_for_unit_test")
self.assertEquals(db.fetchallNewsUrlByTagName(strTagName="tag_for_unit_test")[0], "http://news/for/unit/test")
self.assertFalse(db.checkNewsIsGot(strNewsUrl="http://news/for/unit/test"))
db.updateNewsStatusIsGot(strNewsUrl="http://news/for/unit/test")
self.assertTrue(db.checkNewsIsGot(strNewsUrl="http://news/for/unit/test"))
db.clearTestData() #清除本次測試資料
#測試 pedaily 本地端資料庫存取
def test_localdb_for_pedaily(self):
logging.info("LocalDbTest.test_localdb_for_pedaily")
db = LocalDbForPEDAILY()
db.clearTestData() #清除前次測試資料
db.insertCategoryIfNotExists(strCategoryName="category_for_unit_test")
self.assertEquals(db.fetchallNotObtainedCategoryName()[0], "category_for_unit_test")
db.updateCategoryStatusIsGot(strCategoryName="category_for_unit_test")
self.assertEquals(db.fetchallCompletedObtainedCategoryName()[0], "category_for_unit_test")
db.insertNewsUrlIfNotExists(strNewsUrl="http://news/for/unit/test", strCategoryName="category_for_unit_test")
self.assertEquals(db.fetchallNewsUrlByCategoryName(strCategoryName="category_for_unit_test")[0], "http://news/for/unit/test")
self.assertFalse(db.checkNewsIsGot(strNewsUrl="http://news/for/unit/test"))
db.updateNewsStatusIsGot(strNewsUrl="http://news/for/unit/test")
self.assertTrue(db.checkNewsIsGot(strNewsUrl="http://news/for/unit/test"))
self.assertEquals(db.fetchallCompletedObtainedNewsUrl(), ["http://news/for/unit/test"])
db.updateNewsStatusIsNotGot(strNewsUrl="http://news/for/unit/test")
self.assertFalse(db.checkNewsIsGot(strNewsUrl="http://news/for/unit/test"))
db.clearTestData() #清除本次測試資料
#測試 inside 本地端資料庫存取
def test_localdb_for_inside(self):
logging.info("LocalDbTest.test_localdb_for_inside")
db = LocalDbForINSIDE()
db.clearTestData() #清除前次測試資料
db.insertTagIfNotExists(strTagPage1Url="http://tag_for_unit_test/p1")
self.assertEquals(db.fetchallNotObtainedTagPage1Url()[0], "http://tag_for_unit_test/p1")
db.updateTagStatusIsGot(strTagPage1Url="http://tag_for_unit_test/p1")
self.assertEquals(db.fetchallCompletedObtainedTagPage1Url()[0], "http://tag_for_unit_test/p1")
db.insertNewsUrlAndNewsTagMappingIfNotExists(strNewsUrl="http://news/for/unit/test", strTagPage1Url="http://tag_for_unit_test/p1")
self.assertEquals(db.fetchallNewsUrlByTagPage1Url(strTagPage1Url="http://tag_for_unit_test/p1")[0], "http://news/for/unit/test")
self.assertFalse(db.checkNewsIsGot(strNewsUrl="http://news/for/unit/test"))
db.updateNewsStatusIsGot(strNewsUrl="http://news/for/unit/test")
self.assertTrue(db.checkNewsIsGot(strNewsUrl="http://news/for/unit/test"))
db.updateNewsStatusIsNotGot(strNewsUrlPart="/unit/test")
self.assertFalse(db.checkNewsIsGot(strNewsUrl="http://news/for/unit/test"))
db.clearTestData() #清除本次測試資料
#測試 techcrunch 本地端資料庫存取
def test_localdb_for_techcrunch(self):
logging.info("LocalDbTest.test_localdb_for_techcrunch")
db = LocalDbForTECHCRUNCH()
db.clearTestData() #清除前次測試資料
db.insertTopicIfNotExists(strTopicPage1Url="http://topic_for_unit_test")
self.assertEquals(db.fetchallNotObtainedTopicUrl()[0], "http://topic_for_unit_test")
db.updateTopicStatusIsGot(strTopicPage1Url="http://topic_for_unit_test")
self.assertEquals(db.fetchallCompletedObtainedTopicUrl()[0], "http://topic_for_unit_test")
db.insertNewsUrlIfNotExists(strNewsUrl="http://news/for/unit/test", strTopicPage1Url="http://topic_for_unit_test")
self.assertEquals(db.fetchallNewsUrlByTopicUrl(strTopicPage1Url="http://topic_for_unit_test")[0], "http://news/for/unit/test")
self.assertFalse(db.checkNewsIsGot(strNewsUrl="http://news/for/unit/test"))
db.updateNewsStatusIsGot(strNewsUrl="http://news/for/unit/test")
self.assertTrue(db.checkNewsIsGot(strNewsUrl="http://news/for/unit/test"))
self.assertEquals(db.fetchallCompletedObtainedNewsUrl(), ["http://news/for/unit/test"])
db.updateNewsStatusIsNotGot(strNewsUrl="http://news/for/unit/test")
self.assertFalse(db.checkNewsIsGot(strNewsUrl="http://news/for/unit/test"))
db.clearTestData() #清除本次測試資料
#測試 京東眾籌 本地端資料庫存取
def test_localdb_for_jd(self):
logging.info("LocalDbTest.test_localdb_for_jd")
db = LocalDbForJD()
db.clearTestData() #清除前次測試資料
db.insertCategoryIfNotExists(strCategoryPage1Url="http://category_for_unit_test", strCategoryName="category_for_unit_test")
self.assertEquals(db.fetchCategoryNameByUrl(strCategoryPage1Url="http://category_for_unit_test"), "category_for_unit_test")
self.assertEquals(db.fetchallNotObtainedCategoryUrl()[0], "http://category_for_unit_test")
db.updateCategoryStatusIsGot(strCategoryPage1Url="http://category_for_unit_test")
self.assertEquals(db.fetchallCompletedObtainedCategoryUrl()[0], "http://category_for_unit_test")
db.insertProjectUrlIfNotExists(strProjectUrl="http://project/for/unit/test", strCategoryPage1Url="http://category_for_unit_test")
db.insertFunderUrlIfNotExists(strFunderUrl="http://funder/for/unit/test", strCategoryPage1Url="http://category_for_unit_test")
self.assertEquals(db.fetchallProjectUrlByCategoryUrl(strCategoryPage1Url="http://category_for_unit_test")[0], "http://project/for/unit/test")
self.assertEquals(db.fetchallFunderUrlByCategoryUrl(strCategoryPage1Url="http://category_for_unit_test")[0], "http://funder/for/unit/test")
self.assertFalse(db.checkProjectIsGot(strProjectUrl="http://project/for/unit/test"))
self.assertFalse(db.checkFunderIsGot(strFunderUrl="http://funder/for/unit/test"))
db.updateProjectStatusIsGot(strProjectUrl="http://project/for/unit/test")
db.updateFunderStatusIsGot(strFunderUrl="http://funder/for/unit/test")
self.assertTrue(db.checkProjectIsGot(strProjectUrl="http://project/for/unit/test"))
self.assertTrue(db.checkFunderIsGot(strFunderUrl="http://funder/for/unit/test"))
self.assertEquals(db.fetchallCompletedObtainedProjectUrl(), ["http://project/for/unit/test"])
self.assertEquals(db.fetchallCompletedObtainedFunderUrl(), ["http://funder/for/unit/test"])
db.updateProjectStatusIsNotGot(strProjectUrl="http://project/for/unit/test")
db.updateFunderStatusIsNotGot(strFunderUrl="http://funder/for/unit/test")
self.assertFalse(db.checkProjectIsGot(strProjectUrl="http://project/for/unit/test"))
self.assertFalse(db.checkFunderIsGot(strFunderUrl="http://funder/for/unit/test"))
db.clearTestData() #清除本次測試資料
#測試 crowdcube 本地端資料庫存取
def test_localdb_for_crowdcube(self):
logging.info("LocalDbTest.test_localdb_for_crowdcube")
db = LocalDbForCROWDCUBE()
db.clearTestData() #清除前次測試資料
db.insertAccountIfNotExists(strEmail="ebucdworc+0100@gmail.com", strPassword="bee520")
db.insertAccountIfNotExists(strEmail="ebucdworc+0101@gmail.com", strPassword="bee520")
(strAccountEmail, strAccountPassword) = db.fetchRandomReadyAccount()
self.assertTrue(strAccountEmail.startswith("ebucdworc"))
db.insertCompanyUrlIfNotExists(strCompanyUrl="http://company/for/unit/test")
self.assertEquals(db.fetchallNotObtainedCompanyUrl(), ["http://company/for/unit/test"])
self.assertFalse(db.checkCompanyIsGot(strCompanyUrl="http://company/for/unit/test"))
db.updateCompanyStatusIsGot(strCompanyUrl="http://company/for/unit/test")
self.assertTrue(db.checkCompanyIsGot(strCompanyUrl="http://company/for/unit/test"))
self.assertEquals(db.fetchallCompletedObtainedCompanyUrl(), ["http://company/for/unit/test"])
db.updateCompanyStatusIsNotGot(strCompanyUrl="http://company/for/unit/test")
self.assertFalse(db.checkCompanyIsGot(strCompanyUrl="http://company/for/unit/test"))
db.clearTestData() #清除本次測試資料
"""
#測試 crunchbase 本地端資料庫存取
def test_localdb_for_crunchbase(self):
logging.info("LocalDbTest.test_localdb_for_crunchbase")
db = LocalDbForCRUNCHBASE()
db.clearTestData() #清除前次測試資料
db.insertAccountIfNotExists(strEmail="esabhcnurc+0100@gmail.com", strPassword="bee520")
db.insertAccountIfNotExists(strEmail="esabhcnurc+0101@gmail.com", strPassword="bee520")
(strAccountEmail, strAccountPassword) = db.fetchRandomReadyAccount()
self.assertTrue(strAccountEmail.startswith("esabhcnurc"))
db.insertOrganizationUrlIfNotExists(strOrganizationUrl="http://organization/for/unit/test")
self.assertEquals(db.fetchallNotObtainedOrganizationUrl(), ["http://organization/for/unit/test"])
self.assertFalse(db.checkOrganizationIsGot(strOrganizationUrl="http://organization/for/unit/test"))
db.updateOrganizationStatusIsGot(strOrganizationUrl="http://organization/for/unit/test")
self.assertTrue(db.checkOrganizationIsGot(strOrganizationUrl="http://organization/for/unit/test"))
self.assertEquals(db.fetchallCompletedObtainedOrganizationUrl(), ["http://organization/for/unit/test"])
db.updateOrganizationStatusIsNotGot(strOrganizationUrl="http://organization/for/unit/test")
self.assertFalse(db.checkOrganizationIsGot(strOrganizationUrl="http://organization/for/unit/test"))
db.clearTestData() #清除本次測試資料
#測試開始
if __name__ == "__main__":
unittest.main(exit=False)
| 62.115 | 149 | 0.738871 | 1,286 | 12,423 | 6.994557 | 0.133748 | 0.083268 | 0.129628 | 0.081712 | 0.751306 | 0.708505 | 0.652918 | 0.567538 | 0.500167 | 0.429461 | 0 | 0.00749 | 0.129437 | 12,423 | 199 | 150 | 62.427136 | 0.824226 | 0.018192 | 0 | 0.114286 | 0 | 0 | 0.186829 | 0.043415 | 0 | 0 | 0 | 0 | 0.171429 | 1 | 0.085714 | false | 0.114286 | 0.314286 | 0 | 0.428571 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 1 | 0 | 0 | 0 | 0 | 3 |
0c98a8571671f7ec771a67037041f3b8e9ba1d24 | 274 | py | Python | tests/test_tradera.py | paeronskruven/lw | a2e4b6363656812a0857a8b2cf69be3e710afe94 | [
"MIT"
] | null | null | null | tests/test_tradera.py | paeronskruven/lw | a2e4b6363656812a0857a8b2cf69be3e710afe94 | [
"MIT"
] | null | null | null | tests/test_tradera.py | paeronskruven/lw | a2e4b6363656812a0857a8b2cf69be3e710afe94 | [
"MIT"
] | null | null | null | import lw.sources.tradera
def test_valid_query():
results = lw.sources.tradera.TraderaSource().query('a')
assert len(list(results)) > 0
def test_invalid_query():
results = lw.sources.tradera.TraderaSource().query('abc123')
assert len(list(results)) == 0
| 22.833333 | 64 | 0.70438 | 36 | 274 | 5.25 | 0.472222 | 0.142857 | 0.253968 | 0.222222 | 0.708995 | 0.486772 | 0.486772 | 0 | 0 | 0 | 0 | 0.021368 | 0.145985 | 274 | 11 | 65 | 24.909091 | 0.786325 | 0 | 0 | 0 | 0 | 0 | 0.025547 | 0 | 0 | 0 | 0 | 0 | 0.285714 | 1 | 0.285714 | false | 0 | 0.142857 | 0 | 0.428571 | 0 | 0 | 0 | 0 | null | 0 | 1 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 3 |
0c9a4fc23573fcb066eaa1cdddfd05b22ff7fab8 | 10,370 | py | Python | tests/__init__.py | pywikibot-catfiles/file-metadata | 79c585dcb67b966f02485136c4d875d5b5365230 | [
"MIT"
] | 10 | 2016-07-15T07:07:53.000Z | 2022-02-17T07:41:03.000Z | tests/__init__.py | AbdealiJK/file-metadata | 79c585dcb67b966f02485136c4d875d5b5365230 | [
"MIT"
] | 48 | 2016-03-14T06:44:36.000Z | 2016-07-13T00:35:54.000Z | tests/__init__.py | pywikibot-catfiles/file-metadata | 79c585dcb67b966f02485136c4d875d5b5365230 | [
"MIT"
] | 5 | 2017-04-24T07:02:22.000Z | 2020-12-14T06:23:57.000Z | # -*- coding: utf-8 -*-
from __future__ import (division, absolute_import, unicode_literals,
print_function)
# flake8: noqa (unused import and line too long due to links)
import os
import random
import string
import struct
import wave
try:
import unittest
except ImportError:
import unittest2 as unittest
try:
import unittest.mock as mock
except ImportError:
import mock
from file_metadata._compat import makedirs, which
from file_metadata.utilities import download
CACHE_DIR = os.path.join(os.path.dirname(os.path.abspath(__file__)), 'files')
file_download_links = {
# Audio
'wikiexample.ogg': 'https://upload.wikimedia.org/wikipedia/commons/c/c8/Example.ogg',
'drums.mid': 'https://upload.wikimedia.org/wikipedia/commons/6/61/Drum_sample.mid',
'bell.wav': 'https://upload.wikimedia.org/wikipedia/commons/9/97/156064_marcolo91_bicycle-bell.wav',
'bell.flac': 'https://upload.wikimedia.org/wikipedia/commons/b/b2/Bell-ring.flac',
'bell.oga': 'https://upload.wikimedia.org/wikipedia/commons/6/6c/Announcement_on_a_wharf.oga',
'bell.ogg': 'https://upload.wikimedia.org/wikipedia/commons/3/34/Sound_Effect_-_Door_Bell.ogg',
'multiline_ffprobe.ogg': 'https://upload.wikimedia.org/wikipedia/commons/5/58/17650_thoschi_issyk-kul.ogg',
# Videos
'veins.ogv': 'https://upload.wikimedia.org/wikipedia/commons/f/f2/POROS_3.ogv',
'ogg_video.ogg': 'https://upload.wikimedia.org/wikipedia/commons/e/e3/2010-06-06-V-German-Flag.ogg',
'sample.webm': 'https://upload.wikimedia.org/wikipedia/commons/a/a5/02_Punktion_des_ausgebildeten_Knopflochs%281%29.webm',
# Images
'ball.png': 'https://upload.wikimedia.org/wikipedia/commons/thumb/5/51/1-ball.svg/226px-1-ball.svg.png',
'ball.svg': 'https://upload.wikimedia.org/wikipedia/commons/5/51/1-ball.svg',
'red.png': 'https://upload.wikimedia.org/wikipedia/commons/thumb/6/62/Pure_Red.svg/100px-Pure_Red.svg.png',
'green.png': 'https://upload.wikimedia.org/wikipedia/commons/thumb/c/c5/Pure_Green.svg/100px-Pure_Green.svg.png',
'blue.png': 'https://upload.wikimedia.org/wikipedia/commons/thumb/7/77/Pure_Blue.svg/100px-Pure_Blue.svg.png',
'red.svg': 'https://upload.wikimedia.org/wikipedia/commons/6/62/Pure_Red.svg',
'green.svg': 'https://upload.wikimedia.org/wikipedia/commons/c/c5/Pure_Green.svg',
'blue.svg': 'https://upload.wikimedia.org/wikipedia/commons/7/77/Pure_Blue.svg',
'animated.svg': 'https://upload.wikimedia.org/wikipedia/commons/f/fd/Animated_pendulum.svg',
'animated.gif': 'https://upload.wikimedia.org/wikipedia/commons/d/d7/123_Numbers.gif',
'animated.png': 'https://upload.wikimedia.org/wikipedia/commons/b/b5/Load.png',
'static.gif': 'https://upload.wikimedia.org/wikipedia/commons/e/ed/Pix.gif',
'cmyk.jpg': 'https://upload.wikimedia.org/wikipedia/commons/thumb/1/11/17-barcodes-1-e_ces_2012_01.jpg/524px-17-barcodes-1-e_ces_2012_01.jpg',
'unknown_cmyk.jpg': 'https://upload.wikimedia.org/wikipedia/commons/f/f3/TeXML_dtd.jpg',
# SVG files with different mimetypes
'image_svg_xml.svg': 'https://upload.wikimedia.org/wikipedia/commons/6/62/Pure_Red.svg',
'text_plain.svg': 'https://upload.wikimedia.org/wikipedia/commons/5/57/Color_icon_white.svg',
'text_html.svg': 'https://upload.wikimedia.org/wikipedia/commons/f/fd/Animated_pendulum.svg',
'application_xml.svg': 'https://upload.wikimedia.org/wikipedia/commons/0/0b/Sieve_of_Eratosthenes_animation.svg',
# Images with special exifdata:
'canon_face.jpg': 'https://upload.wikimedia.org/wikipedia/commons/7/7b/Annagrah-2_041.JPG',
'nonascii_exifdata.jpg': 'https://upload.wikimedia.org/wikipedia/commons/d/d5/2013-04-25_21-09-18-ecl-lune-mosaic.jpg',
# Images of faces
'mona_lisa.jpg': 'https://upload.wikimedia.org/wikipedia/commons/7/7d/Mona_Lisa_color_restoration.jpg',
'michael_jackson.jpg': 'https://upload.wikimedia.org/wikipedia/commons/7/7e/Michaeljackson_%28cropped%29.jpg',
'charlie_chaplin.jpg': 'https://upload.wikimedia.org/wikipedia/commons/0/00/Charlie_Chaplin.jpg',
'baby_face.jpg': 'https://upload.wikimedia.org/wikipedia/commons/1/10/Portrait_of_a_male_baby_%285866018681%29.jpg',
'baby_partial_face.jpg': 'https://upload.wikimedia.org/wikipedia/commons/1/1f/Sweet_Baby_Kisses_Family_Love.jpg',
'old_face.jpg': 'https://upload.wikimedia.org/wikipedia/commons/1/11/Brazil_%283042571516%29_%282%29.jpg',
'beard_face.jpg': 'https://upload.wikimedia.org/wikipedia/commons/6/61/Oskar_Almgren%2C_Stockholm%2C_Sweden_%285859501260%29_%282%29.jpg',
'cat_face.jpg': 'https://upload.wikimedia.org/wikipedia/commons/thumb/c/c4/Savannah_Cat_portrait.jpg/400px-Savannah_Cat_portrait.jpg',
'monkey_face.jpg': 'https://upload.wikimedia.org/wikipedia/commons/2/27/Baby_ginger_monkey.jpg',
'woman.xcf': 'https://upload.wikimedia.org/wikipedia/commons/a/af/Beatrix_Podolska_pedagog_muzykolog_Krakow_2008.xcf',
# Barcodes / QR Codes / Data matrices
'qrcode.jpg': 'https://upload.wikimedia.org/wikipedia/commons/5/5b/Qrcode_wikipedia.jpg',
'barcode.png': 'https://upload.wikimedia.org/wikipedia/commons/1/1f/Rationalized-codabar.png',
'datamatrix.png': 'https://upload.wikimedia.org/wikipedia/commons/thumb/e/e8/Datamatrix.svg/200px-Datamatrix.svg.png',
'multibarcodes.png': 'https://upload.wikimedia.org/wikipedia/commons/9/98/DHL_Online-Frankierung_-_Paket_bis_5_kg_-_D-USA.png',
'vertical_barcode.jpg': 'https://upload.wikimedia.org/wikipedia/commons/9/9c/Final_Ida_Pasto_vs._Santa_Fe.jpg',
'huge.png': 'https://upload.wikimedia.org/wikipedia/commons/3/31/Grand_paris_express.png',
'blank.xcf': 'https://upload.wikimedia.org/wikipedia/commons/e/e2/Blank_file.xcf',
'example.tiff': 'https://upload.wikimedia.org/wikipedia/commons/b/b0/Dabigatran_binding_pockets.tiff',
# Line drawings
'simple_line_drawing.jpg': 'https://upload.wikimedia.org/wikipedia/commons/c/c6/Destilacija_rakije.jpg',
'detailed_line_drawing.jpg': 'https://upload.wikimedia.org/wikipedia/commons/d/db/Compound_Microscope_1876.JPG',
'very_detailed_line_drawing.jpg': 'https://upload.wikimedia.org/wikipedia/commons/c/cb/Hospital_ward_on_Red_Rover.jpg',
'dark_line_drawing.jpg': 'https://upload.wikimedia.org/wikipedia/commons/3/3e/Bird_in_flight_line_drawing_art.jpg',
# Logos
'wikimedia_logo.png': 'https://upload.wikimedia.org/wikipedia/commons/thumb/8/81/Wikimedia-logo.svg/768px-Wikimedia-logo.svg.png',
'wikidata_logo.png': 'https://upload.wikimedia.org/wikipedia/commons/thumb/f/ff/Wikidata-logo.svg/1024px-Wikidata-logo.svg.png',
'wikipedia_logo.png': 'https://upload.wikimedia.org/wikipedia/commons/thumb/d/de/Wikipedia_Logo_1.0.png/768px-Wikipedia_Logo_1.0.png',
'commons_logo.png': 'https://upload.wikimedia.org/wikipedia/commons/thumb/4/4a/Commons-logo.svg/571px-Commons-logo.svg.png',
# Geocoded images
'geotag_osaka.jpg': 'https://upload.wikimedia.org/wikipedia/commons/5/50/Honda_STEPWGN_SPADA%E3%83%BBCool_Spirit_%28RP3%29_rear.JPG',
# Monochrome colors
'blackwhite_monochrome.jpg': 'https://upload.wikimedia.org/wikipedia/commons/2/27/0218_-_Taormina_-_Badia_Vecchia_-_Foto_Giovanni_Dall%27Orto%2C_20-May-2008.jpg',
'blue_monochrome.jpg': 'https://upload.wikimedia.org/wikipedia/commons/9/9f/Paolo_Monti_-_Serie_fotografica_-_BEIC_6358396.jpg',
'green_monochrome.jpg': 'https://upload.wikimedia.org/wikipedia/commons/e/ea/Edvard-dawkins.jpg',
'sepia_monochrome.jpg': 'https://upload.wikimedia.org/wikipedia/commons/c/c7/1926_Hupmobile.jpg',
# Color calibrations
'it8_top_bar.jpg': 'https://upload.wikimedia.org/wikipedia/commons/thumb/9/97/Waterfall_at_Schooner_Head_house_%28NYPL_b11707223-G89F198_003B%29.tiff/lossy-page1-1280px-Waterfall_at_Schooner_Head_house_%28NYPL_b11707223-G89F198_003B%29.tiff.jpg',
'it8_bottom_bar.jpg': 'https://upload.wikimedia.org/wikipedia/commons/thumb/b/b5/Two_boys_sitting_in_a_garden_%28NYPL_b11528957-G90F452_008B%29.tiff/lossy-page1-996px-Two_boys_sitting_in_a_garden_%28NYPL_b11528957-G90F452_008B%29.tiff.jpg',
# Application files
'text.pdf': 'https://upload.wikimedia.org/wikipedia/commons/a/a7/Life_of_Future.pdf',
'image.pdf': 'https://upload.wikimedia.org/wikipedia/commons/4/40/AugerTransition1.pdf',
'empty.djvu': 'https://upload.wikimedia.org/wikipedia/commons/4/42/Vuota.djvu',
}
def fetch_file(name, overwrite=False):
"""
Fetch a file based on the given key. If the file is not found, it is
created appropriately by either generating it or downloading it from
elsewhere.
:param name: The name (key) of the file that is needed.
:param overwrite: Force overwrite if file exists.
:return: The absolute path of the requested file.
"""
filepath = os.path.join(CACHE_DIR, name)
makedirs(CACHE_DIR, exist_ok=True)
if os.path.exists(filepath) and not overwrite: # Use cached file
return filepath
# Miscellaneous files
if name == 'ascii.txt':
with open(filepath, 'w') as file_handler:
file_handler.writelines([
string.ascii_lowercase, '\n', string.ascii_uppercase, '\n',
string.digits, '\n', string.punctuation, '\n'])
elif name == 'file.bin':
with open(filepath, 'wb') as file_hander:
allascii = ''.join(chr(i) for i in range(128))
file_hander.write(allascii.encode('ascii'))
# Music files
elif name == "noise.wav":
wav_file = wave.open(filepath, 'w')
wav_file.setparams((1, 2, 44100, 0, 'NONE', 'not compressed'))
for _ in range(44100): # 1 second
value = struct.pack('h', random.randint(-32767, 32767))
wav_file.writeframes(value)
wav_file.close()
elif name in file_download_links:
download(file_download_links[name], filepath)
else:
raise ValueError('Asked to fetch unknown file {0}.'.format(name))
return filepath
def which_sideeffect(unavailable_executables):
def wrapper(command, *args, **kwargs):
if command in unavailable_executables:
return None
return which(command, *args, **kwargs)
return wrapper
def is_toolserver():
return os.environ.get('INSTANCEPROJECT', None) == 'tools'
def is_travis():
return os.environ.get('TRAVIS', None) == 'true'
| 56.666667 | 250 | 0.73433 | 1,488 | 10,370 | 4.949597 | 0.328629 | 0.098574 | 0.179226 | 0.20611 | 0.476986 | 0.460014 | 0.460014 | 0.327631 | 0.167413 | 0.087576 | 0 | 0.048923 | 0.109065 | 10,370 | 182 | 251 | 56.978022 | 0.748241 | 0.066249 | 0 | 0.04918 | 0 | 0.270492 | 0.705161 | 0.019421 | 0 | 0 | 0 | 0 | 0 | 1 | 0.040984 | false | 0 | 0.114754 | 0.016393 | 0.213115 | 0.008197 | 0 | 0 | 0 | null | 0 | 0 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 1 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 3 |
0cae04c95140cd33bca1362795247caf69458f47 | 9,770 | py | Python | fugue/column/functions.py | kvnkho/fugue | 5f3fe8f1fb72632e5b5987d720c1d1ef546e4682 | [
"Apache-2.0"
] | 547 | 2020-09-22T08:30:14.000Z | 2022-03-30T23:11:05.000Z | fugue/column/functions.py | kvnkho/fugue | 5f3fe8f1fb72632e5b5987d720c1d1ef546e4682 | [
"Apache-2.0"
] | 196 | 2020-09-22T23:08:26.000Z | 2022-03-26T21:22:48.000Z | fugue/column/functions.py | kvnkho/fugue | 5f3fe8f1fb72632e5b5987d720c1d1ef546e4682 | [
"Apache-2.0"
] | 37 | 2020-09-23T17:05:00.000Z | 2022-03-29T18:26:52.000Z | from typing import Any, Optional
import pyarrow as pa
from fugue.column.expressions import (
ColumnExpr,
_FuncExpr,
_to_col,
function,
)
from triad import Schema
def coalesce(*args: Any) -> ColumnExpr:
"""SQL ``COALESCE`` function
:param args: If a value is not :class:`~fugue.column.expressions.ColumnExpr`
then it's converted to a literal column by
:func:`~fugue.column.expressions.col`
.. note::
this function can infer neither type nor alias
.. admonition:: New Since
:class: hint
**0.6.0**
.. admonition:: Examples
.. code-block:: python
import fugue.column.functions as f
f.coalesce(col("a"), col("b")+col("c"), 1)
"""
return function("COALESCE", *[_to_col(x) for x in args])
def min(col: ColumnExpr) -> ColumnExpr: # pylint: disable=redefined-builtin
"""SQL ``MIN`` function (aggregation)
:param col: the column to find min
.. note::
* this function can infer type from ``col`` type
* this function can infer alias from ``col``'s inferred alias
.. admonition:: New Since
:class: hint
**0.6.0**
.. admonition:: Examples
.. code-block:: python
import fugue.column.functions as f
# assume col a has type double
f.min(col("a")) # CAST(MIN(a) AS double) AS a
f.min(-col("a")) # CAST(MIN(-a) AS double) AS a
# neither type nor alias can be inferred in the following cases
f.min(col("a")+1)
f.min(col("a")+col("b"))
# you can specify explicitly
# CAST(MIN(a+b) AS int) AS x
f.min(col("a")+col("b")).cast(int).alias("x")
"""
assert isinstance(col, ColumnExpr)
return _SameTypeUnaryAggFuncExpr("MIN", col)
def max(col: ColumnExpr) -> ColumnExpr: # pylint: disable=redefined-builtin
"""SQL ``MAX`` function (aggregation)
:param col: the column to find max
.. note::
* this function can infer type from ``col`` type
* this function can infer alias from ``col``'s inferred alias
.. admonition:: New Since
:class: hint
**0.6.0**
.. admonition:: Examples
.. code-block:: python
import fugue.column.functions as f
# assume col a has type double
f.max(col("a")) # CAST(MAX(a) AS double) AS a
f.max(-col("a")) # CAST(MAX(-a) AS double) AS a
# neither type nor alias can be inferred in the following cases
f.max(col("a")+1)
f.max(col("a")+col("b"))
# you can specify explicitly
# CAST(MAX(a+b) AS int) AS x
f.max(col("a")+col("b")).cast(int).alias("x")
"""
assert isinstance(col, ColumnExpr)
return _SameTypeUnaryAggFuncExpr("MAX", col)
def count(col: ColumnExpr) -> ColumnExpr:
"""SQL ``COUNT`` function (aggregation)
:param col: the column to find count
.. note::
* this function cannot infer type from ``col`` type
* this function can infer alias from ``col``'s inferred alias
.. admonition:: New Since
:class: hint
**0.6.0**
.. admonition:: Examples
.. code-block:: python
import fugue.column.functions as f
f.count(col("*")) # COUNT(*)
f.count(col("a")) # COUNT(a) AS a
# you can specify explicitly
# CAST(COUNT(a) AS double) AS a
f.count(col("a")).cast(float)
"""
assert isinstance(col, ColumnExpr)
return _UnaryAggFuncExpr("COUNT", col)
def count_distinct(col: ColumnExpr) -> ColumnExpr:
"""SQL ``COUNT DISTINCT`` function (aggregation)
:param col: the column to find distinct element count
.. note::
* this function cannot infer type from ``col`` type
* this function can infer alias from ``col``'s inferred alias
.. admonition:: New Since
:class: hint
**0.6.0**
.. admonition:: Examples
.. code-block:: python
import fugue.column.functions as f
f.count_distinct(col("*")) # COUNT(DISTINCT *)
f.count_distinct(col("a")) # COUNT(DISTINCT a) AS a
# you can specify explicitly
# CAST(COUNT(DISTINCT a) AS double) AS a
f.count_distinct(col("a")).cast(float)
"""
assert isinstance(col, ColumnExpr)
return _UnaryAggFuncExpr("COUNT", col, arg_distinct=True)
def avg(col: ColumnExpr) -> ColumnExpr:
"""SQL ``AVG`` function (aggregation)
:param col: the column to find average
.. note::
* this function cannot infer type from ``col`` type
* this function can infer alias from ``col``'s inferred alias
.. admonition:: New Since
:class: hint
**0.6.0**
.. admonition:: Examples
.. code-block:: python
import fugue.column.functions as f
f.avg(col("a")) # AVG(a) AS a
# you can specify explicitly
# CAST(AVG(a) AS double) AS a
f.avg(col("a")).cast(float)
"""
assert isinstance(col, ColumnExpr)
return _UnaryAggFuncExpr("AVG", col)
def sum(col: ColumnExpr) -> ColumnExpr: # pylint: disable=redefined-builtin
"""SQL ``SUM`` function (aggregation)
:param col: the column to find sum
.. note::
* this function cannot infer type from ``col`` type
* this function can infer alias from ``col``'s inferred alias
.. admonition:: New Since
:class: hint
**0.6.0**
.. admonition:: Examples
.. code-block:: python
import fugue.column.functions as f
f.sum(col("a")) # SUM(a) AS a
# you can specify explicitly
# CAST(SUM(a) AS double) AS a
f.sum(col("a")).cast(float)
"""
assert isinstance(col, ColumnExpr)
return _UnaryAggFuncExpr("SUM", col)
def first(col: ColumnExpr) -> ColumnExpr:
"""SQL ``FIRST`` function (aggregation)
:param col: the column to find first
.. note::
* this function can infer type from ``col`` type
* this function can infer alias from ``col``'s inferred alias
.. admonition:: New Since
:class: hint
**0.6.0**
.. admonition:: Examples
.. code-block:: python
import fugue.column.functions as f
# assume col a has type double
f.first(col("a")) # CAST(FIRST(a) AS double) AS a
f.first(-col("a")) # CAST(FIRST(-a) AS double) AS a
# neither type nor alias can be inferred in the following cases
f.first(col("a")+1)
f.first(col("a")+col("b"))
# you can specify explicitly
# CAST(FIRST(a+b) AS int) AS x
f.first(col("a")+col("b")).cast(int).alias("x")
"""
assert isinstance(col, ColumnExpr)
return _SameTypeUnaryAggFuncExpr("FIRST", col)
def last(col: ColumnExpr) -> ColumnExpr:
"""SQL ``LAST`` function (aggregation)
:param col: the column to find last
.. note::
* this function can infer type from ``col`` type
* this function can infer alias from ``col``'s inferred alias
.. admonition:: New Since
:class: hint
**0.6.0**
.. admonition:: Examples
.. code-block:: python
import fugue.column.functions as f
# assume col a has type double
f.last(col("a")) # CAST(LAST(a) AS double) AS a
f.last(-col("a")) # CAST(LAST(-a) AS double) AS a
# neither type nor alias can be inferred in the following cases
f.last(col("a")+1)
f.last(col("a")+col("b"))
# you can specify explicitly
# CAST(LAST(a+b) AS int) AS x
f.last(col("a")+col("b")).cast(int).alias("x")
"""
assert isinstance(col, ColumnExpr)
return _SameTypeUnaryAggFuncExpr("LAST", col)
def is_agg(column: Any) -> bool:
"""Check if a column contains aggregation operation
:param col: the column to check
:return: whether the column is :class:`~fugue.column.expressions.ColumnExpr`
and contains aggregation operations
.. admonition:: New Since
:class: hint
**0.6.0**
.. admonition:: Examples
.. code-block:: python
import fugue.column.functions as f
assert not f.is_agg(1)
assert not f.is_agg(col("a"))
assert not f.is_agg(col("a")+lit(1))
assert f.is_agg(f.max(col("a")))
assert f.is_agg(-f.max(col("a")))
assert f.is_agg(f.max(col("a")+1))
assert f.is_agg(f.max(col("a"))+f.min(col("a"))))
"""
if isinstance(column, _UnaryAggFuncExpr):
return True
if isinstance(column, _FuncExpr):
return any(is_agg(x) for x in column.args) or any(
is_agg(x) for x in column.kwargs.values()
)
return False
class _UnaryAggFuncExpr(_FuncExpr):
def __init__(self, func: str, col: ColumnExpr, arg_distinct: bool = False):
super().__init__(func, col, arg_distinct=arg_distinct)
def infer_alias(self) -> ColumnExpr:
return (
self
if self.output_name != ""
else self.alias(self.args[0].infer_alias().output_name)
)
def _copy(self) -> _FuncExpr:
return _UnaryAggFuncExpr(self.func, *self.args, **self.kwargs)
class _SameTypeUnaryAggFuncExpr(_UnaryAggFuncExpr):
def _copy(self) -> _FuncExpr:
return _SameTypeUnaryAggFuncExpr(self.func, *self.args, **self.kwargs)
def infer_type(self, schema: Schema) -> Optional[pa.DataType]:
return self.as_type or self.args[0].infer_type(schema)
| 26.334232 | 80 | 0.572467 | 1,255 | 9,770 | 4.410359 | 0.097211 | 0.028907 | 0.03523 | 0.046974 | 0.754652 | 0.702981 | 0.682746 | 0.661427 | 0.552123 | 0.509846 | 0 | 0.005801 | 0.294268 | 9,770 | 370 | 81 | 26.405405 | 0.796954 | 0.672979 | 0 | 0.169492 | 0 | 0 | 0.015957 | 0 | 0 | 0 | 0 | 0 | 0.135593 | 1 | 0.254237 | false | 0 | 0.067797 | 0.067797 | 0.627119 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 3 |
0cb24ca44f49e7024594f31e5eea8a2d6ed7620b | 1,437 | py | Python | Source Files/auth.py | clever-username/baseball-card-inventory | 9940ba746072892961b7ade586e63f7deb26d2e6 | [
"MIT"
] | 1 | 2021-05-18T21:32:43.000Z | 2021-05-18T21:32:43.000Z | Source Files/auth.py | clever-username/baseball-card-inventory | 9940ba746072892961b7ade586e63f7deb26d2e6 | [
"MIT"
] | null | null | null | Source Files/auth.py | clever-username/baseball-card-inventory | 9940ba746072892961b7ade586e63f7deb26d2e6 | [
"MIT"
] | 2 | 2015-05-18T14:52:01.000Z | 2015-05-19T18:21:51.000Z | #!/usr/bin/env python
# -*- coding: utf-8 -*-
"""This program prompts for a password."""
import authentication
import getpass
def login(username, maxattempts=3):
"""This function takes input from a user and checks the password.
Arg:
username(str): String input from user.
maxattempts(int): Max attempts for login.
Return:
auth(boolean): True or False if user successfully authenticated
before hitting maximum no. of failed attempts.
Examples:
>>>login('mike', 4)
Incorrect username or password. You have 4 attempts.
Incorrect username or password. You have 3 attempts.
Incorrect username or password. You have 2 attempts.
Incorrect username or password. You have 1 attempts.
Incorrect username or password. You have 0 attempts.
False
"""
auth = False
user_login = 'Please enter your password: '
auth_fail = "Incorrect username or password. You have" ' {} ' "attempts."
attempt = 1
while attempt <= maxattempts:
passwd = getpass.getpass(user_login)
message = authentication.authenticate(username, passwd)
if message:
auth = True
break
else:
print auth_fail.format(maxattempts - attempt)
attempt += 1
return auth
| 31.933333 | 78 | 0.592206 | 156 | 1,437 | 5.429487 | 0.461538 | 0.120425 | 0.134593 | 0.191263 | 0.27863 | 0.27863 | 0.198347 | 0 | 0 | 0 | 0 | 0.01046 | 0.334725 | 1,437 | 44 | 79 | 32.659091 | 0.875523 | 0.029228 | 0 | 0 | 0 | 0 | 0.143617 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | null | null | 0.294118 | 0.117647 | null | null | 0.058824 | 0 | 0 | 0 | null | 0 | 0 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 1 | 0 | 0 | 0 | 0 | 0 | 3 |
0cb26210fdbce5c2de9ff66cfbeec89817eff49b | 267 | py | Python | tests/test_utils.py | yehzhang/dscraper | 6fd1a4238795e9eb01b9dd8329a84495a70979d1 | [
"Apache-2.0"
] | 1 | 2017-08-13T09:50:06.000Z | 2017-08-13T09:50:06.000Z | tests/test_utils.py | yehzhang/dscraper | 6fd1a4238795e9eb01b9dd8329a84495a70979d1 | [
"Apache-2.0"
] | null | null | null | tests/test_utils.py | yehzhang/dscraper | 6fd1a4238795e9eb01b9dd8329a84495a70979d1 | [
"Apache-2.0"
] | null | null | null | import unittest
import logging
import xml.etree.ElementTree as et
import dscraper.utils as utils
logger = logging.getLogger(__name__)
class TestUtils(unittest.TestCase):
XML_FILES = (
'tests/resources/1.xml',
)
def setUp(self):
pass
| 14.833333 | 36 | 0.692884 | 33 | 267 | 5.454545 | 0.727273 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0.004808 | 0.220974 | 267 | 17 | 37 | 15.705882 | 0.860577 | 0 | 0 | 0 | 0 | 0 | 0.078947 | 0.078947 | 0 | 0 | 0 | 0 | 0 | 1 | 0.090909 | false | 0.090909 | 0.363636 | 0 | 0.636364 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 1 | 0 | 1 | 0 | 0 | 3 |
0cb8ec1c4a754eeb4820931d43bc795cf047e17e | 187 | py | Python | api/messages/csv_file.py | pikanezi/Roadkill | b2c69294afa4cce810fa898f3aa1cb467bffa413 | [
"MIT"
] | null | null | null | api/messages/csv_file.py | pikanezi/Roadkill | b2c69294afa4cce810fa898f3aa1cb467bffa413 | [
"MIT"
] | null | null | null | api/messages/csv_file.py | pikanezi/Roadkill | b2c69294afa4cce810fa898f3aa1cb467bffa413 | [
"MIT"
] | null | null | null | __author__ = 'Vincent'
from protorpc import messages
class CsvFile(messages.Message):
file = messages.BytesField(1, required=True)
name = messages.StringField(2, required=False) | 26.714286 | 50 | 0.759358 | 22 | 187 | 6.272727 | 0.818182 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0.012422 | 0.139037 | 187 | 7 | 50 | 26.714286 | 0.844721 | 0 | 0 | 0 | 0 | 0 | 0.037234 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | false | 0 | 0.2 | 0 | 0.8 | 0 | 1 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 3 |
0cc46073749631b895fb07e8351d82807fbd6e14 | 2,140 | py | Python | lms_app/v1/serializers/user_serializers.py | Etomovich/lms-backend | e586abc44a0e74ed28da7a77f6ef31230995c84b | [
"MIT"
] | null | null | null | lms_app/v1/serializers/user_serializers.py | Etomovich/lms-backend | e586abc44a0e74ed28da7a77f6ef31230995c84b | [
"MIT"
] | 1 | 2021-06-02T00:45:56.000Z | 2021-06-02T00:45:56.000Z | lms_app/v1/serializers/user_serializers.py | Etomovich/lms-backend | e586abc44a0e74ed28da7a77f6ef31230995c84b | [
"MIT"
] | null | null | null | from flask_restplus import Namespace, fields
class UserDataModel(object):
"""Represents the user data transfer object."""
api = Namespace(
'user', description='user authentication and signup resources'
)
this_user = api.model('Register input data', {
'username': fields.String(
required=True, description="username"
),
'first_name': fields.String(
required=True, description="user's first name"
),
'last_name': fields.String(
required=True, description="user's last name"
),
'national_id': fields.Integer(
required=True, description="user's national ID"
),
'role': fields.String(
required=True, description="user's role"
),
'date_joined': fields.String(
required=True, description="Date joined timestamp"
),
'email': fields.String(
required=True, description="user's email"
),
'phone_number': fields.String(
required=True, description="user's last name"
),
'password': fields.String(
required=True, description="user's password"
),
'retype_password': fields.String(
required=True, description="Retype password"
),
'officer_username': fields.String(
required=False, description="Enter officer name"
),
'location': fields.String(
required=False, description="Enter location"
),
'officer_info': fields.String(
required=False, description="Add officer information"
),
'farmer_info': fields.String(
required=False, description="Add farmer information"
),
})
login_user = api.model('Login input data', {
'password': fields.String(
required=True, description="Add your password"
),
'username': fields.String(
required=False, description="Add your username"
),
'email': fields.String(
required=False, description="Add you email"
)
})
| 33.4375 | 70 | 0.574299 | 200 | 2,140 | 6.085 | 0.275 | 0.157765 | 0.262942 | 0.197206 | 0.589975 | 0.509449 | 0.287592 | 0.118324 | 0.078883 | 0 | 0 | 0 | 0.309813 | 2,140 | 63 | 71 | 33.968254 | 0.823968 | 0.019159 | 0 | 0.433333 | 0 | 0 | 0.245103 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | false | 0.1 | 0.016667 | 0 | 0.083333 | 0 | 0 | 0 | 0 | null | 0 | 1 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 0 | 0 | 0 | 3 |
0cd6ed4cd564901c9d6e6419361c7b61b1d56dfb | 120 | py | Python | CF_Functions/Arcade/WordPower.py | glickmac/Misc_Scripts | 7e18be79b84a309a1e79935f4470ea915141938d | [
"MIT"
] | null | null | null | CF_Functions/Arcade/WordPower.py | glickmac/Misc_Scripts | 7e18be79b84a309a1e79935f4470ea915141938d | [
"MIT"
] | null | null | null | CF_Functions/Arcade/WordPower.py | glickmac/Misc_Scripts | 7e18be79b84a309a1e79935f4470ea915141938d | [
"MIT"
] | 1 | 2020-07-30T17:37:12.000Z | 2020-07-30T17:37:12.000Z | def wordPower(word):
num = dict(zip(string.ascii_lowercase, range(1,27)))
return sum([num[ch] for ch in word])
| 24 | 56 | 0.666667 | 20 | 120 | 3.95 | 0.85 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0.030303 | 0.175 | 120 | 4 | 57 | 30 | 0.767677 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0.333333 | false | 0 | 0 | 0 | 0.666667 | 0 | 1 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 3 |
0cfc5802ff58618fd079fd5185d9edd8be7eda97 | 13,342 | py | Python | source/rttov_test/profile-datasets-py/div83/027.py | bucricket/projectMAScorrection | 89489026c8e247ec7c364e537798e766331fe569 | [
"BSD-3-Clause"
] | null | null | null | source/rttov_test/profile-datasets-py/div83/027.py | bucricket/projectMAScorrection | 89489026c8e247ec7c364e537798e766331fe569 | [
"BSD-3-Clause"
] | 1 | 2022-03-12T12:19:59.000Z | 2022-03-12T12:19:59.000Z | source/rttov_test/profile-datasets-py/div83/027.py | bucricket/projectMAScorrection | 89489026c8e247ec7c364e537798e766331fe569 | [
"BSD-3-Clause"
] | null | null | null | """
Profile ../profile-datasets-py/div83/027.py
file automaticaly created by prof_gen.py script
"""
self["ID"] = "../profile-datasets-py/div83/027.py"
self["Q"] = numpy.array([ 1.51831800e+00, 2.02599600e+00, 2.94787100e+00,
3.99669400e+00, 4.71653800e+00, 4.89106600e+00,
5.14399400e+00, 5.67274800e+00, 6.02338400e+00,
6.09836300e+00, 6.08376300e+00, 6.01126400e+00,
5.91866500e+00, 5.77584700e+00, 5.59481900e+00,
5.41637100e+00, 5.26750200e+00, 5.10689400e+00,
4.98576500e+00, 4.90039600e+00, 4.80689700e+00,
4.63989800e+00, 4.46443000e+00, 4.30135100e+00,
4.16606300e+00, 4.06766300e+00, 4.01361400e+00,
3.95640400e+00, 3.87825500e+00, 3.79394600e+00,
3.73623600e+00, 3.72919600e+00, 3.74067600e+00,
3.78187600e+00, 3.81900500e+00, 3.85233500e+00,
3.88512500e+00, 3.91148500e+00, 3.92466500e+00,
3.92849500e+00, 3.93905400e+00, 3.97355400e+00,
4.02951400e+00, 4.05710400e+00, 4.04558400e+00,
4.02228400e+00, 4.01040400e+00, 4.00572400e+00,
4.00641400e+00, 4.08608300e+00, 4.44130000e+00,
5.00126500e+00, 5.73600700e+00, 6.83860300e+00,
8.34002000e+00, 9.95999100e+00, 1.13537700e+01,
1.24435500e+01, 1.36048100e+01, 1.55239600e+01,
1.77784800e+01, 1.93991200e+01, 2.00516000e+01,
1.97941100e+01, 1.89638400e+01, 1.84148600e+01,
1.82331700e+01, 1.84861600e+01, 2.02668900e+01,
3.24805400e+01, 6.31028200e+01, 1.09865900e+02,
1.71694500e+02, 2.41407700e+02, 3.05073900e+02,
3.60772800e+02, 4.04902000e+02, 4.16543400e+02,
4.04623200e+02, 3.59892400e+02, 3.06567000e+02,
3.03443900e+02, 4.25764600e+02, 8.75110500e+02,
1.60701300e+03, 2.52645100e+03, 3.50894400e+03,
4.39830900e+03, 5.05090900e+03, 5.40195000e+03,
5.54486300e+03, 5.86218200e+03, 6.10752900e+03,
6.83105600e+03, 6.63557500e+03, 6.44820100e+03,
6.26853800e+03, 6.09616900e+03, 5.93072700e+03,
5.77187200e+03, 5.61926500e+03])
self["P"] = numpy.array([ 5.00000000e-03, 1.61000000e-02, 3.84000000e-02,
7.69000000e-02, 1.37000000e-01, 2.24400000e-01,
3.45400000e-01, 5.06400000e-01, 7.14000000e-01,
9.75300000e-01, 1.29720000e+00, 1.68720000e+00,
2.15260000e+00, 2.70090000e+00, 3.33980000e+00,
4.07700000e+00, 4.92040000e+00, 5.87760000e+00,
6.95670000e+00, 8.16550000e+00, 9.51190000e+00,
1.10038000e+01, 1.26492000e+01, 1.44559000e+01,
1.64318000e+01, 1.85847000e+01, 2.09224000e+01,
2.34526000e+01, 2.61829000e+01, 2.91210000e+01,
3.22744000e+01, 3.56505000e+01, 3.92566000e+01,
4.31001000e+01, 4.71882000e+01, 5.15278000e+01,
5.61260000e+01, 6.09895000e+01, 6.61253000e+01,
7.15398000e+01, 7.72396000e+01, 8.32310000e+01,
8.95204000e+01, 9.61138000e+01, 1.03017000e+02,
1.10237000e+02, 1.17778000e+02, 1.25646000e+02,
1.33846000e+02, 1.42385000e+02, 1.51266000e+02,
1.60496000e+02, 1.70078000e+02, 1.80018000e+02,
1.90320000e+02, 2.00989000e+02, 2.12028000e+02,
2.23442000e+02, 2.35234000e+02, 2.47408000e+02,
2.59969000e+02, 2.72919000e+02, 2.86262000e+02,
3.00000000e+02, 3.14137000e+02, 3.28675000e+02,
3.43618000e+02, 3.58966000e+02, 3.74724000e+02,
3.90893000e+02, 4.07474000e+02, 4.24470000e+02,
4.41882000e+02, 4.59712000e+02, 4.77961000e+02,
4.96630000e+02, 5.15720000e+02, 5.35232000e+02,
5.55167000e+02, 5.75525000e+02, 5.96306000e+02,
6.17511000e+02, 6.39140000e+02, 6.61192000e+02,
6.83667000e+02, 7.06565000e+02, 7.29886000e+02,
7.53628000e+02, 7.77790000e+02, 8.02371000e+02,
8.27371000e+02, 8.52788000e+02, 8.78620000e+02,
9.04866000e+02, 9.31524000e+02, 9.58591000e+02,
9.86067000e+02, 1.01395000e+03, 1.04223000e+03,
1.07092000e+03, 1.10000000e+03])
self["CO2"] = numpy.array([ 375.9234, 375.9232, 375.9219, 375.9195, 375.9172, 375.9142,
375.9041, 375.8819, 375.8607, 375.8617, 375.8997, 375.9717,
376.0398, 376.0858, 376.1489, 376.212 , 376.224 , 376.2321,
376.2481, 376.2772, 376.3252, 376.3663, 376.4023, 376.4224,
376.4504, 376.4865, 376.5545, 376.6335, 376.7605, 376.8966,
377.0446, 377.2036, 377.3766, 377.5606, 377.7106, 377.8485,
378.0765, 378.4945, 378.9365, 379.6475, 380.4225, 381.0245,
381.4085, 381.8025, 381.8315, 381.8625, 381.8985, 381.9405,
381.9845, 382.0364, 382.0903, 382.5651, 383.1618, 383.8894,
384.7668, 385.5962, 386.1156, 386.6532, 386.7607, 386.854 ,
386.8701, 386.8645, 386.8732, 386.8913, 386.9157, 386.9449,
386.9669, 386.9788, 386.9602, 386.9034, 386.8186, 386.7075,
386.6086, 386.5187, 386.4681, 386.4315, 386.4595, 386.5189,
386.6375, 386.8447, 387.1073, 387.3124, 387.433 , 387.3937,
387.2297, 386.9659, 386.6525, 386.3522, 386.1188, 385.9826,
385.9361, 385.8209, 385.7317, 385.4548, 385.5337, 385.6074,
385.6771, 385.744 , 385.8082, 385.8699, 385.9291])
self["CO"] = numpy.array([ 0.2205447 , 0.2185316 , 0.2145434 , 0.2078282 , 0.1977631 ,
0.1839901 , 0.1511932 , 0.09891954, 0.0827345 , 0.05454007,
0.02926452, 0.01534331, 0.01021024, 0.00922827, 0.00895567,
0.00841368, 0.00791632, 0.0076217 , 0.00749041, 0.00745301,
0.00740799, 0.00741502, 0.00746624, 0.00760092, 0.00775626,
0.00793258, 0.0081303 , 0.00834271, 0.00844155, 0.00854593,
0.00861921, 0.00869836, 0.00895125, 0.009236 , 0.00956421,
0.00993273, 0.01050776, 0.01155325, 0.01277055, 0.01483604,
0.01745463, 0.02009092, 0.02248201, 0.0252159 , 0.0250677 ,
0.0249136 , 0.0248554 , 0.0248671 , 0.0248747 , 0.0248604 ,
0.02484549, 0.02830606, 0.03349511, 0.03954063, 0.04649641,
0.05393566, 0.05777834, 0.06203953, 0.06291754, 0.06367061,
0.06376177, 0.06365417, 0.06355173, 0.06345124, 0.063449 ,
0.06353453, 0.06376724, 0.06416551, 0.06445159, 0.0646028 ,
0.06451203, 0.06417925, 0.06369376, 0.06310236, 0.06261609,
0.06216137, 0.06196 , 0.06180874, 0.06178709, 0.06208905,
0.06263239, 0.06350083, 0.06423774, 0.06476787, 0.06481747,
0.06471838, 0.06458966, 0.06447546, 0.06438733, 0.06432344,
0.06428367, 0.06423741, 0.0641983 , 0.06589368, 0.07015209,
0.07475692, 0.0797395 , 0.08513432, 0.09097941, 0.09731644,
0.1041912 ])
self["T"] = numpy.array([ 189.265, 197.336, 211.688, 227.871, 242.446, 252.765,
259.432, 262.908, 263.411, 262.202, 261.422, 259.368,
255.095, 250.075, 244.792, 239.205, 235.817, 231.46 ,
227.966, 225.935, 225.115, 222.382, 219.723, 218.152,
217.875, 218.211, 218.288, 218.294, 217.949, 217.202,
216.158, 214.964, 215.259, 215.053, 215.409, 216.081,
216.441, 216.152, 215.427, 215.082, 216.198, 217.247,
217.006, 216.373, 216.342, 217.088, 218.419, 219.839,
220.797, 220.946, 221.423, 222.504, 223.822, 225.134,
226.221, 226.93 , 227.275, 227.405, 227.434, 227.346,
227.212, 227.246, 227.566, 228.2 , 229.083, 230.094,
231.117, 232.121, 233.086, 234.01 , 235.064, 236.351,
237.928, 239.892, 242.039, 244.306, 246.651, 249.025,
251.415, 253.802, 256.16 , 258.448, 260.591, 262.445,
264.071, 265.349, 266.233, 266.969, 267.78 , 268.72 ,
269.42 , 270.502, 271.421, 273.317, 273.317, 273.317,
273.317, 273.317, 273.317, 273.317, 273.317])
self["N2O"] = numpy.array([ 0.00161 , 0.00187 , 0.00205999, 0.00220999, 0.00233999,
0.00235999, 0.00157999, 0.00186999, 0.00519997, 0.00870995,
0.00838995, 0.00955994, 0.01208993, 0.01432992, 0.0171399 ,
0.02172988, 0.02788985, 0.03756981, 0.04630977, 0.05168975,
0.05680973, 0.05922973, 0.06028973, 0.06131974, 0.07010971,
0.07957968, 0.08867964, 0.09929961, 0.1101496 , 0.1206295 ,
0.1301795 , 0.1371795 , 0.1439595 , 0.1505294 , 0.1651494 ,
0.1848693 , 0.2034792 , 0.2285391 , 0.252299 , 0.2748389 ,
0.2840589 , 0.2926288 , 0.3004188 , 0.3072488 , 0.3129187 ,
0.3172487 , 0.3200187 , 0.3209987 , 0.3209987 , 0.3209987 ,
0.3209986 , 0.3209984 , 0.3209982 , 0.3209978 , 0.3209973 ,
0.3209968 , 0.3209964 , 0.320996 , 0.3209956 , 0.320995 ,
0.3209943 , 0.3209938 , 0.3209936 , 0.3209936 , 0.3209939 ,
0.3209941 , 0.3209941 , 0.3209941 , 0.3209935 , 0.3209896 ,
0.3209797 , 0.3209647 , 0.3209449 , 0.3209225 , 0.3209021 ,
0.3208842 , 0.32087 , 0.3208663 , 0.3208701 , 0.3208845 ,
0.3209016 , 0.3209026 , 0.3208633 , 0.3207191 , 0.3204841 ,
0.320189 , 0.3198736 , 0.3195881 , 0.3193787 , 0.319266 ,
0.3192201 , 0.3191182 , 0.3190395 , 0.3188072 , 0.31887 ,
0.3189301 , 0.3189878 , 0.3190431 , 0.3190962 , 0.3191472 ,
0.3191962 ])
self["O3"] = numpy.array([ 0.1903137 , 0.2192386 , 0.3077081 , 0.5440408 , 0.8590299 ,
1.170854 , 1.499102 , 1.864289 , 2.273556 , 2.805293 ,
3.409769 , 4.028786 , 4.806182 , 5.619898 , 6.411164 ,
7.147361 , 7.51202 , 7.648961 , 7.644362 , 7.556123 ,
7.446574 , 7.281136 , 6.952659 , 6.604492 , 6.296854 ,
6.008776 , 5.751387 , 5.520268 , 5.311749 , 5.111921 ,
4.890092 , 4.593293 , 4.298724 , 3.882905 , 3.380027 ,
2.799559 , 2.288161 , 2.031152 , 2.018272 , 2.047542 ,
1.969722 , 1.685453 , 1.220825 , 0.9176053 , 0.8929574 ,
0.9542592 , 1.004996 , 1.034796 , 1.031726 , 1.019046 ,
0.8797071 , 0.6484178 , 0.4105526 , 0.2529783 , 0.1943934 ,
0.201197 , 0.2459162 , 0.322179 , 0.3977806 , 0.4292413 ,
0.4255834 , 0.3930204 , 0.3461121 , 0.2989281 , 0.2606191 ,
0.2321107 , 0.2069452 , 0.1838146 , 0.1618567 , 0.1410414 ,
0.1225313 , 0.1061913 , 0.09214328, 0.08133816, 0.07293074,
0.06636085, 0.06143102, 0.05859298, 0.05740586, 0.05732126,
0.05783027, 0.05809797, 0.05651443, 0.05019414, 0.0404447 ,
0.03280082, 0.02944741, 0.02902179, 0.02945348, 0.02918976,
0.02836743, 0.02750451, 0.02608958, 0.02225294, 0.02225732,
0.02226152, 0.02226555, 0.02226941, 0.02227312, 0.02227668,
0.02228009])
self["CH4"] = numpy.array([ 0.1059488, 0.1201298, 0.1306706, 0.1417254, 0.1691352,
0.209023 , 0.2345078, 0.2578465, 0.2845033, 0.328699 ,
0.3987896, 0.4800421, 0.5668716, 0.6510682, 0.7280449,
0.7954147, 0.8518465, 0.8903115, 0.9281374, 0.9731752,
1.016085 , 1.071595 , 1.131985 , 1.189835 , 1.247015 ,
1.302185 , 1.355285 , 1.400504 , 1.442154 , 1.464494 ,
1.488464 , 1.514124 , 1.541544 , 1.560774 , 1.579304 ,
1.596804 , 1.612894 , 1.627174 , 1.638294 , 1.650024 ,
1.662373 , 1.675353 , 1.688973 , 1.722213 , 1.729283 ,
1.736683 , 1.741733 , 1.745103 , 1.749093 , 1.755483 ,
1.762122 , 1.770021 , 1.77847 , 1.785498 , 1.790785 ,
1.795642 , 1.79793 , 1.800308 , 1.800506 , 1.800632 ,
1.800498 , 1.800295 , 1.800414 , 1.800704 , 1.800856 ,
1.800867 , 1.800517 , 1.799787 , 1.798434 , 1.796372 ,
1.794017 , 1.791393 , 1.789133 , 1.787118 , 1.785875 ,
1.784886 , 1.784827 , 1.785476 , 1.788046 , 1.791395 ,
1.795229 , 1.798224 , 1.800263 , 1.801052 , 1.800931 ,
1.80036 , 1.799234 , 1.797877 , 1.796739 , 1.796035 ,
1.795827 , 1.795294 , 1.79488 , 1.793604 , 1.793966 ,
1.794315 , 1.794639 , 1.794951 , 1.795249 , 1.795536 ,
1.795812 ])
self["CTP"] = 500.0
self["CFRACTION"] = 0.0
self["IDG"] = 0
self["ISH"] = 0
self["ELEVATION"] = 0.0
self["S2M"]["T"] = 273.317
self["S2M"]["Q"] = 5619.26541873
self["S2M"]["O"] = 0.022280094739
self["S2M"]["P"] = 905.85559
self["S2M"]["U"] = 0.0
self["S2M"]["V"] = 0.0
self["S2M"]["WFETC"] = 100000.0
self["SKIN"]["SURFTYPE"] = 0
self["SKIN"]["WATERTYPE"] = 1
self["SKIN"]["T"] = 273.317
self["SKIN"]["SALINITY"] = 35.0
self["SKIN"]["FOAM_FRACTION"] = 0.0
self["SKIN"]["FASTEM"] = numpy.array([ 3. , 5. , 15. , 0.1, 0.3])
self["ZENANGLE"] = 0.0
self["AZANGLE"] = 0.0
self["SUNZENANGLE"] = 0.0
self["SUNAZANGLE"] = 0.0
self["LATITUDE"] = 45.309
self["GAS_UNITS"] = 2
self["BE"] = 0.0
self["COSBK"] = 0.0
self["DATE"] = numpy.array([2007, 4, 1])
self["TIME"] = numpy.array([0, 0, 0])
| 57.508621 | 92 | 0.570979 | 2,008 | 13,342 | 3.792331 | 0.461155 | 0.008667 | 0.008667 | 0.011031 | 0.019961 | 0.013395 | 0.006303 | 0.006303 | 0.006303 | 0.006303 | 0 | 0.701882 | 0.267126 | 13,342 | 231 | 93 | 57.757576 | 0.076907 | 0.00712 | 0 | 0 | 0 | 0 | 0.018819 | 0.002645 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | true | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 3 |
0cfe0c2510332685f3cc3783752192ba32a124ab | 329 | py | Python | PythonExercicios/ex020.py | github-felipe/ExerciciosEmPython-cursoemvideo | 0045464a287f21b6245554a975588cf06c5b476d | [
"MIT"
] | null | null | null | PythonExercicios/ex020.py | github-felipe/ExerciciosEmPython-cursoemvideo | 0045464a287f21b6245554a975588cf06c5b476d | [
"MIT"
] | null | null | null | PythonExercicios/ex020.py | github-felipe/ExerciciosEmPython-cursoemvideo | 0045464a287f21b6245554a975588cf06c5b476d | [
"MIT"
] | null | null | null | from random import shuffle
a1 = str(input('Digite o nome de um aluno: '))
a2 = str(input('Digite o nome de outro aluno: '))
a3 = str(input('Digite o nome de mais outro aluno: '))
a4 = str(input('Digite o nome do último aluno: '))
lista = [a1, a2, a3, a4]
shuffle(lista)
print(f'A ordem de apresentação é: \033[34m{lista}\033[m')
| 36.555556 | 58 | 0.680851 | 60 | 329 | 3.733333 | 0.5 | 0.142857 | 0.25 | 0.267857 | 0.366071 | 0.28125 | 0 | 0 | 0 | 0 | 0 | 0.058182 | 0.164134 | 329 | 8 | 59 | 41.125 | 0.756364 | 0 | 0 | 0 | 0 | 0 | 0.519757 | 0.06383 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | false | 0 | 0.125 | 0 | 0.125 | 0.125 | 0 | 0 | 0 | null | 0 | 1 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 3 |
0b3f444aab07f3ace7008a9a2f44f279835a4a8e | 25,437 | py | Python | analyses/seasonality_paper_st/lai_only/shap_interaction/model_analysis_shap_interaction_1.py | akuhnregnier/wildfire-analysis | a04deada145cec864051d2fb15aec1a53a0246b9 | [
"MIT"
] | null | null | null | analyses/seasonality_paper_st/lai_only/shap_interaction/model_analysis_shap_interaction_1.py | akuhnregnier/wildfire-analysis | a04deada145cec864051d2fb15aec1a53a0246b9 | [
"MIT"
] | null | null | null | analyses/seasonality_paper_st/lai_only/shap_interaction/model_analysis_shap_interaction_1.py | akuhnregnier/wildfire-analysis | a04deada145cec864051d2fb15aec1a53a0246b9 | [
"MIT"
] | null | null | null | #!/usr/bin/env python3
# -*- coding: utf-8 -*-
import os
from pathlib import Path
from wildfires.utils import handle_array_job_args
try:
# This will only work after the path modification carried out in the job script.
from specific import (
CACHE_DIR,
SimpleCache,
get_model,
data_split_cache,
get_shap_values,
)
except ImportError:
"""Not running as an HPC job yet."""
def func():
# Used to re-compute specific failed jobs, `None` otherwise.
indices = [
0,
1,
2,
3,
4,
7,
8,
9,
15,
61,
62,
63,
64,
65,
66,
68,
69,
73,
75,
76,
77,
78,
79,
80,
81,
82,
83,
92,
93,
102,
103,
119,
120,
121,
122,
123,
128,
129,
130,
132,
169,
170,
171,
172,
174,
175,
176,
177,
178,
179,
180,
181,
182,
183,
184,
185,
188,
189,
200,
201,
208,
209,
229,
230,
231,
232,
233,
235,
236,
237,
242,
260,
261,
275,
276,
277,
278,
280,
281,
283,
284,
285,
286,
287,
288,
289,
290,
291,
292,
302,
303,
333,
334,
335,
336,
337,
345,
346,
347,
349,
366,
367,
382,
383,
384,
385,
390,
391,
397,
401,
402,
403,
404,
405,
406,
407,
408,
409,
419,
420,
446,
447,
448,
449,
450,
456,
457,
458,
465,
479,
480,
488,
489,
490,
491,
492,
493,
499,
500,
501,
502,
503,
505,
506,
507,
508,
509,
520,
521,
532,
533,
548,
549,
550,
551,
552,
553,
554,
555,
556,
561,
562,
563,
564,
579,
580,
595,
596,
601,
602,
603,
604,
606,
608,
620,
621,
646,
647,
648,
649,
651,
652,
653,
654,
655,
664,
665,
666,
667,
680,
681,
698,
699,
704,
705,
706,
707,
708,
709,
717,
718,
735,
736,
737,
738,
739,
740,
741,
742,
743,
751,
752,
753,
754,
768,
769,
801,
802,
808,
809,
810,
811,
814,
815,
823,
824,
856,
857,
858,
859,
860,
861,
862,
863,
864,
868,
869,
870,
871,
892,
893,
936,
937,
946,
947,
948,
949,
950,
951,
966,
967,
977,
978,
1001,
1002,
1003,
1004,
1005,
1006,
1008,
1009,
1010,
1013,
1014,
1015,
1016,
1049,
1050,
1054,
1055,
1056,
1057,
1058,
1059,
1064,
1065,
1073,
1074,
1086,
1087,
1088,
1089,
1090,
1091,
1094,
1095,
1096,
1100,
1101,
1102,
1104,
1126,
1128,
1129,
1130,
1131,
1132,
1133,
1139,
1140,
1147,
1148,
1163,
1164,
1165,
1166,
1167,
1168,
1170,
1171,
1172,
1173,
1174,
1201,
1202,
1203,
1204,
1205,
1206,
1207,
1217,
1218,
1230,
1231,
1241,
1242,
1243,
1244,
1245,
1246,
1247,
1248,
1249,
1250,
1251,
1252,
1267,
1268,
1275,
1276,
1277,
1281,
1282,
1283,
1284,
1286,
1287,
1294,
1295,
1306,
1307,
1308,
1309,
1310,
1311,
1312,
1313,
1314,
1324,
1325,
1332,
1333,
1334,
1335,
1336,
1337,
1338,
1339,
1340,
1345,
1346,
1360,
1361,
1362,
1363,
1366,
1367,
1368,
1369,
1370,
1380,
1381,
1393,
1394,
1395,
1398,
1403,
1404,
1405,
1406,
1407,
1408,
1411,
1412,
1426,
1427,
1428,
1429,
1430,
1438,
1439,
1449,
1450,
1451,
1452,
1454,
1455,
1456,
1457,
1458,
1459,
1462,
1463,
1471,
1472,
1473,
1474,
1475,
1485,
1486,
1494,
1496,
1497,
1498,
1503,
1504,
1505,
1506,
1507,
1508,
1514,
1515,
1521,
1522,
1529,
1530,
1531,
1536,
1537,
1538,
1540,
1541,
1562,
1564,
1565,
1566,
1572,
1574,
1575,
1576,
1577,
1578,
1579,
1584,
1585,
1591,
1592,
1604,
1605,
1606,
1616,
1617,
1618,
1619,
1620,
1643,
1644,
1645,
1646,
1658,
1659,
1660,
1661,
1662,
1663,
1664,
1672,
1673,
1677,
1678,
1689,
1690,
1691,
1706,
1707,
1708,
1709,
1710,
1737,
1740,
1741,
1742,
1750,
1751,
1752,
1753,
1754,
1755,
1756,
1764,
1765,
1769,
1770,
1776,
1781,
1782,
1791,
1792,
1793,
1794,
1795,
1826,
1827,
1828,
1829,
1836,
1837,
1838,
1839,
1840,
1843,
1844,
1851,
1852,
1855,
1856,
1862,
1863,
1864,
1876,
1877,
1878,
1879,
1880,
1901,
1903,
1904,
1905,
1914,
1915,
1916,
1917,
1918,
1919,
1920,
1927,
1928,
1939,
1940,
1957,
1958,
1959,
1962,
1964,
1965,
1966,
1971,
1972,
1973,
1974,
1975,
1976,
1977,
1981,
1982,
2004,
2005,
2027,
2028,
2051,
2053,
2054,
2056,
2059,
2060,
2061,
2073,
2074,
2075,
2076,
2077,
2078,
2079,
2095,
2096,
2102,
2103,
2131,
2132,
2133,
2134,
2185,
2187,
2188,
2189,
2192,
2193,
2194,
2201,
2202,
2203,
2204,
2205,
2206,
2207,
2222,
2225,
2226,
2235,
2236,
2255,
2256,
2257,
2258,
2313,
2316,
2317,
2320,
2323,
2324,
2326,
2336,
2337,
2338,
2339,
2340,
2341,
2342,
2345,
2350,
2351,
2364,
2365,
2387,
2388,
2389,
2390,
2433,
2435,
2436,
2437,
2439,
2440,
2443,
2449,
2450,
2451,
2452,
2453,
2454,
2455,
2461,
2465,
2466,
2470,
2471,
2487,
2488,
2489,
2490,
2533,
2536,
2537,
2538,
2540,
2541,
2542,
2546,
2547,
2548,
2549,
2550,
2551,
2552,
2563,
2566,
2567,
2572,
2573,
2588,
2589,
2590,
2591,
2640,
2641,
2642,
2643,
2644,
2646,
2647,
2648,
2657,
2658,
2659,
2660,
2661,
2662,
2663,
2671,
2674,
2675,
2681,
2682,
2704,
2705,
2706,
2707,
2750,
2752,
2753,
2754,
2755,
2756,
2757,
2758,
2762,
2763,
2764,
2765,
2766,
2767,
2768,
2773,
2778,
2779,
2791,
2792,
2817,
2818,
2819,
2820,
2842,
2845,
2846,
2847,
2848,
2849,
2850,
2851,
2854,
2855,
2856,
2858,
2859,
2860,
2863,
2869,
2870,
2882,
2883,
2895,
2896,
2897,
2898,
2899,
2903,
2920,
2924,
2925,
2926,
2927,
2928,
2929,
2930,
2933,
2934,
2935,
2936,
2937,
2940,
2944,
2945,
2948,
2949,
2959,
2960,
2973,
2974,
2975,
2976,
2977,
2980,
3013,
3016,
3017,
3018,
3019,
3020,
3021,
3022,
3024,
3027,
3028,
3029,
3032,
3034,
3038,
3046,
3047,
3052,
3053,
3057,
3058,
3074,
3075,
3076,
3077,
3078,
3089,
3123,
3125,
3126,
3127,
3128,
3129,
3130,
3131,
3132,
3138,
3139,
3140,
3141,
3142,
3144,
3145,
3146,
3150,
3151,
3159,
3160,
3179,
3180,
3181,
3182,
3183,
3190,
3230,
3232,
3233,
3234,
3235,
3236,
3237,
3238,
3239,
3240,
3245,
3246,
3247,
3248,
3249,
3250,
3254,
3255,
3258,
3259,
3266,
3267,
3300,
3301,
3302,
3303,
3304,
3305,
3309,
3331,
3332,
3333,
3334,
3335,
3337,
3338,
3340,
3341,
3343,
3345,
3346,
3347,
3348,
3349,
3350,
3357,
3358,
3361,
3362,
3370,
3371,
3400,
3401,
3402,
3403,
3404,
3405,
3415,
3456,
3458,
3459,
3460,
3461,
3463,
3464,
3466,
3467,
3468,
3472,
3473,
3474,
3475,
3476,
3477,
3479,
3480,
3482,
3483,
3488,
3489,
3506,
3508,
3509,
3510,
3511,
3512,
3513,
3524,
3556,
3557,
3558,
3559,
3560,
3563,
3564,
3565,
3566,
3567,
3571,
3572,
3573,
3575,
3576,
3578,
3588,
3589,
3592,
3593,
3599,
3600,
3622,
3624,
3625,
3626,
3627,
3628,
3629,
3646,
3676,
3677,
3678,
3679,
3680,
3681,
3682,
3683,
3685,
3686,
3687,
3692,
3693,
3694,
3695,
3696,
3698,
3701,
3708,
3709,
3714,
3715,
3718,
3719,
3740,
3741,
3743,
3745,
3746,
3747,
3748,
3749,
3759,
3791,
3792,
3793,
3794,
3795,
3796,
3798,
3799,
3800,
3801,
3802,
3811,
3812,
3813,
3814,
3815,
3816,
3818,
3826,
3827,
3829,
3830,
3839,
3840,
3856,
3857,
3858,
3859,
3860,
3861,
3872,
3904,
3905,
3907,
3908,
3909,
3910,
3911,
3912,
3913,
3914,
3915,
3916,
3922,
3923,
3924,
3925,
3926,
3927,
3929,
3933,
3934,
3935,
3940,
3941,
3946,
3947,
3969,
3970,
3971,
3972,
3973,
3974,
3975,
3985,
4017,
4020,
4021,
4022,
4023,
4024,
4025,
4026,
4027,
4028,
4029,
4034,
4035,
4036,
4037,
4038,
4039,
4042,
4050,
4051,
4052,
4053,
4054,
4058,
4059,
4069,
4071,
4072,
4073,
4074,
4075,
4076,
4082,
4100,
4102,
4103,
4104,
4105,
4106,
4108,
4109,
4112,
4113,
4114,
4115,
4116,
4117,
4118,
4119,
4120,
4121,
4122,
4127,
4128,
4129,
4130,
4131,
4144,
4145,
4158,
4160,
4161,
4162,
4163,
4164,
4165,
4166,
4172,
4175,
4177,
4178,
4201,
4202,
4203,
4204,
4205,
4206,
4207,
4208,
4210,
4211,
4212,
4213,
4214,
4223,
4224,
4225,
4226,
4227,
4228,
4229,
4234,
4235,
4236,
4237,
4238,
4248,
4261,
4263,
4264,
4265,
4266,
4267,
4268,
4269,
4270,
4285,
4288,
4292,
4298,
4299,
4318,
4322,
4323,
4324,
4325,
4326,
4329,
4330,
4333,
4334,
4336,
4338,
4339,
4340,
4341,
4342,
4345,
4350,
4351,
4352,
4353,
4354,
4366,
4367,
4380,
4382,
4387,
4388,
4389,
4390,
4391,
4392,
4393,
4399,
4403,
4411,
4415,
4416,
4426,
4427,
4444,
4445,
4446,
4447,
4448,
4449,
4450,
4451,
4452,
4453,
4457,
4458,
4459,
4460,
4462,
4464,
4466,
4467,
4475,
4476,
4477,
4478,
4479,
4498,
4499,
4507,
4509,
4510,
4511,
4512,
4513,
4514,
4515,
4524,
4525,
4526,
4533,
4539,
4540,
4549,
4550,
4563,
4566,
4568,
4569,
4570,
4571,
4573,
4574,
4575,
4576,
4578,
4582,
4583,
4584,
4585,
4586,
4587,
4588,
4596,
4597,
4598,
4599,
4600,
4601,
4609,
4610,
4624,
4626,
4627,
4628,
4629,
4630,
4631,
4632,
4638,
4646,
4652,
4653,
4659,
4660,
4669,
4672,
4673,
4674,
4675,
4677,
4678,
4681,
4682,
4683,
4687,
4688,
4689,
4690,
4691,
4692,
4693,
4702,
4703,
4704,
4705,
4706,
4707,
4708,
4723,
4724,
4737,
4739,
4740,
4741,
4742,
4743,
4744,
4745,
4746,
4759,
4768,
4772,
4773,
4779,
4795,
4801,
4802,
4803,
4804,
4806,
4807,
4809,
4810,
4812,
4820,
4821,
4822,
4823,
4825,
4826,
4828,
4829,
4838,
4839,
4840,
4841,
4842,
4843,
4844,
4845,
4858,
4859,
4890,
4891,
4892,
4894,
4895,
4896,
4897,
4898,
4899,
4900,
4911,
4912,
4913,
4915,
4921,
4924,
4925,
4935,
4936,
4957,
4959,
4960,
4961,
4962,
4964,
4965,
4966,
4967,
4969,
4970,
4973,
4977,
4978,
4979,
4980,
4981,
4982,
4990,
4991,
4992,
4993,
4994,
4996,
4997,
4998,
5025,
5028,
5031,
5032,
5033,
5034,
5035,
5036,
5037,
5045,
5046,
5047,
5049,
5054,
5055,
5059,
5060,
5071,
5072,
5105,
5107,
5108,
5109,
5110,
5116,
5118,
5119,
5120,
5122,
5123,
5124,
5126,
5127,
5128,
5137,
5138,
5139,
5140,
5141,
5142,
5143,
5144,
5174,
5176,
5178,
5179,
5180,
5181,
5182,
5183,
5184,
5188,
5189,
5195,
5200,
5201,
5202,
5205,
5206,
5207,
5208,
5213,
5214,
5232,
5233,
5234,
5235,
5236,
5237,
5238,
5239,
5240,
5241,
5242,
5245,
5248,
5249,
5250,
5253,
5254,
5256,
5260,
5261,
5262,
5263,
5264,
5266,
5267,
5268,
5289,
5290,
5292,
5293,
5294,
5295,
5296,
5297,
5298,
5299,
5300,
5306,
5308,
5309,
5310,
5319,
5320,
5327,
5328,
5339,
5340,
5352,
5353,
5354,
5355,
5356,
5357,
5358,
5359,
5361,
5366,
5367,
5368,
5369,
5370,
5371,
5376,
5380,
5381,
5382,
5383,
5384,
5385,
5386,
5387,
5418,
5419,
5421,
5422,
5423,
5424,
5425,
5426,
5427,
5430,
5431,
5438,
5439,
5440,
5441,
5448,
5449,
5454,
5455,
5460,
5461,
5482,
5483,
5484,
5485,
5486,
5488,
5489,
5490,
5491,
5499,
5500,
5501,
5502,
5503,
5504,
5511,
5515,
5516,
5517,
5518,
5519,
5520,
5521,
5522,
5538,
5556,
5557,
5559,
5560,
5561,
5562,
5563,
5564,
5565,
5570,
5571,
5577,
5579,
5580,
5582,
5587,
5588,
5592,
5593,
5601,
5627,
5628,
5629,
5630,
5631,
5633,
5634,
5635,
5636,
5639,
5640,
5641,
5643,
5644,
5645,
5652,
5653,
5654,
5655,
5656,
5657,
5658,
5659,
5660,
5672,
5696,
5697,
5698,
5700,
5701,
5702,
5703,
5704,
5705,
5706,
5710,
5711,
5715,
5716,
5717,
5719,
5723,
5724,
5727,
5728,
5738,
5764,
5765,
5766,
5767,
5769,
5770,
5771,
5772,
5782,
5783,
5784,
5786,
5787,
5788,
5794,
5798,
5799,
5800,
5801,
5802,
5803,
5804,
5805,
5815,
5816,
5837,
5838,
5839,
5840,
5842,
5843,
5844,
5845,
5846,
5847,
5848,
5850,
5851,
5855,
5857,
5858,
5860,
5871,
5872,
5874,
5875,
5899,
5900,
5901,
5902,
5905,
5906,
5907,
5908,
5913,
5914,
5915,
5916,
5917,
5918,
5920,
5926,
5927,
5928,
5929,
5930,
5931,
5932,
5933,
5940,
5941,
5963,
5964,
5965,
5966,
5967,
5968,
5969,
5970,
5972,
5973,
5974,
5975,
5976,
5978,
5979,
5982,
5983,
5990,
5994,
5995,
5997,
]
index = int(os.environ["PBS_ARRAY_INDEX"])
if indices is not None:
index = indices[index]
print("Index:", index)
X_train, X_test, y_train, y_test = data_split_cache.load()
rf = get_model()
job_samples = 50
tree_path_dependent_shap_interact_cache = SimpleCache(
f"tree_path_dependent_shap_interact_{index}_{job_samples}",
cache_dir=os.path.join(CACHE_DIR, "shap_interaction"),
)
@tree_path_dependent_shap_interact_cache
def cached_get_interact_shap_values(model, X):
return get_shap_values(model, X, interaction=True)
cached_get_interact_shap_values(
rf, X_train[index * job_samples : (index + 1) * job_samples]
)
if __name__ == "__main__":
handle_array_job_args(
Path(__file__).resolve(),
func,
ncpus=1,
mem="7gb",
walltime="11:00:00",
max_index=1734,
)
| 14.16314 | 84 | 0.298306 | 1,926 | 25,437 | 3.904465 | 0.949637 | 0.005319 | 0.006782 | 0.008378 | 0.02008 | 0.009043 | 0 | 0 | 0 | 0 | 0 | 0.704385 | 0.627904 | 25,437 | 1,795 | 85 | 14.171031 | 0.090122 | 0.007116 | 0 | 0 | 0 | 0 | 0.004402 | 0.002181 | 0 | 0 | 0 | 0 | 0 | 1 | 0.001126 | false | 0 | 0.002815 | 0.000563 | 0.004505 | 0.000563 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 1 | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 3 |
0b4cc6aa957df616a9c14313fa9b9ee7ec6d0837 | 1,434 | py | Python | calculators/static_dipolar_couplings/dcc.py | jlorieau/nmr | 15224342a9277da8b02e10027644c86ac3769db1 | [
"MIT"
] | null | null | null | calculators/static_dipolar_couplings/dcc.py | jlorieau/nmr | 15224342a9277da8b02e10027644c86ac3769db1 | [
"MIT"
] | null | null | null | calculators/static_dipolar_couplings/dcc.py | jlorieau/nmr | 15224342a9277da8b02e10027644c86ac3769db1 | [
"MIT"
] | null | null | null | from math import pi
u0 = 4.*pi*1E-7 # T m /A
hbar = 1.0545718E-34 # J s
# 1 T = kg s^-2 A-1 = J A^-1 m^-2
g = {
'1H' : 267.513E6, # rad T^-1 s^-1
'13C': 67.262E6,
'15N': -27.116E6,
'e': 176086E6
}
# nuc_i, nuc_j: nucleus string. ex: '1H'
# r_ij: distance in Angstroms
DCC = lambda nuc_i, nuc_j, r_ij: -1.*(u0*g[nuc_i]*g[nuc_j]*hbar)/(4.*pi*(r_ij*1E-10)**3)
print('-'*30)
print('1H-15N (1.02A): {:> 8.1f} Hz'.format(DCC('1H','15N', 1.02)/(2.*pi), 'Hz'))
print('1H-15N (1.04A): {:> 8.1f} Hz'.format(DCC('1H','15N', 1.04)/(2.*pi), 'Hz'))
print('-'*30)
print('1H-13C (1.1A): {:> 8.1f} Hz'.format(DCC('1H','13C', 1.1)/(2.*pi), 'Hz'))
print('-'*30)
print('1H-1H (1.00A): {:> 8.1f} Hz'.format(DCC('1H','1H', 1.0)/(2.*pi), 'Hz'))
print('1H-1H (2.4A): {:> 8.1f} Hz'.format(DCC('1H','1H', 2.4)/(2.*pi), 'Hz'))
print('1H-1H (2.8A): {:> 8.1f} Hz'.format(DCC('1H','1H', 2.8)/(2.*pi), 'Hz'))
print('-'*30)
print('13C-13C (1.53A): {:> 8.1f} Hz'.format(DCC('13C','13C', 1.53)/(2.*pi), 'Hz'))
print('-'*30)
print('1H-e (1A): {:> 8.1f} MHz'.format(DCC('1H','e', 1.0)/(1E6*2.*pi), 'Hz'))
print('1H-e (5A): {:> 8.1f} kHz'.format(DCC('1H','e', 5.0)/(1E3*2.*pi), 'Hz'))
print('1H-e (10A): {:> 8.1f} kHz'.format(DCC('1H','e', 10.0)/(1E3*2.*pi), 'Hz'))
print('1H-e (50A): {:> 8.1f} kHz'.format(DCC('1H','e', 50.0)/(1E3*2.*pi), 'Hz'))
print('1H-e (100A): {:> 8.1f} Hz'.format(DCC('1H','e', 100.0)/(2.*pi), 'Hz'))
print('-'*30)
| 34.142857 | 89 | 0.502092 | 299 | 1,434 | 2.377926 | 0.247492 | 0.050633 | 0.084388 | 0.168776 | 0.548523 | 0.492264 | 0.405063 | 0.181435 | 0 | 0 | 0 | 0.177885 | 0.129707 | 1,434 | 41 | 90 | 34.97561 | 0.391827 | 0.085774 | 0 | 0.214286 | 0 | 0 | 0.307515 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | false | 0 | 0.035714 | 0 | 0.035714 | 0.642857 | 0 | 0 | 0 | null | 0 | 0 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 3 |
0b7345be2719bd8b7fdccdbf2d4ec3d3cec346b7 | 314 | py | Python | Lower_Upper_Counter/Lower_Upper_Counter.py | GracjanBuczek/Python | 655801ae58ed7ef21f7da2f69f649c556b20aaee | [
"MIT"
] | null | null | null | Lower_Upper_Counter/Lower_Upper_Counter.py | GracjanBuczek/Python | 655801ae58ed7ef21f7da2f69f649c556b20aaee | [
"MIT"
] | null | null | null | Lower_Upper_Counter/Lower_Upper_Counter.py | GracjanBuczek/Python | 655801ae58ed7ef21f7da2f69f649c556b20aaee | [
"MIT"
] | null | null | null | x = input("Enter sentence: ")
count={"Uppercase":0, "Lowercase":0}
for i in x:
if i.isupper():
count["Uppercase"]+=1
elif i.islower():
count["Lowercase"]+=1
else:
pass
print ("There is:", count["Uppercase"], "uppercases.")
print ("There is:", count["Lowercase"], "lowercases.")
| 26.166667 | 54 | 0.582803 | 39 | 314 | 4.692308 | 0.589744 | 0.229508 | 0.131148 | 0.185792 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0.016064 | 0.207006 | 314 | 11 | 55 | 28.545455 | 0.718876 | 0 | 0 | 0 | 0 | 0 | 0.350318 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | false | 0.090909 | 0 | 0 | 0 | 0.181818 | 0 | 0 | 0 | null | 1 | 0 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 0 | 0 | 0 | 3 |
0b8b1ecbeb3c81d6b86bae93b7d7c89aca388a29 | 893 | py | Python | mapclientplugins/loadcsvstep/utils/processCSV.py | mahyar-osn/mapclientplugins.loadcsvstep | 2d483d4054f4c30247303e8d4eba706b70364158 | [
"Apache-2.0"
] | null | null | null | mapclientplugins/loadcsvstep/utils/processCSV.py | mahyar-osn/mapclientplugins.loadcsvstep | 2d483d4054f4c30247303e8d4eba706b70364158 | [
"Apache-2.0"
] | null | null | null | mapclientplugins/loadcsvstep/utils/processCSV.py | mahyar-osn/mapclientplugins.loadcsvstep | 2d483d4054f4c30247303e8d4eba706b70364158 | [
"Apache-2.0"
] | null | null | null | import pandas as pd
class ProcessCSV:
"""
A general class to read in and process a csv format file using pandas.
"""
def __init__(self, filename, delim=',', header=None, usecols=None, dtype=None, ignore=False, *args):
self._filename = filename
self._args = args
self._df = self._readFile(delim=delim, header=header, usecols=usecols, dtype=dtype, ignore=ignore)
def _readFile(self, delim=',', header=None, usecols=None, dtype=None, ignore=False):
df = pd.read_csv(self._filename, sep=delim, header=header, usecols=usecols, dtype=dtype)
if ignore:
df.dropna(how="all", inplace=True)
return df.fillna(0)
def getCoordinates(self):
return self._df[['map X', 'map Y', 'map Z']]
def getGene(self):
return self._df.iloc[:, 8:]
def getID(self):
return self._df['Sample Name']
| 28.806452 | 106 | 0.631579 | 120 | 893 | 4.583333 | 0.433333 | 0.08 | 0.076364 | 0.087273 | 0.316364 | 0.316364 | 0.316364 | 0.167273 | 0.167273 | 0 | 0 | 0.002924 | 0.234043 | 893 | 30 | 107 | 29.766667 | 0.80117 | 0.078387 | 0 | 0 | 0 | 0 | 0.038605 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0.294118 | false | 0 | 0.058824 | 0.176471 | 0.647059 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 0 | 1 | 1 | 0 | 0 | 3 |
0b96aaa21f422ac0c7d22576279c69b61dd42c95 | 154 | py | Python | Test/two/payments/momo/urls.py | titan256/Python-Django-Assignment | 9f56f69ea7182456729116e27435231925d24d11 | [
"MIT"
] | null | null | null | Test/two/payments/momo/urls.py | titan256/Python-Django-Assignment | 9f56f69ea7182456729116e27435231925d24d11 | [
"MIT"
] | 9 | 2020-06-05T23:53:04.000Z | 2022-02-10T08:33:32.000Z | Test/two/payments/momo/urls.py | titan256/Python-Django-Assignment | 9f56f69ea7182456729116e27435231925d24d11 | [
"MIT"
] | null | null | null | from django.contrib import admin
from django.urls import path , include
from . import views
urlpatterns = [
path('',views.index,name='index')
] | 19.25 | 38 | 0.701299 | 20 | 154 | 5.4 | 0.6 | 0.185185 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0.188312 | 154 | 8 | 39 | 19.25 | 0.864 | 0 | 0 | 0 | 0 | 0 | 0.032258 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | false | 0 | 0.5 | 0 | 0.5 | 0 | 1 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 0 | 0 | 3 |
0bb9728183f6cd95e86f2c16d976742c14283f39 | 149 | py | Python | api/urls.py | kirklennon/Clickbait | 9ce97d38b3dce78ce151b285a0cc55ddbb7b58be | [
"MIT"
] | 1 | 2020-08-29T09:31:22.000Z | 2020-08-29T09:31:22.000Z | api/urls.py | kirklennon/Clickbait | 9ce97d38b3dce78ce151b285a0cc55ddbb7b58be | [
"MIT"
] | null | null | null | api/urls.py | kirklennon/Clickbait | 9ce97d38b3dce78ce151b285a0cc55ddbb7b58be | [
"MIT"
] | null | null | null | from django.urls import path
from . import views
urlpatterns = [
path('', views.index, name='index'),
path('json', views.api, name='api'),
] | 21.285714 | 40 | 0.644295 | 20 | 149 | 4.8 | 0.55 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0.174497 | 149 | 7 | 41 | 21.285714 | 0.780488 | 0 | 0 | 0 | 0 | 0 | 0.08 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | false | 0 | 0.333333 | 0 | 0.333333 | 0 | 1 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 0 | 0 | 3 |
0bc0b1a713ee07a7da22300f41d7eef91e9cf3f3 | 1,621 | py | Python | games/migrations/0004_auto_20150726_1430.py | rnelson/library | 5f327c188f2847151dcfc92de0dc4f43f24096bf | [
"MIT"
] | null | null | null | games/migrations/0004_auto_20150726_1430.py | rnelson/library | 5f327c188f2847151dcfc92de0dc4f43f24096bf | [
"MIT"
] | null | null | null | games/migrations/0004_auto_20150726_1430.py | rnelson/library | 5f327c188f2847151dcfc92de0dc4f43f24096bf | [
"MIT"
] | null | null | null | # -*- coding: utf-8 -*-
from __future__ import unicode_literals
from django.db import models, migrations
class Migration(migrations.Migration):
dependencies = [
('games', '0003_auto_20150725_1737'),
]
operations = [
migrations.AlterField(
model_name='game',
name='description',
field=models.TextField(null=True),
),
migrations.AlterField(
model_name='game',
name='max_players',
field=models.IntegerField(null=True),
),
migrations.AlterField(
model_name='game',
name='max_time',
field=models.IntegerField(null=True),
),
migrations.AlterField(
model_name='game',
name='min_players',
field=models.IntegerField(null=True),
),
migrations.AlterField(
model_name='game',
name='min_time',
field=models.IntegerField(null=True),
),
migrations.AlterField(
model_name='game',
name='name',
field=models.CharField(max_length=255),
),
migrations.AlterField(
model_name='game',
name='url',
field=models.URLField(null=True),
),
migrations.AlterField(
model_name='publisher',
name='country',
field=models.CharField(max_length=2, null=True),
),
migrations.AlterField(
model_name='publisher',
name='url',
field=models.URLField(null=True),
),
]
| 27.016667 | 60 | 0.52992 | 141 | 1,621 | 5.929078 | 0.304965 | 0.215311 | 0.269139 | 0.312201 | 0.759569 | 0.690191 | 0.606459 | 0.539474 | 0.419856 | 0.358852 | 0 | 0.019962 | 0.351018 | 1,621 | 59 | 61 | 27.474576 | 0.774715 | 0.012955 | 0 | 0.660377 | 0 | 0 | 0.08761 | 0.014393 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | false | 0 | 0.037736 | 0 | 0.09434 | 0 | 0 | 0 | 0 | null | 1 | 1 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 3 |
f00939c44715cbb46e21a3b0bd4e2b066d1b7f29 | 2,549 | py | Python | extras/pyrepl/console.py | dillionhacker/python222 | 205414c33fba8166167fd8a6a03eda1a68f16316 | [
"Apache-2.0"
] | 1 | 2019-05-27T00:58:46.000Z | 2019-05-27T00:58:46.000Z | extras/pyrepl/console.py | tuankien2601/python222 | 205414c33fba8166167fd8a6a03eda1a68f16316 | [
"Apache-2.0"
] | null | null | null | extras/pyrepl/console.py | tuankien2601/python222 | 205414c33fba8166167fd8a6a03eda1a68f16316 | [
"Apache-2.0"
] | null | null | null | # Copyright 2000-2004 Michael Hudson mwh@python.net
#
# All Rights Reserved
#
#
# Permission to use, copy, modify, and distribute this software and
# its documentation for any purpose is hereby granted without fee,
# provided that the above copyright notice appear in all copies and
# that both that copyright notice and this permission notice appear in
# supporting documentation.
#
# THE AUTHOR MICHAEL HUDSON DISCLAIMS ALL WARRANTIES WITH REGARD TO
# THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
# AND FITNESS, IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL,
# INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER
# RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF
# CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN
# CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
class Event:
"""An Event. `evt' is 'key' or somesuch."""
def __init__(self, evt, data, raw=''):
self.evt = evt
self.data = data
self.raw = raw
def __repr__(self):
return 'Event(%r, %r)'%(self.evt, self.data)
class Console:
"""Attributes:
screen,
height,
width,
"""
def refresh(self, screen, xy):
pass
def prepare(self):
pass
def restore(self):
pass
def move_cursor(self, x, y):
pass
def set_cursor_vis(self, vis):
pass
def getheightwidth(self):
"""Return (height, width) where height and width are the height
and width of the terminal window in characters."""
pass
def get_event(self, block=1):
"""Return an Event instance. Returns None if |block| is false
and there is no event pending, otherwise waits for the
completion of an event."""
pass
def beep(self):
pass
def clear(self):
"""Wipe the screen"""
pass
def finish(self):
"""Move the cursor to the end of the display and otherwise get
ready for end. XXX could be merged with restore? Hmm."""
pass
def flushoutput(self):
"""Flush all output to the screen (assuming there's some
buffering going on somewhere)."""
pass
def forgetinput(self):
"""Forget all pending, but not yet processed input."""
pass
def getpending(self):
"""Return the characters that have been typed but not yet
processed."""
pass
def wait(self):
"""Wait for an event."""
pass
| 27.117021 | 71 | 0.634759 | 339 | 2,549 | 4.737463 | 0.460177 | 0.056663 | 0.020548 | 0.022416 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0.004934 | 0.284425 | 2,549 | 93 | 72 | 27.408602 | 0.875548 | 0.595135 | 0 | 0.388889 | 0 | 0 | 0.014461 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0.444444 | false | 0.388889 | 0 | 0.027778 | 0.527778 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 1 | 0 | 0 | 1 | 0 | 0 | 3 |
f015bf5e2e71b04cd941a3ba7f14c687b44c2b00 | 263 | py | Python | apps/transactions/__init__.py | lsdlab/djshop_toturial | 6d450225cc05e6a1ecd161de2b522e1af0b68cc0 | [
"MIT"
] | null | null | null | apps/transactions/__init__.py | lsdlab/djshop_toturial | 6d450225cc05e6a1ecd161de2b522e1af0b68cc0 | [
"MIT"
] | 6 | 2020-06-07T15:18:58.000Z | 2021-09-22T19:07:33.000Z | apps/transactions/__init__.py | lsdlab/djshop_toturial | 6d450225cc05e6a1ecd161de2b522e1af0b68cc0 | [
"MIT"
] | null | null | null | from django.apps import AppConfig
class TransactionsConfig(AppConfig):
name = 'apps.transactions'
verbose_name = "Transactions"
def ready(self):
import apps.transactions.signals
default_app_config = 'apps.transactions.TransactionsConfig'
| 20.230769 | 59 | 0.752852 | 27 | 263 | 7.222222 | 0.62963 | 0.246154 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0.1673 | 263 | 12 | 60 | 21.916667 | 0.890411 | 0 | 0 | 0 | 0 | 0 | 0.247148 | 0.136882 | 0 | 0 | 0 | 0 | 0 | 1 | 0.142857 | false | 0 | 0.285714 | 0 | 0.857143 | 0 | 1 | 0 | 0 | null | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 3 |
f01e36c7e52b2f29e3153f9812f722135e5763dd | 2,483 | py | Python | Curso em Video/D_045.py | tonmarcondes/UNIVESP | a66a623d4811e8f3f9e2999f09e38a4470035ae2 | [
"MIT"
] | null | null | null | Curso em Video/D_045.py | tonmarcondes/UNIVESP | a66a623d4811e8f3f9e2999f09e38a4470035ae2 | [
"MIT"
] | null | null | null | Curso em Video/D_045.py | tonmarcondes/UNIVESP | a66a623d4811e8f3f9e2999f09e38a4470035ae2 | [
"MIT"
] | null | null | null | import random
cor = {
'fim':'\033[m',
'amarelo':'\033[1;033m',
'vermelho':'\033[1;031m',
'vermelhof':'\033[7;031m',
'azul':'\033[1;034m',
'verde':'\033[1;32m',
'verdef':'\033[7;32m',
'branco':'\033[1;030m'
}
print('''
Escolha uma das opções abaixo:
\t {}1{} {}PEDRA{}:
\t {}2{} {}PAPEL{}:
\t {}3{} {}TESOURA{}:'''.format(
cor['vermelho'], cor['fim'], cor['azul'], cor['fim'],
cor['vermelho'], cor['fim'], cor['azul'], cor['fim'],
cor['vermelho'], cor['fim'], cor['azul'], cor['fim']
))
eu = int(input('\t '))
if eu == 1:
me = 'PEDRA'
elif eu == 2:
me = 'PAPEL'
else:
me = 'TESOURA'
pc = ['PEDRA', 'PAPEL', 'TESOURA']
random.shuffle(pc)
if eu < 1 or eu > 3:
print('\n\t\t{}ESCOLHA UM VALOR VÁLIDO{}\n'.format(cor['vermelho'], cor['fim']))
elif eu == 1 and pc[0] == 'PEDRA' or eu == 2 and pc[0] == 'PAPEL' or eu == 3 and pc[0] == 'TESOURA':
print('{}EU{}: {}\t\t{}PC{}: {}'.format(cor['vermelho'], cor['fim'], me, cor['vermelho'], cor['fim'], pc[0]))
print('{} EMPATE, JOGUE OUTRA VEZ {}\n'.format(cor['vermelhof'], cor['fim']))
elif eu == 1 and pc[0] == 'PAPEL':
print('{}EU{}: {}\t\t{}PC{}: {}'.format(cor['vermelho'], cor['fim'], me, cor['vermelho'], cor['fim'], pc[0]))
print('PAPEL {}EMBRULHA{} PEDRA\n'.format(cor['amarelo'], cor['fim']))
elif eu == 1 and pc[0] == 'PAPEL':
print('{}EU{}: {}\t\t{}PC{}: {}'.format(cor['vermelho'], cor['fim'], me, cor['vermelho'], cor['fim'], pc[0]))
print('PEDRA {}QUEBRA{} TESOURA\n'.format(cor['amarelo'], cor['fim']))
elif eu == 2 and pc[0] == 'PEDRA':
print('{}EU{}: {}\t\t{}PC{}: {}'.format(cor['vermelho'], cor['fim'], me, cor['vermelho'], cor['fim'], pc[0]))
print('PAPEL {}EMBRULHA{} PEDRA\n'.format(cor['amarelo'], cor['fim']))
elif eu == 2 and pc[0] == 'TESOURA':
print('{}EU{}: {}\t\t{}PC{}: {}'.format(cor['vermelho'], cor['fim'], me, cor['vermelho'], cor['fim'], pc[0]))
print('TESOURA {}CORTA{} PAPEL\n'.format(cor['amarelo'], cor['fim']))
elif eu == 3 and pc[0] == 'PEDRA':
print('{}EU{}: {}\t\t{}PC{}: {}'.format(cor['vermelho'], cor['fim'], me, cor['vermelho'], cor['fim'], pc[0]))
print('PEDRA {}QUEBRA{} TESOURA\n'.format(cor['amarelo'], cor['fim']))
else:
print('{}EU{}: {}\t\t{}PC{}: {}'.format(cor['vermelho'], cor['fim'], me, cor['vermelho'], cor['fim'], pc[0]))
print('TESOURA {}CORTA{} PAPEL\n'.format(cor['amarelo'], cor['fim']))
| 42.084746 | 114 | 0.515103 | 365 | 2,483 | 3.50411 | 0.153425 | 0.136044 | 0.197029 | 0.239249 | 0.724003 | 0.695856 | 0.695856 | 0.695856 | 0.67631 | 0.67631 | 0 | 0.038854 | 0.170761 | 2,483 | 58 | 115 | 42.810345 | 0.582322 | 0 | 0 | 0.365385 | 0 | 0 | 0.405528 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | false | 0 | 0.019231 | 0 | 0.019231 | 0.307692 | 0 | 0 | 0 | null | 0 | 1 | 1 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 3 |
f022af95545ca83849a19b9cfbeb75f2ed9c4fd0 | 181 | py | Python | transitfeed_web/__init__.py | ed-g/transitfeed_web | 1e9be7152823641c450612b27cace99a1efe0b4f | [
"Apache-2.0"
] | null | null | null | transitfeed_web/__init__.py | ed-g/transitfeed_web | 1e9be7152823641c450612b27cace99a1efe0b4f | [
"Apache-2.0"
] | null | null | null | transitfeed_web/__init__.py | ed-g/transitfeed_web | 1e9be7152823641c450612b27cace99a1efe0b4f | [
"Apache-2.0"
] | null | null | null | #!/usr/bin/env python2
import sys
import transitfeed
import run_transitfeed_web_server
import util
def main():
print ("Hello, world.")
if __name__ == '__main__':
main()
| 12.928571 | 33 | 0.707182 | 24 | 181 | 4.875 | 0.75 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0.006711 | 0.176796 | 181 | 13 | 34 | 13.923077 | 0.778523 | 0.116022 | 0 | 0 | 0 | 0 | 0.132911 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0.125 | true | 0 | 0.5 | 0 | 0.625 | 0.125 | 1 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 1 | 0 | 0 | 0 | 0 | 3 |
f023dd97d1d559d5d0d17b6855fef5c568625d43 | 236 | py | Python | loadenv.py | Natsu-dev/otenki | d962d44737a68a4751fd58051a670be4ecf852ce | [
"MIT"
] | null | null | null | loadenv.py | Natsu-dev/otenki | d962d44737a68a4751fd58051a670be4ecf852ce | [
"MIT"
] | null | null | null | loadenv.py | Natsu-dev/otenki | d962d44737a68a4751fd58051a670be4ecf852ce | [
"MIT"
] | null | null | null | import os
from os.path import join, dirname
from dotenv import load_dotenv
load_dotenv(verbose=True)
dotenv_path = join(dirname(__file__), '.env')
load_dotenv(verbose=True, dotenv_path=dotenv_path)
TOKEN = os.getenv('DISCORD_TOKEN')
| 21.454545 | 50 | 0.792373 | 36 | 236 | 4.888889 | 0.416667 | 0.170455 | 0.193182 | 0.238636 | 0.352273 | 0.352273 | 0 | 0 | 0 | 0 | 0 | 0 | 0.101695 | 236 | 10 | 51 | 23.6 | 0.830189 | 0 | 0 | 0 | 0 | 0 | 0.072034 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | false | 0 | 0.428571 | 0 | 0.428571 | 0 | 0 | 0 | 0 | null | 0 | 1 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 0 | 0 | 3 |
f029112ff9d652c6d8e36f9059cb703264d4ebbd | 739 | py | Python | Hartree-Fock_H2/utils.py | WonhoZhung/CH502 | c64a174fe7218e6e86c84c73e6df441fb5074211 | [
"MIT"
] | null | null | null | Hartree-Fock_H2/utils.py | WonhoZhung/CH502 | c64a174fe7218e6e86c84c73e6df441fb5074211 | [
"MIT"
] | null | null | null | Hartree-Fock_H2/utils.py | WonhoZhung/CH502 | c64a174fe7218e6e86c84c73e6df441fb5074211 | [
"MIT"
] | null | null | null | #----------------------------------------------------------------------
# Basis Set Exchange
# Version v0.8.13
# https://www.basissetexchange.org
#----------------------------------------------------------------------
# Basis set: STO-3G
# Description: STO-3G Minimal Basis (3 functions/AO)
# Role: orbital
# Version: 1 (Data from Gaussian09)
#----------------------------------------------------------------------
# BASIS "ao basis" PRINT
# #BASIS SET: (3s) -> [1s]
# H S
# 0.3425250914E+01 0.1543289673E+00
# 0.6239137298E+00 0.5353281423E+00
# 0.1688554040E+00 0.4446345422E+00
# END
A_LIST = [3.425250914 , 0.6239137298, 0.1688554040]
D_LIST = [0.1543289673, 0.5353281423, 0.4446345422]
| 35.190476 | 71 | 0.460081 | 75 | 739 | 4.506667 | 0.64 | 0.035503 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0.248796 | 0.156969 | 739 | 20 | 72 | 36.95 | 0.29374 | 0.810555 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | false | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 0 | 0 | 0 | 1 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 3 |
f02f263b4792b69303bcdec39c484284dc805802 | 1,221 | py | Python | src/prefect/engine/result_handlers/secret_result_handler.py | trapped/prefect | 128f11570c35e7156d65ba65fdcbc1f4ccd7c2b7 | [
"Apache-2.0"
] | 1 | 2019-12-20T07:43:55.000Z | 2019-12-20T07:43:55.000Z | src/prefect/engine/result_handlers/secret_result_handler.py | trapped/prefect | 128f11570c35e7156d65ba65fdcbc1f4ccd7c2b7 | [
"Apache-2.0"
] | null | null | null | src/prefect/engine/result_handlers/secret_result_handler.py | trapped/prefect | 128f11570c35e7156d65ba65fdcbc1f4ccd7c2b7 | [
"Apache-2.0"
] | null | null | null | import json
from typing import Any
import prefect
from prefect.engine.result_handlers import ResultHandler
class SecretResultHandler(ResultHandler):
"""
Hook for storing and retrieving sensitive task results from a Secret store. Only intended to be used
for Secret tasks.
Args:
- secret_task (Task): the Secret Task that this result handler will be used for
"""
def __init__(self, secret_task: "prefect.tasks.secrets.Secret") -> None:
self.secret_task = secret_task
super().__init__()
def read(self, name: str) -> Any:
"""
Read a secret from a provided name with the provided Secret class;
this method actually retrieves the secret from the Secret store.
Args:
- name (str): the name of the secret to retrieve
Returns:
- Any: the deserialized result
"""
return self.secret_task.run() # type: ignore
def write(self, result: Any) -> str:
"""
Returns the name of the secret.
Args:
- result (Any): the result to write
Returns:
- str: the JSON representation of the result
"""
return self.secret_task.name
| 27.133333 | 104 | 0.626536 | 152 | 1,221 | 4.934211 | 0.388158 | 0.093333 | 0.074667 | 0.032 | 0.117333 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0.299754 | 1,221 | 44 | 105 | 27.75 | 0.877193 | 0.489762 | 0 | 0 | 0 | 0 | 0.0587 | 0.0587 | 0 | 0 | 0 | 0 | 0 | 1 | 0.25 | false | 0 | 0.333333 | 0 | 0.833333 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 1 | 0 | 1 | 0 | 0 | 3 |
f03f530e1dc98bcc4544ec79667fa0181fc768d4 | 373 | py | Python | tests/data_elements/test_other_double.py | GalBenZvi/dicom_parser | fc3e892ebf99c4e5d62cb5e7de7df341baf445fe | [
"MIT"
] | 11 | 2020-08-08T21:41:54.000Z | 2021-07-27T12:48:31.000Z | tests/data_elements/test_other_double.py | GalBenZvi/dicom_parser | fc3e892ebf99c4e5d62cb5e7de7df341baf445fe | [
"MIT"
] | 45 | 2020-03-03T14:32:16.000Z | 2021-07-30T16:42:17.000Z | tests/data_elements/test_other_double.py | GalBenZvi/dicom_parser | fc3e892ebf99c4e5d62cb5e7de7df341baf445fe | [
"MIT"
] | 6 | 2021-10-19T09:19:22.000Z | 2022-03-13T19:26:10.000Z | """
Definition of the :class:`OtherDoubleTestCase` class.
"""
from dicom_parser.data_elements.other_double import OtherDouble
from tests.test_data_element import DataElementTestCase
class OtherDoubleTestCase(DataElementTestCase):
"""
Tests for the
:class:`~dicom_parser.data_elements.other_double.OtherDouble`
class.
"""
TEST_CLASS = OtherDouble
| 23.3125 | 65 | 0.766756 | 40 | 373 | 6.925 | 0.475 | 0.057762 | 0.108303 | 0.166065 | 0.245487 | 0.245487 | 0 | 0 | 0 | 0 | 0 | 0 | 0.144772 | 373 | 15 | 66 | 24.866667 | 0.868339 | 0.364611 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | false | 0 | 0.5 | 0 | 1 | 0 | 0 | 0 | 0 | null | 0 | 0 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 1 | 0 | 0 | 3 |
f076d7596035ea99f16b2ee688410ac4e2c0be9a | 2,292 | py | Python | tests/coro.py | dshean/sliderule-python | 3cf9a6c65987705354cb536d71f85a32fbb24d15 | [
"BSD-3-Clause"
] | 1 | 2021-04-09T22:01:33.000Z | 2021-04-09T22:01:33.000Z | tests/coro.py | dshean/sliderule-python | 3cf9a6c65987705354cb536d71f85a32fbb24d15 | [
"BSD-3-Clause"
] | null | null | null | tests/coro.py | dshean/sliderule-python | 3cf9a6c65987705354cb536d71f85a32fbb24d15 | [
"BSD-3-Clause"
] | null | null | null | # python
import sys
import h5coro
###############################################################################
# DATA
###############################################################################
# set resource
resource = "file:///data/ATLAS/ATL06_20200714160647_02950802_003_01.h5"
# expected single read
h_li_exp_1 = [3432.17578125, 3438.776611328125, 3451.01123046875, 3462.688232421875, 3473.559326171875]
# expected parallel read
h_li_exp_2 = { '/gt1l/land_ice_segments/h_li': [3432.17578125, 3438.776611328125, 3451.01123046875, 3462.688232421875, 3473.559326171875],
'/gt2l/land_ice_segments/h_li': [3263.659912109375, 3258.362548828125, 3.4028234663852886e+38, 3233.031494140625, 3235.200927734375],
'/gt3l/land_ice_segments/h_li': [3043.489013671875, 3187.576171875, 3.4028234663852886e+38, 4205.04248046875, 2924.724365234375]}
###############################################################################
# UTILITY FUNCTIONS
###############################################################################
def check_results(act, exp):
if type(exp) == dict:
for dataset in exp:
for i in range(len(exp[dataset])):
if exp[dataset][i] != act[dataset][i]:
print("Failed parallel read test")
return False
print("Passed parallel read test")
return True
else:
for i in range(len(exp)):
if exp[i] != act[i]:
print("Failed single read test")
return False
print("Passed single read test")
return True
###############################################################################
# MAIN
###############################################################################
if __name__ == '__main__':
# Open H5Coro File #
h5file = h5coro.file(resource)
# Perform Single Read #
h_li_1 = h5file.read("/gt1l/land_ice_segments/h_li", 0, 19, 5)
check_results(h_li_1, h_li_exp_1)
# Perform Parallel Read #
datasets = [["/gt1l/land_ice_segments/h_li", 0, 19, 5],
["/gt2l/land_ice_segments/h_li", 0, 19, 5],
["/gt3l/land_ice_segments/h_li", 0, 19, 5]]
h_li_2 = h5file.readp(datasets)
check_results(h_li_2, h_li_exp_2)
| 38.2 | 149 | 0.505236 | 244 | 2,292 | 4.516393 | 0.377049 | 0.040835 | 0.095281 | 0.101633 | 0.375681 | 0.375681 | 0.22323 | 0.22323 | 0.183303 | 0.136116 | 0 | 0.205087 | 0.193717 | 2,292 | 59 | 150 | 38.847458 | 0.391234 | 0.066318 | 0 | 0.125 | 0 | 0 | 0.216838 | 0.153846 | 0 | 0 | 0 | 0 | 0 | 1 | 0.03125 | false | 0.0625 | 0.0625 | 0 | 0.21875 | 0.125 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 0 | 0 | 0 | 3 |
b2cabd96c3fc001d2729753488a402fc76f755f0 | 8,187 | py | Python | tests/test_skipping.py | pytask-dev/pytask | b6769b48abda44c6261b9a7b58865f8844423c13 | [
"MIT"
] | 41 | 2020-07-24T15:19:19.000Z | 2022-03-17T17:40:57.000Z | tests/test_skipping.py | pytask-dev/pytask | b6769b48abda44c6261b9a7b58865f8844423c13 | [
"MIT"
] | 240 | 2020-06-26T21:37:49.000Z | 2022-03-31T08:56:56.000Z | tests/test_skipping.py | pytask-dev/pytask | b6769b48abda44c6261b9a7b58865f8844423c13 | [
"MIT"
] | null | null | null | import textwrap
from contextlib import ExitStack as does_not_raise # noqa: N813
import pytest
from _pytask.mark import Mark
from _pytask.outcomes import Skipped
from _pytask.outcomes import SkippedAncestorFailed
from _pytask.outcomes import SkippedUnchanged
from _pytask.skipping import pytask_execute_task_setup
from pytask import cli
from pytask import main
class DummyClass:
pass
@pytest.mark.end_to_end
def test_skip_unchanged(tmp_path):
source = """
def task_dummy():
pass
"""
tmp_path.joinpath("task_dummy.py").write_text(textwrap.dedent(source))
session = main({"paths": tmp_path})
assert session.execution_reports[0].success
session = main({"paths": tmp_path})
assert isinstance(session.execution_reports[0].exc_info[1], SkippedUnchanged)
@pytest.mark.end_to_end
def test_skip_unchanged_w_dependencies_and_products(tmp_path):
source = """
import pytask
@pytask.mark.depends_on("in.txt")
@pytask.mark.produces("out.txt")
def task_dummy(depends_on, produces):
produces.write_text(depends_on.read_text())
"""
tmp_path.joinpath("task_dummy.py").write_text(textwrap.dedent(source))
tmp_path.joinpath("in.txt").write_text("Original content of in.txt.")
session = main({"paths": tmp_path})
assert session.execution_reports[0].success
assert tmp_path.joinpath("out.txt").read_text() == "Original content of in.txt."
session = main({"paths": tmp_path})
assert isinstance(session.execution_reports[0].exc_info[1], SkippedUnchanged)
assert tmp_path.joinpath("out.txt").read_text() == "Original content of in.txt."
@pytest.mark.end_to_end
def test_skipif_ancestor_failed(tmp_path):
source = """
import pytask
@pytask.mark.produces("out.txt")
def task_first():
assert 0
@pytask.mark.depends_on("out.txt")
def task_second():
pass
"""
tmp_path.joinpath("task_dummy.py").write_text(textwrap.dedent(source))
session = main({"paths": tmp_path})
assert not session.execution_reports[0].success
assert isinstance(session.execution_reports[0].exc_info[1], Exception)
assert not session.execution_reports[1].success
assert isinstance(session.execution_reports[1].exc_info[1], SkippedAncestorFailed)
@pytest.mark.end_to_end
def test_if_skip_decorator_is_applied_to_following_tasks(tmp_path):
source = """
import pytask
@pytask.mark.skip
@pytask.mark.produces("out.txt")
def task_first():
assert 0
@pytask.mark.depends_on("out.txt")
def task_second():
pass
"""
tmp_path.joinpath("task_dummy.py").write_text(textwrap.dedent(source))
session = main({"paths": tmp_path})
assert session.execution_reports[0].success
assert isinstance(session.execution_reports[0].exc_info[1], Skipped)
assert session.execution_reports[1].success
assert isinstance(session.execution_reports[1].exc_info[1], Skipped)
@pytest.mark.end_to_end
@pytest.mark.parametrize(
"mark_string", ["@pytask.mark.skip", "@pytask.mark.skipif(True, reason='bla')"]
)
def test_skip_if_dependency_is_missing(tmp_path, mark_string):
source = f"""
import pytask
{mark_string}
@pytask.mark.depends_on("in.txt")
def task_first():
assert 0
"""
tmp_path.joinpath("task_dummy.py").write_text(textwrap.dedent(source))
session = main({"paths": tmp_path})
assert session.execution_reports[0].success
assert isinstance(session.execution_reports[0].exc_info[1], Skipped)
@pytest.mark.end_to_end
@pytest.mark.parametrize(
"mark_string", ["@pytask.mark.skip", "@pytask.mark.skipif(True, reason='bla')"]
)
def test_skip_if_dependency_is_missing_only_for_one_task(runner, tmp_path, mark_string):
source = f"""
import pytask
{mark_string}
@pytask.mark.depends_on("in.txt")
def task_first():
assert 0
@pytask.mark.depends_on("in.txt")
def task_second():
assert 0
"""
tmp_path.joinpath("task_dummy.py").write_text(textwrap.dedent(source))
result = runner.invoke(cli, [tmp_path.as_posix()])
assert result.exit_code == 4
assert "in.txt" in result.output
assert "task_first" not in result.output
assert "task_second" in result.output
@pytest.mark.end_to_end
def test_if_skipif_decorator_is_applied_skipping(tmp_path):
source = """
import pytask
@pytask.mark.skipif(condition=True, reason="bla")
@pytask.mark.produces("out.txt")
def task_first():
assert False
@pytask.mark.depends_on("out.txt")
def task_second():
assert False
"""
tmp_path.joinpath("task_dummy.py").write_text(textwrap.dedent(source))
session = main({"paths": tmp_path})
node = session.collection_reports[0].node
assert len(node.markers) == 1
assert node.markers[0].name == "skipif"
assert node.markers[0].args == ()
assert node.markers[0].kwargs == {"condition": True, "reason": "bla"}
assert session.execution_reports[0].success
assert isinstance(session.execution_reports[0].exc_info[1], Skipped)
assert session.execution_reports[1].success
assert isinstance(session.execution_reports[1].exc_info[1], Skipped)
assert session.execution_reports[0].exc_info[1].args[0] == "bla"
@pytest.mark.end_to_end
def test_if_skipif_decorator_is_applied_execute(tmp_path):
source = """
import pytask
@pytask.mark.skipif(False, reason="bla")
@pytask.mark.produces("out.txt")
def task_first(produces):
with open(produces, "w") as f:
f.write("hello world.")
@pytask.mark.depends_on("out.txt")
def task_second():
pass
"""
tmp_path.joinpath("task_dummy.py").write_text(textwrap.dedent(source))
session = main({"paths": tmp_path})
node = session.collection_reports[0].node
assert len(node.markers) == 1
assert node.markers[0].name == "skipif"
assert node.markers[0].args == (False,)
assert node.markers[0].kwargs == {"reason": "bla"}
assert session.execution_reports[0].success
assert session.execution_reports[0].exc_info is None
assert session.execution_reports[1].success
assert session.execution_reports[1].exc_info is None
@pytest.mark.end_to_end
def test_if_skipif_decorator_is_applied_any_condition_matches(tmp_path):
"""Any condition of skipif has to be True and only their message is shown."""
source = """
import pytask
@pytask.mark.skipif(condition=False, reason="I am fine")
@pytask.mark.skipif(condition=True, reason="No, I am not.")
@pytask.mark.produces("out.txt")
def task_first():
assert False
@pytask.mark.depends_on("out.txt")
def task_second():
assert False
"""
tmp_path.joinpath("task_dummy.py").write_text(textwrap.dedent(source))
session = main({"paths": tmp_path})
node = session.collection_reports[0].node
assert len(node.markers) == 2
assert node.markers[0].name == "skipif"
assert node.markers[0].args == ()
assert node.markers[0].kwargs == {"condition": True, "reason": "No, I am not."}
assert node.markers[1].name == "skipif"
assert node.markers[1].args == ()
assert node.markers[1].kwargs == {"condition": False, "reason": "I am fine"}
assert session.execution_reports[0].success
assert isinstance(session.execution_reports[0].exc_info[1], Skipped)
assert session.execution_reports[1].success
assert isinstance(session.execution_reports[1].exc_info[1], Skipped)
assert session.execution_reports[0].exc_info[1].args[0] == "No, I am not."
@pytest.mark.unit
@pytest.mark.parametrize(
("marker_name", "expectation"),
[
("skip_unchanged", pytest.raises(SkippedUnchanged)),
("skip_ancestor_failed", pytest.raises(SkippedAncestorFailed)),
("skip", pytest.raises(Skipped)),
("", does_not_raise()),
],
)
def test_pytask_execute_task_setup(marker_name, expectation):
class Task:
pass
task = Task()
kwargs = {"reason": ""} if marker_name == "skip_ancestor_failed" else {}
task.markers = [Mark(marker_name, (), kwargs)]
with expectation:
pytask_execute_task_setup(task)
| 30.662921 | 88 | 0.696836 | 1,104 | 8,187 | 4.953804 | 0.116848 | 0.040958 | 0.117755 | 0.078991 | 0.771622 | 0.749497 | 0.729384 | 0.672335 | 0.65021 | 0.626257 | 0 | 0.010268 | 0.167338 | 8,187 | 266 | 89 | 30.778195 | 0.791991 | 0.010138 | 0 | 0.65534 | 0 | 0 | 0.296369 | 0.094097 | 0 | 0 | 0 | 0 | 0.281553 | 1 | 0.048544 | false | 0.029126 | 0.087379 | 0 | 0.145631 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 1 | 1 | 0 | 0 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 3 |
b2cf11ab3d7e9318bb55599575d25a729b83ace2 | 319 | py | Python | mayan/apps/dependencies/permissions.py | CMU-313/fall-2021-hw2-451-unavailable-for-legal-reasons | 0e4e919fd2e1ded6711354a0330135283e87f8c7 | [
"Apache-2.0"
] | 2 | 2021-09-12T19:41:19.000Z | 2021-09-12T19:41:20.000Z | mayan/apps/dependencies/permissions.py | CMU-313/fall-2021-hw2-451-unavailable-for-legal-reasons | 0e4e919fd2e1ded6711354a0330135283e87f8c7 | [
"Apache-2.0"
] | 37 | 2021-09-13T01:00:12.000Z | 2021-10-02T03:54:30.000Z | mayan/apps/dependencies/permissions.py | CMU-313/fall-2021-hw2-451-unavailable-for-legal-reasons | 0e4e919fd2e1ded6711354a0330135283e87f8c7 | [
"Apache-2.0"
] | 1 | 2021-09-22T13:17:30.000Z | 2021-09-22T13:17:30.000Z | from django.utils.translation import ugettext_lazy as _
from mayan.apps.permissions import PermissionNamespace
namespace = PermissionNamespace(label=_('Dependencies'), name='dependencies')
permission_dependencies_view = namespace.add_permission(
label=_('View dependencies'), name='dependencies_view'
)
| 31.9 | 78 | 0.793103 | 32 | 319 | 7.65625 | 0.59375 | 0.130612 | 0.228571 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0.115987 | 319 | 9 | 79 | 35.444444 | 0.868794 | 0 | 0 | 0 | 0 | 0 | 0.187097 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | false | 0 | 0.333333 | 0 | 0.333333 | 0 | 0 | 0 | 0 | null | 0 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 0 | 0 | 3 |
b2d75b157f57c7832de3185889e5c4f8fbd90377 | 234 | py | Python | faketranslate/metadata.py | HeywoodKing/faketranslate | 683821eccd0004305c9f1bbfa0aae16f5fbcd829 | [
"MIT"
] | null | null | null | faketranslate/metadata.py | HeywoodKing/faketranslate | 683821eccd0004305c9f1bbfa0aae16f5fbcd829 | [
"MIT"
] | null | null | null | faketranslate/metadata.py | HeywoodKing/faketranslate | 683821eccd0004305c9f1bbfa0aae16f5fbcd829 | [
"MIT"
] | null | null | null | # -*- encoding: utf-8 -*-
"""
@File : metadata.py
@Time : 2020/1/1
@Author : flack
@Email : opencoding@hotmail.com
@ide : PyCharm
@project : faketranslate
@description : 描述
""" | 23.4 | 40 | 0.491453 | 22 | 234 | 5.227273 | 0.954545 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0.04698 | 0.363248 | 234 | 10 | 41 | 23.4 | 0.724832 | 0.961538 | 0 | null | 0 | null | 0 | 0 | null | 0 | 0 | 0 | null | 1 | null | true | 0 | 0 | null | null | null | 1 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 3 |
b2d93cfb63dcf1ebc579a1abfad61711545c68bf | 628 | py | Python | app/main/controller/sample_controller.py | Eliotdoesprogramming/python.flask.sqlalchemy.Rest_Api_Template | 3f0a98ae4676aef9ecdf0df70eb9d1990fee6182 | [
"MIT"
] | null | null | null | app/main/controller/sample_controller.py | Eliotdoesprogramming/python.flask.sqlalchemy.Rest_Api_Template | 3f0a98ae4676aef9ecdf0df70eb9d1990fee6182 | [
"MIT"
] | null | null | null | app/main/controller/sample_controller.py | Eliotdoesprogramming/python.flask.sqlalchemy.Rest_Api_Template | 3f0a98ae4676aef9ecdf0df70eb9d1990fee6182 | [
"MIT"
] | null | null | null | from flask import Flask
from flask_sqlalchemy import SQLAlchemy
from service.api_service import Service
class SampleController(object):
def __init__(self,app:Flask,db:SQLAlchemy,service:Service) -> None:
self.app=app
self.db=db
self.service=service
self.add_routes(app)
def add_routes(self,app:Flask):
app.add_url_rule('/example',methods=['GET'],view_func=self.example)
app.add_url_rule('/example',methods=['POST'],view_func=self.add_example)
def example(self):
return self.service.example()
def add_example(self):
return self.service.add_example() | 39.25 | 80 | 0.703822 | 86 | 628 | 4.94186 | 0.302326 | 0.049412 | 0.056471 | 0.061176 | 0.258824 | 0.127059 | 0 | 0 | 0 | 0 | 0 | 0 | 0.179936 | 628 | 16 | 81 | 39.25 | 0.825243 | 0 | 0 | 0 | 0 | 0 | 0.036566 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0.25 | false | 0 | 0.1875 | 0.125 | 0.625 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 0 | 1 | 1 | 0 | 0 | 3 |
b2e1c343a37dcd72cd8cbdfb5d12721802108339 | 296 | py | Python | digin/leads/views.py | yhung119/cs411-digin | 55e884ff0c26ca06056219e6cb641dc1ceae1f56 | [
"Apache-2.0"
] | null | null | null | digin/leads/views.py | yhung119/cs411-digin | 55e884ff0c26ca06056219e6cb641dc1ceae1f56 | [
"Apache-2.0"
] | null | null | null | digin/leads/views.py | yhung119/cs411-digin | 55e884ff0c26ca06056219e6cb641dc1ceae1f56 | [
"Apache-2.0"
] | null | null | null | from django.shortcuts import render
from leads.models import Lead
from leads.serializers import LeadSerializer
from rest_framework import generics
# Create your views here.
class LeadListCreate(generics.ListCreateAPIView):
queryset = Lead.objects.all()
serializer_class = LeadSerializer
| 29.6 | 49 | 0.820946 | 35 | 296 | 6.885714 | 0.685714 | 0.074689 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0.128378 | 296 | 9 | 50 | 32.888889 | 0.934109 | 0.077703 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | false | 0 | 0.571429 | 0 | 1 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 1 | 0 | 0 | 3 |
b2eaad3cf6ba61735dc17fc8cd249e0de4bd056b | 8,879 | py | Python | examples/json_serializer.py | trisongz/lazycls | 701bad1a358ed3bb136347d0c5eb81de3201f6a3 | [
"MIT"
] | 2 | 2021-12-02T00:13:16.000Z | 2022-02-26T11:18:33.000Z | examples/json_serializer.py | trisongz/lazycls | 701bad1a358ed3bb136347d0c5eb81de3201f6a3 | [
"MIT"
] | null | null | null | examples/json_serializer.py | trisongz/lazycls | 701bad1a358ed3bb136347d0c5eb81de3201f6a3 | [
"MIT"
] | null | null | null | """
This test will show how to use the various Json serializer(s)
"""
from lazy.io.pathz import get_path
from lazy.serialize import SimdJson, OrJson, Json, Serializer
from lazy.utils import get_logger, timer
logger = get_logger('lazytest')
test_file = './files/naics_codes.json'
test_path = get_path(test_file, resolve=True)
test_keys = [
'112930', '11299', '112990', '1131', '11311', '113110', '1132', '11321', '113210', '1133', '11331', '113310', '1141', '11411', '114111', '114112', '114119', '1142', '11421', '114210', '1151', '11511', '115111', '115112', '115113', '115114', '115115', '115116', '1152', '11521', '115210', '1153', '11531', '115310', '2111', '21112', '211120', '21113', '211130', '2121', '21211', '212111', '212112', '212113', '2122', '21221', '212210', '21222', '212221', '212222', '21223', '212230', '21229', '212291', '212299', '2123', '21231', '212311', '212312', '212313', '212319', '21232', '212321', '212322', '212324', '212325', '21239', '212391', '212392', '212393', '212399', '2131', '21311', '213111', '213112', '213113', '213114', '213115', '2211', '22111', '221111', '221112', '221113', '221114', '221115', '221116', '221117', '221118', '22112', '221121', '221122', '2212', '22121', '221210', '2213', '22131', '221310', '22132', '221320', '22133', '221330', '2361', '23611', '236115', '236116', '236117', '236118', '2362', '23621', '236210', '23622', '236220', '2371', '23711', '237110', '23712', '237120', '23713', '237130', '2372', '23721', '237210', '2373', '23731', '237310', '2379', '23799', '237990', '2381', '23811', '238110',
'32412', '324121', '324122', '32419', '324191', '324199', '3251', '32511', '325110', '32512', '325120', '32513', '325130', '32518', '325180', '32519', '325193', '325194', '325199', '3252', '32521', '325211', '325212', '32522', '325220', '3253', '32531', '325311', '325312', '325314', '32532', '325320', '3254', '32541', '325411', '325412', '325413', '325414', '3255', '32551', '325510', '32552', '325520', '3256', '32561', '325611', '325612', '325613', '32562', '325620', '3259', '32591', '325910', '32592', '325920', '32599', '325991', '325992', '325998', '3261', '32611', '326111', '326112', '326113', '32612', '326121', '326122', '32613', '326130', '32614', '326140', '32615', '326150', '32616', '326160', '32619', '326191', '326199', '3262', '32621', '326211', '326212', '32622', '326220', '32629', '326291', '326299', '3271', '32711', '327110', '32712', '327120', '3272', '32721', '327211', '327212', '327213', '327215', '3273', '32731', '327310', '32732', '327320', '32733', '327331', '327332', '32739', '327390', '3274', '32741', '327410', '32742', '327420', '3279', '32791', '327910', '32799', '327991', '327992', '327993', '327999', '3311', '33111', '331110', '3312', '33121', '331210', '33122', '3312',
'333413', '333414', '333415', '3335', '33351', '333511', '333514', '333515', '333517', '333519', '3336', '33361', '333611', '333612', '333613', '333618', '3339', '33391', '333912', '333914', '33392', '333921', '333922', '333923', '333924', '33399', '333991', '333992', '333993', '333994', '333995', '333996', '333997', '333999', '3341', '33411', '334111', '334112', '334118', '3342', '33421', '334210', '33422', '334220', '33429', '334290', '3343', '33431', '334310', '3344', '33441', '334412', '334413', '334416', '334417', '334418', '334419', '3345', '33451', '334510', '334511', '334512', '334513', '334514', '334515', '334516', '334517', '334519', '3346', '33461', '334613', '334614', '3351', '33511', '335110', '33512', '335121', '335122', '335129', '3352', '33521', '335210', '33522', '335220', '3353', '33531', '335311', '335312', '335313', '335314', '3359', '33591', '335911', '335912', '33592', '335921', '335929', '33593', '335931', '335932', '33599', '335991', '335999', '3361', '33611', '336111',
'519190', '5211', '52111', '521110', '5221', '52211', '522110', '52212', '522120', '52213', '522130', '52219', '522190', '5222', '52221', '522210', '52222', '522220', '52229', '522291', '522292', '522293', '522294', '522298', '5223', '52231', '522310', '52232', '522320', '52239', '522390', '5231', '52311', '523110', '52312', '523120', '52313', '523130', '52314', '523140', '5232', '52321', '523210', '5239', '52391',
'7113', '71131', '711310', '71132', '711320', '7114', '71141', '711410', '7115', '71151', '711510', '7121', '71211', '712110', '71212', '712120', '71213', '712130', '71219', '712190', '7131', '71311', '713110', '71312', '713120', '7132', '71321', '713210', '71329', '713290', '7139', '71391', '713910', '71392', '713920', '71393', '713930', '71394', '713940', '71395', '713950', '71399', '713990', '7211', '72111', '721110', '72112', '721120', '72119', '721191', '721199', '7212', '72121', '721211', '721214', '7213', '72131', '721310', '7223', '72231', '722310', '72232', '722320', '72233', '722330', '7224', '72241', '722410', '7225', '72251', '722511', '722513', '722514', '722515', '8111', '81111', '811111', '811112', '811113', '811118', '81112', '811121', '811122', '81119', '811191', '811192', '811198', '8112', '81121', '811211', '811212', '811213', '811219', '8113', '81131', '811310', '8114', '81141', '811411', '811412', '81142', '811420', '81143', '811430', '81149', '811490', '8121', '81211', '812111',
]
def get_text():
s = timer()
text = test_path.read_text()
logger(f'Time to Read Text: {timer(s, as_string=True, short=True)}')
return text
def test_simdjson():
js = timer()
text = get_text()
t = SimdJson.parse(text)
logger(f'[SimdJson] Time to Parse: {timer(js, as_string=True, short=True)}')
num_keys = len(t.keys)
logger(f'[SimdJson] Time to Load {num_keys} Keys: {timer(js, as_string=True, short=True)}')
lt = timer()
for i in test_keys:
_ = t[i]
logger(f'[SimdJson] Time to Read {len(test_keys)} Items: {timer(lt, as_string=True, short=True)}')
lt = timer()
_ = SimdJson.dumps(t)
logger(f'[SimdJson] Time to Dump {len(test_keys)} Items: {timer(lt, as_string=True, short=True)}')
logger(f'[SimdJson] Completed Test in: {timer(js, as_string=True, short=True)}')
logger('----------------------------------------------------------------')
def test_orjson():
js = timer()
text = get_text()
t = OrJson.loads(text)
num_keys = len(t.keys())
logger(f'[OrJson] Time to Load with {num_keys} Total Items: {timer(js, as_string=True, short=True)}')
lt = timer()
for i in test_keys:
_ = t[i]
logger(f'[OrJson] Time to Read {len(test_keys)} Items: {timer(lt, as_string=True, short=True)}')
lt = timer()
_ = OrJson.dumps(t)
logger(f'[OrJson] Time to Dump {len(test_keys)} Items: {timer(lt, as_string=True, short=True)}')
logger(f'[OrJson] Completed Test in: {timer(js, as_string=True, short=True)}')
logger('----------------------------------------------------------------')
def test_json():
js = timer()
text = get_text()
## Explicitly disable Parser
Json.parser_enabled = False
t = Json.loads(text)
logger(f'[Json] Time to Load: {timer(js, as_string=True, short=True)}')
lt = timer()
for i in test_keys:
_ = t[i]
logger(f'[Json] Time to [Loads]Read {len(test_keys)} Items: {timer(lt, as_string=True, short=True)}')
t = Json.parse(text)
logger(f'[Json] Time to Parse: {timer(js, as_string=True, short=True)}')
lt = timer()
for i in test_keys:
_ = t[i]
logger(f'[Json] Time to [Parse]Read {len(test_keys)} Items: {timer(lt, as_string=True, short=True)}')
lt = timer()
_ = Json.dumps(t)
logger(f'[Json] Time to Dump {len(test_keys)} Items: {timer(lt, as_string=True, short=True)}')
logger(f'[Json] Completed Test in: {timer(js, as_string=True, short=True)}')
logger('----------------------------------------------------------------')
"""
Expected Results
Time to Read Text: 0.00095 secs
[OrJson] Time to Load with 2077 Total Items: 0.00378 secs
[OrJson] Time to Read 520 Items: 2e-05 secs
[OrJson] Time to Dump 520 Items: 0.00097 secs
[OrJson] Completed Test in: 0.00497 secs
----------------------------------------------------------------
Time to Read Text: 0.00022 secs
[Json] Time to Load: 0.00234 secs
[Json] Time to [Loads]Read 520 Items: 2e-05 secs
[Json] Time to Parse: 0.0032 secs
[Json] Time to [Parse]Read 520 Items: 0.00237 secs
[Json] Time to Dump 520 Items: 0.00238 secs
[Json] Completed Test in: 0.00814 secs
----------------------------------------------------------------
Time to Read Text: 0.00023 secs
[SimdJson] Time to Parse: 0.00051 secs
[SimdJson] Time to Load 2077 Keys: 0.00214 secs
[SimdJson] Time to Read 520 Items: 0.00011 secs
[SimdJson] Time to Dump 520 Items: 0.00365 secs
[SimdJson] Completed Test in: 0.00611 secs
----------------------------------------------------------------
"""
if __name__ == '__main__':
test_orjson()
test_json()
test_simdjson()
| 75.245763 | 1,231 | 0.582273 | 1,102 | 8,879 | 4.629764 | 0.553539 | 0.032928 | 0.037632 | 0.053312 | 0.271854 | 0.221286 | 0.179341 | 0.170717 | 0.170717 | 0.170717 | 0 | 0.384213 | 0.139655 | 8,879 | 117 | 1,232 | 75.888889 | 0.283676 | 0.009911 | 0 | 0.324324 | 0 | 0.121622 | 0.545967 | 0.027696 | 0 | 0 | 0 | 0 | 0 | 1 | 0.054054 | false | 0 | 0.040541 | 0 | 0.108108 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 0 | 1 | 0 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 3 |
b2fa730dbd73b043c294390890c9c13d76abf7ce | 1,685 | py | Python | tests/stdlib_test.py | misantroop/jsonpickle | 97f4a05ccffe8593458b4b787c3fc97622f23cec | [
"BSD-3-Clause"
] | null | null | null | tests/stdlib_test.py | misantroop/jsonpickle | 97f4a05ccffe8593458b4b787c3fc97622f23cec | [
"BSD-3-Clause"
] | 1 | 2019-04-03T20:19:40.000Z | 2019-04-03T20:19:40.000Z | tests/stdlib_test.py | parsons-kyle-89/jsonpickle | 2828dd4a247bbae9d37a3d78194caaaeadeb2ed2 | [
"BSD-3-Clause"
] | null | null | null | # -*- coding: utf-8 -*-
"""Test miscellaneous objects from the standard library"""
import uuid
import unittest
import jsonpickle
class UUIDTestCase(unittest.TestCase):
def test_random_uuid(self):
u = uuid.uuid4()
encoded = jsonpickle.encode(u)
decoded = jsonpickle.decode(encoded)
expect = u.hex
actual = decoded.hex
self.assertEqual(expect, actual)
def test_known_uuid(self):
expect = '28b56adbd18f44e2a5556bba2f23e6f6'
exemplar = uuid.UUID(expect)
encoded = jsonpickle.encode(exemplar)
decoded = jsonpickle.decode(encoded)
actual = decoded.hex
self.assertEqual(expect, actual)
class BytesTestCase(unittest.TestCase):
def test_bytestream(self):
expect = (b'\x89HDF\r\n\x1a\n\x00\x00\x00\x00\x00\x08\x08\x00'
b'\x04\x00\x10\x00\x00\x00\x00\x00\x00\x00\x00\x00'
b'\x00\x00\x00\x00\xff\xff\xff\xff\xff\xff\xff\xffh'
b'\x848\x00\x00\x00\x00\x00\xff\xff\xff\xff\xff\xff'
b'\xff\xff\x00\x00\x00\x00\x00\x00\x00\x00`\x00\x00'
b'\x00\x00\x00\x00\x00\x01\x00\x00\x00\x00\x00\x00'
b'\x00\x88\x00\x00\x00\x00\x00\x00\x00\xa8\x02\x00'
b'\x00\x00\x00\x00\x00\x01\x00\x01\x00')
encoded = jsonpickle.encode(expect)
actual = jsonpickle.decode(encoded)
self.assertEqual(expect, actual)
def suite():
suite = unittest.TestSuite()
suite.addTest(unittest.makeSuite(UUIDTestCase))
suite.addTest(unittest.makeSuite(BytesTestCase))
return suite
if __name__ == '__main__':
unittest.main(defaultTest='suite')
| 30.089286 | 70 | 0.629674 | 219 | 1,685 | 4.785388 | 0.273973 | 0.269084 | 0.326336 | 0.332061 | 0.329198 | 0.280534 | 0.277672 | 0.175573 | 0.157443 | 0.122137 | 0 | 0.131008 | 0.234421 | 1,685 | 55 | 71 | 30.636364 | 0.681395 | 0.04451 | 0 | 0.184211 | 0 | 0.184211 | 0.262469 | 0.254364 | 0 | 0 | 0 | 0 | 0.078947 | 1 | 0.105263 | false | 0 | 0.078947 | 0 | 0.263158 | 0 | 0 | 0 | 0 | null | 1 | 1 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 3 |
b2fd53048e194cb59b5b4420a7e50d932868c531 | 1,878 | py | Python | glance/rpc/common.py | Quinton/glance | 7674bc8963a3bec21f719c48f40e8a3fc0846e6f | [
"Apache-2.0"
] | 5 | 2017-04-23T05:50:36.000Z | 2019-03-12T09:45:20.000Z | glance/rpc/common.py | Quinton/glance | 7674bc8963a3bec21f719c48f40e8a3fc0846e6f | [
"Apache-2.0"
] | null | null | null | glance/rpc/common.py | Quinton/glance | 7674bc8963a3bec21f719c48f40e8a3fc0846e6f | [
"Apache-2.0"
] | 2 | 2018-08-16T11:41:18.000Z | 2018-10-21T06:56:50.000Z | #!/usr/bin/env python
#encode=utf-8
#vim: tabstop=4 shiftwidth=4 softtabstop=4
#Created on 2013-8-17
#Copyright 2013 nuoqingyun xuqifeng
import copy
import logging
import traceback
class RPCException(Exception):
message = "An Unknown RPC related exception occurred"
def __init__(self, message = None, **kwargs):
self.kwargs = kwargs
if not message:
try:
message = self.message % kwargs
except Exception as e:
message = self.message
super(RPCException, self).__init__(message)
class RemoteError(RPCException):
message = "Remote error: %(exc_type)s %(value)s\n%(traceback)s"
def __init__(self, exc_type = None, value = None, traceback = None):
self.exc_type = exc_type
self.value = value
self.traceback = traceback
super(RemoteError, self).__init__(exc_type = exc_type,
value = value,
traceback = traceback)
class Timeout(RPCException):
"""
"""
message = "Timeout while waiting on RPC response"
class InvalidRPCConnectionReuse(RPCException):
message = "Invalid reuse of an RPC Connection"
class Connection(object):
def close(self):
raise NotImplementedError()
def create_consumer(self, topic, proxy, fanout = False):
raise NotImplementedError()
def create_worker(self, topic, proxy, pool_name):
raise NotImplementedError()
def consumer_in_thread(self):
raise NotImplementedError()
def _sage_log(log_func, mes, msg_data):
"""
"""
pass
def serialize_remote_exception(failure_info):
"""
"""
pass
def deserialize_remote_exception(conf, data):
"""
"""
pass
| 22.357143 | 73 | 0.596912 | 193 | 1,878 | 5.621762 | 0.455959 | 0.03871 | 0.099539 | 0.025806 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0.011637 | 0.313632 | 1,878 | 83 | 74 | 22.626506 | 0.830101 | 0.067625 | 0 | 0.170732 | 0 | 0 | 0.100679 | 0.014824 | 0 | 0 | 0 | 0 | 0 | 1 | 0.219512 | false | 0.073171 | 0.073171 | 0 | 0.512195 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 1 | 0 | 0 | 1 | 0 | 0 | 3 |
6502f4ca30fdd305a49eeefeb8dc2c19d45c0e83 | 2,598 | py | Python | dit/divergences/tests/test_jensen_shannon_divergence.py | chebee7i/dit | 59626e34c7938fddeec140522dd2a592ba4f42ef | [
"BSD-2-Clause"
] | null | null | null | dit/divergences/tests/test_jensen_shannon_divergence.py | chebee7i/dit | 59626e34c7938fddeec140522dd2a592ba4f42ef | [
"BSD-2-Clause"
] | null | null | null | dit/divergences/tests/test_jensen_shannon_divergence.py | chebee7i/dit | 59626e34c7938fddeec140522dd2a592ba4f42ef | [
"BSD-2-Clause"
] | null | null | null | """
Tests for dit.divergences.jensen_shannon_divergence.
"""
from nose.tools import assert_almost_equal, assert_raises
from dit import Distribution
from dit.exceptions import ditException
from dit.divergences.jensen_shannon_divergence import (
jensen_shannon_divergence as JSD,
jensen_shannon_divergence_pmf as JSD_pmf
)
def test_jsd0():
""" Test the JSD of a distribution but with weights misspecified."""
d1 = Distribution("AB", [0.5, 0.5])
assert_raises(ditException, JSD, d1, d1)
def test_jsd1():
""" Test the JSD of a distribution with itself """
d1 = Distribution("AB", [0.5, 0.5])
jsd = JSD([d1, d1])
assert_almost_equal(jsd, 0)
def test_jsd2():
""" Test the JSD with half-overlapping distributions """
d1 = Distribution("AB", [0.5, 0.5])
d2 = Distribution("BC", [0.5, 0.5])
jsd = JSD([d1, d2])
assert_almost_equal(jsd, 0.5)
def test_jsd3():
""" Test the JSD with disjoint distributions """
d1 = Distribution("AB", [0.5, 0.5])
d2 = Distribution("CD", [0.5, 0.5])
jsd = JSD([d1, d2])
assert_almost_equal(jsd, 1.0)
def test_jsd4():
""" Test the JSD with half-overlapping distributions with weights """
d1 = Distribution("AB", [0.5, 0.5])
d2 = Distribution("BC", [0.5, 0.5])
jsd = JSD([d1, d2], [0.25, 0.75])
assert_almost_equal(jsd, 0.40563906222956625)
def test_jsd5():
""" Test that JSD fails when more weights than dists are given """
d1 = Distribution("AB", [0.5, 0.5])
d2 = Distribution("BC", [0.5, 0.5])
assert_raises(ditException, JSD, [d1, d2], [0.1, 0.6, 0.3])
def test_jsd_pmf1():
""" Test the JSD of a distribution with itself """
d1 = [0.5, 0.5]
jsd = JSD_pmf([d1, d1])
assert_almost_equal(jsd, 0)
def test_jsd_pmf2():
""" Test the JSD with half-overlapping distributions """
d1 = [0.5, 0.5, 0.0]
d2 = [0.0, 0.5, 0.5]
jsd = JSD_pmf([d1, d2])
assert_almost_equal(jsd, 0.5)
def test_jsd_pmf3():
""" Test the JSD with disjoint distributions """
d1 = [0.5, 0.5, 0.0, 0.0]
d2 = [0.0, 0.0, 0.5, 0.5]
jsd = JSD_pmf([d1, d2])
assert_almost_equal(jsd, 1.0)
def test_jsd_pmf4():
""" Test the JSD with half-overlapping distributions with weights """
d1 = [0.5, 0.5, 0.0]
d2 = [0.0, 0.5, 0.5]
jsd = JSD_pmf([d1, d2], [0.25, 0.75])
assert_almost_equal(jsd, 0.40563906222956625)
def test_jsd_pmf5():
""" Test that JSD fails when more weights than dists are given """
d1 = [0.5, 0.5, 0.0]
d2 = [0.0, 0.5, 0.5]
assert_raises(ditException, JSD_pmf, [d1, d2], [0.1, 0.6, 0.2, 0.1])
| 30.928571 | 73 | 0.624326 | 432 | 2,598 | 3.631944 | 0.157407 | 0.050988 | 0.043977 | 0.048439 | 0.807521 | 0.758445 | 0.738687 | 0.674952 | 0.590822 | 0.463352 | 0 | 0.107108 | 0.209392 | 2,598 | 83 | 74 | 31.301205 | 0.656767 | 0.243264 | 0 | 0.482143 | 0 | 0 | 0.010571 | 0 | 0 | 0 | 0 | 0 | 0.214286 | 1 | 0.196429 | false | 0 | 0.071429 | 0 | 0.267857 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 1 | 1 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 3 |
6506db5995970d6837a7164f54f13ccdaecfc008 | 1,651 | py | Python | steampipe_alchemy/models/aws_route53_resolver_rule.py | RyanJarv/steampipe_alchemy | c8a31303252c1bd8d83d0f9c429d7d0ef7e1690f | [
"BSD-3-Clause"
] | 9 | 2021-04-21T04:21:01.000Z | 2021-06-19T19:33:36.000Z | steampipe_alchemy/models/aws_route53_resolver_rule.py | RyanJarv/steampipe_alchemy | c8a31303252c1bd8d83d0f9c429d7d0ef7e1690f | [
"BSD-3-Clause"
] | null | null | null | steampipe_alchemy/models/aws_route53_resolver_rule.py | RyanJarv/steampipe_alchemy | c8a31303252c1bd8d83d0f9c429d7d0ef7e1690f | [
"BSD-3-Clause"
] | 1 | 2021-04-26T21:08:20.000Z | 2021-04-26T21:08:20.000Z | from sqlalchemy import Column
from sqlalchemy.types import JSON, Text, Boolean, TIMESTAMP, BigInteger
from sqlalchemy.dialects import postgresql as psql
from steampipe_alchemy.mixins import FormatMixins
from steampipe_alchemy import Base
class AwsRoute53ResolverRule(Base, FormatMixins):
__tablename__ = 'aws_route53_resolver_rule'
tags = Column('tags', JSON, nullable=True)
akas = Column('akas', JSON, nullable=True)
target_ips = Column('target_ips', JSON, nullable=True)
tags_src = Column('tags_src', JSON, nullable=True)
resolver_rule_associations = Column('resolver_rule_associations', JSON, nullable=True)
domain_name = Column('domain_name', Text, nullable=True)
owner_id = Column('owner_id', Text, nullable=True)
resolver_endpoint_id = Column('resolver_endpoint_id', Text, nullable=True)
rule_type = Column('rule_type', Text, nullable=True)
share_status = Column('share_status', Text, nullable=True)
status_message = Column('status_message', Text, nullable=True)
creation_time = Column('creation_time', Text, nullable=True)
modification_time = Column('modification_time', Text, nullable=True)
title = Column('title', Text, nullable=True)
partition = Column('partition', Text, nullable=True)
region = Column('region', Text, nullable=True)
name = Column('name', Text, nullable=True)
account_id = Column('account_id', Text, nullable=True)
id = Column('id', Text, nullable=True)
arn = Column('arn', Text, primary_key=True, nullable=True)
status = Column('status', Text, nullable=True)
creator_request_id = Column('creator_request_id', Text, nullable=True) | 53.258065 | 90 | 0.740763 | 207 | 1,651 | 5.705314 | 0.2657 | 0.223539 | 0.216765 | 0.076207 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0.002827 | 0.142944 | 1,651 | 31 | 91 | 53.258065 | 0.831802 | 0 | 0 | 0 | 0 | 0 | 0.1477 | 0.030872 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | false | 0 | 0.172414 | 0 | 1 | 0 | 0 | 0 | 0 | null | 1 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 3 |
650d548dfcf197b677b3b51c6953dea2bc1cb40b | 305 | py | Python | codes/Ex036.py | BelfortJoao/Curso-phyton01 | 79376233be228f39bf548f90b8d9bd5419ac067a | [
"MIT"
] | 3 | 2021-08-17T14:02:14.000Z | 2021-08-19T02:37:30.000Z | codes/Ex036.py | BelfortJoao/Curso-phyton01 | 79376233be228f39bf548f90b8d9bd5419ac067a | [
"MIT"
] | null | null | null | codes/Ex036.py | BelfortJoao/Curso-phyton01 | 79376233be228f39bf548f90b8d9bd5419ac067a | [
"MIT"
] | null | null | null | x = float(input('Qual o valor da casa que quer comprar? '))
y = int(input("em quantos anos quer comprar a casa? "))
z = int(input("Qual seu salario? "))
w = y*12
if x / w > (z/100)*30:
print("Voce não pode comprar a casa")
else:
print('Voce pode comprar a casa a parcela é de {:.2f}'.format(x/y))
| 33.888889 | 71 | 0.636066 | 58 | 305 | 3.344828 | 0.603448 | 0.123711 | 0.185567 | 0.164948 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0.032787 | 0.2 | 305 | 8 | 72 | 38.125 | 0.762295 | 0 | 0 | 0 | 0 | 0 | 0.55082 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | false | 0 | 0 | 0 | 0 | 0.25 | 0 | 0 | 0 | null | 0 | 1 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 3 |
6514ff55c2d00ee1deed3eaa7d8b92b095c218ad | 141 | py | Python | featureflags/__init__.py | enverbisevac/ff-python-server-sdk | e7c809229d13517e0bf4b28fc0a556e693c9034e | [
"Apache-2.0"
] | null | null | null | featureflags/__init__.py | enverbisevac/ff-python-server-sdk | e7c809229d13517e0bf4b28fc0a556e693c9034e | [
"Apache-2.0"
] | null | null | null | featureflags/__init__.py | enverbisevac/ff-python-server-sdk | e7c809229d13517e0bf4b28fc0a556e693c9034e | [
"Apache-2.0"
] | null | null | null | """Top-level package for Feature Flag Server SDK."""
__author__ = """Enver Bisevac"""
__email__ = "enver@bisevac.com"
__version__ = "0.1.0"
| 23.5 | 52 | 0.695035 | 19 | 141 | 4.526316 | 0.842105 | 0.27907 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0.02439 | 0.12766 | 141 | 5 | 53 | 28.2 | 0.674797 | 0.326241 | 0 | 0 | 0 | 0 | 0.393258 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | false | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 0 | null | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 3 |
65192f76bf69dd1b91580c7c3d8c5be7720e2e54 | 410 | py | Python | peerplays/blockchainobject.py | farisshajahan/python-peerplays | 260e43d39307554f5c35574fe7a6f5451a51697f | [
"MIT"
] | 10 | 2019-03-14T03:09:42.000Z | 2021-03-17T10:20:05.000Z | peerplays/blockchainobject.py | farisshajahan/python-peerplays | 260e43d39307554f5c35574fe7a6f5451a51697f | [
"MIT"
] | 8 | 2019-04-02T17:07:20.000Z | 2020-04-30T08:24:01.000Z | peerplays/blockchainobject.py | farisshajahan/python-peerplays | 260e43d39307554f5c35574fe7a6f5451a51697f | [
"MIT"
] | 4 | 2019-04-02T17:00:22.000Z | 2021-08-09T11:28:20.000Z | # -*- coding: utf-8 -*-
from .instance import BlockchainInstance
from graphenecommon.blockchainobject import (
BlockchainObject as GrapheneBlockchainObject,
BlockchainObjects as GrapheneBlockchainObjects,
ObjectCache,
)
@BlockchainInstance.inject
class BlockchainObject(GrapheneBlockchainObject):
pass
@BlockchainInstance.inject
class BlockchainObjects(GrapheneBlockchainObjects):
pass
| 22.777778 | 51 | 0.807317 | 30 | 410 | 11.033333 | 0.566667 | 0.145015 | 0.175227 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0.002801 | 0.129268 | 410 | 17 | 52 | 24.117647 | 0.92437 | 0.05122 | 0 | 0.333333 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | true | 0.166667 | 0.166667 | 0 | 0.333333 | 0 | 0 | 0 | 1 | null | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 1 | 0 | 0 | 0 | 0 | 0 | 3 |
65411b851445a48f4001d24e9d3426293a327569 | 243 | py | Python | src/data_curation/dataset_manager/views.py | NovaSBE-DSKC/retention-evaluation | 5b68b9282f0b5479a9dc5238faef68067c76b861 | [
"MIT"
] | null | null | null | src/data_curation/dataset_manager/views.py | NovaSBE-DSKC/retention-evaluation | 5b68b9282f0b5479a9dc5238faef68067c76b861 | [
"MIT"
] | null | null | null | src/data_curation/dataset_manager/views.py | NovaSBE-DSKC/retention-evaluation | 5b68b9282f0b5479a9dc5238faef68067c76b861 | [
"MIT"
] | null | null | null | from src.data_curation.dataset_manager import get_meta
import pandas as pd
def view_all():
return get_meta()
def get_docs(id):
df = get_meta()
docs = df[df["id"] == id]["docs"].iloc[0]
df = pd.read_json(docs)
return df
| 17.357143 | 54 | 0.654321 | 41 | 243 | 3.682927 | 0.560976 | 0.139073 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0.005208 | 0.209877 | 243 | 13 | 55 | 18.692308 | 0.78125 | 0 | 0 | 0 | 0 | 0 | 0.024691 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0.222222 | false | 0 | 0.222222 | 0.111111 | 0.666667 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 0 | 1 | 1 | 0 | 0 | 3 |
654ad9f66cc00d76dc7800cff09e9d14c95e20e3 | 2,259 | py | Python | tpdatasrc/tpgamefiles/rules/char_class/class020_archmage.py | edoipi/TemplePlus | f0e552289822fea908f16daa379fa568b1bd286d | [
"MIT"
] | null | null | null | tpdatasrc/tpgamefiles/rules/char_class/class020_archmage.py | edoipi/TemplePlus | f0e552289822fea908f16daa379fa568b1bd286d | [
"MIT"
] | null | null | null | tpdatasrc/tpgamefiles/rules/char_class/class020_archmage.py | edoipi/TemplePlus | f0e552289822fea908f16daa379fa568b1bd286d | [
"MIT"
] | null | null | null | from toee import *
import char_class_utils
###################################################
def GetConditionName():
return "Archmage"
def GetSpellCasterConditionName():
return "Archmage Spellcasting"
def GetCategory():
return "Core 3.5 Ed Prestige Classes"
def GetClassDefinitionFlags():
return CDF_CoreClass
def GetClassHelpTopic():
return "TAG_ARCHMAGES"
classEnum = stat_level_archmage
###################################################
class_feats = {
}
class_skills = (skill_alchemy, skill_concentration, skill_craft, skill_knowledge_all, skill_profession, skill_search, skill_spellcraft)
def IsEnabled():
return 1
def GetHitDieType():
return 4
def GetSkillPtsPerLevel():
return 2
def GetBabProgression():
return base_attack_bonus_type_non_martial
def IsFortSaveFavored():
return 0
def IsRefSaveFavored():
return 0
def IsWillSaveFavored():
return 1
def GetSpellListType():
return spell_list_type_arcane
def GetSpellSourceType():
return spell_source_type_arcane
def IsClassSkill(skillEnum):
return char_class_utils.IsClassSkill(class_skills, skillEnum)
def IsClassFeat(featEnum):
return char_class_utils.IsClassFeat(class_feats, featEnum)
def GetClassFeats():
return class_feats
def IsAlignmentCompatible( alignment):
return 1
def CanCastArcaneLvl7(obj):
# TODO: generalize (to support other arcane classes)
if obj.stat_level_get(stat_level_sorcerer) >= 14:
return 1
if obj.stat_level_get(stat_level_wizard) >= 13:
return 1
def HasSpellFocusInTwoSchool( obj ):
sf1 = 0
for p in range(feat_spell_focus_abjuration, feat_spell_focus_transmutation+1):
if obj.has_feat(p):
sf1 = p
break
if sf1 == 0:
return 0
sf2 = 0
for p in range(feat_spell_focus_abjuration, feat_spell_focus_transmutation+1):
if obj.has_feat(p) and p != sf1:
sf2 = p
break
if sf2 == 0:
return 0
return 1
def ObjMeetsPrereqs( obj ):
return 0 # WIP
# skill ranks (only Disable Device since Escape Artist, Decipher Script and Knowledge Arcana aren't implemented in ToEE)
if obj.skill_ranks_get(skill_spellcraft) < 15:
return 0
if (not obj.has_feat(feat_skill_focus_spellcraft)):
return 0
if (not CanCastArcaneLvl7(obj)):
return 0
if (not HasSpellFocusInTwoSchool(obj)):
return 0
return 1 | 20.916667 | 135 | 0.736609 | 292 | 2,259 | 5.482877 | 0.386986 | 0.03935 | 0.03123 | 0.022486 | 0.12867 | 0.12867 | 0.12867 | 0.09619 | 0.09619 | 0.09619 | 0 | 0.021211 | 0.144312 | 2,259 | 108 | 136 | 20.916667 | 0.807036 | 0.076583 | 0 | 0.27027 | 0 | 0 | 0.035336 | 0 | 0 | 0 | 0 | 0.009259 | 0 | 1 | 0.283784 | false | 0 | 0.027027 | 0.243243 | 0.702703 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 0 | 1 | 1 | 0 | 0 | 3 |
e8df842f0c6982487b7ca3ace562a894cc9d1940 | 606 | py | Python | exposures/generate_passwords.py | jarnoln/exposures | bbae3f79078048d25b77e178db6c0801ffe9f97e | [
"MIT"
] | null | null | null | exposures/generate_passwords.py | jarnoln/exposures | bbae3f79078048d25b77e178db6c0801ffe9f97e | [
"MIT"
] | null | null | null | exposures/generate_passwords.py | jarnoln/exposures | bbae3f79078048d25b77e178db6c0801ffe9f97e | [
"MIT"
] | null | null | null | #!/usr/bin/env python
import random
import argparse
def generate_passwords(password_file_path):
password_file = open(password_file_path, 'w')
chars = 'abcdefghijklmnopqrstuvxyz01234567890_-!*'
secret_key = ''.join(random.SystemRandom().choice(chars) for _ in range(50))
password_file.write("SECRET_KEY = '%s'\n" % secret_key)
password_file.close()
if __name__ == '__main__':
parser = argparse.ArgumentParser()
parser.add_argument('password_file_path', help='Where password file will be placed')
args = parser.parse_args()
generate_passwords(args.password_file_path)
| 31.894737 | 88 | 0.737624 | 75 | 606 | 5.586667 | 0.586667 | 0.229117 | 0.152745 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0.025 | 0.141914 | 606 | 18 | 89 | 33.666667 | 0.780769 | 0.033003 | 0 | 0 | 1 | 0 | 0.205128 | 0.068376 | 0 | 0 | 0 | 0 | 0 | 1 | 0.076923 | false | 0.461538 | 0.153846 | 0 | 0.230769 | 0 | 0 | 0 | 0 | null | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 0 | 0 | 0 | 3 |
330000bbbc4cd1509f76a97c2471648387f8c603 | 332 | py | Python | src/data/dbConnection.py | leonardoleyva/api-agenda-uas | 697740a0a3feebb2ada01133db020fcf5127e1de | [
"MIT"
] | 1 | 2022-03-13T02:28:29.000Z | 2022-03-13T02:28:29.000Z | src/data/dbConnection.py | leonardoleyva/api-agenda-uas | 697740a0a3feebb2ada01133db020fcf5127e1de | [
"MIT"
] | null | null | null | src/data/dbConnection.py | leonardoleyva/api-agenda-uas | 697740a0a3feebb2ada01133db020fcf5127e1de | [
"MIT"
] | null | null | null | from firebase_admin import firestore
from google.cloud.firestore_v1.base_client import BaseClient
from ..core.app import App
class DBConnection(App):
def __init__(self) -> None:
super().__init__()
self.__db: BaseClient = firestore.client()
def getDBInstance(self) -> BaseClient:
return self.__db
| 23.714286 | 60 | 0.710843 | 40 | 332 | 5.525 | 0.575 | 0.072398 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0.003745 | 0.195783 | 332 | 13 | 61 | 25.538462 | 0.82397 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0.222222 | false | 0 | 0.333333 | 0.111111 | 0.777778 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 1 | 1 | 0 | 0 | 0 | 3 |
331719a2a5a244761348d8660d5c741b1f74d90f | 2,921 | py | Python | tests/test1.py | pedroramaciotti/Cloudtropy | bce1cc1cd6c5217ac20cf5a98491d10c6a8905b2 | [
"MIT"
] | null | null | null | tests/test1.py | pedroramaciotti/Cloudtropy | bce1cc1cd6c5217ac20cf5a98491d10c6a8905b2 | [
"MIT"
] | null | null | null | tests/test1.py | pedroramaciotti/Cloudtropy | bce1cc1cd6c5217ac20cf5a98491d10c6a8905b2 | [
"MIT"
] | 1 | 2021-03-10T14:04:04.000Z | 2021-03-10T14:04:04.000Z | import numpy as np
import matplotlib.pyplot as plt
from mpl_toolkits import mplot3d
# from scipy.stats import entropy
import sys
sys.path.append('../')
import cloudtropy
# data
gen_dim = 2
gen_N = 300
lims = (-2,6)
scale = 0.2
X = np.random.uniform(low=lims[0],high=lims[1],size=(10000,2)) # background
X = np.concatenate([X,scale*np.random.randn(gen_N,gen_dim)+np.array([0,0])] )
X = np.concatenate([X,scale*np.random.randn(gen_N,gen_dim)+np.array([4,0])] )
X = np.concatenate([X,scale*np.random.randn(gen_N,gen_dim)+np.array([0,4])] )
X = np.concatenate([X,scale*np.random.randn(gen_N,gen_dim)+np.array([4,4])] )
# input parameters
N_grid = 80
delta_c = 0.35
# grid,pmf = cloudtropy.pmf(X,N=N_grid,delta_c=delta_c,lims=[(-2,6),(-2,6)])
grid,pmf = cloudtropy.pmf(X,d=0.1,delta_c=delta_c,lims=[(-2,6),(-2,6)])
entropy = cloudtropy.entropy(X,base=2,N=N_grid,delta_c=delta_c,lims=[(-3,7),(-3,7)])
print(cloudtropy.entropy(X,base=2,d=0.1,delta_c=delta_c,lims=[(-3,7),(-3,7)]))
############## All in one
fig = plt.figure(figsize=(14,3))
#
ax1 = fig.add_subplot(1,4,1)
# levels = np.linspace(0,flat_pmf.max(),40)
ax1.scatter(X[:,0], X[:,1],s=1,alpha=0.1,color='k')
ax1.set_xlabel('x'),ax1.set_ylabel('y')
ax1.set_xlim(lims),ax1.set_xlim(lims)
ax1.axis('equal')
#
ax2 = fig.add_subplot(1,3,2,projection='3d')
ax2.plot_surface(grid[0], grid[1], pmf,cmap='coolwarm', edgecolor='none',shade='interp')
ax2.set_xlabel('x'),ax2.set_ylabel('y')#,ax.set_zlabel('PMF',rotation=90)
ax2.view_init(elev=60, azim=-45)
#
ax3 = fig.add_subplot(1,3,3)
cs = ax3.contourf(grid[0], grid[1], pmf, levels=np.linspace(0,pmf.max(),40), cmap='Purples_r')
ax3.set_xlabel('x'),ax3.set_ylabel('y')
ax3.set_title('Entropy = %.3f'%entropy)
ax3.set_xlim(lims),ax3.set_xlim(lims),
ax3.axis('equal')
cbar = fig.colorbar(cs)
#
plt.tight_layout()
# plt.savefig('all.pdf')
plt.savefig('all.png',dpi=400)
############## Separate
fig = plt.figure(figsize=(4,3))
#
ax1 = fig.add_subplot(1,1,1)
# levels = np.linspace(0,flat_pmf.max(),40)
ax1.scatter(X[:,0], X[:,1],s=1,alpha=0.1,color='k')
ax1.set_xlabel('x'),ax1.set_ylabel('y')
ax1.set_xlim(lims),ax1.set_xlim(lims)
ax1.axis('equal')
plt.savefig('scatter.png',dpi=400)
#
fig = plt.figure(figsize=(4,3))
#
ax2 = fig.add_subplot(1,1,1,projection='3d')
ax2.plot_surface(grid[0], grid[1], pmf,cmap='coolwarm', edgecolor='none',shade='interp')
ax2.set_xlabel('x'),ax2.set_ylabel('y')#,ax.set_zlabel('PMF',rotation=90)
ax2.view_init(elev=60, azim=-45)
plt.savefig('surf.png',dpi=400)
#
fig = plt.figure(figsize=(4,3))
#
ax3 = fig.add_subplot(1,1,1)
cs = ax3.contourf(grid[0], grid[1], pmf, levels=np.linspace(0,pmf.max(),40), cmap='Purples_r')
# ax3.set_xlabel('x'),ax3.set_ylabel('y')
# ax3.set_title('Entropy = %.3f'%entropy)
ax3.set_xlim(lims),ax3.set_xlim(lims),
ax3.axis('equal')
cbar = fig.colorbar(cs)
#
plt.tight_layout()
# plt.savefig('all.pdf')
plt.savefig('contour_simple.png',dpi=400)
| 27.819048 | 94 | 0.680589 | 553 | 2,921 | 3.479204 | 0.220615 | 0.031185 | 0.045738 | 0.043659 | 0.808212 | 0.740644 | 0.694387 | 0.694387 | 0.685031 | 0.612266 | 0 | 0.065556 | 0.075659 | 2,921 | 104 | 95 | 28.086538 | 0.647037 | 0.148922 | 0 | 0.45 | 0 | 0 | 0.062114 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | false | 0 | 0.083333 | 0 | 0.083333 | 0.016667 | 0 | 0 | 0 | null | 0 | 0 | 0 | 1 | 1 | 0 | 0 | 0 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 3 |
331dc380a0542f7715a2dea44ae9eaa75a2bf837 | 193 | py | Python | RecoLocalCalo/HGCalRecProducers/python/HeterogeneousHEBRecHitGPUtoSoA_cfi.py | Purva-Chaudhari/cmssw | 32e5cbfe54c4d809d60022586cf200b7c3020bcf | [
"Apache-2.0"
] | 852 | 2015-01-11T21:03:51.000Z | 2022-03-25T21:14:00.000Z | RecoLocalCalo/HGCalRecProducers/python/HeterogeneousHEBRecHitGPUtoSoA_cfi.py | Purva-Chaudhari/cmssw | 32e5cbfe54c4d809d60022586cf200b7c3020bcf | [
"Apache-2.0"
] | 30,371 | 2015-01-02T00:14:40.000Z | 2022-03-31T23:26:05.000Z | RecoLocalCalo/HGCalRecProducers/python/HeterogeneousHEBRecHitGPUtoSoA_cfi.py | Purva-Chaudhari/cmssw | 32e5cbfe54c4d809d60022586cf200b7c3020bcf | [
"Apache-2.0"
] | 3,240 | 2015-01-02T05:53:18.000Z | 2022-03-31T17:24:21.000Z | import FWCore.ParameterSet.Config as cms
HEBRecHitGPUtoSoAProd = cms.EDProducer('HEBRecHitGPUtoSoA',
HEBRecHitGPUTok = cms.InputTag('HEBRecHitGPUProd'))
| 38.6 | 90 | 0.663212 | 14 | 193 | 9.142857 | 0.857143 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0.259067 | 193 | 4 | 91 | 48.25 | 0.895105 | 0 | 0 | 0 | 0 | 0 | 0.170984 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | false | 0 | 0.333333 | 0 | 0.333333 | 0 | 1 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 0 | 0 | 3 |
33270a402f92d2ec94e2db647e7c5d239b6f78fe | 3,733 | py | Python | temboo/core/Library/LittleSis/Relationship/GetOneRelationship.py | jordanemedlock/psychtruths | 52e09033ade9608bd5143129f8a1bfac22d634dd | [
"Apache-2.0"
] | 7 | 2016-03-07T02:07:21.000Z | 2022-01-21T02:22:41.000Z | temboo/core/Library/LittleSis/Relationship/GetOneRelationship.py | jordanemedlock/psychtruths | 52e09033ade9608bd5143129f8a1bfac22d634dd | [
"Apache-2.0"
] | null | null | null | temboo/core/Library/LittleSis/Relationship/GetOneRelationship.py | jordanemedlock/psychtruths | 52e09033ade9608bd5143129f8a1bfac22d634dd | [
"Apache-2.0"
] | 8 | 2016-06-14T06:01:11.000Z | 2020-04-22T09:21:44.000Z | # -*- coding: utf-8 -*-
###############################################################################
#
# GetOneRelationship
# Retrieves information about any known relationship between two entities in LittleSis according their IDs.
#
# Python versions 2.6, 2.7, 3.x
#
# Copyright 2014, Temboo 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,
# software distributed under the License is distributed on an
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND,
# either express or implied. See the License for the specific
# language governing permissions and limitations under the License.
#
#
###############################################################################
from temboo.core.choreography import Choreography
from temboo.core.choreography import InputSet
from temboo.core.choreography import ResultSet
from temboo.core.choreography import ChoreographyExecution
import json
class GetOneRelationship(Choreography):
def __init__(self, temboo_session):
"""
Create a new instance of the GetOneRelationship Choreo. A TembooSession object, containing a valid
set of Temboo credentials, must be supplied.
"""
super(GetOneRelationship, self).__init__(temboo_session, '/Library/LittleSis/Relationship/GetOneRelationship')
def new_input_set(self):
return GetOneRelationshipInputSet()
def _make_result_set(self, result, path):
return GetOneRelationshipResultSet(result, path)
def _make_execution(self, session, exec_id, path):
return GetOneRelationshipChoreographyExecution(session, exec_id, path)
class GetOneRelationshipInputSet(InputSet):
"""
An InputSet with methods appropriate for specifying the inputs to the GetOneRelationship
Choreo. The InputSet object is used to specify input parameters when executing this Choreo.
"""
def set_APIKey(self, value):
"""
Set the value of the APIKey input for this Choreo. ((required, string) The API Key obtained from LittleSis.org.)
"""
super(GetOneRelationshipInputSet, self)._set_input('APIKey', value)
def set_EntityIDs(self, value):
"""
Set the value of the EntityIDs input for this Choreo. ((required, string) The IDs of the entities between which you want to find relationships. Format is a semicolon delimited string (e.g. 1026;1))
"""
super(GetOneRelationshipInputSet, self)._set_input('EntityIDs', value)
def set_ResponseFormat(self, value):
"""
Set the value of the ResponseFormat input for this Choreo. ((optional, string) Format of the response returned by LittleSis.org. Acceptable inputs: xml or json. Defaults to xml)
"""
super(GetOneRelationshipInputSet, self)._set_input('ResponseFormat', value)
class GetOneRelationshipResultSet(ResultSet):
"""
A ResultSet with methods tailored to the values returned by the GetOneRelationship Choreo.
The ResultSet object is used to retrieve the results of a Choreo execution.
"""
def getJSONFromString(self, str):
return json.loads(str)
def get_Response(self):
"""
Retrieve the value for the "Response" output from this Choreo execution. (The response from LittleSis.org.)
"""
return self._output.get('Response', None)
class GetOneRelationshipChoreographyExecution(ChoreographyExecution):
def _make_result_set(self, response, path):
return GetOneRelationshipResultSet(response, path)
| 40.139785 | 205 | 0.699437 | 436 | 3,733 | 5.912844 | 0.385321 | 0.013576 | 0.021722 | 0.040341 | 0.171451 | 0.056245 | 0.056245 | 0 | 0 | 0 | 0 | 0.006246 | 0.185106 | 3,733 | 92 | 206 | 40.576087 | 0.841223 | 0.4854 | 0 | 0 | 0 | 0 | 0.055063 | 0.031646 | 0 | 0 | 0 | 0 | 0 | 1 | 0.344828 | false | 0 | 0.172414 | 0.172414 | 0.862069 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 0 | 1 | 1 | 0 | 0 | 3 |
3327fef21614dc3511498e572fb63b8ff5adf0a3 | 9,385 | py | Python | rec_to_nwb/test/processing/tools/test_beartype.py | jihyunbak/rec_to_nwb | 6e65f8bf0a4faa4d986483ec2442ba19d70c92a9 | [
"Apache-2.0"
] | 8 | 2020-05-29T13:48:35.000Z | 2021-11-19T04:24:48.000Z | rec_to_nwb/test/processing/tools/test_beartype.py | jihyunbak/rec_to_nwb | 6e65f8bf0a4faa4d986483ec2442ba19d70c92a9 | [
"Apache-2.0"
] | 12 | 2020-11-13T01:36:32.000Z | 2022-01-23T20:35:55.000Z | rec_to_nwb/test/processing/tools/test_beartype.py | jihyunbak/rec_to_nwb | 6e65f8bf0a4faa4d986483ec2442ba19d70c92a9 | [
"Apache-2.0"
] | 3 | 2020-10-20T06:52:45.000Z | 2021-07-06T23:00:53.000Z | #!/usr/bin/env python3
"""
`py.test`-driven unit test suite for the `@beartype` decorator, implementing a
rudimentary subset of PEP 484-style type checking based on Python 3.x function
annotations.
Usage
----------
These tests assume the `@beartype` decorator and all utility functions (e.g.,
`_check_type_annotation()`) and globals (e.g., `_PARAMETER_KIND_IGNORED`)
required by this decorator to reside in a top-level module named `beartype`. If
this is the case, these tests may be run as is with:
$ py.test -k test_beartype
See Also
----------
https://stackoverflow.com/a/37961120/2809027
Stackoverflow answer introducing the `@beartype` decorator.
"""
from unittest import TestCase
import typing
import pytest
from testfixtures import should_raise
from rec_to_nwb.processing.tools.beartype.beartype import beartype
class TestBearyype(TestCase):
def test_beartype_noop(self) -> None:
"""
Test bear typing of a function with no function annotations, reducing to
_no_ type checking.
"""
# Unannotated function to be type checked.
@beartype
def khorne(gork, mork):
return gork + mork
# Call this function and assert the expected return value.
assert khorne('WAAAGH!', '!HGAAAW') == 'WAAAGH!!HGAAAW'
# ....................{ TESTS ~ pass : param }....................
def test_beartype_pass_param_keyword_and_positional(self) -> None:
"""
Test bear typing of a function call successfully passed both annotated
positional and keyword parameters.
"""
# Function to be type checked.
@beartype
def slaanesh(daemonette: str, keeper_of_secrets: str) -> str:
return daemonette + keeper_of_secrets
# Call this function with both positional and keyword arguments and assert
# the expected return value.
assert slaanesh(
'Seeker of Decadence', keeper_of_secrets="N'Kari") == (
"Seeker of DecadenceN'Kari")
def test_beartype_pass_param_keyword_only(self) -> None:
"""
Test bear typing of a function call successfully passed an annotated
keyword-only parameter following an `*` or `*args` parameter.
"""
# Function to be type checked.
@beartype
def changer_of_ways(sky_shark: str, *, chaos_spawn: str) -> str:
return sky_shark + chaos_spawn
# Call this function with keyword arguments and assert the expected return
# value.
assert changer_of_ways(
'Screamers', chaos_spawn="Mith'an'driarkh") == (
"ScreamersMith'an'driarkh")
def test_beartype_pass_param_tuple(self) -> None:
"""
Test bear typing of a function call successfully passed a parameter
annotated as a tuple.
"""
# Function to be type checked.
@beartype
def genestealer(tyranid: str, hive_fleet: (str, int)) -> str:
return tyranid + str(hive_fleet)
# Call this function with each of the two types listed in the above tuple.
assert genestealer(
'Norn-Queen', hive_fleet='Behemoth') == 'Norn-QueenBehemoth'
assert genestealer(
'Carnifex', hive_fleet=0xDEADBEEF) == 'Carnifex3735928559'
def test_type_check_pass_param_custom(self) -> None:
"""
Test bear typing of a function call successfully passed a parameter
annotated as a user-defined rather than builtin type.
"""
# User-defined type.
class CustomTestStr(str):
pass
# Function to be type checked.
@beartype
def hrud(gugann: str, delphic_plague: CustomTestStr) -> str:
return gugann + delphic_plague
# Call this function with each of the two types listed in the above tuple.
assert hrud(
'Troglydium hruddi', delphic_plague=CustomTestStr('Delphic Sink')) == (
'Troglydium hruddiDelphic Sink')
def test_type_check_pass_typing_module(self) -> None:
"""
Test bear typing of a function call successfully passed a parameter
annotated with an abstract type from the typing module.
"""
MyMap = typing.Mapping
@beartype
def function(par: MyMap, ameter: MyMap) -> MyMap:
result = par.copy()
result.update(ameter)
return result
assert function({1:1}, {2:2}) == {1:1, 2:2}
def test_type_check_pass_parameterized_typing_module(self) -> None:
"""
Test bear typing of a function call successfully passed a parameter
annotated with a parametirized abstract type from the typing module.
"""
MyMap = typing.Mapping
@beartype
def function(par: MyMap, ameter: MyMap) -> MyMap:
result = par.copy()
result.update(ameter)
return result
assert function({1:1}, {2:2}) == {1:1, 2:2}
# ....................{ TESTS ~ pass : return }....................
def test_type_check_pass_return_none(self) -> None:
"""
Test bear typing of a function call successfully returning `None` and
annotated as such.
"""
# Function to be type checked.
@beartype
def xenos(interex: str, diasporex: str) -> None:
interex + diasporex
# Call this function and assert no value to be returned.
assert xenos(
'Luna Wolves', diasporex='Iron Hands Legion') is None
# ....................{ TESTS ~ fail }....................
def test_beartype_fail_keyword_unknown(self) -> None:
"""
Test bear typing of an annotated function call passed an unrecognized
keyword parameter.
"""
# Annotated function to be type checked.
@beartype
def tau(kroot: str, vespid: str) -> str:
return kroot + vespid
# Call this function with an unrecognized keyword parameter and assert the
# expected exception.
with pytest.raises(TypeError) as exception:
tau(kroot='Greater Good', nicassar='Dhow')
# For readability, this should be a "TypeError" synopsizing the exact issue
# raised by the Python interpreter on calling the original function rather
# than a "TypeError" failing to synopsize the exact issue raised by the
# wrapper type-checking the original function. Since the function
# annotations defined above guarantee that the exception message of the
# latter will be suffixed by "not a str", ensure this is *NOT* the case.
assert not str(exception.value).endswith('not a str')
def test_beartype_fail_param_name(self) -> None:
"""
Test bear typing of a function accepting a parameter name reserved for
use by the `@beartype` decorator.
"""
# Define a function accepting a reserved parameter name and assert the
# expected exception.
@beartype
@should_raise(NameError)
def jokaero(weaponsmith: str, __beartype_func: str) -> str:
return weaponsmith + __beartype_func
# ....................{ TESTS ~ fail : type }....................
def test_beartype_fail_param_type(self) -> None:
"""
Test bear typing of an annotated function call failing a parameter type
check.
"""
# Annotated function to be type checked.
@beartype
def eldar(isha: str, asuryan: (str, int)) -> str:
return isha + asuryan
# Call this function with an invalid type and assert the expected exception.
with pytest.raises(TypeError):
eldar('Mother of the Eldar', 100.100)
def test_beartype_fail_return_type(self) -> None:
"""
Test bear typing of an annotated function call failing a return type
check.
"""
# Annotated function to be type checked.
@beartype
def necron(star_god: str, old_one: str) -> str:
return 60e6
# Call this function and assert the expected exception.
with pytest.raises(TypeError):
necron("C'tan", 'Elder Thing')
# ....................{ TESTS ~ fail : annotation }....................
def test_beartype_fail_annotation_param(self) -> None:
"""
Test bear typing of a function with an unsupported parameter annotation.
"""
# Assert the expected exception from attempting to type check a function
# with a parameter annotation that is *NOT* a type.
with pytest.raises(TypeError):
@beartype
def nurgle(nurgling: str, great_unclean_one: 'Bringer of Poxes') -> str:
return nurgling + great_unclean_one
def test_beartype_fail_annotation_return(self) -> None:
"""
Test bear typing of a function with an unsupported return annotation.
"""
# Assert the expected exception from attempting to type check a function
# with a return annotation that is *NOT* a type.
with pytest.raises(TypeError):
@beartype
def tzeentch(disc: str, lord_of_change: str) -> 'Player of Games':
return disc + lord_of_change
| 36.235521 | 84 | 0.613213 | 1,098 | 9,385 | 5.138434 | 0.247723 | 0.01737 | 0.029777 | 0.039702 | 0.468983 | 0.414392 | 0.394895 | 0.346508 | 0.333038 | 0.278979 | 0 | 0.008391 | 0.288865 | 9,385 | 258 | 85 | 36.375969 | 0.836979 | 0.444113 | 0 | 0.326531 | 0 | 0 | 0.07681 | 0.005051 | 0 | 0 | 0.002104 | 0 | 0.102041 | 1 | 0.285714 | false | 0.081633 | 0.05102 | 0.112245 | 0.489796 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 1 | 0 | 1 | 0 | 0 | 0 | 3 |
3339f7cf782a2803830764348c1674b391c59c54 | 113 | py | Python | DigitalMeLib/servers/gedis/GedisProcessManager.py | jdelrue/digital_me | e5c92c405c0cea419ce18d25863f35d1bfe5a428 | [
"Apache-2.0"
] | null | null | null | DigitalMeLib/servers/gedis/GedisProcessManager.py | jdelrue/digital_me | e5c92c405c0cea419ce18d25863f35d1bfe5a428 | [
"Apache-2.0"
] | 72 | 2018-08-01T06:13:46.000Z | 2019-02-01T15:50:20.000Z | DigitalMeLib/servers/gedis/GedisProcessManager.py | jdelrue/digital_me | e5c92c405c0cea419ce18d25863f35d1bfe5a428 | [
"Apache-2.0"
] | 2 | 2018-08-05T08:09:13.000Z | 2018-11-21T13:11:28.000Z | from jumpscale import j
JSBASE = j.application.jsbase_get_class()
class GedisProcessManager(JSBASE):
pass
| 14.125 | 41 | 0.778761 | 14 | 113 | 6.142857 | 0.714286 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0.150442 | 113 | 7 | 42 | 16.142857 | 0.895833 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | false | 0.25 | 0.25 | 0 | 0.5 | 0 | 1 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 0 | 0 | 0 | 3 |
333a9b81c1942bff823966256c44e46de0b7f8db | 1,753 | py | Python | install/install.py | naztronaut/FCW | e272f29dda54f8a18f9ff533de598bb0bfd29099 | [
"MIT"
] | 4 | 2021-01-03T05:54:23.000Z | 2021-08-06T19:39:04.000Z | install/install.py | naztronaut/FCW | e272f29dda54f8a18f9ff533de598bb0bfd29099 | [
"MIT"
] | 4 | 2020-10-15T17:09:31.000Z | 2022-03-26T00:46:48.000Z | install/install.py | naztronaut/FCW | e272f29dda54f8a18f9ff533de598bb0bfd29099 | [
"MIT"
] | 1 | 2021-01-17T14:12:43.000Z | 2021-01-17T14:12:43.000Z | # install.py
# Version: 1.0.0
# Installs dependencies needed for FCW
# Author: Nazmus Nasir
# Website: https://www.easyprogramming.net
import os
from shutil import copy2
def install_dependencies():
print("================== Start Installing PIP and venv ==================")
os.system("sudo apt install python3-pip python3-venv -y")
print("================== Completed Installing PIP ==================")
print("================== Start Updating PIP ==================")
os.system("sudo pip3 install --upgrade pip")
print("================== Completed Updating PIP ==================")
print("================== Start Installing Setuptools and Libatlas ==================")
os.system("sudo apt install python-setuptools libatlas-base-dev -y")
print("================== Completed Installing Setuptools and Libatlas ==================")
print("================== Start Installing Fortran ==================")
os.system("sudo apt install libatlas3-base libgfortran5 -y")
print("================== Completed Installing Fortran ==================")
print("================== Start Installing rpi_ws281x ==================")
os.system("sudo pip3 install rpi_ws281x")
print("================== Completed Installing rpi_ws281x ==================")
print("================== Start Installing Apache ==================")
os.system("sudo apt install apache2 -y")
print("================== Completed Installing Apache ==================")
print("================== Start Installing Mod WSGI ==================")
os.system("sudo apt install libapache2-mod-wsgi-py3 -y")
print("================== Completed Installing Mod WSGI ==================")
install_dependencies()
| 40.767442 | 95 | 0.503708 | 157 | 1,753 | 5.592357 | 0.350318 | 0.079727 | 0.095672 | 0.085421 | 0.177677 | 0 | 0 | 0 | 0 | 0 | 0 | 0.014521 | 0.135767 | 1,753 | 42 | 96 | 41.738095 | 0.565017 | 0.070736 | 0 | 0 | 0 | 0 | 0.738594 | 0.01418 | 0 | 0 | 0 | 0 | 0 | 1 | 0.04 | true | 0 | 0.08 | 0 | 0.12 | 0.56 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 0 | 0 | 1 | 0 | 3 |
3344e7fbcc20c1b88448cf2bc6b2cea4cf5be780 | 331 | py | Python | Part_3_advanced/m14_metaclass/register_cls/homework_1_solution/example_system/bike.py | Mikma03/InfoShareacademy_Python_Courses | 3df1008c8c92831bebf1625f960f25b39d6987e6 | [
"MIT"
] | null | null | null | Part_3_advanced/m14_metaclass/register_cls/homework_1_solution/example_system/bike.py | Mikma03/InfoShareacademy_Python_Courses | 3df1008c8c92831bebf1625f960f25b39d6987e6 | [
"MIT"
] | null | null | null | Part_3_advanced/m14_metaclass/register_cls/homework_1_solution/example_system/bike.py | Mikma03/InfoShareacademy_Python_Courses | 3df1008c8c92831bebf1625f960f25b39d6987e6 | [
"MIT"
] | null | null | null | from example_system.serializable import RegisteredSerializable
class Bike(RegisteredSerializable):
def __init__(self, brand: str, model: str) -> None:
super().__init__(brand, model)
self.brand = brand
self.model = model
def __str__(self) -> str:
return f"Bike: {self.brand} {self.model}"
| 27.583333 | 62 | 0.667674 | 38 | 331 | 5.473684 | 0.473684 | 0.129808 | 0.134615 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0.220544 | 331 | 11 | 63 | 30.090909 | 0.806202 | 0 | 0 | 0 | 0 | 0 | 0.093656 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0.25 | false | 0 | 0.125 | 0.125 | 0.625 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 0 | 1 | 1 | 0 | 0 | 3 |
334572d04bea77a18ada43a30928987b98727f24 | 107 | py | Python | authentication/authenticator.py | gabrielbazan/http_auth | 5d86669ead6beedd8d980031d09d7dedfc1033fd | [
"MIT"
] | null | null | null | authentication/authenticator.py | gabrielbazan/http_auth | 5d86669ead6beedd8d980031d09d7dedfc1033fd | [
"MIT"
] | null | null | null | authentication/authenticator.py | gabrielbazan/http_auth | 5d86669ead6beedd8d980031d09d7dedfc1033fd | [
"MIT"
] | null | null | null |
class Authenticator(object):
def authenticate(self, credentials):
raise NotImplementedError()
| 21.4 | 40 | 0.728972 | 9 | 107 | 8.666667 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0.186916 | 107 | 4 | 41 | 26.75 | 0.896552 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0.333333 | false | 0 | 0 | 0 | 0.666667 | 0 | 1 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 3 |
3349c42d9a6787f22dabc4fb2936a9e909a361bb | 121 | py | Python | EX10 dolar carteira.py | RODRIGOKTK/Python-exercicios | f7985f2c277aae8b158bdeea4f2493febaaf06c5 | [
"Unlicense"
] | null | null | null | EX10 dolar carteira.py | RODRIGOKTK/Python-exercicios | f7985f2c277aae8b158bdeea4f2493febaaf06c5 | [
"Unlicense"
] | null | null | null | EX10 dolar carteira.py | RODRIGOKTK/Python-exercicios | f7985f2c277aae8b158bdeea4f2493febaaf06c5 | [
"Unlicense"
] | null | null | null | carteira=float(input('Quanto tem na carteira: '))
dolar=3.27
print('Equivalente em dolares: %.2f ' %(carteira/dolar))
| 30.25 | 57 | 0.702479 | 17 | 121 | 5 | 0.823529 | 0.305882 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0.037736 | 0.123967 | 121 | 3 | 58 | 40.333333 | 0.764151 | 0 | 0 | 0 | 0 | 0 | 0.449153 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | false | 0 | 0 | 0 | 0 | 0.333333 | 1 | 0 | 0 | null | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 3 |
334e95ed5c389e7fbe37935a81f7aca297e6dd30 | 2,367 | py | Python | tests/factorys.py | ireneontheway5/pymilvus | b812449a98602b4370b3b3430bdeb18b24035e53 | [
"Apache-2.0"
] | null | null | null | tests/factorys.py | ireneontheway5/pymilvus | b812449a98602b4370b3b3430bdeb18b24035e53 | [
"Apache-2.0"
] | null | null | null | tests/factorys.py | ireneontheway5/pymilvus | b812449a98602b4370b3b3430bdeb18b24035e53 | [
"Apache-2.0"
] | null | null | null | # STL imports
import random
import logging
import string
import time
import datetime
import random
import struct
import sys
from functools import wraps
# Third party imports
import numpy as np
import faker
from faker.providers import BaseProvider
logging.getLogger('faker').setLevel(logging.ERROR)
sys.path.append('.')
def gen_vectors(num, dim):
return [[random.random() for _ in range(dim)] for _ in range(num)]
def gen_single_vector(dim):
return [[random.random() for _ in range(dim)]]
def gen_vector(nb, d, seed=np.random.RandomState(1234)):
xb = seed.rand(nb, d).astype("float32")
return xb.tolist()
def gen_unique_str(str=None):
prefix = "".join(random.choice(string.ascii_letters + string.digits) for _ in range(8))
return prefix if str is None else str + "_" + prefix
def get_current_day():
return time.strftime('%Y-%m-%d', time.localtime())
def get_last_day(day):
tmp = datetime.datetime.now() - datetime.timedelta(days=day)
return tmp.strftime('%Y-%m-%d')
def get_next_day(day):
tmp = datetime.datetime.now() + datetime.timedelta(days=day)
return tmp.strftime('%Y-%m-%d')
def gen_long_str(num):
string = ''
for _ in range(num):
char = random.choice('tomorrow')
string += char
class FakerProvider(BaseProvider):
def collection_name(self):
return 'collection_names' + str(random.randint(1000, 9999))
def name(self):
return 'name' + str(random.randint(1000, 9999))
def dim(self):
return random.randint(0, 999)
fake = faker.Faker()
fake.add_provider(FakerProvider)
def collection_name_factory():
return fake.collection_name()
def records_factory(dimension, nq):
return [[random.random() for _ in range(dimension)] for _ in range(nq)]
def binary_records_factory(dim, nq):
# uint8 values range is [0, 256), so we specify the high range is 256.
xnb = np.random.randint(256, size=[nq, (dim // 8)], dtype="uint8")
xb = [bytes(b) for b in xnb]
return xb
def integer_factory(nq):
return [random.randint(0, 128) for _ in range(nq)]
def time_it(func):
@wraps(func)
def inner(*args, **kwrgs):
pref = time.perf_counter()
result = func(*args, **kwrgs)
delt = time.perf_counter() - pref
print(f"[{func.__name__}][{delt:.4}s]")
return result
return inner
| 22.330189 | 91 | 0.669624 | 338 | 2,367 | 4.568047 | 0.366864 | 0.025907 | 0.051813 | 0.040803 | 0.213731 | 0.194301 | 0.141192 | 0.141192 | 0.09715 | 0.09715 | 0 | 0.02361 | 0.194761 | 2,367 | 105 | 92 | 22.542857 | 0.786464 | 0.042248 | 0 | 0.061538 | 0 | 0 | 0.044189 | 0.012815 | 0 | 0 | 0 | 0 | 0 | 1 | 0.261538 | false | 0 | 0.184615 | 0.138462 | 0.707692 | 0.015385 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 0 | 1 | 1 | 0 | 0 | 3 |
3367ac8d7631adea65a66b8a1b9f9c5b430f34ba | 335 | py | Python | src/eduid_graphdb/exceptions.py | SUNET/eduid-groupdb | c9b4631ff944211eab82595f005bc7e707142216 | [
"BSD-3-Clause"
] | 1 | 2020-09-05T03:14:37.000Z | 2020-09-05T03:14:37.000Z | src/eduid_graphdb/exceptions.py | SUNET/eduid-graphdb | c9b4631ff944211eab82595f005bc7e707142216 | [
"BSD-3-Clause"
] | null | null | null | src/eduid_graphdb/exceptions.py | SUNET/eduid-graphdb | c9b4631ff944211eab82595f005bc7e707142216 | [
"BSD-3-Clause"
] | null | null | null | # -*- coding: utf-8 -*-
__author__ = 'lundberg'
class EduIDGroupDBError(Exception):
pass
class VersionMismatch(EduIDGroupDBError):
pass
class MultipleReturnedError(EduIDGroupDBError):
pass
class MultipleUsersReturned(MultipleReturnedError):
pass
class MultipleGroupsReturned(MultipleReturnedError):
pass
| 13.958333 | 52 | 0.758209 | 25 | 335 | 10 | 0.52 | 0.144 | 0.208 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0.003559 | 0.161194 | 335 | 23 | 53 | 14.565217 | 0.886121 | 0.062687 | 0 | 0.454545 | 0 | 0 | 0.025641 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | false | 0.454545 | 0 | 0 | 0.454545 | 0 | 1 | 0 | 0 | null | 0 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 0 | 0 | 0 | 3 |
681d29014f10010799276f1e756503fc734bd148 | 21 | py | Python | portfolio/Python/scrapy/loi/__init__.py | 0--key/lib | ba7a85dda2b208adc290508ca617bdc55a5ded22 | [
"Apache-2.0"
] | null | null | null | portfolio/Python/scrapy/loi/__init__.py | 0--key/lib | ba7a85dda2b208adc290508ca617bdc55a5ded22 | [
"Apache-2.0"
] | null | null | null | portfolio/Python/scrapy/loi/__init__.py | 0--key/lib | ba7a85dda2b208adc290508ca617bdc55a5ded22 | [
"Apache-2.0"
] | 5 | 2016-03-22T07:40:46.000Z | 2021-05-30T16:12:21.000Z | ACCOUNT_NAME = 'Loi'
| 10.5 | 20 | 0.714286 | 3 | 21 | 4.666667 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0.142857 | 21 | 1 | 21 | 21 | 0.777778 | 0 | 0 | 0 | 0 | 0 | 0.142857 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | false | 0 | 0 | 0 | 0 | 0 | 1 | 1 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 3 |
681e352b042459db2c73a2cf9e2013e8047fcc1a | 600 | py | Python | tests/test_parametrized_circuit.py | mdrft/Blueqat | 878d24e2038063e32b4d391a03bc2c2be0600470 | [
"Apache-2.0"
] | 25 | 2018-09-16T22:54:48.000Z | 2019-02-22T01:21:30.000Z | tests/test_parametrized_circuit.py | mdrft/blueqat | 6c5f26b377bc3ce0d02adec8b9132d70870b3d95 | [
"Apache-2.0"
] | 22 | 2018-09-20T02:47:56.000Z | 2019-02-08T05:25:30.000Z | tests/test_parametrized_circuit.py | mdrft/blueqat | 6c5f26b377bc3ce0d02adec8b9132d70870b3d95 | [
"Apache-2.0"
] | 5 | 2018-10-23T04:56:04.000Z | 2019-02-13T14:02:31.000Z | from blueqat import Circuit, ParametrizedCircuit
def compare_circuit(c1: Circuit, c2: Circuit) -> bool:
return repr(c1) == repr(c2)
def test_parametrized1():
assert compare_circuit(
ParametrizedCircuit().ry('a')[0].rz('b')[0].subs([1.2, 3.4]),
Circuit().ry(1.2)[0].rz(3.4)[0])
def test_parametrized2():
assert compare_circuit(
ParametrizedCircuit().ry('a')[0].rz('b')[0].subs({'a': 1.2, 'b': 3.4}),
Circuit().ry(1.2)[0].rz(3.4)[0])
def test_parametrized3():
assert compare_circuit(
ParametrizedCircuit().subs([]),
Circuit()
)
| 26.086957 | 79 | 0.605 | 83 | 600 | 4.289157 | 0.325301 | 0.292135 | 0.168539 | 0.328652 | 0.432584 | 0.432584 | 0.432584 | 0.432584 | 0.432584 | 0.432584 | 0 | 0.063655 | 0.188333 | 600 | 22 | 80 | 27.272727 | 0.667351 | 0 | 0 | 0.3125 | 0 | 0 | 0.01 | 0 | 0 | 0 | 0 | 0 | 0.1875 | 1 | 0.25 | false | 0 | 0.0625 | 0.0625 | 0.375 | 0 | 0 | 0 | 0 | null | 1 | 0 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 3 |
682755414252899eae0fb1b519e05847d5ff143c | 56 | py | Python | djangoautoconf/keys_default/admin_account_template.py | weijia/djangoautoconf | 590acfdcc6a3e051a2048ba1dbf980f908a7af91 | [
"BSD-3-Clause"
] | null | null | null | djangoautoconf/keys_default/admin_account_template.py | weijia/djangoautoconf | 590acfdcc6a3e051a2048ba1dbf980f908a7af91 | [
"BSD-3-Clause"
] | null | null | null | djangoautoconf/keys_default/admin_account_template.py | weijia/djangoautoconf | 590acfdcc6a3e051a2048ba1dbf980f908a7af91 | [
"BSD-3-Clause"
] | null | null | null | admin_username = "richard"
admin_password = "richard666" | 28 | 29 | 0.803571 | 6 | 56 | 7.166667 | 0.833333 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0.058824 | 0.089286 | 56 | 2 | 29 | 28 | 0.784314 | 0 | 0 | 0 | 0 | 0 | 0.298246 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | false | 0.5 | 0 | 0 | 0 | 0 | 1 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 0 | 0 | 0 | 3 |
682eb91e753309f5167c5c3ce7b313c8b3f7ea9a | 120 | py | Python | Oefeningen/standalone/list_comprehension_4.py | Seviran/Python_3 | e30ead250129d25bbc0a7ee2f6298775b2f4529a | [
"MIT"
] | null | null | null | Oefeningen/standalone/list_comprehension_4.py | Seviran/Python_3 | e30ead250129d25bbc0a7ee2f6298775b2f4529a | [
"MIT"
] | null | null | null | Oefeningen/standalone/list_comprehension_4.py | Seviran/Python_3 | e30ead250129d25bbc0a7ee2f6298775b2f4529a | [
"MIT"
] | null | null | null |
string_input = "amazing"
vowels = "aeiou"
answer = [char for char in string_input if char not in vowels]
print(answer)
| 20 | 62 | 0.741667 | 19 | 120 | 4.578947 | 0.631579 | 0.252874 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0.166667 | 120 | 5 | 63 | 24 | 0.87 | 0 | 0 | 0 | 0 | 0 | 0.10084 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | false | 0 | 0 | 0 | 0 | 0.25 | 1 | 0 | 0 | null | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 3 |
6837cc30692c462a7a0c489ba23cd6a7b34c84cf | 402 | py | Python | db/db_connector.py | waynshang/stock_institution | 72b0374ed148f1bdb4e276422a095411ab564455 | [
"MIT"
] | 1 | 2021-05-29T11:08:09.000Z | 2021-05-29T11:08:09.000Z | db/db_connector.py | waynshang/stock_institution | 72b0374ed148f1bdb4e276422a095411ab564455 | [
"MIT"
] | 1 | 2021-08-03T12:36:46.000Z | 2021-08-03T12:36:46.000Z | db/db_connector.py | waynshang/stock_institution | 72b0374ed148f1bdb4e276422a095411ab564455 | [
"MIT"
] | null | null | null | from config import secret
from utils import getLogger
DEBUG = getLogger()
class MysqlConnection:
def __init__(self, database, server_name):
self.host = secret[server_name]['mysql']['host']
self.port = secret[server_name]['mysql']['port']
self.username = secret[server_name]['mysql']['username']
self.password = secret[server_name]['mysql']['password']
self.database = database
| 33.5 | 60 | 0.711443 | 49 | 402 | 5.653061 | 0.408163 | 0.180505 | 0.231047 | 0.303249 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0.141791 | 402 | 11 | 61 | 36.545455 | 0.802899 | 0 | 0 | 0 | 0 | 0 | 0.109453 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0.1 | false | 0.1 | 0.2 | 0 | 0.4 | 0 | 0 | 0 | 0 | null | 0 | 1 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 0 | 0 | 0 | 3 |
684188842440f0302697bdfa81cff956f82483fa | 266 | py | Python | server/medication_icons/admin.py | nickdotreid/opioid-mat-decision-aid | bbc2a0d8931d59cd6ab64b0b845e88c8dc1af5d1 | [
"MIT"
] | null | null | null | server/medication_icons/admin.py | nickdotreid/opioid-mat-decision-aid | bbc2a0d8931d59cd6ab64b0b845e88c8dc1af5d1 | [
"MIT"
] | 27 | 2018-09-30T07:59:21.000Z | 2020-11-05T19:25:41.000Z | server/medication_icons/admin.py | nickdotreid/opioid-mat-decision-aid | bbc2a0d8931d59cd6ab64b0b845e88c8dc1af5d1 | [
"MIT"
] | null | null | null | from django.contrib import admin
from imagekit.admin import AdminThumbnail
from .models import Icon
@admin.register(Icon)
class IconAdmin(admin.ModelAdmin):
list_display = ('name', 'icon_thumbnail')
icon_thumbnail = AdminThumbnail(image_field='thumbnail')
| 26.6 | 60 | 0.785714 | 32 | 266 | 6.40625 | 0.59375 | 0.126829 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0.120301 | 266 | 9 | 61 | 29.555556 | 0.876068 | 0 | 0 | 0 | 0 | 0 | 0.101504 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | false | 0 | 0.428571 | 0 | 0.857143 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 1 | 0 | 0 | 3 |
6842dd797c24725a8fb09ac24488ca4ad6bea4a3 | 245 | py | Python | dlutils/models/sklearn/classification.py | chelseajohn/dlapplication | d2eaba9077320f5a33e122b99691577fe899e1d6 | [
"Apache-2.0"
] | 2 | 2020-05-07T05:08:54.000Z | 2020-05-13T10:14:53.000Z | dlutils/models/sklearn/classification.py | chelseajohn/dlapplication | d2eaba9077320f5a33e122b99691577fe899e1d6 | [
"Apache-2.0"
] | null | null | null | dlutils/models/sklearn/classification.py | chelseajohn/dlapplication | d2eaba9077320f5a33e122b99691577fe899e1d6 | [
"Apache-2.0"
] | 3 | 2020-05-06T18:49:37.000Z | 2020-07-13T05:11:56.000Z | def getSKLearnLogisticRegression(self, regParam, dim=1):
from DLplatform.learning.batch.sklearnClassifiers import LogisticRegression
learner = LogisticRegression(regParam = regParam, dim = dim)
return learner | 49 | 83 | 0.718367 | 21 | 245 | 8.380952 | 0.714286 | 0.125 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0.005236 | 0.220408 | 245 | 5 | 84 | 49 | 0.91623 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | null | null | 0 | 0.25 | null | null | 0 | 1 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 3 |
68587aa670f83d82520736428332f2bf416f400e | 254 | py | Python | funcion_mutacion.py | J0SU3IC3/Proyecto_Algoritmo_Genetico | bcf98d335def651726b17154624c96ee3b8cfdeb | [
"BSD-2-Clause"
] | null | null | null | funcion_mutacion.py | J0SU3IC3/Proyecto_Algoritmo_Genetico | bcf98d335def651726b17154624c96ee3b8cfdeb | [
"BSD-2-Clause"
] | null | null | null | funcion_mutacion.py | J0SU3IC3/Proyecto_Algoritmo_Genetico | bcf98d335def651726b17154624c96ee3b8cfdeb | [
"BSD-2-Clause"
] | null | null | null | import random
def mutacion(indiv):
alea_1=random.randint(0,len(indiv)-1)
alea_2 = random.randint(0, len(indiv)-1)
interc_1=indiv[alea_1]
interc_2=indiv[alea_2]
indiv[alea_1] = interc_2
indiv[alea_2] = interc_1
return indiv
| 19.538462 | 44 | 0.681102 | 43 | 254 | 3.790698 | 0.302326 | 0.276074 | 0.184049 | 0.208589 | 0.613497 | 0.613497 | 0.331288 | 0.331288 | 0 | 0 | 0 | 0.068627 | 0.19685 | 254 | 12 | 45 | 21.166667 | 0.730392 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0.111111 | false | 0 | 0.111111 | 0 | 0.333333 | 0 | 0 | 0 | 0 | null | 1 | 1 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 3 |
685f6ab1c2d0c0bbd4bb81f5a339300b7344f2f1 | 258 | py | Python | placement/serializers.py | uditpd3000/SCP-Backend | 604c9040faf5652d31bf923d647684ff8f272dc7 | [
"Apache-2.0"
] | 5 | 2021-06-21T18:36:56.000Z | 2021-08-04T04:07:56.000Z | placement/serializers.py | uditpd3000/SCP-Backend | 604c9040faf5652d31bf923d647684ff8f272dc7 | [
"Apache-2.0"
] | 23 | 2021-05-31T13:41:13.000Z | 2021-07-23T08:12:17.000Z | placement/serializers.py | uditpd3000/SCP-Backend | 604c9040faf5652d31bf923d647684ff8f272dc7 | [
"Apache-2.0"
] | 30 | 2021-05-31T10:53:14.000Z | 2022-03-01T12:56:36.000Z | from rest_framework import serializers
from .models import Placement
class PlacementSerializer(serializers.ModelSerializer):
class Meta:
model = Placement
fields = ("key", "placement_name", "company", "role", "description", "deadline")
| 28.666667 | 88 | 0.72093 | 25 | 258 | 7.36 | 0.76 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0.174419 | 258 | 8 | 89 | 32.25 | 0.86385 | 0 | 0 | 0 | 0 | 0 | 0.182171 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | false | 0 | 0.333333 | 0 | 0.666667 | 0 | 1 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 0 | 0 | 3 |
6862d3264687638cc92a1818114ac16c66aeabc5 | 688 | py | Python | classifier/cal.py | EnviewFulda/SeagrassExplorer | 0f6a0e15d1ffb8220e951c52ec1634e7a0763f4e | [
"BSD-2-Clause"
] | null | null | null | classifier/cal.py | EnviewFulda/SeagrassExplorer | 0f6a0e15d1ffb8220e951c52ec1634e7a0763f4e | [
"BSD-2-Clause"
] | null | null | null | classifier/cal.py | EnviewFulda/SeagrassExplorer | 0f6a0e15d1ffb8220e951c52ec1634e7a0763f4e | [
"BSD-2-Clause"
] | null | null | null | #!/usr/bin/env python
import numpy as np
def ini():
'''initialization
Args:
Returns:
'''
pass
def accuracy(Yte_predict, Yte):
'''verification of the correct label with the predicted one
Args:
Yte_predict (list): predicted labels (by computer)
Yte (list): true labels (by human)
Returns:
accuracy (list): congruity
'''
return np.mean(Yte_predict == Yte)
def ratio(Yte_predict):
'''Percentage portion of array
Args:
Yte_predict (list): predicted labels (by computer)
Returns:
accuracy (list): relative part of the labels "1" in the array
'''
return np.mean(Yte_predict == 1)
| 16.780488 | 69 | 0.616279 | 86 | 688 | 4.860465 | 0.488372 | 0.143541 | 0.062201 | 0.086124 | 0.311005 | 0.205742 | 0.205742 | 0.205742 | 0 | 0 | 0 | 0.004032 | 0.27907 | 688 | 40 | 70 | 17.2 | 0.83871 | 0.609012 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0.428571 | false | 0.142857 | 0.142857 | 0 | 0.857143 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 1 | 0 | 0 | 1 | 0 | 0 | 3 |
686a214c567ebd3ab53753f4ce246c0fac04cd72 | 109 | py | Python | Python/Arrays/Solution.py | chessmastersan/HackerRank | 850319e6f79e7473afbb847d28edde7b2cdfc37d | [
"MIT"
] | 2 | 2019-08-07T19:58:20.000Z | 2019-08-27T00:06:09.000Z | Python/Arrays/Solution.py | chessmastersan/HackerRank | 850319e6f79e7473afbb847d28edde7b2cdfc37d | [
"MIT"
] | 1 | 2020-06-11T19:09:48.000Z | 2020-06-11T19:09:48.000Z | Python/Arrays/Solution.py | chessmastersan/HackerRank | 850319e6f79e7473afbb847d28edde7b2cdfc37d | [
"MIT"
] | 7 | 2019-08-27T00:06:11.000Z | 2021-12-11T10:01:45.000Z | #author SANKALP SAXENA
def arrays(arr):
arr.reverse()
l = numpy.array(arr, float)
return l
| 10.9 | 31 | 0.614679 | 15 | 109 | 4.466667 | 0.8 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0.275229 | 109 | 9 | 32 | 12.111111 | 0.848101 | 0.192661 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0.25 | false | 0 | 0 | 0 | 0.5 | 0 | 1 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 3 |
6892e2003fc1c2b7ef39326cbcdfaa61a234e1ef | 185 | py | Python | insights_messaging/downloaders/localfs.py | dpensi/insights-core-messaging | a964cecdf5cbb57407dae9e9208a31fc5e9318e4 | [
"Apache-2.0"
] | 6 | 2019-12-12T14:19:30.000Z | 2020-04-08T16:20:04.000Z | insights_messaging/downloaders/localfs.py | dpensi/insights-core-messaging | a964cecdf5cbb57407dae9e9208a31fc5e9318e4 | [
"Apache-2.0"
] | 14 | 2020-01-27T17:04:39.000Z | 2021-03-16T15:18:30.000Z | insights_messaging/downloaders/localfs.py | dpensi/insights-core-messaging | a964cecdf5cbb57407dae9e9208a31fc5e9318e4 | [
"Apache-2.0"
] | 13 | 2019-12-16T09:32:38.000Z | 2021-05-05T12:39:38.000Z | import os
from contextlib import contextmanager
class LocalFS:
@contextmanager
def get(self, src):
path = os.path.realpath(os.path.expanduser(src))
yield path
| 18.5 | 56 | 0.686486 | 23 | 185 | 5.521739 | 0.652174 | 0.094488 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0.232432 | 185 | 9 | 57 | 20.555556 | 0.894366 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0.142857 | false | 0 | 0.285714 | 0 | 0.571429 | 0 | 1 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 3 |
68b43353f299ef2ed5654c73d7e6db582ed331bb | 132 | py | Python | src/clarityv2/homepage/urls.py | Clarity-89/clarityv2 | 7c4af765c5473778fc0750d1505f8b5f1724e5c5 | [
"MIT"
] | null | null | null | src/clarityv2/homepage/urls.py | Clarity-89/clarityv2 | 7c4af765c5473778fc0750d1505f8b5f1724e5c5 | [
"MIT"
] | 1 | 2022-03-11T23:38:16.000Z | 2022-03-11T23:38:16.000Z | src/clarityv2/homepage/urls.py | Clarity-89/clarityv2 | 7c4af765c5473778fc0750d1505f8b5f1724e5c5 | [
"MIT"
] | null | null | null | from django.urls import path
from .views import HomepageView
urlpatterns = [
path('', HomepageView.as_view(), name='home'),
]
| 16.5 | 50 | 0.704545 | 16 | 132 | 5.75 | 0.75 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0.159091 | 132 | 7 | 51 | 18.857143 | 0.828829 | 0 | 0 | 0 | 0 | 0 | 0.030303 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | false | 0 | 0.4 | 0 | 0.4 | 0 | 1 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 0 | 0 | 3 |
d7a7c1b8bf94815da1b2a43d746bb8543d773174 | 1,106 | py | Python | Cita.py | Desquivel501/Backend_Proyecto2_IPC1 | b983682eef4bcc379f6d57bf034675bf623fb33d | [
"Apache-2.0"
] | null | null | null | Cita.py | Desquivel501/Backend_Proyecto2_IPC1 | b983682eef4bcc379f6d57bf034675bf623fb33d | [
"Apache-2.0"
] | null | null | null | Cita.py | Desquivel501/Backend_Proyecto2_IPC1 | b983682eef4bcc379f6d57bf034675bf623fb33d | [
"Apache-2.0"
] | null | null | null | class Cita:
def __init__(self,id,solicitante,fecha,hora,motivo,estado,doctor):
self.id = id
self.solicitante = solicitante
self.fecha = fecha
self.hora = hora
self.motivo = motivo
self.estado = estado
self.doctor = doctor
def getId(self):
return self.id
def getSolicitante(self):
return self.solicitante
def getFecha(self):
return self.fecha
def getHora(self):
return self.hora
def getMotivo(self):
return self.motivo
def getEstado(self):
return self.estado
def getDoctor(self):
return self.doctor
def setSolicitante(self,solicitante):
self.solicitante = solicitante
def setFecha(self,fecha):
self.fecha = fecha
def setHora(self,hora):
self.hora = hora
def setMotivo(self,motivo):
self.motivo = motivo
def setEstado(self,estado):
self.estado = estado
def setDoctor(self,doctor):
self.doctor = doctor
| 20.867925 | 70 | 0.567812 | 117 | 1,106 | 5.333333 | 0.222222 | 0.112179 | 0.157051 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0.351718 | 1,106 | 53 | 71 | 20.867925 | 0.870293 | 0 | 0 | 0.342857 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0.4 | false | 0 | 0 | 0.2 | 0.628571 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 0 | 1 | 1 | 0 | 0 | 3 |
d7b71be599126f3487b3d6c940f7c879926c6044 | 1,491 | py | Python | gravityspytools/search/models.py | Gravity-Spy/gravityspytools | 23ef83e36ed934f7c39440bf43f4d5c7b7b4abb0 | [
"BSD-3-Clause"
] | 4 | 2019-03-11T12:32:24.000Z | 2020-12-01T06:31:39.000Z | gravityspytools/search/models.py | johnwick211/gravityspytools | 23ef83e36ed934f7c39440bf43f4d5c7b7b4abb0 | [
"BSD-3-Clause"
] | 19 | 2018-01-29T21:28:39.000Z | 2020-07-14T18:38:23.000Z | gravityspytools/search/models.py | johnwick211/gravityspytools | 23ef83e36ed934f7c39440bf43f4d5c7b7b4abb0 | [
"BSD-3-Clause"
] | 4 | 2018-02-02T16:47:16.000Z | 2020-12-01T06:31:49.000Z | # -*- coding: utf-8 -*-
from __future__ import unicode_literals
from django.db import models
from django.contrib.auth.models import User
from django.contrib.postgres.fields import ArrayField
# Create your models here.
"""
class NewSearch(models.Model):
SINGLEVIEW = 'similarityindex'
MULTIVIEW = 'updated_similarity_index'
DATABASE_CHOICES = (
(MULTIVIEW, 'Multiview Model'),
(SINGLEVIEW, 'Single View Model'),
)
H1 = "\'H1\'"
H1L1 = "\'H1\', \'L1\'"
H1L1V1 = "\'H1\', \'L1\', \'V1\'"
L1 = "\'L1\'"
L1V1 = "\'L1\', \'V1\'"
V1 = "\'V1\'"
IFO_CHOICES = (
(H1L1, 'H1 L1'),
(H1, 'H1'),
(H1L1V1, 'H1 L1 V1'),
(L1, 'L1'),
(L1V1, 'L1 V1'),
(V1, 'V1'),
)
database = models.ChoiceField(choices=DATABASE_CHOICES,)
howmany = models.IntegerField(label='How many similar images would you like to return', max_value=500, min_value=1)
zooid = models.CharField(label = 'This is the Zooniverse assigned random ID of the image (an integer value)', max_length=10, required=False)
imageid = models.CharField(label='The GravitySpy uniqueid (this is the 10 character hash that uniquely identifies all gravity spy images)', max_length=10, required=False)
ifo = models.ChoiceField(choices=IFO_CHOICES,)
user = models.ForeignKey(User)
new_subjects = ArrayField(models.CharField(max_length=10), blank=True)
created_at = models.DateTimeField(auto_now_add=True)
"""
| 31.723404 | 174 | 0.646546 | 184 | 1,491 | 5.130435 | 0.527174 | 0.016949 | 0.034958 | 0.025424 | 0.110169 | 0.059322 | 0.059322 | 0.059322 | 0.059322 | 0.059322 | 0 | 0.044877 | 0.207914 | 1,491 | 46 | 175 | 32.413043 | 0.754445 | 0.030852 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | true | 0 | 1 | 0 | 1 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 1 | 0 | 1 | 0 | 0 | 3 |
cc14238d3a5df01ff014ec40e1bf90f7a196fccb | 18,170 | py | Python | python/examples/kaitai/msgpack.py | carsonharmon/binaryninja-api | f7ad332ad69d370aa29cd54f4c7307da4d9173e2 | [
"MIT"
] | 1 | 2021-04-05T15:01:23.000Z | 2021-04-05T15:01:23.000Z | python/examples/kaitai/msgpack.py | carsonharmon/binaryninja-api | f7ad332ad69d370aa29cd54f4c7307da4d9173e2 | [
"MIT"
] | null | null | null | python/examples/kaitai/msgpack.py | carsonharmon/binaryninja-api | f7ad332ad69d370aa29cd54f4c7307da4d9173e2 | [
"MIT"
] | 1 | 2021-06-10T04:27:19.000Z | 2021-06-10T04:27:19.000Z | # This is a generated file! Please edit source .ksy file and use kaitai-struct-compiler to rebuild
from pkg_resources import parse_version
from .kaitaistruct import __version__ as ks_version, KaitaiStruct, KaitaiStream, BytesIO
import collections
if parse_version(ks_version) < parse_version('0.7'):
raise Exception("Incompatible Kaitai Struct Python API: 0.7 or later is required, but you have %s" % (ks_version))
class Msgpack(KaitaiStruct):
"""MessagePack (msgpack) is a system to serialize arbitrary structured
data into a compact binary stream.
.. seealso::
Source - https://github.com/msgpack/msgpack/blob/master/spec.md
"""
SEQ_FIELDS = ["b1", "int_extra", "float_32_value", "float_64_value", "str_len_8", "str_len_16", "str_len_32", "str_value", "num_array_elements_16", "num_array_elements_32", "array_elements", "num_map_elements_16", "num_map_elements_32", "map_elements"]
def __init__(self, _io, _parent=None, _root=None):
self._io = _io
self._parent = _parent
self._root = _root if _root else self
self._debug = collections.defaultdict(dict)
def _read(self):
self._debug['b1']['start'] = self._io.pos()
self.b1 = self._io.read_u1()
self._debug['b1']['end'] = self._io.pos()
self._debug['int_extra']['start'] = self._io.pos()
_on = self.b1
if _on == 211:
self.int_extra = self._io.read_s8be()
elif _on == 209:
self.int_extra = self._io.read_s2be()
elif _on == 210:
self.int_extra = self._io.read_s4be()
elif _on == 208:
self.int_extra = self._io.read_s1()
elif _on == 205:
self.int_extra = self._io.read_u2be()
elif _on == 207:
self.int_extra = self._io.read_u8be()
elif _on == 204:
self.int_extra = self._io.read_u1()
elif _on == 206:
self.int_extra = self._io.read_u4be()
self._debug['int_extra']['end'] = self._io.pos()
if self.is_float_32:
self._debug['float_32_value']['start'] = self._io.pos()
self.float_32_value = self._io.read_f4be()
self._debug['float_32_value']['end'] = self._io.pos()
if self.is_float_64:
self._debug['float_64_value']['start'] = self._io.pos()
self.float_64_value = self._io.read_f8be()
self._debug['float_64_value']['end'] = self._io.pos()
if self.is_str_8:
self._debug['str_len_8']['start'] = self._io.pos()
self.str_len_8 = self._io.read_u1()
self._debug['str_len_8']['end'] = self._io.pos()
if self.is_str_16:
self._debug['str_len_16']['start'] = self._io.pos()
self.str_len_16 = self._io.read_u2be()
self._debug['str_len_16']['end'] = self._io.pos()
if self.is_str_32:
self._debug['str_len_32']['start'] = self._io.pos()
self.str_len_32 = self._io.read_u4be()
self._debug['str_len_32']['end'] = self._io.pos()
if self.is_str:
self._debug['str_value']['start'] = self._io.pos()
self.str_value = (self._io.read_bytes(self.str_len)).decode(u"UTF-8")
self._debug['str_value']['end'] = self._io.pos()
if self.is_array_16:
self._debug['num_array_elements_16']['start'] = self._io.pos()
self.num_array_elements_16 = self._io.read_u2be()
self._debug['num_array_elements_16']['end'] = self._io.pos()
if self.is_array_32:
self._debug['num_array_elements_32']['start'] = self._io.pos()
self.num_array_elements_32 = self._io.read_u4be()
self._debug['num_array_elements_32']['end'] = self._io.pos()
if self.is_array:
self._debug['array_elements']['start'] = self._io.pos()
self.array_elements = [None] * (self.num_array_elements)
for i in range(self.num_array_elements):
if not 'arr' in self._debug['array_elements']:
self._debug['array_elements']['arr'] = []
self._debug['array_elements']['arr'].append({'start': self._io.pos()})
_t_array_elements = Msgpack(self._io)
_t_array_elements._read()
self.array_elements[i] = _t_array_elements
self._debug['array_elements']['arr'][i]['end'] = self._io.pos()
self._debug['array_elements']['end'] = self._io.pos()
if self.is_map_16:
self._debug['num_map_elements_16']['start'] = self._io.pos()
self.num_map_elements_16 = self._io.read_u2be()
self._debug['num_map_elements_16']['end'] = self._io.pos()
if self.is_map_32:
self._debug['num_map_elements_32']['start'] = self._io.pos()
self.num_map_elements_32 = self._io.read_u4be()
self._debug['num_map_elements_32']['end'] = self._io.pos()
if self.is_map:
self._debug['map_elements']['start'] = self._io.pos()
self.map_elements = [None] * (self.num_map_elements)
for i in range(self.num_map_elements):
if not 'arr' in self._debug['map_elements']:
self._debug['map_elements']['arr'] = []
self._debug['map_elements']['arr'].append({'start': self._io.pos()})
_t_map_elements = self._root.MapTuple(self._io, self, self._root)
_t_map_elements._read()
self.map_elements[i] = _t_map_elements
self._debug['map_elements']['arr'][i]['end'] = self._io.pos()
self._debug['map_elements']['end'] = self._io.pos()
class MapTuple(KaitaiStruct):
SEQ_FIELDS = ["key", "value"]
def __init__(self, _io, _parent=None, _root=None):
self._io = _io
self._parent = _parent
self._root = _root if _root else self
self._debug = collections.defaultdict(dict)
def _read(self):
self._debug['key']['start'] = self._io.pos()
self.key = Msgpack(self._io)
self.key._read()
self._debug['key']['end'] = self._io.pos()
self._debug['value']['start'] = self._io.pos()
self.value = Msgpack(self._io)
self.value._read()
self._debug['value']['end'] = self._io.pos()
@property
def is_array_32(self):
"""
.. seealso::
Source - https://github.com/msgpack/msgpack/blob/master/spec.md#formats-array
"""
if hasattr(self, '_m_is_array_32'):
return self._m_is_array_32 if hasattr(self, '_m_is_array_32') else None
self._m_is_array_32 = self.b1 == 221
return self._m_is_array_32 if hasattr(self, '_m_is_array_32') else None
@property
def int_value(self):
if hasattr(self, '_m_int_value'):
return self._m_int_value if hasattr(self, '_m_int_value') else None
if self.is_int:
self._m_int_value = (self.pos_int7_value if self.is_pos_int7 else (self.neg_int5_value if self.is_neg_int5 else 4919))
return self._m_int_value if hasattr(self, '_m_int_value') else None
@property
def str_len(self):
if hasattr(self, '_m_str_len'):
return self._m_str_len if hasattr(self, '_m_str_len') else None
if self.is_str:
self._m_str_len = ((self.b1 & 31) if self.is_fix_str else (self.str_len_8 if self.is_str_8 else (self.str_len_16 if self.is_str_16 else self.str_len_32)))
return self._m_str_len if hasattr(self, '_m_str_len') else None
@property
def is_fix_array(self):
"""
.. seealso::
Source - https://github.com/msgpack/msgpack/blob/master/spec.md#formats-array
"""
if hasattr(self, '_m_is_fix_array'):
return self._m_is_fix_array if hasattr(self, '_m_is_fix_array') else None
self._m_is_fix_array = (self.b1 & 240) == 144
return self._m_is_fix_array if hasattr(self, '_m_is_fix_array') else None
@property
def is_map(self):
"""
.. seealso::
Source - https://github.com/msgpack/msgpack/blob/master/spec.md#formats-map
"""
if hasattr(self, '_m_is_map'):
return self._m_is_map if hasattr(self, '_m_is_map') else None
self._m_is_map = ((self.is_fix_map) or (self.is_map_16) or (self.is_map_32))
return self._m_is_map if hasattr(self, '_m_is_map') else None
@property
def is_array(self):
"""
.. seealso::
Source - https://github.com/msgpack/msgpack/blob/master/spec.md#formats-array
"""
if hasattr(self, '_m_is_array'):
return self._m_is_array if hasattr(self, '_m_is_array') else None
self._m_is_array = ((self.is_fix_array) or (self.is_array_16) or (self.is_array_32))
return self._m_is_array if hasattr(self, '_m_is_array') else None
@property
def is_float(self):
if hasattr(self, '_m_is_float'):
return self._m_is_float if hasattr(self, '_m_is_float') else None
self._m_is_float = ((self.is_float_32) or (self.is_float_64))
return self._m_is_float if hasattr(self, '_m_is_float') else None
@property
def is_str_8(self):
"""
.. seealso::
Source - https://github.com/msgpack/msgpack/blob/master/spec.md#formats-str
"""
if hasattr(self, '_m_is_str_8'):
return self._m_is_str_8 if hasattr(self, '_m_is_str_8') else None
self._m_is_str_8 = self.b1 == 217
return self._m_is_str_8 if hasattr(self, '_m_is_str_8') else None
@property
def is_fix_map(self):
"""
.. seealso::
Source - https://github.com/msgpack/msgpack/blob/master/spec.md#formats-map
"""
if hasattr(self, '_m_is_fix_map'):
return self._m_is_fix_map if hasattr(self, '_m_is_fix_map') else None
self._m_is_fix_map = (self.b1 & 240) == 128
return self._m_is_fix_map if hasattr(self, '_m_is_fix_map') else None
@property
def is_int(self):
if hasattr(self, '_m_is_int'):
return self._m_is_int if hasattr(self, '_m_is_int') else None
self._m_is_int = ((self.is_pos_int7) or (self.is_neg_int5))
return self._m_is_int if hasattr(self, '_m_is_int') else None
@property
def is_bool(self):
if hasattr(self, '_m_is_bool'):
return self._m_is_bool if hasattr(self, '_m_is_bool') else None
self._m_is_bool = ((self.b1 == 194) or (self.b1 == 195))
return self._m_is_bool if hasattr(self, '_m_is_bool') else None
@property
def is_str_16(self):
"""
.. seealso::
Source - https://github.com/msgpack/msgpack/blob/master/spec.md#formats-str
"""
if hasattr(self, '_m_is_str_16'):
return self._m_is_str_16 if hasattr(self, '_m_is_str_16') else None
self._m_is_str_16 = self.b1 == 218
return self._m_is_str_16 if hasattr(self, '_m_is_str_16') else None
@property
def is_float_64(self):
"""
.. seealso::
Source - https://github.com/msgpack/msgpack/blob/master/spec.md#formats-float
"""
if hasattr(self, '_m_is_float_64'):
return self._m_is_float_64 if hasattr(self, '_m_is_float_64') else None
self._m_is_float_64 = self.b1 == 203
return self._m_is_float_64 if hasattr(self, '_m_is_float_64') else None
@property
def is_map_16(self):
"""
.. seealso::
Source - https://github.com/msgpack/msgpack/blob/master/spec.md#formats-map
"""
if hasattr(self, '_m_is_map_16'):
return self._m_is_map_16 if hasattr(self, '_m_is_map_16') else None
self._m_is_map_16 = self.b1 == 222
return self._m_is_map_16 if hasattr(self, '_m_is_map_16') else None
@property
def is_neg_int5(self):
if hasattr(self, '_m_is_neg_int5'):
return self._m_is_neg_int5 if hasattr(self, '_m_is_neg_int5') else None
self._m_is_neg_int5 = (self.b1 & 224) == 224
return self._m_is_neg_int5 if hasattr(self, '_m_is_neg_int5') else None
@property
def pos_int7_value(self):
if hasattr(self, '_m_pos_int7_value'):
return self._m_pos_int7_value if hasattr(self, '_m_pos_int7_value') else None
if self.is_pos_int7:
self._m_pos_int7_value = self.b1
return self._m_pos_int7_value if hasattr(self, '_m_pos_int7_value') else None
@property
def is_nil(self):
"""
.. seealso::
Source - https://github.com/msgpack/msgpack/blob/master/spec.md#formats-nil
"""
if hasattr(self, '_m_is_nil'):
return self._m_is_nil if hasattr(self, '_m_is_nil') else None
self._m_is_nil = self.b1 == 192
return self._m_is_nil if hasattr(self, '_m_is_nil') else None
@property
def float_value(self):
if hasattr(self, '_m_float_value'):
return self._m_float_value if hasattr(self, '_m_float_value') else None
if self.is_float:
self._m_float_value = (self.float_32_value if self.is_float_32 else self.float_64_value)
return self._m_float_value if hasattr(self, '_m_float_value') else None
@property
def num_array_elements(self):
"""
.. seealso::
Source - https://github.com/msgpack/msgpack/blob/master/spec.md#formats-array
"""
if hasattr(self, '_m_num_array_elements'):
return self._m_num_array_elements if hasattr(self, '_m_num_array_elements') else None
if self.is_array:
self._m_num_array_elements = ((self.b1 & 15) if self.is_fix_array else (self.num_array_elements_16 if self.is_array_16 else self.num_array_elements_32))
return self._m_num_array_elements if hasattr(self, '_m_num_array_elements') else None
@property
def neg_int5_value(self):
if hasattr(self, '_m_neg_int5_value'):
return self._m_neg_int5_value if hasattr(self, '_m_neg_int5_value') else None
if self.is_neg_int5:
self._m_neg_int5_value = -((self.b1 & 31))
return self._m_neg_int5_value if hasattr(self, '_m_neg_int5_value') else None
@property
def bool_value(self):
"""
.. seealso::
Source - https://github.com/msgpack/msgpack/blob/master/spec.md#formats-bool
"""
if hasattr(self, '_m_bool_value'):
return self._m_bool_value if hasattr(self, '_m_bool_value') else None
if self.is_bool:
self._m_bool_value = self.b1 == 195
return self._m_bool_value if hasattr(self, '_m_bool_value') else None
@property
def is_pos_int7(self):
if hasattr(self, '_m_is_pos_int7'):
return self._m_is_pos_int7 if hasattr(self, '_m_is_pos_int7') else None
self._m_is_pos_int7 = (self.b1 & 128) == 0
return self._m_is_pos_int7 if hasattr(self, '_m_is_pos_int7') else None
@property
def is_array_16(self):
"""
.. seealso::
Source - https://github.com/msgpack/msgpack/blob/master/spec.md#formats-array
"""
if hasattr(self, '_m_is_array_16'):
return self._m_is_array_16 if hasattr(self, '_m_is_array_16') else None
self._m_is_array_16 = self.b1 == 220
return self._m_is_array_16 if hasattr(self, '_m_is_array_16') else None
@property
def is_str(self):
if hasattr(self, '_m_is_str'):
return self._m_is_str if hasattr(self, '_m_is_str') else None
self._m_is_str = ((self.is_fix_str) or (self.is_str_8) or (self.is_str_16) or (self.is_str_32))
return self._m_is_str if hasattr(self, '_m_is_str') else None
@property
def is_fix_str(self):
"""
.. seealso::
Source - https://github.com/msgpack/msgpack/blob/master/spec.md#formats-str
"""
if hasattr(self, '_m_is_fix_str'):
return self._m_is_fix_str if hasattr(self, '_m_is_fix_str') else None
self._m_is_fix_str = (self.b1 & 224) == 160
return self._m_is_fix_str if hasattr(self, '_m_is_fix_str') else None
@property
def is_str_32(self):
"""
.. seealso::
Source - https://github.com/msgpack/msgpack/blob/master/spec.md#formats-str
"""
if hasattr(self, '_m_is_str_32'):
return self._m_is_str_32 if hasattr(self, '_m_is_str_32') else None
self._m_is_str_32 = self.b1 == 219
return self._m_is_str_32 if hasattr(self, '_m_is_str_32') else None
@property
def num_map_elements(self):
"""
.. seealso::
Source - https://github.com/msgpack/msgpack/blob/master/spec.md#formats-map
"""
if hasattr(self, '_m_num_map_elements'):
return self._m_num_map_elements if hasattr(self, '_m_num_map_elements') else None
if self.is_map:
self._m_num_map_elements = ((self.b1 & 15) if self.is_fix_map else (self.num_map_elements_16 if self.is_map_16 else self.num_map_elements_32))
return self._m_num_map_elements if hasattr(self, '_m_num_map_elements') else None
@property
def is_float_32(self):
"""
.. seealso::
Source - https://github.com/msgpack/msgpack/blob/master/spec.md#formats-float
"""
if hasattr(self, '_m_is_float_32'):
return self._m_is_float_32 if hasattr(self, '_m_is_float_32') else None
self._m_is_float_32 = self.b1 == 202
return self._m_is_float_32 if hasattr(self, '_m_is_float_32') else None
@property
def is_map_32(self):
"""
.. seealso::
Source - https://github.com/msgpack/msgpack/blob/master/spec.md#formats-map
"""
if hasattr(self, '_m_is_map_32'):
return self._m_is_map_32 if hasattr(self, '_m_is_map_32') else None
self._m_is_map_32 = self.b1 == 223
return self._m_is_map_32 if hasattr(self, '_m_is_map_32') else None
| 38.907923 | 256 | 0.616346 | 2,695 | 18,170 | 3.744341 | 0.059369 | 0.086215 | 0.087405 | 0.120702 | 0.815776 | 0.746408 | 0.623427 | 0.566544 | 0.512734 | 0.480032 | 0 | 0.032418 | 0.258118 | 18,170 | 466 | 257 | 38.991416 | 0.716172 | 0.10743 | 0 | 0.353535 | 1 | 0 | 0.131661 | 0.012091 | 0 | 0 | 0 | 0 | 0 | 1 | 0.111111 | false | 0 | 0.010101 | 0 | 0.326599 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 1 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 3 |
cc17e63865e94c50206dc38b7367c698252eecb5 | 23 | py | Python | FileUtils/__init__.py | cognitiveqe/cqepyutils | 7d83f2bbe667294802c2ca9f20a42e1fa3e635d5 | [
"MIT"
] | null | null | null | FileUtils/__init__.py | cognitiveqe/cqepyutils | 7d83f2bbe667294802c2ca9f20a42e1fa3e635d5 | [
"MIT"
] | null | null | null | FileUtils/__init__.py | cognitiveqe/cqepyutils | 7d83f2bbe667294802c2ca9f20a42e1fa3e635d5 | [
"MIT"
] | null | null | null | __all__ = ['FileUtils'] | 23 | 23 | 0.695652 | 2 | 23 | 6 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0.086957 | 23 | 1 | 23 | 23 | 0.571429 | 0 | 0 | 0 | 0 | 0 | 0.375 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | false | 0 | 0 | 0 | 0 | 0 | 1 | 1 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 3 |
0bc7213c09c10b1bc55de9468af8657cffd677c7 | 1,020 | py | Python | Tests/testApi.py | garnachod/ConcursoPolicia | f123595afc697ddfa862114a228d7351e2f8fd73 | [
"Apache-2.0"
] | null | null | null | Tests/testApi.py | garnachod/ConcursoPolicia | f123595afc697ddfa862114a228d7351e2f8fd73 | [
"Apache-2.0"
] | null | null | null | Tests/testApi.py | garnachod/ConcursoPolicia | f123595afc697ddfa862114a228d7351e2f8fd73 | [
"Apache-2.0"
] | null | null | null | # -*- coding: utf-8 -*-
import os
import sys
lib_path = os.path.abspath('../')
sys.path.append(lib_path)
from API.APITextos import APITextos
if __name__ == '__main__':
"""
users = APITextos.getUsersSimilar_user_all_topic("Taxigate", "ar", 100, 1)
for user in users:
print user.screen_name + "\t"+ user.location
users = APITextos.getUsersSimilar_user_all_topic("abosofyan7", "ar", 100, 1)
for user in users:
print user.screen_name + "\t"+ user.location
print ""
print ""
users = APITextos.getUsersSimilar_user_all_topic("nightwalker_109", "ar", 100, 1)
for user in users:
print user.screen_name + "\t"+ user.location
"""
users = APITextos.getUsersSimilar_user_all_topic("@nvidia", "en", 100, 897)
if users != False:
for user in users:
print user.screen_name + "\t"+ user.location
"""
users = APITextos.getUsersSimilar_text_all_topic("hola mundo", "es", 100, 714)
if users != False:
for user in users:
print user.screen_name + "\t"+ user.location
""" | 29.142857 | 83 | 0.67549 | 140 | 1,020 | 4.7 | 0.307143 | 0.106383 | 0.220365 | 0.106383 | 0.706687 | 0.706687 | 0.582067 | 0.582067 | 0.582067 | 0.582067 | 0 | 0.034689 | 0.180392 | 1,020 | 35 | 84 | 29.142857 | 0.752392 | 0.020588 | 0 | 0 | 0 | 0 | 0.068966 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | null | null | 0 | 0.3 | null | null | 0.1 | 0 | 0 | 0 | null | 0 | 1 | 0 | 0 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 3 |
0bcf6189d3d5a0a37bc27a9c69ab2228205c0630 | 5,103 | py | Python | test/simple_imputation/test_logistic_regression.py | macarro/imputena | 3a94ae1419a2af0d9707b20546ee078929ce99e8 | [
"MIT"
] | 6 | 2020-04-27T21:21:47.000Z | 2022-03-30T03:02:54.000Z | test/simple_imputation/test_logistic_regression.py | macarro/imputena | 3a94ae1419a2af0d9707b20546ee078929ce99e8 | [
"MIT"
] | 1 | 2021-07-01T18:49:27.000Z | 2021-07-01T18:49:27.000Z | test/simple_imputation/test_logistic_regression.py | macarro/imputena | 3a94ae1419a2af0d9707b20546ee078929ce99e8 | [
"MIT"
] | null | null | null | import unittest
from imputena import logistic_regression
from test.example_data import *
class TestLogisticRegression(unittest.TestCase):
# Positive tests ----------------------------------------------------------
def test_logistic_regression_returning(self):
"""
Positive test
data: Correct data frame (df_breast_cancer)
The data frame (df_breast_cancer) contains 15 NA values.
logistic_regression() should impute 7 of them.
Checks that the original series remains unmodified and that the
returned series contains 8 NA values.
"""
# 1. Arrange
df = generate_df_breast_cancer()
# 2. Act
df2 = logistic_regression(df, 'class', ['thickness', 'uniformity'])
# 3. Assert
self.assertEqual(df.isna().sum().sum(), 15)
self.assertEqual(df2.isna().sum().sum(), 8)
def test_logistic_regression_inplace(self):
"""
Positive test
data: Correct data frame (df_breast_cancer)
The data frame (df_breast_cancer) contains 15 NA values.
logistic_regression() should impute 7 of them.
Checks that the data frame contains 8 NA values after the operation.
"""
# 1. Arrange
df = generate_df_breast_cancer()
# 2. Act
logistic_regression(
df, 'class', ['thickness', 'uniformity'], inplace=True)
# 3. Assert
self.assertEqual(df.isna().sum().sum(), 8)
def test_logistic_regression_implicit_predictors(self):
"""
Positive test
data: Correct data frame (df_breast_cancer)
predictors: None
The data frame (df_breast_cancer) contains 15 NA values.
logistic_regression() should impute 7 of them.
Checks that the original series remains unmodified and that the
returned series contains 8 NA values.
"""
# 1. Arrange
df = generate_df_breast_cancer()
# 2. Act
df2 = logistic_regression(df, 'class')
# 3. Assert
self.assertEqual(df.isna().sum().sum(), 15)
self.assertEqual(df2.isna().sum().sum(), 8)
def test_logistic_regression_complete(self):
"""
Positive test
data: Correct data frame (df_breast_cancer)
regressions: 'complete'
The data frame (df_breast_cancer) contains 15 NA values.
logistic_regression() should impute 3 of them.
Checks that the original series remains unmodified and that the
returned series contains 12 NA values.
"""
# 1. Arrange
df = generate_df_breast_cancer()
# 2. Act
df2 = logistic_regression(
df, 'class', ['thickness', 'uniformity'], regressions='complete')
# 3. Assert
self.assertEqual(df.isna().sum().sum(), 15)
self.assertEqual(df2.isna().sum().sum(), 12)
# Negative tests ----------------------------------------------------------
def test_logistic_regression_wrong_type(self):
"""
Negative test
data: array (unsupported type)
Checks that the function raises a TypeError if the data is passed as
an array.
"""
# 1. Arrange
data = [2, 4, np.nan, 1]
# 2. Act & 3. Assert
with self.assertRaises(TypeError):
logistic_regression(data)
def test_logistic_regression_wrong_dependent(self):
"""
Negative test
data: Correct data frame (df_breast_cancer)
dependent: 'z' (not a column of df_breast_cancer)
Checks that the function raises a ValueError if the column specified as
the dependent variable doesn't exist in the data.
"""
# 1. Arrange
df = generate_df_breast_cancer()
# 2. Act & 3. Assert
with self.assertRaises(ValueError):
logistic_regression(df, 'z', ['thickness', 'uniformity'])
def test_logistic_regression_wrong_predictor(self):
"""
Negative test
data: Correct data frame (df_breast_cancer)
predictors: ['thickness', 'z'] ('z' is not a column of
df_breast_cancer)
Checks that the function raises a ValueError if one of the column s
specified as the predictor variables doesn't exist in the data.
"""
# 1. Arrange
df = generate_df_breast_cancer()
# 2. Act & 3. Assert
with self.assertRaises(ValueError):
logistic_regression(df, 'class', ['thickness', 'z'])
def test_logistic_regression_wrong_regressions(self):
"""
Negative test
data: Correct data frame (df_breast_cancer)
regressions: 'z' (not a valid value)
Checks that the function raises a ValueError if the value passed for
the parameter regressions is not valid.
"""
# 1. Arrange
df = generate_df_breast_cancer()
# 2. Act & 3. Assert
with self.assertRaises(ValueError):
logistic_regression(
df, 'class', ['thickness', 'uniformity'], regressions='z')
| 31.89375 | 79 | 0.600039 | 585 | 5,103 | 5.080342 | 0.174359 | 0.127187 | 0.094213 | 0.062921 | 0.796433 | 0.74428 | 0.720054 | 0.698856 | 0.678668 | 0.636945 | 0 | 0.016837 | 0.290025 | 5,103 | 159 | 80 | 32.09434 | 0.803478 | 0.447972 | 0 | 0.404762 | 0 | 0 | 0.062635 | 0 | 0 | 0 | 0 | 0 | 0.261905 | 1 | 0.190476 | false | 0 | 0.071429 | 0 | 0.285714 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 1 | 1 | 0 | 0 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 3 |
0bf1df4821a7ee776dde7f0d63b87186e9b1ce95 | 209 | py | Python | djangox/lib/python3.8/site-packages/allauth/socialaccount/providers/draugiem/urls.py | DemarcusL/django_wiki_lab | 3b7cf18af7e0f89c94d10eb953ca018a150a2f55 | [
"MIT"
] | 6,342 | 2015-01-01T07:40:30.000Z | 2022-03-31T04:18:30.000Z | djangox/lib/python3.8/site-packages/allauth/socialaccount/providers/draugiem/urls.py | DemarcusL/django_wiki_lab | 3b7cf18af7e0f89c94d10eb953ca018a150a2f55 | [
"MIT"
] | 2,198 | 2015-01-02T15:17:45.000Z | 2022-03-28T10:20:43.000Z | djangox/lib/python3.8/site-packages/allauth/socialaccount/providers/draugiem/urls.py | DemarcusL/django_wiki_lab | 3b7cf18af7e0f89c94d10eb953ca018a150a2f55 | [
"MIT"
] | 2,928 | 2015-01-01T10:44:13.000Z | 2022-03-31T03:20:16.000Z | from django.urls import path
from . import views
urlpatterns = [
path("draugiem/login/", views.login, name="draugiem_login"),
path("draugiem/callback/", views.callback, name="draugiem_callback"),
]
| 20.9 | 73 | 0.712919 | 25 | 209 | 5.88 | 0.44 | 0.163265 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0.138756 | 209 | 9 | 74 | 23.222222 | 0.816667 | 0 | 0 | 0 | 0 | 0 | 0.30622 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | false | 0 | 0.333333 | 0 | 0.333333 | 0 | 1 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 0 | 0 | 3 |
0403e4d350613ff44a670bf3891877f93092864d | 324 | py | Python | cryptodoge/cmds/units.py | grayfallstown-cryptodoge/cryptodoge | ffeb5218ce184a56073a5dc0ac5acddba3728bd4 | [
"Apache-2.0"
] | 10 | 2021-08-21T17:41:51.000Z | 2022-02-09T04:28:12.000Z | cryptodoge/cmds/units.py | grayfallstown-cryptodoge/cryptodoge | ffeb5218ce184a56073a5dc0ac5acddba3728bd4 | [
"Apache-2.0"
] | 1 | 2021-12-15T21:23:38.000Z | 2021-12-15T21:23:38.000Z | cryptodoge/cmds/units.py | grayfallstown-cryptodoge/cryptodoge | ffeb5218ce184a56073a5dc0ac5acddba3728bd4 | [
"Apache-2.0"
] | 2 | 2021-08-21T18:22:59.000Z | 2021-12-10T07:12:18.000Z | from typing import Dict
# The rest of the codebase uses mojos everywhere.
# Only use these units for user facing interfaces.
units: Dict[str, int] = {
"cryptodoge": 10 ** 6, # 1 cryptodoge (XCD) is 1,000,000 mojo (1 million)
"mojo:": 1,
"colouredcoin": 10 ** 3, # 1 coloured coin is 1000 colouredcoin mojos
}
| 32.4 | 78 | 0.67284 | 49 | 324 | 4.44898 | 0.714286 | 0.045872 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0.082677 | 0.216049 | 324 | 9 | 79 | 36 | 0.775591 | 0.580247 | 0 | 0 | 0 | 0 | 0.206107 | 0 | 0 | 0 | 0 | 0.111111 | 0 | 1 | 0 | true | 0 | 0.166667 | 0 | 0.166667 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | null | 0 | 0 | 1 | 0 | 0 | 0 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 3 |
0405fb654ca1caa004613619d41e36289a568124 | 853 | bzl | Python | integration/bazel_workspace_tests/bazel_ngtsc_plugin/packages.bzl | John-Cassidy/angular | 6375fa79875c0fe7b815efc45940a6e6f5c9c9eb | [
"MIT"
] | 95,154 | 2015-01-01T04:52:07.000Z | 2022-03-31T21:33:49.000Z | integration/bazel_workspace_tests/bazel_ngtsc_plugin/packages.bzl | John-Cassidy/angular | 6375fa79875c0fe7b815efc45940a6e6f5c9c9eb | [
"MIT"
] | 45,008 | 2015-01-03T23:36:09.000Z | 2022-03-31T23:57:28.000Z | integration/bazel_workspace_tests/bazel_ngtsc_plugin/packages.bzl | John-Cassidy/angular | 6375fa79875c0fe7b815efc45940a6e6f5c9c9eb | [
"MIT"
] | 30,083 | 2015-01-02T20:55:07.000Z | 2022-03-31T21:03:16.000Z | ANGULAR_PACKAGES_CONFIG = [
("@angular/animations", struct(entry_points = ["browser"])),
("@angular/common", struct(entry_points = ["http/testing", "http", "testing"])),
("@angular/compiler", struct(entry_points = ["testing"])),
("@angular/core", struct(entry_points = ["testing"])),
("@angular/forms", struct(entry_points = [])),
("@angular/platform-browser", struct(entry_points = ["testing", "animations"])),
("@angular/platform-browser-dynamic", struct(entry_points = ["testing"])),
("@angular/router", struct(entry_points = [])),
]
ANGULAR_PACKAGES = [
struct(
name = name[len("@angular/"):],
entry_points = config.entry_points,
platform = config.platform if hasattr(config, "platform") else "browser",
module_name = name,
)
for name, config in ANGULAR_PACKAGES_CONFIG
]
| 40.619048 | 84 | 0.638921 | 87 | 853 | 6.08046 | 0.287356 | 0.20794 | 0.257089 | 0.181474 | 0.175803 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0.168816 | 853 | 20 | 85 | 42.65 | 0.746121 | 0 | 0 | 0 | 0 | 0 | 0.284877 | 0.067995 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | false | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | null | 1 | 1 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 3 |
044fa9bc2b971a59a7630fd706352bd033dc7523 | 2,761 | py | Python | legacy/zero_training.py | GabrielePicco/pytorch-lightning | 0d6dfd42d8965347a258e3d20e83bddd344e718f | [
"Apache-2.0"
] | 4 | 2021-07-27T14:39:02.000Z | 2022-03-07T10:57:13.000Z | legacy/zero_training.py | GabrielePicco/pytorch-lightning | 0d6dfd42d8965347a258e3d20e83bddd344e718f | [
"Apache-2.0"
] | 2 | 2021-07-03T07:07:32.000Z | 2022-03-10T16:07:20.000Z | legacy/zero_training.py | GabrielePicco/pytorch-lightning | 0d6dfd42d8965347a258e3d20e83bddd344e718f | [
"Apache-2.0"
] | 1 | 2021-02-16T00:47:46.000Z | 2021-02-16T00:47:46.000Z | # Copyright The PyTorch Lightning team.
#
# 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
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
import os
import torch
from torch.utils.data import Dataset
import pytorch_lightning as pl
PATH_LEGACY = os.path.dirname(__file__)
class RandomDataset(Dataset):
def __init__(self, size, length: int = 100):
self.len = length
self.data = torch.randn(length, size)
def __getitem__(self, index):
return self.data[index]
def __len__(self):
return self.len
class DummyModel(pl.LightningModule):
def __init__(self):
super().__init__()
self.layer = torch.nn.Linear(32, 2)
def forward(self, x):
return self.layer(x)
def _loss(self, batch, prediction):
# An arbitrary loss to have a loss that updates the model weights during `Trainer.fit` calls
return torch.nn.functional.mse_loss(prediction, torch.ones_like(prediction))
def _step(self, batch, batch_idx):
output = self.layer(batch)
loss = self._loss(batch, output)
# return {'loss': loss} # used for PL<1.0
return loss # used for PL >= 1.0
def training_step(self, batch, batch_idx):
return self._step(batch, batch_idx)
def validation_step(self, batch, batch_idx):
self._step(batch, batch_idx)
def test_step(self, batch, batch_idx):
self._step(batch, batch_idx)
def configure_optimizers(self):
optimizer = torch.optim.SGD(self.layer.parameters(), lr=0.1)
lr_scheduler = torch.optim.lr_scheduler.StepLR(optimizer, step_size=1)
return [optimizer], [lr_scheduler]
def train_dataloader(self):
return torch.utils.data.DataLoader(RandomDataset(32, 64))
def val_dataloader(self):
return torch.utils.data.DataLoader(RandomDataset(32, 64))
def test_dataloader(self):
return torch.utils.data.DataLoader(RandomDataset(32, 64))
def main_train(dir_path, max_epochs: int = 5):
trainer = pl.Trainer(
default_root_dir=dir_path,
checkpoint_callback=True,
max_epochs=max_epochs,
)
model = DummyModel()
trainer.fit(model)
if __name__ == '__main__':
path_dir = os.path.join(PATH_LEGACY, 'checkpoints', str(pl.__version__))
main_train(path_dir)
| 29.063158 | 100 | 0.688156 | 380 | 2,761 | 4.797368 | 0.394737 | 0.038398 | 0.049918 | 0.039495 | 0.207351 | 0.184312 | 0.15469 | 0.15469 | 0.15469 | 0.15469 | 0 | 0.013799 | 0.212604 | 2,761 | 94 | 101 | 29.37234 | 0.824747 | 0.256791 | 0 | 0.096154 | 0 | 0 | 0.009341 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0.288462 | false | 0 | 0.076923 | 0.153846 | 0.596154 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 0 | 1 | 1 | 0 | 0 | 3 |
f0a252d3651a304580c3dce4edc0080b4ebde52d | 402 | py | Python | tests/test_euclidean_distance.py | danielwardega141196/unittests-with-pytest | 8dbedbe87fbfc5786856872dff6873395e6f4726 | [
"MIT"
] | null | null | null | tests/test_euclidean_distance.py | danielwardega141196/unittests-with-pytest | 8dbedbe87fbfc5786856872dff6873395e6f4726 | [
"MIT"
] | null | null | null | tests/test_euclidean_distance.py | danielwardega141196/unittests-with-pytest | 8dbedbe87fbfc5786856872dff6873395e6f4726 | [
"MIT"
] | null | null | null | from application.euclidean_distance import euclidean_distance
def test_euclidean_distance():
point_a = (0, 0)
point_b = (3, 4)
distance_between_a_and_b = euclidean_distance(point_a, point_b)
assert distance_between_a_and_b == 5
point_c = (-2, 3)
point_d = (2, 3)
distance_between_c_and_d = euclidean_distance(point_c, point_d)
assert distance_between_c_and_d == 4
| 23.647059 | 67 | 0.728856 | 63 | 402 | 4.174603 | 0.31746 | 0.323194 | 0.250951 | 0.174905 | 0.304183 | 0 | 0 | 0 | 0 | 0 | 0 | 0.030675 | 0.189055 | 402 | 16 | 68 | 25.125 | 0.776074 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0.2 | 1 | 0.1 | false | 0 | 0.1 | 0 | 0.2 | 0 | 0 | 0 | 0 | null | 1 | 1 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 3 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.