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 |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
d242ed9d3520b1a1062f3207cee3beda75ae982b | 1,039 | py | Python | printapp/migrations/0002_auto_20180217_1917.py | sumanlearning/potpapa2018 | 1557dd5aca645cb55a08e5b92623804e51fa8dfe | [
"Unlicense"
] | null | null | null | printapp/migrations/0002_auto_20180217_1917.py | sumanlearning/potpapa2018 | 1557dd5aca645cb55a08e5b92623804e51fa8dfe | [
"Unlicense"
] | null | null | null | printapp/migrations/0002_auto_20180217_1917.py | sumanlearning/potpapa2018 | 1557dd5aca645cb55a08e5b92623804e51fa8dfe | [
"Unlicense"
] | null | null | null | # Generated by Django 2.0.2 on 2018-02-17 12:17
import datetime
from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
('printapp', '0001_initial'),
]
operations = [
migrations.AlterField(
model_name='historybayar',
name='bayar_now',
field=models.DecimalField(decimal_places=2, max_digits=14, verbose_name='pembayaran sekarang'),
),
migrations.AlterField(
model_name='kontrak',
name='nhari_har',
field=models.IntegerField(default=0, verbose_name='masa pemeliharaan (hari)'),
),
migrations.AlterField(
model_name='kontrak',
name='tgl_due',
field=models.DateField(default=datetime.date.today, verbose_name='tgl jatuh tempo'),
),
migrations.AlterField(
model_name='termin',
name='nth_termin',
field=models.IntegerField(default=1, verbose_name='termin ke-'),
),
]
| 29.685714 | 107 | 0.599615 | 105 | 1,039 | 5.790476 | 0.552381 | 0.131579 | 0.164474 | 0.190789 | 0.131579 | 0.131579 | 0 | 0 | 0 | 0 | 0 | 0.032258 | 0.283927 | 1,039 | 34 | 108 | 30.558824 | 0.784946 | 0.043311 | 0 | 0.357143 | 1 | 0 | 0.15625 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | false | 0 | 0.071429 | 0 | 0.178571 | 0.035714 | 0 | 0 | 0 | null | 0 | 0 | 1 | 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 | 0 | 0 | 0 | 0 | 0 | 0 | 2 |
d24abb7e1be3b51950c14587cbae8b44aa330b06 | 5,676 | py | Python | h/security/predicates.py | hypothesis/h | 92c1a326c305a3d94fe48f87402135fd7beb6a20 | [
"BSD-2-Clause"
] | 2,103 | 2015-01-07T12:47:49.000Z | 2022-03-29T02:38:25.000Z | h/security/predicates.py | hypothesis/h | 92c1a326c305a3d94fe48f87402135fd7beb6a20 | [
"BSD-2-Clause"
] | 4,322 | 2015-01-04T17:18:01.000Z | 2022-03-31T17:06:02.000Z | h/security/predicates.py | hypothesis/h | 92c1a326c305a3d94fe48f87402135fd7beb6a20 | [
"BSD-2-Clause"
] | 389 | 2015-01-24T04:10:02.000Z | 2022-03-28T08:00:16.000Z | """
Define authorization predicates.
These are functions which accept an `Identity` object and a context object and
return a truthy value. These represent building blocks of our permission map
which define when people do, or don't have permissions.
For example a predicate might define "group_created_by_user" which is only
true when a user is present, a group is present and the user created that
group.
"""
from itertools import chain
from h.models.group import JoinableBy, ReadableBy, WriteableBy
def requires(*parent_predicates):
"""
Decorate a predicate to say it requires other predicates to be True first.
:param parent_predicates: A list of predicates that have to be true for
this predicate to be true as well.
"""
def decorator(function):
function.requires = parent_predicates
return function
return decorator
# Identity things
def authenticated(identity, _context):
return identity
# The `@requires` here means that this predicate needs `authenticate` to be
# True before it's True. It also avoids attribute errors if identity is None
@requires(authenticated)
def authenticated_user(identity, _context):
return identity.user
@requires(authenticated_user)
def user_is_staff(identity, _context):
return identity.user.staff
@requires(authenticated_user)
def user_is_admin(identity, _context):
return identity.user.admin
@requires(authenticated)
def authenticated_client(identity, _context):
return identity.auth_client
@requires(authenticated_client)
def authenticated_client_is_lms(identity, _context):
authority = identity.auth_client.authority
return authority.startswith("lms.") and authority.endswith(".hypothes.is")
# Users
def user_found(_identity, context):
return hasattr(context, "user") and context.user
@requires(authenticated_client, user_found)
def user_authority_matches_authenticated_client(identity, context):
return context.user.authority == identity.auth_client.authority
# Annotations
def annotation_found(_identity, context):
return hasattr(context, "annotation") and context.annotation
@requires(annotation_found)
def annotation_shared(_identity, context):
return context.annotation.shared
@requires(annotation_found)
def annotation_not_shared(_identity, context):
return not context.annotation.shared
@requires(annotation_found)
def annotation_live(_identity, context):
return not context.annotation.deleted
@requires(authenticated_user, annotation_found)
def annotation_created_by_user(identity, context):
return identity.user.userid == context.annotation.userid
# Groups
def group_found(_identity, context):
return hasattr(context, "group") and context.group
def group_not_found(_identity, context):
return not hasattr(context, "group") or not context.group
@requires(group_found)
def group_writable_by_members(_identity, context):
return context.group.writeable_by == WriteableBy.members
@requires(group_found)
def group_writable_by_authority(_identity, context):
return context.group.writeable_by == WriteableBy.authority
@requires(group_found)
def group_readable_by_world(_identity, context):
return context.group.readable_by == ReadableBy.world
@requires(group_found)
def group_readable_by_members(_identity, context):
return context.group.readable_by == ReadableBy.members
@requires(group_found)
def group_joinable_by_authority(_identity, context):
return context.group.joinable_by == JoinableBy.authority
@requires(authenticated_user, group_found)
def group_created_by_user(identity, context):
return context.group.creator and context.group.creator.id == identity.user.id
@requires(authenticated_user, group_found)
def group_has_user_as_member(identity, context):
# With detached groups like we have with the websocket, this doesn't work
# as SQLAlchemy does not consider them equal:
# return context.group in identity.user.groups
return any(user_group.id == context.group.id for user_group in identity.user.groups)
@requires(authenticated_user, group_found)
def group_matches_user_authority(identity, context):
return context.group.authority == identity.user.authority
@requires(authenticated_client, group_found)
def group_matches_authenticated_client_authority(identity, context):
return context.group.authority == identity.auth_client.authority
def resolve_predicates(mapping):
"""
Expand predicates with requirements into concrete lists of predicates.
This takes a permission map which contains predicates which reference
other ones (using `@requires`), and converts each clause to include the
parents in parent first order. This means any parent which is referred to
by a predicate is executed before it, and no predicate appears more than once.
"""
return {
key: [_expand_clause(clause) for clause in clauses]
for key, clauses in mapping.items()
}
def _expand_clause(clause):
"""Generate all of the predicates + parents in a clause without dupes."""
seen_before = set()
# The chain.from_iterable here flattens nested iterables
return list(
chain.from_iterable(
_expand_predicate(predicate, seen_before) for predicate in clause
)
)
def _expand_predicate(predicate, seen_before):
"""Generate all of the parents and the predicate in parents first order."""
if hasattr(predicate, "requires"):
for parent in predicate.requires:
yield from _expand_predicate(parent, seen_before)
if predicate not in seen_before:
seen_before.add(predicate)
yield predicate
| 27.687805 | 88 | 0.767442 | 730 | 5,676 | 5.787671 | 0.234247 | 0.085207 | 0.109349 | 0.066272 | 0.387456 | 0.284497 | 0.187456 | 0.106982 | 0 | 0 | 0 | 0 | 0.158562 | 5,676 | 204 | 89 | 27.823529 | 0.884631 | 0.263742 | 0 | 0.159574 | 0 | 0 | 0.011713 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0.308511 | false | 0 | 0.021277 | 0.244681 | 0.62766 | 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 | 0 | 0 | 0 | 2 |
d25d20d8eebe1fa8e5a33aad978f268f206cda23 | 602 | py | Python | xmrswap/interface_part.py | tecnovert/xmrswap | ad2983a4df03184453ff680c17602497acc75a87 | [
"MIT"
] | 2 | 2020-09-21T17:33:23.000Z | 2020-10-03T08:54:01.000Z | xmrswap/interface_part.py | tecnovert/xmrswap | ad2983a4df03184453ff680c17602497acc75a87 | [
"MIT"
] | 2 | 2020-10-03T09:18:48.000Z | 2020-10-13T19:58:34.000Z | xmrswap/interface_part.py | tecnovert/xmrswap | ad2983a4df03184453ff680c17602497acc75a87 | [
"MIT"
] | null | null | null | #!/usr/bin/env python
# -*- coding: utf-8 -*-
# Copyright (c) 2020 tecnovert
# Distributed under the MIT software license, see the accompanying
# file LICENSE.txt or http://www.opensource.org/licenses/mit-license.php.
from .contrib.test_framework.messages import (
CTxOutPart,
)
from .interface_btc import BTCInterface
class PARTInterface(BTCInterface):
@staticmethod
def witnessScaleFactor():
return 2
@staticmethod
def txVersion():
return 0xa0
def __init__(self, rpc_callback):
self.rpc_callback = rpc_callback
self.txoType = CTxOutPart
| 22.296296 | 73 | 0.704319 | 70 | 602 | 5.928571 | 0.742857 | 0.079518 | 0.072289 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0.016632 | 0.200997 | 602 | 26 | 74 | 23.153846 | 0.846154 | 0.345515 | 0 | 0.142857 | 0 | 0 | 0 | 0 | 0 | 0 | 0.010283 | 0 | 0 | 1 | 0.214286 | false | 0 | 0.142857 | 0.142857 | 0.571429 | 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 | 0 | 0 | 0 | 2 |
d2657376a64e94e969ed1edf71ca0efd3af9b3de | 2,046 | py | Python | pytrek/settings/LimitsSettings.py | hasii2011/PyArcadeStarTrek | 370edbb62f15f69322aa7f109d6d36ebf20cbe4a | [
"MIT"
] | 1 | 2021-06-13T00:56:24.000Z | 2021-06-13T00:56:24.000Z | pytrek/settings/LimitsSettings.py | hasii2011/PyArcadeStarTrek | 370edbb62f15f69322aa7f109d6d36ebf20cbe4a | [
"MIT"
] | 94 | 2021-04-16T20:34:10.000Z | 2022-01-13T19:58:20.000Z | pytrek/settings/LimitsSettings.py | hasii2011/PyArcadeStarTrek | 370edbb62f15f69322aa7f109d6d36ebf20cbe4a | [
"MIT"
] | null | null | null |
from logging import Logger
from logging import getLogger
from pytrek.settings.BaseSubSetting import BaseSubSetting
from pytrek.settings.SettingsCommon import SettingsCommon
from pytrek.settings.SettingsCommon import SettingsNameValues
class LimitsSettings(BaseSubSetting):
LIMITS_SECTION: str = 'Limits'
MAXIMUM_STARS: str = 'maximum_stars'
MINIMUM_STAR_BASES: str = 'minimum_star_bases'
MAXIMUM_STAR_BASES: str = 'maximum_star_bases'
MAXIMUM_PLANETS: str = 'maximum_planets'
DEFAULT_FULL_SHIELDS: str = 'default_full_shields'
LIMITS_SETTINGS: SettingsNameValues = SettingsNameValues({
MAXIMUM_STARS: '4',
MINIMUM_STAR_BASES: '2',
MAXIMUM_STAR_BASES: '5',
MAXIMUM_PLANETS: '10',
DEFAULT_FULL_SHIELDS: '2500'
})
"""
This is a singleton based on the inheritance hierarchy
"""
def init(self, *args, **kwds):
self.logger: Logger = getLogger(__name__)
BaseSubSetting.init(self, *args, **kwds)
self._settingsCommon: SettingsCommon = SettingsCommon(self._config)
def addMissingSettings(self):
self._settingsCommon.addMissingSettings(sectionName=LimitsSettings.LIMITS_SECTION, nameValues=LimitsSettings.LIMITS_SETTINGS)
@property
def maximumStars(self) -> int:
return self._config.getint(LimitsSettings.LIMITS_SECTION, LimitsSettings.MAXIMUM_STARS)
@property
def minimumStarBases(self) -> int:
return self._config.getint(LimitsSettings.LIMITS_SECTION, LimitsSettings.MINIMUM_STAR_BASES)
@property
def maximumStarBases(self) -> int:
return self._config.getint(LimitsSettings.LIMITS_SECTION, LimitsSettings.MAXIMUM_STAR_BASES)
@property
def maximumPlanets(self) -> int:
return self._config.getint(LimitsSettings.LIMITS_SECTION, LimitsSettings.MAXIMUM_PLANETS)
@property
def defaultFullShields(self) -> int:
return self._config.getint(LimitsSettings.LIMITS_SECTION, LimitsSettings.DEFAULT_FULL_SHIELDS)
| 33.540984 | 133 | 0.729717 | 208 | 2,046 | 6.923077 | 0.274038 | 0.05 | 0.1125 | 0.059028 | 0.338194 | 0.257639 | 0.257639 | 0.257639 | 0.257639 | 0.257639 | 0 | 0.005418 | 0.188172 | 2,046 | 60 | 134 | 34.1 | 0.861529 | 0 | 0 | 0.125 | 0 | 0 | 0.050127 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0.175 | 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 | 0 | 0 | 0 | 0 | 1 | 1 | 0 | 0 | 2 |
d26eb1d2c5907c778452828f508b0d406c3d409a | 605 | py | Python | conduit_tests/fixtu.py | ArtuZi2/conduit | 804fc2b69dda7e244fc91025eb30ad1847b81f6a | [
"MIT"
] | null | null | null | conduit_tests/fixtu.py | ArtuZi2/conduit | 804fc2b69dda7e244fc91025eb30ad1847b81f6a | [
"MIT"
] | null | null | null | conduit_tests/fixtu.py | ArtuZi2/conduit | 804fc2b69dda7e244fc91025eb30ad1847b81f6a | [
"MIT"
] | null | null | null | import time
import pytest
# preparing selenium and chrome web driver manager
from selenium import webdriver
from selenium.webdriver.chrome.options import Options
from webdriver_manager.chrome import ChromeDriverManager
# importing os for environmental variable, and docker-compose up
import os
@pytest.fixture(scope="session")
def browser():
driver = webdriver.Chrome(ChromeDriverManager().install(), options=options)
driver.get("http://localhost:1667")
options = webdriver.ChromeOptions()
options.add_argument('--headless')
options.add_argument('--disable-gpu')
return driver
| 28.809524 | 79 | 0.77686 | 71 | 605 | 6.577465 | 0.549296 | 0.051392 | 0.077088 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0.00759 | 0.128926 | 605 | 20 | 80 | 30.25 | 0.878558 | 0.183471 | 0 | 0 | 0 | 0 | 0.10387 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0.071429 | false | 0 | 0.428571 | 0 | 0.571429 | 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 | 0 | 1 | 0 | 1 | 0 | 0 | 2 |
d276c726608d0b175c4c5a4e294d5b6baeab2166 | 377 | py | Python | templates/django/__APPNAME__/apps/utils/models.py | ba1dr/tplgenerator | f05b6f9a32cf825d326dd2faf551d1e156d2df37 | [
"MIT"
] | null | null | null | templates/django/__APPNAME__/apps/utils/models.py | ba1dr/tplgenerator | f05b6f9a32cf825d326dd2faf551d1e156d2df37 | [
"MIT"
] | null | null | null | templates/django/__APPNAME__/apps/utils/models.py | ba1dr/tplgenerator | f05b6f9a32cf825d326dd2faf551d1e156d2df37 | [
"MIT"
] | null | null | null |
from django.db import models
from django.core import signing
class PasswordMixin(object):
password_encrypted = models.CharField(max_length=128, null=False, blank=False)
@property
def password(self):
return signing.loads(self.password_encrypted)
@password.setter
def password(self, value):
self.password_encrypted = signing.dumps(value)
| 23.5625 | 82 | 0.732095 | 46 | 377 | 5.913043 | 0.586957 | 0.1875 | 0.110294 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0.009709 | 0.180371 | 377 | 15 | 83 | 25.133333 | 0.87055 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0.2 | false | 0.7 | 0.2 | 0.1 | 0.7 | 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 | 0 | 0 | 1 | 0 | 0 | 2 |
d27bf22d6bf897be8eacbdeb8156e0811b013b5d | 3,497 | py | Python | stressTest/stressTestPV.py | bhill-slac/epics-stress-tests | bf895cdf84e3ef16819204fbf49f2dd54c9473fb | [
"BSD-3-Clause-LBNL"
] | null | null | null | stressTest/stressTestPV.py | bhill-slac/epics-stress-tests | bf895cdf84e3ef16819204fbf49f2dd54c9473fb | [
"BSD-3-Clause-LBNL"
] | null | null | null | stressTest/stressTestPV.py | bhill-slac/epics-stress-tests | bf895cdf84e3ef16819204fbf49f2dd54c9473fb | [
"BSD-3-Clause-LBNL"
] | null | null | null | #!/usr/bin/env python3
class stressTestPV:
def __init__( self, pvName ):
self._pvName = pvName
self._tsValues = {} # Dict of collected values, keys are float timestamps
self._tsRates = {} # Dict of collection rates, keys are int secPastEpoch values
self._tsMissRates = {} # Dict of missed count rates, keys are int secPastEpoch values
self._timeoutRates= {} # Dict of timeout rates, keys are int secPastEpoch values
self._numMissed = 0 # Cumulative number of missed counts
self._numTimeouts = 0 # Cumulative number of timeouts
self._startTime = None # Earliest timestamp of all collected values
self._endTime = None # Latest timestamp of all collected values
# Accessors
def getName( self ):
return self._pvName
def getNumTsValues( self ):
return len(self._tsValues)
def getNumMissed( self ):
return self._numMissed
def getNumTimeouts( self ):
return self._numTimeouts
def getEndTime( self ):
return self._endTime;
def getStartTime( self ):
return self._startTime;
def getTsValues( self ):
return self._tsValues
def getTsRates( self ):
return self._tsRates
def getTsMissRates( self ):
return self._tsMissRates
def getTimeoutRates( self ):
return self._timeoutRates
def addTsValues( self, tsValues ):
# TODO: check for more than one value for the same timestamp
self._tsValues.update( tsValues )
def addTsTimeouts( self, tsTimeouts ):
self._tsTimeouts.update( tsTimeouts )
# stressTestPV.analyze
def analyze( self ):
( priorSec, priorValue ) = ( None, None )
( count, missed, timeouts ) = ( 0, 0, 0 )
sec = None
for timestamp in self._tsValues:
sec = int(timestamp)
if priorSec is None:
self._endTime = timestamp
self._startTime = timestamp
priorSec = sec - 1
if sec != priorSec:
if self._endTime < sec:
self._endTime = sec
self._tsRates[priorSec] = count
self._tsMissRates[priorSec] = missed
self._timeoutRates[priorSec] = timeouts
self._numMissed += missed
self._numTimeouts += timeouts
( count, missed, timeouts ) = ( 0, 0, 0 )
# Advance priorSec, filling gaps w/ zeroes
while True:
priorSec += 1
if priorSec >= sec:
break
self._tsRates[priorSec] = 0
self._tsMissRates[priorSec] = 0
self._timeoutRates[priorSec] = 0
priorSec = sec
count += 1
value = self._tsValues[timestamp]
if value is None:
timeouts += 1
continue
if priorValue is not None:
if priorValue + 1 != value:
# Keep track of miss incidents
#missed += 1
# or
# Keep track of how many we missed
missed += ( value - priorValue + 1 )
priorValue = value
if sec:
self._tsRates[sec] = count
self._tsMissRates[sec] = missed
self._timeoutRates[sec] = timeouts
| 38.01087 | 98 | 0.543323 | 336 | 3,497 | 5.529762 | 0.282738 | 0.053821 | 0.067815 | 0.02422 | 0.114639 | 0.083423 | 0.059742 | 0 | 0 | 0 | 0 | 0.00887 | 0.387475 | 3,497 | 91 | 99 | 38.428571 | 0.858543 | 0.174721 | 0 | 0.026667 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0.010989 | 0 | 1 | 0.186667 | false | 0 | 0 | 0.133333 | 0.333333 | 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 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 0 | 2 |
d282949426f3fae8441528c5a9f321ae9b759d68 | 324 | py | Python | transformers/transformers/data/processors/split_sentences.py | richardbaihe/segatron_aaai | 1739b667f2bee53541f00d227da8375543fe5f11 | [
"MIT"
] | 16 | 2020-12-22T07:35:20.000Z | 2022-02-09T19:49:02.000Z | transformers/transformers/data/processors/split_sentences.py | richardbaihe/segatron_aaai | 1739b667f2bee53541f00d227da8375543fe5f11 | [
"MIT"
] | 1 | 2021-12-21T14:33:15.000Z | 2021-12-27T20:40:39.000Z | transformers/transformers/data/processors/split_sentences.py | richardbaihe/segatron_aaai | 1739b667f2bee53541f00d227da8375543fe5f11 | [
"MIT"
] | 2 | 2020-12-22T08:46:01.000Z | 2021-01-09T14:50:12.000Z | #!/usr/bin/env python3
# -*- coding:utf-8 -*-
# @Time : 2020-04-13 21:19
# @Author : Richard Bai
# @EMail : he.bai@uwaterloo.ca
import nltk
import os
import json
def sentence_split(line):
sents = nltk.tokenize.sent_tokenize(line)
rnt = [sent.split() for sent in sents]
return rnt
| 19.058824 | 49 | 0.608025 | 46 | 324 | 4.23913 | 0.76087 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0.058333 | 0.259259 | 324 | 16 | 50 | 20.25 | 0.754167 | 0.410494 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0.142857 | false | 0 | 0.428571 | 0 | 0.714286 | 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 | 0 | 1 | 0 | 1 | 0 | 0 | 2 |
96346b689665119bb71187a849bd5ed61453fc88 | 23,288 | py | Python | hkdataminer/utils/plot_.py | stephenliu1989/HK_DataMiner | 312d8244d33337971d81305ec7a9986427c669d9 | [
"Apache-2.0"
] | 3 | 2020-06-12T21:25:05.000Z | 2021-03-02T09:38:24.000Z | hkdataminer/utils/plot_.py | stephenliu1989/HK_DataMiner | 312d8244d33337971d81305ec7a9986427c669d9 | [
"Apache-2.0"
] | 1 | 2018-01-30T09:52:01.000Z | 2018-01-30T09:52:01.000Z | hkdataminer/utils/plot_.py | stephenliu1989/HK_DataMiner | 312d8244d33337971d81305ec7a9986427c669d9 | [
"Apache-2.0"
] | 1 | 2021-01-16T13:07:50.000Z | 2021-01-16T13:07:50.000Z | __author__ = 'stephen'
import numpy as np
import scipy.io
import scipy.sparse
import matplotlib
matplotlib.use('agg')
import matplotlib.pyplot as plt
import matplotlib.mlab as mlab
import matplotlib.pylab as pylab
from .utils import get_subindices
import matplotlib.ticker as mtick
from collections import Counter
from sklearn.neighbors.kde import KernelDensity
from scipy import stats
from mpl_toolkits.axes_grid1 import make_axes_locatable
def plot_cluster(labels, phi_angles, psi_angles, name, outliers=-1, step=1, potential=False):
'''
:param labels: the assignments after clustering or lumping
:param phi_angles: the phi angles
:param psi_angles: the psi angles
:param name: the name of the result pictures
:param outliers: outliers default is -1
:return: None
'''
clusters = np.unique(labels)
plt.rc("font", size=10)
if step > 1:
clusters = clusters[0:len(clusters):step]
colors_jet = plt.cm.jet(np.linspace(0, 1, np.max(clusters)+1))
if potential is False: #plot Alanine Dipeptide
for i in clusters:
if i != outliers:
point = np.where(labels == i)
plt.plot(phi_angles[point], psi_angles[point], '.', markersize=1.0, alpha=0.7)#, color=colors_jet[i])
#else:
# point = np.where(labels == i)
# plt.plot(phi_angles[point], psi_angles[point], '.', markersize=1.0, alpha=0.7, color='black') # , color=colors_jet[i])
plt.title("Alanine Dipeptide " + name + " states", fontsize=10)
# plt.xlim([-180, 180])
# plt.ylim([-180, 180])
# plt.xticks([-110, -60, 0, 60, 120])
# plt.yticks([-120, -60, 0, 60, 120])
else: # if plot 2D potential
plt.figure(figsize=(10, 10))
for i in clusters:
if i != outliers:
plt.plot(phi_angles[np.where(labels == i)],
psi_angles[np.where(labels == i)], '.', markersize=1.0, alpha=0.7) #markersize=20.0, color=colors_jet[i])
#plt.plot(phi_angles[np.where(labels == i)],
# psi_angles[np.where(labels == i)],
# '.', color=colors_jet[i], label='State %d' % i)
#plt.title("2D potential " + name + " states", fontsize=20)
plt.xlim([-75, 75])
plt.ylim([-75, 75])
plt.xticks([-50, 0, 50])
plt.yticks([-50, 0, 50])
plt.xlabel(r"$\phi$", fontsize=25)
plt.ylabel(r"$\psi$", fontsize=25)
# Save the result figure
plt.savefig('./'+name+'.png', dpi=400)
plt.close()
#plt.show()
def plot_each_cluster(labels, phi_angles, psi_angles, name, outliers=-1, step=1):
'''
:param labels: the assignments after clustering or lumping
:param phi_angles: the phi angles
:param psi_angles: the psi angles
:param name: the name of the result pictures
:param outliers: outliers default is -1
:return: None
'''
clusters = np.unique(labels)
if step > 1:
clusters = clusters[0:len(clusters):step]
colors_jet = plt.cm.jet(np.linspace(0, 1, np.max(clusters)+1))
for i in np.unique(clusters):
if i != outliers:
plt.plot(phi_angles[np.where(labels == i)],
psi_angles[np.where(labels == i)],
'x', color=colors_jet[i], label='State %d' % i)
#plt.title("Alanine Dipeptide " + name + " state_" + str(i))
plt.xlabel(r"$\phi$")
plt.ylabel(r"$\psi$")
plt.xlim([-180, 180])
plt.ylim([-180, 180])
plt.xticks([-120, -60, 0, 60, 120])
plt.yticks([-120, -60, 0, 60, 120])
# Save the result figure
plt.savefig('./'+ name + " state_" + str(i)+'.png', dpi = 400)
plt.close()
#plt.show()
def contour_cluster(labels, phi_angles, psi_angles, name, outliers=-1):
'''
:param labels: the assignments after clustering or lumping
:param phi_angles: the phi angles
:param psi_angles: the psi angles
:param name: the name of the result pictures
:param outliers: outliers default is -1
:return: None
'''
# lables_array = np.array(labels)
# colors_jet = plt.cm.jet(np.linspace(0, 1, np.max(lables_array)+1))
for i in np.unique(labels):
#if i != outliers:
if i == 1:
print("i=", i)
x = phi_angles[np.where(labels == i)]
y = psi_angles[np.where(labels == i)]
indices = get_subindices(assignments=x, state=None, samples=1000)
x = x[indices]
y = y[indices]
X, Y= np.meshgrid(x, y)
positions = np.vstack([X.ravel(), Y.ravel()])
values = np.vstack([x, y])
kernel = stats.gaussian_kde(values)
Z = np.reshape(kernel(positions).T, X.shape)
#kde = KernelDensity(kernel='gaussian', bandwidth=0.2)
#kde_results = kde.score_samples([x,y])
#X, Y, Z = np.meshgrid(x, y, kde_results)
#Z = np.reshape(kernel([x,y]).T, x.shape)
#Z1 = mlab.bivariate_normal(X, Y, 5.0, 5.0, 0.0, 0.0)
#Z2 = mlab.bivariate_normal(X, Y, 7.5, 2.5, 5, 5)
# difference of Gaussians
#Z = 10.0 * (Z2 - Z1)
#step = Z.max()-Z.min()/10
#print "Z min:",Z.min(), "Z.max:", Z.max(), "step:", step
#levels = np.arange(Z.min(), Z.min(), Z.max())
#print levels
plt.contour(X, Y, Z, origin='lower') #, linewidths=Z.min(), levels=levels)
plt.title("Alanine Dipeptide " + name + " states")
plt.xlabel(r"$\phi$")
plt.ylabel(r"$\psi$")
plt.xlim([-180, 180])
plt.ylim([-180, 180])
# Save the result figure
plt.savefig('./'+name+'.png', dpi=400)
plt.close()
#plt.show()
def plot_matrix(tProb_=None, name=None):
'''
if labels is not None:
n_states = len(set(labels)) - (1 if -1 in labels else 0)
print 'n_states=', n_states
#diagC = tProb_.diagonal()
length = len(labels)
print "length=", length
Cmn = scipy.sparse.lil_matrix(n_states, n_states, dtype=np.float32)
Cmn = np.zeros((n_states, n_states))
print "size of tProb", tProb_.shape
if scipy.sparse.issparse(tProb_):
tProb_ = tProb_.todense()
for i in xrange(length):
for j in xrange(length):
Cmn[labels[i], labels[j]] += tProb_[i, j]
#for i in xrange(n_states):
#Cmn[i,i] += diagC[i]
# for j in xrange(n_states):
# Cmn[i, j] += Cmn[j, i]
# Cmn[j, i] = Cmn[i, j]
for j in xrange(n_states):
sum_row = np.sum(Cmn[j,:])
if sum_row is not 0:
Cmn[j,:] /= sum_row
pylab.matshow(Cmn, cmap=plt.cm.OrRd)
else:
'''
pylab.matshow(tProb_, cmap=plt.cm.OrRd)
plt.colorbar()
#pylab.show()
plt.savefig('./' + name + 'Matrix.png', dpi=400)
plt.close()
def plot_block_matrix(labels, tProb_, name='BlockMatrix'):
print("Plot Block Matrix")
indices = np.argsort(labels)
#print indices
block_matrix = tProb_[:,indices]
block_matrix = block_matrix[indices,:]
block_matrix = 1 - block_matrix
#print block_matrix
pylab.matshow(block_matrix, cmap=plt.cm.OrRd)
plt.colorbar()
plt.savefig('./' + name + '.png', dpi=400)
#pylab.show()
plt.close()
def plot_cluster_size_distribution(populations, name='Populations'):
fig = plt.figure(1, (10,6))
distrib = fig.add_subplot(1,1,1)
fmt = '%.0f%%' # Format you want the ticks, e.g. '40%'
xticks = mtick.FormatStrFormatter(fmt)
distrib.yaxis.set_major_formatter(xticks)
plt.rc("font", size=30)
plt.title('Cluster size distributions', fontsize=20)
distrib.grid(True)
X = range(len(populations))
X_xtick = ['']
for i in xrange(1, len(populations)+1):
xx = '$10^' + str(i) + '$'
X_xtick.append(xx)
print(X_xtick)
#plt.xticks(X , ('$10^0$', '$10^1$', '$10^2$', '$10^3$', '$10^4$'))
plt.xticks(np.arange(len(populations)+1), X_xtick)
plt.ylabel(r"Probability")
plt.ylim([0,100])
print("X:", X)
distrib.bar(X, populations*100, facecolor='black', edgecolor='white', width=1.0) #facecolor='#f78181',
plt.savefig('./' + name + '_Distribution.png', dpi=400)
plt.close()
#plt.show()
def plot_compare_cluster_size_distribution(populations_1, populations_2, name='Populations'):
fig = plt.figure(1, (10,8))
distrib = fig.add_subplot(1,1,1)
fmt = '%.0f%%' # Format you want the ticks, e.g. '40%'
xticks = mtick.FormatStrFormatter(fmt)
distrib.yaxis.set_major_formatter(xticks)
bar_width = 0.45
plt.rc("font", size=20)
#plt.title('Cluster size distributions', fontsize=20)
distrib.grid(True)
X = np.arange(len(populations_1))
X_xtick = ['']
for i in xrange(1, len(populations_1)+1):
xx = '$10^' + str(i) + '$'
X_xtick.append(xx)
print(X_xtick)
#plt.xticks(X , ('$10^0$', '$10^1$', '$10^2$', '$10^3$', '$10^4$'))
print("X:", X)
distrib.bar(X, populations_1*100, facecolor='black', edgecolor='white', width=bar_width,label="kNN Density Peaks 3645 states") #facecolor='#f78181',
# populations_2
#X = range(len(populations_2))
X_xtick = ['']
for i in xrange(1, len(populations_2)+1):
xx = '$10^' + str(i) + '$'
X_xtick.append(xx)
print(X_xtick)
#plt.xticks(X , ('$10^0$', '$10^1$', '$10^2$', '$10^3$', '$10^4$'))
print("X:", X)
distrib.bar(X+bar_width, populations_2*100, facecolor='gray', edgecolor='white', width=bar_width, label="kNN Density Peaks 117 states") #facecolor='#f78181',
plt.xticks(np.arange(len(populations_1)+1+bar_width), X_xtick)
#plt.ylabel(r"Fraction number of clusters")
plt.ylabel(r"Probability")
plt.ylim([0,60])
plt.legend()
plt.savefig('./' + name + '_Distribution.png', dpi=400)
plt.close()
#plt.show()
#From Wang Wei's code
def plot_landscape(labels=None, phi_angles=None, psi_angles=None, phi_ctr=None, psi_ctr=None, name='Energy_Landscape', bins=80, potential=False):
H, xedges, yedges = np.histogram2d(psi_angles, phi_angles, bins=bins)
#since we calculate total number in 10 interval, thus bin of every dimension must be 36
#If element in H is zero, set the final energy to be 9
plt.rc("font", size=25)
maxH = np.max(H)
for i in range(len(H)):
for j in range(len(H)):
if H[i][j]==0:
H[i][j]=9
else:
H[i][j] = -np.log(H[i][j]/maxH)
#H = -np.log(H/np.max(H))
extent =[np.min(xedges), np.max(xedges), np.min(yedges), np.max(yedges)]
plt.figure(figsize=(12, 12))
plt.imshow(H, extent=extent, origin="lower", cmap=plt.cm.gray) #plt.cm.jet
#plot cluster centers on landscape
if labels is not None:
plt.plot(phi_ctr, psi_ctr, '.', markersize=10, color='r')
distribution = np.array([0,0,0,0,0,0,0,0,0,0], dtype=np.float64)
#print "len phi_ctr", len(phi_ctr)
#print "shape of xedges", xedges.shape
for i in range(0, len(phi_angles)):
if psi_angles[i] > 179.0:
index_x = np.where(xedges > 179.0)[0][0] - 1
else:
index_x = np.where(xedges > psi_angles[i])[0][0] - 1
if phi_angles[i] > 179.0:
index_y = np.where(yedges > 179.0)[0][0] - 1
else:
index_y = np.where(yedges > phi_angles[i])[0][0] - 1
index_distrib = int(H[index_x][index_y])
distribution[index_distrib] += 1
distribution /= len(phi_angles)
print(distribution)
# print "clenter:", i, "[", phi_ctr,",", psi_ctr,"]", "H=", H[index_x][index_y]
plt.xlabel('$\phi$', fontsize=20)
plt.ylabel('$\Psi$', fontsize=20)
cbar = plt.colorbar(shrink=0.77)
#plt.title('Free energy landscape', fontsize=20)
cbar.set_label("$k_B T$", size=20)
cbar.ax.tick_params(labelsize=20)
if potential is False:
plt.xlim([-180, 180])
plt.ylim([-180, 180])
plt.xticks([-120, -60, 0, 60, 120])
plt.yticks([-120, -60, 0, 60, 120])
else:
plt.xlim([-75, 75])
plt.ylim([-75, 75])
plt.xticks([-50, 0, 50])
plt.yticks([-50, 0, 50])
plt.savefig('./' + name + '.png', dpi=400)
#plt.show()
plt.close()
#Cluster Centers on Free energy landscape distribution
fig = plt.figure(1, (10,6))
plt.rc("font", size=15)
distrib = fig.add_subplot(1,1,1)
distrib.grid(True)
fmt = '%.0f%%' # Format you want the ticks, e.g. '40%'
xticks = mtick.FormatStrFormatter(fmt)
distrib.yaxis.set_major_formatter(xticks)
plt.title('Cluster Centers on Free energy landscape distribution', fontsize=20)
plt.xlabel("$k_B T$")
plt.ylabel(r"Probability")
plt.ylim([0, 100])
plt.xticks(np.arange(11), ('', '1', '', '3', '', '5', '', '7', '', '9', ''))
distrib.bar(np.arange(10), distribution*100, facecolor='black', edgecolor='white', width=1.0) #facecolor='#f78181'
plt.savefig('./' + name + '_Distribution.png', dpi=400)
#plt.show()
plt.close()
def plot_compare_distribution(labels_1=None, labels_2=None, phi_angles=None, psi_angles=None, phi_ctr_1=None, psi_ctr_1=None, phi_ctr_2=None, psi_ctr_2=None, name='Energy_Landscape', bins=36, potential=False):
H, xedges, yedges = np.histogram2d(psi_angles, phi_angles, bins=bins)
#since we calculate total number in 10 interval, thus bin of every dimension must be 36
#If element in H is zero, set the final energy to be 9
plt.rc("font", size=25)
maxH = np.max(H)
for i in range(len(H)):
for j in range(len(H)):
if H[i][j]==0:
H[i][j]=9
else:
H[i][j] = -np.log(H[i][j]/maxH)
#H = -np.log(H/np.max(H))
#extent =[np.min(xedges), np.max(xedges), np.min(yedges), np.max(yedges)]
#plt.figure(figsize=(10, 10))
#plt.imshow(H, extent=extent, origin="lower", cmap=plt.cm.gray) #plt.cm.jet
#plot cluster centers on landscape
#if labels_1 is not None:
# plt.plot(phi_ctr_1, psi_ctr_1, '*', markersize=8, color='r')
distribution_1 = np.array([0,0,0,0,0,0,0,0,0,0], dtype=np.float64)
for i in xrange(0, len(phi_ctr_1)):
if psi_ctr_1[i] > 179.0:
index_x = np.where(xedges > 179.0)[0][0] - 1
else:
index_x = np.where(xedges > psi_ctr_1[i])[0][0] - 1
if phi_ctr_1[i] > 179.0:
index_y = np.where(yedges > 179.0)[0][0] - 1
else:
index_y = np.where(yedges > phi_ctr_1[i])[0][0] - 1
index_distrib = int(H[index_x][index_y])
distribution_1[index_distrib] += 1
distribution_1 /= len(phi_ctr_1)
print(distribution_1)
distribution_2 = np.array([0,0,0,0,0,0,0,0,0,0], dtype=np.float64)
for i in xrange(0, len(phi_ctr_2)):
if psi_ctr_2[i] > 179.0:
index_x = np.where(xedges > 179.0)[0][0] - 1
else:
index_x = np.where(xedges > psi_ctr_2[i])[0][0] - 1
if phi_ctr_2[i] > 179.0:
index_y = np.where(yedges > 179.0)[0][0] - 1
else:
index_y = np.where(yedges > phi_ctr_2[i])[0][0] - 1
index_distrib = int(H[index_x][index_y])
distribution_2[index_distrib] += 1
distribution_2 /= len(phi_ctr_2)
print(distribution_2)
# print "clenter:", i, "[", phi_ctr,",", psi_ctr,"]", "H=", H[index_x][index_y]
plt.xlabel('$\phi$', fontsize=20)
plt.ylabel('$\Psi$', fontsize=20)
#cbar = plt.colorbar(shrink=0.77)
##plt.title('Free energy landscape', fontsize=20)
#cbar.set_label("$k_B T$", size=20)
#cbar.ax.tick_params(labelsize=20)
#if potential is False:
# plt.xlim([-180, 180])
# plt.ylim([-180, 180])
# plt.xticks([-120, -60, 0, 60, 120])
# plt.yticks([-120, -60, 0, 60, 120])
#else:
# plt.xlim([-75, 75])
# plt.ylim([-75, 75])
# plt.xticks([-50, 0, 50])
# plt.yticks([-50, 0, 50])
#plt.savefig('./' + name + '.png', dpi=400)
##plt.show()
#plt.close()
#Cluster Centers on Free energy landscape distribution
fig=plt.figure(1, (10,6))
plt.rc("font", size=15)
distrib = fig.add_subplot(1,1,1)
distrib.grid(True)
fmt = '%.0f%%' # Format you want the ticks, e.g. '40%'
xticks = mtick.FormatStrFormatter(fmt)
distrib.yaxis.set_major_formatter(xticks)
# plt.xticks(np.arange(11), ('', '1', '', '3', '', '5', '', '7', '', '9', ''))
n_groups = 10
index = np.arange(n_groups)
bar_width = 0.45
distrib.bar(index, distribution_1*100, facecolor='black', edgecolor='white', width=bar_width, label="kNN Density Peaks 3645 states") #facecolor='#f78181'
distrib.bar(index+bar_width, distribution_2*100, facecolor='gray', edgecolor='white', width=bar_width, label="kNN Density Peaks 117 states")
#plt.title('Cluster Centers on Free energy landscape distribution', fontsize=10)
plt.xlabel("$k_B T$")
plt.ylabel(r"Fraction number of clusters")
plt.ylim([0, 50])
plt.xticks(index+bar_width, ('', '1', '', '3', '', '5', '', '7', '', '9', ''))
plt.legend()
#plt.tight_layout()
plt.savefig('./' + name + '_Distribution.png', dpi=400)
#plt.show()
plt.close()
def plot_landscape_barrier(labels=None, selected=1, phi_angles=None, psi_angles=None, phi_ctr=None, psi_ctr=None, name='Energy_Landscape', bins=36, potential=False, outliers=-1):
H, xedges, yedges = np.histogram2d(psi_angles, phi_angles, bins=bins)
#since we calculate total number in 10 interval, thus bin of every dimension must be 36
#If element in H is zero, set the final energy to be 9
plt.rc("font", size=25)
maxH = np.max(H)
for i in range(len(H)):
for j in range(len(H)):
if H[i][j]==0:
H[i][j]=9
else:
H[i][j] = -np.log(H[i][j]/maxH)
#H = -np.log(H/np.max(H))
extent =[np.min(xedges), np.max(xedges), np.min(yedges), np.max(yedges)]
plt.figure(figsize=(12, 12))
plt.imshow(H, extent=extent, origin="lower", cmap=plt.cm.gray) #plt.cm.jet
#plot points
colors = ['y', 'b', 'tomato', 'm', 'g', 'c', 'yellowgreen']
color_index = 0
clusters = np.unique(labels)
for i in clusters:
if i != outliers:
if i in selected:
point = np.where(labels == i)
plt.plot(phi_angles[point], psi_angles[point], '2', alpha=0.20, color=colors[color_index])#, color=colors_jet[i])
color_index += 1
#plot cluster centers on landscape
if labels is not None:
plt.plot(phi_ctr, psi_ctr, '*', markersize=10, color='r')
distribution = np.array([0,0,0,0,0,0,0,0,0,0], dtype=np.float64)
#print "len phi_ctr", len(phi_ctr)
#print "shape of xedges", xedges.shape
for i in xrange(0, len(phi_ctr)):
if psi_ctr[i] > 179.0:
index_x = np.where(xedges > 179.0)[0][0] - 1
else:
index_x = np.where(xedges > psi_ctr[i])[0][0] - 1
if phi_ctr[i] > 179.0:
index_y = np.where(yedges > 179.0)[0][0] - 1
else:
index_y = np.where(yedges > phi_ctr[i])[0][0] - 1
index_distrib = int(H[index_x][index_y])
distribution[index_distrib] += 1
distribution /= len(phi_ctr)
print(distribution)
# print "clenter:", i, "[", phi_ctr,",", psi_ctr,"]", "H=", H[index_x][index_y]
plt.xlabel('$\phi$', fontsize=20)
plt.ylabel('$\Psi$', fontsize=20)
cbar = plt.colorbar(shrink=0.77)
#plt.title('Free energy landscape', fontsize=20)
cbar.set_label("$k_B T$", size=20)
cbar.ax.tick_params(labelsize=20)
plt.xlim([-180, 180])
plt.ylim([-180, 180])
plt.xticks([-120, -60, 0, 60, 120])
plt.yticks([-120, -60, 0, 60, 120])
plt.plot([-103,-103],[30,180],'w') #plot the barrier
plt.savefig('./' + name + '.png', dpi=400)
#plt.show()
plt.close()
def calculate_population(labels, name='Populations'):
print("Calculating and plotting population...")
counts = list(Counter(labels).values())
total_states = np.max(labels) + 1
#states_magnitude = int(np.ceil(np.log10(total_states)))
total_frames = len(labels)
frames_magnitude = int(np.ceil(np.log10(total_frames)))
print("states", total_states, "frames", total_frames)
populations = np.zeros(frames_magnitude+1)
for i in counts:
if i > 0:
log_i = np.log10(i)
magnitude = np.ceil(log_i)
populations[magnitude] += 1
#print magnitude populations
print("Populations Probability:")
#bins = [0]
for i in xrange(len(populations)):
populations[i] = populations[i] / total_states
print("10 ^", i, "to", "10 ^", i+1,":", populations[i]*100, "%")
#bins.append(10**(i+1))
name += '_Populations'
print("name:", name)
plot_cluster_size_distribution(populations=populations, name=name)
print("Done.")
def compare_population(labels_1, labels_2, name='Compare_Populations'):
print("Calculating and plotting population...")
counts = list(Counter(labels_1).values())
total_states = np.max(labels_1) + 1
total_frames = len(labels_1)
frames_magnitude = int(np.ceil(np.log10(total_frames)))
print("states", total_states, "frames", total_frames)
populations_1 = np.zeros(frames_magnitude+1)
for i in counts:
if i > 0:
log_i = np.log10(i)
magnitude = np.ceil(log_i)
populations_1[magnitude] += 1
print("Populations Probability:")
for i in xrange(len(populations_1)):
populations_1[i] = populations_1[i] / total_states
print("10 ^", i, "to", "10 ^", i+1,":", populations_1[i]*100, "%")
counts = list(Counter(labels_2).values())
total_states = np.max(labels_2) + 1
total_frames = len(labels_2)
frames_magnitude = int(np.ceil(np.log10(total_frames)))
print("states", total_states, "frames", total_frames)
populations_2 = np.zeros(frames_magnitude+1)
for i in counts:
if i > 0:
log_i = np.log10(i)
magnitude = np.ceil(log_i)
populations_2[magnitude] += 1
print("Populations Probability:")
for i in xrange(len(populations_2)):
populations_2[i] = populations_2[i] / total_states
print("10 ^", i, "to", "10 ^", i+1,":", populations_2[i]*100, "%")
name += '_Populations'
print("name:", name)
plot_compare_cluster_size_distribution(populations_1=populations_1, populations_2=populations_2, name=name)
#plot_cluster_size_distribution(populations_1=populations_1, name=name)
print("Done.")
def calculate_landscape(labels, centers, phi_angles, psi_angles, potential=False, name='Energy_Landscape'):
print("Calculating and plotting Landscape...")
phi_ctr = phi_angles[centers]
psi_ctr = psi_angles[centers]
labels_ctr = labels[centers]
name = name + '_Energy_Landscape'
print("name:", name)
plot_landscape(labels=labels_ctr, phi_angles=phi_angles, psi_angles=psi_angles, phi_ctr=phi_ctr, psi_ctr=psi_ctr, potential=potential, name=name)
print("Done")
#plot_landscape(labels=None, phi_angles=phi_angles, psi_angles=psi_angles)
| 38.556291 | 209 | 0.591635 | 3,425 | 23,288 | 3.905985 | 0.091095 | 0.009568 | 0.009643 | 0.00897 | 0.753476 | 0.729257 | 0.691135 | 0.649275 | 0.616759 | 0.607565 | 0 | 0.055339 | 0.238793 | 23,288 | 603 | 210 | 38.620232 | 0.699329 | 0.259318 | 0 | 0.588542 | 0 | 0 | 0.071953 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0.033854 | false | 0 | 0.033854 | 0 | 0.067708 | 0.078125 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 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 | 2 |
963c73799bbdb00fb97205577d7028cae7121d80 | 1,535 | py | Python | tests/conftest.py | banteg/lido-vault | 702fa9c58a26c01c61b24489d18ea099e22e8b09 | [
"MIT"
] | 22 | 2020-12-19T10:07:38.000Z | 2022-01-03T03:28:08.000Z | tests/conftest.py | banteg/lido-vault | 702fa9c58a26c01c61b24489d18ea099e22e8b09 | [
"MIT"
] | 1 | 2020-12-23T22:32:42.000Z | 2020-12-23T22:35:56.000Z | tests/conftest.py | banteg/lido-vault | 702fa9c58a26c01c61b24489d18ea099e22e8b09 | [
"MIT"
] | 1 | 2020-12-21T08:45:07.000Z | 2020-12-21T08:45:07.000Z | import pytest
from brownie import Wei
@pytest.fixture(scope="function", autouse=True)
def shared_setup(fn_isolation):
pass
@pytest.fixture(scope='module')
def nocoiner(accounts, lido):
assert lido.balanceOf(accounts[9]) == 0
return accounts[9]
@pytest.fixture(scope='module')
def ape(accounts):
return accounts[0]
@pytest.fixture(scope='module')
def whale(accounts):
return accounts[1]
@pytest.fixture()
def vault(LidoVault, ape):
return LidoVault.deploy({"from": ape})
@pytest.fixture(scope='module')
def lido(interface, accounts):
lido = interface.Lido("0xae7ab96520DE3A18E5e111B5EaAb095312D7fE84")
oracle = accounts.at(lido.getOracle(), force=True)
return interface.Lido(lido, owner=oracle)
class Helpers:
@staticmethod
def filter_events_from(addr, events):
return list(filter(lambda evt: evt.address == addr, events))
@staticmethod
def assert_single_event_named(evt_name, tx, evt_keys_dict):
receiver_events = Helpers.filter_events_from(tx.receiver, tx.events[evt_name])
assert len(receiver_events) == 1
assert dict(receiver_events[0]) == evt_keys_dict
@staticmethod
def report_beacon_balance_increase(lido):
beacon_stat = lido.getBeaconStat().dict()
total_pooled_ether = lido.getTotalPooledEther()
new_beacon_balance = Wei(total_pooled_ether * 1.5) + "1 ether"
lido.pushBeacon(beacon_stat['beaconValidators'], new_beacon_balance)
@pytest.fixture(scope='module')
def helpers():
return Helpers
| 25.583333 | 84 | 0.721173 | 190 | 1,535 | 5.663158 | 0.373684 | 0.084572 | 0.100372 | 0.111524 | 0.125465 | 0 | 0 | 0 | 0 | 0 | 0 | 0.026336 | 0.158958 | 1,535 | 59 | 85 | 26.016949 | 0.807126 | 0 | 0 | 0.195122 | 0 | 0 | 0.069707 | 0.027362 | 0 | 0 | 0.027362 | 0 | 0.097561 | 1 | 0.243902 | false | 0.02439 | 0.04878 | 0.121951 | 0.487805 | 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 | 0 | 0 | 0 | 2 |
9640feccc968d6a78b76b7178f48a08b2309b36c | 5,459 | py | Python | builder/action.py | nagisc007/storybuilder | 54b28934de8acedbe35930ce27e12a7e75f91be0 | [
"MIT"
] | null | null | null | builder/action.py | nagisc007/storybuilder | 54b28934de8acedbe35930ce27e12a7e75f91be0 | [
"MIT"
] | 176 | 2019-03-07T13:31:26.000Z | 2019-11-02T12:38:23.000Z | builder/action.py | nagisc007/storybuilder | 54b28934de8acedbe35930ce27e12a7e75f91be0 | [
"MIT"
] | null | null | null | # -*- coding: utf-8 -*-
"""Define action class.
"""
from enum import Enum
from . import assertion
from .basedata import BaseData
from .description import Description, NoDesc, DescType
from .flag import Flag, NoFlag, NoDeflag
from .basesubject import NoSubject
from .person import Person
from .chara import Chara
from .who import Who
class ActType(Enum):
"""Action type.
"""
ACT = "act" # 全般
MOVE = "move" # 動かす
COME = "come" # 出現
GO = "go" # 消去
LOOK = "look" # 描画
BE = "be" # 外部状態
THINK = "think" # 内部状態
HAVE = "have" # 所有変更
HEAR = "hear" # 効果音などの音声
TALK = "talk" # 台詞
TAG = "tag" # for tag
class TagType(Enum):
"""Tag type
"""
BR = "breakline" # BR
COMMENT = "comment" # コメント
HR = "horizontalline" # HR
SYMBOL = "symbol" # シンボル
TITLE = "title" # タイトル
SET_LAYER = "layer" # レイヤー用
class Action(BaseData):
"""Data type of an action.
"""
DEF_PRIORITY = 5
MAX_PRIORITY = 10
MIN_PRIORITY = 0
DEF_LAYER = "__default__"
MAIN_LAYER = "main"
def __init__(self, subject: [Person, Chara, None],
outline: str="", act_type: ActType=ActType.ACT,
layer: str=DEF_LAYER):
super().__init__("__action__")
_subject_is_str = isinstance(subject, str)
self._subject = Who() if _subject_is_str else Action._validatedSubject(subject)
self._outline = assertion.is_str(subject if _subject_is_str else outline)
self._act_type = assertion.is_instance(act_type, ActType)
self._description = NoDesc()
self._flag = NoFlag()
self._deflag = NoDeflag()
self._priority = Action.DEF_PRIORITY
self._layer = assertion.is_str(layer)
def inherited(self, subject=None, outline=None, desc=None):
return Action(subject if subject else self.subject,
outline if outline else self.outline,
self.act_type) \
.flag(self.getFlag()).deflag(self.getDeflag()) \
._setDescription(desc if desc else self.description,
self.description.desc_type) \
.setPriority(self.priority) \
.setLayer(self.layer)
@property
def act_type(self): return self._act_type
@property
def subject(self): return self._subject
@property
def outline(self): return self._outline
@property
def description(self): return self._description
@property
def priority(self): return self._priority
@property
def layer(self): return self._layer
def setPriority(self, pri: int):
self._priority = assertion.is_between(assertion.is_int(pri),
Action.MAX_PRIORITY, Action.MIN_PRIORITY)
return self
def setLayer(self, layer: str):
self._layer = assertion.is_str(layer)
return self
def flag(self, val: [str, NoFlag]):
if isinstance(val, Flag):
self._flag = val
elif isinstance(val, str):
self._flag = Flag(val)
else:
self._flag = NoFlag()
return self
def deflag(self, val: [str, NoDeflag]):
if isinstance(val, Flag):
self._deflag = val
elif isinstance(val, str):
self._deflag = Flag(val, True)
else:
self._deflag = NoDeflag()
return self
def getFlag(self): return self._flag
def getDeflag(self): return self._deflag
def omit(self):
self._priority = Action.MIN_PRIORITY
return self
# methods
def desc(self, *args):
self._description = Description(*args, desc_type=DescType.DESC)
return self
def d(self, *args): return self.desc(*args)
def tell(self, *args):
self._description = Description(*args, desc_type=DescType.DIALOGUE)
return self
def t(self, *args): return self.tell(*args)
def comp(self, *args):
self._description = Description(*args, desc_type=DescType.COMPLEX)
return self
def same(self, desc_type: str=None):
if not desc_type:
desc_type = 't' if self.act_type is ActType.TALK else 'd'
if desc_type in ('t', 'tell'):
self.tell(self.outline)
elif desc_type in ('c', 'comp'):
self.comp(self.outline)
else:
self.desc(self.outline)
return self
# private
def _validatedSubject(sub: [str, Person, Chara, None]):
if isinstance(sub, str):
return Who()
elif isinstance(sub, (Person, Chara)):
return sub
else:
return NoSubject()
def _setDescription(self, descs, desc_type: DescType):
if isinstance(descs, Description):
self._description = descs
else:
self._description = Description(*descs,
desc_type=desc_type)
return self
class TagAction(Action):
def __init__(self, info: str, subinfo: str="", tag_type: TagType=TagType.COMMENT):
super().__init__(None, info, ActType.TAG)
self._subinfo = assertion.is_str(subinfo)
self._tag_type = assertion.is_instance(tag_type, TagType)
@property
def info(self): return self._outline
@property
def subinfo(self): return self._subinfo
@property
def tag_type(self): return self._tag_type
def inherited(self):
return TagAction(self, self.info, self.subinfo, self.tag_type)
| 28.432292 | 87 | 0.605972 | 645 | 5,459 | 4.948837 | 0.186047 | 0.072055 | 0.048246 | 0.021617 | 0.152882 | 0.127193 | 0.050752 | 0.050752 | 0.050752 | 0 | 0 | 0.001284 | 0.286683 | 5,459 | 191 | 88 | 28.581152 | 0.818439 | 0.03627 | 0 | 0.236111 | 0 | 0 | 0.023372 | 0 | 0 | 0 | 0 | 0 | 0.055556 | 1 | 0.194444 | false | 0 | 0.0625 | 0.104167 | 0.541667 | 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 | 0 | 0 | 1 | 1 | 0 | 0 | 2 |
964481acbba226d6bc1f722acc9bd0960d9cebe5 | 936 | py | Python | Lesson3/coefficient_of_determination2.py | rmhyman/DataScience | c839c97c76f104ab298563a5c8b48f6d90be5f60 | [
"MIT"
] | 1 | 2015-09-17T18:49:09.000Z | 2015-09-17T18:49:09.000Z | Lesson3/coefficient_of_determination2.py | rmhyman/DataScience | c839c97c76f104ab298563a5c8b48f6d90be5f60 | [
"MIT"
] | null | null | null | Lesson3/coefficient_of_determination2.py | rmhyman/DataScience | c839c97c76f104ab298563a5c8b48f6d90be5f60 | [
"MIT"
] | null | null | null | import numpy as np
import scipy
import matplotlib.pyplot as plt
import sys
def compute_r_squared(data, predictions):
'''
In exercise 5, we calculated the R^2 value for you. But why don't you try and
and calculate the R^2 value yourself.
Given a list of original data points, and also a list of predicted data points,
write a function that will compute and return the coefficient of determination (R^2)
for this data. numpy.mean() and numpy.sum() might both be useful here, but
not necessary.
Documentation about numpy.mean() and numpy.sum() below:
http://docs.scipy.org/doc/numpy/reference/generated/numpy.mean.html
http://docs.scipy.org/doc/numpy/reference/generated/numpy.sum.html
'''
mean = data.mean()
numerator = np.sum((data - predictions)**2)
denom = np.sum((data-mean)**2)
r_squared = 1 - numerator/denom
return r_squared | 36 | 89 | 0.679487 | 142 | 936 | 4.450704 | 0.5 | 0.037975 | 0.015823 | 0.031646 | 0.212025 | 0.148734 | 0.148734 | 0.148734 | 0.148734 | 0 | 0 | 0.009682 | 0.227564 | 936 | 26 | 90 | 36 | 0.864454 | 0.602564 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0.1 | false | 0 | 0.4 | 0 | 0.6 | 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 | 0 | 1 | 0 | 1 | 0 | 0 | 2 |
964683b856f9816db2cfc1191cef1b460b9b0c10 | 2,030 | py | Python | logsight/result/template.py | aiops/logsight-sdk-py | 35fd9f99eb03472dee7ae6a1639502b7ea0c485e | [
"MIT"
] | 1 | 2021-10-02T09:29:10.000Z | 2021-10-02T09:29:10.000Z | logsight/result/template.py | aiops/logsight-sdk-py | 35fd9f99eb03472dee7ae6a1639502b7ea0c485e | [
"MIT"
] | null | null | null | logsight/result/template.py | aiops/logsight-sdk-py | 35fd9f99eb03472dee7ae6a1639502b7ea0c485e | [
"MIT"
] | null | null | null |
class Template:
def __init__(self, data):
"""Class representing log templates.
Note:
Timestamps are represented in ISO format with timezone information.
e.g, 2021-10-07T13:18:09.178477+02:00.
"""
self._timestamp = data.get("@timestamp", None)
self._actual_level = data.get("actual_level", None)
self._app_name = data.get("app_name", None)
self._message = data.get("message", None)
self._name = data.get("name", None)
self._params = data.get("params", None)
self._template = data.get("template", None)
self._tag = data.get("tag", None)
def __repr__(self):
return {"app_name": self._app_name, "template": self._template}
@property
def timestamp(self):
"""str: Timestamp when the log message was generated."""
return self._timestamp
@property
def actual_level(self):
"""str: Log level of the message (e.g., WARNING)."""
return self._actual_level
@property
def app_name(self):
"""str: Application name."""
return self._app_name
@property
def message(self):
"""str: Log message."""
return self._message
@property
def name(self):
"""str: Name."""
return self._name
@property
def template(self):
"""str: Template generated from log message.
Examples:
nova.virt.libvirt.imagecache <*> ] <*> base <*> <*>
"""
return self._template
@property
def params(self):
"""(:obj:`list` of :obj:`str`): Parameters extracted from log message.
Examples:
"param_0":"[req-addc1839-2ed5-4778-b57e-5854eb7b8b09"
"param_1":"Unknown"
"param_2":"file:"
"param_3":"/var/lib/nova/instances/_base/a489c868..."
"""
return self._params
@property
def tag(self):
"""str: Tag associated with a log message.
"""
return self._tag
| 25.375 | 79 | 0.567488 | 231 | 2,030 | 4.809524 | 0.34632 | 0.050405 | 0.029703 | 0.041404 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0.037815 | 0.296552 | 2,030 | 79 | 80 | 25.696203 | 0.740196 | 0.348276 | 0 | 0.222222 | 0 | 0 | 0.063465 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0.277778 | false | 0 | 0 | 0.027778 | 0.555556 | 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 | 0 | 1 | 0 | 0 | 2 |
964933bf3abeb9eecd5bbbd430d2ba1f1f9daec5 | 142 | py | Python | Python practice/Mit opencourceware(2.7)/quiz1_p2.py | chiranjeevbitp/Python27new | d366efee57857402bae16cabf1df94c657490750 | [
"bzip2-1.0.6"
] | null | null | null | Python practice/Mit opencourceware(2.7)/quiz1_p2.py | chiranjeevbitp/Python27new | d366efee57857402bae16cabf1df94c657490750 | [
"bzip2-1.0.6"
] | null | null | null | Python practice/Mit opencourceware(2.7)/quiz1_p2.py | chiranjeevbitp/Python27new | d366efee57857402bae16cabf1df94c657490750 | [
"bzip2-1.0.6"
] | null | null | null | #import pdb
T = (0.1, 0.1)
x = 0.0
for i in range(len(T)):
for j in T:
x += i + j
print x
print i
#pdb.set_trace()
| 14.2 | 24 | 0.464789 | 30 | 142 | 2.166667 | 0.5 | 0.061538 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0.068182 | 0.380282 | 142 | 9 | 25 | 15.777778 | 0.670455 | 0.176056 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | null | null | 0 | 0 | null | null | 0.285714 | 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 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 2 |
964d60906285ddfcdeb808da94455db7bd3067ea | 5,998 | py | Python | meAdota/settings.py | guipeeix7/website | 4081899060e69688314a5577ceab5c7b840e7b7f | [
"MIT"
] | 6 | 2020-10-19T23:13:07.000Z | 2020-12-02T19:08:32.000Z | meAdota/settings.py | guipeeix7/website | 4081899060e69688314a5577ceab5c7b840e7b7f | [
"MIT"
] | 69 | 2020-10-23T03:52:47.000Z | 2020-12-04T01:12:49.000Z | meAdota/settings.py | guipeeix7/website | 4081899060e69688314a5577ceab5c7b840e7b7f | [
"MIT"
] | 1 | 2020-12-08T22:10:08.000Z | 2020-12-08T22:10:08.000Z | """
Django settings for meAdota project.
Generated by 'django-admin startproject' using Django 3.1.1.
For more information on this file, see
https://docs.djangoproject.com/en/3.1/topics/settings/
For the full list of settings and their values, see
https://docs.djangoproject.com/en/3.1/ref/settings/
"""
from pathlib import Path
# Load dotenv
import os
from dotenv import load_dotenv
load_dotenv()
# Build paths inside the project like this: BASE_DIR / 'subdir'.
BASE_DIR = Path(__file__).resolve().parent.parent
# Quick-start development settings - unsuitable for production
# See https://docs.djangoproject.com/en/3.1/howto/deployment/checklist/
# SECURITY WARNING: keep the secret key used in production secret!
SECRET_KEY = os.getenv("SECRET_KEY")
# SECURITY WARNING: don't run with debug turned on in production!
DEBUG = True
ALLOWED_HOSTS = ['127.0.0.1', 'localhost']
STATIC_ROOT = ''
STATIC_URL = '/static/'
STATICFILES_DIRS = ('static',)
# Application definition
INSTALLED_APPS = [
'django.contrib.admin',
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.messages',
'django.contrib.staticfiles',
'django.contrib.sites',
'allauth',
'allauth.account',
'allauth.socialaccount',
'django_countries',
'cpf_field',
'django_filters',
# AllAuth [custom providers]
'allauth.socialaccount.providers.facebook',
'allauth.socialaccount.providers.google',
'allauth.socialaccount.providers.twitter',
#my apps
'users',
'pets',
'crispy_forms',
]
CRISPY_TEMPLATE_PACK = 'bootstrap4'
SITE_ID = 1
AUTH_USER_MODEL = 'users.User'
#verify email
EMAIL_BACKEND = 'django.core.mail.backends.console.EmailBackend' #check email on console
ACCOUNT_EMAIL_VERIFICATION = True
ACCOUNT_EMAIL_REQUIRED = True
ACCOUNT_USERNAME_REQUIRED = False
ACCOUNT_AUTHENTICATION_METHOD = 'email'
ACCOUNT_USER_MODEL_USERNAME_FIELD = None
ACCOUNT_LOGOUT_ON_GET = True
MIDDLEWARE = [
'django.middleware.security.SecurityMiddleware',
'django.contrib.sessions.middleware.SessionMiddleware',
'django.middleware.common.CommonMiddleware',
'django.middleware.csrf.CsrfViewMiddleware',
'django.contrib.auth.middleware.AuthenticationMiddleware',
'django.contrib.messages.middleware.MessageMiddleware',
'django.middleware.clickjacking.XFrameOptionsMiddleware',
]
ROOT_URLCONF = 'meAdota.urls'
ACCOUNT_FORMS = {
'login': 'users.forms.MyLoginForm',
# 'signup': 'allauth.account.forms.SignupForm',
'signup': 'users.forms.MyCustomSignupForm',
'add_email': 'allauth.account.forms.AddEmailForm',
'change_password': 'allauth.account.forms.ChangePasswordForm',
'set_password': 'allauth.account.forms.SetPasswordForm',
'reset_password': 'allauth.account.forms.ResetPasswordForm',
'reset_password_from_key': 'allauth.account.forms.ResetPasswordKeyForm',
'disconnect': 'allauth.socialaccount.forms.DisconnectForm',
}
SOCIALACCOUNT_PROVIDERS = {
'facebook': {
'METHOD': 'oauth2',
'SDK_URL': '//connect.facebook.net/{locale}/sdk.js',
'SCOPE': ['email', 'public_profile'],
'AUTH_PARAMS': {'auth_type': 'reauthenticate'},
'INIT_PARAMS': {'cookie': True},
'FIELDS': [
'id',
'first_name',
'last_name',
'middle_name',
'name',
'name_format',
'picture',
'short_name'
],
'EXCHANGE_TOKEN': True,
'LOCALE_FUNC': lambda request: 'en_US',
'VERIFIED_EMAIL': False,
'VERSION': 'v7.0',
},
'google': {
'SCOPE': [
'profile',
'email',
],
'AUTH_PARAMS': {
'access_type': 'online',
}
}
}
LOGIN_REDIRECT_URL ='/'
TEMPLATES = [
{
'BACKEND': 'django.template.backends.django.DjangoTemplates',
'DIRS': [str(BASE_DIR / "templates"), str(BASE_DIR / "templates/account")],
'APP_DIRS': True,
'OPTIONS': {
'context_processors': [
'django.template.context_processors.debug',
'django.template.context_processors.request',
'django.contrib.auth.context_processors.auth',
'django.contrib.messages.context_processors.messages',
],
},
},
]
AUTHENTICATION_BACKENDS = [
# Needed to login by username in Django admin, regardless of `allauth`
'django.contrib.auth.backends.ModelBackend',
# `allauth` specific authentication methods, such as login by e-mail
'allauth.account.auth_backends.AuthenticationBackend',
]
WSGI_APPLICATION = 'meAdota.wsgi.application'
# Database
# https://docs.djangoproject.com/en/3.1/ref/settings/#databases
DATABASES = {
'default': {
'ENGINE': 'django.db.backends.postgresql_psycopg2',
'NAME': os.getenv("DATABASE_NAME"),
'USER': os.getenv("DATABASE_USER"),
'PASSWORD': os.getenv("DATABASE_PASSWORD"),
'HOST': os.getenv("DATABASE_HOST"),
'PORT': os.getenv("DATABASE_PORT"),
}
}
# Password validation
# https://docs.djangoproject.com/en/3.1/ref/settings/#auth-password-validators
AUTH_PASSWORD_VALIDATORS = [
{
'NAME': 'django.contrib.auth.password_validation.UserAttributeSimilarityValidator',
},
{
'NAME': 'django.contrib.auth.password_validation.MinimumLengthValidator',
},
{
'NAME': 'django.contrib.auth.password_validation.CommonPasswordValidator',
},
{
'NAME': 'django.contrib.auth.password_validation.NumericPasswordValidator',
},
]
# Internationalization
# https://docs.djangoproject.com/en/3.1/topics/i18n/
LANGUAGE_CODE = 'en-us'
TIME_ZONE = 'UTC'
USE_I18N = True
USE_L10N = True
USE_TZ = True
# Static files (CSS, JavaScript, Images)
# https://docs.djangoproject.com/en/3.1/howto/static-files/
STATIC_URL = '/static/'
MEDIA_URL = '/media/'
MEDIA_ROOT = os.path.join(BASE_DIR, 'media')
| 27.140271 | 91 | 0.672391 | 636 | 5,998 | 6.183962 | 0.386792 | 0.056191 | 0.034579 | 0.044495 | 0.107551 | 0.107551 | 0.067887 | 0.067887 | 0.030511 | 0 | 0 | 0.007218 | 0.191564 | 5,998 | 220 | 92 | 27.263636 | 0.803877 | 0.207069 | 0 | 0.034014 | 1 | 0 | 0.507725 | 0.340529 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | false | 0.068027 | 0.020408 | 0 | 0.020408 | 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 | 0 | 0 | 0 | 2 |
966233a14411c83da996b856512cb5f8c21c76c2 | 277 | py | Python | teachers/views.py | xuhairmeer/school-management | 36394c841a61e46bc00e1dc21bcfcdd5fa6f6918 | [
"bzip2-1.0.6"
] | null | null | null | teachers/views.py | xuhairmeer/school-management | 36394c841a61e46bc00e1dc21bcfcdd5fa6f6918 | [
"bzip2-1.0.6"
] | 9 | 2021-03-19T08:15:07.000Z | 2022-03-12T00:13:19.000Z | teachers/views.py | muhammadzuhair95/school-management | 36394c841a61e46bc00e1dc21bcfcdd5fa6f6918 | [
"bzip2-1.0.6"
] | null | null | null | # Create your views here.
from django.urls import reverse_lazy
from django.views import generic
from forms.forms import UserCreateForm
class SignUp(generic.CreateView):
form_class = UserCreateForm
success_url = reverse_lazy('home')
template_name = 'signup.html'
| 23.083333 | 38 | 0.776173 | 36 | 277 | 5.833333 | 0.638889 | 0.095238 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0.155235 | 277 | 11 | 39 | 25.181818 | 0.897436 | 0.083032 | 0 | 0 | 0 | 0 | 0.059524 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | false | 0 | 0.428571 | 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 | 0 | 0 | 1 | 0 | 1 | 0 | 0 | 2 |
966403bf90394bfb6b137e41500328a65675b400 | 822 | py | Python | zeromq/test/manifest.py | brettin/liquidhandling | 7a96e2881ffaa0326514cf5d97ba49d65ad42a14 | [
"MIT"
] | null | null | null | zeromq/test/manifest.py | brettin/liquidhandling | 7a96e2881ffaa0326514cf5d97ba49d65ad42a14 | [
"MIT"
] | null | null | null | zeromq/test/manifest.py | brettin/liquidhandling | 7a96e2881ffaa0326514cf5d97ba49d65ad42a14 | [
"MIT"
] | null | null | null | import os
import os.path
from datetime import datetime
import time
from stat import *
import pathlib
import json
def generateFileManifest(filename, manifest_filename=None):
string = ""
data = {}
if os.path.isfile(filename):
f = pathlib.Path(filename)
data[os.path.abspath(filename)] = {
'ctime': [str(f.stat().st_ctime), str(datetime.fromtimestamp(f.stat().st_ctime))],
'mtime':[str(f.stat().st_mtime), str(datetime.fromtimestamp(f.stat().st_mtime))]
}
json_data = json.dumps(data)
if manifest_filename != None:
with open(manifest_filename, "w+") as manifest_file:
manifest_file.write(json_data)
else:
print ("skipping bad filename: {}".format(filename))
return data
| 26.516129 | 102 | 0.611922 | 97 | 822 | 5.072165 | 0.391753 | 0.04065 | 0.056911 | 0.04065 | 0.126016 | 0.126016 | 0 | 0 | 0 | 0 | 0 | 0 | 0.26399 | 822 | 30 | 103 | 27.4 | 0.813223 | 0 | 0 | 0 | 1 | 0 | 0.045012 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0.043478 | false | 0 | 0.304348 | 0 | 0.391304 | 0.043478 | 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 | 0 | 1 | 0 | 0 | 0 | 0 | 2 |
966a5cfd248281b2c96521b02313c0a59ac99d4a | 625 | py | Python | mutational_landscape/migrations/0003_auto_20220225_1650.py | protwis/Protwis | fdcad0a2790721b02c0d12d8de754313714c575e | [
"Apache-2.0"
] | null | null | null | mutational_landscape/migrations/0003_auto_20220225_1650.py | protwis/Protwis | fdcad0a2790721b02c0d12d8de754313714c575e | [
"Apache-2.0"
] | null | null | null | mutational_landscape/migrations/0003_auto_20220225_1650.py | protwis/Protwis | fdcad0a2790721b02c0d12d8de754313714c575e | [
"Apache-2.0"
] | null | null | null | # Generated by Django 2.2.1 on 2022-02-25 15:50
from django.db import migrations
class Migration(migrations.Migration):
dependencies = [
('mutational_landscape', '0002_auto_20180117_1457'),
]
operations = [
migrations.RemoveField(
model_name='diseasemutations',
name='protein',
),
migrations.RemoveField(
model_name='diseasemutations',
name='residue',
),
migrations.DeleteModel(
name='CancerMutations',
),
migrations.DeleteModel(
name='DiseaseMutations',
),
]
| 22.321429 | 60 | 0.5712 | 51 | 625 | 6.882353 | 0.647059 | 0.17094 | 0.148148 | 0.17094 | 0.2849 | 0.2849 | 0 | 0 | 0 | 0 | 0 | 0.07346 | 0.3248 | 625 | 27 | 61 | 23.148148 | 0.758294 | 0.072 | 0 | 0.47619 | 1 | 0 | 0.207612 | 0.039792 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | false | 0 | 0.047619 | 0 | 0.190476 | 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 | 1 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 2 |
9683761b0e8ad668daa9ae8b7d5e998f46a35736 | 9,609 | py | Python | 2020/8/input.py | sishtiaq/aoc | 1c200ebed048bbd8ad6a684aaef8921d826f3d1b | [
"Apache-2.0"
] | null | null | null | 2020/8/input.py | sishtiaq/aoc | 1c200ebed048bbd8ad6a684aaef8921d826f3d1b | [
"Apache-2.0"
] | null | null | null | 2020/8/input.py | sishtiaq/aoc | 1c200ebed048bbd8ad6a684aaef8921d826f3d1b | [
"Apache-2.0"
] | null | null | null | test = [
'nop +0',
'acc +1',
'jmp +4',
'acc +3',
'jmp -3',
'acc -99',
'acc +1',
'jmp -4',
'acc +6',
]
actual = [
'acc +17',
'acc +37',
'acc -13',
'jmp +173',
'nop +100',
'acc -7',
'jmp +447',
'nop +283',
'acc +41',
'acc +32',
'jmp +1',
'jmp +585',
'jmp +1',
'acc -5',
'nop +71',
'acc +49',
'acc -18',
'jmp +527',
'jmp +130',
'jmp +253',
'acc +11',
'acc -11',
'jmp +390',
'jmp +597',
'jmp +1',
'acc +6',
'acc +0',
'jmp +588',
'acc -17',
'jmp +277',
'acc +2',
'nop +163',
'jmp +558',
'acc +38',
'jmp +369',
'acc +13',
'jmp +536',
'acc +38',
'acc +39',
'acc +6',
'jmp +84',
'acc +11',
'nop +517',
'acc +48',
'acc +47',
'jmp +1',
'acc +42',
'acc +0',
'acc +2',
'acc +24',
'jmp +335',
'acc +44',
'acc +47',
'jmp +446',
'nop +42',
'nop +74',
'acc +45',
'jmp +548',
'jmp +66',
'acc +1',
'jmp +212',
'acc +18',
'jmp +1',
'acc +4',
'acc -16',
'jmp +366',
'acc +0',
'jmp +398',
'acc +45',
'jmp +93',
'acc +40',
'acc +38',
'acc +21',
'nop +184',
'jmp -46',
'nop -9',
'jmp +53',
'acc +46',
'acc +36',
'jmp +368',
'acc +16',
'acc +8',
'acc -9',
'acc -4',
'jmp +328',
'acc -15',
'acc -5',
'acc +21',
'jmp +435',
'acc -5',
'acc +36',
'jmp +362',
'acc +26',
'jmp +447',
'jmp +1',
'jmp +412',
'acc +11',
'acc +41',
'nop -32',
'acc +17',
'jmp -63',
'jmp +1',
'nop +393',
'jmp +62',
'acc +18',
'acc +30',
'nop +417',
'jmp +74',
'acc +29',
'acc +23',
'jmp +455',
'jmp +396',
'jmp +395',
'acc +33',
'nop +137',
'nop +42',
'jmp +57',
'jmp +396',
'acc +7',
'acc +0',
'jmp +354',
'acc +15',
'acc +50',
'jmp -12',
'jmp +84',
'nop +175',
'acc +5',
'acc -2',
'jmp -82',
'acc +1',
'acc +26',
'jmp +288',
'nop -113',
'nop +366',
'acc +45',
'jmp +388',
'acc +21',
'acc +38',
'jmp +427',
'acc +33',
'jmp -94',
'nop -118',
'nop +411',
'jmp +472',
'nop +231',
'nop +470',
'acc +48',
'jmp -124',
'jmp +1',
'acc +5',
'acc +37',
'acc +42',
'jmp +301',
'acc -11',
'acc -17',
'acc +14',
'jmp +357',
'acc +6',
'acc +20',
'acc +13',
'jmp +361',
'jmp -65',
'acc +29',
'jmp +26',
'jmp +329',
'acc +32',
'acc +32',
'acc +17',
'jmp -102',
'acc -6',
'acc +33',
'acc +9',
'jmp +189',
'acc +3',
'jmp -128',
'jmp -142',
'acc +24',
'acc -5',
'jmp +403',
'acc +28',
'jmp +310',
'acc +34',
'acc +4',
'acc +33',
'acc +18',
'jmp +227',
'acc -8',
'acc -15',
'jmp +112',
'jmp +54',
'acc +21',
'acc +23',
'acc +20',
'jmp +320',
'acc +13',
'jmp -77',
'acc +15',
'nop +310',
'nop +335',
'jmp +232',
'acc -3',
'nop +50',
'acc +41',
'jmp +112',
'nop -10',
'acc +29',
'acc +27',
'jmp +52',
'acc +40',
'nop -132',
'acc -16',
'acc +27',
'jmp +309',
'acc -8',
'nop +147',
'acc +20',
'acc +46',
'jmp +202',
'acc +27',
'jmp -43',
'jmp +1',
'acc +33',
'acc -13',
'jmp +300',
'acc +1',
'jmp -202',
'acc -17',
'acc +0',
'acc +34',
'jmp -5',
'nop +335',
'acc -16',
'acc -17',
'jmp -120',
'acc -19',
'acc -13',
'acc +4',
'jmp +368',
'jmp +21',
'acc +39',
'acc +39',
'acc -18',
'jmp -157',
'nop +280',
'acc +33',
'nop -37',
'jmp +32',
'acc -16',
'acc +18',
'acc +46',
'jmp -121',
'acc -19',
'jmp +195',
'acc +28',
'jmp +124',
'jmp +331',
'jmp -228',
'jmp -146',
'jmp +85',
'jmp +60',
'acc +20',
'acc -9',
'jmp +303',
'jmp -122',
'jmp +111',
'acc +32',
'acc +0',
'acc +39',
'acc +29',
'jmp -31',
'nop +320',
'jmp -63',
'jmp +223',
'nop -149',
'acc -12',
'acc -11',
'acc +32',
'jmp +309',
'jmp -13',
'acc -19',
'jmp -123',
'acc +21',
'acc +18',
'acc +49',
'jmp +175',
'acc -14',
'nop -129',
'acc -2',
'acc +31',
'jmp +79',
'acc +23',
'acc +50',
'acc +39',
'acc +7',
'jmp -235',
'jmp -166',
'acc +9',
'jmp +293',
'acc -11',
'jmp +76',
'acc +44',
'acc +3',
'acc +37',
'jmp +123',
'nop -104',
'jmp -157',
'acc +14',
'acc +10',
'acc +28',
'jmp +25',
'acc +37',
'jmp +188',
'jmp -49',
'acc -11',
'jmp -90',
'acc -8',
'jmp +197',
'acc +5',
'jmp +115',
'acc +44',
'jmp -228',
'nop -2',
'acc +46',
'jmp +130',
'nop +183',
'nop +106',
'acc +27',
'acc +37',
'jmp -309',
'acc +28',
'acc -4',
'acc -12',
'acc +38',
'jmp +93',
'acc +8',
'acc +23',
'acc -9',
'acc +6',
'jmp -42',
'acc +10',
'acc +35',
'acc +4',
'jmp -231',
'acc +19',
'acc +7',
'acc +23',
'acc +11',
'jmp -90',
'acc +0',
'nop +158',
'nop -150',
'acc +33',
'jmp +107',
'acc +48',
'acc -2',
'jmp -104',
'acc +6',
'nop -57',
'nop +172',
'acc -11',
'jmp -7',
'acc +6',
'acc +50',
'acc -9',
'acc +12',
'jmp -171',
'acc +3',
'jmp +26',
'acc +42',
'acc +31',
'acc +20',
'acc +32',
'jmp -48',
'acc +13',
'jmp -6',
'jmp +178',
'acc +47',
'jmp -153',
'acc +28',
'nop +74',
'jmp -162',
'acc -15',
'nop -104',
'acc -9',
'jmp -227',
'acc +49',
'acc -19',
'acc +41',
'jmp -318',
'acc +9',
'acc +12',
'acc +7',
'jmp +34',
'jmp +137',
'nop -143',
'acc -8',
'acc +5',
'acc +31',
'jmp -20',
'jmp -237',
'acc +39',
'acc +0',
'jmp -298',
'acc +45',
'acc -19',
'acc +11',
'jmp -151',
'acc +40',
'acc +27',
'nop +150',
'nop -391',
'jmp -341',
'acc +1',
'acc +11',
'acc +18',
'nop -234',
'jmp +77',
'nop +104',
'jmp -65',
'acc +32',
'jmp -27',
'nop -317',
'nop +159',
'acc +14',
'acc -10',
'jmp -348',
'acc +29',
'jmp +32',
'acc +48',
'acc -19',
'jmp +17',
'jmp -201',
'jmp -224',
'nop +26',
'acc -7',
'acc +23',
'acc +46',
'jmp -6',
'acc +22',
'acc +39',
'acc +9',
'acc +23',
'jmp -30',
'jmp -243',
'acc +47',
'acc -15',
'jmp -298',
'jmp -393',
'jmp +1',
'acc +3',
'nop -24',
'acc +7',
'jmp -59',
'acc -6',
'acc +26',
'jmp -102',
'acc +34',
'acc +24',
'jmp -207',
'acc +36',
'acc +40',
'acc +41',
'jmp +1',
'jmp -306',
'jmp +57',
'jmp +1',
'nop +99',
'acc +28',
'jmp -391',
'acc +50',
'jmp -359',
'acc -5',
'jmp +9',
'jmp -355',
'acc +5',
'acc +2',
'jmp -77',
'acc +40',
'acc +28',
'acc +22',
'jmp -262',
'nop -287',
'acc +34',
'acc -4',
'nop +112',
'jmp -195',
'acc +29',
'nop -94',
'nop -418',
'jmp +24',
'jmp -190',
'acc +2',
'jmp -311',
'jmp -178',
'jmp -276',
'acc -12',
'acc -18',
'jmp +62',
'jmp -174',
'nop +31',
'acc +33',
'nop -158',
'jmp -417',
'acc +3',
'acc +21',
'acc +47',
'jmp +87',
'acc +45',
'jmp -77',
'acc +6',
'acc -10',
'jmp +1',
'jmp -240',
'acc +7',
'acc +47',
'jmp -379',
'acc -14',
'acc +50',
'nop -75',
'acc +30',
'jmp +70',
'jmp -392',
'jmp -430',
'acc +22',
'acc -2',
'jmp -492',
'jmp +1',
'acc -6',
'acc +38',
'jmp -36',
'nop -336',
'jmp -32',
'jmp +61',
'acc +20',
'acc -9',
'acc +2',
'jmp -175',
'acc +21',
'acc -2',
'jmp -6',
'jmp -527',
'acc +11',
'acc +16',
'jmp -262',
'jmp +1',
'nop -327',
'acc +29',
'jmp -114',
'acc +11',
'acc +17',
'acc +26',
'nop -104',
'jmp -428',
'nop -178',
'nop -242',
'acc +29',
'acc +5',
'jmp -245',
'jmp -417',
'jmp -278',
'acc +35',
'acc +21',
'jmp +1',
'nop -263',
'jmp +8',
'acc +42',
'jmp -95',
'nop -312',
'acc -11',
'acc +34',
'acc +0',
'jmp +19',
'acc +8',
'acc -13',
'acc +32',
'acc +21',
'jmp -208',
'acc +15',
'acc +39',
'nop -194',
'jmp -280',
'jmp +24',
'nop -516',
'acc +21',
'acc +48',
'jmp -367',
'jmp -121',
'acc +49',
'acc -16',
'jmp -136',
'acc +0',
'jmp -148',
'jmp -85',
'jmp -103',
'nop -446',
'jmp -242',
'acc -12',
'acc +13',
'acc +31',
'acc -1',
'jmp -435',
'nop -420',
'acc +22',
'acc -5',
'jmp -567',
'nop -354',
'acc +11',
'acc +33',
'acc +45',
'jmp -76',
'acc -2',
'acc +0',
'acc +25',
'acc +46',
'jmp -555',
'acc +0',
'acc +11',
'nop -2',
'jmp -394',
'jmp -395',
'acc +8',
'acc +14',
'acc +47',
'acc +22',
'jmp +1',]
| 15.037559 | 15 | 0.338329 | 1,270 | 9,609 | 2.559843 | 0.18189 | 0.020917 | 0.022147 | 0.004922 | 0.042756 | 0 | 0 | 0 | 0 | 0 | 0 | 0.231141 | 0.397128 | 9,609 | 638 | 16 | 15.061129 | 0.330054 | 0 | 0 | 0.637363 | 0 | 0 | 0.469248 | 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 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 2 |
968a0ed358f9602c37b149e837fd6e25f4d5114f | 4,492 | py | Python | capnpy/segment/builder.py | GambitResearch/capnpy | 3b8d9ed0623e160f69dee07ec2fc6303683c2a3c | [
"MIT"
] | 45 | 2016-10-28T10:16:07.000Z | 2022-03-06T20:16:57.000Z | capnpy/segment/builder.py | GambitResearch/capnpy | 3b8d9ed0623e160f69dee07ec2fc6303683c2a3c | [
"MIT"
] | 42 | 2016-12-20T18:10:53.000Z | 2021-09-08T12:29:04.000Z | capnpy/segment/builder.py | GambitResearch/capnpy | 3b8d9ed0623e160f69dee07ec2fc6303683c2a3c | [
"MIT"
] | 21 | 2017-02-28T06:39:15.000Z | 2021-09-07T05:30:46.000Z | import struct
from six import binary_type
from capnpy import ptr
from capnpy.packing import mychr
from capnpy.printer import print_buffer
class SegmentBuilder(object):
def __init__(self, length=None):
self.buf = bytearray()
def get_length(self):
return len(self.buf)
def as_string(self):
return binary_type(self.buf)
def _print(self):
print_buffer(self.as_string())
def write_generic(self, ifmt, i, value):
struct.pack_into(mychr(ifmt), self.buf, i, value)
def write_int8(self, i, value):
struct.pack_into('b', self.buf, i, value)
def write_uint8(self, i, value):
struct.pack_into('B', self.buf, i, value)
def write_int16(self, i, value):
struct.pack_into('h', self.buf, i, value)
def write_uint16(self, i, value):
struct.pack_into('H', self.buf, i, value)
def write_int32(self, i, value):
struct.pack_into('i', self.buf, i, value)
def write_uint32(self, i, value):
struct.pack_into('I', self.buf, i, value)
def write_int64(self, i, value):
struct.pack_into('q', self.buf, i, value)
def write_uint64(self, i, value):
struct.pack_into('Q', self.buf, i, value)
def write_float32(self, i, value):
struct.pack_into('f', self.buf, i, value)
def write_float64(self, i, value):
struct.pack_into('d', self.buf, i, value)
def write_bool(self, byteoffset, bitoffset, value):
current = struct.unpack_from('B', self.buf, byteoffset)[0]
current |= (value << bitoffset)
struct.pack_into('B', self.buf, byteoffset, current)
def write_slice(self, i, src, start, n):
self.buf[i:i+n] = src.buf[start:start+n]
def allocate(self, length):
# XXX: check whether there is a better method to zero-extend the array in PyPy
result = len(self.buf)
self.buf += b'\x00'*length
return result
def alloc_struct(self, pos, data_size, ptrs_size):
"""
Allocate a new struct of the given size, and write the resulting pointer
at position i. Return the newly allocated position.
"""
length = (data_size+ptrs_size) * 8
result = self.allocate(length)
offet = result - (pos+8)
p = ptr.new_struct(offet//8, data_size, ptrs_size)
self.write_int64(pos, p)
return result
def alloc_list(self, pos, size_tag, item_count, body_length):
"""
Allocate a new list of the given size, and write the resulting pointer
at position i. Return the newly allocated position.
"""
body_length = ptr.round_up_to_word(body_length)
result = self.allocate(body_length)
offet = result - (pos+8)
p = ptr.new_list(offet//8, size_tag, item_count)
self.write_int64(pos, p)
return result
def alloc_text(self, pos, s, trailing_zero=1):
if s is None:
self.write_int64(pos, 0)
return -1
n = len(s)
nn = n + trailing_zero
result = self.alloc_list(pos, ptr.LIST_SIZE_8, nn, nn)
self.buf[result:result+n] = s
# there is no need to write the trailing 0 as the byte is already
# guaranteed to be 0
return result
def alloc_data(self, pos, s):
return self.alloc_text(pos, s, trailing_zero=0)
def copy_from_struct(self, dst_pos, structcls, value):
if value is None:
self.write_int64(dst_pos, 0)
return
if not isinstance(value, structcls):
raise TypeError("Expected %s instance, got %s" %
(structcls.__class__.__name__, value))
self.copy_from_pointer(dst_pos, value._seg, value._as_pointer(0), 0)
def copy_from_pointer(self, dst_pos, src, p, src_pos):
return copy_pointer(src, p, src_pos, self, dst_pos)
def copy_inline_struct(self, dst_pos, src, p, src_pos):
"""
Similar to copy_from_pointer but:
1. it assumes that p is a pointer to a struct
2. it does NOT allocate a new struct in dst_pos: instead, it writes
the struct directly into dst_pos
"""
return _copy_struct_inline(src, p, src_pos, self, dst_pos)
def copy_from_list(self, pos, item_type, lst):
return copy_from_list(self, pos, item_type, lst)
from capnpy.segment._copy_pointer import copy_pointer, _copy_struct_inline
from capnpy.segment._copy_list import copy_from_list
| 33.274074 | 86 | 0.629564 | 663 | 4,492 | 4.075415 | 0.21267 | 0.048853 | 0.062176 | 0.065137 | 0.373427 | 0.351221 | 0.301999 | 0.287195 | 0.245744 | 0.197631 | 0 | 0.013927 | 0.264693 | 4,492 | 134 | 87 | 33.522388 | 0.804117 | 0.133348 | 0 | 0.091954 | 0 | 0 | 0.011637 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0.298851 | false | 0 | 0.08046 | 0.057471 | 0.528736 | 0.034483 | 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 | 0 | 1 | 0 | 0 | 2 |
96935625868f5df6499326134d54ac7ad8bc8a3f | 1,172 | py | Python | samcli/cli/main.py | langn/aws-sam-cli | 160d87ff3c07f092315e1ac71ddc00257fde011b | [
"Apache-2.0"
] | null | null | null | samcli/cli/main.py | langn/aws-sam-cli | 160d87ff3c07f092315e1ac71ddc00257fde011b | [
"Apache-2.0"
] | 1 | 2018-05-23T19:51:18.000Z | 2018-05-23T19:51:18.000Z | samcli/cli/main.py | langn/aws-sam-cli | 160d87ff3c07f092315e1ac71ddc00257fde011b | [
"Apache-2.0"
] | null | null | null | """
Entry point for the CLI
"""
import logging
import click
from samcli import __version__
from .options import debug_option
from .context import Context
from .command import BaseCommand
logger = logging.getLogger(__name__)
logging.basicConfig(level=logging.INFO, format='%(asctime)s %(message)s', datefmt='%Y-%m-%d %H:%M:%S')
pass_context = click.make_pass_decorator(Context)
def common_options(f):
"""
Common CLI options used by all commands. Ex: --debug
:param f: Callback function passed by Click
:return: Callback function
"""
f = debug_option(f)
return f
@click.command(cls=BaseCommand)
@common_options
@click.version_option(version=__version__, prog_name="SAM CLI")
@pass_context
def cli(ctx):
"""
AWS Serverless Application Model (SAM) CLI
The AWS Serverless Application Model extends AWS CloudFormation to provide a simplified way of defining the
Amazon API Gateway APIs, AWS Lambda functions, and Amazon DynamoDB tables needed by your serverless application.
You can find more in-depth guide about the SAM specification here:
https://github.com/awslabs/serverless-application-model.
"""
pass
| 26.636364 | 116 | 0.740614 | 161 | 1,172 | 5.254658 | 0.559006 | 0.099291 | 0.092199 | 0.068558 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0.168089 | 1,172 | 43 | 117 | 27.255814 | 0.867692 | 0.457338 | 0 | 0 | 0 | 0 | 0.081882 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0.111111 | false | 0.166667 | 0.333333 | 0 | 0.5 | 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 | 0 | 0 | 0 | 2 |
9699da91536be3b5f7938a488f2471ecc9d269c7 | 1,318 | py | Python | app/web/obtain_url.py | gpp0725/EchoProxy | 0273f47397b76fa0292db267d99eeb9dccc4e869 | [
"Apache-2.0"
] | null | null | null | app/web/obtain_url.py | gpp0725/EchoProxy | 0273f47397b76fa0292db267d99eeb9dccc4e869 | [
"Apache-2.0"
] | null | null | null | app/web/obtain_url.py | gpp0725/EchoProxy | 0273f47397b76fa0292db267d99eeb9dccc4e869 | [
"Apache-2.0"
] | null | null | null | # !/usr/bin/env python
# -*- coding: utf-8 -*-
# @Time : 2020/3/4 0004 2:09
# @Author : Gpp
# @File : obtain_url.py
from app.web import api
from flask_restful import Resource
from flask import make_response, send_from_directory, jsonify
from app.helper.encrypt import two_encrypting
from app.crud.proxy_crud import ProtocolCrud
from app.helper.get_one_encrypt import get_one_encrypt_data
from app.helper.update_subscribe import add_proxy
# @api.resource('/generate')
# class Generate(Resource):
# def get(self):
# proxies = ProtocolCrud.get_all_share()
# one_encrypt = get_one_encrypt_data(proxies)
# result = add_proxy(two_encrypting(''.join(one_encrypt)))
# return jsonify(result)
@api.resource('/generate/<proxy_information>')
class GetUrl(Resource):
def get(self, proxy_information):
# 获取代理元数据
proxies = ProtocolCrud.get_all_share()
one_encrypt = get_one_encrypt_data(proxies)
add_proxy(two_encrypting(''.join(one_encrypt)))
# 获取代理实时信息
# 获取prometheus数据存入别名
# 生成订阅链接
response = make_response(send_from_directory('url_file', f'{proxy_information}.txt', as_attachment=True))
response.headers["Content-Disposition"] = f"attachment; filename={proxy_information}.txt"
return response
| 33.794872 | 113 | 0.707132 | 167 | 1,318 | 5.335329 | 0.42515 | 0.089787 | 0.058361 | 0.057239 | 0.287318 | 0.222222 | 0.222222 | 0.143659 | 0.143659 | 0.143659 | 0 | 0.013023 | 0.18437 | 1,318 | 38 | 114 | 34.684211 | 0.815814 | 0.322458 | 0 | 0 | 0 | 0 | 0.140411 | 0.09589 | 0 | 0 | 0 | 0 | 0 | 1 | 0.0625 | false | 0 | 0.4375 | 0 | 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 | 0 | 0 | 0 | 1 | 0 | 1 | 0 | 0 | 2 |
969bb241fcdc0d7ab1f0ae016a66c74578107f98 | 639 | py | Python | AMAO/apps/Avaliacao/views/exibir.py | arruda/amao | 83648aa2c408b1450d721b3072dc9db4b53edbb8 | [
"MIT"
] | 2 | 2017-04-26T14:08:02.000Z | 2017-09-01T13:10:17.000Z | AMAO/apps/Avaliacao/views/exibir.py | arruda/amao | 83648aa2c408b1450d721b3072dc9db4b53edbb8 | [
"MIT"
] | null | null | null | AMAO/apps/Avaliacao/views/exibir.py | arruda/amao | 83648aa2c408b1450d721b3072dc9db4b53edbb8 | [
"MIT"
] | null | null | null | # -*- coding: utf-8 -*-
from django.http import HttpResponse
from django.contrib.auth import login
from django.shortcuts import redirect, get_object_or_404
from django.contrib.auth.decorators import login_required
from Aluno.views.utils import aluno_exist
from annoying.decorators import render_to
from django.contrib.auth.models import User
from Avaliacao.models import *
from Aluno.models import *
@render_to('avaliacao/exibir.html')
@aluno_exist
def exibir(request,template_id):
aluno = request.user.aluno_set.get()
avaliacao=Avaliacao.objects.get(pk=template_id)
questoes=avaliacao.questoes.all()
return locals()
| 27.782609 | 57 | 0.791862 | 90 | 639 | 5.5 | 0.466667 | 0.10101 | 0.10303 | 0.127273 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0.007092 | 0.117371 | 639 | 22 | 58 | 29.045455 | 0.870567 | 0.032864 | 0 | 0 | 0 | 0 | 0.034146 | 0.034146 | 0 | 0 | 0 | 0 | 0 | 1 | 0.0625 | false | 0 | 0.5625 | 0 | 0.6875 | 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 | 0 | 1 | 0 | 1 | 0 | 0 | 2 |
969e2f3ff112021f4be66464e152ec69c802c02b | 320 | py | Python | connect/eaas/exceptions.py | bdjilka/connect-extension-runner | 7930b34dae92addb3807984fd553debc2b78ac23 | [
"Apache-2.0"
] | null | null | null | connect/eaas/exceptions.py | bdjilka/connect-extension-runner | 7930b34dae92addb3807984fd553debc2b78ac23 | [
"Apache-2.0"
] | null | null | null | connect/eaas/exceptions.py | bdjilka/connect-extension-runner | 7930b34dae92addb3807984fd553debc2b78ac23 | [
"Apache-2.0"
] | null | null | null | #
# This file is part of the Ingram Micro CloudBlue Connect EaaS Extension Runner.
#
# Copyright (c) 2021 Ingram Micro. All Rights Reserved.
#
class EaaSError(Exception):
pass
class MaintenanceError(EaaSError):
pass
class CommunicationError(EaaSError):
pass
class StopBackoffError(EaaSError):
pass
| 16 | 80 | 0.74375 | 37 | 320 | 6.432432 | 0.702703 | 0.113445 | 0.151261 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0.015385 | 0.1875 | 320 | 19 | 81 | 16.842105 | 0.9 | 0.4125 | 0 | 0.5 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | true | 0.5 | 0 | 0 | 0.5 | 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 | 1 | 0 | 0 | 0 | 0 | 0 | 2 |
96a839ea7a6be1421d492c4092e290ebd78292b8 | 715 | py | Python | examples/wsgi_usage/apache_modwsgi_server_example.py | digimatspa/python-jsonrpc | 7f8a022c112f8957cee18c54fc48557690cfe417 | [
"MIT"
] | 97 | 2015-01-06T14:29:31.000Z | 2022-02-17T07:27:11.000Z | examples/wsgi_usage/apache_modwsgi_server_example.py | HoverHell/python-jsonrpc | 41bcd48dd7879ca780481605dc1ffb611ead9100 | [
"MIT"
] | 37 | 2015-01-03T11:00:48.000Z | 2021-04-23T06:12:45.000Z | examples/wsgi_usage/apache_modwsgi_server_example.py | HoverHell/python-jsonrpc | 41bcd48dd7879ca780481605dc1ffb611ead9100 | [
"MIT"
] | 63 | 2015-02-04T20:14:48.000Z | 2022-02-17T07:27:13.000Z | #!/usr/bin/env python
# coding: utf-8
# BEGIN --- required only for testing, remove in real world code --- BEGIN
import os
import sys
THISDIR = os.path.dirname(os.path.abspath(__file__))
APPDIR = os.path.abspath(os.path.join(THISDIR, os.path.pardir, os.path.pardir))
sys.path.insert(0, APPDIR)
# END --- required only for testing, remove in real world code --- END
#
# See http://tools.cherrypy.org/wiki/ModWSGI
#
import cherrypy
from pyjsonrpc.cp import CherryPyJsonRpc, rpcmethod
class Root(CherryPyJsonRpc):
@rpcmethod
def add(self, a, b):
"""Test method"""
return a + b
index = CherryPyJsonRpc.request_handler
# WSGI-Application
application = cherrypy.Application(Root())
| 21.029412 | 79 | 0.706294 | 99 | 715 | 5.050505 | 0.585859 | 0.072 | 0.06 | 0.088 | 0.172 | 0.172 | 0.172 | 0.172 | 0.172 | 0 | 0 | 0.003356 | 0.166434 | 715 | 33 | 80 | 21.666667 | 0.83557 | 0.346853 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0.076923 | false | 0 | 0.307692 | 0 | 0.615385 | 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 | 0 | 1 | 0 | 1 | 0 | 0 | 2 |
7382ea8531ce700712937018018e99ffb94c7c1d | 562 | py | Python | codepack/service/delivery_service/delivery_service.py | ihnokim/codepack | 9d043b2db977de503faf7f5f1370c1424c6cb19f | [
"MIT"
] | 2 | 2021-04-18T17:51:49.000Z | 2021-06-22T10:21:30.000Z | codepack/service/delivery_service/delivery_service.py | ihnokim/codepack | 9d043b2db977de503faf7f5f1370c1424c6cb19f | [
"MIT"
] | 24 | 2021-12-23T18:02:01.000Z | 2022-03-27T03:03:38.000Z | codepack/service/delivery_service/delivery_service.py | ihnokim/codepack | 9d043b2db977de503faf7f5f1370c1424c6cb19f | [
"MIT"
] | 1 | 2021-09-13T12:56:40.000Z | 2021-09-13T12:56:40.000Z | import abc
from codepack.service.service import Service
class DeliveryService(Service, metaclass=abc.ABCMeta):
def __init__(self):
super().__init__()
@abc.abstractmethod
def send(self, id, serial_number, item=None, timestamp=None):
"""send item"""
@abc.abstractmethod
def receive(self, serial_number):
"""receive item"""
@abc.abstractmethod
def cancel(self, serial_number):
"""cancel delivery"""
@abc.abstractmethod
def check(self, serial_number):
"""check arrival of delivery"""
| 23.416667 | 65 | 0.658363 | 62 | 562 | 5.774194 | 0.435484 | 0.189944 | 0.223464 | 0.134078 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0.218861 | 562 | 23 | 66 | 24.434783 | 0.81549 | 0.113879 | 0 | 0.307692 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0.384615 | false | 0 | 0.153846 | 0 | 0.615385 | 0 | 0 | 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 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 2 |
7387856755f04e2fce184f38847164fa54bfabcd | 922 | py | Python | joplin_web/api.py | foxmask/joplin-web | eb261e515b9ecf9c878a1d6492aba06ddf6d97c6 | [
"BSD-3-Clause"
] | 382 | 2018-08-20T07:51:11.000Z | 2022-03-11T14:52:53.000Z | joplin_web/api.py | marph91/joplin-web | eb261e515b9ecf9c878a1d6492aba06ddf6d97c6 | [
"BSD-3-Clause"
] | 71 | 2018-10-01T07:01:20.000Z | 2022-02-22T07:17:47.000Z | joplin_web/api.py | marph91/joplin-web | eb261e515b9ecf9c878a1d6492aba06ddf6d97c6 | [
"BSD-3-Clause"
] | 67 | 2018-10-01T07:09:50.000Z | 2022-03-19T09:30:09.000Z | # coding: utf-8
"""
joplin-web
"""
from django.conf import settings
from django.http.response import JsonResponse
from django.urls import reverse
from joplin_api import JoplinApiSync
from joplin_web.utils import nb_notes_by_tag, nb_notes_by_folder
import logging
from rich import console
console = console.Console()
logger = logging.getLogger("joplin_web.app")
joplin = JoplinApiSync(token=settings.JOPLIN_WEBCLIPPER_TOKEN)
def get_folders(request):
"""
all the folders
:param request
:return: json
"""
res = joplin.get_folders()
json_data = sorted(res.json(), key=lambda k: k['title'])
data = nb_notes_by_folder(json_data)
logger.debug(data)
return JsonResponse(data, safe=False)
def get_tags(request):
res = joplin.get_tags()
json_data = sorted(res.json(), key=lambda k: k['title'])
data = nb_notes_by_tag(json_data)
return JsonResponse(data, safe=False)
| 24.918919 | 64 | 0.729935 | 131 | 922 | 4.946565 | 0.389313 | 0.04321 | 0.055556 | 0.037037 | 0.262346 | 0.262346 | 0.154321 | 0.154321 | 0.154321 | 0.154321 | 0 | 0.001297 | 0.163774 | 922 | 36 | 65 | 25.611111 | 0.83917 | 0.075922 | 0 | 0.190476 | 0 | 0 | 0.02934 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0.095238 | false | 0 | 0.333333 | 0 | 0.52381 | 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 | 0 | 1 | 0 | 1 | 0 | 0 | 2 |
7398e8292797a50bf6c42c368fc2eb59c7ca47ec | 5,612 | py | Python | feeds.py | yoursantu/indiannewsplus | 252f0367b43ec2edea636157bcf2d8a92dda6f3f | [
"MIT"
] | null | null | null | feeds.py | yoursantu/indiannewsplus | 252f0367b43ec2edea636157bcf2d8a92dda6f3f | [
"MIT"
] | null | null | null | feeds.py | yoursantu/indiannewsplus | 252f0367b43ec2edea636157bcf2d8a92dda6f3f | [
"MIT"
] | null | null | null | """RSS feeds for the `multilingual_news` app."""
from django.conf import settings
from django.contrib.contenttypes.models import ContentType
from django.contrib.sites.shortcuts import get_current_site
from django.contrib.syndication.views import Feed
from django.core.urlresolvers import reverse
from django.utils.translation import ugettext_lazy as _
from cms.utils import get_language_from_request
from multilingual_tags.models import Tag, TaggedItem
from people.models import Person
from .models import NewsEntry
def is_multilingual():
return 'django.middleware.locale.LocaleMiddleware' in \
settings.MIDDLEWARE_CLASSES
def get_lang_name(lang):
return _(dict(settings.LANGUAGES)[lang])
class NewsEntriesFeed(Feed):
"""A news feed, that shows all entries."""
title_template = 'multilingual_news/feed/entries_title.html'
description_template = 'multilingual_news/feed/entries_description.html'
def get_object(self, request, **kwargs):
self.language_code = get_language_from_request(request)
self.site = get_current_site(request)
self.any_language = kwargs.get('any_language', None)
def feed_url(self, item):
if is_multilingual() or self.any_language:
return reverse('news_rss_any', kwargs={'any_language': True})
return reverse('news_rss')
def title(self, item):
if self.any_language or not is_multilingual():
return _(u"{0} blog entries".format(self.site.name))
return _(u"{0} blog entries in {1}".format(self.site.name,
get_lang_name(self.language_code)))
def link(self, item):
return reverse('news_list')
def item_link(self, item):
return item.get_absolute_url()
def description(self, item):
if self.any_language or not is_multilingual():
return _(u"{0} blog entries".format(self.site.name))
return _(u"{0} blog entries in {1}".format(self.site.name,
get_lang_name(self.language_code)))
def get_queryset(self, item):
if not is_multilingual() or self.any_language:
check_language = False
else:
check_language = True
return NewsEntry.objects.recent(limit=10,
check_language=check_language)
def items(self, item):
return self.get_queryset(item)
def item_pubdate(self, item):
return item.pub_date
class AuthorFeed(NewsEntriesFeed):
"""A news feed, that shows only entries from a certain author."""
title_template = 'multilingual_news/feed/author_title.html'
description_template = 'multilingual_news/feed/author_description.html'
def get_object(self, request, **kwargs):
super(AuthorFeed, self).get_object(request, **kwargs)
# Needs no try. If the author does not exist, we automatically get a
# 404 response.
self.author = Person.objects.get(pk=kwargs.get('author'))
def title(self, obj):
title = super(AuthorFeed, self).title(obj)
return _(u'{0} by {1}'.format(title, self.author))
def feed_url(self, obj):
if is_multilingual() or self.any_language:
return reverse('news_rss_any_author', kwargs={
'author': self.author.id, 'any_language': True})
return reverse('news_rss_author', kwargs={'author': self.author.id})
def link(self, obj):
# TODO Author specific archive
return reverse('news_list')
def description(self, obj):
description = super(AuthorFeed, self).description(obj)
return _(u'{0} by {1}'.format(description, self.author))
def get_queryset(self, obj):
if not is_multilingual() or self.any_language:
check_language = False
else:
check_language = True
return NewsEntry.objects.recent(limit=10,
check_language=check_language,
kwargs={'author': self.author})
class TaggedFeed(NewsEntriesFeed):
"""A news feed, that shows only entries with a special tag."""
title_template = 'multilingual_news/feed/author_title.html'
description_template = 'multilingual_news/feed/author_description.html'
def get_object(self, request, **kwargs):
super(TaggedFeed, self).get_object(request, **kwargs)
# Needs no try. If the tag does not exist, we automatically get a
# 404 response.
self.tag = Tag.objects.get(slug=kwargs.get('tag'))
def title(self, obj):
title = super(TaggedFeed, self).title(obj)
return _(u'{0} by {1}'.format(title, self.tag.name))
def feed_url(self, obj):
if is_multilingual() or self.any_language:
return reverse('news_rss_any_tagged', kwargs={
'tag': self.tag.slug, 'any_language': True})
return reverse('news_rss_tagged', kwargs={'tag': self.tag.slug})
def link(self, obj):
return reverse('news_archive_tagged', kwargs={'tag': self.tag.slug})
def description(self, obj):
description = super(TaggedFeed, self).description(obj)
return _(u'{0} by {1}'.format(description, self.tag.name))
def get_queryset(self, obj):
content_type = ContentType.objects.get_for_model(NewsEntry)
tagged_items = TaggedItem.objects.filter(
content_type=content_type, tag=self.tag)
entries = []
for tagged_item in tagged_items:
if tagged_item.object and tagged_item.object.is_public():
entries.append(tagged_item.object)
return entries[:10]
| 37.66443 | 76 | 0.661083 | 710 | 5,612 | 5.049296 | 0.18169 | 0.03682 | 0.042678 | 0.046862 | 0.589121 | 0.546722 | 0.488982 | 0.430126 | 0.393305 | 0.393305 | 0 | 0.006023 | 0.230756 | 5,612 | 148 | 77 | 37.918919 | 0.824415 | 0.068603 | 0 | 0.377358 | 0 | 0 | 0.120723 | 0.057862 | 0 | 0 | 0 | 0.006757 | 0 | 1 | 0.216981 | false | 0 | 0.09434 | 0.075472 | 0.632075 | 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 | 0 | 1 | 0 | 0 | 2 |
739b66623c870e2641dd70a59dd1c2539187536e | 1,161 | py | Python | tests/cli.py | chriswmackey/honeybee-radiance-folder | 5576df94d781fd131c683c8b05aa04ac42df34b8 | [
"MIT"
] | null | null | null | tests/cli.py | chriswmackey/honeybee-radiance-folder | 5576df94d781fd131c683c8b05aa04ac42df34b8 | [
"MIT"
] | 113 | 2019-07-18T03:38:26.000Z | 2022-03-26T03:26:06.000Z | tests/cli.py | chriswmackey/honeybee-radiance-folder | 5576df94d781fd131c683c8b05aa04ac42df34b8 | [
"MIT"
] | 6 | 2019-07-18T00:05:26.000Z | 2021-10-04T08:50:26.000Z | from click.testing import CliRunner
from honeybee_radiance_folder.cli import filter_json_file
import json
import os
def test_filter_file():
runner = CliRunner()
input_file = './tests/assets/project_folder/grid_info.json'
output_file = './tests/assets/temp/grid_filtered_0.json'
result = runner.invoke(
filter_json_file, [
input_file, 'group:daylight_grids', '--output-file', output_file
]
)
assert result.exit_code == 0
# check the file is created
with open(output_file) as inf:
data = json.load(inf)
assert len(data) == 1
os.unlink(output_file)
def test_filter_file_remove():
runner = CliRunner()
input_file = './tests/assets/project_folder/grid_info.json'
output_file = './tests/assets/project_folder/grid_filtered_1.json'
result = runner.invoke(
filter_json_file, [
input_file, 'group:daylight_grids', '--output-file', output_file, '--remove'
]
)
assert result.exit_code == 0
# check the file is created
with open(output_file) as inf:
data = json.load(inf)
assert len(data) == 8
os.unlink(output_file)
| 29.769231 | 88 | 0.669251 | 155 | 1,161 | 4.767742 | 0.316129 | 0.135318 | 0.081191 | 0.08931 | 0.718539 | 0.718539 | 0.695535 | 0.695535 | 0.695535 | 0.695535 | 0 | 0.006637 | 0.221361 | 1,161 | 38 | 89 | 30.552632 | 0.810841 | 0.043928 | 0 | 0.5 | 0 | 0 | 0.227642 | 0.160795 | 0 | 0 | 0 | 0 | 0.125 | 1 | 0.0625 | false | 0 | 0.125 | 0 | 0.1875 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 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 | 2 |
739e6d0875de7997feffc9f90decf0de25b225f9 | 9,157 | py | Python | src/memberdef.py | alljoyn/devtools-codegen | 388cac15e584dce3040d5090e8f627e5360e5c0f | [
"0BSD"
] | null | null | null | src/memberdef.py | alljoyn/devtools-codegen | 388cac15e584dce3040d5090e8f627e5360e5c0f | [
"0BSD"
] | null | null | null | src/memberdef.py | alljoyn/devtools-codegen | 388cac15e584dce3040d5090e8f627e5360e5c0f | [
"0BSD"
] | null | null | null | # Copyright AllSeen Alliance. All rights reserved.
#
# Permission to use, copy, modify, and/or distribute this software for any
# purpose with or without fee is hereby granted, provided that the above
# copyright notice and this permission notice appear in all copies.
#
# THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR 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, DIRECT, 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.
import validate
import common
class MemberDef:
"""Common base class for field and argument definitions."""
def __init__(self, name = None, arg_type = None):
"""Initialize an instance of the MemberDef class."""
self.name = name
self.arg_type = arg_type
# This is initialized in Interface.parse()
self.interface = None
return
def get_flattened_signature(self):
"""Flatten the signature by replacing all [NamedTypes] with their expanded signature."""
basesig = self.get_base_signature()
if basesig[0] != '[':
return self.arg_type
prefix = 'a'*(len(self.arg_type)-len(basesig))
basetype = self.get_named_type().get_flattened_signature()
return prefix+basetype
def get_flattened_base_signature(self):
"""Return the flattened base signature."""
return get_base_signature(self.get_flattened_signature())
def get_base_signature(self):
"""Return the base signature i.e. 'i', 'ai', and 'aai' all return 'i'."""
return get_base_signature(self.arg_type)
def get_named_type(self):
"""Returns the named type definition this argument refers to, or None."""
if self.interface is None:
return None
basesig = self.get_base_signature()
if basesig[0] == '[':
return self.interface.get_named_type(basesig[1:-1])
return None
def references_named_type(self):
"""Returns true if arg_type contains a [NamedType] reference."""
basesig = self.get_base_signature()
return basesig[0] == '['
def is_basic_type(self):
"""Return True if this argument is a basic type."""
return (not self.references_named_type()) and is_basic_type(self.arg_type)
def is_array(self):
"""Return True if this argument is an array. A dictionary is considered an array."""
return is_array(self.get_flattened_signature())
def is_structure(self):
"""Return True if the base argument type is a structure."""
return is_structure(self.get_flattened_signature())
def is_dictionary(self):
"""Return True if the base argument type is a dictionary."""
return is_dictionary(self.get_flattened_signature())
def is_dictionary_array(self):
"""Return True if the base argument type is an array of dictionaries."""
return is_dictionary_array(self.get_flattened_signature())
def get_indirection_level(self):
"""Get the number of dimensions in the array or 0 if not an array."""
return get_indirection_level(self.get_flattened_signature())
def get_max_array_dimension(self):
"""Gets the number of array dimensions in this signature."""
return get_max_array_dimension(self.get_flattened_signature())
def get_max_structure_depth(self):
"""Return the maximum depth of structures in this type.
Examples:
"bud" returns 0
"(bud)" returns 1
"(bud)(did)" returns 1
"(bud(did))" returns 2
"(q(bud)(did))" returns 2
"(i((bud(did))i))" returns 4
"""
return get_max_structure_depth(self.get_flattened_signature())
def get_max_dictionary_depth(self):
"""Return the maximum depth of dictionaries in this type.
Examples:
"bud" returns 0
"a{bud}" returns 1
"a{bud}a{did}" returns 1
"a{buda{did}}" returns 2
"a{qa{bud}a{did})" returns 2
"a{ia{a{buda{did}}i}}" returns 4
"""
return get_max_dictionary_depth(self.get_flattened_signature())
def __str__(self):
return "{0} : {1}".format(self.name, self.arg_type)
def __eq__(self, other):
"""Compares this member definition to another and returns true if equal."""
return self.name == other.name and self.arg_type == other.arg_type
def __ne__(self, other):
"""Implements the '!=' operator."""
if self == other:
return False
return True
def get_indirection_level(signature):
"""Get the number of dimensions in the array or 0 if not an array."""
return len(signature) - len(signature.lstrip('a'))
def get_base_signature(signature, index = 0):
"""Return the base signature i.e. 'i', 'ai', and 'aai' all return 'i'."""
return signature[index:len(signature)].lstrip('a')
def is_array(signature):
"""Return True if this argument is an array. A dictionary is considered an array."""
return signature[0] == "a"
def is_structure(signature):
"""Return True if the base argument type is a structure."""
sig = get_base_signature(signature)
return sig[0] == '('
def is_dictionary(signature):
"""Return True if the base argument type is a dictionary."""
sig = get_base_signature(signature)
return signature[0] == 'a' and sig[0] == '{'
def is_dictionary_array(signature):
"""Return True if the base argument type is an array of dictionaries."""
return is_dictionary(signature) and get_indirection_level(signature) > 1
def __find_end_of_type(signature, index = 0):
"""Returns the index of the start of the next type starting at 'index'.
If there are no more types then return the end of the type signature.
For example:
("ab", 0) returns 1
("ab", 1) returns 2
("aab", 0) returns 1
("aab", 1) returns 1
("aab", 2) returns 3
("abb", 1) returns 2
("abb", 2) returns 3
("bqd", 0) returns 1
("bqd", 1) returns 2
("bqd", 2) returns 3
("(bqd)", 0) returns 4
("(bqd)", 1) returns 2
("(bqd)", 2) returns 3
("(bqd)", 3) returns 4
("(bqd)", 4) returns 5
("(bqd(bad))", 0) returns 9
("(bqd(bad))", 1) returns 2
("(bqd(bad))", 2) returns 3
("(bqd(bad))", 3) returns 4
("(bqd(bad))", 4) returns 8
("(bqd(bad))", 5) returns 6"""
assert(index < len(signature))
c = signature[index]
if c == '(':
end_index = __find_container_end(signature, index, ')')
elif c == '{':
end_index = __find_container_end(signature, index, '}')
elif c == 'a':
base = get_base_signature(signature, index)
end_index = __find_end_of_type(base)
end_index += index + get_indirection_level(signature, index)
else:
end_index = index + 1
return end_index
def is_basic_type(signature):
"""Returns True if the signature is a basic type
'a', '(', '{', and 'v' are not considered basic types because they usually
cannot be handled the same as other types."""
basic_types = ('b','d', 'g', 'i','n','o','q','s','t','u','x','y')
return signature in basic_types
def get_max_array_dimension(signature):
"""Gets the number of array dimensions in this signature."""
return_value = 0
while signature.find((return_value + 1) * 'a') != -1:
return_value += 1
return return_value
def get_max_structure_depth(signature):
return get_max_container_depth(signature, '(', ')')
def get_max_dictionary_depth(signature):
return get_max_container_depth(signature, '{', '}')
def get_max_container_depth(signature, start, stop):
return_value = 0
count = 0
for c in signature:
if c == start:
count += 1
elif c == stop:
count -= 1
if count > return_value:
return_value += 1
return return_value
def split_signature(sig):
"""splits a container signature into individual fields."""
components = []
index = 1
while index < len(sig)-1:
part = sig[index:]
startindex = get_indirection_level(part)
endindex = __find_end_of_type(part, startindex)
components.append(part[:endindex])
index = index + endindex
return components
def make_clean_name(signature):
clean_name = signature.replace("(", "_")
clean_name = clean_name.replace(")", "")
clean_name = clean_name.replace("{", "_")
clean_name = clean_name.replace("}", "")
clean_name = clean_name.replace("[", "_")
clean_name = clean_name.replace("]", "")
return clean_name
def __find_container_end(signature, index, end):
start = signature[index]
count = 0
while index < len(signature):
c = signature[index]
if c == start:
count += 1
elif c == end:
count -= 1
if count == 0:
index += 1
break
index += 1
return index
| 33.177536 | 96 | 0.644207 | 1,249 | 9,157 | 4.552442 | 0.179343 | 0.014773 | 0.040626 | 0.039571 | 0.459374 | 0.368976 | 0.323954 | 0.238656 | 0.226521 | 0.214738 | 0 | 0.012602 | 0.237414 | 9,157 | 275 | 97 | 33.298182 | 0.801661 | 0.390849 | 0 | 0.181159 | 0 | 0 | 0.009222 | 0 | 0 | 0 | 0 | 0 | 0.007246 | 1 | 0.23913 | false | 0 | 0.014493 | 0.021739 | 0.528986 | 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 | 0 | 1 | 0 | 0 | 2 |
73a9cda8e0d2bd2c5fe35622d180c1e9b443a525 | 1,905 | py | Python | application/modules/post/windows-priv-check/wpc/report/issues.py | cys3c/viper-shell | e05a07362b7d1e6d73c302a24d2506846e43502c | [
"PSF-2.0",
"BSD-2-Clause"
] | 2 | 2018-06-30T03:21:30.000Z | 2020-03-22T02:31:02.000Z | application/modules/post/windows-priv-check/wpc/report/issues.py | cys3c/viper-shell | e05a07362b7d1e6d73c302a24d2506846e43502c | [
"PSF-2.0",
"BSD-2-Clause"
] | null | null | null | application/modules/post/windows-priv-check/wpc/report/issues.py | cys3c/viper-shell | e05a07362b7d1e6d73c302a24d2506846e43502c | [
"PSF-2.0",
"BSD-2-Clause"
] | 3 | 2017-11-15T11:08:20.000Z | 2020-03-22T02:31:03.000Z | from wpc.report.issue import issue
import xml.etree.cElementTree as etree
from lxml import etree as letree
from operator import itemgetter, attrgetter, methodcaller
# TODO should this class contain info about the scan? or define a new class called report?
# Version of script
# Date, time of audit
# Who the audit ran as (username, groups, privs)
# ...
class issues:
def __init__(self):
self.issues = []
def get_by_id(self, identifier):
# search for issue
for i in self.issues:
if i.get_id() == identifier:
return i
# create new issue
i = issue(identifier)
self.add_issue(i)
return i
def add_issue(self, i):
self.issues.append(i)
def add_supporting_data(self, identifier, k, v):
self.get_by_id(identifier).add_supporting_data(k, v)
def get_all(self):
s = sorted(self.issues, key=methodcaller('get_confidence'), reverse=True)
return sorted(s, key=methodcaller('get_severity'), reverse=True)
def as_xml_string(self):
return etree.tostring(self.as_xml())
def as_xml(self):
r = etree.Element('issues')
for i in self.get_all():
r.append(i.as_xml())
return r
def as_text(self):
xslt_fh = open('xsl/text.xsl', 'r') # TODO need to be able to run from other dirs too!
xslt_str = xslt_fh.read()
xslt_fh.close()
xslt_root = letree.XML(xslt_str)
transform = letree.XSLT(xslt_root)
return str(transform(letree.XML(self.as_xml_string())))
def as_html(self):
xslt_fh = open('xsl/html.xsl', 'r') # TODO need to be able to run from other dirs too!
xslt_str = xslt_fh.read()
xslt_fh.close()
xslt_root = letree.XML(xslt_str)
transform = letree.XSLT(xslt_root)
return str(transform(letree.XML(self.as_xml_string())))
| 31.229508 | 95 | 0.632546 | 277 | 1,905 | 4.191336 | 0.33213 | 0.02584 | 0.062016 | 0.017227 | 0.308355 | 0.27907 | 0.27907 | 0.27907 | 0.27907 | 0.27907 | 0 | 0 | 0.260892 | 1,905 | 60 | 96 | 31.75 | 0.824574 | 0.16273 | 0 | 0.285714 | 0 | 0 | 0.036593 | 0 | 0 | 0 | 0 | 0.016667 | 0 | 1 | 0.214286 | false | 0 | 0.095238 | 0.02381 | 0.5 | 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 | 1 | 0 | 0 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 2 |
73ac2455924ff0001809acc001de20f6e6bc1656 | 813 | py | Python | neurokit2/microstates/__init__.py | danibene/NeuroKit | df0ab6696e7418cf8b8dcd3ed82dbf879fa61b3a | [
"MIT"
] | 1 | 2020-12-31T17:48:11.000Z | 2020-12-31T17:48:11.000Z | neurokit2/microstates/__init__.py | danibene/NeuroKit | df0ab6696e7418cf8b8dcd3ed82dbf879fa61b3a | [
"MIT"
] | null | null | null | neurokit2/microstates/__init__.py | danibene/NeuroKit | df0ab6696e7418cf8b8dcd3ed82dbf879fa61b3a | [
"MIT"
] | 2 | 2021-12-25T15:39:49.000Z | 2021-12-25T15:44:16.000Z | """Submodule for NeuroKit."""
from .microstates_clean import microstates_clean
from .microstates_peaks import microstates_peaks
from .microstates_static import microstates_static
from .microstates_dynamic import microstates_dynamic
from .microstates_complexity import microstates_complexity
from .microstates_segment import microstates_segment
from .microstates_classify import microstates_classify
from .microstates_plot import microstates_plot
from .microstates_findnumber import microstates_findnumber
__all__ = ["microstates_clean",
"microstates_peaks",
"microstates_static",
"microstates_dynamic",
"microstates_complexity",
"microstates_segment",
"microstates_classify",
"microstates_plot",
"microstates_findnumber"]
| 35.347826 | 58 | 0.771218 | 76 | 813 | 7.842105 | 0.210526 | 0.22651 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0.173432 | 813 | 22 | 59 | 36.954545 | 0.886905 | 0.02829 | 0 | 0 | 0 | 0 | 0.216837 | 0.056122 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | false | 0 | 0.5 | 0 | 0.5 | 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 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 0 | 0 | 2 |
73aed6f56861e4609809462a9a1cf35c41cc4da9 | 612 | py | Python | torchx/examples/apps/lightning_classy_vision/test/component_test.py | LaudateCorpus1/torchx | 9ee0fdbf63882ba836c00d7522f6850c0c6dc418 | [
"BSD-3-Clause"
] | 101 | 2021-06-12T20:00:09.000Z | 2022-03-31T11:14:35.000Z | torchx/examples/apps/lightning_classy_vision/test/component_test.py | LaudateCorpus1/torchx | 9ee0fdbf63882ba836c00d7522f6850c0c6dc418 | [
"BSD-3-Clause"
] | 340 | 2021-06-14T18:16:12.000Z | 2022-03-31T21:10:28.000Z | torchx/examples/apps/lightning_classy_vision/test/component_test.py | LaudateCorpus1/torchx | 9ee0fdbf63882ba836c00d7522f6850c0c6dc418 | [
"BSD-3-Clause"
] | 19 | 2021-06-13T06:17:21.000Z | 2022-03-28T19:28:00.000Z | # Copyright (c) Meta Platforms, Inc. and affiliates.
# All rights reserved.
#
# This source code is licensed under the BSD-style license found in the
# LICENSE file in the root directory of this source tree.
import torchx.examples.apps.lightning_classy_vision.component as lightning_classy_vision
from torchx.components.component_test_base import ComponentTestCase
class DistributedComponentTest(ComponentTestCase):
def test_trainer(self) -> None:
self.validate(lightning_classy_vision, "trainer")
def test_interpret(self) -> None:
self.validate(lightning_classy_vision, "interpret")
| 36 | 88 | 0.785948 | 78 | 612 | 6.012821 | 0.628205 | 0.127932 | 0.179104 | 0.085288 | 0.17484 | 0.17484 | 0.17484 | 0 | 0 | 0 | 0 | 0 | 0.142157 | 612 | 16 | 89 | 38.25 | 0.893333 | 0.321895 | 0 | 0 | 0 | 0 | 0.03912 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0.285714 | false | 0 | 0.285714 | 0 | 0.714286 | 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 | 0 | 1 | 0 | 0 | 2 |
73b135f20a4d854cdb5b09c10b76e9756be5c474 | 161 | py | Python | shipfunk_python/__init__.py | vilkasgroup/shipfunk_python | cd8a5414bda7e9670511c52d0b4df2efd11ee5d9 | [
"MIT"
] | null | null | null | shipfunk_python/__init__.py | vilkasgroup/shipfunk_python | cd8a5414bda7e9670511c52d0b4df2efd11ee5d9 | [
"MIT"
] | 2 | 2018-01-16T07:32:18.000Z | 2018-01-17T07:29:41.000Z | shipfunk_python/__init__.py | vilkasgroup/shipfunk_python | cd8a5414bda7e9670511c52d0b4df2efd11ee5d9 | [
"MIT"
] | null | null | null | # -*- coding: utf-8 -*-
"""Top-level package for Shipfunk."""
__author__ = """Jaana Sarajärvi"""
__email__ = 'jaana.sarajarvi@vilkas.fi'
__version__ = '0.1.1'
| 20.125 | 39 | 0.652174 | 20 | 161 | 4.65 | 0.9 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0.028571 | 0.130435 | 161 | 7 | 40 | 23 | 0.635714 | 0.335404 | 0 | 0 | 0 | 0 | 0.445545 | 0.247525 | 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 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 2 |
73b14a8ac2d94f0475d3f40d5181eb41aedadcce | 638 | py | Python | vpc/nos/driver/ovs/ne.py | zhufawuwo/baton | 64c88750bc96b92e268b4903f34a1d5021c686f4 | [
"Apache-2.0"
] | null | null | null | vpc/nos/driver/ovs/ne.py | zhufawuwo/baton | 64c88750bc96b92e268b4903f34a1d5021c686f4 | [
"Apache-2.0"
] | null | null | null | vpc/nos/driver/ovs/ne.py | zhufawuwo/baton | 64c88750bc96b92e268b4903f34a1d5021c686f4 | [
"Apache-2.0"
] | null | null | null | #! python3
# coding: utf-8
from vpc.nos import NetworkElement,NetworkElementEvent,event_t,EventChain
class OVSEvent(NetworkElementEvent):
def __init__(self,ne_id,type):
super().__init__(ne_id,type)
class OVS(NetworkElement):
def __init__(self,channel,datapath):
super().__init__()
self.chn = channel
self.ofp = self.chn.ofp
self._datapath = datapath
self.ne_online()
@property
def datapath(self):
return self._datapath
def ne_online(self):
e = OVSEvent(self.id,event_t.NE_ONLINE)
EventChain().feed(e)
if __name__ == "__main__":
pass | 20.580645 | 73 | 0.653605 | 77 | 638 | 4.987013 | 0.467532 | 0.0625 | 0.057292 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0.004098 | 0.23511 | 638 | 31 | 74 | 20.580645 | 0.782787 | 0.03605 | 0 | 0 | 0 | 0 | 0.013029 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0.210526 | false | 0.052632 | 0.052632 | 0.052632 | 0.421053 | 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 | 0 | 0 | 0 | 2 |
73de5fb73d8473474f580b5f20b98adc8660e07b | 1,141 | py | Python | platypush/plugins/logger/__init__.py | BlackLight/runbullet | 8d26c8634d2677b4402f0a21b9ab8244b44640db | [
"MIT"
] | 3 | 2017-11-03T17:03:36.000Z | 2017-11-10T06:38:15.000Z | platypush/plugins/logger/__init__.py | BlackLight/runbullet | 8d26c8634d2677b4402f0a21b9ab8244b44640db | [
"MIT"
] | 14 | 2017-11-04T11:46:37.000Z | 2017-12-11T19:15:27.000Z | platypush/plugins/logger/__init__.py | BlackLight/runbullet | 8d26c8634d2677b4402f0a21b9ab8244b44640db | [
"MIT"
] | null | null | null | from platypush.plugins import Plugin, action
class LoggerPlugin(Plugin):
"""
Plugin to log traces on the standard Platypush logger
"""
@action
def trace(self, msg, *args, **kwargs):
"""
logger.trace wrapper
"""
self.logger.trace(msg, *args, **kwargs)
@action
def debug(self, msg, *args, **kwargs):
"""
logger.debug wrapper
"""
self.logger.debug(msg, *args, **kwargs)
@action
def info(self, msg, *args, **kwargs):
"""
logger.info wrapper
"""
self.logger.info(msg, *args, **kwargs)
@action
def warning(self, msg, *args, **kwargs):
"""
logger.warning wrapper
"""
self.logger.warning(msg, *args, **kwargs)
@action
def error(self, msg, *args, **kwargs):
"""
logger.error wrapper
"""
self.logger.error(msg, *args, **kwargs)
@action
def exception(self, exception, *args, **kwargs):
"""
logger.exception wrapper
"""
self.logger.exception(exception, *args, **kwargs)
# vim:sw=4:ts=4:et:
| 21.12963 | 57 | 0.531113 | 120 | 1,141 | 5.05 | 0.266667 | 0.19802 | 0.214521 | 0.140264 | 0.371287 | 0 | 0 | 0 | 0 | 0 | 0 | 0.002564 | 0.316389 | 1,141 | 53 | 58 | 21.528302 | 0.774359 | 0.177914 | 0 | 0.3 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0.3 | false | 0 | 0.05 | 0 | 0.4 | 0 | 0 | 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 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 2 |
73df0b517cdf0b8ebc3a55ea196f1562c83f9f1c | 4,329 | py | Python | tests/test_bullet_train.py | masschallenge/bullet-train-python-client | bcec653c0b4ed65779ab4e1a2f809810c684be00 | [
"BSD-3-Clause"
] | null | null | null | tests/test_bullet_train.py | masschallenge/bullet-train-python-client | bcec653c0b4ed65779ab4e1a2f809810c684be00 | [
"BSD-3-Clause"
] | null | null | null | tests/test_bullet_train.py | masschallenge/bullet-train-python-client | bcec653c0b4ed65779ab4e1a2f809810c684be00 | [
"BSD-3-Clause"
] | null | null | null | import json
import logging
from unittest import mock, TestCase
from bullet_train import BulletTrain
import os
logger = logging.getLogger(__name__)
logger.setLevel(logging.INFO)
TEST_API_URL = 'https://test.bullet-train.io/api'
TEST_IDENTIFIER = 'test-identity'
TEST_FEATURE = 'test-feature'
class MockResponse:
def __init__(self, data, status_code):
self.json_data = json.loads(data)
self.status_code = status_code
def json(self):
return self.json_data
def mock_response(filename, *args, status=200, **kwargs):
print('Hit URL %s with params' % args[0], kwargs.get('params'))
dir_path = os.path.dirname(os.path.realpath(__file__))
with open(os.path.join(dir_path, filename), 'rt') as f:
return MockResponse(f.read(), status)
def mocked_get_specific_feature_flag_enabled(*args, **kwargs):
return mock_response('data/get-flag-for-specific-feature-enabled.json', *args, **kwargs)
def mocked_get_specific_feature_flag_disabled(*args, **kwargs):
return mock_response('data/get-flag-for-specific-feature-disabled.json', *args, **kwargs)
def mocked_get_specific_feature_flag_not_found(*args, **kwargs):
return mock_response('data/not-found.json', *args, status=404, **kwargs)
def mocked_get_value(*args, **kwargs):
return mock_response('data/get-value-for-specific-feature.json', *args, **kwargs)
def mocked_get_identity_flags_with_trait(*args, **kwargs):
return mock_response('data/get-identity-flags-with-trait.json', *args, **kwargs)
def mocked_get_identity_flags_without_trait(*args, **kwargs):
return mock_response('data/get-identity-flags-without-trait.json', *args, **kwargs)
class BulletTrainTestCase(TestCase):
test_environment_key = 'test-env-key'
def setUp(self) -> None:
self.bt = BulletTrain(environment_id=self.test_environment_key, api=TEST_API_URL)
@mock.patch('bullet_train.bullet_train.requests.get', side_effect=mocked_get_specific_feature_flag_enabled)
def test_has_feature_returns_true_if_feature_returned(self, mock_get):
# When
result = self.bt.has_feature(TEST_FEATURE)
# Then
assert result
@mock.patch('bullet_train.bullet_train.requests.get', side_effect=mocked_get_specific_feature_flag_not_found)
def test_has_feature_returns_false_if_feature_not_returned(self, mock_get):
# When
result = self.bt.has_feature(TEST_FEATURE)
# Then
assert not result
@mock.patch('bullet_train.bullet_train.requests.get', side_effect=mocked_get_specific_feature_flag_enabled)
def test_feature_enabled_returns_true_if_feature_enabled(self, mock_get):
# When
result = self.bt.feature_enabled(TEST_FEATURE)
# Then
assert result
@mock.patch('bullet_train.bullet_train.requests.get', side_effect=mocked_get_specific_feature_flag_disabled)
def test_feature_enabled_returns_true_if_feature_disabled(self, mock_get):
# When
result = self.bt.feature_enabled(TEST_FEATURE)
# Then
assert not result
@mock.patch('bullet_train.bullet_train.requests.get', side_effect=mocked_get_value)
def test_get_value_returns_value_for_environment_if_feature_exists(self, mock_get):
# When
result = self.bt.get_value(TEST_FEATURE)
# Then
assert result == 'Test value'
@mock.patch('bullet_train.bullet_train.requests.get', side_effect=mocked_get_specific_feature_flag_not_found)
def test_get_value_returns_None_for_environment_if_feature_does_not_exist(self, mock_get):
# When
result = self.bt.get_value(TEST_FEATURE)
# Then
assert result is None
@mock.patch('bullet_train.bullet_train.requests.get', side_effect=mocked_get_identity_flags_with_trait)
def test_get_trait_returns_trait_value_if_trait_key_exists(self, mock_get):
# When
result = self.bt.get_trait('trait_key', TEST_IDENTIFIER)
# Then
assert result == 'trait_value'
@mock.patch('bullet_train.bullet_train.requests.get', side_effect=mocked_get_identity_flags_without_trait)
def test_get_trait_returns_None_if_trait_key_does_not_exist(self, mock_get):
# When
result = self.bt.get_trait('trait_key', TEST_IDENTIFIER)
# Then
assert result is None
| 34.632 | 113 | 0.736891 | 599 | 4,329 | 4.951586 | 0.160267 | 0.066757 | 0.045853 | 0.064734 | 0.688132 | 0.653068 | 0.598449 | 0.583951 | 0.532367 | 0.497977 | 0 | 0.001929 | 0.161931 | 4,329 | 124 | 114 | 34.91129 | 0.815601 | 0.018249 | 0 | 0.26087 | 0 | 0 | 0.159934 | 0.122844 | 0 | 0 | 0 | 0 | 0.115942 | 1 | 0.26087 | false | 0 | 0.072464 | 0.101449 | 0.492754 | 0.014493 | 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 | 0 | 0 | 0 | 2 |
73f42c1536b7cbae9884bce03cfe3067637e0ad1 | 3,681 | py | Python | get_stock_data.py | jeremychonggg/Alpaca-Trading-Bot | 82df00e327e2e55f5a0cdf85cd950c49c59bf669 | [
"MIT"
] | null | null | null | get_stock_data.py | jeremychonggg/Alpaca-Trading-Bot | 82df00e327e2e55f5a0cdf85cd950c49c59bf669 | [
"MIT"
] | null | null | null | get_stock_data.py | jeremychonggg/Alpaca-Trading-Bot | 82df00e327e2e55f5a0cdf85cd950c49c59bf669 | [
"MIT"
] | null | null | null | import json
import requests
import pandas as pd
import websocket
# Get Alpaca API Credential
endpoint = "https://data.alpaca.markets/v2"
headers = json.loads(open("key.txt", 'r').read())
def hist_data(symbols, start="2021-01-01", timeframe="1Hour", limit=50, end=""):
"""
returns historical bar data for a string of symbols separated by comma
symbols should be in a string format separated by comma e.g. symbols = "MSFT,AMZN,GOOG"
"""
df_data_tickers = {}
for symbol in symbols:
bar_url = endpoint + "/stocks/{}/bars".format(symbol)
params = {"start":start, "limit" :limit, "timeframe":timeframe}
data = {"bars": [], "next_page_token":'', "symbol":symbol}
while True:
r = requests.get(bar_url, headers = headers, params = params)
r = r.json()
if r["next_page_token"] == None:
data["bars"]+=r["bars"]
break
else:
params["page_token"] = r["next_page_token"]
data["bars"]+=r["bars"]
data["next_page_token"] = r["next_page_token"]
df_data = pd.DataFrame(data["bars"])
df_data.rename({"t":"time","o":"open","h":"high","l":"low","c":"close","v":"volume"},axis=1, inplace=True)
df_data["time"] = pd.to_datetime(df_data["time"])
df_data.set_index("time",inplace=True)
df_data.index = df_data.index.tz_convert("America/Indiana/Petersburg")
df_data_tickers[symbol] = df_data
return df_data_tickers
def get_historical_data(ticker_list, start_date, end_date=None, limit=10000, timeframe="1Day"):
"""
returns historical bar data for a string of symbols separated by comma
symbols should be in a string format separated by comma e.g. symbols = "MSFT,AMZN,GOOG"
* timeframe - Timeframe for the aggregation. Available values are: `1Min`, `1Hour`, `1Day`
https://alpaca.markets/docs/api-documentation/api-v2/market-data/alpaca-data-api-v2/historical/#bars
"""
df_data_tickers = {}
for symbol in ticker_list:
bar_url = endpoint + "/stocks/{}/bars".format(symbol)
params = {"start":start_date, "end": end_date, "limit": limit, "timeframe":timeframe}
data = {"bars": [], "next_page_token": '', "symbol": symbol}
# r = requests.get(bar_url, headers=headers, params=params)
# r = r.json()
# data["bars"] += r["bars"]
while True:
r = requests.get(bar_url, headers=headers, params=params)
r = r.json()
try:
if r["next_page_token"] == None:
data["bars"] += r["bars"]
break
else:
params["page_token"] = r["next_page_token"]
data["bars"] += r["bars"]
data["next_page_token"] = r["next_page_token"]
except:
break
# Create a DataFrame for the data["bars"] of each stock
df_data = pd.DataFrame(data["bars"])
df_data.rename({"t":"time","o":"open","h":"high","l":"low","c":"close","v":"volume"},axis=1, inplace=True)
try:
df_data["time"] = pd.to_datetime(df_data["time"])
df_data.set_index("time",inplace=True)
df_data.index = df_data.index.tz_convert("America/New_York")
df_data_tickers[symbol] = df_data
except:
pass
print("---- Created for [{}]".format(symbol))
return df_data_tickers
| 39.159574 | 115 | 0.551481 | 451 | 3,681 | 4.343681 | 0.263858 | 0.067381 | 0.06636 | 0.042879 | 0.685043 | 0.685043 | 0.635018 | 0.635018 | 0.635018 | 0.635018 | 0 | 0.009705 | 0.30019 | 3,681 | 93 | 116 | 39.580645 | 0.750776 | 0.186906 | 0 | 0.728814 | 0 | 0 | 0.179099 | 0.009148 | 0 | 0 | 0 | 0 | 0 | 1 | 0.033898 | false | 0.016949 | 0.067797 | 0 | 0.135593 | 0.016949 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 2 |
fb53c7de261609a0deb36f13cdae3c4c1cc92433 | 789 | py | Python | Libraries/DUTs/Community/di_vsphere/pysphere/revertToNamedSnapshot.py | nneul/iTest-assets | 478659d176891e45d81f7fdb27440a86a21965bb | [
"MIT"
] | 10 | 2017-12-28T10:15:56.000Z | 2020-10-19T18:13:58.000Z | Libraries/DUTs/Community/di_vsphere/pysphere/revertToNamedSnapshot.py | nneul/iTest-assets | 478659d176891e45d81f7fdb27440a86a21965bb | [
"MIT"
] | 37 | 2018-03-07T00:48:37.000Z | 2021-03-22T20:03:48.000Z | Libraries/DUTs/Community/di_vsphere/pysphere/revertToNamedSnapshot.py | nneul/iTest-assets | 478659d176891e45d81f7fdb27440a86a21965bb | [
"MIT"
] | 27 | 2018-03-06T19:56:01.000Z | 2022-03-23T04:18:23.000Z | import sys
sys.path.append("./pysphere")
from pysphere import VIServer
from pysphere.resources.vi_exception import VIException, VIApiException, \
FaultTypes
import sys
if len(sys.argv) != 6:
sys.exit("error = please check arguments")
serverName = sys.argv[1]
login = sys.argv[2]
passwd = sys.argv[3]
vm_name = sys.argv[4]
snap_name = sys.argv[5]
server = VIServer()
server.connect(serverName, login, passwd)
myVm = server.get_vm_by_name(vm_name)
try:
revertTask = myVm.revert_to_named_snapshot(snap_name)
server.disconnect()
except (VIException), err:
print "RevertResult = " + err.message
sys.exit(1)
if revertTask is None:
print "RevertResult = success"
else:
print "RevertResult = failure" | 29.222222 | 75 | 0.673004 | 101 | 789 | 5.148515 | 0.544554 | 0.080769 | 0.042308 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0.011364 | 0.219265 | 789 | 27 | 76 | 29.222222 | 0.832792 | 0 | 0 | 0.076923 | 0 | 0 | 0.13089 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | null | null | 0.076923 | 0.153846 | null | null | 0.115385 | 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 | 1 | 0 | 0 | 1 | 0 | 0 | 0 | 0 | 0 | 2 |
fb56b6a8fcadb6c716511c7be794553961db8e2e | 529 | py | Python | modules/api/functional_test/live_tests/conftest.py | exoego/vinyldns | aac4c2afe4c599ac8c96ad3a826f3a6dff887104 | [
"Apache-2.0"
] | null | null | null | modules/api/functional_test/live_tests/conftest.py | exoego/vinyldns | aac4c2afe4c599ac8c96ad3a826f3a6dff887104 | [
"Apache-2.0"
] | 1 | 2019-02-06T21:38:12.000Z | 2019-02-06T21:38:12.000Z | modules/api/functional_test/live_tests/conftest.py | exoego/vinyldns | aac4c2afe4c599ac8c96ad3a826f3a6dff887104 | [
"Apache-2.0"
] | null | null | null | import pytest
@pytest.fixture(scope="session")
def shared_zone_test_context(request):
from shared_zone_test_context import SharedZoneTestContext
ctx = SharedZoneTestContext()
def fin():
ctx.tear_down()
request.addfinalizer(fin)
return ctx
@pytest.fixture(scope="session")
def zone_history_context(request):
from zone_history_context import ZoneHistoryContext
context = ZoneHistoryContext()
def fin():
context.tear_down()
request.addfinalizer(fin)
return context
| 18.241379 | 62 | 0.725898 | 58 | 529 | 6.413793 | 0.362069 | 0.069892 | 0.096774 | 0.134409 | 0.344086 | 0.193548 | 0 | 0 | 0 | 0 | 0 | 0 | 0.190926 | 529 | 28 | 63 | 18.892857 | 0.869159 | 0 | 0 | 0.352941 | 0 | 0 | 0.026465 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0.235294 | false | 0 | 0.176471 | 0 | 0.529412 | 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 | 0 | 1 | 0 | 0 | 2 |
fb607c62040621d2cd1122da4b43413ea79de0be | 4,331 | py | Python | engine/resources.py | gerizim16/MP2_GRP19 | 591fbb47fec6c5471d4e63151f494641452b4cb7 | [
"CC0-1.0"
] | 1 | 2020-09-25T02:46:00.000Z | 2020-09-25T02:46:00.000Z | engine/resources.py | gerizim16/MP2_GRP19 | 591fbb47fec6c5471d4e63151f494641452b4cb7 | [
"CC0-1.0"
] | null | null | null | engine/resources.py | gerizim16/MP2_GRP19 | 591fbb47fec6c5471d4e63151f494641452b4cb7 | [
"CC0-1.0"
] | null | null | null | import pyglet
print('Loading resources')
def center_image(image):
"""Sets an image's anchor point to its center"""
image.anchor_x = image.width / 2
image.anchor_y = image.height / 2
# Tell pyglet where to find the resources
pyglet.resource.path = ['./resources', './resources/backgrounds']
pyglet.resource.reindex()
images = list()
# Load the three main resources and get them to draw centered
tank_body_img = pyglet.resource.image('tank_body.png')
images.append(tank_body_img)
tank_head_img = pyglet.resource.image('tank_head.png')
images.append(tank_head_img)
boxlife_img = pyglet.resource.image('boxlife.png')
images.append(boxlife_img)
boxlife_dead_img = pyglet.resource.image('boxlife_dead.png')
images.append(boxlife_dead_img)
wheel_img = pyglet.resource.image('wheel.png')
images.append(wheel_img)
thread_img = pyglet.resource.image('thread.png')
images.append(thread_img)
motorbike_chassis_img = pyglet.resource.image('motorbike_chassis.png')
images.append(motorbike_chassis_img)
mb_wheel_img = pyglet.resource.image('mb_wheel.png')
images.append(mb_wheel_img)
mb_holder_img = pyglet.resource.image('mb_holder.png')
images.append(mb_holder_img)
vbv_chassis_img = pyglet.resource.image('vbv_chassis.png')
images.append(vbv_chassis_img)
vbv_wheels_img = pyglet.resource.image('vbv_wheels.png')
images.append(vbv_wheels_img)
vbv_platform_img = pyglet.resource.image('vbv_platform.png')
images.append(vbv_platform_img)
vb_net_img = pyglet.resource.image('vb_net.png')
images.append(vb_net_img)
vb_ball_img = pyglet.resource.image('vb_ball.png')
images.append(vb_ball_img)
game1_button_img = pyglet.resource.image('game1.png')
images.append(game1_button_img)
game1_button_hover_img = pyglet.resource.image('game1_hover.png')
images.append(game1_button_hover_img)
game2_button_img = pyglet.resource.image('game2.png')
images.append(game2_button_img)
game2_button_hover_img = pyglet.resource.image('game2_hover.png')
images.append(game2_button_hover_img)
game3_button_img = pyglet.resource.image('game3.png')
images.append(game3_button_img)
game3_button_hover_img = pyglet.resource.image('game3_hover.png')
images.append(game3_button_hover_img)
game1_hs_button_img = pyglet.resource.image('game1_hs.png')
images.append(game1_hs_button_img)
game1_hs_button_hover_img = pyglet.resource.image('game1_hs_hover.png')
images.append(game1_hs_button_hover_img)
game2_hs_button_img = pyglet.resource.image('game2_hs.png')
images.append(game2_hs_button_img)
game2_hs_button_hover_img = pyglet.resource.image('game2_hs_hover.png')
images.append(game2_hs_button_hover_img)
menu_button_img = pyglet.resource.image('menu.png')
images.append(menu_button_img)
gravity_button_img = pyglet.resource.image('gravity.png')
images.append(gravity_button_img)
fullscreen_button_img = pyglet.resource.image('fullscreen.png')
images.append(fullscreen_button_img)
restart_button_img = pyglet.resource.image('restart_button.png')
images.append(restart_button_img)
enter_button_img = pyglet.resource.image('enter_button.png')
images.append(enter_button_img)
enter_button_hover_img = pyglet.resource.image('enter_button_hover.png')
images.append(enter_button_hover_img)
circle_meter_img = pyglet.resource.image('circle_meter.png')
images.append(circle_meter_img)
pointer_img = pyglet.resource.image('pointer.png')
images.append(pointer_img)
finishflag_img = pyglet.resource.image('finishflag.png')
images.append(finishflag_img)
goal_meter_img = pyglet.resource.image('goal_meter.png')
images.append(goal_meter_img)
bg_goal_meter_img = pyglet.resource.image('bg_goal_meter.png')
images.append(bg_goal_meter_img)
background_img = pyglet.resource.image('background.png')
images.append(background_img)
for image in images:
center_image(image)
# load backgrounds
parallax_bgs = list()
layer_counts = (3, 2, 2, 2, 3, 4)
for bg_i, layer_count in enumerate(layer_counts):
bg_set = list()
for layer_i in range(layer_count):
bg_set.append(pyglet.resource.image('{}layer_{}.png'.format(bg_i, layer_i)))
parallax_bgs.append(tuple(bg_set))
parallax_bgs = tuple(parallax_bgs)
# Load sfx without streaming
engine_sfx = pyglet.media.load('./resources/engine_sfx.wav', streaming=False)
bg_music = pyglet.media.load('./resources/bg_music.wav', streaming=False)
print('Resource loading successful')
| 30.286713 | 84 | 0.803048 | 658 | 4,331 | 4.972644 | 0.151976 | 0.16687 | 0.214853 | 0.242054 | 0.433374 | 0.178484 | 0.047677 | 0 | 0 | 0 | 0 | 0.009495 | 0.075964 | 4,331 | 142 | 85 | 30.5 | 0.808096 | 0.043177 | 0 | 0 | 0 | 0 | 0.153083 | 0.028053 | 0 | 0 | 0 | 0 | 0 | 1 | 0.010753 | false | 0 | 0.010753 | 0 | 0.021505 | 0.021505 | 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 | 0 | 0 | 0 | 0 | 0 | 2 |
fb705b9a868266542cc3de66cc5408c3859e9bcd | 617 | py | Python | messenger/helper/http/post.py | gellowmellow/python-messenger-bot | 01aaba569add8a6ed1349fc4774e3c7e64439dc0 | [
"MIT"
] | null | null | null | messenger/helper/http/post.py | gellowmellow/python-messenger-bot | 01aaba569add8a6ed1349fc4774e3c7e64439dc0 | [
"MIT"
] | null | null | null | messenger/helper/http/post.py | gellowmellow/python-messenger-bot | 01aaba569add8a6ed1349fc4774e3c7e64439dc0 | [
"MIT"
] | null | null | null | import requests
class Post:
def __init__(self, page_access_token, **kwargs):
self.page_access_token = page_access_token
return super().__init__(**kwargs)
def send(self, url, json):
try:
request_session = requests.Session()
params = {'access_token': self.page_access_token}
request = requests.Request('POST', url = url, params = params, json = json)
prepare = request.prepare()
response = request_session.send(prepare)
finally:
request_session.close()
return response.text | 30.85 | 87 | 0.593193 | 65 | 617 | 5.338462 | 0.4 | 0.158501 | 0.172911 | 0.164265 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0.309562 | 617 | 20 | 88 | 30.85 | 0.812207 | 0 | 0 | 0 | 0 | 0 | 0.025932 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | null | null | 0 | 0.066667 | null | null | 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 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 2 |
fb8cf968314b4148ab23bd50a8ea481955bbd517 | 963 | py | Python | {{cookiecutter.project_slug}}/sources/app/config/settings/components/security.py | AsheKR/cookiecutter-django | d0402aefcc2eeaffa747faa7ef50ad97286bfcca | [
"BSD-3-Clause"
] | null | null | null | {{cookiecutter.project_slug}}/sources/app/config/settings/components/security.py | AsheKR/cookiecutter-django | d0402aefcc2eeaffa747faa7ef50ad97286bfcca | [
"BSD-3-Clause"
] | null | null | null | {{cookiecutter.project_slug}}/sources/app/config/settings/components/security.py | AsheKR/cookiecutter-django | d0402aefcc2eeaffa747faa7ef50ad97286bfcca | [
"BSD-3-Clause"
] | null | null | null | # https://docs.djangoproject.com/en/dev/ref/settings/#secure-proxy-ssl-header
SECURE_PROXY_SSL_HEADER = ("HTTP_X_FORWARDED_PROTO", "https")
# https://docs.djangoproject.com/en/dev/ref/settings/#secure-ssl-redirect
SECURE_SSL_REDIRECT = True
# https://docs.djangoproject.com/en/dev/ref/settings/#session-cookie-secure
SESSION_COOKIE_SECURE = True
# https://docs.djangoproject.com/en/dev/ref/settings/#csrf-cookie-secure
CSRF_COOKIE_SECURE = True
# https://docs.djangoproject.com/en/dev/topics/security/#ssl-https
# https://docs.djangoproject.com/en/dev/ref/settings/#secure-hsts-preload
SECURE_HSTS_PRELOAD = True
# https://docs.djangoproject.com/en/dev/ref/settings/#secure-hsts-include-subdomains
SECURE_HSTS_INCLUDE_SUBDOMAINS = True
# https://docs.djangoproject.com/en/dev/ref/settings/#secure-hsts-seconds
SECURE_HSTS_SECONDS = 31536000
# https://docs.djangoproject.com/en/dev/ref/middleware/#x-content-type-options-nosniff
SECURE_CONTENT_TYPE_NOSNIFF = True
| 53.5 | 86 | 0.805815 | 141 | 963 | 5.347518 | 0.241135 | 0.107427 | 0.262599 | 0.298408 | 0.591512 | 0.591512 | 0.591512 | 0.547745 | 0.547745 | 0.289125 | 0 | 0.008696 | 0.044652 | 963 | 17 | 87 | 56.647059 | 0.81087 | 0.685358 | 0 | 0 | 0 | 0 | 0.09507 | 0.077465 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | false | 0 | 0 | 0 | 0 | 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 | 0 | 0 | 0 | 0 | 0 | 2 |
fb90339a9b070648b3ffa1426d143af98658172e | 345 | py | Python | cc/apps/coder/admin.py | mavroskardia/codechallenge | a5fee4ba73be186d90daafca50819a6817ad3d27 | [
"MIT"
] | null | null | null | cc/apps/coder/admin.py | mavroskardia/codechallenge | a5fee4ba73be186d90daafca50819a6817ad3d27 | [
"MIT"
] | null | null | null | cc/apps/coder/admin.py | mavroskardia/codechallenge | a5fee4ba73be186d90daafca50819a6817ad3d27 | [
"MIT"
] | null | null | null | from django.contrib import admin
from .models import Coder, Level
class CoderAdmin(admin.ModelAdmin):
pass
class LevelAdmin(admin.ModelAdmin):
list_display_links = ('id',)
list_display = ('id', 'name', 'starting_xp')
list_editable = ('name', 'starting_xp')
admin.site.register(Coder, CoderAdmin)
admin.site.register(Level, LevelAdmin)
| 20.294118 | 45 | 0.750725 | 44 | 345 | 5.75 | 0.522727 | 0.118577 | 0.110672 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0.115942 | 345 | 16 | 46 | 21.5625 | 0.829508 | 0 | 0 | 0 | 0 | 0 | 0.098551 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | false | 0.1 | 0.2 | 0 | 0.7 | 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 | 0 | 0 | 1 | 0 | 0 | 2 |
fb9d867e25a8da5be0e4b33fa5b6bfbaf98a5fde | 298 | py | Python | bookmarks/images/signals.py | hiteshgarg14/Django-Social-Website | 750f3b6e457a0da84e3fe4eaa56f54cb007d9e1e | [
"MIT"
] | 1 | 2020-11-19T19:33:10.000Z | 2020-11-19T19:33:10.000Z | bookmarks/images/signals.py | hiteshgarg14/Django-Social-Website | 750f3b6e457a0da84e3fe4eaa56f54cb007d9e1e | [
"MIT"
] | null | null | null | bookmarks/images/signals.py | hiteshgarg14/Django-Social-Website | 750f3b6e457a0da84e3fe4eaa56f54cb007d9e1e | [
"MIT"
] | null | null | null | from django.db.models.signals import m2m_changed
from django.dispatch import receiver
from .models import Image
@receiver(m2m_changed, sender=Image.users_likes.through)
def users_like_changed(sender, instance, **kwargs):
instance.total_likes = instance.users_likes.count()
instance.save()
| 33.111111 | 56 | 0.802013 | 41 | 298 | 5.658537 | 0.536585 | 0.086207 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0.007491 | 0.104027 | 298 | 8 | 57 | 37.25 | 0.861423 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0.142857 | false | 0 | 0.428571 | 0 | 0.571429 | 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 | 0 | 0 | 0 | 2 |
fba413cbbac04e4578ce84a8676b8bf632b9cb46 | 431 | py | Python | configs/production.py | syz247179876/Flask-Sports | ed2d21c5a6172e7b6f3fc479bd5114fdb171896d | [
"Apache-2.0"
] | 2 | 2020-12-02T14:20:44.000Z | 2020-12-08T15:36:51.000Z | configs/production.py | syz247179876/Flask-Sports | ed2d21c5a6172e7b6f3fc479bd5114fdb171896d | [
"Apache-2.0"
] | 1 | 2020-12-05T13:44:14.000Z | 2020-12-05T13:44:14.000Z | configs/production.py | syz247179876/Flask-Sports | ed2d21c5a6172e7b6f3fc479bd5114fdb171896d | [
"Apache-2.0"
] | null | null | null | # -*- coding: utf-8 -*-
# @Time : 2020/12/1 下午11:24
# @Author : 司云中
# @File : production.py
# @Software: Pycharm
from configs.default import DefaultConfig
class ProductionConfig(DefaultConfig):
"""the config of production env"""
DEBUG = False
TESTING = False
MONGODB_DB = ''
MONGODB_HOST = ''
MONGODB_PORT = ''
MONGODB_USERNAME = ''
MONGODB_PASSWORD = ''
production_config = ProductionConfig()
| 20.52381 | 41 | 0.656613 | 46 | 431 | 6.021739 | 0.782609 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0.035503 | 0.215777 | 431 | 20 | 42 | 21.55 | 0.784024 | 0.308585 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | false | 0.1 | 0.1 | 0 | 0.9 | 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 | 0 | 0 | 1 | 0 | 0 | 2 |
fba528d6b9c993f8745f860d915d34b0353a4f4d | 426 | py | Python | glider/test/test_gliderRadio.py | ezeakeal/glider_drone | f0d5bb973d38245351a0fe1f4833827d94d0b0e4 | [
"Apache-2.0"
] | null | null | null | glider/test/test_gliderRadio.py | ezeakeal/glider_drone | f0d5bb973d38245351a0fe1f4833827d94d0b0e4 | [
"Apache-2.0"
] | null | null | null | glider/test/test_gliderRadio.py | ezeakeal/glider_drone | f0d5bb973d38245351a0fe1f4833827d94d0b0e4 | [
"Apache-2.0"
] | null | null | null | from unittest import TestCase
from glider.modules.glider_radio import GliderRadio
class TestGliderRadio(TestCase):
def setUp(self):
self.radio = GliderRadio(self.test_callback)
self.radio.start()
def tearDown(self):
self.radio.stop()
def test_callback(self, msgdict):
print("Received message: %s" % msgdict)
def test_send_data(self):
self.radio.send_data(["test"])
| 23.666667 | 52 | 0.678404 | 52 | 426 | 5.442308 | 0.480769 | 0.127208 | 0.137809 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0.213615 | 426 | 17 | 53 | 25.058824 | 0.844776 | 0 | 0 | 0 | 0 | 0 | 0.056338 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0.333333 | false | 0 | 0.166667 | 0 | 0.583333 | 0.083333 | 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 | 0 | 1 | 0 | 0 | 2 |
fba67a228cffbfee38985da067132482c7b8a08a | 1,052 | py | Python | apps/warframes/migrations/0001_initial.py | tufbel/wFocus | ee0f02053b8a5bc9c40dd862306fc5df1a063b9d | [
"Apache-2.0"
] | null | null | null | apps/warframes/migrations/0001_initial.py | tufbel/wFocus | ee0f02053b8a5bc9c40dd862306fc5df1a063b9d | [
"Apache-2.0"
] | 11 | 2020-06-06T01:51:51.000Z | 2022-02-10T14:31:21.000Z | apps/warframes/migrations/0001_initial.py | tufbel/wFocus | ee0f02053b8a5bc9c40dd862306fc5df1a063b9d | [
"Apache-2.0"
] | null | null | null | # Generated by Django 2.2.7 on 2019-12-15 12:15
from django.db import migrations, models
class Migration(migrations.Migration):
initial = True
dependencies = [
]
operations = [
migrations.CreateModel(
name='Warframe',
fields=[
('id', models.AutoField(primary_key=True, serialize=False)),
('name', models.CharField(max_length=100, unique=True)),
('health', models.IntegerField()),
('shield', models.IntegerField()),
('armor', models.IntegerField()),
('power', models.IntegerField()),
('sprint_speed', models.FloatField()),
('power_strength', models.FloatField(default=1)),
('power_duration', models.FloatField(default=1)),
('power_range', models.FloatField(default=1)),
('power_efficiency', models.FloatField(default=1)),
('img', models.URLField(max_length=255, null=True)),
],
),
]
| 32.875 | 76 | 0.543726 | 95 | 1,052 | 5.936842 | 0.557895 | 0.141844 | 0.163121 | 0.170213 | 0.154255 | 0 | 0 | 0 | 0 | 0 | 0 | 0.03453 | 0.311787 | 1,052 | 31 | 77 | 33.935484 | 0.744475 | 0.042776 | 0 | 0 | 1 | 0 | 0.105473 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | false | 0 | 0.041667 | 0 | 0.208333 | 0.041667 | 0 | 0 | 0 | null | 0 | 0 | 1 | 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 | 0 | 0 | 0 | 0 | 0 | 0 | 2 |
fbbc3f98679b551d2bd048c8773e0364748a4e51 | 2,333 | py | Python | test/test_format.py | GuyTuval/msgpack-python | 8fb709f2e0438862020d8810fa70a81fb5dac7d4 | [
"Apache-2.0"
] | 1,252 | 2015-01-05T18:18:10.000Z | 2022-03-27T16:40:44.000Z | test/test_format.py | GuyTuval/msgpack-python | 8fb709f2e0438862020d8810fa70a81fb5dac7d4 | [
"Apache-2.0"
] | 298 | 2015-01-06T12:21:09.000Z | 2022-03-11T23:57:58.000Z | test/test_format.py | GuyTuval/msgpack-python | 8fb709f2e0438862020d8810fa70a81fb5dac7d4 | [
"Apache-2.0"
] | 199 | 2015-01-09T04:33:00.000Z | 2022-03-30T15:04:37.000Z | #!/usr/bin/env python
# coding: utf-8
from msgpack import unpackb
def check(src, should, use_list=0, raw=True):
assert unpackb(src, use_list=use_list, raw=raw, strict_map_key=False) == should
def testSimpleValue():
check(b"\x93\xc0\xc2\xc3", (None, False, True))
def testFixnum():
check(b"\x92\x93\x00\x40\x7f\x93\xe0\xf0\xff", ((0, 64, 127), (-32, -16, -1)))
def testFixArray():
check(b"\x92\x90\x91\x91\xc0", ((), ((None,),)))
def testFixRaw():
check(b"\x94\xa0\xa1a\xa2bc\xa3def", (b"", b"a", b"bc", b"def"))
def testFixMap():
check(
b"\x82\xc2\x81\xc0\xc0\xc3\x81\xc0\x80", {False: {None: None}, True: {None: {}}}
)
def testUnsignedInt():
check(
b"\x99\xcc\x00\xcc\x80\xcc\xff\xcd\x00\x00\xcd\x80\x00"
b"\xcd\xff\xff\xce\x00\x00\x00\x00\xce\x80\x00\x00\x00"
b"\xce\xff\xff\xff\xff",
(0, 128, 255, 0, 32768, 65535, 0, 2147483648, 4294967295),
)
def testSignedInt():
check(
b"\x99\xd0\x00\xd0\x80\xd0\xff\xd1\x00\x00\xd1\x80\x00"
b"\xd1\xff\xff\xd2\x00\x00\x00\x00\xd2\x80\x00\x00\x00"
b"\xd2\xff\xff\xff\xff",
(0, -128, -1, 0, -32768, -1, 0, -2147483648, -1),
)
def testRaw():
check(
b"\x96\xda\x00\x00\xda\x00\x01a\xda\x00\x02ab\xdb\x00\x00"
b"\x00\x00\xdb\x00\x00\x00\x01a\xdb\x00\x00\x00\x02ab",
(b"", b"a", b"ab", b"", b"a", b"ab"),
)
check(
b"\x96\xda\x00\x00\xda\x00\x01a\xda\x00\x02ab\xdb\x00\x00"
b"\x00\x00\xdb\x00\x00\x00\x01a\xdb\x00\x00\x00\x02ab",
("", "a", "ab", "", "a", "ab"),
raw=False,
)
def testArray():
check(
b"\x96\xdc\x00\x00\xdc\x00\x01\xc0\xdc\x00\x02\xc2\xc3\xdd\x00"
b"\x00\x00\x00\xdd\x00\x00\x00\x01\xc0\xdd\x00\x00\x00\x02"
b"\xc2\xc3",
((), (None,), (False, True), (), (None,), (False, True)),
)
def testMap():
check(
b"\x96"
b"\xde\x00\x00"
b"\xde\x00\x01\xc0\xc2"
b"\xde\x00\x02\xc0\xc2\xc3\xc2"
b"\xdf\x00\x00\x00\x00"
b"\xdf\x00\x00\x00\x01\xc0\xc2"
b"\xdf\x00\x00\x00\x02\xc0\xc2\xc3\xc2",
(
{},
{None: False},
{True: False, None: False},
{},
{None: False},
{True: False, None: False},
),
)
| 25.358696 | 88 | 0.533648 | 376 | 2,333 | 3.297872 | 0.239362 | 0.198387 | 0.123387 | 0.03871 | 0.360484 | 0.26129 | 0.141935 | 0.141935 | 0.141935 | 0.141935 | 0 | 0.203495 | 0.239606 | 2,333 | 91 | 89 | 25.637363 | 0.49549 | 0.014574 | 0 | 0.257576 | 0 | 0.151515 | 0.38485 | 0.316064 | 0 | 0 | 0 | 0 | 0.015152 | 1 | 0.166667 | false | 0 | 0.015152 | 0 | 0.181818 | 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 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 2 |
fbc4fa09de1f509b411b286d8439548aa1647a45 | 544 | py | Python | config.py | Laikos38/rockopy | 3816ebb8466a27c65e76a387abc36c96df688ef7 | [
"CC0-1.0"
] | null | null | null | config.py | Laikos38/rockopy | 3816ebb8466a27c65e76a387abc36c96df688ef7 | [
"CC0-1.0"
] | null | null | null | config.py | Laikos38/rockopy | 3816ebb8466a27c65e76a387abc36c96df688ef7 | [
"CC0-1.0"
] | null | null | null | # =================================================
# SERVER CONFIGURATIONS
# =================================================
CLIENT_ID=''
CLIENT_SECRET=''
REDIRECT_URI='http://ROCKOPY/'
# =================================================
# SERVER CONFIGURATIONS
# =================================================
SERVER_IP = "127.0.0.1"
SERVER_PORT = 5043
# =================================================
# OTHER OPTIONS
# =================================================
# how many track search results show:
TRACKS_TO_SEARCH = 5
| 24.727273 | 51 | 0.318015 | 33 | 544 | 5.030303 | 0.787879 | 0.240964 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0.022044 | 0.082721 | 544 | 21 | 52 | 25.904762 | 0.310621 | 0.722426 | 0 | 0 | 0 | 0 | 0.172662 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | false | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | null | 1 | 0 | 0 | 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 | 0 | 0 | 2 |
fbd3b3b8ed744c1417f498327a5a9678f19a086e | 327 | py | Python | keycache/util.py | psytron/keycache | 0b69e21719dbe76908476c01e3e487aae2612fd2 | [
"Apache-2.0"
] | 2 | 2020-04-27T07:48:54.000Z | 2020-10-21T17:47:54.000Z | keycache/util.py | psytron/keycache | 0b69e21719dbe76908476c01e3e487aae2612fd2 | [
"Apache-2.0"
] | null | null | null | keycache/util.py | psytron/keycache | 0b69e21719dbe76908476c01e3e487aae2612fd2 | [
"Apache-2.0"
] | null | null | null | import platform as p
import uuid
import hashlib
def basic():
sb = []
sb.append(p.node())
sb.append( ''.join([ x for x in p.architecture() ]) )
sb.append(p.machine())
sb.append(p.processor())
sb.append(p.system())
sb.append(str(uuid.getnode())) # MAC address
text = '.'.join(sb)
return text | 21.8 | 57 | 0.599388 | 48 | 327 | 4.083333 | 0.520833 | 0.244898 | 0.183673 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0.220183 | 327 | 15 | 58 | 21.8 | 0.768627 | 0.033639 | 0 | 0 | 0 | 0 | 0.003175 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0.076923 | false | 0 | 0.230769 | 0 | 0.384615 | 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 | 0 | 0 | 0 | 2 |
837c932ac45c8e6207580a84130808a7f51d5177 | 685 | py | Python | django_sso_app/app/views.py | paiuolo/django-sso-app | 75b96c669dc0b176dc77e08f018a3e97d259f636 | [
"MIT"
] | 1 | 2021-11-16T15:16:08.000Z | 2021-11-16T15:16:08.000Z | django_sso_app/app/views.py | paiuolo/django-sso-app | 75b96c669dc0b176dc77e08f018a3e97d259f636 | [
"MIT"
] | null | null | null | django_sso_app/app/views.py | paiuolo/django-sso-app | 75b96c669dc0b176dc77e08f018a3e97d259f636 | [
"MIT"
] | null | null | null | from django.http import HttpResponseRedirect
from django.views import View
from ..core import app_settings
class AppLoginView(View):
def get(self, request, *args, **kwargs):
next = request.GET.get('next', '')
return HttpResponseRedirect(app_settings.REMOTE_LOGIN_URL + next)
class AppSignupView(View):
def get(self, request, *args, **kwargs):
next = request.GET.get('next', '')
return HttpResponseRedirect(app_settings.REMOTE_SIGNUP_URL + next)
class AppLogoutView(View):
def get(self, request, *args, **kwargs):
next = request.GET.get('next', '')
return HttpResponseRedirect(app_settings.REMOTE_LOGOUT_URL + next)
| 26.346154 | 74 | 0.694891 | 81 | 685 | 5.753086 | 0.333333 | 0.094421 | 0.064378 | 0.090129 | 0.611588 | 0.611588 | 0.611588 | 0.611588 | 0.611588 | 0.611588 | 0 | 0 | 0.185401 | 685 | 25 | 75 | 27.4 | 0.835125 | 0 | 0 | 0.4 | 0 | 0 | 0.017518 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0.2 | false | 0 | 0.2 | 0 | 0.8 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 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 | 1 | 0 | 0 | 2 |
8386475aa5d024fe1d36e6904efce3bbf70bc22b | 328 | py | Python | 2/week2/c.py | briannice/logiscool-python | 00cf772072f574d297ed487e8edc9bb0158b6c68 | [
"Apache-2.0"
] | null | null | null | 2/week2/c.py | briannice/logiscool-python | 00cf772072f574d297ed487e8edc9bb0158b6c68 | [
"Apache-2.0"
] | null | null | null | 2/week2/c.py | briannice/logiscool-python | 00cf772072f574d297ed487e8edc9bb0158b6c68 | [
"Apache-2.0"
] | null | null | null | def som(a, b):
"""Bereken de som van twee getallen. Als de som groter is dan nul return je de som.
Als de som kleiner is dan nul, dan return je nul.
Args:
a (int): het eerste getal
b (int): het tweede getal
"""
pass
assert som(1, 2) == 3
assert som(-1, -2) == -3
assert som(0, 0) == 0
| 20.5 | 87 | 0.570122 | 59 | 328 | 3.169492 | 0.491525 | 0.106952 | 0.085562 | 0.117647 | 0.176471 | 0.176471 | 0.176471 | 0 | 0 | 0 | 0 | 0.039823 | 0.310976 | 328 | 15 | 88 | 21.866667 | 0.787611 | 0.609756 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0.6 | 1 | 0.2 | false | 0.2 | 0 | 0 | 0.2 | 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 | 1 | 0 | 0 | 0 | 1 | 0 | 0 | 0 | 0 | 0 | 2 |
838edfd8c862125c349c121325bcacc9bf203166 | 1,177 | py | Python | tools/harness/tests/freemem.py | lambdaxymox/barrelfish | 06a9f54721a8d96874a8939d8973178a562c342f | [
"MIT"
] | 111 | 2015-02-03T02:57:27.000Z | 2022-03-01T23:57:09.000Z | tools/harness/tests/freemem.py | lambdaxymox/barrelfish | 06a9f54721a8d96874a8939d8973178a562c342f | [
"MIT"
] | 12 | 2016-03-22T14:44:32.000Z | 2020-03-18T13:30:29.000Z | tools/harness/tests/freemem.py | lambdaxymox/barrelfish | 06a9f54721a8d96874a8939d8973178a562c342f | [
"MIT"
] | 55 | 2015-02-03T05:28:12.000Z | 2022-03-31T05:00:03.000Z | ##########################################################################
# Copyright (c) 2009, ETH Zurich.
# All rights reserved.
#
# This file is distributed under the terms in the attached LICENSE file.
# If you do not find this file, copies can be found by writing to:
# ETH Zurich D-INFK, Universitaetstrasse 6, CH-8092 Zurich. Attn: Systems Group.
##########################################################################
import re
import tests
from common import TestCommon
from results import PassFailResult
@tests.add_test
class MemTest(TestCommon):
'''prints out free and total memory after system boot up'''
name = "freemem"
def get_modules(self, build, machine):
modules = super(MemTest, self).get_modules(build, machine)
modules.add_module("freemem")
return modules
def get_finish_string(self):
return "freemem done!"
def process_data(self, testdir, rawiter):
# the test passed iff the last line is the finish string
lastline = ''
for line in rawiter:
lastline = line
passed = lastline.startswith(self.get_finish_string())
return PassFailResult(passed)
| 33.628571 | 80 | 0.605777 | 138 | 1,177 | 5.101449 | 0.623188 | 0.051136 | 0.053977 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0.009574 | 0.201359 | 1,177 | 34 | 81 | 34.617647 | 0.739362 | 0.320306 | 0 | 0 | 0 | 0 | 0.042188 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0.157895 | false | 0.157895 | 0.210526 | 0.052632 | 0.631579 | 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 | 0 | 0 | 1 | 0 | 0 | 2 |
83929360847de74ce432577b4612ddd776a07618 | 3,472 | py | Python | Protheus_WebApp/Modules/SIGAACD/ACDA035TESTCASE.py | 98llm/tir-script-samples | 0bff8393b79356aa562e9e6512c11ee6e039b177 | [
"MIT"
] | 17 | 2018-09-24T17:27:08.000Z | 2021-09-16T19:09:46.000Z | Protheus_WebApp/Modules/SIGAACD/ACDA035TESTCASE.py | 98llm/tir-script-samples | 0bff8393b79356aa562e9e6512c11ee6e039b177 | [
"MIT"
] | 4 | 2018-09-24T17:30:32.000Z | 2022-01-03T11:39:30.000Z | Protheus_WebApp/Modules/SIGAACD/ACDA035TESTCASE.py | 98llm/tir-script-samples | 0bff8393b79356aa562e9e6512c11ee6e039b177 | [
"MIT"
] | 18 | 2019-06-07T17:41:34.000Z | 2022-01-31T18:17:31.000Z | #//-------------------------------------------------------------------
#/*/{Protheus.doc} ACDA035 -
#
#@author PEDRO ANTONIO MISSAGLIA
#@since 23/09/2019
#@version P12
#
# CT001 - Inclusão de Lançamento de Inventário
# CT002 - Visão de um lançamento de inventário
# CT003 - Visualização das legendas
# CT004 - Alteração de Lançamento de Inventário
# CT005 - Exclusão de Lançamento de Inventário
# CT007 - Alteração de Lançamento de Inventário sem finalizar contagem
#
#/*/
#//-------------------------------------------------------------------
from tir import Webapp
import unittest
import time
class ACDA035(unittest.TestCase):
@classmethod
def setUpClass(inst):
inst.oHelper = Webapp()
inst.oHelper.Setup('SIGAEST','11/07/2019','T1','D MG 01')
inst.oHelper.Program('ACDA035')
inst.oHelper.AddParameter("MV_CBPE012", "", ".T.", ".T.", ".T.")
inst.oHelper.SetParameters()
#CT001 - Geração de uma ordem de separação por ordem de produção
#@author: Pedro Antonio Missaglia
#@date: 18/09/2019
def test_ACDA035_CT001(self):
self.oHelper.SetButton("Incluir")
self.oHelper.SetButton('Ok')
self.oHelper.SetValue('Codigo Inv.', '000000005')
self.oHelper.SetValue('Usuario', '000010')
self.oHelper.SetValue('Quantidade', '1', grid=True)
self.oHelper.SetValue('Endereco', 'ENDSE01', grid=True)
self.oHelper.LoadGrid()
self.oHelper.SetButton('Salvar')
self.oHelper.SetButton('Não')
self.oHelper.SetButton('Cancelar')
#Definição do operação
self.oHelper.AssertTrue()
def test_ACDA035_CT002(self):
self.oHelper.SearchBrowse("D MG 01 000000003")
self.oHelper.SetButton("Visão")
self.oHelper.SetButton('Confirmar')
self.oHelper.AssertTrue()
def test_ACDA035_CT003(self):
self.oHelper.SetButton("Outras Ações", "Legenda")
self.oHelper.SetButton('Ok')
self.oHelper.SetButton('Fechar')
self.oHelper.AssertTrue()
def test_ACDA035_CT004(self):
self.oHelper.SearchBrowse("D MG 01 000000030")
self.oHelper.SetButton("Alterar")
self.oHelper.SetValue('Quantidade', '3', grid=True)
self.oHelper.LoadGrid()
self.oHelper.SetButton('Salvar')
self.oHelper.SetButton('Não')
self.oHelper.AssertTrue()
def test_ACDA035_CT005(self):
self.oHelper.SearchBrowse("D MG 01 000000005")
self.oHelper.SetButton("Outras Ações", "Excluir")
self.oHelper.SetButton('Confirmar')
self.oHelper.SetButton('Sim')
self.oHelper.AssertTrue()
def test_ACDA035_CT006(self):
self.oHelper.AddParameter("MV_WMSNEW ", "", ".F.", ".T.", ".T.")
self.oHelper.SetParameters()
self.oHelper.SearchBrowse("D MG 01 000000029")
self.oHelper.SetButton("Alterar")
self.oHelper.SetValue('Qtd.Original', '3', grid=True)
self.oHelper.LoadGrid()
self.oHelper.SetButton('Salvar')
self.oHelper.SetButton('Sim')
self.oHelper.AssertTrue()
def test_ACDA035_CT007(self):
self.oHelper.SearchBrowse("D MG 01 000000032")
self.oHelper.SetButton("Alterar")
self.oHelper.SetButton("Salvar")
self.oHelper.WaitShow("Deseja finalizar a contagem?")
self.oHelper.SetButton("Não")
self.oHelper.WaitHide("Deseja finalizar a contagem?")
time.sleep(3)
self.oHelper.SetButton("Visão")
self.oHelper.CheckResult("Produto","ACDACDA03500000000000000000001",grid=True, line=1)
self.oHelper.LoadGrid()
self.oHelper.SetButton('Confirmar')
self.oHelper.AssertTrue()
@classmethod
def tearDownClass(inst):
inst.oHelper.TearDown()
if __name__ == '__main__':
unittest.main() | 27.125 | 88 | 0.692396 | 410 | 3,472 | 5.804878 | 0.307317 | 0.235714 | 0.201681 | 0.060504 | 0.505042 | 0.451261 | 0.279412 | 0.144958 | 0.144958 | 0.144958 | 0 | 0.067194 | 0.125576 | 3,472 | 128 | 89 | 27.125 | 0.716733 | 0.191244 | 0 | 0.4 | 0 | 0 | 0.179276 | 0.010757 | 0 | 0 | 0 | 0 | 0.093333 | 1 | 0.12 | false | 0 | 0.04 | 0 | 0.173333 | 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 | 0 | 0 | 0 | 2 |
8392df442da4b2f8acf4cb05c261720a7e2145a4 | 967 | py | Python | tests/unit/test_cust_driver.py | abreu4/jina | d1d045e9e0933dffb3bd668cb9cfebab6cd52202 | [
"Apache-2.0"
] | 2 | 2021-01-22T07:34:35.000Z | 2021-01-23T04:36:41.000Z | tests/unit/test_cust_driver.py | abreu4/jina | d1d045e9e0933dffb3bd668cb9cfebab6cd52202 | [
"Apache-2.0"
] | 1 | 2021-02-27T05:56:45.000Z | 2021-02-27T05:57:03.000Z | tests/unit/test_cust_driver.py | abreu4/jina | d1d045e9e0933dffb3bd668cb9cfebab6cd52202 | [
"Apache-2.0"
] | null | null | null | from pathlib import Path
from jina import Flow, Document
from jina.executors import BaseExecutor
from jina.parsers import set_pea_parser
from jina.peapods.peas import BasePea
cur_dir = Path(__file__).parent
def test_load_executor_with_custom_driver():
with BaseExecutor.load_config(str(cur_dir / 'yaml/test-executor-with-custom-driver.yml')) as be:
assert be._drivers['IndexRequest'][0].__class__.__name__ == 'DummyEncodeDriver'
def test_load_pod_with_custom_driver():
args = set_pea_parser().parse_args(['--uses', str(cur_dir / 'yaml/test-executor-with-custom-driver.yml')])
with BasePea(args):
# load success with no error
pass
def validate(req):
assert len(req.docs) == 1
assert req.docs[0].text == 'hello from DummyEncodeDriver'
def test_load_flow_with_custom_driver():
with Flow().add(uses=str(cur_dir / 'yaml/test-executor-with-custom-driver.yml')) as f:
f.index([Document()], on_done=validate)
| 31.193548 | 110 | 0.733195 | 141 | 967 | 4.751773 | 0.425532 | 0.089552 | 0.143284 | 0.143284 | 0.214925 | 0.214925 | 0.214925 | 0.214925 | 0.214925 | 0.214925 | 0 | 0.003632 | 0.145812 | 967 | 30 | 111 | 32.233333 | 0.807506 | 0.026887 | 0 | 0 | 0 | 0 | 0.198083 | 0.13099 | 0 | 0 | 0 | 0 | 0.157895 | 1 | 0.210526 | false | 0.052632 | 0.263158 | 0 | 0.473684 | 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 | 0 | 0 | 0 | 2 |
8393065c4b6aeffae6a10f048cd67e3a8fa65388 | 373 | py | Python | 02-19-Cuma/forLoop.py | cihatdev/misha-staj | d0ee95d5e77a7d7a1f16611d49c87be429a25b31 | [
"MIT"
] | 9 | 2021-03-16T20:21:54.000Z | 2022-01-08T09:15:10.000Z | 02-19-Cuma/forLoop.py | cihatdev/misha-staj | d0ee95d5e77a7d7a1f16611d49c87be429a25b31 | [
"MIT"
] | 1 | 2021-02-28T21:27:17.000Z | 2021-02-28T21:27:17.000Z | 02-19-Cuma/forLoop.py | cihatdev/misha-staj | d0ee95d5e77a7d7a1f16611d49c87be429a25b31 | [
"MIT"
] | 1 | 2021-05-24T11:34:48.000Z | 2021-05-24T11:34:48.000Z | # for loops
# for letter in "Cihat Salik":
# print(letter)
friends = ["Hasan", "Mahmut", "Ali", "Veli"]
for friend in friends:
print(friend)
for index in range(3, 10):
print(index)
for index in range(len(friends)):
print(friends[index])
for index in range(5):
if index == 0:
print("First Iteration")
else:
print("Not first")
| 15.541667 | 44 | 0.600536 | 52 | 373 | 4.307692 | 0.480769 | 0.107143 | 0.133929 | 0.200893 | 0.178571 | 0 | 0 | 0 | 0 | 0 | 0 | 0.017921 | 0.252011 | 373 | 23 | 45 | 16.217391 | 0.784946 | 0.150134 | 0 | 0 | 0 | 0 | 0.134185 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | false | 0 | 0 | 0 | 0 | 0.416667 | 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 | 0 | 0 | 0 | 1 | 0 | 2 |
83a72aa00c8eb33d1a3ee2b6393e98bf6532dbf4 | 6,467 | py | Python | siqbal/hooks.py | smehata/siqbal | 8b6a21fb63c050237593c49757065198c0e2c54a | [
"MIT"
] | null | null | null | siqbal/hooks.py | smehata/siqbal | 8b6a21fb63c050237593c49757065198c0e2c54a | [
"MIT"
] | null | null | null | siqbal/hooks.py | smehata/siqbal | 8b6a21fb63c050237593c49757065198c0e2c54a | [
"MIT"
] | null | null | null | # -*- coding: utf-8 -*-
from __future__ import unicode_literals
from . import __version__ as app_version
app_name = "SIqbal"
app_title = "SIqbal"
app_publisher = "RC"
app_description = "Customizations for SIqbal"
app_icon = "octicon octicon-file-directory"
app_color = "green"
app_email = "developer@rccorner.com"
app_license = "MIT"
# Includes in <head>
# ------------------
# include js, css files in header of desk.html
app_include_css = "/assets/siqbal/css/siqbal.css"
# app_include_js = "/assets/siqbal/js/siqbal.js"
# include js, css files in header of web template
# web_include_css = "/assets/siqbal/css/siqbal.css"
# web_include_js = "/assets/siqbal/js/siqbal.js"
# include js in page
# page_js = {"page" : "public/js/file.js"}
# include js in doctype views
# doctype_js = {"doctype" : "public/js/doctype.js"}
# doctype_list_js = {"doctype" : "public/js/doctype_list.js"}
# doctype_tree_js = {"doctype" : "public/js/doctype_tree.js"}
# doctype_calendar_js = {"doctype" : "public/js/doctype_calendar.js"}
doctype_js = {
"Address": "public/js/address.js",
"Architect and Contractor": "public/js/architect_and_contractor.js",
"Authorization Rule": "public/js/authorization_rule.js",
"Customer": "public/js/customer.js",
"Delivery Note" : "public/js/delivery_note.js",
"Item": "public/js/item.js",
"Journal Entry": "public/js/journal_entry.js",
"Landed Cost Voucher": "public/js/landed_cost_voucher.js",
"Material Request" : "public/js/material_request.js",
"Opportunity": "public/js/opportunity.js",
"Payment Entry": "public/js/payment_entry.js",
"Property Detail": "public/js/property_detail.js",
"Purchase Invoice" : "public/js/purchase_invoice.js",
"Purchase Order" : "public/js/purchase_order.js",
"Purchase Receipt" : "public/js/purchase_receipt.js",
"Quotation" : "public/js/quotation.js",
"Request for Quotation": "public/js/request_for_quotation.js",
"Salary Slip" : "public/js/salary_slip.js",
"Sales Invoice" : "public/js/sales_invoice.js",
"Sales Order" : "public/js/sales_order.js",
"Stock Entry" : "public/js/stock_entry.js",
"Stock Reconciliation" : "public/js/stock_reconciliation.js",
"Supplier Quotation": "public/js/supplier_quotation.js"
}
# Home Pages
# ----------
# application home page (will override Website Settings)
# home_page = "login"
# website user home page (by Role)
# role_home_page = {
# "Role": "home_page"
# }
# Website user home page (by function)
# get_website_user_home_page = "siqbal.utils.get_home_page"
# Generators
# ----------
# automatically create page for each record of this doctype
# website_generators = ["Web Page"]
# Installation
# ------------
# before_install = "siqbal.install.before_install"
# after_install = "siqbal.install.after_install"
# Desk Notifications
# ------------------
# See frappe.core.notifications.get_notification_config
# notification_config = "siqbal.notifications.get_notification_config"
# Permissions
# -----------
# Permissions evaluated in scripted ways
# permission_query_conditions = {
# "Event": "frappe.desk.doctype.event.event.get_permission_query_conditions",
# }
#
# has_permission = {
# "Event": "frappe.desk.doctype.event.event.has_permission",
# }
# Document Events
# ---------------
# Hook on document methods and events
# doc_events = {
# "*": {
# "on_update": "method",
# "on_cancel": "method",
# "on_trash": "method"
# }
# }
doc_events = {
"Sales Order": {
"validate": [
"siqbal.hook_events.sales_order.set_average_valuation_rate",
# "siqbal.utils.validate_date"
],
"before_submit": "siqbal.hook_events.sales_order.unset_needs_approval",
"before_update_after_submit": "siqbal.hook_events.sales_order.validate_items_rate_and_update_boxes"
},
"Sales Invoice": {
"validate": [
"siqbal.hook_events.sales_invoice.validate_discount_while_return",
"siqbal.hook_events.sales_invoice.validate_taxes_and_charges_from_so",
"siqbal.utils.add_location",
"siqbal.hook_events.sales_invoice.validate_sales_invoice"
# "siqbal.utils.validate_date"
],
"before_insert": "siqbal.hook_events.sales_invoice.set_supplier_details",
"on_submit": [
"siqbal.hook_events.sales_invoice.update_reserved_qty",
"siqbal.hook_events.sales_invoice.create_purchase_invoices_against_sales_taxes",
# "siqbal.utils.change_pi_status"
#"siqbal.hook_events.sales_invoice.validate_user_warehouse"
],
"on_cancel": "siqbal.hook_events.sales_invoice.update_reserved_qty"
},
"Payment Entry": {
"validate": [
"siqbal.hook_events.payment_entry.validate_sales_order",
# "siqbal.hook_events.payment_entry.validate_salaryslip_amount",
#"siqbal.utils.validate_date"
],
# "on_submit": "siqbal.hook_events.payment_entry.update_salaryslip_status",
# "on_cancel": "siqbal.hook_events.payment_entry.update_salaryslip_status"
},
"Stock Entry": {
#"validate": "siqbal.utils.validate_date",
#"on_submit": "siqbal.hook_events.stock_entry.validate_user_warehouse"
},
"Opportunity": {
"validate": "siqbal.utils.send_followup_sms"
},
"Purchase Invoice": {
"validate": "siqbal.utils.add_location"
},
"Purchase Order": {
#"validate": "siqbal.utils.validate_date"
},
"Purchase Receipt": {
#"validate": "siqbal.utils.validate_date"
},
"Stock Reconciliation": {
#"validate": "siqbal.utils.validate_date"
},
# "Quotation": {
#"validate": "siqbal.utils.validate_date"
# },
# "Journal Entry": {
# "before_save": "siqbal.hook_events.journal_entry.set_name"
# }
}
jenv = {
"methods" : [
"get_qrcode_image:siqbal.utils.get_qrcode_image"
]
}
# Scheduled Tasks
# ---------------
# scheduler_events = {
# "all": [
# "siqbal.tasks.all"
# ],
# "daily": [
# "siqbal.tasks.daily"
# ],
# "hourly": [
# "siqbal.tasks.hourly"
# ],
# "weekly": [
# "siqbal.tasks.weekly"
# ]
# "monthly": [
# "siqbal.tasks.monthly"
# ]
# }
# Testing
# -------
# before_tests = "siqbal.install.before_tests"
# Overriding Methods
# ------------------------------
#
# override_whitelisted_methods = {
# "frappe.desk.doctype.event.event.get_events": "siqbal.event.get_events"
# }
#
# each overriding function accepts a `data` argument;
# generated from the base implementation of the doctype dashboard,
# along with any modifications made in other Frappe apps
# override_doctype_dashboards = {
# "Task": "siqbal.task.get_dashboard_data"
# }
override_doctype_class = {
'Sales Invoice': 'siqbal.hook_events.overide_sales_invoice.OverrideSalesInvoice'
}
| 28.117391 | 101 | 0.706355 | 789 | 6,467 | 5.518378 | 0.259823 | 0.051447 | 0.066146 | 0.053055 | 0.311438 | 0.192467 | 0.10588 | 0.079927 | 0.039963 | 0 | 0 | 0.000177 | 0.12587 | 6,467 | 229 | 102 | 28.240175 | 0.770034 | 0.4925 | 0 | 0.081395 | 0 | 0 | 0.680972 | 0.478384 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | false | 0 | 0.023256 | 0 | 0.023256 | 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 | 1 | 1 | null | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 2 |
83aba0fd5dc8afef0605fcfd0ba5992a35684f2e | 12,989 | py | Python | Speedo/plugins/animoji.py | aviskumar/speedo | 758e8ac1fdeeb0b72c3a57742032ca5c79f0b2fa | [
"BSD-3-Clause"
] | null | null | null | Speedo/plugins/animoji.py | aviskumar/speedo | 758e8ac1fdeeb0b72c3a57742032ca5c79f0b2fa | [
"BSD-3-Clause"
] | null | null | null | Speedo/plugins/animoji.py | aviskumar/speedo | 758e8ac1fdeeb0b72c3a57742032ca5c79f0b2fa | [
"BSD-3-Clause"
] | 3 | 2021-10-12T08:17:01.000Z | 2021-12-21T01:17:54.000Z | import asyncio
from collections import deque
from . import *
@speedo.on(Speedo_cmd(pattern="think$", outgoing=True))
@speedo.on(sudo_cmd(pattern="think$", allow_sudo=True))
async def _(event):
if event.fwd_from:
return
event = await eor(event, "think")
deq = deque(list("🤔🧐🤔🧐🤔🧐"))
for _ in range(48):
await asyncio.sleep(0.1)
await event.edit("".join(deq))
deq.rotate(1)
@speedo.on(Speedo_cmd(pattern="ccry$", outgoing=True))
@speedo.on(sudo_cmd(pattern="ccry$", allow_sudo=True))
async def cry(e):
if e.fwd_from:
return
if not e.text[0].isalpha() and e.text[0] not in ("/", "#", "@", "!"):
await e.edit("(;´༎ຶД༎ຶ)")
@speedo.on(Speedo_cmd(pattern="fap$", outgoing=True))
@speedo.on(sudo_cmd(pattern="fap$", allow_sudo=True))
async def _(event):
if event.fwd_from:
return
event = await eor(event, "fapping(°_°)")
deq = deque(list("🍆✊🏻💦"))
for _ in range(32):
await asyncio.sleep(0.1)
await event.edit("".join(deq))
deq.rotate(1)
@speedo.on(Speedo_cmd(pattern=r"lmao$"))
@speedo.on(sudo_cmd(pattern=r"lmao$", allow_sudo=True))
async def _(event):
if event.fwd_from:
return
event = await eor(event, "lmao")
deq = deque(list("😂🤣😂🤣😂🤣"))
for _ in range(48):
await asyncio.sleep(0.1)
await event.edit("".join(deq))
deq.rotate(1)
@speedo.on(Speedo_cmd(pattern=r"nothappy$"))
@speedo.on(sudo_cmd(pattern="nothappy$", allow_sudo=True))
async def _(event):
if event.fwd_from:
return
event = await eor(event, "nathappy")
deq = deque(list("😁☹️😁☹️😁☹️😁"))
for _ in range(48):
await asyncio.sleep(0.4)
await event.edit("".join(deq))
deq.rotate(1)
@speedo.on(Speedo_cmd(outgoing=True, pattern="clock$"))
@speedo.on(sudo_cmd(pattern="clock$", allow_sudo=True))
async def _(event):
if event.fwd_from:
return
event = await eor(event, "clock")
deq = deque(list("🕙🕘🕗🕖🕕🕔🕓🕒🕑🕐🕛"))
for _ in range(48):
await asyncio.sleep(0.1)
await event.edit("".join(deq))
deq.rotate(1)
@speedo.on(Speedo_cmd(pattern=r"muah$"))
@speedo.on(sudo_cmd(pattern="muah$", allow_sudo=True))
async def _(event):
if event.fwd_from:
return
event = await eor(event, "muah")
deq = deque(list("😗😙😚😚😘"))
for _ in range(48):
await asyncio.sleep(0.1)
await event.edit("".join(deq))
deq.rotate(1)
@speedo.on(Speedo_cmd(pattern="heart$"))
@speedo.on(sudo_cmd(pattern="heart$", allow_sudo=True))
async def _(event):
if event.fwd_from:
return
event = await eor(event, "heart")
deq = deque(list("❤️🧡💛💚💙💜🖤"))
for _ in range(48):
await asyncio.sleep(0.1)
await event.edit("".join(deq))
deq.rotate(1)
@speedo.on(Speedo_cmd(pattern="gym$", outgoing=True))
@speedo.on(sudo_cmd(pattern="gym$", allow_sudo=True))
async def _(event):
if event.fwd_from:
return
event = await eor(event, "gym")
deq = deque(list("🏃🏋🤸🏃🏋🤸🏃🏋🤸"))
for _ in range(48):
await asyncio.sleep(0.1)
await event.edit("".join(deq))
deq.rotate(1)
@speedo.on(Speedo_cmd(pattern=f"earth$", outgoing=True))
@speedo.on(sudo_cmd(pattern="earth$", allow_sudo=True))
async def _(event):
if event.fwd_from:
return
event = await eor(event, "earth")
deq = deque(list("🌏🌍🌎🌎🌍🌏🌍🌎"))
for _ in range(48):
await asyncio.sleep(0.1)
await event.edit("".join(deq))
deq.rotate(1)
@speedo.on(Speedo_cmd(outgoing=True, pattern="moon$"))
@speedo.on(sudo_cmd(pattern="moon$", allow_sudo=True))
async def _(event):
if event.fwd_from:
return
event = await eor(event, "moon")
deq = deque(list("🌗🌘🌑🌒🌓🌔🌕🌖"))
for _ in range(48):
await asyncio.sleep(0.1)
await event.edit("".join(deq))
deq.rotate(1)
@speedo.on(Speedo_cmd(pattern=f"lovestory$", outgoing=True))
@speedo.on(sudo_cmd(pattern=f"lovestory$", allow_sudo=True))
async def _(event):
if event.fwd_from:
return
animation_interval = 3
animation_ttl = range(0, 103)
await eor(event, "Let me tel you")
animation_chars = [
"1 ❤️ love story",
" 😐 😕 \n/👕\ <👗\ \n 👖 /|",
" 😉 😳 \n/👕\ /👗\ \n 👖 /|",
" 😚 😒 \n/👕\ <👗> \n 👖 /|",
" 😍 ☺️ \n/👕\ /👗\ \n 👖 /|",
" 😍 😍 \n/👕\ /👗\ \n 👖 /|",
" 😘 😊 \n /👕\/👗\ \n 👖 /|",
" 😳 😁 \n /|\ /👙\ \n / / |",
"😈 /😰\ \n<|\ 👙 \n /🍆 / |",
"😅 \n/(),✊😮 \n /\ _/\\/|",
"😎 \n/\\_,__😫 \n // // \\",
"😖 \n/\\_,💦_😋 \n // // \\",
" 😭 ☺️ \n /|\ /(👶)\ \n /!\ / \ ",
"Abee aur kitna dekhoge be besharmi ki bhi hadd hoti hai..,The End 😂...",
]
for i in animation_ttl:
await asyncio.sleep(animation_interval)
await event.edit(animation_chars[i % 103])
@speedo.on(Speedo_cmd(pattern=f"smoon$", outgoing=True))
@speedo.on(sudo_cmd(pattern="smoon$", allow_sudo=True))
async def _(event):
if event.fwd_from:
return
event = await eor(event, "smoon")
animation_interval = 0.1
animation_ttl = range(101)
await event.edit("smoon..")
animation_chars = [
"🌗🌗🌗🌗🌗\n🌓🌓🌓🌓🌓\n🌗🌗🌗🌗🌗\n🌓🌓🌓🌓🌓\n🌗🌗🌗🌗🌗",
"🌘🌘🌘🌘🌘\n🌔🌔🌔🌔🌔\n🌘🌘🌘🌘🌘\n🌔🌔🌔🌔🌔\n🌘🌘🌘🌘🌘",
"🌑🌑🌑🌑🌑\n🌕🌕🌕🌕🌕\n🌑🌑🌑🌑🌑\n🌕🌕🌕🌕🌕\n🌑🌑🌑🌑🌑",
"🌒🌒🌒🌒🌒\n🌖🌖🌖🌖🌖\n🌒🌒🌒🌒🌒\n🌖🌖🌖🌖🌖\n🌒🌒🌒🌒🌒",
"🌓🌓🌓🌓🌓\n🌗🌗🌗🌗🌗\n🌓🌓🌓🌓🌓\n🌗🌗🌗🌗🌗\n🌓🌓🌓🌓🌓",
"🌔🌔🌔🌔🌔\n🌘🌘🌘🌘🌘\n🌔🌔🌔🌔🌔\n🌘🌘🌘🌘🌘\n🌔🌔🌔🌔🌔",
"🌕🌕🌕🌕🌕\n🌑🌑🌑🌑🌑\n🌕🌕🌕🌕🌕\n🌑🌑🌑🌑🌑\n🌕🌕🌕🌕🌕",
"🌖🌖🌖🌖🌖\n🌒🌒🌒🌒🌒\n🌖🌖🌖🌖🌖\n🌒🌒🌒🌒🌒\n🌖🌖🌖🌖🌖",
]
for i in animation_ttl:
await asyncio.sleep(animation_interval)
await event.edit(animation_chars[i % 8])
@speedo.on(Speedo_cmd(pattern=f"tmoon$", outgoing=True))
@speedo.on(sudo_cmd(pattern="tmoon$", allow_sudo=True))
async def _(event):
if event.fwd_from:
return
event = await eor(event, "tmoon")
animation_interval = 0.1
animation_ttl = range(117)
await event.edit("tmoon")
animation_chars = [
"🌗",
"🌘",
"🌑",
"🌒",
"🌓",
"🌔",
"🌕",
"🌖",
"🌗",
"🌘",
"🌑",
"🌒",
"🌓",
"🌔",
"🌕",
"🌖",
"🌗",
"🌘",
"🌑",
"🌒",
"🌓",
"🌔",
"🌕",
"🌖",
"🌗",
"🌘",
"🌑",
"🌒",
"🌓",
"🌔",
"🌕",
"🌖",
]
for i in animation_ttl:
await asyncio.sleep(animation_interval)
await event.edit(animation_chars[i % 32])
@speedo.on(Speedo_cmd(pattern=f"hart$", outgoing=True))
@speedo.on(sudo_cmd(pattern=f"hart$", allow_sudo=True))
async def _(event):
if event.fwd_from:
return
animation_interval = 0.5
animation_ttl = range(20)
event = await eor(event, "❤️")
animation_chars = ["🖤", "❤️", "🖤", "❤️", ""]
for i in animation_ttl:
await asyncio.sleep(animation_interval)
await event.edit(animation_chars[i % 4])
@speedo.on(Speedo_cmd(pattern=f"anim$", outgoing=True))
@speedo.on(sudo_cmd(pattern=f"anim$", allow_sudo=True))
async def _(event):
if event.fwd_from:
return
animation_interval = 1
animation_ttl = range(20)
event = await eor(event, "😢")
animation_chars = [
"😁",
"😧",
"😡",
"😢",
"😁",
"😧",
"😡",
"😢",
]
for i in animation_ttl:
await asyncio.sleep(animation_interval)
await event.edit(animation_chars[i % 10])
@speedo.on(Speedo_cmd(pattern=f"fuck$", outgoing=True))
@speedo.on(sudo_cmd(pattern=f"fuck$", allow_sudo=True))
async def _(event):
if event.fwd_from:
return
animation_interval = 1
animation_ttl = range(0, 101)
await eor(event, "fuk")
animation_chars = ["👉 ✊️", "👉 ✊️", "👉 ✊️", "👉✊️💦"]
for i in animation_ttl:
await asyncio.sleep(animation_interval)
await event.edit(animation_chars[i % 4])
@speedo.on(Speedo_cmd(pattern=f"sux$", outgoing=True))
@speedo.on(sudo_cmd(pattern=f"sux$", allow_sudo=True))
async def _(event):
if event.fwd_from:
return
animation_interval = 1
animation_ttl = range(0, 101)
await eor(event, "sux")
animation_chars = ["🤵 👰", "🤵 👰", "🤵 👰", "🤵👼👰"]
for i in animation_ttl:
await asyncio.sleep(animation_interval)
await event.edit(animation_chars[i % 4])
@speedo.on(Speedo_cmd(pattern=f"kiss$", outgoing=True))
@speedo.on(sudo_cmd(pattern=f"kiss$", allow_sudo=True))
async def _(event):
if event.fwd_from:
return
animation_interval = 1
animation_ttl = range(0, 101)
await eor(event, "kiss")
animation_chars = ["🤵 👰", "🤵 👰", "🤵 👰", "🤵💋👰"]
for i in animation_ttl:
await asyncio.sleep(animation_interval)
await event.edit(animation_chars[i % 4])
@speedo.on(Speedo_cmd(pattern=f"fnl$", outgoing=True))
@speedo.on(sudo_cmd(pattern=f"fnl$", allow_sudo=True))
async def _(event):
if event.fwd_from:
return
animation_interval = 2
animation_ttl = range(6)
event = await eor(event, "Hey There....")
animation_chars = ["😁🏿", "😁🏾", "😁🏽", "😁🏼", "😁"]
for i in animation_ttl:
await asyncio.sleep(animation_interval)
await event.edit(animation_chars[i % 6])
@speedo.on(Speedo_cmd(pattern=f"monkey$", outgoing=True))
@speedo.on(sudo_cmd(pattern=f"monkey$", allow_sudo=True))
async def _(event):
if event.fwd_from:
return
animation_interval = 2
animation_ttl = range(12)
event = await eor(event, "Hey There....")
animation_chars = ["🐵", "🙉", "🙈", "🙊", "🖕🐵🖕"]
for i in animation_ttl:
await asyncio.sleep(animation_interval)
await event.edit(animation_chars[i % 6])
@speedo.on(Speedo_cmd(pattern=f"hand$", outgoing=True))
@speedo.on(sudo_cmd(pattern=f"hand$", allow_sudo=True))
async def _(event):
if event.fwd_from:
return
animation_interval = 1
animation_ttl = range(13)
event = await eor(event, "🖐️")
animation_chars = [
"👈",
"👉",
"☝️",
"👆",
"🖕",
"👇",
"✌️",
"🤞",
"🖖",
"🤘",
"🤙",
"🖐️",
"👌",
]
for i in animation_ttl:
await asyncio.sleep(animation_interval)
await event.edit(animation_chars[i % 13])
@speedo.on(Speedo_cmd(pattern=f"gsg$", outgoing=True))
@speedo.on(sudo_cmd(pattern=f"gsg$", allow_sudo=True))
async def _(event):
if event.fwd_from:
return
animation_interval = 1
animation_ttl = range(12)
event = await eor(event, "ContDown....")
animation_chars = [
"🔟",
"9️⃣",
"8️⃣",
"7️⃣",
"6️⃣",
"5️⃣",
"4️⃣",
"3️⃣",
"2️⃣",
"1️⃣",
"0️⃣",
"🆘",
]
for i in animation_ttl:
await asyncio.sleep(animation_interval)
await event.edit(animation_chars[i % 12])
@speedo.on(Speedo_cmd(pattern=r"theart$", outgoing=True))
@speedo.on(sudo_cmd(pattern=r"theart$", allow_sudo=True))
async def _(event):
if event.fwd_from:
return
animation_interval = 0.3
animation_ttl = range(54)
event = await eor(event, "🖤")
animation_chars = [
"❤️",
"🧡",
"💛",
"💚",
"💙",
"💜",
"🖤",
"💘",
"💝",
"❤️",
"🧡",
"💛",
"💚",
"💙",
"💜",
"🖤",
"💘",
"💝",
]
for i in animation_ttl:
await asyncio.sleep(animation_interval)
await event.edit(animation_chars[i % 18])
CmdHelp("animoji").add_command(
'think', None, 'Use and see'
).add_command(
'ccry', None, 'Use and see'
).add_command(
'fap', None, 'Use and see'
).add_command(
'lmao', None, 'Use and see'
).add_command(
'nothappy', None, 'Use and see'
).add_command(
'clock', None, 'Use and see'
).add_command(
'muah', None, 'Use and see'
).add_command(
'heart', None, 'Use and see'
).add_command(
'gym', None, 'Use and see'
).add_command(
'earth', None, 'Use and see'
).add_command(
'moon', None, 'Use and see'
).add_command(
'lovestory', None, 'Turu Lob'
).add_command(
'smoon', None, 'Use and see'
).add_command(
'tmoon', None, 'Use and see'
).add_command(
'hart', None, 'Use and see'
).add_command(
'anim', None, 'Use and see'
).add_command(
'fuck', None, 'Use and see'
).add_command(
'sux', None, 'Use and see'
).add_command(
'kiss', None, 'Kya dekh rha h jhopdike.'
).add_command(
'fnl', None, 'Use and See.'
).add_command(
'monkey', None, 'Use and see.'
).add_command(
'hand', None, 'Use and See.'
).add_command(
'gsg', None, 'Use and See.'
).add_command(
'theart', None, 'Hearts Animation.'
).add()
| 26.781443 | 81 | 0.528755 | 1,791 | 12,989 | 3.98325 | 0.129537 | 0.053827 | 0.049061 | 0.057191 | 0.811326 | 0.783431 | 0.689655 | 0.608915 | 0.527754 | 0.524951 | 0 | 0.014193 | 0.267688 | 12,989 | 484 | 82 | 26.836777 | 0.682822 | 0 | 0 | 0.562642 | 0 | 0 | 0.151205 | 0.020325 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | false | 0 | 0.006834 | 0 | 0.061503 | 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 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 2 |
83b09d2ad07562da3b8e8e789cc7815800d89928 | 1,338 | py | Python | jsonclasses_cli/package/swift/main_program_content.py | forever9717/jsonclasses-cli | b20d10cdf2d6c970a879e2a64f31555d4d808829 | [
"MIT"
] | null | null | null | jsonclasses_cli/package/swift/main_program_content.py | forever9717/jsonclasses-cli | b20d10cdf2d6c970a879e2a64f31555d4d808829 | [
"MIT"
] | null | null | null | jsonclasses_cli/package/swift/main_program_content.py | forever9717/jsonclasses-cli | b20d10cdf2d6c970a879e2a64f31555d4d808829 | [
"MIT"
] | null | null | null | from jsonclasses.cgraph import CGraph
from .import_lines import import_lines
from .string_query import string_query
from .int_query import int_query
from .float_query import float_query
from .bool_query import bool_query
from .sort_order import sort_order
from .data_enum import data_enum
from .data_class import data_class
from .session_items import session_items
from .session import session
from .response import response_struct
from .user_default import user_default
from .session_manager import session_manager
from .sign_out import sign_out
from .request_manager import request_manager
from ...utils.join_lines import join_lines
def main_program_content(cgraph: CGraph) -> str:
session_classes = session_items(cgraph)
use_session = len(session_classes) > 0
return join_lines([
import_lines(),
string_query(),
int_query(),
float_query(),
bool_query(),
# other type queries
sort_order(),
*map(lambda e: data_enum(e), cgraph._enum_map.values()),
*map(lambda c: data_class(c), cgraph._map.values()),
session(session_classes) if use_session else '',
response_struct(),
user_default(),
session_manager() if use_session else '',
sign_out(),
request_manager('http://127.0.0.1:5000', use_session),
], 2)
| 34.307692 | 64 | 0.724963 | 184 | 1,338 | 4.967391 | 0.282609 | 0.04814 | 0.032823 | 0.035011 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0.01108 | 0.190583 | 1,338 | 38 | 65 | 35.210526 | 0.832872 | 0.013453 | 0 | 0 | 0 | 0 | 0.015933 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0.027778 | false | 0 | 0.5 | 0 | 0.555556 | 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 | 0 | 1 | 0 | 1 | 0 | 0 | 2 |
83b4ad592dcb04cd2de490a6b0d70c2d9d26c009 | 2,815 | py | Python | photos/models.py | kimutaimeshack/Instagram_clone | bdb035087f85fe055da29634cf7bc5dcb843897f | [
"MIT"
] | null | null | null | photos/models.py | kimutaimeshack/Instagram_clone | bdb035087f85fe055da29634cf7bc5dcb843897f | [
"MIT"
] | null | null | null | photos/models.py | kimutaimeshack/Instagram_clone | bdb035087f85fe055da29634cf7bc5dcb843897f | [
"MIT"
] | null | null | null | from django.db import models
import datetime as dt
from django.urls import reverse
# Create your models here.
class Editor(models.Model):
first_name = models.CharField(max_length =30 ,null=True)
last_name = models.CharField(max_length =30 ,null=True)
email = models.EmailField()
phone_number = models.CharField(max_length = 10,blank =True)
def __str__(self):
return self.first_name
class meta:
ordering =['name']
def save_editor(self):
self.save()
class tags(models.Model):
name = models.CharField(max_length =30, null=True)
def __str__(self):
return self.name
from cloudinary.models import CloudinaryField
class Postall(models.Model):
# title field
newimage = CloudinaryField('image',null=True)
def __str__(self):
return self.newimage
class Category(models.Model):
# title field
name = models.CharField(max_length=100, null=True)
def __str__(self):
return self.name
class Location(models.Model):
# title field
name = models.CharField(max_length=100, null=True)
def __str__(self):
return self.name
class photos(models.Model):
title = models.CharField(max_length=100)
details = models.TextField(null=True)
category = models.ForeignKey(Category, on_delete=models.CASCADE, null=True)
location = models.ForeignKey(Location, on_delete=models.CASCADE, null=True)
image = CloudinaryField('image',null=True)
pub_date = models.DateTimeField(auto_now_add=True ,null=True)
@classmethod
def search_by_category(cls,search_term):
news = cls.objects.filter(category__name__icontains=search_term)
return news
class Article(models.Model):
title = models.CharField(max_length =60, null=True)
post = models.TextField(null=True)
editor = models.ForeignKey(Editor, on_delete=models.CASCADE, null=True)
tags = models.ManyToManyField(tags)
pub_date = models.DateTimeField(auto_now_add=True, null=True)
photo_imagen = models.ImageField(upload_to = 'articles/', null=True)
def get_absolute_url(self): # new
return reverse('postdetail', args=[str(self.id)])
def __str__(self):
return self.title
@classmethod
def todays_news(cls):
today = dt.date.today()
news = cls.objects.filter(pub_date__date = today)
return news
@classmethod
def days_news(cls,date):
news = cls.objects.filter(pub_date__date = date)
return news
#..search
#...................
# class Post(models.Model):
# title = models.CharField(max_length=200)
# author = models.ForeignKey('auth.User',
# on_delete=models.CASCADE,)
# body = models.TextField()
# def __str__(self):
# return self.title | 29.946809 | 79 | 0.671403 | 351 | 2,815 | 5.179487 | 0.273504 | 0.070407 | 0.089109 | 0.118812 | 0.432343 | 0.430693 | 0.342134 | 0.226623 | 0.150715 | 0.150715 | 0 | 0.009959 | 0.215275 | 2,815 | 94 | 80 | 29.946809 | 0.813038 | 0.120782 | 0 | 0.306452 | 0 | 0 | 0.013409 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0.177419 | false | 0 | 0.064516 | 0.112903 | 0.854839 | 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 | 0 | 0 | 1 | 1 | 0 | 0 | 2 |
83c5d489d870a160b110a47da3fc244bdbe0bd80 | 4,699 | py | Python | Wrappers/Python/Testing/MasterTest.py | gregmedlock/roadrunnerwork | 11f18f78ef3e381bc59c546a8d5e3ed46d8ab596 | [
"Apache-2.0"
] | null | null | null | Wrappers/Python/Testing/MasterTest.py | gregmedlock/roadrunnerwork | 11f18f78ef3e381bc59c546a8d5e3ed46d8ab596 | [
"Apache-2.0"
] | null | null | null | Wrappers/Python/Testing/MasterTest.py | gregmedlock/roadrunnerwork | 11f18f78ef3e381bc59c546a8d5e3ed46d8ab596 | [
"Apache-2.0"
] | null | null | null | import os
location = os.path.join(os.path.dirname(__file__), 'Functions\\')
#location = 'Tests\\'
execfile(location + 'getVersion.py')
execfile(location + 'writeSBML.py')
#execfile(location + 'computeSteadyStateValues.py')
execfile(location + 'evalModel.py')
#execfile(location + 'getAvailableSymbols.py')
execfile(location + 'getBoundarySpeciesByIndex.py')
execfile(location + 'getBoundarySpeciesIds.py')
execfile(location + 'getBuildDate.py')
#execfile(location + 'getCCode.py')
#execfile(location + 'getCCodeHeader.py')
#execfile(location + 'getCCodeSource.py')
execfile(location + 'getCapabilities.py')
execfile(location + 'getCompartmentByIndex.py')
execfile(location + 'getCompartmentIds.py')
execfile(location + 'getConcentrationControlCoefficientIds.py')
execfile(location + 'getConservationMatrix.py')
execfile(location + 'getCopyright.py')
#execfile(location + 'getuCC.py')
#execfile(location + 'getuEE.py')
#execfile(location + 'getCC.py')
#execfile(location + 'getEE.py')
execfile(location + 'getEigenValueIds.py')
execfile(location + 'getElasticityCoefficientIds.py')
execfile(location + 'getFloatingSpeciesByIndex.py')
execfile(location + 'getFloatingSpeciesInitialConcentrations.py')
execfile(location + 'getFloatingSpeciesInitialConditionIds.py')
execfile(location + 'getFloatingSpeciesIds.py')
execfile(location + 'getFloatingSpeciesConcentrations.py')
execfile(location + 'getFluxControlCoefficientIds.py')
#execfile(location + 'getFullJacobian.py') Causes crash
execfile(location + 'getGlobalParameterByIndex.py')
execfile(location + 'getGlobalParameterIds.py')
execfile(location + 'getGlobalParameterValues.py')
execfile(location + 'getLastError.py')
execfile(location + 'getLinkMatrix.py')
execfile(location + 'getNrMatrix.py')
execfile(location + 'getL0Matrix.py')
execfile(location + 'getMatrixNumCols.py')
execfile(location + 'getMatrixNumRows.py')
execfile(location + 'getMatrixElement.py')
execfile(location + 'getNumberOfBoundarySpecies.py')
execfile(location + 'getNumberOfCompartments.py')
execfile(location + 'getNumberOfDependentSpecies.py')
execfile(location + 'getNumberOfFloatingSpecies.py')
execfile(location + 'getNumberOfGlobalParameters.py')
execfile(location + 'getNumberOfIndependentSpecies.py')
execfile(location + 'getNumberOfReactions.py')
execfile(location + 'getParamPromotedSBML.py')
execfile(location + 'getRRInstance.py')
execfile(location + 'getRateOfChange.py')
execfile(location + 'getRatesOfChange.py')
execfile(location + 'getRatesOfChangeEx.py')
execfile(location + 'getRatesOfChangeIds.py')
execfile(location + 'getReactionIds.py')
execfile(location + 'getReactionRate.py')
execfile(location + 'getReactionRates.py')
execfile(location + 'getReactionRatesEx.py')
#execfile(location + 'getReducedJacobian.py')
execfile(location + 'getResultColumnLabel.py')
execfile(location + 'getResultElement.py')
execfile(location + 'getResultNumCols.py')
execfile(location + 'getResultNumRows.py')
execfile(location + 'getSBML.py')
#execfile(location + 'getScaledElasticityMatrix.py')
#execfile(location + 'getScaledFloatingSpeciesElasticity.py')
execfile(location + 'getSelectionList.py')
execfile(location + 'getSteadyStateSelectionList.py')
execfile(location + 'getStoichiometryMatrix.py')
#execfile(location + 'getStringListElement.py')
#execfile(location + 'getStringListLength.py')
execfile(location + 'getTempFolder.py')
execfile(location + 'getValue.py')
#execfile(location + 'getVectorElement.py')
#execfile(location + 'getVectorLength.py')
#execfile(location + 'hasError.py')
execfile(location + 'loadSBML.py')
execfile(location + 'loadSBMLFromFile.py')
#execfile(location + 'oneStep.py')
execfile(location + 'printList.py')
execfile(location + 'printMatrix.py')
#execfile(location + 'printResult.py')
#execfile(location + 'printVector.py')
execfile(location + 'reset.py')
execfile(location + 'setBoundarySpeciesByIndex.py')
execfile(location + 'setCapabilities.py')
execfile(location + 'setCompartmentByIndex.py')
execfile(location + 'setComputeAndAssignConservationLaws.py')
execfile(location + 'setFloatingSpeciesByIndex.py')
execfile(location + 'setGlobalParameterByIndex.py')
execfile(location + 'setNumPoints.py')
execfile(location + 'setSelectionList.py')
execfile(location + 'setSteadyStateSelectionList.py')
execfile(location + 'setTempFolder.py')
execfile(location + 'setTimeEnd.py')
execfile(location + 'setTimeStart.py')
execfile(location + 'setValue.py')
#execfile(location + 'setVectorElement.py')
#execfile(location + 'simulate.py')
#execfile(location + 'simulateEx.py')
#execfile(location + 'steadyState.py') | 44.330189 | 72 | 0.770377 | 415 | 4,699 | 8.713253 | 0.272289 | 0.442478 | 0.487832 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0.000234 | 0.09236 | 4,699 | 106 | 73 | 44.330189 | 0.847597 | 0.222175 | 0 | 0 | 0 | 0 | 0.462695 | 0.280567 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | false | 0 | 0.012987 | 0 | 0.012987 | 0.025974 | 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 | 0 | 0 | 0 | 2 |
83cdd7dc6122382de1e26b815171dea31d9c7f62 | 917 | py | Python | rondgang/models.py | eternallyBaffled/rondgang | 6d0442279b60a75518579df88bfc53a57d98c2b3 | [
"MIT"
] | null | null | null | rondgang/models.py | eternallyBaffled/rondgang | 6d0442279b60a75518579df88bfc53a57d98c2b3 | [
"MIT"
] | null | null | null | rondgang/models.py | eternallyBaffled/rondgang | 6d0442279b60a75518579df88bfc53a57d98c2b3 | [
"MIT"
] | null | null | null | from datetime import date
from django.db import models
# Create your models here.
class Gemeente(models.Model):
naam_text = models.CharField(max_length=50)
deelgemeente_text = models.CharField(max_length=50)
class Segment(models.Model):
gemeente = models.CharField(max_length=55)
straat = models.CharField(max_length=50)
commentaar = models.TextField(blank=True)
def __str__(self):
return '%s, %s' % (self.straat, self.gemeente)
class Meta:
verbose_name_plural = 'segmenten'
class Status(models.Model):
segment = models.ForeignKey(Segment, on_delete=models.CASCADE)
afgewerkt = models.BooleanField()
# lid = models.ForeignKey(Lid, to_field='naam')
lid = models.CharField(max_length=50, null=True)
datum = models.DateField(default=date.today)
commentaar = models.TextField(blank=True)
class Meta:
verbose_name_plural = 'statussen'
| 28.65625 | 66 | 0.715376 | 115 | 917 | 5.556522 | 0.46087 | 0.117371 | 0.140845 | 0.187793 | 0.363067 | 0.093897 | 0 | 0 | 0 | 0 | 0 | 0.013228 | 0.175573 | 917 | 31 | 67 | 29.580645 | 0.832011 | 0.079607 | 0 | 0.190476 | 0 | 0 | 0.028537 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0.047619 | false | 0 | 0.095238 | 0.047619 | 0.904762 | 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 | 0 | 0 | 1 | 0 | 0 | 2 |
83d7cca1abc5dcfe213ee77fb80532cd598c02d8 | 1,642 | py | Python | card-games/lists.py | vietanhtran2710/python-exercism | 1f88dfca56928276ab81a274e8259ce465a2d425 | [
"MIT"
] | null | null | null | card-games/lists.py | vietanhtran2710/python-exercism | 1f88dfca56928276ab81a274e8259ce465a2d425 | [
"MIT"
] | null | null | null | card-games/lists.py | vietanhtran2710/python-exercism | 1f88dfca56928276ab81a274e8259ce465a2d425 | [
"MIT"
] | null | null | null | """
Card games exercise
"""
def get_rounds(number):
"""
:param number: int - current round number.
:return: list - current round and the two that follow.
"""
return [i + number for i in range(3)]
def concatenate_rounds(rounds_1, rounds_2):
"""
:param rounds_1: list - first rounds played.
:param rounds_2: list - second set of rounds played.
:return: list - all rounds played.
"""
return rounds_1 + rounds_2
def list_contains_round(rounds, number):
"""
:param rounds: list - rounds played.
:param number: int - round number.
:return: bool - was the round played?
"""
return number in rounds
def card_average(hand):
"""
:param hand: list - cards in hand.
:return: float - average value of the cards in the hand.
"""
return sum(hand) / len(hand)
def approx_average_is_average(hand):
"""
:param hand: list - cards in hand.
:return: bool - if approximate average equals to the `true average`.
"""
return card_average(hand) in (hand[len(hand) // 2], (hand[0] + hand[-1]) / 2)
def average_even_is_average_odd(hand):
"""
:param hand: list - cards in hand.
:return: bool - are even and odd averages equal?
"""
even = [hand[index] for index in range(0, len(hand), 2)]
odd = [hand[index] for index in range(1, len(hand), 2)]
return card_average(even) == card_average(odd)
def maybe_double_last(hand):
"""
:param hand: list - cards in hand.
:return: list - hand with Jacks (if present) value doubled.
"""
if hand[-1] == 11:
hand[-1] *= 2
return hand
| 20.78481 | 81 | 0.612667 | 229 | 1,642 | 4.292576 | 0.279476 | 0.035605 | 0.052899 | 0.069176 | 0.209563 | 0.209563 | 0.160732 | 0.160732 | 0.126144 | 0 | 0 | 0.016461 | 0.260049 | 1,642 | 78 | 82 | 21.051282 | 0.792593 | 0.448843 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0.388889 | false | 0 | 0 | 0 | 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 | 0 | 1 | 0 | 0 | 2 |
83da20131082094621964e1f90f87f88548deff3 | 121 | py | Python | output/models/ms_data/regex/re_k14_xsd/__init__.py | tefra/xsdata-w3c-tests | b6b6a4ac4e0ab610e4b50d868510a8b7105b1a5f | [
"MIT"
] | 1 | 2021-08-14T17:59:21.000Z | 2021-08-14T17:59:21.000Z | output/models/ms_data/regex/re_k14_xsd/__init__.py | tefra/xsdata-w3c-tests | b6b6a4ac4e0ab610e4b50d868510a8b7105b1a5f | [
"MIT"
] | 4 | 2020-02-12T21:30:44.000Z | 2020-04-15T20:06:46.000Z | output/models/ms_data/regex/re_k14_xsd/__init__.py | tefra/xsdata-w3c-tests | b6b6a4ac4e0ab610e4b50d868510a8b7105b1a5f | [
"MIT"
] | null | null | null | from output.models.ms_data.regex.re_k14_xsd.re_k14 import (
Regex,
Doc,
)
__all__ = [
"Regex",
"Doc",
]
| 12.1 | 59 | 0.603306 | 17 | 121 | 3.823529 | 0.705882 | 0.153846 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0.043956 | 0.247934 | 121 | 9 | 60 | 13.444444 | 0.67033 | 0 | 0 | 0 | 0 | 0 | 0.066116 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | false | 0 | 0.125 | 0 | 0.125 | 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 | 0 | 0 | 0 | 2 |
83dc4959d0371e253276a653ff679aa4ad785db5 | 10,237 | py | Python | pyeventbus/tests/IO_performance_testing.py | n89nanda/EventBus | d1e35fa1ce9a2cb502404ecc2328c6c59745fce6 | [
"MIT"
] | 24 | 2018-02-02T03:12:05.000Z | 2021-11-11T10:06:22.000Z | pyeventbus/tests/IO_performance_testing.py | n89nanda/EventBus | d1e35fa1ce9a2cb502404ecc2328c6c59745fce6 | [
"MIT"
] | 2 | 2018-08-13T14:08:51.000Z | 2020-02-18T20:11:19.000Z | pyeventbus/tests/IO_performance_testing.py | n89nanda/EventBus | d1e35fa1ce9a2cb502404ecc2328c6c59745fce6 | [
"MIT"
] | 2 | 2020-01-17T12:47:30.000Z | 2020-05-05T14:10:10.000Z | from pyeventbus import *
from timeit import default_timer as timer
import numpy
import sys
from os import getcwd
import json
class Events:
class IOHeavyTestEvent:
start = 0
finish = 0
duration = 0
def __init__(self):
pass
def setStart(self, time):
self.start = time
def setFinish(self, time):
self.finish = time
def getDuration(self):
return self.finish - self.start
class IOHeavyTestEventBG:
start = 0
finish = 0
duration = 0
def __init__(self):
pass
def setStart(self, time):
self.start = time
def setFinish(self, time):
self.finish = time
def getDuration(self):
return self.finish - self.start
class IOHeavyTestEventGreenlet:
start = 0
finish = 0
duration = 0
def __init__(self):
pass
def setStart(self, time):
self.start = time
def setFinish(self, time):
self.finish = time
def getDuration(self):
return self.finish - self.start
class IOHeavyTestEventParallel:
start = 0
finish = 0
duration = 0
def __init__(self):
pass
def setStart(self, time):
self.start = time
def setFinish(self, time):
self.finish = time
def getDuration(self):
return self.finish - self.start
class IOHeavyTestEventConcurrent:
start = 0
finish = 0
duration = 0
def __init__(self):
pass
def setStart(self, time):
self.start = time
def setFinish(self, time):
self.finish = time
def getDuration(self):
return self.finish - self.start
class PerformanceTester:
def __init__(self):
pass
def register(self, aInstance):
PyBus.Instance().register(aInstance, self.__class__.__name__)
def startIOHeavyTestInMain(self):
event = Events.IOHeavyTestEvent()
event.setStart(timer())
start = timer()
PyBus.Instance().post(event)
print("{} got control back in {} seconds.".format('startIOHeavyTestInMain: ', timer() - start))
def startIOHeavyTestInBackground(self):
event = Events.IOHeavyTestEventBG()
event.setStart(timer())
start = timer()
PyBus.Instance().post(event)
print("{} got control back in {} seconds.".format('startIOHeavyTestInBackground: ', timer() - start))
def startIOHeavyTestInGreenlet(self):
event = Events.IOHeavyTestEventGreenlet()
event.setStart(timer())
start = timer()
PyBus.Instance().post(event)
print("{} got control back in {} seconds.".format('startIOHeavyTestInGreenlet: ', timer() - start))
def startIOHeavyTestInParallel(self):
event = Events.IOHeavyTestEventParallel()
event.setStart(timer())
start = timer()
PyBus.Instance().post(event)
print("{} got control back in {} seconds.".format('startIOHeavyTestInParallel: ', timer() - start))
def startIOHeavyTestInConcurrent(self):
event = Events.IOHeavyTestEventConcurrent()
event.setStart(timer())
start = timer()
PyBus.Instance().post(event)
print("{} got control back in {} seconds.".format('startIOHeavyTestInConcurrent: ', timer() - start))
class PerformanceExecuter:
def __init__(self):
pass
def register(self, bInstance):
PyBus.Instance().register(bInstance, self.__class__.__name__)
@subscribe(onEvent=Events.IOHeavyTestEvent)
def IOHeavyTest1(self, event):
for i in range(3000):
with open('{}/generated.json'.format(getcwd())) as f:
data = json.load(f)
event.setFinish(timer())
print("{} ran the code in {} seconds.".format('IOHeavyTest1: Main-thread', event.getDuration()))
@subscribe(threadMode = Mode.BACKGROUND, onEvent=Events.IOHeavyTestEventBG)
def IOHeavyTest2(self, event):
for i in range(3000):
with open('{}/generated.json'.format(getcwd())) as f:
data = json.load(f)
event.setFinish(timer())
print("{} ran the code in {} seconds.".format('IOHeavyTest2: Background-thread', event.getDuration()))
@subscribe(threadMode = Mode.GREENLET, onEvent=Events.IOHeavyTestEventGreenlet)
def IOHeavyTest3(self, event):
for i in range(3000):
with open('{}/generated.json'.format(getcwd())) as f:
data = json.load(f)
event.setFinish(timer())
print("{} ran the code in {} seconds.".format('IOHeavyTest3: Greenlet', event.getDuration()))
@subscribe(threadMode = Mode.PARALLEL, onEvent=Events.IOHeavyTestEventParallel)
def IOHeavyTest4(self, event):
for i in range(3000):
with open('{}/generated.json'.format(getcwd())) as f:
data = json.load(f)
event.setFinish(timer())
print("{} ran the code in {} seconds.".format('IOHeavyTest4: parallel', event.getDuration()))
@subscribe(threadMode = Mode.CONCURRENT, onEvent=Events.IOHeavyTestEventConcurrent)
def IOHeavyTest5(self, event):
for i in range(3000):
with open('{}/generated.json'.format(getcwd())) as f:
data = json.load(f)
event.setFinish(timer())
print("{} ran the code in {} seconds.".format('IOHeavyTest5: Concurrent', event.getDuration()))
@subscribe(onEvent=Events.IOHeavyTestEvent)
def IOHeavyTest6(self, event):
for i in range(3000):
with open('{}/generated.json'.format(getcwd())) as f:
data = json.load(f)
event.setFinish(timer())
print("{} ran the code in {} seconds.".format('IOHeavyTest6: Main-thread', event.getDuration()))
@subscribe(threadMode = Mode.BACKGROUND, onEvent=Events.IOHeavyTestEventBG)
def IOHeavyTest7(self, event):
for i in range(3000):
with open('{}/generated.json'.format(getcwd())) as f:
data = json.load(f)
event.setFinish(timer())
print("{} ran the code in {} seconds.".format('IOHeavyTest7: Background-thread', event.getDuration()))
@subscribe(threadMode = Mode.GREENLET, onEvent=Events.IOHeavyTestEventGreenlet)
def IOHeavyTest8(self, event):
for i in range(3000):
with open('{}/generated.json'.format(getcwd())) as f:
data = json.load(f)
event.setFinish(timer())
print("{} ran the code in {} seconds.".format('IOHeavyTest8: Greenlet', event.getDuration()))
@subscribe(threadMode = Mode.PARALLEL, onEvent=Events.IOHeavyTestEventParallel)
def IOHeavyTest9(self, event):
for i in range(3000):
with open('{}/generated.json'.format(getcwd())) as f:
data = json.load(f)
event.setFinish(timer())
print("{} ran the code in {} seconds.".format('IOHeavyTest9: parallel', event.getDuration()))
@subscribe(threadMode = Mode.CONCURRENT, onEvent=Events.IOHeavyTestEventConcurrent)
def IOHeavyTest10(self, event):
for i in range(3000):
with open('{}/generated.json'.format(getcwd())) as f:
data = json.load(f)
event.setFinish(timer())
print("{} ran the code in {} seconds.".format('IOHeavyTest10: Concurrent', event.getDuration()))
@subscribe(onEvent=Events.IOHeavyTestEvent)
def IOHeavyTest11(self, event):
for i in range(3000):
with open('{}/generated.json'.format(getcwd())) as f:
data = json.load(f)
event.setFinish(timer())
print("{} ran the code in {} seconds.".format('IOHeavyTest11: Main-thread', event.getDuration()))
@subscribe(threadMode = Mode.BACKGROUND, onEvent=Events.IOHeavyTestEventBG)
def IOHeavyTest12(self, event):
for i in range(3000):
with open('{}/generated.json'.format(getcwd())) as f:
data = json.load(f)
event.setFinish(timer())
print("{} ran the code in {} seconds.".format('IOHeavyTest12: Background-thread', event.getDuration()))
@subscribe(threadMode = Mode.GREENLET, onEvent=Events.IOHeavyTestEventGreenlet)
def IOHeavyTest13(self, event):
for i in range(3000):
with open('{}/generated.json'.format(getcwd())) as f:
data = json.load(f)
event.setFinish(timer())
print("{} ran the code in {} seconds.".format('IOHeavyTest13: Greenlet', event.getDuration()))
@subscribe(threadMode = Mode.PARALLEL, onEvent=Events.IOHeavyTestEventParallel)
def IOHeavyTest14(self, event):
for i in range(3000):
with open('{}/generated.json'.format(getcwd())) as f:
data = json.load(f)
event.setFinish(timer())
print("{} ran the code in {} seconds.".format('IOHeavyTest14: parallel', event.getDuration()))
@subscribe(threadMode = Mode.CONCURRENT, onEvent=Events.IOHeavyTestEventConcurrent)
def IOHeavyTest15(self, event):
for i in range(3000):
with open('{}/generated.json'.format(getcwd())) as f:
data = json.load(f)
event.setFinish(timer())
print("{} ran the code in {} seconds.".format('IOHeavyTest15: Concurrent', event.getDuration()))
if __name__ == '__main__':
tester = PerformanceTester()
tester.register(tester)
executer = PerformanceExecuter()
executer.register(executer)
print sys.argv[1:][0]
arg = sys.argv[1:][0]
if arg == 'startIOHeavyTestInMain': tester.startIOHeavyTestInMain()
elif arg == 'startIOHeavyTestInBackground': tester.startIOHeavyTestInBackground()
elif arg == 'startIOHeavyTestInGreenlet': tester.startIOHeavyTestInGreenlet()
elif arg == 'startIOHeavyTestInParallel': tester.startIOHeavyTestInParallel()
elif arg == 'startIOHeavyTestInConcurrent': tester.startIOHeavyTestInConcurrent()
# tester.startIOHeavyTestInMain()
# tester.startIOHeavyTestInBackground()
# tester.startIOHeavyTestInGreenlet()
# tester.startIOHeavyTestInParallel()
# tester.startIOHeavyTestInConcurrent()
| 38.197761 | 111 | 0.62069 | 1,036 | 10,237 | 6.082046 | 0.09556 | 0.028567 | 0.047611 | 0.030947 | 0.699889 | 0.693382 | 0.693382 | 0.68386 | 0.662593 | 0.662593 | 0 | 0.015803 | 0.252027 | 10,237 | 267 | 112 | 38.340824 | 0.807105 | 0.017486 | 0 | 0.665179 | 0 | 0 | 0.152308 | 0.026363 | 0 | 0 | 0 | 0 | 0 | 0 | null | null | 0.03125 | 0.026786 | null | null | 0.09375 | 0 | 0 | 0 | null | 0 | 0 | 0 | 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 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 2 |
83dd12a100f10a5e78beecf49e3037dfe7dab6b8 | 79 | py | Python | hrsxrate.py | fabiovitoriano7/pythoncourse | cceb9b727abd15c4a63f08b5678b224011441997 | [
"MIT"
] | null | null | null | hrsxrate.py | fabiovitoriano7/pythoncourse | cceb9b727abd15c4a63f08b5678b224011441997 | [
"MIT"
] | null | null | null | hrsxrate.py | fabiovitoriano7/pythoncourse | cceb9b727abd15c4a63f08b5678b224011441997 | [
"MIT"
] | null | null | null | hrs = input("Enter Hours:")
rate=2.75
print ("Pay: " + str(float(rate) * hrs))
| 19.75 | 40 | 0.607595 | 13 | 79 | 3.692308 | 0.846154 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0.044776 | 0.151899 | 79 | 3 | 41 | 26.333333 | 0.671642 | 0 | 0 | 0 | 0 | 0 | 0.21519 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | false | 0 | 0 | 0 | 0 | 0.333333 | 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 | 0 | 0 | 0 | 2 |
83f41e9d7d2619c0ed48dbceaafa749c11834cc5 | 1,431 | py | Python | Breeze18/Breeze/migrations/0006_auto_20180110_2205.py | Breeze18/Breeze | 4215776e2f02fab3ce357e67b3b6ca378742049c | [
"Apache-2.0"
] | null | null | null | Breeze18/Breeze/migrations/0006_auto_20180110_2205.py | Breeze18/Breeze | 4215776e2f02fab3ce357e67b3b6ca378742049c | [
"Apache-2.0"
] | 1 | 2017-11-09T13:07:24.000Z | 2018-01-29T04:31:26.000Z | Breeze18/Breeze/migrations/0006_auto_20180110_2205.py | Breeze18/Breeze | 4215776e2f02fab3ce357e67b3b6ca378742049c | [
"Apache-2.0"
] | null | null | null | # -*- coding: utf-8 -*-
# Generated by Django 1.11.4 on 2018-01-10 16:35
from __future__ import unicode_literals
from django.conf import settings
from django.db import migrations, models
import django.db.models.deletion
class Migration(migrations.Migration):
dependencies = [
('Breeze', '0005_forgetpass'),
]
operations = [
migrations.RemoveField(
model_name='registration',
name='transaction_id',
),
migrations.AddField(
model_name='registration',
name='college',
field=models.CharField(default='', max_length=200),
),
migrations.AddField(
model_name='registration',
name='payable',
field=models.DecimalField(decimal_places=2, max_digits=8, null=True),
),
migrations.AddField(
model_name='registration',
name='registration_id',
field=models.CharField(default='', max_length=200, unique=True),
),
migrations.AddField(
model_name='registration',
name='transaction_status',
field=models.CharField(default='Unpaid', max_length=200),
),
migrations.AlterField(
model_name='registration',
name='userId',
field=models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to=settings.AUTH_USER_MODEL),
),
]
| 30.446809 | 110 | 0.600978 | 140 | 1,431 | 5.978571 | 0.471429 | 0.133811 | 0.150538 | 0.179211 | 0.364397 | 0.308244 | 0.205496 | 0 | 0 | 0 | 0 | 0.031189 | 0.283019 | 1,431 | 46 | 111 | 31.108696 | 0.7846 | 0.047519 | 0 | 0.410256 | 1 | 0 | 0.122059 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | false | 0.025641 | 0.102564 | 0 | 0.179487 | 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 | 1 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 2 |
f7b50b715b179630c9fcdafb1ce4cd54b3be0ee5 | 423 | py | Python | edm_web1/middleware/errors.py | zhouli121018/nodejsgm | 0ccbc8acf61badc812f684dd39253d55c99f08eb | [
"MIT"
] | null | null | null | edm_web1/middleware/errors.py | zhouli121018/nodejsgm | 0ccbc8acf61badc812f684dd39253d55c99f08eb | [
"MIT"
] | 18 | 2020-06-05T18:17:40.000Z | 2022-03-11T23:25:21.000Z | edm_web1/middleware/errors.py | zhouli121018/nodejsgm | 0ccbc8acf61badc812f684dd39253d55c99f08eb | [
"MIT"
] | null | null | null | # -*- coding: utf-8 -*-
from django.http import HttpResponseForbidden
from django.template import loader
from django.utils.translation import ugettext_lazy as _
# 普通用户
def _requred_forbid(msg):
t = loader.get_template('limit_ip.html')
content = t.render({'message': msg })
return HttpResponseForbidden(content)
_msg = _(u'请求太频繁,请等待30s后重试(Request too often)。')
limitip_requred_forbid = _requred_forbid(_msg)
| 26.4375 | 55 | 0.754137 | 54 | 423 | 5.666667 | 0.666667 | 0.098039 | 0.104575 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0.008197 | 0.134752 | 423 | 15 | 56 | 28.2 | 0.827869 | 0.061466 | 0 | 0 | 0 | 0 | 0.139949 | 0.058524 | 0 | 0 | 0 | 0 | 0 | 1 | 0.111111 | false | 0 | 0.333333 | 0 | 0.555556 | 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 | 0 | 1 | 0 | 1 | 0 | 0 | 2 |
f7b9749cf050209379cfad2f528020cbb5090d82 | 263 | py | Python | feed/models.py | Lisgevan/DJANGO-101-PROJECT-COPY | 01655b30682efd435d91e85223af0fd6186e6a59 | [
"MIT"
] | null | null | null | feed/models.py | Lisgevan/DJANGO-101-PROJECT-COPY | 01655b30682efd435d91e85223af0fd6186e6a59 | [
"MIT"
] | null | null | null | feed/models.py | Lisgevan/DJANGO-101-PROJECT-COPY | 01655b30682efd435d91e85223af0fd6186e6a59 | [
"MIT"
] | null | null | null | from django.db import models
from sorl.thumbnail import ImageField
# Create your models here.
class Post(models.Model):
text = models.CharField(max_length=140, blank=False, null=False)
image = ImageField()
def __str__(self):
return self.text | 26.3 | 68 | 0.726236 | 36 | 263 | 5.166667 | 0.75 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0.013953 | 0.18251 | 263 | 10 | 69 | 26.3 | 0.851163 | 0.091255 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0.142857 | false | 0 | 0.285714 | 0.142857 | 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 | 0 | 0 | 0 | 1 | 1 | 0 | 0 | 2 |
f7c3c4d630855f49542b120f69474ebe854a401b | 310 | py | Python | toast/decorators/__init__.py | joshuaskelly/Toast | 741bc17992fd654c9834b080189eb800202ce999 | [
"MIT"
] | null | null | null | toast/decorators/__init__.py | joshuaskelly/Toast | 741bc17992fd654c9834b080189eb800202ce999 | [
"MIT"
] | null | null | null | toast/decorators/__init__.py | joshuaskelly/Toast | 741bc17992fd654c9834b080189eb800202ce999 | [
"MIT"
] | null | null | null | class call_if(object):
def __init__(self, cond):
self.condition = cond
def __call__(self, func):
def inner(*args, **kwargs):
if getattr(args[0], self.condition):
return func(*args, **kwargs)
else:
return None
return inner | 28.181818 | 48 | 0.525806 | 34 | 310 | 4.529412 | 0.529412 | 0.168831 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0.005076 | 0.364516 | 310 | 11 | 49 | 28.181818 | 0.77665 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0.3 | false | 0 | 0 | 0 | 0.7 | 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 | 0 | 1 | 0 | 0 | 2 |
f7d2cd873463ee3cda95ca64c29e31dbdad2cad2 | 2,989 | py | Python | musicdb/restapi/migrations/0001_initial.py | alexebaker/django-music_database | cffa2574d894509b0eec7c71bd821cc0fd2f2cf7 | [
"MIT"
] | null | null | null | musicdb/restapi/migrations/0001_initial.py | alexebaker/django-music_database | cffa2574d894509b0eec7c71bd821cc0fd2f2cf7 | [
"MIT"
] | 7 | 2020-06-05T18:23:50.000Z | 2022-03-11T23:24:27.000Z | musicdb/restapi/migrations/0001_initial.py | alexebaker/django-music_database | cffa2574d894509b0eec7c71bd821cc0fd2f2cf7 | [
"MIT"
] | null | null | null | # Generated by Django 2.0.4 on 2018-05-01 05:22
from django.db import migrations, models
import django.db.models.deletion
class Migration(migrations.Migration):
initial = True
dependencies = [
]
operations = [
migrations.CreateModel(
name='Album',
fields=[
('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
('title', models.CharField(max_length=100)),
('year', models.CharField(max_length=4)),
],
),
migrations.CreateModel(
name='AlbumArt',
fields=[
('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
('image', models.ImageField(upload_to='album_art')),
('album', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='album_art', to='restapi.Album')),
],
),
migrations.CreateModel(
name='Artist',
fields=[
('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
('name', models.CharField(max_length=200)),
],
),
migrations.CreateModel(
name='Genre',
fields=[
('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
('name', models.CharField(max_length=50)),
],
),
migrations.CreateModel(
name='Style',
fields=[
('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
('name', models.CharField(max_length=50)),
],
),
migrations.CreateModel(
name='Track',
fields=[
('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
('title', models.CharField(max_length=100)),
('duration', models.TimeField()),
('position', models.CharField(max_length=3)),
('album', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='tracks', to='restapi.Album')),
],
),
migrations.AddField(
model_name='album',
name='artist',
field=models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='albums', to='restapi.Artist'),
),
migrations.AddField(
model_name='album',
name='genres',
field=models.ManyToManyField(blank=True, related_name='albums', to='restapi.Genre'),
),
migrations.AddField(
model_name='album',
name='styles',
field=models.ManyToManyField(blank=True, related_name='albums', to='restapi.Style'),
),
]
| 38.320513 | 136 | 0.556708 | 289 | 2,989 | 5.622837 | 0.249135 | 0.064615 | 0.077538 | 0.103385 | 0.691077 | 0.681846 | 0.615385 | 0.615385 | 0.615385 | 0.615385 | 0 | 0.014368 | 0.301439 | 2,989 | 77 | 137 | 38.818182 | 0.763889 | 0.015055 | 0 | 0.614286 | 1 | 0 | 0.087016 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | false | 0 | 0.028571 | 0 | 0.085714 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 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 | 2 |
f7d411b7a1e10f51b58ab6692c180f5bbcd91a28 | 2,007 | py | Python | src/tests/Yi/tests/inner_product_between_lobatto_and_gauss.py | Idate96/Mimetic-Fem | 75ad3b982ef7ed7c6198f526d19dc460dec28f4d | [
"MIT"
] | null | null | null | src/tests/Yi/tests/inner_product_between_lobatto_and_gauss.py | Idate96/Mimetic-Fem | 75ad3b982ef7ed7c6198f526d19dc460dec28f4d | [
"MIT"
] | null | null | null | src/tests/Yi/tests/inner_product_between_lobatto_and_gauss.py | Idate96/Mimetic-Fem | 75ad3b982ef7ed7c6198f526d19dc460dec28f4d | [
"MIT"
] | null | null | null | # -*- coding: utf-8 -*-
"""
(SHORT NAME EXPLANATION)
>>>DOCTEST COMMANDS
(THE TEST ANSWER)
@author: Yi Zhang. Created on Mon Jul 10 20:12:27 2017
Department of Aerodynamics
Faculty of Aerospace Engineering
TU Delft
#SUMMARY----------------
#INPUTS-----------------
#ESSENTIAL:
#OPTIONAL:
#OUTPUTS----------------
#EXAMPLES---------------
#NOTES------------------
"""
# -*- coding: utf-8 -*-
"""
(SHORT NAME EXPLANATION)
>>>DOCTEST COMMANDS
(THE TEST ANSWER)
@author: Yi Zhang (张仪). Created on Thu Jul 6 16:00:33 2017
Department of Aerodynamics
Faculty of Aerospace Engineering
TU Delft
#SUMMARY----------------
#INPUTS-----------------
#ESSENTIAL:
#OPTIONAL:
#OUTPUTS----------------
#EXAMPLES---------------
#NOTES------------------
"""
from function_space import FunctionSpace
import numpy as np
from mesh import CrazyMesh
from forms import Form
from hodge import hodge
from coboundaries import d
from assemble import assemble
from _assembling import assemble_, integral1d_
import matplotlib.pyplot as plt
from quadrature import extended_gauss_quad
from scipy.integrate import quad
from sympy import Matrix
import scipy.io
from scipy import sparse
import scipy as sp
from inner_product import inner
# %% exact solution define
# u^{(1)} = { u, v }^T
def u(x,y):
return +np.cos(np.pi*x) * np.sin(np.pi*y)
def v(x,y):
return -np.sin(np.pi*x) * np.cos(np.pi*y)
def r_u(x,y):
return -2* np.pi**2 * np.cos(np.pi*x) * np.sin(np.pi*y)
def r_v(x,y):
return 2* np.pi**2 * np.sin(np.pi*x) * np.cos(np.pi*y)
# %% define the mesh
mesh = CrazyMesh( 2, (2, 2), ((-1, 1), (-1, 1)), 0.05 )
func_space_gauss1 = FunctionSpace(mesh, '1-gauss', (5, 5), is_inner=False)
func_space_lobatto1 = FunctionSpace(mesh, '1-lobatto', (5, 5), is_inner=False)
form_1_gauss = Form(func_space_gauss1)
form_1_lobatto = Form(func_space_lobatto1)
M = inner(form_1_lobatto.basis,form_1_gauss.basis)
| 22.3 | 78 | 0.619332 | 289 | 2,007 | 4.207612 | 0.363322 | 0.032895 | 0.026316 | 0.029605 | 0.425164 | 0.398026 | 0.398026 | 0.398026 | 0.375 | 0.375 | 0 | 0.03366 | 0.18585 | 2,007 | 89 | 79 | 22.550562 | 0.710526 | 0.249626 | 0 | 0 | 0 | 0 | 0.014665 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0.133333 | false | 0 | 0.533333 | 0.133333 | 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 | 0 | 0 | 1 | 1 | 0 | 0 | 0 | 2 |
f7d62d0a50f28ea90ec1747700a205b806ed75b7 | 2,684 | py | Python | allennlp/tests/data/tokenizers/pretrained_transformer_tokenizer_test.py | donna-legal/allennlp | fd1e3cfaed07ec3ba03b922d12eee47f8be16837 | [
"Apache-2.0"
] | 1 | 2020-01-28T07:52:28.000Z | 2020-01-28T07:52:28.000Z | allennlp/tests/data/tokenizers/pretrained_transformer_tokenizer_test.py | donna-legal/allennlp | fd1e3cfaed07ec3ba03b922d12eee47f8be16837 | [
"Apache-2.0"
] | null | null | null | allennlp/tests/data/tokenizers/pretrained_transformer_tokenizer_test.py | donna-legal/allennlp | fd1e3cfaed07ec3ba03b922d12eee47f8be16837 | [
"Apache-2.0"
] | null | null | null | from allennlp.common.testing import AllenNlpTestCase
from allennlp.data.tokenizers import PretrainedTransformerTokenizer
class TestPretrainedTransformerTokenizer(AllenNlpTestCase):
def test_splits_roberta(self):
tokenizer = PretrainedTransformerTokenizer("roberta-base")
sentence = "A, <mask> AllenNLP sentence."
expected_tokens = ["<s>", "A", ",", "<mask>", "Allen", "N", "LP", "Ġsentence", ".", "</s>"]
tokens = [t.text for t in tokenizer.tokenize(sentence)]
assert tokens == expected_tokens
# sentence pair
sentence_1 = "A, <mask> AllenNLP sentence."
sentence_2 = "A sentence."
expected_tokens = [
"<s>",
"A",
",",
"<mask>",
"Allen",
"N",
"LP",
"Ġsentence",
".",
"</s>",
"</s>",
"A",
"Ġsentence",
".",
"</s>",
]
tokens = [t.text for t in tokenizer.tokenize_sentence_pair(sentence_1, sentence_2)]
assert tokens == expected_tokens
def test_splits_cased_bert(self):
tokenizer = PretrainedTransformerTokenizer("bert-base-cased")
sentence = "A, [MASK] AllenNLP sentence."
expected_tokens = [
"[CLS]",
"A",
",",
"[MASK]",
"Allen",
"##NL",
"##P",
"sentence",
".",
"[SEP]",
]
tokens = [t.text for t in tokenizer.tokenize(sentence)]
assert tokens == expected_tokens
# sentence pair
sentence_1 = "A, [MASK] AllenNLP sentence."
sentence_2 = "A sentence."
expected_tokens = [
"[CLS]",
"A",
",",
"[MASK]",
"Allen",
"##NL",
"##P",
"sentence",
".",
"[SEP]",
"A",
"sentence",
".",
"[SEP]",
]
tokens = [t.text for t in tokenizer.tokenize_sentence_pair(sentence_1, sentence_2)]
assert tokens == expected_tokens
def test_splits_uncased_bert(self):
sentence = "A, [MASK] AllenNLP sentence."
expected_tokens = [
"[CLS]",
"a",
",",
"[MASK]",
"allen",
"##nl",
"##p",
"sentence",
".",
"[SEP]",
]
tokenizer = PretrainedTransformerTokenizer("bert-base-uncased")
tokens = [t.text for t in tokenizer.tokenize(sentence)]
assert tokens == expected_tokens
| 28.252632 | 99 | 0.462742 | 217 | 2,684 | 5.585253 | 0.202765 | 0.041254 | 0.05363 | 0.086634 | 0.690594 | 0.690594 | 0.690594 | 0.673267 | 0.673267 | 0.673267 | 0 | 0.004923 | 0.39456 | 2,684 | 94 | 100 | 28.553191 | 0.740923 | 0.01006 | 0 | 0.702381 | 0 | 0 | 0.159382 | 0 | 0 | 0 | 0 | 0 | 0.059524 | 1 | 0.035714 | false | 0 | 0.02381 | 0 | 0.071429 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 2 |
f7d6ae2f3cb3eec3b7e8a4d67b500afb529fc556 | 2,928 | py | Python | openmdao/api.py | ryanfarr01/blue | a9aac98c09cce0f7cadf26cf592e3d978bf4e3ff | [
"Apache-2.0"
] | null | null | null | openmdao/api.py | ryanfarr01/blue | a9aac98c09cce0f7cadf26cf592e3d978bf4e3ff | [
"Apache-2.0"
] | null | null | null | openmdao/api.py | ryanfarr01/blue | a9aac98c09cce0f7cadf26cf592e3d978bf4e3ff | [
"Apache-2.0"
] | null | null | null | """Key OpenMDAO classes can be imported from here."""
# Core
from openmdao.core.problem import Problem
from openmdao.core.group import Group
from openmdao.core.parallel_group import ParallelGroup
from openmdao.core.explicitcomponent import ExplicitComponent
from openmdao.core.implicitcomponent import ImplicitComponent
from openmdao.core.indepvarcomp import IndepVarComp
from openmdao.core.analysis_error import AnalysisError
# Components
from openmdao.components.deprecated_component import Component
from openmdao.components.exec_comp import ExecComp
from openmdao.components.linear_system_comp import LinearSystemComp
from openmdao.components.meta_model import MetaModel
from openmdao.components.multifi_meta_model import MultiFiMetaModel
# Solvers
from openmdao.solvers.linear.linear_block_gs import LinearBlockGS
from openmdao.solvers.linear.linear_block_jac import LinearBlockJac
from openmdao.solvers.linear.direct import DirectSolver
from openmdao.solvers.linear.petsc_ksp import PetscKSP
from openmdao.solvers.linear.linear_runonce import LinearRunOnce
from openmdao.solvers.linear.scipy_iter_solver import ScipyIterativeSolver
from openmdao.solvers.linesearch.backtracking import ArmijoGoldsteinLS
from openmdao.solvers.linesearch.backtracking import BoundsEnforceLS
from openmdao.solvers.nonlinear.nonlinear_block_gs import NonlinearBlockGS
from openmdao.solvers.nonlinear.nonlinear_block_jac import NonlinearBlockJac
from openmdao.solvers.nonlinear.newton import NewtonSolver
from openmdao.solvers.nonlinear.nonlinear_runonce import NonLinearRunOnce
# Surrogate Models
from openmdao.surrogate_models.kriging import KrigingSurrogate, FloatKrigingSurrogate
from openmdao.surrogate_models.multifi_cokriging import MultiFiCoKrigingSurrogate, \
FloatMultiFiCoKrigingSurrogate
from openmdao.surrogate_models.nearest_neighbor import NearestNeighbor
from openmdao.surrogate_models.response_surface import ResponseSurface
from openmdao.surrogate_models.surrogate_model import SurrogateModel, \
MultiFiSurrogateModel
# Vectors
from openmdao.vectors.default_vector import DefaultVector
try:
from openmdao.vectors.petsc_vector import PETScVector
except ImportError:
PETScVector = None
# Developer Tools
from openmdao.devtools.problem_viewer.problem_viewer import view_model
from openmdao.devtools.viewconns import view_connections
# Derivative Specification
from openmdao.jacobians.assembled_jacobian import AssembledJacobian, \
DenseJacobian, COOJacobian, CSRJacobian, CSCJacobian
# Drivers
try:
from openmdao.drivers.pyoptsparse_driver import pyOptSparseDriver
except ImportError:
pass
from openmdao.drivers.scipy_optimizer import ScipyOptimizer
# System-Building Tools
from openmdao.utils.options_dictionary import OptionsDictionary
# Recorders
from openmdao.recorders.sqlite_recorder import SqliteRecorder
from openmdao.recorders.openmdao_server_recorder import OpenMDAOServerRecorder
| 41.828571 | 85 | 0.873634 | 330 | 2,928 | 7.618182 | 0.366667 | 0.186158 | 0.090692 | 0.059666 | 0.126492 | 0.099443 | 0 | 0 | 0 | 0 | 0 | 0 | 0.084016 | 2,928 | 69 | 86 | 42.434783 | 0.93736 | 0.060792 | 0 | 0.083333 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | false | 0.020833 | 0.854167 | 0 | 0.854167 | 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 | 0 | 1 | 0 | 1 | 0 | 0 | 2 |
f7ea40e807af6204059adeba1056db95e63b5bcf | 492 | py | Python | plugins/hashsum_download/girder_hashsum_download/settings.py | JKitok/girder | 317962d155fc9811d25e5f33bd3e849c4ac96645 | [
"Apache-2.0"
] | 395 | 2015-01-12T19:20:13.000Z | 2022-03-30T05:40:40.000Z | plugins/hashsum_download/girder_hashsum_download/settings.py | JKitok/girder | 317962d155fc9811d25e5f33bd3e849c4ac96645 | [
"Apache-2.0"
] | 2,388 | 2015-01-01T20:09:19.000Z | 2022-03-29T16:49:14.000Z | plugins/hashsum_download/girder_hashsum_download/settings.py | JKitok/girder | 317962d155fc9811d25e5f33bd3e849c4ac96645 | [
"Apache-2.0"
] | 177 | 2015-01-04T14:47:00.000Z | 2022-03-25T09:01:51.000Z | from girder.exceptions import ValidationException
from girder.utility import setting_utilities
class PluginSettings:
AUTO_COMPUTE = 'hashsum_download.auto_compute'
@setting_utilities.default(PluginSettings.AUTO_COMPUTE)
def _defaultAutoCompute():
return False
@setting_utilities.validator(PluginSettings.AUTO_COMPUTE)
def _validateAutoCompute(doc):
if not isinstance(doc['value'], bool):
raise ValidationException('Auto-compute hash setting must be true or false.')
| 27.333333 | 85 | 0.802846 | 55 | 492 | 7 | 0.6 | 0.142857 | 0.194805 | 0.145455 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0.121951 | 492 | 17 | 86 | 28.941176 | 0.891204 | 0 | 0 | 0 | 0 | 0 | 0.166667 | 0.058943 | 0 | 0 | 0 | 0 | 0 | 1 | 0.181818 | false | 0 | 0.181818 | 0.090909 | 0.636364 | 0 | 0 | 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 | 0 | 0 | 0 | 1 | 0 | 0 | 2 |
f7f110d1e3f278e009edf38f3492952620bab08d | 619 | py | Python | bin/training_data/redmagic_ds_training_data.py | mclaughlin6464/pearce | 746f2bf4bf45e904d66996e003043661a01423ba | [
"MIT"
] | null | null | null | bin/training_data/redmagic_ds_training_data.py | mclaughlin6464/pearce | 746f2bf4bf45e904d66996e003043661a01423ba | [
"MIT"
] | 16 | 2016-11-04T22:24:32.000Z | 2018-05-01T22:53:39.000Z | bin/training_data/redmagic_ds_training_data.py | mclaughlin6464/pearce | 746f2bf4bf45e904d66996e003043661a01423ba | [
"MIT"
] | 3 | 2016-10-04T08:07:52.000Z | 2019-05-03T23:50:01.000Z | #!/.conda/envs/hodemulator/bin/python
from pearce.emulator import make_training_data
from pearce.emulator import DEFAULT_PARAMS as ordered_params
ordered_params['f_c'] = (0.05, .5)
ordered_params['logMmin'] = (11.5, 13.0)#(13.0, 14.5)
ordered_params['sigma_logM'] = (0.05, 1.0)
ordered_params['logM1'] = (12.0, 15.0)
ordered_params['alpha'] = (0.8, 1.5)
ordered_params.update({'mean_occupation_centrals_assembias_param1':( -1.0, 1.0),
'mean_occupation_satellites_assembias_param1':( -1.0, 1.0)})
make_training_data('/u/ki/swmclau2/Git/pearce/bin/training_data/ds_redmagic.cfg',ordered_params)
| 38.6875 | 96 | 0.726979 | 98 | 619 | 4.336735 | 0.479592 | 0.244706 | 0.098824 | 0.112941 | 0.089412 | 0.089412 | 0 | 0 | 0 | 0 | 0 | 0.077617 | 0.105008 | 619 | 15 | 97 | 41.266667 | 0.689531 | 0.077544 | 0 | 0 | 0 | 0 | 0.305115 | 0.252205 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | true | 0 | 0.2 | 0 | 0.2 | 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 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 2 |
f7fc84f573aa97d3b828afe66e29e4f49f7bb79c | 1,393 | py | Python | quantlab/COCO/utils/inference.py | lukasc-ch/QuantLab | 7ddcc51ec1131a58269768cd898ce04e8b49beb6 | [
"Apache-2.0"
] | 6 | 2019-05-24T17:39:07.000Z | 2021-11-06T22:19:55.000Z | quantlab/COCO/utils/inference.py | lukasc-ch/QuantLab | 7ddcc51ec1131a58269768cd898ce04e8b49beb6 | [
"Apache-2.0"
] | null | null | null | quantlab/COCO/utils/inference.py | lukasc-ch/QuantLab | 7ddcc51ec1131a58269768cd898ce04e8b49beb6 | [
"Apache-2.0"
] | 4 | 2019-05-24T17:39:15.000Z | 2021-04-02T07:13:11.000Z | import matplotlib.patches as patches
import matplotlib.pyplot as plt
import numpy as np
def view_instance(img, gt_label, pr_label=None):
img = img.cpu()
# gt_label = gt_label.cpu()
# pr_label = pr_label.cpu()
# c, h, w = img.shape
# with open('/home/spmatteo/MSDocuments/QuantLab/COCO/coco.names', 'r') as f:
# classes = [line.strip() for line in f.read().splitlines()]
# cmap = plt.get_cmap('tab20b')
# colors = [cmap(i) for i in np.linspace(0, 1, len(classes)-1)]
# fig, ax = plt.subplots(1, figsize=(12, 9))
# ax.imshow(img.permute(1, 2, 0)) # h, w, c
# # browse annotations and draw bounding boxes
# bboxes = []
# if label is not None:
# for i, annotation in enumerate(label):
# cls = annotation[6]
# if i < 6:
# print(annotation, classes[int(cls)])
# color = colors[int(cls)]
# bbox = patches.Rectangle((annotation[0], annotation[1]), annotation[2]-annotation[0], annotation[3]-annotation[1],
# linewidth=2, edgecolor=color, facecolor='none', label=classes[int(cls)])
# ax.add_patch(bbox)
# bboxes.append((bbox, classes[int(cls)], color))
# for bbox in bboxes:
# ax.annotate(bbox[1], bbox[0].get_xy(), weight='bold', fontsize=10, color=bbox[2])
# plt.axis('off')
# plt.show()
| 42.212121 | 128 | 0.580761 | 191 | 1,393 | 4.183246 | 0.47644 | 0.030038 | 0.048811 | 0.045056 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0.025194 | 0.259153 | 1,393 | 32 | 129 | 43.53125 | 0.749031 | 0.776023 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0.2 | false | 0 | 0.6 | 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 | 0 | 0 | 1 | 0 | 1 | 0 | 0 | 2 |
f7fcc0247bffa7d5ad90651380c319258f099e35 | 633 | py | Python | dockwidhistory.py | kimoamer/Clinic-Manager | 53184a4e8f369bf083109d065b2042fc7cf5bfbd | [
"MIT"
] | 3 | 2021-05-12T01:05:12.000Z | 2022-02-11T15:43:00.000Z | dockwidhistory.py | kimoamer/Clinic-Manager | 53184a4e8f369bf083109d065b2042fc7cf5bfbd | [
"MIT"
] | null | null | null | dockwidhistory.py | kimoamer/Clinic-Manager | 53184a4e8f369bf083109d065b2042fc7cf5bfbd | [
"MIT"
] | null | null | null | from PyQt5.QtWidgets import QDialog
from PyQt5.QtGui import QFont
from PyQt5.QtCore import Qt
from dockwina import Ui_Form as docka
class Dialog(QDialog, docka):
def __init__(self):
super(Dialog, self).__init__()
QDialog.__init__(self)
self.setupUi(self)
self.setWindowFlag(Qt.FramelessWindowHint)
self.font1 = QFont("Tajawal", 9)
self.label2.setFont(self.font1)
self.label7.setFont(self.font1)
self.label3.setFont(self.font1)
self.label5.setFont(self.font1)
self.label6.setFont(self.font1)
self.label.setFont(self.font1)
| 33.315789 | 51 | 0.665087 | 78 | 633 | 5.230769 | 0.423077 | 0.154412 | 0.235294 | 0.245098 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0.033058 | 0.235387 | 633 | 18 | 52 | 35.166667 | 0.809917 | 0 | 0 | 0 | 0 | 0 | 0.011382 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0.058824 | false | 0 | 0.235294 | 0 | 0.352941 | 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 | 0 | 0 | 0 | 0 | 0 | 2 |
7907463be0399381dbb251da2399a40b35f47313 | 986 | py | Python | {{cookiecutter.app_name}}/{{cookiecutter.app_name}}/app.py | opatua/cookiecutter-flask-api | 67e5a37ee2b8ca32823ac2f8051bab6653b3b44e | [
"MIT"
] | 2 | 2019-04-06T05:08:15.000Z | 2019-04-06T19:23:44.000Z | {{cookiecutter.app_name}}/{{cookiecutter.app_name}}/app.py | opatua/cookiecutter-flask-api | 67e5a37ee2b8ca32823ac2f8051bab6653b3b44e | [
"MIT"
] | null | null | null | {{cookiecutter.app_name}}/{{cookiecutter.app_name}}/app.py | opatua/cookiecutter-flask-api | 67e5a37ee2b8ca32823ac2f8051bab6653b3b44e | [
"MIT"
] | null | null | null | from flask import Flask
from flask_restful import Api
from flask_cors import CORS
from flask_migrate import Migrate, MigrateCommand
from flask_script import Manager
from {{cookiecutter.app_name}}.config import app_config
from {{cookiecutter.app_name}}.models import db, bcrypt
from {{cookiecutter.app_name}}.resources import Login, Register
from {{cookiecutter.app_name}}.schemas import ma
def create_app(env_name):
"""
Create app
"""
# app initiliazation
app = Flask(__name__)
CORS(app)
app.config.from_object(app_config[env_name])
# initializing bcrypt and db
bcrypt.init_app(app)
db.init_app(app)
ma.init_app(app)
migrate = Migrate(app, db)
manager = Manager(app)
manager.add_command('db', MigrateCommand)
if __name__ == '__main__':
manager.run()
# Route
api = Api(app)
# user endpoint
api.add_resource(Login, '/auth/login')
api.add_resource(Register, '/auth/register')
return app
| 22.930233 | 63 | 0.704868 | 131 | 986 | 5.061069 | 0.312977 | 0.067873 | 0.11463 | 0.138763 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0.193712 | 986 | 42 | 64 | 23.47619 | 0.833962 | 0.065923 | 0 | 0 | 0 | 0 | 0.039326 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | null | null | 0 | 0.36 | null | null | 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 | 1 | 0 | 0 | 0 | 1 | 0 | 0 | 0 | 0 | 2 |
79093ae44bacb9494b8349f6098239d9b14a8d37 | 567 | py | Python | Glyph-Builders/lowercase_from_upper.py | m4rc1e/mf-glyphs-scripts | c5ed026e5b72a886f1e574f85659cdcae041e66a | [
"MIT"
] | 27 | 2015-09-01T00:19:34.000Z | 2021-12-05T01:59:01.000Z | Glyph-Builders/lowercase_from_upper.py | m4rc1e/mf-glyphs-scripts | c5ed026e5b72a886f1e574f85659cdcae041e66a | [
"MIT"
] | 26 | 2016-01-03T09:31:39.000Z | 2018-06-01T18:05:58.000Z | Glyph-Builders/lowercase_from_upper.py | m4rc1e/mf-glyphs-scripts | c5ed026e5b72a886f1e574f85659cdcae041e66a | [
"MIT"
] | 7 | 2016-01-03T07:09:04.000Z | 2018-04-06T00:24:14.000Z | #MenuTitle: Generate lowercase from uppercase
"""
Generate lowercase a-z from uppercase A-Z
TODO (M Foley) Generate all lowercase glyphs, not just a-z
"""
font = Glyphs.font
glyphs = list('abcdefghijklmnopqrstuvwxyz')
masters = font.masters
for glyph_name in glyphs:
glyph = GSGlyph(glyph_name)
glyph.updateGlyphInfo()
font.glyphs.append(glyph)
for idx,layer in enumerate(masters):
comp_name = glyph_name.upper()
component = GSComponent(comp_name, (0,0))
glyph.layers[idx].components.append(component)
Glyphs.redraw()
| 24.652174 | 58 | 0.714286 | 73 | 567 | 5.479452 | 0.493151 | 0.015 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0.00431 | 0.181658 | 567 | 22 | 59 | 25.772727 | 0.857759 | 0.257496 | 0 | 0 | 1 | 0 | 0.062954 | 0.062954 | 0 | 0 | 0 | 0.045455 | 0 | 1 | 0 | false | 0 | 0 | 0 | 0 | 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 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 2 |
7916e1c58cd3262cc6b3f5abd2ae3b7c7603279e | 9,607 | py | Python | users_django/users/tests/test_views.py | r-o-main/users-exercise | ecd6e33308140f72cb6c446e0e7e93f327b57a97 | [
"MIT"
] | null | null | null | users_django/users/tests/test_views.py | r-o-main/users-exercise | ecd6e33308140f72cb6c446e0e7e93f327b57a97 | [
"MIT"
] | null | null | null | users_django/users/tests/test_views.py | r-o-main/users-exercise | ecd6e33308140f72cb6c446e0e7e93f327b57a97 | [
"MIT"
] | null | null | null | from rest_framework.test import APIRequestFactory
from rest_framework import status
from django.test import TestCase
from django.urls import reverse
from ..models import User
from ..serializer import UserSerializer
from ..views import UserViewSet
import ipapi
class UsersApiRootTestCase(TestCase):
def test_api_root_should_reply_200(self):
""" GET /api/v1/ should return an hyperlink to the users view and return a successful status 200 OK.
"""
request = APIRequestFactory().get("/api/v1/")
user_list_view = UserViewSet.as_view({"get": "list"})
response = user_list_view(request)
self.assertEqual(status.HTTP_200_OK, response.status_code)
class UsersApiTestCase(TestCase):
""" Factorize the tests setup to use a pool of existing users. """
def setUp(self):
self.factory = APIRequestFactory()
self.users = [
User.objects.create(
first_name="Riri", last_name="Duck", email="riri.duck@ricardo.ch", password="dummy"),
User.objects.create(
first_name="Fifi", last_name="Duck", email="fifi.duck@ricardo.ch", password="dummy"),
User.objects.create(
first_name="Loulou", last_name="Duck", email="loulou.duck@ricardo.ch", password="dummy")
]
class GetAllUsersTest(UsersApiTestCase):
""" Test GET /api/v1/users """
def test_list_all_users_should_retrieve_all_users_and_reply_200(self):
""" GET /api/v1/users should return all the users (or empty if no users found)
and return a successful status 200 OK.
"""
users = User.objects.all().order_by("id")
request = self.factory.get(reverse("v1:user-list"))
serializer = UserSerializer(users, many=True, context={'request': request})
user_list_view = UserViewSet.as_view({"get": "list"})
response = user_list_view(request)
self.assertEqual(len(self.users), len(response.data["results"]))
self.assertEqual(serializer.data, response.data["results"])
self.assertEqual(status.HTTP_200_OK, response.status_code)
class GetSingleUserTest(UsersApiTestCase):
""" Test GET /api/v1/users/:id """
def test_get_user_when_id_valid_should_retrieve_user_and_reply_200(self):
riri = User.objects.create(
first_name="Riri", last_name="Duck", email="riri.duck@ricardo.ch", password="dummy")
user = User.objects.get(pk=riri.pk)
request = self.factory.get(reverse("v1:user-detail", kwargs={"pk": riri.pk}))
serializer = UserSerializer(user, context={'request': request})
user_detail_view = UserViewSet.as_view({"get": "retrieve"})
response = user_detail_view(request, pk=riri.pk)
self.assertEqual(serializer.data, response.data)
self.assertEqual(status.HTTP_200_OK, response.status_code)
def test_get_user_when_id_invalid_should_reply_404(self):
request = self.factory.get(reverse("v1:user-detail", kwargs={"pk": 100}))
user_detail_view = UserViewSet.as_view({"get": "retrieve"})
response = user_detail_view(request, pk=100)
self.assertEqual(status.HTTP_404_NOT_FOUND, response.status_code)
class CreateNewUserTest(UsersApiTestCase):
""" Test POST /api/v1/users
Override 'REMOTE_ADDR' to set IP address to Switzerland or another country for testing purpose.
"""
def test_post_user_when_from_Switzerland_and_data_valid_should_create_user_and_reply_201(self):
initial_users_count = len(self.users)
valid_data = {
"first_name": "Casper",
"last_name": "Canterville",
"email": "c@sper.com",
"password": "dummy",
}
request = self.factory.post(
reverse("v1:user-list"),
data=valid_data,
REMOTE_ADDR='2.16.92.0'
)
user_detail_view = UserViewSet.as_view({"post": "create"})
response = user_detail_view(request)
self.assertEqual(status.HTTP_201_CREATED, response.status_code)
new_users_count = User.objects.count()
self.assertEqual(initial_users_count+1, new_users_count)
def test_post_user_when_id_invalid_should_not_create_user_and_reply_400(self):
initial_users_count = len(self.users)
invalid_data = {
"first_name": "Casper",
"last_name": "Canterville",
"email": "",
"password": "dummy",
}
request = self.factory.post(
reverse("v1:user-list"),
data=invalid_data,
REMOTE_ADDR='2.16.92.0'
)
user_detail_view = UserViewSet.as_view({"post": "create"})
response = user_detail_view(request)
self.assertEqual(status.HTTP_400_BAD_REQUEST, response.status_code)
users_count = User.objects.count()
self.assertEqual(initial_users_count, users_count)
def test_post_user_when_data_valid_but_email_already_used_should_not_create_user_and_reply_400(self):
initial_users_count = len(self.users)
valid_data_with_used_email = {
"first_name": "Casper",
"last_name": "Canterville",
"email": "riri.duck@ricardo.ch",
"password": "dummy",
}
request = self.factory.post(
reverse("v1:user-list"),
data=valid_data_with_used_email,
REMOTE_ADDR='2.16.92.0'
)
user_detail_view = UserViewSet.as_view({"post": "create"})
response = user_detail_view(request)
self.assertEqual(status.HTTP_400_BAD_REQUEST, response.status_code)
new_users_count = User.objects.count()
self.assertEqual(initial_users_count, new_users_count)
def test_post_user_when_IP_not_in_Switzerland_should_not_create_user_and_reply_403(self):
initial_users_count = len(self.users)
valid_data = {
"first_name": "Casper",
"last_name": "Canterville",
"email": "c@sper.com",
"password": "dummy",
}
request = self.factory.post(
reverse("v1:user-list"),
data=valid_data,
REMOTE_ADDR='2.16.8.0' # Spain
)
user_detail_view = UserViewSet.as_view({"post": "create"})
response = user_detail_view(request)
self.assertEqual(status.HTTP_403_FORBIDDEN, response.status_code)
self.assertTrue(len(response.data['detail']) > 0)
users_count = User.objects.count()
self.assertEqual(initial_users_count, users_count)
class UpdateSinglUserTest(UsersApiTestCase):
""" Test PUT|PATCH /api/v1/user/:id """
def test_patch_user_when_id_valid_should_patch_user_and_reply_200(self):
riri = User.objects.create(
first_name="Riri", last_name="Duck", email="riri.duck@ricardo.ch", password="dummy")
request = self.factory.patch(
reverse("v1:user-detail", kwargs={"pk": riri.pk}),
data={"email": "riri@ricardo.ch"}
)
user_detail_view = UserViewSet.as_view({"patch": "partial_update"})
response = user_detail_view(request, pk=riri.pk)
self.assertEqual(status.HTTP_200_OK, response.status_code)
def test_patch_user_when_id_invalid_should_not_patch_user_and_reply_404(self):
riri = User.objects.create(
first_name="Riri", last_name="Duck", email="riri.duck@ricardo.ch", password="dummy")
request = self.factory.patch(
reverse("v1:user-detail", kwargs={"pk": 100}),
data={"email": "riri@ricardo.ch"}
)
user_detail_view = UserViewSet.as_view({"patch": "partial_update"})
response = user_detail_view(request, pk=100)
self.assertEqual(status.HTTP_404_NOT_FOUND, response.status_code)
def test_put_when_invalid_data_should_not_update_user_and_reply_400(self):
riri = User.objects.create(
first_name="Riri", last_name="Duck", email="riri.duck@ricardo.ch", password="dummy")
invalid_payload = {
"first_name": "",
"last_name": "Duck",
"email": "riri.duck@ricardo.ch"
}
request = self.factory.put(
reverse("v1:user-detail", kwargs={"pk": riri.pk}),
data=invalid_payload
)
user_detail_view = UserViewSet.as_view({"put": "update"})
response = user_detail_view(request, pk=riri.pk)
self.assertEqual(status.HTTP_400_BAD_REQUEST, response.status_code)
class DeleteSinglePuppyTest(UsersApiTestCase):
""" Test DELETE /api/v1/user/:id """
def test_delete_user_when_id_valid_should_delete_user_and_reply_204(self):
initial_users_count = len(self.users)
user_to_delete = self.users[0]
request = self.factory.delete(reverse("v1:user-detail", kwargs={"pk": user_to_delete.pk}))
user_detail_view = UserViewSet.as_view({"delete": "destroy"})
response = user_detail_view(request, pk=user_to_delete.pk)
self.assertEqual(status.HTTP_204_NO_CONTENT, response.status_code)
new_users_count = User.objects.count()
self.assertEqual(initial_users_count-1, new_users_count)
def test_delete_user_when_id_invalid_should_reply_404(self):
request = self.factory.delete(reverse("v1:user-detail", kwargs={"pk": 100}))
user_detail_view = UserViewSet.as_view({"delete": "destroy"})
response = user_detail_view(request, pk=100)
self.assertEqual(status.HTTP_404_NOT_FOUND, response.status_code)
| 39.052846 | 108 | 0.65192 | 1,183 | 9,607 | 5.001691 | 0.125951 | 0.049011 | 0.052053 | 0.046138 | 0.756126 | 0.72148 | 0.659456 | 0.62819 | 0.606726 | 0.597938 | 0 | 0.020105 | 0.228583 | 9,607 | 245 | 109 | 39.212245 | 0.778303 | 0.054231 | 0 | 0.522727 | 0 | 0 | 0.108754 | 0.002444 | 0 | 0 | 0 | 0 | 0.125 | 1 | 0.079545 | false | 0.0625 | 0.045455 | 0 | 0.164773 | 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 | 0 | 0 | 0 | 0 | 0 | 2 |
791fc2d140f54e02c2b4d1000be7565797957857 | 136 | py | Python | gtf2bed/__init__.py | jvfe/gtf2bed | 7ac21759498ca9495030982d2a11c2a63149a75c | [
"BSD-3-Clause"
] | 1 | 2021-04-22T09:27:35.000Z | 2021-04-22T09:27:35.000Z | gtf2bed/__init__.py | jvfe/gtf2bed | 7ac21759498ca9495030982d2a11c2a63149a75c | [
"BSD-3-Clause"
] | null | null | null | gtf2bed/__init__.py | jvfe/gtf2bed | 7ac21759498ca9495030982d2a11c2a63149a75c | [
"BSD-3-Clause"
] | null | null | null | """Top-level package for gtf2bed."""
__author__ = """João Vitor F. Cavalcante"""
__email__ = "jvfecav@gmail.com"
__version__ = "0.1.0"
| 22.666667 | 43 | 0.683824 | 18 | 136 | 4.5 | 0.944444 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0.033613 | 0.125 | 136 | 5 | 44 | 27.2 | 0.647059 | 0.220588 | 0 | 0 | 0 | 0 | 0.46 | 0 | 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 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 2 |
7922c3c12c906f5e3ff236bb30e73bcdb61a9ea9 | 477 | py | Python | setup.py | samytessier/group_9_mlops | 774f69354aeb5a9ddb59eb2cf5f8460832ab21b2 | [
"MIT"
] | 1 | 2022-01-20T02:18:16.000Z | 2022-01-20T02:18:16.000Z | setup.py | samytessier/group_9_mlops | 774f69354aeb5a9ddb59eb2cf5f8460832ab21b2 | [
"MIT"
] | 1 | 2022-01-08T17:18:04.000Z | 2022-01-08T17:18:04.000Z | setup.py | samytessier/group_9_mlops | 774f69354aeb5a9ddb59eb2cf5f8460832ab21b2 | [
"MIT"
] | null | null | null | from setuptools import find_packages, setup
setup(
name='src',
packages=find_packages(),
version='0.1.0',
description='This MLOps project aims to use the Transformers framework from Hugging Face in order to tweak a pre-trained NLP model to accurately gauge the sentiment of an Amazon review (being able to guess the whether the rating of a product is positive or negative given only the text in a review).',
author='group9 DTU MLops',
license='MIT',
)
| 43.363636 | 305 | 0.742138 | 75 | 477 | 4.693333 | 0.746667 | 0.068182 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0.010336 | 0.188679 | 477 | 10 | 306 | 47.7 | 0.899225 | 0 | 0 | 0 | 0 | 0.111111 | 0.656184 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | true | 0 | 0.111111 | 0 | 0.111111 | 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 | 1 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 2 |
7926794343cfee2a3a93c437f389f8d256dd16f9 | 320 | py | Python | Community/get_audit_info/__init__.py | spenney-bc/gateway-workflows | 0311a9224b2d53c01689eb6a9a0a593177abed63 | [
"Apache-2.0"
] | 43 | 2017-12-04T17:38:24.000Z | 2021-12-29T09:17:17.000Z | Community/get_audit_info/__init__.py | spenney-bc/gateway-workflows | 0311a9224b2d53c01689eb6a9a0a593177abed63 | [
"Apache-2.0"
] | 49 | 2017-12-07T21:02:29.000Z | 2022-02-04T22:27:16.000Z | Community/get_audit_info/__init__.py | spenney-bc/gateway-workflows | 0311a9224b2d53c01689eb6a9a0a593177abed63 | [
"Apache-2.0"
] | 82 | 2017-12-04T17:56:00.000Z | 2021-12-29T09:17:21.000Z | # Copyright 2020 BlueCat Networks. All rights reserved.
# -*- coding: utf-8 -*-
type = 'ui'
sub_pages = [
{
'name' : 'get_audit_info_page',
'title' : u'Get Audit Info',
'endpoint' : 'get_audit_info/get_audit_info_endpoint',
'description' : u'get_audit_info'
},
]
| 24.615385 | 65 | 0.56875 | 37 | 320 | 4.621622 | 0.621622 | 0.233918 | 0.350877 | 0.152047 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0.022026 | 0.290625 | 320 | 12 | 66 | 26.666667 | 0.731278 | 0.234375 | 0 | 0 | 0 | 0 | 0.475207 | 0.157025 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | false | 0 | 0 | 0 | 0 | 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 | 0 | 0 | 0 | 2 |
792b96690a5711f347a2fe1364e3eef792d1ebea | 1,393 | py | Python | corehq/apps/commtrack/resources/v0_1.py | johan--/commcare-hq | 86ee99c54f55ee94e4c8f2f6f30fc44e10e69ebd | [
"BSD-3-Clause"
] | null | null | null | corehq/apps/commtrack/resources/v0_1.py | johan--/commcare-hq | 86ee99c54f55ee94e4c8f2f6f30fc44e10e69ebd | [
"BSD-3-Clause"
] | 1 | 2022-03-12T01:03:25.000Z | 2022-03-12T01:03:25.000Z | corehq/apps/commtrack/resources/v0_1.py | johan--/commcare-hq | 86ee99c54f55ee94e4c8f2f6f30fc44e10e69ebd | [
"BSD-3-Clause"
] | null | null | null | from tastypie import fields
from corehq.apps.api.resources.v0_1 import CustomResourceMeta, DomainAdminAuthentication
from corehq.apps.products.models import Product
from corehq.apps.api.util import get_object_or_not_exist
from corehq.apps.api.resources import HqBaseResource
"""
Implementation of the CommCare Supply APIs. For more information see:
https://confluence.dimagi.com/display/lmis/API
"""
class ProductResource(HqBaseResource):
type = "product"
id = fields.CharField(attribute='_id', readonly=True, unique=True)
code = fields.CharField(attribute='code', readonly=True, unique=True)
name = fields.CharField(attribute='name', readonly=True)
unit = fields.CharField(attribute='unit', readonly=True, null=True)
description = fields.CharField(attribute='description', readonly=True, null=True)
category = fields.CharField(attribute='category', readonly=True, null=True)
last_modified = fields.DateTimeField(attribute='last_modified', readonly=True, null=True)
# TODO:
# price?
def obj_get(self, request, **kwargs):
return get_object_or_not_exist(Product, kwargs['pk'], kwargs['domain'])
def obj_get_list(self, request, **kwargs):
return Product.by_domain(kwargs['domain'])
class Meta(CustomResourceMeta):
authentication = DomainAdminAuthentication()
resource_name = 'product'
limit = 0
| 36.657895 | 93 | 0.740847 | 166 | 1,393 | 6.114458 | 0.439759 | 0.082759 | 0.141872 | 0.078818 | 0.08867 | 0 | 0 | 0 | 0 | 0 | 0 | 0.002521 | 0.145729 | 1,393 | 37 | 94 | 37.648649 | 0.85042 | 0.008615 | 0 | 0 | 0 | 0 | 0.059856 | 0 | 0 | 0 | 0 | 0.027027 | 0 | 1 | 0.090909 | false | 0 | 0.227273 | 0.090909 | 0.863636 | 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 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 2 |
7937d7c40eebe24b6b2fbdc5b2fcb247cedd3bed | 1,211 | py | Python | lesson-12/ex1.py | alirsamar/intro-ml | 36450b26b7ea09472ccdd2a0abce51b6c3889a20 | [
"MIT"
] | null | null | null | lesson-12/ex1.py | alirsamar/intro-ml | 36450b26b7ea09472ccdd2a0abce51b6c3889a20 | [
"MIT"
] | null | null | null | lesson-12/ex1.py | alirsamar/intro-ml | 36450b26b7ea09472ccdd2a0abce51b6c3889a20 | [
"MIT"
] | null | null | null | # Explained Variance of Each PC
#### Boilerplate #################################################################
print __doc__
from time import time
import logging
import pylab as pl
import numpy as np
from sklearn.cross_validation import train_test_split
from sklearn.datasets import fetch_lfw_people
from sklearn.grid_search import GridSearchCV
from sklearn.metrics import classification_report
from sklearn.metrics import confusion_matrix
from sklearn.decomposition import RandomizedPCA
from sklearn.svm import SVC
logging.basicConfig(level=logging.INFO, format='%(asctime)s %(message)s')
lfw_people = fetch_lfw_people(min_faces_per_person=70, resize=0.4)
n_samples, h, w = lfw_people.images.shape
np.random.seed(42)
X = lfw_people.data
n_features = X.shape[1]
y = lfw_people.target
target_names = lfw_people.target_names
n_classes = target_names.shape[0]
X_train, X_test, y_train, y_test = train_test_split(X, y, test_size=0.25, random_state=42)
n_components = 150
t0 = time()
pca = RandomizedPCA(n_components=n_components, whiten=True).fit(X_train)
#### Exercise code #############################################################
print "Variance ratio:"
print pca.explained_variance_ratio_
| 26.911111 | 90 | 0.720066 | 171 | 1,211 | 4.847953 | 0.491228 | 0.092883 | 0.033776 | 0.057901 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0.015625 | 0.101569 | 1,211 | 44 | 91 | 27.522727 | 0.746324 | 0.046243 | 0 | 0 | 0 | 0 | 0.037328 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | null | null | 0 | 0.407407 | null | null | 0.111111 | 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 | 1 | 0 | 0 | 0 | 1 | 0 | 0 | 0 | 0 | 2 |
793dd777651fda3f7f0226048a22a03099d8826c | 2,110 | py | Python | {{ cookiecutter.project_name|replace(' ', '_')|replace('-', '_')|lower }}/project/apps/users/views.py | digitalashes/django2.0-template | 4387c25fb94cbff4f201b279f2eefcb174658eff | [
"Apache-2.0"
] | 1 | 2018-03-13T21:16:49.000Z | 2018-03-13T21:16:49.000Z | {{ cookiecutter.project_name|replace(' ', '_')|replace('-', '_')|lower }}/project/apps/users/views.py | digitalashes/django2.0-template | 4387c25fb94cbff4f201b279f2eefcb174658eff | [
"Apache-2.0"
] | null | null | null | {{ cookiecutter.project_name|replace(' ', '_')|replace('-', '_')|lower }}/project/apps/users/views.py | digitalashes/django2.0-template | 4387c25fb94cbff4f201b279f2eefcb174658eff | [
"Apache-2.0"
] | null | null | null | {%- if cookiecutter.use_allauth == "y" and cookiecutter.use_rest == "y" %}
from django.contrib.auth import logout as auth_logout
from django.core.exceptions import ObjectDoesNotExist
from django.utils.translation import ugettext_lazy as _
from rest_auth.app_settings import create_token
from rest_auth.registration.views import RegisterView as RegisterViewBase
from rest_auth.views import PasswordChangeView as BasePasswordChangeView
from rest_framework import status
from rest_framework.permissions import AllowAny, IsAuthenticated
from rest_framework.response import Response
from rest_framework.views import APIView
from users.jwt import jwt_response_payload_handler
class RegisterApiView(RegisterViewBase):
"""
Generic user registration.
"""
http_method_names = ('post', 'head', 'options')
permission_classes = (AllowAny,)
def get_response_data(self, user):
token = create_token(user)
data = jwt_response_payload_handler(token, user)
return data
class LogoutApiView(APIView):
"""
Calls Django logout method and delete the Token object
assigned to the current User object.
Accepts/Returns nothing.
"""
http_method_names = ('post', 'head', 'options')
permission_classes = (AllowAny,)
def post(self, request):
return self.logout(request)
def logout(self, request):
try:
request.user.auth_token.delete()
except (AttributeError, ObjectDoesNotExist):
pass
auth_logout(request)
return Response({'detail': _('Successfully logged out.')}, status=status.HTTP_200_OK)
class PasswordChangeApiView(BasePasswordChangeView):
"""
Calls Django Auth SetPasswordForm save method.
Accepts the following POST parameters: old_password, new_password1, new_password2
Returns the success/fail message.
"""
http_method_names = ('post', 'head', 'options')
permission_classes = (IsAuthenticated,)
registration = RegisterApiView.as_view()
logout = LogoutApiView.as_view()
password_change = PasswordChangeApiView.as_view()
{%- endif %}
| 27.763158 | 93 | 0.734597 | 238 | 2,110 | 6.327731 | 0.407563 | 0.037185 | 0.045153 | 0.037849 | 0.108234 | 0.108234 | 0.108234 | 0.108234 | 0.077025 | 0.077025 | 0 | 0.002894 | 0.181043 | 2,110 | 75 | 94 | 28.133333 | 0.868634 | 0 | 0 | 0.131579 | 0 | 0 | 0.044329 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | null | null | 0.105263 | 0.289474 | null | null | 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 | 1 | 0 | 0 | 1 | 0 | 0 | 0 | 0 | 0 | 2 |
f70474925eb078c598d03d4255e4e76e7b6c9361 | 420 | py | Python | examples/function_examples/bpod_info.py | ckarageorgkaneen/pybpod-api | ebccef800ae1abf3b6a643ff33166fab2096c780 | [
"MIT"
] | 1 | 2021-01-18T08:18:22.000Z | 2021-01-18T08:18:22.000Z | examples/function_examples/bpod_info.py | ckarageorgkaneen/pybpod-api | ebccef800ae1abf3b6a643ff33166fab2096c780 | [
"MIT"
] | 1 | 2020-09-18T20:46:11.000Z | 2020-12-29T14:55:20.000Z | examples/function_examples/bpod_info.py | ckarageorgkaneen/pybpod-api | ebccef800ae1abf3b6a643ff33166fab2096c780 | [
"MIT"
] | 3 | 2020-09-12T15:32:11.000Z | 2022-03-11T23:08:03.000Z | # !/usr/bin/python3
# -*- coding: utf-8 -*-
"""
Get hardware info from Bpod
"""
from pybpodapi.protocol import Bpod
from confapp import conf
my_bpod = Bpod()
my_bpod.close()
print("Target Bpod firmware version: ", conf.TARGET_BPOD_FIRMWARE_VERSION)
print("Firmware version (read from device): ", my_bpod.hardware.firmware_version)
print("Machine type version (read from device): ", my_bpod.hardware.machine_type)
| 21 | 81 | 0.742857 | 59 | 420 | 5.135593 | 0.440678 | 0.079208 | 0.118812 | 0.165017 | 0.231023 | 0.231023 | 0.231023 | 0 | 0 | 0 | 0 | 0.005464 | 0.128571 | 420 | 19 | 82 | 22.105263 | 0.822404 | 0.161905 | 0 | 0 | 0 | 0 | 0.315789 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | false | 0 | 0.285714 | 0 | 0.285714 | 0.428571 | 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 | 0 | 0 | 0 | 1 | 0 | 2 |
f70e20602d9329f0b785241b32a1ae744bf6d702 | 119 | py | Python | number reverser.py | Jayapraveen34/crazy-lover | be5bd897c40c31b3e5e6eafe3b6436cb3d888efe | [
"BSD-2-Clause"
] | null | null | null | number reverser.py | Jayapraveen34/crazy-lover | be5bd897c40c31b3e5e6eafe3b6436cb3d888efe | [
"BSD-2-Clause"
] | null | null | null | number reverser.py | Jayapraveen34/crazy-lover | be5bd897c40c31b3e5e6eafe3b6436cb3d888efe | [
"BSD-2-Clause"
] | null | null | null | a = str(input('Enter the number you want to reverse:'))
b = (a[::-1])
c = int(b)
print('the reversed number is',c)
| 23.8 | 56 | 0.605042 | 22 | 119 | 3.272727 | 0.772727 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0.010417 | 0.193277 | 119 | 4 | 57 | 29.75 | 0.739583 | 0 | 0 | 0 | 0 | 0 | 0.513043 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | false | 0 | 0 | 0 | 0 | 0.25 | 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 | 0 | 0 | 0 | 2 |
f719bed52604d78cd372c38b0ba41bc4f013d7b2 | 311 | py | Python | routes/show_bp.py | Silve1ra/fyyur | 580562cc592d587c9bed4f080b856664abb9f70d | [
"MIT"
] | 1 | 2021-09-17T11:56:38.000Z | 2021-09-17T11:56:38.000Z | routes/show_bp.py | Silve1ra/fyyur | 580562cc592d587c9bed4f080b856664abb9f70d | [
"MIT"
] | null | null | null | routes/show_bp.py | Silve1ra/fyyur | 580562cc592d587c9bed4f080b856664abb9f70d | [
"MIT"
] | null | null | null | from flask import Blueprint
from controllers.show import shows, create_shows, create_show_submission
show_bp = Blueprint('show_bp', __name__)
show_bp.route('/', methods=['GET'])(shows)
show_bp.route('/create', methods=['GET'])(create_shows)
show_bp.route('/create', methods=['POST'])(create_show_submission)
| 31.1 | 72 | 0.762058 | 43 | 311 | 5.162791 | 0.348837 | 0.135135 | 0.148649 | 0.144144 | 0.261261 | 0.261261 | 0 | 0 | 0 | 0 | 0 | 0 | 0.073955 | 311 | 9 | 73 | 34.555556 | 0.770833 | 0 | 0 | 0 | 0 | 0 | 0.102894 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | false | 0 | 0.333333 | 0 | 0.333333 | 0.333333 | 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 | 0 | 0 | 0 | 2 |
f71b20c6a58525d0ad6e5a5b0ad92dbbdf9f5849 | 1,599 | py | Python | user/tests.py | Vr3n/django_react_cart_system | f6d2572b640f711ff9c7020641051e3f92c3dd59 | [
"MIT"
] | null | null | null | user/tests.py | Vr3n/django_react_cart_system | f6d2572b640f711ff9c7020641051e3f92c3dd59 | [
"MIT"
] | 3 | 2021-06-18T15:13:46.000Z | 2021-06-18T18:24:43.000Z | user/tests.py | Vr3n/django_react_cart_system | f6d2572b640f711ff9c7020641051e3f92c3dd59 | [
"MIT"
] | null | null | null | from django.contrib.auth import get_user_model
from django.test import TestCase
# Create your tests here.
class UserManagersTests(TestCase):
def test_create_user(self):
User = get_user_model()
user = User.objects.create_user(
email="normal@user.com", password="testing@123")
self.assertEqual(user.email, 'normal@user.com')
self.assertTrue(user.is_active)
self.assertFalse(user.is_staff)
self.assertFalse(user.is_superuser)
try:
self.assertIsNotNone(user.username)
self.assertIsNotNone(user.email)
except AttributeError:
pass
with self.assertRaises(TypeError):
User.objects.create_user()
with self.assertRaises(TypeError):
User.objects.create_user(email='')
with self.assertRaises(ValueError):
User.objects.create_user(email='', password="testing@123")
def test_create_superuser(self):
User = get_user_model()
admin = User.objects.create_superuser(
email="admin@user.com", password="testing@123")
self.assertEqual(admin.email, 'admin@user.com')
self.assertTrue(admin.is_active)
self.assertTrue(admin.is_staff)
self.assertTrue(admin.is_superuser)
try:
self.assertIsNotNone(admin.username)
self.assertIsNotNone(admin.email)
except AttributeError:
pass
with self.assertRaises(ValueError):
User.objects.create_user(
email='', password="testing@123", is_superuser=False)
| 34.76087 | 70 | 0.642276 | 174 | 1,599 | 5.770115 | 0.252874 | 0.059761 | 0.101594 | 0.104582 | 0.548805 | 0.384462 | 0.384462 | 0.247012 | 0.14741 | 0.14741 | 0 | 0.010067 | 0.254534 | 1,599 | 45 | 71 | 35.533333 | 0.832215 | 0.014384 | 0 | 0.315789 | 0 | 0 | 0.064803 | 0 | 0 | 0 | 0 | 0 | 0.421053 | 1 | 0.052632 | false | 0.157895 | 0.052632 | 0 | 0.131579 | 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 | 1 | 0 | 0 | 0 | 1 | 0 | 0 | 0 | 0 | 0 | 2 |
f735f8fc14c7fe9404c2a5d90d59491063b15f84 | 1,539 | py | Python | pygna/cli.py | Gee-3/pygna | 61f2128e918e423fef73d810e0c3af5761933096 | [
"MIT"
] | 32 | 2019-07-11T22:58:14.000Z | 2022-03-04T19:34:55.000Z | pygna/cli.py | Gee-3/pygna | 61f2128e918e423fef73d810e0c3af5761933096 | [
"MIT"
] | 3 | 2021-05-24T14:03:13.000Z | 2022-01-07T03:47:32.000Z | pygna/cli.py | Gee-3/pygna | 61f2128e918e423fef73d810e0c3af5761933096 | [
"MIT"
] | 5 | 2019-07-24T09:38:07.000Z | 2021-12-30T09:20:20.000Z | import logging
import argh
import pygna.command as cmd
import pygna.painter as paint
import pygna.utils as utils
import pygna.block_model as bm
import pygna.degree_model as dm
"""
autodoc
"""
logging.basicConfig(level=logging.INFO)
def main():
argh.dispatch_commands([
# network summary and graph file
cmd.network_summary,
cmd.network_graphml,
cmd.get_connected_components,
# geneset network topology analyses
cmd.test_topology_total_degree,
cmd.test_topology_internal_degree,
cmd.test_topology_module,
cmd.test_topology_sp,
cmd.test_topology_rwr,
cmd.test_diffusion_hotnet,
# comparison analysis
cmd.test_association_sp,
cmd.test_association_rwr,
# building functions
cmd.build_distance_matrix,
cmd.build_rwr_diffusion,
# paint
paint.paint_datasets_stats,
paint.paint_comparison_matrix,
paint.plot_adjacency,
paint.paint_volcano_plot,
paint.paint_summary_gnt,
# utils
utils.convert_gmt,
utils.geneset_from_table,
utils.convert_csv,
utils.generate_group_gmt,
# simulations
bm.generate_gnt_sbm,
bm.generate_gna_sbm,
dm.generate_hdn_network,
bm.generate_sbm_network,
bm.generate_sbm2_network,
dm.hdn_add_partial,
dm.hdn_add_extended,
dm.hdn_add_branching,
], )
if __name__ == "__main__":
"""
MAIN
"""
main()
| 23.676923 | 43 | 0.654321 | 180 | 1,539 | 5.216667 | 0.416667 | 0.059638 | 0.079872 | 0.044728 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0.000899 | 0.277453 | 1,539 | 64 | 44 | 24.046875 | 0.843525 | 0.082521 | 0 | 0 | 0 | 0 | 0.005844 | 0 | 0 | 0 | 0 | 0.015625 | 0 | 1 | 0.023256 | true | 0 | 0.162791 | 0 | 0.186047 | 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 | 1 | 0 | 0 | 0 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 2 |
f74471527dea41ff8d2f932ecbb41c7a4779f9c6 | 894 | py | Python | native/release/test.py | ncbray/pystream | 70bba5646d6512adb6803564c22268d3424c66d8 | [
"Apache-2.0"
] | 6 | 2015-09-19T18:22:33.000Z | 2020-11-29T15:21:17.000Z | native/release/test.py | ncbray/pystream | 70bba5646d6512adb6803564c22268d3424c66d8 | [
"Apache-2.0"
] | 1 | 2015-08-04T08:03:46.000Z | 2015-08-04T08:03:46.000Z | native/release/test.py | ncbray/pystream | 70bba5646d6512adb6803564c22268d3424c66d8 | [
"Apache-2.0"
] | 1 | 2019-12-09T08:27:09.000Z | 2019-12-09T08:27:09.000Z | # Copyright 2011 Nicholas Bray
#
# 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 time
import pybind
a = pybind.vec3(1.0, 2.0, 3.0)
b = pybind.vec3(2.0, 1.0, 3.0)
def dot(a, b):
return a.x*b.x+a.y*b.y+a.z*b.z
def dummy(a, b):
pass
def test(f):
start = time.clock()
for i in range(1000000):
f(a, b)
return time.clock()-start
t1 = test(pybind.dot)
t2 = test(dummy)
print t1/t2
| 22.35 | 74 | 0.710291 | 162 | 894 | 3.919753 | 0.54321 | 0.094488 | 0.040945 | 0.050394 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0.044959 | 0.178971 | 894 | 39 | 75 | 22.923077 | 0.820163 | 0.615213 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | null | null | 0.0625 | 0.125 | null | null | 0.0625 | 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 | 1 | 0 | 0 | 1 | 0 | 0 | 0 | 0 | 0 | 2 |
f74b23abf6614d599940d2f82ff8df5980edce4e | 378 | py | Python | nmutant_model/retrain_mu_test0.py | asplos2020/DRTest | c3de497142d9b226e518a1a0f95f7350d2f7acd6 | [
"MIT"
] | 1 | 2021-04-01T07:31:17.000Z | 2021-04-01T07:31:17.000Z | nmutant_model/retrain_mu_test0.py | Justobe/DRTest | 85c3c9b2a46cafa7184130f2596c5f9eb3b20bff | [
"MIT"
] | null | null | null | nmutant_model/retrain_mu_test0.py | Justobe/DRTest | 85c3c9b2a46cafa7184130f2596c5f9eb3b20bff | [
"MIT"
] | 1 | 2020-12-24T12:12:54.000Z | 2020-12-24T12:12:54.000Z | import os
import numpy as np
import sys
sys.path.append("../")
for model in ['lenet1', 'lenet4', 'lenet5']:
for attack in ['fgsm', 'cw', 'jsma']:
for mu_var in ['gf', 'nai', 'ns', 'ws']:
os.system('CUDA_VISIBLE_DEVICES=0 python retrain_mu_mnist.py --datasets=mnist --attack=' + attack + ' --model_name=' + model + ' --mu_var=' + mu_var + ' --epochs=50') | 42 | 178 | 0.600529 | 55 | 378 | 3.981818 | 0.672727 | 0.068493 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0.019608 | 0.190476 | 378 | 9 | 178 | 42 | 0.696078 | 0 | 0 | 0 | 0 | 0 | 0.401055 | 0.058047 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | false | 0 | 0.375 | 0 | 0.375 | 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 | 0 | 0 | 0 | 2 |
f75e9b9f00f9f84646e14e8f9e1b2be7266630e1 | 365 | py | Python | fate/labeling/txt.py | Mattias1/fate | 10266406336bc4c683ff5b23af32ac3447f7f054 | [
"MIT"
] | null | null | null | fate/labeling/txt.py | Mattias1/fate | 10266406336bc4c683ff5b23af32ac3447f7f054 | [
"MIT"
] | null | null | null | fate/labeling/txt.py | Mattias1/fate | 10266406336bc4c683ff5b23af32ac3447f7f054 | [
"MIT"
] | null | null | null | import re
from .common import regex_labels, re_number, re_string
keywords = ['TODO']
re_keyword = re.compile(r'\b({})\b'.format('|'.join(keywords)))
def init(document):
document.OnGenerateLabeling.add(main)
def main(document):
regex_list = [(re_keyword, 'keyword'), (re_number, 'number'), (re_string, 'string')]
regex_labels(document, regex_list)
| 22.8125 | 88 | 0.70137 | 49 | 365 | 5.020408 | 0.469388 | 0.089431 | 0.113821 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0.128767 | 365 | 15 | 89 | 24.333333 | 0.773585 | 0 | 0 | 0 | 1 | 0 | 0.087671 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0.222222 | false | 0 | 0.222222 | 0 | 0.444444 | 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 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 2 |
f7603cc1049048de6e8b2c24b0acac1e2d8f0746 | 490 | py | Python | Conteudo das Aulas/146/cgi-bin/cgi4_css_2.py | cerberus707/lab-python | ebba3c9cde873d70d4bb61084f79ce30b7f9e047 | [
"Apache-2.0"
] | null | null | null | Conteudo das Aulas/146/cgi-bin/cgi4_css_2.py | cerberus707/lab-python | ebba3c9cde873d70d4bb61084f79ce30b7f9e047 | [
"Apache-2.0"
] | null | null | null | Conteudo das Aulas/146/cgi-bin/cgi4_css_2.py | cerberus707/lab-python | ebba3c9cde873d70d4bb61084f79ce30b7f9e047 | [
"Apache-2.0"
] | null | null | null | #!/usr/bin/env python
import cgitb; cgitb.enable()
print('Content-type: text/html\n')
print(
"""<html>
<head>
<title>CGI 4 - CSS</title>
<link rel="stylesheet" type="text/css" href="../css/estilo1.css">
</head>
<body>
<h1>Colocando CSS em um script a parte</h1>
<hr>
<p>Ola imagens CGI!</p>
<div class="wraptocenter">
<img id="imagem" src="../imagens/evil.jpg" border=1 alt="Piadinha idiota" width=350 height=500>
</div>
<hr>
</body>
</html>
"""
)
| 18.846154 | 101 | 0.604082 | 72 | 490 | 4.111111 | 0.736111 | 0.054054 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0.027431 | 0.181633 | 490 | 25 | 102 | 19.6 | 0.710723 | 0.040816 | 0 | 0 | 0 | 0 | 0.316456 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | true | 0 | 0.25 | 0 | 0.25 | 0.5 | 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 | 0 | 0 | 0 | 1 | 0 | 2 |
f77623537e19394a7aca74fbc25bffc73cb1952f | 584 | py | Python | Dataset/Leetcode/train/125/245.py | kkcookies99/UAST | fff81885aa07901786141a71e5600a08d7cb4868 | [
"MIT"
] | null | null | null | Dataset/Leetcode/train/125/245.py | kkcookies99/UAST | fff81885aa07901786141a71e5600a08d7cb4868 | [
"MIT"
] | null | null | null | Dataset/Leetcode/train/125/245.py | kkcookies99/UAST | fff81885aa07901786141a71e5600a08d7cb4868 | [
"MIT"
] | null | null | null | class Solution:
def XXX(self, s: str) -> bool:
i=0
j = len(s)-1
#lower()把所有大写字母改成小写,其余不变
s = s.lower()
while i<j:
while not(97 <= ord(s[i]) <= 122 or 48 <= ord(s[i]) <= 57):
if i == j:
return True
i += 1
while not(97 <= ord(s[j]) <= 122 or 48 <= ord(s[j]) <= 57):
if i == j:
return True
j -= 1
if s[i] != s[j]:
return False
i += 1
j -= 1
return True
| 26.545455 | 71 | 0.332192 | 76 | 584 | 2.552632 | 0.368421 | 0.082474 | 0.103093 | 0.134021 | 0.42268 | 0.164948 | 0 | 0 | 0 | 0 | 0 | 0.086957 | 0.527397 | 584 | 21 | 72 | 27.809524 | 0.615942 | 0.039384 | 0 | 0.473684 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | null | null | 0 | 0 | null | null | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 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 | 2 |
f77cc067eb5667c5dadfdaf7622c60b024ae8bc5 | 2,004 | py | Python | rlo/test/rlo/test_factory.py | tomjaguarpaw/knossos-ksc | 8fa75e67c0db8f632b135379740051cd10ff31f2 | [
"MIT"
] | 31 | 2021-09-09T16:09:55.000Z | 2022-02-20T02:15:19.000Z | rlo/test/rlo/test_factory.py | tomjaguarpaw/knossos-ksc | 8fa75e67c0db8f632b135379740051cd10ff31f2 | [
"MIT"
] | 40 | 2021-08-06T14:30:08.000Z | 2022-01-19T08:49:52.000Z | rlo/test/rlo/test_factory.py | tomjaguarpaw/knossos-ksc | 8fa75e67c0db8f632b135379740051cd10ff31f2 | [
"MIT"
] | 5 | 2021-08-06T11:20:31.000Z | 2022-01-07T19:39:40.000Z | import pytest
from rlo import factory
@pytest.mark.parametrize("use_subtree_match_edges", [True, False])
@pytest.mark.parametrize("loss", ["pinball=0.6", "huber"])
def test_torch_model_from_config(use_subtree_match_edges, loss):
# Check we can construct a Model
config = {
"num_embeddings": 3,
"hidden_dim": 2,
"num_gnn_blocks": 5,
"output_hidden_dim": 2,
"simulation_depth_train": 10,
"lr": 0.01,
"loss": loss,
"repetition": 1,
"decoder_readout": "sum",
"graph_state_keep_prob": 0.9,
"output_keep_prob": 0.2,
"aggregation_over_edge_types": "sum",
"use_subtree_match_edges": use_subtree_match_edges,
}
factory.torch_model_from_config(config)
@pytest.mark.parametrize("use_subtree_match_edges", [True, False])
def test_torch_data_converter_from_config(use_subtree_match_edges):
# Check we can construct a DataConverter
config = {
"simulation_depth_train": 11,
"use_subtree_match_edges": use_subtree_match_edges,
"cost_normalization": "none",
}
factory.data_converter_from_config(config)
@pytest.mark.parametrize("use_subtree_match_edges", [True, False])
@pytest.mark.parametrize("loss", ["pinball=0.3", "huber"])
def test_torch_regressor_from_config(use_subtree_match_edges, loss):
# Check we can construct a TorchModelWrapper
config = {
"num_embeddings": 3,
"hidden_dim": 2,
"num_gnn_blocks": 5,
"output_hidden_dim": 2,
"lr": 0.01,
"loss": loss,
"repetition": 1,
"use_subtree_match_edges": use_subtree_match_edges,
"cost_normalization": "none",
"tensorflow": False,
"simulation_depth_eval": 10,
"decoder_readout": "sum",
"graph_state_keep_prob": 0.99,
"output_keep_prob": 0.2,
"aggregation_over_edge_types": "sum",
"simulation_depth_train": 10,
}
factory.single_regressor_from_config(config)
| 31.809524 | 68 | 0.657685 | 249 | 2,004 | 4.899598 | 0.285141 | 0.098361 | 0.147541 | 0.196721 | 0.731148 | 0.714754 | 0.690164 | 0.65082 | 0.559016 | 0.559016 | 0 | 0.023672 | 0.22006 | 2,004 | 62 | 69 | 32.322581 | 0.756878 | 0.055888 | 0 | 0.647059 | 0 | 0 | 0.334216 | 0.170021 | 0 | 0 | 0 | 0 | 0 | 1 | 0.058824 | false | 0 | 0.039216 | 0 | 0.098039 | 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 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 2 |
f78287f3fba8bcf7a557dbad608ff12faa053899 | 687 | py | Python | tests/test_gpcontrolset.py | waider/gopro-py-api | b18b5458f5bbe689f468842d6888104317786de8 | [
"MIT"
] | 1 | 2019-05-06T21:48:54.000Z | 2019-05-06T21:48:54.000Z | tests/test_gpcontrolset.py | waider/gopro-py-api | b18b5458f5bbe689f468842d6888104317786de8 | [
"MIT"
] | null | null | null | tests/test_gpcontrolset.py | waider/gopro-py-api | b18b5458f5bbe689f468842d6888104317786de8 | [
"MIT"
] | null | null | null | from .conftest import GoProCameraTest
from socket import timeout
from urllib import error
class GpControlSetTest(GoProCameraTest):
def test_gp_control_set(self):
# on success, this is an empty json blob
self.responses['/gp/gpControl/setting/foo/bar'] = '{}'
assert '{}' == self.goprocam.gpControlSet('foo', 'bar')
def test_gp_control_set_error(self):
assert isinstance(self.goprocam.gpControlSet('foo', 'bar'),
error.HTTPError)
def test_gp_control_set_timeout(self):
self.responses['/gp/gpControl/setting/foo/bar'] = timeout()
assert isinstance(self.goprocam.gpControlSet('foo', 'bar'), timeout)
| 34.35 | 76 | 0.676856 | 81 | 687 | 5.604938 | 0.419753 | 0.066079 | 0.059471 | 0.105727 | 0.557269 | 0.365639 | 0.365639 | 0 | 0 | 0 | 0 | 0 | 0.202329 | 687 | 19 | 77 | 36.157895 | 0.828467 | 0.055313 | 0 | 0 | 0 | 0 | 0.123648 | 0.089645 | 0 | 0 | 0 | 0 | 0.230769 | 1 | 0.230769 | false | 0 | 0.230769 | 0 | 0.538462 | 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 | 0 | 1 | 0 | 0 | 2 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.