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 |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
ee004784a941d5d77b5b6e8ddb93e733ed381343 | 1,658 | py | Python | classifieds/tests/test_views/test_browse.py | hpunnoose01/finaltry | f5430486bccbb170392de192a265e67ffad78f39 | [
"BSD-3-Clause"
] | 21 | 2015-04-16T15:37:02.000Z | 2022-03-16T12:37:25.000Z | classifieds/tests/test_views/test_browse.py | hpunnoose01/finaltry | f5430486bccbb170392de192a265e67ffad78f39 | [
"BSD-3-Clause"
] | 3 | 2020-06-06T00:45:19.000Z | 2021-06-10T22:37:36.000Z | classifieds/tests/test_views/test_browse.py | hpunnoose01/finaltry | f5430486bccbb170392de192a265e67ffad78f39 | [
"BSD-3-Clause"
] | 15 | 2015-02-27T07:20:48.000Z | 2021-08-21T03:54:50.000Z | from django.test import TestCase
from django.core.urlresolvers import reverse
from classifieds.tests.test_views import FancyTestCase
class TestAdBrowsing(FancyTestCase):
fixtures = ['users', 'categories', 'ads']
def setUp(self):
self.client.login(username='user', password='user')
def test_view_ad_must_be_active(self):
response = self.get('classifieds_browse_ad_view', pk=1)
self.assertEqual(response.status_code, 404)
def test_cant_view_expired_ad_when_logged_out(self):
self.client.logout()
response = self.get('classifieds_browse_ad_view', pk=2)
self.assertEqual(response.status_code, 404)
def test_cant_view_expiered_ad_of_another_user(self):
self.client.logout()
self.client.login(username='other_user', password='user')
response = self.get('classifieds_browse_ad_view', pk=2)
self.assertEqual(response.status_code, 404)
def test_can_view_own_expired_ad(self):
response = self.get('classifieds_browse_ad_view', pk=2)
self.assertEqual(response.status_code, 200)
def test_unauthed_user_can_view_active_ad(self):
self.client.logout()
response = self.get('classifieds_browse_ad_view', pk=18)
self.assertEqual(response.status_code, 200)
def test_authed_user_can_view_active_ad(self):
response = self.get('classifieds_browse_ad_view', pk=18)
self.assertEqual(response.status_code, 200)
def test_category_overview_uses_template(self):
response = self.get('classifieds_browse_categories')
self.assertTemplateUsed(response, 'classifieds/category_overview.html')
| 37.681818 | 79 | 0.727986 | 216 | 1,658 | 5.268519 | 0.291667 | 0.043058 | 0.092267 | 0.15993 | 0.570299 | 0.570299 | 0.50703 | 0.50703 | 0.498243 | 0.459578 | 0 | 0.018895 | 0.170084 | 1,658 | 43 | 80 | 38.55814 | 0.80814 | 0 | 0 | 0.4375 | 0 | 0 | 0.156212 | 0.132087 | 0 | 0 | 0 | 0 | 0.21875 | 1 | 0.25 | false | 0.0625 | 0.09375 | 0 | 0.40625 | 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 |
ee06e2130c81b205dae91fe73662387dcbfe3fb2 | 206 | py | Python | ex049.py | PedroHPAlmeida/exercicios-Python-CEV | 81b0eeba1e2916f42821e738def1f25bced66fd9 | [
"MIT"
] | null | null | null | ex049.py | PedroHPAlmeida/exercicios-Python-CEV | 81b0eeba1e2916f42821e738def1f25bced66fd9 | [
"MIT"
] | null | null | null | ex049.py | PedroHPAlmeida/exercicios-Python-CEV | 81b0eeba1e2916f42821e738def1f25bced66fd9 | [
"MIT"
] | null | null | null | #entrada
n = int(input('Digite um número: '))
print('-=' * 5, f'TABUADA DO {n}', '-=' * 5)
#processamento & saida
for i in range(1, 11):
print(f' {n} x {i:>2} = {n * i:>2}')
print('-=' * 17)
| 22.888889 | 50 | 0.485437 | 33 | 206 | 3.030303 | 0.69697 | 0.04 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0.057692 | 0.242718 | 206 | 8 | 51 | 25.75 | 0.583333 | 0.135922 | 0 | 0 | 0 | 0 | 0.420455 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | false | 0 | 0 | 0 | 0 | 0.6 | 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 | 0 | 0 | 0 | 1 | 0 | 2 |
ee0932c335d360968e1955dbd2c8351506149082 | 1,991 | py | Python | substitutions.py | PythonIsMagic/octavia | 7161b3b2089c6fa142cc6633c55102d0b78ce0c7 | [
"WTFPL"
] | null | null | null | substitutions.py | PythonIsMagic/octavia | 7161b3b2089c6fa142cc6633c55102d0b78ce0c7 | [
"WTFPL"
] | null | null | null | substitutions.py | PythonIsMagic/octavia | 7161b3b2089c6fa142cc6633c55102d0b78ce0c7 | [
"WTFPL"
] | 1 | 2022-03-22T12:43:46.000Z | 2022-03-22T12:43:46.000Z | """
These are junk terms that commonly occur:
Variations: parentheses/brackets, uppercase, lowercase, or Title Style.
And with spaces or underscores
Ex: 'song' can come as:
[epilepsy warning], [EPILEPSY WARNING], [Epilepsy Warning]
[epilepsy_warning], [EPILEPSY_WARNING], [Epilepsy_Warning]
(epilepsy warning), (EPILEPSY WARNING), (Epilepsy Warning)
(epilepsy_warning), (EPILEPSY_WARNING), (Epilepsy_Warning)
This should cover a LOT of the junk that occurs, and any more specific stuff can be added to
JUNK
"""
KEYWORDS = [
'2011', '2012', '2013', '2014', '2015', '2016', '2017', '2018',
'1080P',
'AMV',
'Audio',
'Audio Only',
'CHIPTUNE 8-BIT',
'Cover',
'Cover Art',
'DRUM AND BASS',
'DUBSTEP',
'Drumstep',
'ELECTRO',
'EPILEPSY WARNING',
'EUROBEAT',
'EXPLICIT',
'FULL VERSION',
'Free DL',
'HARDSTYLE',
'HD',
'HOUSE',
'HQ',
'HQ+lyrics',
'LYRICS',
'LYRICS ON SCREEN',
'Lyric video',
'M-V',
'MV',
'MUSIC VIDEO',
'Monstercat Release',
'new album',
'Official Audio',
'Official Full Stream',
'OFFICIAL MUSIC VIDEO',
'OFFICIAL VIDEO HQ',
'OFFICIAL VIDEO',
'OFFICIAL VIDEOCLIP',
'OFFICIAL',
'OST',
'OUT NOW',
'PMV',
'SONG',
'ULTRA MUSIC',
'VIDEO VERSION',
'VIP',
'WIP',
'With Lyrics',
]
JUNK = [
'| MUSIC |',
'_ Music _ ',
'| HD',
' _ HD',
'EPILEPSY_WARNING!',
'+Lyrics',
'now on iTunes!',
]
SUBS = {
'MLP: FiM': 'MLP -',
'MLP -FiM': 'MLP -',
'My Little Pony - Friendship is Magic': 'MLP',
'My_little_Pony': 'MLP',
}
SANITIZATIONS = {
'_': ' ', # More readable for humans and media libraries
'(': '[', # Parentheses aren't linux friendly
')': ']',
'\\': ' ', # Slashes are not filename friendly
'/': ' ', # Slashes are not filename friendly
',': '',
'!': '',
'&': 'x', # Use x instead of &
'..': '.',
}
| 21.180851 | 92 | 0.549473 | 210 | 1,991 | 5.147619 | 0.580952 | 0.194265 | 0.234043 | 0.305273 | 0.227567 | 0.227567 | 0.166512 | 0.166512 | 0.166512 | 0.166512 | 0 | 0.025552 | 0.272727 | 1,991 | 93 | 93 | 21.408602 | 0.720994 | 0.345053 | 0 | 0 | 0 | 0 | 0.469814 | 0 | 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 |
ee11a2f92cc315b4a311cdd22f99d4794a4761e5 | 3,194 | py | Python | Comportamentais/Strategy/main.py | DionVitor/design_pattern | 6356e126abf32f74691010b45b2ffbc231b082ca | [
"MIT"
] | null | null | null | Comportamentais/Strategy/main.py | DionVitor/design_pattern | 6356e126abf32f74691010b45b2ffbc231b082ca | [
"MIT"
] | null | null | null | Comportamentais/Strategy/main.py | DionVitor/design_pattern | 6356e126abf32f74691010b45b2ffbc231b082ca | [
"MIT"
] | null | null | null | """Baseado no livro Python Fluente, Luciano Ramalho."""
from abc import ABC, abstractmethod
from collections import namedtuple
Customer = namedtuple('Customer', 'name fidelity')
a = namedtuple('int', 'name')
class LineItem:
def __init__(self, product, quantity, price):
self.__product = product
self.__quantity = quantity
self.__price = price
@property
def product(self):
return self.__product
@property
def quantity(self):
return self.__quantity
@property
def price(self):
return self.__price
def total(self):
return self.price * self.quantity
class Order:
def __init__(self, customer, cart, promotion=None):
self.__customer = customer
self.__cart = cart
self.__promotion = promotion
@property
def customer(self):
return self.__customer
@property
def cart(self):
return self.__cart
@property
def promotion(self):
return self.__promotion
def total(self):
if not hasattr(self, '__total'):
self.__total = sum(item.total() for item in self.cart)
return self.__total
def due(self):
if self.__promotion is None:
discount = 0
else:
discount = self.__promotion.discount(self)
return self.total() - discount
def __repr__(self):
return f'<Order by {self.customer.name}. Total: {self.total():.2f}, due: {self.due():.2f}>'
class Promotion(ABC): # Strategy: uma classe-base abstrata
@abstractmethod
def discount(self, order):
"""Devolver o desconto como um valor positivo em dólares"""
class FidelityPromo(Promotion): # Primeira estratégia concreta
"""5% de desconto para clientes com mil ou mais pontos no programa de fidelidade."""
def discount(self, order):
return order.total() * .05 if order.customer.fidelity >= 1000 else 0
class BulkItemPromo(Promotion): # Segunda estratégia concreta
"""10% de desconto para cada LineItem com 20 ou mais unidades"""
def discount(self, order):
discount = 0
for item in order.cart:
if item.quantity >= 20:
discount += item.total() * .1
return discount
class LargeOrderPromo(Promotion): # Terceira estratégia concreta
""""7% de desconto para pedidos com 10 ou mais itens diferentes"""
def discount(self, order):
distinct_items = {item.product for item in order.cart}
if len(distinct_items) >= 10:
return order.total() * .07
return 0
dion = Customer('Dion Vitor', 0)
fernanda = Customer('Fernanda', 1100)
cart = [LineItem('banana', 4, 0.5), LineItem('apple', 10, 1.5), LineItem('watermelon', 5, 5.0)]
print(Order(dion, cart, FidelityPromo()))
print(Order(fernanda, cart, FidelityPromo()))
banana_cart = [LineItem('banana', 30, 0.5), LineItem('apple', 10, 1.5)]
print(Order(dion, banana_cart, BulkItemPromo()))
print(Order(fernanda, banana_cart, BulkItemPromo()))
long_order = [LineItem(str(item_code), 1, 1.0) for item_code in range(10)]
print(Order(dion, long_order, LargeOrderPromo()))
print(Order(dion, cart, LargeOrderPromo()))
| 26.840336 | 99 | 0.64809 | 390 | 3,194 | 5.166667 | 0.284615 | 0.044665 | 0.055583 | 0.039702 | 0.03871 | 0.03871 | 0.018859 | 0 | 0 | 0 | 0 | 0.02255 | 0.236381 | 3,194 | 118 | 100 | 27.067797 | 0.803608 | 0.132749 | 0 | 0.184211 | 0 | 0.013158 | 0.060562 | 0.007661 | 0 | 0 | 0 | 0 | 0 | 1 | 0.210526 | false | 0 | 0.026316 | 0.118421 | 0.5 | 0.078947 | 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 |
ee15a1c62dbdb46affe456aa9d04260b4b28b537 | 1,021 | py | Python | toast.py | ErinMorelli/em-slack-french-toast | 4883e73b6ef02bc920f90ca106774945ae2636ac | [
"MIT"
] | null | null | null | toast.py | ErinMorelli/em-slack-french-toast | 4883e73b6ef02bc920f90ca106774945ae2636ac | [
"MIT"
] | 2 | 2019-11-11T14:04:04.000Z | 2021-07-30T02:41:08.000Z | toast.py | ErinMorelli/em-slack-french-toast | 4883e73b6ef02bc920f90ca106774945ae2636ac | [
"MIT"
] | null | null | null | """
Copyright (c) 2021 Erin Morelli.
Permission is hereby granted, free of charge, to any person obtaining
a copy of this software and associated documentation files (the
"Software"), to deal in the Software without restriction, including
without limitation the rights to use, copy, modify, merge, publish,
distribute, sublicense, and/or sell copies of the Software, and to
permit persons to whom the Software is furnished to do so, subject to
the following conditions:
The above copyright notice and this permission notice shall be
included in all copies or substantial portions of the Software.
"""
from os import environ
import newrelic.agent
from french_toast.app import app
from french_toast.alert import FrenchToastAlerter
def main():
"""Initialize Flask application."""
newrelic.agent.initialize()
# Start status checking daemon
FrenchToastAlerter().run_daemon()
# Start Flask app
app.run(host='0.0.0.0', port=int(environ.get("PORT", 5000)))
if __name__ == '__main__':
main()
| 28.361111 | 69 | 0.757101 | 146 | 1,021 | 5.219178 | 0.59589 | 0.072178 | 0.034121 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0.014085 | 0.165524 | 1,021 | 35 | 70 | 29.171429 | 0.880282 | 0.656219 | 0 | 0 | 0 | 0 | 0.05638 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0.1 | true | 0 | 0.4 | 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 | 0 | 1 | 0 | 0 | 0 | 0 | 2 |
ee1840a677b8ff6df1e684c2ba380e45eda809dc | 1,268 | py | Python | search/operators/operators_api.py | JinHai-CN/phantoscope | 1148a30bd379691220e46520248f76615f1d86d3 | [
"Apache-2.0"
] | null | null | null | search/operators/operators_api.py | JinHai-CN/phantoscope | 1148a30bd379691220e46520248f76615f1d86d3 | [
"Apache-2.0"
] | null | null | null | search/operators/operators_api.py | JinHai-CN/phantoscope | 1148a30bd379691220e46520248f76615f1d86d3 | [
"Apache-2.0"
] | null | null | null | import json
from flask import Blueprint
from flask_restful import reqparse
from common.common import json_response
from operators.operator import all_operators
from operators.operator import regist_operators
from operators.operator import delete_operators
from operators.operator import operator_detail
from operators.operator import operator_health
from common.common import from_view_dict
operator = Blueprint('operator', __name__)
@operator.route("/")
@json_response
def operator_list_api():
return all_operators()
@operator.route("/regist", methods=['POST'])
@json_response
def operator_refresh_api():
args = reqparse.RequestParser(). \
add_argument("endpoint", type=str, required=True). \
add_argument("name", type=str, required=True). \
parse_args()
args = from_view_dict(args)
ed = args['endpoint']
name = args['name']
return regist_operators(ed, name)
@operator.route("/<name>", methods=['DELETE'])
@json_response
def delete_operator_api(name):
return delete_operators(name)
@operator.route("/<name>")
@json_response
def operator_detail_api(name):
return operator_detail(name)
@operator.route("/<name>/health")
@json_response
def operator_health_api(name):
return operator_health(name)
| 25.36 | 61 | 0.755521 | 160 | 1,268 | 5.75 | 0.2375 | 0.078261 | 0.11413 | 0.146739 | 0.16413 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0.134858 | 1,268 | 49 | 62 | 25.877551 | 0.838651 | 0 | 0 | 0.131579 | 0 | 0 | 0.061514 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0.131579 | false | 0 | 0.263158 | 0.105263 | 0.526316 | 0.052632 | 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 |
ee1c8bd3e1b254b426a21475642b0fc173f44e9d | 21,797 | py | Python | fatf/transparency/tests/test_lime.py | perellonieto/fat-forensics | 0fd975ec743c5f44fc29bb2a499a2c1067bdbeff | [
"BSD-3-Clause"
] | null | null | null | fatf/transparency/tests/test_lime.py | perellonieto/fat-forensics | 0fd975ec743c5f44fc29bb2a499a2c1067bdbeff | [
"BSD-3-Clause"
] | null | null | null | fatf/transparency/tests/test_lime.py | perellonieto/fat-forensics | 0fd975ec743c5f44fc29bb2a499a2c1067bdbeff | [
"BSD-3-Clause"
] | null | null | null | """
Tests the LIME wrapper.
"""
# Author: Alex Hepburn <ah13558@bristol.ac.uk>
# Kacper Sokol <k.sokol@bristol.ac.uk>
# License: new BSD
import pytest
try:
import lime
except ImportError: # pragma: no cover
pytest.skip(
'Skipping lime wrapper tests -- lime missing.',
allow_module_level=True)
else:
del lime
import importlib
import sys
import numpy as np
import fatf.transparency.lime as ftl
import fatf.utils.models as fum
import fatf.utils.testing.imports as futi
import fatf.utils.testing.transparency as futt
from fatf.exceptions import IncompatibleModelError, IncorrectShapeError
# yapf: disable
FUTURE_WARNING = (
'The LIME wrapper will be deprecated in FAT Forensics version '
'0.0.3. Please consider using the TabularBlimeyLime explainer '
'class implemented in the fatf.transparency.predictions.'
'surrogate_explainers module instead. Alternatively, you may '
'consider building a custom surrogate explainer using the '
'functionality implemented in FAT Forensics -- see the *Tabular '
'Surrogates* how-to guide for more details.')
SAMPLE = np.array([0, 1, 0.08, 0.54])
SAMPLE_STRUCT = np.array(
[(0, 1, 0.08, 0.54)],
dtype=[('a', 'i'), ('b', 'i'), ('c', 'f'), ('d', 'f')])[0]
CLF = fum.KNN()
CLF.fit(futt.NUMERICAL_NP_ARRAY, futt.LABELS)
CLASS_NAMES = ['class0', 'class1', 'class2']
FEATURE_NAMES = ['feat0', 'feat1', 'feat2', 'feat3']
NUMERICAL_RESULTS = {
'class0': [('feat0 <= 0.00', -0.415),
('0.50 < feat1 <= 1.00', -0.280),
('0.07 < feat2 <= 0.22', 0.037),
('0.34 < feat3 <= 0.58', -0.007)],
'class1': [('0.50 < feat1 <= 1.00', 0.202),
('0.07 < feat2 <= 0.22', -0.076),
('feat0 <= 0.00', 0.019),
('0.34 < feat3 <= 0.58', -0.018)],
'class2': [('feat0 <= 0.00', 0.395),
('0.50 < feat1 <= 1.00', 0.077),
('0.07 < feat2 <= 0.22', 0.039),
('0.34 < feat3 <= 0.58', 0.025)]
}
CATEGORICAL_RESULTS = {
'class0': [('feat0=0', -0.413),
('feat1=1', -0.282),
('0.07 < feat2 <= 0.22', 0.0366),
('0.34 < feat3 <= 0.58', -0.00717)],
'class1': [('feat1=1', 0.2048),
('0.07 < feat2 <= 0.22', -0.0767),
('feat0=0', 0.0179),
('0.34 < feat3 <= 0.58', -0.018)],
'class2': [('feat0=0', 0.395),
('feat1=1', 0.077),
('0.07 < feat2 <= 0.22', 0.039),
('0.34 < feat3 <= 0.58', 0.025)]
}
REGRESSION_RESULTS = [
('feat0 <= 0.00', 1.332),
('0.50 < feat1 <= 1.00', 0.767),
('0.34 < feat3 <= 0.58', 0.149),
('0.07 < feat2 <= 0.22', -0.048)
]
# yapf: enable
USER_WARNING_MODEL_PRED = ('Since both, a model and a predictive function, '
'are provided only the latter will be used.')
LOG_WARNING = 'The model can only be used for LIME in a regressor mode.'
CLF_NON_PROBA = futt.NonProbabilisticModel(CLF.predict)
def test_import_when_missing():
"""
Tests importing :mod:`fatf.transparency.lime` module when LIME is missing.
"""
assert 'fatf.transparency.lime' in sys.modules
warning_msg = (
'Lime package is not installed on your system. You must install it in '
'order to use the fatf.transparency.lime module. One possibility is '
'to install LIME alongside this package with: pip install fatf[lime].')
with futi.module_import_tester('lime', when_missing=True):
with pytest.warns(ImportWarning) as w:
importlib.reload(ftl)
assert len(w) == 1
assert str(w[0].message) == warning_msg
assert 'fatf.transparency.lime' in sys.modules
def test_lime_init():
"""
Tests :mod:`fatf.transparency.lime.Lime` object initialisation.
This only looks into cases where the initialisation would fail.
"""
attribute_error = 'The following named parameters are not valid: {}.'
shape_error_data = ('The data parameter must be a 2-dimensional numpy '
'array.')
value_error_cat = 'LIME does not support non-numerical data arrays.'
value_error = ("The mode must be either 'classification' or 'regression'. "
"'{}' given.")
incompatible_model_error = ('LIME requires a model object to have a fit '
'method and optionally a predict_proba '
'method.')
type_error_predictor = ('The predict_fn parameter is not callable -- it '
'has to be a function.')
type_error_struct_indices = ('The categorical_features parameter either '
'has to be a list, a numpy array or None.')
incorrect_shape_struct_indices = ('categorical_features array/list is not '
'1-dimensional.')
value_error_struct_indices = ('Since categorical_features is an array of '
'indices for a structured array, all of its '
'elements should be strings.')
value_error_struct_incorrect_indices = (
'Indices given in the categorical_features parameter are not valid '
'for the input data array.')
#
attribute_error_explain = ('The following named parameters are not valid: '
'{}.')
incorrect_shape_error_explain = ('The instance to be explained should be '
'1-dimensional.')
value_error_explain = ('The instance to be explained should be purely '
'numerical -- LIME does not support categorical '
'features.')
# Wrong named parameter
with pytest.warns(FutureWarning) as warning:
with pytest.raises(AttributeError) as exin:
ftl.Lime(futt.NUMERICAL_NP_ARRAY, model=CLF, lorem='ipsum')
assert str(exin.value) == attribute_error.format("{'lorem'}")
assert len(warning) == 1
assert str(warning[0].message) == FUTURE_WARNING
# Not a 2-dimensional array
with pytest.warns(FutureWarning) as warning:
with pytest.raises(IncorrectShapeError) as exin:
ftl.Lime(np.ones((6, 4, 4)))
assert str(exin.value) == shape_error_data
assert len(warning) == 1
assert str(warning[0].message) == FUTURE_WARNING
# Not a numerical array
with pytest.warns(FutureWarning) as warning:
with pytest.raises(ValueError) as exin:
lime = ftl.Lime(np.ones((6, 4), dtype='U1'))
assert str(exin.value) == value_error_cat
assert len(warning) == 1
assert str(warning[0].message) == FUTURE_WARNING
# A structured data array with weird categorical indices type
with pytest.warns(FutureWarning) as warning:
with pytest.raises(TypeError) as exin:
ftl.Lime(futt.NUMERICAL_STRUCT_ARRAY, categorical_features='')
assert str(exin.value) == type_error_struct_indices
assert len(warning) == 1
assert str(warning[0].message) == FUTURE_WARNING
# A structured data array with weird categorical indices shape
with pytest.warns(FutureWarning) as warning:
with pytest.raises(IncorrectShapeError) as exin:
ftl.Lime(futt.NUMERICAL_STRUCT_ARRAY, categorical_features=[['a']])
assert str(exin.value) == incorrect_shape_struct_indices
assert len(warning) == 1
assert str(warning[0].message) == FUTURE_WARNING
# A structured data array with non-textual categorical indices
with pytest.warns(FutureWarning) as warning:
with pytest.raises(ValueError) as exin:
ftl.Lime(
futt.NUMERICAL_STRUCT_ARRAY,
categorical_features=np.array([3, 2]))
assert str(exin.value) == value_error_struct_indices
assert len(warning) == 1
assert str(warning[0].message) == FUTURE_WARNING
# A structured data array with incorrect categorical indices
with pytest.warns(FutureWarning) as warning:
with pytest.raises(ValueError) as exin:
ftl.Lime(
futt.NUMERICAL_STRUCT_ARRAY,
categorical_features=['a', 'e', 'b'])
assert str(exin.value) == value_error_struct_incorrect_indices
assert len(warning) == 1
assert str(warning[0].message) == FUTURE_WARNING
# Wrong operation mode
with pytest.warns(FutureWarning) as warning:
with pytest.raises(ValueError) as exin:
ftl.Lime(futt.NUMERICAL_NP_ARRAY, mode='c')
assert str(exin.value) == value_error.format('c')
assert len(warning) == 1
assert str(warning[0].message) == FUTURE_WARNING
# Invalid model
invalid_model = futt.InvalidModel()
with pytest.warns(FutureWarning) as warning:
with pytest.raises(IncompatibleModelError) as exin:
ftl.Lime(
futt.NUMERICAL_NP_ARRAY,
model=invalid_model,
mode='classification')
assert str(exin.value) == incompatible_model_error
assert len(warning) == 1
assert str(warning[0].message) == FUTURE_WARNING
with pytest.warns(FutureWarning) as warning:
with pytest.raises(IncompatibleModelError) as exin:
ftl.Lime(futt.NUMERICAL_NP_ARRAY, model='a', mode='classification')
assert str(exin.value) == incompatible_model_error
assert len(warning) == 1
assert str(warning[0].message) == FUTURE_WARNING
# Invalid predictive function
with pytest.warns(FutureWarning) as warning:
with pytest.raises(TypeError) as exin:
ftl.Lime(
futt.NUMERICAL_NP_ARRAY, predict_fn='a', mode='regression')
assert str(exin.value) == type_error_predictor
assert len(warning) == 1
assert str(warning[0].message) == FUTURE_WARNING
###########################################################################
# Test explain_instance for exceptions and errors
with pytest.warns(FutureWarning) as warning:
lime = ftl.Lime(futt.NUMERICAL_NP_ARRAY)
assert len(warning) == 1
assert str(warning[0].message) == FUTURE_WARNING
# Incorrect parameter
with pytest.raises(AttributeError) as exin:
lime.explain_instance(SAMPLE, weird_named_argument='yes')
assert str(exin.value) == attribute_error_explain.format(
"{'weird_named_argument'}")
# Incorrect shape
with pytest.raises(IncorrectShapeError) as exin:
lime.explain_instance(futt.NUMERICAL_STRUCT_ARRAY)
assert str(exin.value) == incorrect_shape_error_explain
# Not numerical
with pytest.raises(ValueError) as exin:
lime.explain_instance(np.ones((5, ), dtype='U1'))
assert str(exin.value) == value_error_explain
def test_explain_instance_classification(caplog):
"""
Tests :mod:`fatf.transparency.lime.Lime.explain_instance` method.
These tests are for a classification task.
"""
runtime_error_no_predictor = 'A predictive function is not available.'
runtime_error_non_prob = ('The predictive model is not probabilistic. '
'Please specify a predictive function instead.')
# Check logging
assert len(caplog.records) == 0
# Non-probabilistic model -- function -- probabilistic function
with pytest.warns(None) as warning:
lime = ftl.Lime(
futt.NUMERICAL_NP_ARRAY,
model=CLF_NON_PROBA,
predict_fn=CLF.predict_proba,
class_names=CLASS_NAMES,
feature_names=FEATURE_NAMES)
assert len(warning) == 2
assert str(warning[0].message) == FUTURE_WARNING
assert str(warning[1].message) == USER_WARNING_MODEL_PRED
explained = lime.explain_instance(SAMPLE, predict_fn=CLF.predict_proba)
assert futt.is_explanation_equal_list(explained, NUMERICAL_RESULTS)
# Non-probabilistic model -- function -- no function
with pytest.warns(None) as warning:
lime = ftl.Lime(
futt.NUMERICAL_NP_ARRAY,
model=CLF_NON_PROBA,
predict_fn=CLF.predict_proba,
class_names=CLASS_NAMES,
feature_names=FEATURE_NAMES)
assert len(warning) == 2
assert str(warning[0].message) == FUTURE_WARNING
assert str(warning[1].message) == USER_WARNING_MODEL_PRED
explained = lime.explain_instance(SAMPLE)
assert futt.is_explanation_equal_list(explained, NUMERICAL_RESULTS)
# Non-probabilistic model -- no function -- probabilistic function
with pytest.warns(FutureWarning) as warning:
lime = ftl.Lime(
futt.NUMERICAL_NP_ARRAY,
model=CLF_NON_PROBA,
class_names=CLASS_NAMES,
feature_names=FEATURE_NAMES)
assert len(warning) == 1
assert str(warning[0].message) == FUTURE_WARNING
explained = lime.explain_instance(SAMPLE, predict_fn=CLF.predict_proba)
assert futt.is_explanation_equal_list(explained, NUMERICAL_RESULTS)
# Non-probabilistic model -- no function -- no function
with pytest.warns(FutureWarning) as warning:
lime = ftl.Lime(
futt.NUMERICAL_NP_ARRAY,
model=CLF_NON_PROBA,
class_names=CLASS_NAMES,
feature_names=FEATURE_NAMES)
assert len(warning) == 1
assert str(warning[0].message) == FUTURE_WARNING
with pytest.raises(RuntimeError) as exin:
lime.explain_instance(SAMPLE_STRUCT)
assert str(exin.value) == runtime_error_non_prob
# Check logging
assert len(caplog.records) == 4
for i in range(4):
assert caplog.records[i].levelname == 'WARNING'
assert caplog.records[i].getMessage() == LOG_WARNING
# No model -- function -- probabilistic function
with pytest.warns(FutureWarning) as warning:
lime = ftl.Lime(
futt.NUMERICAL_STRUCT_ARRAY,
predict_fn=CLF.predict_proba,
class_names=CLASS_NAMES,
feature_names=FEATURE_NAMES)
assert len(warning) == 1
assert str(warning[0].message) == FUTURE_WARNING
explained = lime.explain_instance(SAMPLE, predict_fn=CLF.predict_proba)
assert futt.is_explanation_equal_list(explained, NUMERICAL_RESULTS)
# No model -- function -- no function
with pytest.warns(FutureWarning) as warning:
lime = ftl.Lime(
futt.NUMERICAL_STRUCT_ARRAY,
predict_fn=CLF.predict_proba,
class_names=CLASS_NAMES,
feature_names=FEATURE_NAMES)
assert len(warning) == 1
assert str(warning[0].message) == FUTURE_WARNING
explained = lime.explain_instance(SAMPLE)
assert futt.is_explanation_equal_list(explained, NUMERICAL_RESULTS)
# No model -- no function -- probabilistic function
with pytest.warns(FutureWarning) as warning:
lime = ftl.Lime(
futt.NUMERICAL_NP_ARRAY,
class_names=CLASS_NAMES,
feature_names=FEATURE_NAMES)
assert len(warning) == 1
assert str(warning[0].message) == FUTURE_WARNING
explained = lime.explain_instance(SAMPLE, predict_fn=CLF.predict_proba)
assert futt.is_explanation_equal_list(explained, NUMERICAL_RESULTS)
# No model -- no function -- no function
with pytest.warns(FutureWarning) as warning:
lime = ftl.Lime(
futt.NUMERICAL_NP_ARRAY,
class_names=CLASS_NAMES,
feature_names=FEATURE_NAMES)
assert len(warning) == 1
assert str(warning[0].message) == FUTURE_WARNING
with pytest.raises(RuntimeError) as exin:
lime.explain_instance(SAMPLE)
assert str(exin.value) == runtime_error_no_predictor
# Check logging
assert len(caplog.records) == 4
# Probabilistic model -- probabilistic function -- empty call
with pytest.warns(None) as warning:
lime = ftl.Lime(
futt.NUMERICAL_NP_ARRAY,
model=CLF,
predict_fn=CLF.predict_proba,
class_names=CLASS_NAMES,
feature_names=FEATURE_NAMES)
assert len(warning) == 2
assert str(warning[0].message) == FUTURE_WARNING
assert str(warning[1].message) == USER_WARNING_MODEL_PRED
explained = lime.explain_instance(SAMPLE_STRUCT)
assert futt.is_explanation_equal_list(explained, NUMERICAL_RESULTS)
#
# Probabilistic model -- probabilistic function -- non-empty call
with pytest.warns(None) as warning:
lime = ftl.Lime(
futt.NUMERICAL_NP_ARRAY,
model=CLF,
predict_fn=CLF.predict_proba,
class_names=CLASS_NAMES,
feature_names=FEATURE_NAMES)
assert len(warning) == 2
assert str(warning[0].message) == FUTURE_WARNING
assert str(warning[1].message) == USER_WARNING_MODEL_PRED
explained = lime.explain_instance(SAMPLE, predict_fn=CLF.predict_proba)
assert futt.is_explanation_equal_list(explained, NUMERICAL_RESULTS)
#
# Probabilistic model -- no function -- empty call
with pytest.warns(FutureWarning) as warning:
lime = ftl.Lime(
futt.NUMERICAL_STRUCT_ARRAY,
model=CLF,
class_names=CLASS_NAMES,
feature_names=FEATURE_NAMES)
assert len(warning) == 1
assert str(warning[0].message) == FUTURE_WARNING
explained = lime.explain_instance(SAMPLE)
assert futt.is_explanation_equal_list(explained, NUMERICAL_RESULTS)
#
# Probabilistic model -- no function -- non-empty call
with pytest.warns(FutureWarning) as warning:
lime = ftl.Lime(
futt.NUMERICAL_STRUCT_ARRAY,
model=CLF,
class_names=CLASS_NAMES,
feature_names=FEATURE_NAMES)
assert len(warning) == 1
assert str(warning[0].message) == FUTURE_WARNING
explained = lime.explain_instance(
SAMPLE_STRUCT, predict_fn=CLF.predict_proba)
assert futt.is_explanation_equal_list(explained, NUMERICAL_RESULTS)
# Check logging
assert len(caplog.records) == 4
###########################################################################
# Test with categorical features: feat0 and feat1
cat_feat = [0, 1]
with pytest.warns(FutureWarning) as warning:
lime = ftl.Lime(
futt.NUMERICAL_NP_ARRAY,
model=CLF,
class_names=CLASS_NAMES,
feature_names=FEATURE_NAMES,
categorical_features=cat_feat)
assert len(warning) == 1
assert str(warning[0].message) == FUTURE_WARNING
explained = lime.explain_instance(SAMPLE_STRUCT)
assert futt.is_explanation_equal_list(CATEGORICAL_RESULTS, explained)
cat_feat = ['a', 'b']
with pytest.warns(FutureWarning) as warning:
lime = ftl.Lime(
futt.NUMERICAL_STRUCT_ARRAY,
model=CLF,
class_names=CLASS_NAMES,
feature_names=FEATURE_NAMES,
categorical_features=cat_feat)
assert len(warning) == 1
assert str(warning[0].message) == FUTURE_WARNING
explained = lime.explain_instance(SAMPLE)
assert futt.is_explanation_equal_list(CATEGORICAL_RESULTS, explained)
# Check logging
assert len(caplog.records) == 4
def test_explain_instance_regression(caplog):
"""
Tests :mod:`fatf.transparency.lime.Lime.explain_instance` method.
These tests are for a regression task.
"""
# Check logging
assert len(caplog.records) == 0
# Regression a non-probabilistic model
with pytest.warns(FutureWarning) as warning:
lime = ftl.Lime(
futt.NUMERICAL_STRUCT_ARRAY,
mode='regression',
model=CLF_NON_PROBA,
class_names=CLASS_NAMES,
feature_names=FEATURE_NAMES)
assert len(warning) == 1
assert str(warning[0].message) == FUTURE_WARNING
explained = lime.explain_instance(SAMPLE)
assert futt.is_explanation_equal_list({'a': explained},
{'a': REGRESSION_RESULTS})
# Check logging
assert len(caplog.records) == 1
assert caplog.records[0].levelname == 'WARNING'
assert caplog.records[0].getMessage() == LOG_WARNING
# Regression a probabilistic model
with pytest.warns(FutureWarning) as warning:
lime = ftl.Lime(
futt.NUMERICAL_NP_ARRAY,
mode='regression',
model=CLF,
class_names=CLASS_NAMES,
feature_names=FEATURE_NAMES)
assert len(warning) == 1
assert str(warning[0].message) == FUTURE_WARNING
explained = lime.explain_instance(SAMPLE_STRUCT)
assert futt.is_explanation_equal_list({'a': explained},
{'a': REGRESSION_RESULTS})
# Regression with a model and function
with pytest.warns(None) as warning:
lime = ftl.Lime(
futt.NUMERICAL_STRUCT_ARRAY,
mode='regression',
model=CLF,
predict_fn=CLF_NON_PROBA.predict,
class_names=CLASS_NAMES,
feature_names=FEATURE_NAMES)
assert len(warning) == 2
assert str(warning[0].message) == FUTURE_WARNING
assert str(warning[1].message) == USER_WARNING_MODEL_PRED
explained = lime.explain_instance(SAMPLE_STRUCT)
assert futt.is_explanation_equal_list({'a': explained},
{'a': REGRESSION_RESULTS})
# Regression without a model
with pytest.warns(FutureWarning) as warning:
lime = ftl.Lime(
futt.NUMERICAL_NP_ARRAY,
mode='regression',
class_names=CLASS_NAMES,
feature_names=FEATURE_NAMES)
assert len(warning) == 1
assert str(warning[0].message) == FUTURE_WARNING
explained = lime.explain_instance(SAMPLE, predict_fn=CLF_NON_PROBA.predict)
assert futt.is_explanation_equal_list({'a': explained},
{'a': REGRESSION_RESULTS})
# Check logging
assert len(caplog.records) == 1
| 40.141805 | 79 | 0.639354 | 2,624 | 21,797 | 5.14253 | 0.117759 | 0.034682 | 0.045353 | 0.037795 | 0.732029 | 0.721284 | 0.674226 | 0.635245 | 0.626575 | 0.609308 | 0 | 0.024871 | 0.25109 | 21,797 | 542 | 80 | 40.215867 | 0.801764 | 0.091343 | 0 | 0.638955 | 0 | 0 | 0.131964 | 0.006145 | 0 | 0 | 0 | 0 | 0.268409 | 1 | 0.009501 | false | 0 | 0.035629 | 0 | 0.045131 | 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 |
ee3627a94d24c93abb9ea94e133026291a97ca19 | 310 | py | Python | officialWebsite/team/serializers.py | rdotjain/officialWebsite | d5f37cf840c303ecbc47aa12bd76781bb725422d | [
"MIT"
] | 1 | 2021-11-21T04:34:13.000Z | 2021-11-21T04:34:13.000Z | officialWebsite/team/serializers.py | raghavTinker/officialWebsite | bf02249894b7d26b8b3f8062f2fc75556a52ae1e | [
"MIT"
] | null | null | null | officialWebsite/team/serializers.py | raghavTinker/officialWebsite | bf02249894b7d26b8b3f8062f2fc75556a52ae1e | [
"MIT"
] | null | null | null | from rest_framework import serializers
from .models import Team
from officialWebsite.users.serializers import UserSerializer
class TeamSerializer(serializers.ModelSerializer):
users = UserSerializer(read_only=True, many=True)
class Meta:
model = Team
fields = ("id", "name", "users")
| 28.181818 | 60 | 0.741935 | 34 | 310 | 6.705882 | 0.647059 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0.174194 | 310 | 10 | 61 | 31 | 0.890625 | 0 | 0 | 0 | 0 | 0 | 0.035484 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | false | 0 | 0.375 | 0 | 0.75 | 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 |
ee3ca5ce4f16c7d9f4d138a5cfe977b8efe30284 | 1,113 | py | Python | errors.py | abc22413/LibraryDB | 558df63becaf45e7a281b86c38f8d3c43bc7bc87 | [
"Apache-2.0"
] | null | null | null | errors.py | abc22413/LibraryDB | 558df63becaf45e7a281b86c38f8d3c43bc7bc87 | [
"Apache-2.0"
] | null | null | null | errors.py | abc22413/LibraryDB | 558df63becaf45e7a281b86c38f8d3c43bc7bc87 | [
"Apache-2.0"
] | null | null | null | # Custom Exceptions
class Error(Exception):
"""Base class for other exceptions
"""
pass
class OptionOutOfRange(Error):
"""Raised when option selected from menu is out of range
"""
pass
class DBConnectionError(Error):
"""Raised when option selected from menu is out of range
"""
pass
class TooManyLoans(Error):
"""Raised when user already has too many loans
"""
pass
class BookNotAvail(Error):
"""Raised when book user intends to borrow is not available
"""
pass
class AlreadyRenewed(Error):
"""Raised if intended book is already renewed once
"""
pass
class BookIsOverdue(Error):
"""Raised if intended book is already renewed once
"""
pass
class ObjNotHaveAttr(Error):
'''Raised when mongoDB object does not have requested field for editing
'''
pass
class BookNotHaveAttr(ObjNotHaveAttr):
'''Raised when mongoDB Book does not have requested field for editing
'''
pass
class UserNotHaveAttr(ObjNotHaveAttr):
'''Raised when mongoDB User does not have requested field for editing
'''
pass | 22.26 | 75 | 0.681941 | 134 | 1,113 | 5.664179 | 0.380597 | 0.106719 | 0.098814 | 0.079051 | 0.462451 | 0.462451 | 0.462451 | 0.462451 | 0.411067 | 0.295125 | 0 | 0 | 0.236298 | 1,113 | 50 | 76 | 22.26 | 0.892941 | 0.546271 | 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 |
ee4aa53d11532ad9f10dc755168bfcad139451c2 | 5,829 | py | Python | mongoengine/connection.py | iainb/mongoengine | 290e70a2455227783f675c5aa5d8b799e73cdd1e | [
"MIT"
] | null | null | null | mongoengine/connection.py | iainb/mongoengine | 290e70a2455227783f675c5aa5d8b799e73cdd1e | [
"MIT"
] | 2 | 2015-09-17T15:56:10.000Z | 2018-09-04T14:15:48.000Z | mongoengine/connection.py | iainb/mongoengine | 290e70a2455227783f675c5aa5d8b799e73cdd1e | [
"MIT"
] | 3 | 2015-02-17T15:48:39.000Z | 2021-02-05T09:12:30.000Z | import pymongo
from pymongo import Connection, ReplicaSetConnection, uri_parser
__all__ = ['ConnectionError', 'connect', 'register_connection',
'DEFAULT_CONNECTION_NAME']
DEFAULT_CONNECTION_NAME = 'default'
DEFAULT_DB_ALIAS = 'default'
class ConnectionError(Exception):
pass
_connection_settings = {}
_connections = {}
_dbs = {}
# Map of DB aliases to settings for the DB, including connection alias
_db_settings = {}
def register_connection(alias, host='localhost', port=27017,
is_slave=False, read_preference=False, slaves=None,
username=None, password=None, **kwargs):
"""Add a connection.
:param alias: the name that will be used to refer to this connection
throughout MongoEngine
:param name: the name of the specific database to use
:param host: the host name of the :program:`mongod` instance to connect to
:param port: the port that the :program:`mongod` instance is running on
:param is_slave: whether the connection can act as a slave ** Depreciated pymongo 2.0.1+
:param read_preference: The read preference for the collection ** Added pymongo 2.1
:param slaves: a list of aliases of slave connections; each of these must
be a registered connection that has :attr:`is_slave` set to ``True``
:param username: username to authenticate with
:param password: password to authenticate with
:param kwargs: allow ad-hoc parameters to be passed into the pymongo driver
"""
global _connection_settings
# Handle uri style connections
if "://" in host:
uri_dict = uri_parser.parse_uri(host)
_connection_settings[alias] = {
'host': host,
'username': uri_dict.get('username'),
'password': uri_dict.get('password')
}
_connection_settings[alias].update(kwargs)
return
_connection_settings[alias] = {
'host': host,
'port': port,
'is_slave': is_slave,
'slaves': slaves or [],
'username': username,
'password': password,
'read_preference': read_preference
}
_connection_settings[alias].update(kwargs)
def disconnect(alias=DEFAULT_CONNECTION_NAME):
global _connections
global _dbs
if alias in _connections:
conn = get_connection(alias=alias)
conn.disconnect()
if hasattr(conn, 'close'):
conn.close()
del _connections[alias]
if alias in _dbs:
del _dbs[alias]
def get_connection(alias=DEFAULT_CONNECTION_NAME, reconnect=False):
global _connections
# Connect to the database if not already connected
if reconnect:
disconnect(alias)
if alias not in _connections:
if alias not in _connection_settings:
msg = 'Connection with alias "%s" has not been defined'
if alias == DEFAULT_CONNECTION_NAME:
msg = 'You have not defined a default connection'
raise ConnectionError(msg)
conn_settings = _connection_settings[alias].copy()
if hasattr(pymongo, 'version_tuple'): # Support for 2.1+
conn_settings.pop('slaves', None)
conn_settings.pop('is_slave', None)
conn_settings.pop('username', None)
conn_settings.pop('password', None)
else:
# Get all the slave connections
if 'slaves' in conn_settings:
slaves = []
for slave_alias in conn_settings['slaves']:
slaves.append(get_connection(slave_alias))
conn_settings['slaves'] = slaves
conn_settings.pop('read_preference')
connection_class = Connection
if 'replicaSet' in conn_settings:
conn_settings['hosts_or_uri'] = conn_settings.pop('host', None)
connection_class = ReplicaSetConnection
try:
_connections[alias] = connection_class(**conn_settings)
except Exception, e:
raise ConnectionError("Cannot connect to database %s :\n%s" % (alias, e))
return _connections[alias]
def register_db(
db_name, db_alias=DEFAULT_DB_ALIAS,
connection_alias=DEFAULT_CONNECTION_NAME):
assert isinstance(db_name, basestring)
assert isinstance(db_alias, basestring)
assert isinstance(connection_alias, basestring)
global _db_settings
_db_settings[db_alias] = {
'connection_alias': connection_alias,
'db_name': db_name,
}
def get_db(alias=DEFAULT_DB_ALIAS, reconnect=False, refresh=False):
global _dbs
global _db_settings
db_settings = _db_settings[alias]
if reconnect:
disconnect(db_settings['connection_alias'])
if alias not in _dbs or refresh:
conn = get_connection(db_settings['connection_alias'])
_dbs[alias] = conn[db_settings['db_name']]
if db_settings.get('username') and db_settings.get('password'):
_dbs[alias].authenticate(db_settings['username'],
db_settings['password'])
return _dbs[alias]
def connect(alias=DEFAULT_CONNECTION_NAME, **kwargs):
"""
Connect to a server.
Connection settings may be provided here as well if the database is not
running on the default port on localhost. If authentication is needed,
provide username and password arguments as well.
Multiple connections are supported by using aliases. Provide a separate
`alias` to connect to a different instance of :program:`mongod`.
.. versionchanged:: 0.6 - added multiple database support.
"""
global _connections
if alias not in _connections:
register_connection(alias, **kwargs)
return get_connection(alias)
# Support old naming convention
_get_connection = get_connection
_get_db = get_db
| 33.889535 | 92 | 0.662035 | 688 | 5,829 | 5.398256 | 0.228198 | 0.035003 | 0.03958 | 0.035003 | 0.105816 | 0.015078 | 0 | 0 | 0 | 0 | 0 | 0.003221 | 0.254246 | 5,829 | 171 | 93 | 34.087719 | 0.851162 | 0.038257 | 0 | 0.155963 | 0 | 0 | 0.117468 | 0.005371 | 0 | 0 | 0 | 0 | 0.027523 | 0 | null | null | 0.06422 | 0.018349 | 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 |
ee61ee030f831a9da2fe6e962e58238e687809aa | 829 | py | Python | exts/omni.warp/omni/warp/scripts/extension.py | NVIDIA/warp | fc7d3255435fc2fe6b54300e689f74e6d67418ca | [
"CNRI-Python-GPL-Compatible",
"Unlicense",
"0BSD",
"Apache-2.0",
"MIT"
] | 306 | 2022-03-21T23:24:13.000Z | 2022-03-31T21:11:28.000Z | exts/omni.warp/omni/warp/scripts/extension.py | NVIDIA/warp | fc7d3255435fc2fe6b54300e689f74e6d67418ca | [
"CNRI-Python-GPL-Compatible",
"Unlicense",
"0BSD",
"Apache-2.0",
"MIT"
] | 11 | 2022-03-23T06:23:25.000Z | 2022-03-31T22:17:18.000Z | exts/omni.warp/omni/warp/scripts/extension.py | NVIDIA/warp | fc7d3255435fc2fe6b54300e689f74e6d67418ca | [
"CNRI-Python-GPL-Compatible",
"Unlicense",
"0BSD",
"Apache-2.0",
"MIT"
] | 18 | 2022-03-22T16:27:21.000Z | 2022-03-30T20:07:47.000Z | # Copyright (c) 2022 NVIDIA CORPORATION. All rights reserved.
# NVIDIA CORPORATION and its licensors retain all intellectual property
# and proprietary rights in and to this software, related documentation
# and any modifications thereto. Any use, reproduction, disclosure or
# distribution of this software and related documentation without an express
# license agreement from NVIDIA CORPORATION is strictly prohibited.
import warp as wp
import omni.ext
from .menu import WarpMenu
from .common import log_info
class OmniWarpExtension(omni.ext.IExt):
def on_startup(self, ext_id):
log_info("OmniWarpExtension startup")
wp.init()
self._menu = WarpMenu()
def on_shutdown(self):
log_info("OmniWarpExtension shutdown")
self._menu.shutdown()
self._menu = None
| 29.607143 | 76 | 0.737033 | 104 | 829 | 5.788462 | 0.586538 | 0.084718 | 0.079734 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0.006042 | 0.201448 | 829 | 27 | 77 | 30.703704 | 0.903323 | 0.494572 | 0 | 0 | 0 | 0 | 0.124088 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0.153846 | false | 0 | 0.307692 | 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 | 0 | 0 | 0 | 1 | 0 | 1 | 0 | 0 | 2 |
ee621e39eb148613e23d7c1de9d0625f6a325375 | 816 | py | Python | neko3/pagination/factory/basefactory.py | Natsurii/nicabot-monkee | 0f32132184c31bea0015f232c0abf3ec993129fa | [
"MIT"
] | null | null | null | neko3/pagination/factory/basefactory.py | Natsurii/nicabot-monkee | 0f32132184c31bea0015f232c0abf3ec993129fa | [
"MIT"
] | null | null | null | neko3/pagination/factory/basefactory.py | Natsurii/nicabot-monkee | 0f32132184c31bea0015f232c0abf3ec993129fa | [
"MIT"
] | null | null | null | #!/usr/bin/env python3
# -*- coding: utf-8 -*-
# Nekozilla is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# Nekozilla is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with Nekozilla. If not, see <https://www.gnu.org/licenses/>.
"""
Base factory ABC.
"""
__all__ = ("BaseFactory",)
import abc
class BaseFactory(abc.ABC):
"""Base class for a factory."""
pass
| 28.137931 | 70 | 0.727941 | 125 | 816 | 4.72 | 0.632 | 0.025424 | 0.066102 | 0.09661 | 0.138983 | 0.094915 | 0 | 0 | 0 | 0 | 0 | 0.004498 | 0.182598 | 816 | 28 | 71 | 29.142857 | 0.88006 | 0.844363 | 0 | 0 | 0 | 0 | 0.108911 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | false | 0.25 | 0.25 | 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 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 0 | 0 | 0 | 2 |
ee71e30ced27fc0e2fc537b501b8b0b3ff411eea | 795 | py | Python | migrations/0092_permissionssupport.py | audaciouscode/PassiveDataKit-Django | ed1e00c436801b9f49a3e0e6657c2adb6b2ba3d4 | [
"Apache-2.0"
] | 5 | 2016-01-26T19:19:44.000Z | 2018-12-12T18:04:04.000Z | migrations/0092_permissionssupport.py | audacious-software/PassiveDataKit-Django | da91a375c075ceec938f2c9bb6b011f9f019b024 | [
"Apache-2.0"
] | 6 | 2020-02-17T20:16:28.000Z | 2021-12-13T21:51:20.000Z | migrations/0092_permissionssupport.py | audacious-software/PassiveDataKit-Django | da91a375c075ceec938f2c9bb6b011f9f019b024 | [
"Apache-2.0"
] | 4 | 2020-01-29T15:36:58.000Z | 2021-06-01T18:55:26.000Z | # pylint: skip-file
# Generated by Django 2.2.16 on 2021-01-15 19:57
from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
('passive_data_kit', '0091_auto_20200918_1819'),
]
operations = [
migrations.CreateModel(
name='PermissionsSupport',
fields=[
('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
],
options={
'permissions': (('passive_data_kit_dashboard_access', 'Access Passive Data Kit dashboard'), ('passive_data_kit_export_access', 'Create Passive Data Kit data exports')),
'managed': False,
'default_permissions': (),
},
),
]
| 30.576923 | 184 | 0.596226 | 80 | 795 | 5.7125 | 0.65 | 0.12035 | 0.153173 | 0.100656 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0.056338 | 0.285535 | 795 | 25 | 185 | 31.8 | 0.748239 | 0.080503 | 0 | 0 | 1 | 0 | 0.315934 | 0.118132 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | false | 0.111111 | 0.055556 | 0 | 0.222222 | 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 |
ee75da045a48ec3e7f811354cd25d6eb3d21796d | 242 | py | Python | Networking/Packets/Outgoing/GotoAckPacket.py | henriquelino/pyrelay | b448cca3accc9a566616b756a03958ba096a5ebf | [
"MIT"
] | 26 | 2020-07-24T05:47:02.000Z | 2022-03-31T16:03:13.000Z | Networking/Packets/Outgoing/GotoAckPacket.py | henriquelino/pyrelay | b448cca3accc9a566616b756a03958ba096a5ebf | [
"MIT"
] | 17 | 2020-07-27T08:11:19.000Z | 2022-03-29T05:26:16.000Z | Networking/Packets/Outgoing/GotoAckPacket.py | henriquelino/pyrelay | b448cca3accc9a566616b756a03958ba096a5ebf | [
"MIT"
] | 16 | 2021-01-20T14:30:37.000Z | 2022-03-18T05:31:51.000Z | class GotoAckPacket:
def __init__(self):
self.type = "GOTOACK"
self.time = 0
def write(self, writer):
writer.writeInt32(self.time)
def read(self, reader):
self.time = reader.readInt32()
| 22 | 39 | 0.57438 | 27 | 242 | 5 | 0.555556 | 0.177778 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0.03012 | 0.31405 | 242 | 10 | 40 | 24.2 | 0.783133 | 0 | 0 | 0 | 0 | 0 | 0.030172 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0.375 | false | 0 | 0 | 0 | 0.5 | 0 | 1 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 2 |
ee7e4b1ededa9ee8cf532e86ab93a946c74436dc | 3,913 | py | Python | 12.py | nikolas2000/PYTHON | 9febcdd5f60d65fe2d035bc06065a94a5c51fa18 | [
"Unlicense"
] | null | null | null | 12.py | nikolas2000/PYTHON | 9febcdd5f60d65fe2d035bc06065a94a5c51fa18 | [
"Unlicense"
] | null | null | null | 12.py | nikolas2000/PYTHON | 9febcdd5f60d65fe2d035bc06065a94a5c51fa18 | [
"Unlicense"
] | null | null | null | f = open("keimeno.txt", "r")
keimeno=f.read()
list1=list(keimeno)
list_peza=[] #lower all the letters of the text
for x in list1:
list_peza.append(x.lower())
num=0
a=list1.count("a")
b=list1.count("b")
c=list1.count("c")
d=list1.count("d")
e=list1.count("e")
f=list1.count("f")
g=list1.count("g")
h=list1.count("h")
i=list1.count("i")
j=list1.count("j")
k=list1.count("k")
l=list1.count("l")
m=list1.count("m")
n=list1.count("n")
o=list1.count("o")
p=list1.count("p")
q=list1.count("q")
r=list1.count("r")
s=list1.count("s")
t=list1.count("t")
u=list1.count("u")
v=list1.count("v")
w=list1.count("w")
x=list1.count("x")
y=list1.count("y")
z=list1.count("z")
sinolo=a+b+c+d+e+f+g+h+i+j+k+l+m+n+o+p+q+r+s+t+u+v+w+x+y+z
pososto_a=(float(a)/float(sinolo))*100
pososto_b=(float(b)/float(sinolo))*100
pososto_c=(float(c)/float(sinolo))*100
pososto_d=(float(d)/float(sinolo))*100
pososto_e=(float(e)/float(sinolo))*100
pososto_f=(float(f)/float(sinolo))*100
pososto_g=(float(g)/float(sinolo))*100
pososto_h=(float(h)/float(sinolo))*100
pososto_i=(float(i)/float(sinolo))*100
pososto_j=(float(j)/float(sinolo))*100
pososto_k=(float(k)/float(sinolo))*100
pososto_l=(float(l)/float(sinolo))*100
pososto_m=(float(m)/float(sinolo))*100
pososto_n=(float(n)/float(sinolo))*100
pososto_o=(float(o)/float(sinolo))*100
pososto_p=(float(p)/float(sinolo))*100
pososto_q=(float(q)/float(sinolo))*100
pososto_r=(float(r)/float(sinolo))*100
pososto_s=(float(s)/float(sinolo))*100
pososto_t=(float(t)/float(sinolo))*100
pososto_u=(float(u)/float(sinolo))*100
pososto_v=(float(v)/float(sinolo))*100
pososto_w=(float(w)/float(sinolo))*100
pososto_x=(float(x)/float(sinolo))*100
pososto_y=(float(y)/float(sinolo))*100
pososto_z=(float(z)/float(sinolo))*100
print "\nSTATISTICS PER LETTER:\n"
print "a:",pososto_a ,"%"
print "b:",pososto_b ,"%"
print "c:",pososto_c ,"%"
print "d:",pososto_d ,"%"
print "e:",pososto_e ,"%"
print "f:",pososto_f ,"%"
print "g:",pososto_g ,"%"
print "h:",pososto_h ,"%"
print "i:",pososto_i ,"%"
print "j:",pososto_j ,"%"
print "k:",pososto_k ,"%"
print "l:",pososto_l ,"%"
print "m:",pososto_m ,"%"
print "n:",pososto_n ,"%"
print "o:",pososto_o ,"%"
print "p:",pososto_p ,"%"
print "q:",pososto_q ,"%"
print "r:",pososto_r ,"%"
print "s:",pososto_s ,"%"
print "t:",pososto_t ,"%"
print "u:",pososto_u ,"%"
print "v:",pososto_v ,"%"
print "w:",pososto_w ,"%"
print "x:",pososto_x ,"%"
print "y:",pososto_y ,"%"
print "z:",pososto_z ,"%"
list2=[pososto_a,pososto_b,pososto_c,pososto_d,pososto_e,pososto_f,pososto_g,pososto_h,pososto_i,pososto_j,pososto_k,pososto_l,pososto_m,pososto_n,pososto_o,pososto_p,pososto_q,pososto_r,pososto_s,pososto_t,pososto_u,pososto_v,pososto_w,pososto_x,pososto_y,pososto_z]
list3=['a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z']
#print list2
list4=[]#create two new lists winthout 0%
list6=[]
for i in range(len(list2)):
if list2[i]!=0:
list4.append(list2[i])
list6.append(list3[i])
max_pososto=max(list4)
min_pososto=min(list4)
thesi_max=list4.index(max_pososto)
thesi_min=list4.index(min_pososto)
list7=[list6[thesi_max],max_pososto] #list with the letter and the biggest number
list8=[list6[thesi_min],min_pososto] #list with the letter and the smallest number
print "\n", list7,list8
#print list_peza
for i in range(len(list_peza)):
if list_peza[i]==list7[0]:
list_peza.remove(list_peza[i])
list_peza.insert(i,list8[0])
elif list_peza[i]==list8[0]:
list_peza.remove(list_peza[i])
list_peza.insert(i,list7[0])
list_kefalaia=[] #upper all the letters of the text
for x in list_peza:
list_kefalaia.append(x.upper())
print "\n"," ".join(list_kefalaia) #join method to get the elements of the list out of it
#end of the program
| 27.95 | 268 | 0.660363 | 699 | 3,913 | 3.547926 | 0.128755 | 0.104839 | 0.146774 | 0.211694 | 0.110484 | 0.099194 | 0.099194 | 0.075 | 0.075 | 0.052419 | 0 | 0.039712 | 0.111935 | 3,913 | 139 | 269 | 28.151079 | 0.673957 | 0.072067 | 0 | 0.017699 | 0 | 0 | 0.04967 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | null | null | 0 | 0 | null | null | 0.256637 | 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 |
ee824e8f30e7d5511e3c7a4aea278df6d84b181a | 9,079 | py | Python | nbt/entity_nbt.py | SpikeVN/pycmdblock | 9c93e2ecf2336ed2c9d8cae9fbaec21525f90ba8 | [
"MIT"
] | null | null | null | nbt/entity_nbt.py | SpikeVN/pycmdblock | 9c93e2ecf2336ed2c9d8cae9fbaec21525f90ba8 | [
"MIT"
] | null | null | null | nbt/entity_nbt.py | SpikeVN/pycmdblock | 9c93e2ecf2336ed2c9d8cae9fbaec21525f90ba8 | [
"MIT"
] | null | null | null | from ..abc import Item, Position, UUID, JSONText, Entity
from .attributes import EntityAttribute
from ..utils import asm_item
class EntityNBT:
"""
The NBT of an entity
"""
def __init__(self):
self.raw = ""
self.attributes = []
def __str__(self):
return "{" + self.raw[:-1] + "}"
def motion(self, value_x: float = 0.0, value_y: float = 0.0, value_z: float = 0.0):
"""
The motion of the entity.
"""
self.raw += f"Motion:[{value_x},{value_y},{value_z}],"
return self
def rotate(self, yaw: float = 0.0, pitch: float = 0.0):
"""
The rotation of the entity.
"""
self.raw += f"Rotation:[{yaw}F,{pitch}F],"
return self
def burn_time_left(self, ticks: int):
"""
The time left that the entity burn until the fire distinguish itself.
"""
self.raw += f"Fire:{ticks},"
return self
def has_visual_fire(self, option: bool = True):
"""
Whether the entity has fire visually on it or not.
"""
self.raw += f"HasVisualFire:{'1b' if option else '0b'},"
return self
def air_left(self, ticks: int):
"""
The air of the entity left underwater.
"""
self.raw += f"Air:{ticks},"
return self
def on_ground(self, option: bool = True):
"""
Whether the entity is on ground or not.
"""
self.raw += f"OnGround:{'1b' if option else '0b'},"
return self
def no_gravity(self, option: bool = True):
"""
Whether the entity has gravity or not.
"""
self.raw += f"NoGravity:{'1b' if option else '0b'},"
return self
def invulnerable(self, option: bool = True):
"""
Whether the entity is attackable for player in survival mode.
"""
self.raw += f"Invulnerable:{'1b' if option else '0b'},"
return self
def silent(self, option: bool = True):
"""
Whether the entity makes noise.
"""
self.raw += f"Silent:{'1b' if option else '0b'},"
return self
def glowing(self, option: bool = True):
"""
Whether the entity is glowing.
"""
self.raw += f"Glowing:{'1b' if option else '0b'},"
return self
def name(self, name: JSONText | list[JSONText]):
"""
Sets the name of the entity.
"""
self.raw += f"CustomName:'{name}',"
return self
def tag(self, *args: str):
"""
Custom tag name for the target selector.
"""
self.raw += f"Tags:[{','.join(args)}],"
return self
def fall_distance(self, distance: float):
"""
The distance the entity has fallen. Affects fall damage.
"""
self.raw += f"FallDistance:{distance}f,"
return self
def portal_cooldown(self, ticks: int):
"""
The time the entity has left the portal from now
"""
self.raw += f"PortalCooldown:{ticks},"
return self
# def uuid(self, uuid: str):
# """
# Set the UUID of the entity. Two entities with the same UUID cannot
# exist at the same time.
#
# UUID here consists of 36 hex digits, representing a 128-bit number.
# """
# nuuid = uuid.replace("-", "")
# # c7562635-dee1-47e6-8c6f-3c4a7b9da042
# if len(nuuid) != 36:
# raise SyntaxError("UUID can only consist of 36 hex digits.")
# self.raw += f"UUID:[I;{nuuid[:8]},{nuuid[8:12]},{nuuid[12:16]}]"
def hurt_time(self, ticks: int):
"""
The amount of time the entity flashes red when attacked.
"""
self.raw += f"HurtTime:{ticks},"
return self
def death_time(self, ticks: int):
"""
The amount of time that the mob has been dying. Controls death animation.
"""
self.raw += f"DeathTime:{ticks},"
return self
def loot_table_path(self, path: str):
"""
The file path to the loot table for that entity.
"""
# Somehow Minecraft requires you to double escape
path.replace("\\", "\\\\")
self.raw += f"DeathLootTable:\"{path}\","
return self
def left_handed(self, option: bool = True):
"""
Whether the entity's main hand is the left hand.
Only affects human-like entities like Zombies and Skeletons.
"""
self.raw += f"LeftHanded:{'1b' if option else '0b'},"
return self
def team(self, team_name: str):
"""
Makes the entity instantly joins the team with
the name specified when spawned.
"""
self.raw += f"Team:\"{team_name}\","
return self
def leash(self, to: Position | UUID):
"""
What is the entity leashed to, or whether it is leashed.
"""
if type(to) == UUID:
result = f"UUID:{to}"
elif type(to) == Position:
result = f"X:{to.x},Y:{to.y},Z:{to.z}"
else:
raise SyntaxError("The entity can only be leashed to a Position or an UUID of an entity.")
result = "{" + result + "}"
self.raw += f"Leashed:1b,Leash:{result},"
return self
def enable_despawn(self, option: bool = True):
"""
Whether the entity will despawn
"""
self.raw += f"PersistenceRequired:{'1b' if option else '0b'},"
return self
def disable_ai(self, option: bool = True):
"""
Whether the entity will attempt to move.
"""
self.raw += f"NoAI:{'1b' if option else '0b'},"
return self
def pick_up_item(self, option: bool = True):
"""
Whether the entity can pick up items and wear armour
it picked up them.
"""
self.raw += f"CanPickUpLoot:{'1b' if option else '0b'},"
return self
def wielding(
self,
main_hand: Item = None,
off_hand: Item = None,
head: Item = None,
body: Item = None,
leggings: Item = None,
boots: Item = None
):
"""
Set the item that the entity is wielding or wearing.
"""
# != is xor.
# https://stackoverflow.com/questions/432842/how-do-you-get-the-logical-xor-of-two-variables-in-python
if (main_hand is None) != (off_hand is None):
self.raw += "HandItems:["
self.raw = self.raw + asm_item(main_hand) + ","
self.raw = self.raw + asm_item(off_hand)
self.raw += "],"
if ((head is None) != (body is None)) != ((leggings is None) != (boots is None)):
self.raw += "ArmorItems:["
self.raw = self.raw + asm_item(boots) + ","
self.raw = self.raw + asm_item(leggings) + ","
self.raw = self.raw + asm_item(body) + ","
self.raw = self.raw + asm_item(head)
self.raw += "],"
return self
def absorption(self, amount: float):
"""
The amount of health gained by absorption effect, like
eating a golden apple.
"""
self.raw += f"AbsorptionAmount:{amount}f,"
return self
def health(self, amount: float):
"""
The amount of base HP the entity gets.
"""
self.raw += f"Health:{amount}f,"
return self
def sleeping_at(self, at: Position):
"""
Sets the block that is the top of a bed (with the pillow)
that the entity sleeps on when spawned.
"""
self.raw += f"SleepingX:{at.x},SleepingY:{at.y},SleepingZ:{at.z},"
return self
def set_attributes(self, attribute: EntityAttribute):
self.raw = self.raw + str(attribute) + ","
def in_love(self, ticks: int):
"""
The time left for the entity to search for a mate.
"""
self.raw += f"InLove:{ticks},"
return self
def age(self, ticks: int):
"""
The age of the entity.
Negative values are considered a baby.
Zero or above is considered an adult.
Larger than zero is the time left until the entity can be bred again.
"""
self.raw += f"Age:{ticks},"
return self
def forced_age(self, ticks: int):
"""
A value of age which will be assigned to this mob when it grows up.
Incremented when a baby mob is fed.
"""
self.raw += f"ForcedAge:{ticks},"
return self
def love_cause(self, cause: UUID):
"""
The cause of the entity's breading.
"""
self.raw += f"LoveCause:{cause},"
return self
def passengers(self, *entities: Entity):
"""
Sets the passengers of the entity.
Can be chained indefinitely.
"""
self.raw += "Passengers:["
for i in entities:
self.raw = self.raw + "{" + f"id:{i.type},{i.nbt}" + "},"
self.raw = self.raw[:-1] + "],"
return self
| 30.162791 | 110 | 0.532107 | 1,139 | 9,079 | 4.195786 | 0.244952 | 0.082026 | 0.053568 | 0.037665 | 0.241055 | 0.207784 | 0.148985 | 0.127642 | 0 | 0 | 0 | 0.012662 | 0.338914 | 9,079 | 300 | 111 | 30.263333 | 0.783572 | 0.27459 | 0 | 0.248175 | 0 | 0 | 0.17233 | 0.051054 | 0 | 0 | 0 | 0 | 0 | 1 | 0.255474 | false | 0.014599 | 0.021898 | 0.007299 | 0.525547 | 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 |
ee84269051d53c2906477252de66f0b5fb2e0a64 | 449 | py | Python | apps/grupo/admin.py | mariomtzjr/podemos_test | 5efaf02a19aa8c4849e3ad0108546e95af524126 | [
"MIT"
] | null | null | null | apps/grupo/admin.py | mariomtzjr/podemos_test | 5efaf02a19aa8c4849e3ad0108546e95af524126 | [
"MIT"
] | null | null | null | apps/grupo/admin.py | mariomtzjr/podemos_test | 5efaf02a19aa8c4849e3ad0108546e95af524126 | [
"MIT"
] | null | null | null | from django.contrib import admin
from import_export import resources
from import_export.admin import ImportExportModelAdmin
from .models import Grupo
# Register your models here.
class GrupoResource(resources.ModelResource):
class Meta:
model = Grupo
@admin.register(Grupo)
class GrupoAdmin(ImportExportModelAdmin, admin.ModelAdmin):
list_display = ('id', 'nombre', )
ordering = ['id', ]
resource_class = GrupoResource
| 22.45 | 59 | 0.755011 | 49 | 449 | 6.836735 | 0.530612 | 0.059701 | 0.095522 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0.164811 | 449 | 19 | 60 | 23.631579 | 0.893333 | 0.057906 | 0 | 0 | 0 | 0 | 0.023753 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | false | 0 | 0.416667 | 0 | 0.916667 | 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 |
c99951702c4e861a655294280979c7569c065e3f | 348 | py | Python | docs/conf.py | 4admin2root/my_tcpconn | 87f16f319eb1fc093bada53731464737bbe8d9d2 | [
"BSD-3-Clause"
] | 1 | 2017-09-02T09:37:49.000Z | 2017-09-02T09:37:49.000Z | docs/conf.py | 4admin2root/my_tcpconn | 87f16f319eb1fc093bada53731464737bbe8d9d2 | [
"BSD-3-Clause"
] | null | null | null | docs/conf.py | 4admin2root/my_tcpconn | 87f16f319eb1fc093bada53731464737bbe8d9d2 | [
"BSD-3-Clause"
] | null | null | null | #!/usr/bin/env python
# -*- coding:utf-8 -*-
"""
my_tcpconn conf
~~~~~~~~~~~~~~~~~~~~~
@time: 2017/5/27 15:45
@contact: a@b.com
usage:
links:
:copyright:
:license: BSD 3-Clause License
"""
import sys
import os
from recommonmark.parser import CommonMarkParser
source_parsers = {
'.md': CommonMarkParser,
}
source_suffix = ['.rst', '.md'] | 13.92 | 48 | 0.632184 | 45 | 348 | 4.822222 | 0.866667 | 0.202765 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0.043919 | 0.149425 | 348 | 25 | 49 | 13.92 | 0.689189 | 0.522989 | 0 | 0 | 0 | 0 | 0.063291 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | false | 0 | 0.428571 | 0 | 0.428571 | 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 |
c9a175261f2b7da7b38f62787f9487ca3c884420 | 1,099 | py | Python | tests/test_readiter.py | rfinnie/rf-pymods | 14c73ba1a8614c9579a7957de97d7b3c7058891e | [
"Unlicense"
] | null | null | null | tests/test_readiter.py | rfinnie/rf-pymods | 14c73ba1a8614c9579a7957de97d7b3c7058891e | [
"Unlicense"
] | null | null | null | tests/test_readiter.py | rfinnie/rf-pymods | 14c73ba1a8614c9579a7957de97d7b3c7058891e | [
"Unlicense"
] | null | null | null | # SPDX-FileCopyrightText: Copyright (C) 2020-2021 Ryan Finnie
# SPDX-License-Identifier: MIT
import io
import unittest
from rf_pymods.readiter import readiter
class TestReaditer(unittest.TestCase):
def test_short(self):
fh = io.StringIO("?" * 10)
self.assertEqual([x for x in readiter(fh)], ["?" * 10])
def test_one(self):
fh = io.StringIO("?" * 1024)
self.assertEqual([x for x in readiter(fh)], ["?" * 1024])
def test_one_plus_partial(self):
fh = io.StringIO(("?" * 1024) + ("!" * 15))
self.assertEqual([x for x in readiter(fh)], ["?" * 1024, "!" * 15])
def test_two(self):
fh = io.StringIO(("?" * 1024) + ("!" * 1024))
self.assertEqual([x for x in readiter(fh)], ["?" * 1024, "!" * 1024])
def test_size(self):
fh = io.StringIO(("?" * 10) + ("!" * 15))
self.assertEqual(
[x for x in readiter(fh, size=10)], ["?" * 10, "!" * 10, "!" * 5]
)
def test_bytes(self):
fh = io.BytesIO(bytes(1024))
self.assertEqual([x for x in readiter(fh)], [bytes(1024)])
| 30.527778 | 77 | 0.55232 | 141 | 1,099 | 4.241135 | 0.297872 | 0.070234 | 0.080268 | 0.190635 | 0.521739 | 0.367893 | 0.367893 | 0.367893 | 0.314381 | 0.133779 | 0 | 0.082007 | 0.256597 | 1,099 | 35 | 78 | 31.4 | 0.649939 | 0.080073 | 0 | 0 | 0 | 0 | 0.016865 | 0 | 0 | 0 | 0 | 0 | 0.25 | 1 | 0.25 | false | 0 | 0.125 | 0 | 0.416667 | 0 | 0 | 0 | 0 | null | 0 | 0 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 2 |
c9af485354c93f5785f782502791b07a9732249e | 356 | py | Python | datasets/preprocessed/perform_preprocessing.py | polimi-mt-acg/DEBS-2013-soccer-monitoring | c8203d814ba4641e641887246fea6458fa8aaa17 | [
"MIT"
] | 2 | 2018-07-05T19:15:55.000Z | 2018-07-10T12:02:32.000Z | datasets/preprocessed/perform_preprocessing.py | polimi-mt-acg/DEBS-2013-soccer-monitoring | c8203d814ba4641e641887246fea6458fa8aaa17 | [
"MIT"
] | null | null | null | datasets/preprocessed/perform_preprocessing.py | polimi-mt-acg/DEBS-2013-soccer-monitoring | c8203d814ba4641e641887246fea6458fa8aaa17 | [
"MIT"
] | null | null | null | # -*- coding: utf-8 -*-
"""
Apply the preprocessing transformations to all files required.
"""
from preprocess_full_game import process_full_game
from preprocess_metadata import process_metadata
if __name__ == '__main__':
process_full_game(source_filepath='./../original/full-game')
process_metadata(source_filepath='./../original/metadata.txt')
| 29.666667 | 66 | 0.764045 | 43 | 356 | 5.883721 | 0.581395 | 0.126482 | 0.118577 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0.003155 | 0.109551 | 356 | 11 | 67 | 32.363636 | 0.794953 | 0.238764 | 0 | 0 | 0 | 0 | 0.21673 | 0.186312 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | true | 0 | 0.4 | 0 | 0.4 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 1 | 0 | 0 | 0 | 0 | 2 |
c9afb384faab5721e2a85763be3a0e853d982718 | 4,430 | py | Python | test/lease_desired_access.py | abhilashabhardwaj/pike | a1ad05b37231d8ac0a0442ab8d32a363e75ada9a | [
"Apache-2.0"
] | null | null | null | test/lease_desired_access.py | abhilashabhardwaj/pike | a1ad05b37231d8ac0a0442ab8d32a363e75ada9a | [
"Apache-2.0"
] | null | null | null | test/lease_desired_access.py | abhilashabhardwaj/pike | a1ad05b37231d8ac0a0442ab8d32a363e75ada9a | [
"Apache-2.0"
] | null | null | null | #
# copyright (C) EMC Corporation. All rights reserved.
#
# Module Name:
#
# lease_desired_access.py
#
# Abstract:
#
# Valid combinations of Lease(5) combined with Desired Access
# values used in single create request. For each Valid bit of Lease,
# different bits of "desired access" is tried, and handle
# creation is checked. There are 45 test cases.
#
# Author(s): Abhilasha Bhardwaj (abhilasha.bhardwaj@calsoftinc.com)
#
import pike.smb2
import pike.test
import random
import array
import sys
@pike.test.RequireDialect(0x210)
@pike.test.RequireCapabilities(pike.smb2.SMB2_GLOBAL_CAP_LEASING)
class TestLease(pike.test.PikeTest):
def __init__(self, *args, **kwargs):
super(TestLease, self).__init__(*args, **kwargs)
self.share_all = pike.smb2.FILE_SHARE_READ | pike.smb2.FILE_SHARE_WRITE\
| pike.smb2.FILE_SHARE_DELETE
self.r = pike.smb2.SMB2_LEASE_READ_CACHING
self.rw = self.r | pike.smb2.SMB2_LEASE_WRITE_CACHING
self.rh = self.r | pike.smb2.SMB2_LEASE_HANDLE_CACHING
self.rwh = self.rw | self.rh
self.none = pike.smb2.SMB2_LEASE_NONE
# Desired accesses
self.read_a = pike.smb2.FILE_READ_DATA
self.write_a = pike.smb2.FILE_WRITE_DATA
self.delete_a = pike.smb2.DELETE
self.append_a = pike.smb2.FILE_APPEND_DATA
self.generic_read_a = pike.smb2.GENERIC_READ
self.generic_write_a = pike.smb2.GENERIC_WRITE
self.generic_execute_a = pike.smb2.GENERIC_EXECUTE
self.generic_all_a = pike.smb2.GENERIC_ALL
self.max_allowed_a = pike.smb2.MAXIMUM_ALLOWED
# Define a lease list of valid combinations
self.lease_list = [self.none, self.r, self.rw, self.rh, self.rwh]
# Define a list of desired access.
self.access_list = [self.read_a, self.write_a, self.delete_a,
self.append_a, self.generic_read_a,
self.generic_write_a, self.generic_execute_a,
self.generic_all_a, self.max_allowed_a]
self.tc = 1
self.num = 1
self.fail_count, self.pass_count = 0, 0
def test_lease(self):
for lease_req in self.lease_list:
for desired_access in self.access_list:
print "==============================================="
print "TestCase {0} - Verify server response when {1} Lease \
is requested with {2} Desired Access".format(self.tc, lease_req, desired_access)
lease = array.array('B', map(random.randint, [0]*16, [255]*16))
self.lease_file(lease_req, desired_access, lease, self.num)
self.tc = self.tc + 1
self.num = self.num + 1
print "\n\nTest cases passed:", self.pass_count
print "Test cases failed:", self.fail_count
def lease_file(self, lease_req, desired_access, lease, num):
chan, tree = self.tree_connect()
try:
print "\nCreate a file with Lease bit set."
print "Creating session and tree connect..."
handle1 = chan.create(tree,
'lease_' + str(num) + '.txt',
share=self.share_all,
oplock_level=pike.smb2.SMB2_OPLOCK_LEVEL_LEASE,
access=desired_access,
disposition=pike.smb2.FILE_SUPERSEDE,
lease_key=lease,
lease_state=lease_req).result()
print "File created."
print "\nLease requested", lease_req
print "Lease obtained", handle1.lease.lease_state
try:
print "\nValidate lease obtained on the file."
self.assertEqual(handle1.lease.lease_state, lease_req)
print "Lease granted. Validation successfully done."
print "\nTest Case has PASSED!"
self.pass_count = self.pass_count + 1
except Exception as e:
print "Lease Rejected", str(e)
print "\nTest Case has FAILED"
self.fail_count = self.fail_count + 1
except Exception as e:
print "HANDLE- Handle creation failed, exiting...", str(e)
sys.exit()
chan.close(handle1)
print "File closed after test case failed."
#handle1 closed
| 43.861386 | 80 | 0.599549 | 556 | 4,430 | 4.580935 | 0.284173 | 0.062819 | 0.031802 | 0.026698 | 0.120927 | 0.048685 | 0.022772 | 0 | 0 | 0 | 0 | 0.018423 | 0.30158 | 4,430 | 100 | 81 | 44.3 | 0.804783 | 0.116027 | 0 | 0.051948 | 0 | 0 | 0.110655 | 0.012067 | 0 | 0 | 0.001284 | 0 | 0.012987 | 0 | null | null | 0.051948 | 0.064935 | null | null | 0.207792 | 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 |
c9c0977b7ae531fde85593500a2c7d143ad4b245 | 652 | py | Python | offset-game/gui/information.py | JosephDistefano/offset-human-interface | 88ba05554c289f2c966f663b11930f37fc938a83 | [
"MIT"
] | null | null | null | offset-game/gui/information.py | JosephDistefano/offset-human-interface | 88ba05554c289f2c966f663b11930f37fc938a83 | [
"MIT"
] | null | null | null | offset-game/gui/information.py | JosephDistefano/offset-human-interface | 88ba05554c289f2c966f663b11930f37fc938a83 | [
"MIT"
] | null | null | null | import pygame
def get_window_size(screen_size):
size = (0.225 * screen_size[0], 0.75 * screen_size[1])
return size
def get_position(screen_size):
position = (10 + 0.75 * screen_size[0], 5 + 0.0 * screen_size[1])
return position
class Information(pygame.sprite.Sprite):
def __init__(self, screen, screen_size):
super().__init__()
self.position = get_position(screen_size)
self.surface = pygame.Surface(get_window_size(screen_size))
self.surface.fill((0, 0, 0))
screen.blit(self.surface, self.position)
def update(self, screen):
self.surface.fill(pygame.Color('dodgerblue'))
| 27.166667 | 69 | 0.668712 | 91 | 652 | 4.538462 | 0.296703 | 0.217918 | 0.062954 | 0.09201 | 0.11138 | 0 | 0 | 0 | 0 | 0 | 0 | 0.042226 | 0.20092 | 652 | 23 | 70 | 28.347826 | 0.75048 | 0 | 0 | 0 | 0 | 0 | 0.015337 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0.25 | false | 0 | 0.0625 | 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 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 2 |
c9c64a83e06df7446d47677d3de82e0982fab9a5 | 519 | py | Python | tests/test_example.py | kipe/pyfibot | ec20ac66f0c3f562298c9fb3b46f294993303eb9 | [
"BSD-3-Clause"
] | null | null | null | tests/test_example.py | kipe/pyfibot | ec20ac66f0c3f562298c9fb3b46f294993303eb9 | [
"BSD-3-Clause"
] | null | null | null | tests/test_example.py | kipe/pyfibot | ec20ac66f0c3f562298c9fb3b46f294993303eb9 | [
"BSD-3-Clause"
] | null | null | null | from nose.tools import eq_
import bot_mock
def test_example():
assert True
def test_botmock():
bot = bot_mock.BotMock({})
eq_(('#channel', 'Foo'), bot.say("#channel", "Foo"))
def test_factorymock():
factory = bot_mock.FactoryMock({})
bot = factory.find_bot_for_network('nerv')
eq_('nerv', bot.factory.find_bot_for_network('nerv').network.alias)
eq_('localhost', bot.factory.find_bot_for_network('localhost').network.alias)
eq_(None, bot.factory.find_bot_for_network('not_found'))
| 24.714286 | 81 | 0.701349 | 73 | 519 | 4.657534 | 0.369863 | 0.117647 | 0.164706 | 0.2 | 0.341176 | 0.341176 | 0.182353 | 0 | 0 | 0 | 0 | 0 | 0.138728 | 519 | 20 | 82 | 25.95 | 0.760626 | 0 | 0 | 0 | 0 | 0 | 0.117534 | 0 | 0 | 0 | 0 | 0 | 0.076923 | 1 | 0.230769 | false | 0 | 0.153846 | 0 | 0.384615 | 0 | 0 | 0 | 0 | null | 0 | 0 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 2 |
c9c677ab1cd726c3b535e18742c4f4e79ccb737d | 505 | py | Python | examples/example_2.py | sjyk/dc4ds-core | 1ee38fccf42521bdcfb09e5964bc50c66aa9695c | [
"MIT"
] | 4 | 2016-11-17T01:55:09.000Z | 2021-07-26T04:59:18.000Z | examples/example_2.py | sjyk/dc4ds-core | 1ee38fccf42521bdcfb09e5964bc50c66aa9695c | [
"MIT"
] | null | null | null | examples/example_2.py | sjyk/dc4ds-core | 1ee38fccf42521bdcfb09e5964bc50c66aa9695c | [
"MIT"
] | null | null | null | import os,sys,inspect
currentdir = os.path.dirname(os.path.abspath(inspect.getfile(inspect.currentframe())))
parentdir = os.path.dirname(currentdir)
sys.path.insert(0,parentdir)
from dc4ds.dataset import FeaturizedDataset
from dc4ds.constraint import DomainConstraint
from dc4ds.loaders.CSVLoader import CSVLoader
c = CSVLoader(fname="examples/datasets/missing_values.csv")
d = FeaturizedDataset(c)
e,f = d.test_train_split()
a = e.getFeatures(label_column="14")
print f.getTestFeatures("14", a)
| 24.047619 | 86 | 0.790099 | 69 | 505 | 5.724638 | 0.594203 | 0.04557 | 0.065823 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0.017391 | 0.089109 | 505 | 20 | 87 | 25.25 | 0.841304 | 0 | 0 | 0 | 0 | 0 | 0.079365 | 0.071429 | 0 | 0 | 0 | 0 | 0 | 0 | null | null | 0 | 0.333333 | null | null | 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 | 1 | 0 | 0 | 0 | 1 | 0 | 0 | 0 | 0 | 2 |
c9c902cbad102e6c64a9bf4566a727d1012c787d | 730 | py | Python | BlaBlauto/AdministracionReservas/views/cancelarreserva.py | irri96/BlaBlautos | 2ca3d808ef8ba18d6fa8658edd1411f72cc71e71 | [
"MIT"
] | null | null | null | BlaBlauto/AdministracionReservas/views/cancelarreserva.py | irri96/BlaBlautos | 2ca3d808ef8ba18d6fa8658edd1411f72cc71e71 | [
"MIT"
] | null | null | null | BlaBlauto/AdministracionReservas/views/cancelarreserva.py | irri96/BlaBlautos | 2ca3d808ef8ba18d6fa8658edd1411f72cc71e71 | [
"MIT"
] | null | null | null | from django.shortcuts import render,redirect
from Nucleo.models import Viaje,Tramo,Reservacion
from datetime import datetime,timedelta
from django.contrib.auth.decorators import user_passes_test
# Create your views here.
def CancelarReserva(request, reserva):
res = Reservacion.objects.get(id=reserva)
if res.estado_reserva==Reservacion.ACEPTADO:
for tramo in res.tramos.all():
tramo.asientos_libres+=1
tramo.save()
res.delete()
return redirect('/')
def Confirmar(request, reserva):
print("reserva a cancelar ",reserva)
return render(request, 'confirmacion.html', {"reserva":Reservacion.objects.get(id=reserva),'mensaje':'¿Está seguro que desea eliminar su reserva?'})
| 33.181818 | 152 | 0.732877 | 92 | 730 | 5.782609 | 0.630435 | 0.037594 | 0.078947 | 0.086466 | 0.112782 | 0 | 0 | 0 | 0 | 0 | 0 | 0.001629 | 0.158904 | 730 | 21 | 153 | 34.761905 | 0.863192 | 0.031507 | 0 | 0 | 0 | 0 | 0.133523 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0.133333 | false | 0.066667 | 0.266667 | 0 | 0.533333 | 0.066667 | 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 |
c9d4d7e3f8f89f74eb631907f3a1a274e03845cd | 98 | py | Python | exerfor_2.py | Index-Eletronic/python2 | 92b6e844171976c782bd827ebb8c05364c34d6ad | [
"MIT"
] | null | null | null | exerfor_2.py | Index-Eletronic/python2 | 92b6e844171976c782bd827ebb8c05364c34d6ad | [
"MIT"
] | null | null | null | exerfor_2.py | Index-Eletronic/python2 | 92b6e844171976c782bd827ebb8c05364c34d6ad | [
"MIT"
] | null | null | null | from time import sleep
for i in range(10, -1, -1):
print(1)
sleep(0.5)
print('BUMM BUMM') | 16.333333 | 27 | 0.612245 | 19 | 98 | 3.157895 | 0.736842 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0.092105 | 0.22449 | 98 | 6 | 28 | 16.333333 | 0.697368 | 0 | 0 | 0 | 0 | 0 | 0.090909 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | false | 0 | 0.2 | 0 | 0.2 | 0.4 | 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 |
c9db2cb6df4cac0f90ed11f21974c3eaa95191cb | 248 | py | Python | molsysmt/element/entity/cosolute/get_name_from_mmtf_name.py | uibcdf/MolModMTs | 4f6b6f671a9fa3e73008d1e9c48686d5f20a6573 | [
"MIT"
] | null | null | null | molsysmt/element/entity/cosolute/get_name_from_mmtf_name.py | uibcdf/MolModMTs | 4f6b6f671a9fa3e73008d1e9c48686d5f20a6573 | [
"MIT"
] | null | null | null | molsysmt/element/entity/cosolute/get_name_from_mmtf_name.py | uibcdf/MolModMTs | 4f6b6f671a9fa3e73008d1e9c48686d5f20a6573 | [
"MIT"
] | null | null | null | from molsysmt._private.exceptions import *
from molsysmt._private.digestion import *
mmtf_translator = {
'SULFATE ION' : 'sulfate ion',
'ACETATE ION' : 'acetate ion',
}
def get_name_from_mmtf_name(name):
return mmtf_translator[name]
| 20.666667 | 42 | 0.729839 | 31 | 248 | 5.580645 | 0.483871 | 0.138728 | 0.219653 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0.165323 | 248 | 11 | 43 | 22.545455 | 0.835749 | 0 | 0 | 0 | 0 | 0 | 0.177419 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0.125 | false | 0 | 0.25 | 0.125 | 0.5 | 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 | 1 | 0 | 0 | 0 | 2 |
c9e1e808fe9f8b926d63c2de1ce053d2f71b0c5b | 3,164 | py | Python | app/users/views.py | averma111/Flask-Angularjs-JSON-Auth | aa6e16477dc94028dea2c1b6400382fcaea83812 | [
"MIT"
] | 25 | 2015-09-24T14:51:32.000Z | 2018-02-17T14:27:31.000Z | app/users/views.py | manioftony/Flask-Angularjs-JSON-Auth | 18671ac1244758d5a34e4b8e49f09d3a64e58997 | [
"MIT"
] | null | null | null | app/users/views.py | manioftony/Flask-Angularjs-JSON-Auth | 18671ac1244758d5a34e4b8e49f09d3a64e58997 | [
"MIT"
] | 19 | 2015-11-10T01:34:21.000Z | 2021-03-21T08:04:31.000Z | from flask import Blueprint, render_template, request, flash, redirect, url_for, jsonify, make_response
from app.users.models import Users, UsersSchema
from werkzeug.security import generate_password_hash, check_password_hash
from flask_restful import Resource, Api
import flask_restful
import jwt
from jwt import DecodeError, ExpiredSignature
from config import SECRET_KEY
from datetime import datetime, timedelta
from functools import wraps
from flask import g
users = Blueprint('users', __name__)
# http://marshmallow.readthedocs.org/en/latest/quickstart.html#declaring-schemas
schema = UsersSchema()
# JWT AUTh process start
def create_token(user):
payload = {
'sub': user.id,
'iat': datetime.utcnow(),
'exp': datetime.utcnow() + timedelta(days=1)
}
token = jwt.encode(payload, SECRET_KEY, algorithm='HS256')
return token.decode('unicode_escape')
def parse_token(req):
token = req.headers.get('Authorization').split()[1]
return jwt.decode(token, SECRET_KEY, algorithms='HS256')
# Login decorator function
def login_required(f):
@wraps(f)
def decorated_function(*args, **kwargs):
if not request.headers.get('Authorization'):
response = jsonify(message='Missing authorization header')
response.status_code = 401
return response
try:
payload = parse_token(request)
except DecodeError:
response = jsonify(message='Token is invalid')
response.status_code = 401
return response
except ExpiredSignature:
response = jsonify(message='Token has expired')
response.status_code = 401
return response
g.user_id = payload['sub']
return f(*args, **kwargs)
return decorated_function
# JWT AUTh process end
api = Api(users)
class Auth(Resource):
def post(self):
data = request.get_json(force=True)
print(data)
email = data['email']
password = data['password']
user = Users.query.filter_by(email=email).first()
if user == None:
response = make_response(
jsonify({"message": "invalid username/password"}))
response.status_code = 401
return response
if check_password_hash(user.password, password):
token = create_token(user)
return {'token': token}
else:
response = make_response(
jsonify({"message": "invalid username/password"}))
response.status_code = 401
return response
api.add_resource(Auth, '/login')
# Adding the login decorator to the Resource class
class Resource(flask_restful.Resource):
method_decorators = [login_required]
# Any API class now inheriting the Resource class will need Authentication
class User(Resource):
def get(self):
results = Users.query.all()
users = schema.dump(results, many=True).data
return jsonify({"users": users})
api.add_resource(User, '/users')
| 29.027523 | 104 | 0.637168 | 351 | 3,164 | 5.626781 | 0.381766 | 0.037975 | 0.055696 | 0.053165 | 0.146329 | 0.146329 | 0.093165 | 0.093165 | 0.093165 | 0.093165 | 0 | 0.009948 | 0.269279 | 3,164 | 108 | 105 | 29.296296 | 0.844291 | 0.084703 | 0 | 0.189189 | 1 | 0 | 0.081655 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0.081081 | false | 0.067568 | 0.148649 | 0 | 0.432432 | 0.040541 | 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 |
c9e78d41a3d5966c0694f18c2261ddb42690b468 | 303 | py | Python | pythonic/c2.py | xiaolinzi-xl/python_imooc | 07bde890e3ab0ddef4467b0c77ef33614339a657 | [
"Apache-2.0"
] | null | null | null | pythonic/c2.py | xiaolinzi-xl/python_imooc | 07bde890e3ab0ddef4467b0c77ef33614339a657 | [
"Apache-2.0"
] | null | null | null | pythonic/c2.py | xiaolinzi-xl/python_imooc | 07bde890e3ab0ddef4467b0c77ef33614339a657 | [
"Apache-2.0"
] | null | null | null |
def get_sunday():
return 'Sunday'
def get_monday():
return 'Monday'
def get_tuesday():
return 'Tuesday'
def get_default():
return 'Unknown'
day = 4
switcher = {
0 : get_sunday,
1 : get_monday,
2 : get_tuesday
}
day_name = switcher.get(day,get_default)()
print(day_name) | 13.772727 | 42 | 0.646865 | 42 | 303 | 4.428571 | 0.380952 | 0.129032 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0.017094 | 0.227723 | 303 | 22 | 43 | 13.772727 | 0.777778 | 0 | 0 | 0 | 0 | 0 | 0.085809 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0.25 | false | 0 | 0 | 0.25 | 0.5 | 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 | 0 | 1 | 0 | 0 | 0 | 1 | 0 | 0 | 0 | 2 |
c9eb2f215f32b9e1a5e6d74734e86b9c7c920eac | 77 | py | Python | vint/linting/config/config_filenames.py | tmsanrinsha/vint | 8c34196252b43d7361d0f58cb78cf2d3e4e4fbd0 | [
"MIT"
] | 538 | 2015-01-03T18:54:53.000Z | 2020-01-11T01:34:51.000Z | vint/linting/config/config_filenames.py | tmsanrinsha/vint | 8c34196252b43d7361d0f58cb78cf2d3e4e4fbd0 | [
"MIT"
] | 235 | 2015-01-01T06:20:01.000Z | 2020-01-17T11:32:39.000Z | vint/linting/config/config_filenames.py | tmsanrinsha/vint | 8c34196252b43d7361d0f58cb78cf2d3e4e4fbd0 | [
"MIT"
] | 43 | 2015-01-23T16:59:49.000Z | 2019-12-27T10:56:12.000Z | CONFIG_FILENAMES = [
'.vintrc.yaml',
'.vintrc.yml',
'.vintrc',
]
| 12.833333 | 20 | 0.532468 | 7 | 77 | 5.714286 | 0.714286 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0.246753 | 77 | 5 | 21 | 15.4 | 0.689655 | 0 | 0 | 0 | 0 | 0 | 0.38961 | 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 |
c9fae3f92cac5f7116c1edcf096f23a76fa919ec | 3,042 | py | Python | admin/updateActiveDirectory.py | KleeGroup-BaseCamp/klee-office | 6683b5dfcb603de5ba18526adcb243d3e1fa31f6 | [
"MIT"
] | null | null | null | admin/updateActiveDirectory.py | KleeGroup-BaseCamp/klee-office | 6683b5dfcb603de5ba18526adcb243d3e1fa31f6 | [
"MIT"
] | null | null | null | admin/updateActiveDirectory.py | KleeGroup-BaseCamp/klee-office | 6683b5dfcb603de5ba18526adcb243d3e1fa31f6 | [
"MIT"
] | null | null | null | # -*- coding: utf-8 -*-
import json # jsonfy search result
import psycopg2
import sys # sys.exit()
import ldap3 as ldap # ldap connection request
from ldap3 import Server,Connection , NTLM, ALL, MODIFY_ADD, MODIFY_REPLACE
try:
con_db = psycopg2.connect(database='localmap-dev', user='localmap-dev', host='laura.dev.klee.lan.net', password='localmap-dev')
except:
print "I am unable to connect to the database"
cur=con_db.cursor()
cur.execute('SELECT firstname, lastname, "Desk".name, "Site".name,"Company".name '+
'FROM "Person" '+
'JOIN "Desk" ON "Desk".person_id="Person".per_id '+
'JOIN "Site" ON "Site".sit_id="Desk".site_id '+
'JOIN "BusinessUnit" ON "BusinessUnit".bus_id="Person"."businessUnit_id" '+
'JOIN "Company" ON "Company".com_id="BusinessUnit".company_id;')
res=cur.fetchall()
#print(res)
######################################################
with open('../config/config-ldap.json') as data_file:
settings = json.load(data_file)
Serv = settings['url']
BaseDN = settings['baseDN']
BaseDNDesactives = settings['BaseDNDesactives']
User = settings['username']
Password = settings['password']
#######################################################
base_dn = BaseDN
server = Server(Serv, get_info=ALL)
con=Connection(server, user=BaseDN+'\\'+User, password=Password,authentication = NTLM ,return_empty_attributes=True)
if con.bind():
#for each person we have to check if the office name in the active directory is up-to-date with the database
for i in range(0,len(res)):
name=(res[i][0]+" "+res[i][1]).decode("utf-8")
#if res[i][3]=="La Boursidière" and res[i][2]!="aucun":
# officeName=("La Boursidière : "+res[i][2]).decode("utf-8")
if res[i][3]=="La Boursidière":
if res[i][2]!="aucun":
officeName=("La Boursidière : "+res[i][2]).decode("utf-8")
else:
officeName="nochange"
else:
officeName=res[i][3].decode("utf-8")
company=res[i][4].decode("utf-8")
base='cn='+name+',ou='+company+','+base_dn.decode("utf-8")
#print (base)
con.search(base,'(cn='+name+')',attributes=['physicalDeliveryOfficeName'])
if con.entries:
if (not con.entries[0].physicalDeliveryOfficeName):
print(name.encode('utf-8'),"add new office", officeName.encode('utf-8'))
con.modify(base,{'physicalDeliveryOfficeName':[(MODIFY_ADD,[officeName])]})
else:
if officeName=="nochange":
print("pas de changement")
elif (officeName=="Issy-les-Moulineaux" and con.entries[0].physicalDeliveryOfficeName.value.find("Issy-les-Moulineaux")==-1) or (officeName!="Issy-les-Moulineaux" and not con.entries[0].physicalDeliveryOfficeName==officeName):
print(name.encode('utf-8'),"change my office",con.entries[0].physicalDeliveryOfficeName,officeName.encode('utf-8'))
con.modify(base,{'physicalDeliveryOfficeName':[(MODIFY_REPLACE,[officeName])]})
con.unbind()
sys.exit()
| 40.56 | 228 | 0.628534 | 382 | 3,042 | 4.950262 | 0.353403 | 0.023268 | 0.031729 | 0.078265 | 0.264939 | 0.145955 | 0.145955 | 0.145955 | 0.145955 | 0.050767 | 0 | 0.012248 | 0.167982 | 3,042 | 74 | 229 | 41.108108 | 0.734887 | 0.105523 | 0 | 0.057692 | 0 | 0 | 0.294005 | 0.116449 | 0 | 0 | 0 | 0 | 0 | 0 | null | null | 0.057692 | 0.096154 | null | null | 0.076923 | 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 |
c9fc0c876427fb630e3fb3822003b7a5a526e832 | 160 | py | Python | python/1.base/4.varoprate.py | luffysk/coderesources | 9e9b5d631710bccdac8419f3e0524440b5ea4da3 | [
"MIT"
] | null | null | null | python/1.base/4.varoprate.py | luffysk/coderesources | 9e9b5d631710bccdac8419f3e0524440b5ea4da3 | [
"MIT"
] | null | null | null | python/1.base/4.varoprate.py | luffysk/coderesources | 9e9b5d631710bccdac8419f3e0524440b5ea4da3 | [
"MIT"
] | null | null | null | # 打印变量的值
a = 101
print(a)
# 打印变量的唯一id
print(id(a))
# 判断变量是否相等 == is
a = 100
b = 100
print(a is b)
a = 10000
b = 10000
print(a is b)
# 打印变量的类型
print(type(a)) | 9.411765 | 17 | 0.6125 | 31 | 160 | 3.16129 | 0.419355 | 0.183673 | 0.163265 | 0.183673 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0.154472 | 0.23125 | 160 | 17 | 18 | 9.411765 | 0.642276 | 0.25 | 0 | 0.2 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | false | 0 | 0 | 0 | 0 | 0.5 | 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 |
a001e3cb583937ebed31ef22ac3985b0c5c3b7e7 | 109 | py | Python | pyavo/_version.py | TolaAbiodun/pyavo | e8accc66ab495b8a494db7ac7015719c81edf792 | [
"MIT"
] | 6 | 2021-07-26T15:21:06.000Z | 2021-08-07T14:28:00.000Z | pyavo/_version.py | TolaAbiodun/pyavo | e8accc66ab495b8a494db7ac7015719c81edf792 | [
"MIT"
] | null | null | null | pyavo/_version.py | TolaAbiodun/pyavo | e8accc66ab495b8a494db7ac7015719c81edf792 | [
"MIT"
] | 2 | 2021-07-26T19:22:26.000Z | 2022-01-15T15:18:19.000Z | """
Version.
Doing it this way provides for access in setup.py and via __version__
"""
__version__ = "0.1.4"
| 18.166667 | 69 | 0.715596 | 18 | 109 | 3.888889 | 0.888889 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0.032967 | 0.165138 | 109 | 5 | 70 | 21.8 | 0.736264 | 0.715596 | 0 | 0 | 0 | 0 | 0.217391 | 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 |
a016f53fb3a0db49df0d01f9299887d91a6424d1 | 625 | py | Python | attalos/dataset/wordvectors/wrapper.py | millertime145/attalos | dbb7994928cfb5f3a338eb5faa4bd3c3fcda5e84 | [
"Apache-2.0"
] | 101 | 2016-06-03T00:15:52.000Z | 2021-11-12T11:57:46.000Z | attalos/dataset/wordvectors/wrapper.py | millertime145/attalos | dbb7994928cfb5f3a338eb5faa4bd3c3fcda5e84 | [
"Apache-2.0"
] | 70 | 2016-05-27T21:05:33.000Z | 2017-08-09T05:13:45.000Z | attalos/dataset/wordvectors/wrapper.py | millertime145/attalos | dbb7994928cfb5f3a338eb5faa4bd3c3fcda5e84 | [
"Apache-2.0"
] | 46 | 2016-05-27T16:19:20.000Z | 2019-06-24T12:37:22.000Z | from abc import ABCMeta, abstractmethod
class WordVectorWrapper:
__metaclass__ = ABCMeta
def __init__(self, w2v_model):
self.w2v_model = w2v_model
self.vocab = self.get_vocab()
self.word_vector_shape = self.get_word_vector_shape()
@abstractmethod
def get_vocab(self):
pass
@abstractmethod
def get_vector(self, word):
pass
@abstractmethod
def closest_words(self, vector, k):
pass
@abstractmethod
def get_word_vector_shape(self):
pass
def __getitem__(self, item):
return self.get_vector(item) | 22.321429 | 61 | 0.64 | 71 | 625 | 5.239437 | 0.352113 | 0.182796 | 0.120968 | 0.102151 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0.006742 | 0.288 | 625 | 28 | 62 | 22.321429 | 0.829213 | 0 | 0 | 0.380952 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0.285714 | false | 0.190476 | 0.047619 | 0.047619 | 0.47619 | 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 |
4e49ffc536a3442db092b4d67121c1133be4ebdb | 898 | py | Python | day_18/day_18_project_the_hirst_painting.py | MatheusNascimentoS/100_days_of_code_python | 5e5fe6b010fb09ac61b6bbc6634c2c0662d2560b | [
"MIT"
] | null | null | null | day_18/day_18_project_the_hirst_painting.py | MatheusNascimentoS/100_days_of_code_python | 5e5fe6b010fb09ac61b6bbc6634c2c0662d2560b | [
"MIT"
] | null | null | null | day_18/day_18_project_the_hirst_painting.py | MatheusNascimentoS/100_days_of_code_python | 5e5fe6b010fb09ac61b6bbc6634c2c0662d2560b | [
"MIT"
] | null | null | null | import turtle as t
from random import choice,randint
rgb_colors = [(202, 164, 110), (240, 245, 241), (236, 239, 243), (149, 75, 50), (222, 201, 136), (53, 93, 123), (170, 154, 41), (138, 31, 20), (134, 163, 184), (197, 92, 73), (47, 121, 86), (73, 43, 35), (145, 178, 149), (14, 98, 70), (232, 176, 165), (160, 142, 158), (54, 45,
50), (101, 75, 77), (183, 205, 171), (36, 60, 74), (19, 86, 89), (82, 148, 129), (147, 17, 19), (27, 68, 102), (12, 70, 64), (107, 127, 153), (176, 192, 208), (168, 99, 102)]
print(rgb_colors)
tim = t.Turtle()
tim.speed("fastest")
tim.penup()
t.colormode(255)
tim.goto(-250,-250)
for _ in range(10):
for _ in range(10):
tim.color(choice(rgb_colors))
tim.forward(50)
tim.dot(20)
tim.left(90)
tim.forward(50)
tim.left(90)
tim.forward(500)
tim.left(180)
tim.hideturtle()
screen = t.Screen()
screen.exitonclick()
| 29.933333 | 278 | 0.566815 | 154 | 898 | 3.272727 | 0.701299 | 0.053571 | 0.047619 | 0.047619 | 0.075397 | 0 | 0 | 0 | 0 | 0 | 0 | 0.340307 | 0.201559 | 898 | 29 | 279 | 30.965517 | 0.362622 | 0 | 0 | 0.26087 | 0 | 0 | 0.007795 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | false | 0 | 0.086957 | 0 | 0.086957 | 0.043478 | 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 |
4e589ce6166a3ad4858a6085cbf33d7882abdcba | 1,018 | py | Python | legacy/de422/de422/__init__.py | jayvdb/python-jplephem | 331f0fff156ddd83acd5d5a6d8e3be5e07d9dd04 | [
"MIT"
] | 71 | 2015-02-07T18:15:51.000Z | 2022-03-23T09:32:02.000Z | legacy/de422/de422/__init__.py | jayvdb/python-jplephem | 331f0fff156ddd83acd5d5a6d8e3be5e07d9dd04 | [
"MIT"
] | 42 | 2015-01-11T21:22:13.000Z | 2022-01-02T08:42:20.000Z | legacy/de422/de422/__init__.py | jayvdb/python-jplephem | 331f0fff156ddd83acd5d5a6d8e3be5e07d9dd04 | [
"MIT"
] | 26 | 2015-04-04T17:55:52.000Z | 2021-12-26T00:09:32.000Z | """JPL Planetary and Lunar Ephemeris DE422 for the jplephem package.
This is the most recent long-period ephemeris published by the Jet
Propulsion Laboratory. While requiring more than half a gigabyte of
space, it achieves quite high accuracy.
:Name: DE422 (September 2009)
:Years: -3000 through 3000
:Planets: Yes
:Sun/Moon: Yes
:Nutations: Yes
:Librations: Yes
:Report: `Jones, Fomalont, Dhawan, Romney, Folkner, Lanyi, Border, Jacobson (2010) [PDF] <http://arxiv.org/pdf/1012.0264>`_
:Size: 531 MB
This ephemeris incorporates ranging data from recent spacecraft
missions, including the Cassini mission to Saturn, which results in an
accuracy for Saturn of a few milliarcseconds for positions over the past
decade. If this ephemeris is too large for your application, take a
look at `DE421 <http://pypi.python.org/pypi/de421>`_ and `DE423
<http://pypi.python.org/pypi/de423>`_ as alternatives.
To compute using this ephemeris in Python, see the `jplephem
<http://pypi.python.org/pypi/jplephem>`_ package.
"""
| 37.703704 | 123 | 0.77112 | 154 | 1,018 | 5.071429 | 0.675325 | 0.049936 | 0.053777 | 0.065301 | 0.080666 | 0 | 0 | 0 | 0 | 0 | 0 | 0.051253 | 0.137525 | 1,018 | 26 | 124 | 39.153846 | 0.838269 | 0.991159 | 0 | null | 0 | null | 0 | 0 | null | 0 | 0 | 0 | null | 1 | null | true | 0 | 0 | null | null | null | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 2 |
4e5b3948338b51fcb66980378857101d83cc3f72 | 420 | py | Python | Dev/Tests/Terminal_Ping_Test.py | parallaxinc/cyberbot | f7c4d355ee0310dcfef81027802cc41ac6ce90e1 | [
"MIT"
] | 4 | 2019-03-18T20:49:41.000Z | 2022-03-24T01:44:36.000Z | Dev/Tests/Terminal_Ping_Test.py | parallaxinc/cyberbot | f7c4d355ee0310dcfef81027802cc41ac6ce90e1 | [
"MIT"
] | 5 | 2019-06-07T18:09:27.000Z | 2021-04-08T17:16:55.000Z | Dev/Tests/Terminal_Ping_Test.py | parallaxinc/cyberbot | f7c4d355ee0310dcfef81027802cc41ac6ce90e1 | [
"MIT"
] | null | null | null | # Ping_Test.py
from cyberbot import *
from ping import *
bot(22).tone(2000, 300)
while True:
distance = ping(8).distance()
print('Dist() = %d' % distance)
distance = ping(8).distance('cm')
print('Dist(cm) = %d' % distance)
distance = ping(8).distance('in')
print('Dist(in) = %d' % distance)
distance = ping(8).distance('us')
print('Dist(us) = %d\r' % distance)
#display.scroll(str(distance), 125)
sleep(750) | 23.333333 | 36 | 0.647619 | 62 | 420 | 4.370968 | 0.451613 | 0.177122 | 0.191882 | 0.309963 | 0.332103 | 0.332103 | 0 | 0 | 0 | 0 | 0 | 0.052925 | 0.145238 | 420 | 18 | 37 | 23.333333 | 0.70195 | 0.109524 | 0 | 0 | 0 | 0 | 0.155914 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | false | 0 | 0.153846 | 0 | 0.153846 | 0.307692 | 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 |
4e61e7451294e9943259a4b0c2d746f220765076 | 1,088 | py | Python | conductor/app/api/endpoints/stations.py | PHT-EU/central-conductor | 59e394128be1385664064f62400914b98a2e9104 | [
"MIT"
] | null | null | null | conductor/app/api/endpoints/stations.py | PHT-EU/central-conductor | 59e394128be1385664064f62400914b98a2e9104 | [
"MIT"
] | null | null | null | conductor/app/api/endpoints/stations.py | PHT-EU/central-conductor | 59e394128be1385664064f62400914b98a2e9104 | [
"MIT"
] | null | null | null | from fastapi import APIRouter, Depends
from sqlalchemy.orm import Session
from typing import List
from conductor.app.crud.station import create_station, register_train_for_station, read_trains_for_station
from conductor.app.protocol.token import create_train_token
from conductor.app.schemas.train import Train
from conductor.app.api.dependencies import get_db
from conductor.app.crud import stations
from conductor.app.schemas import StationCreate, Station
router = APIRouter()
@router.post("/stations", response_model=Station)
def register_station(station_in: StationCreate, db: Session = Depends(get_db)):
db_station = stations.create(db, obj_in=station_in)
return db_station
@router.get("/stations", response_model=List[Station])
def get_all_stations(db: Session = Depends(get_db)):
db_stations = stations.get_multi(db)
return db_stations
@router.get("/stations/{station_id}/trains", response_model=List[Train])
def get_trains_for_station(station_id: int, db: Session = Depends(get_db)):
trains = read_trains_for_station(db, station_id)
return trains
| 34 | 106 | 0.801471 | 156 | 1,088 | 5.358974 | 0.262821 | 0.093301 | 0.114833 | 0.068182 | 0.080144 | 0.055024 | 0 | 0 | 0 | 0 | 0 | 0 | 0.108456 | 1,088 | 31 | 107 | 35.096774 | 0.861856 | 0 | 0 | 0 | 0 | 0 | 0.043199 | 0.026654 | 0 | 0 | 0 | 0 | 0 | 1 | 0.136364 | false | 0 | 0.409091 | 0 | 0.681818 | 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 |
4e65a2bb95999eb9dc894e7f7e596a250fec5b49 | 431 | py | Python | move_zeroes_5kyu.py | chelseadole/code-katas | 1b433282b2acc7eea4080656febc61881e08a7e1 | [
"MIT"
] | null | null | null | move_zeroes_5kyu.py | chelseadole/code-katas | 1b433282b2acc7eea4080656febc61881e08a7e1 | [
"MIT"
] | null | null | null | move_zeroes_5kyu.py | chelseadole/code-katas | 1b433282b2acc7eea4080656febc61881e08a7e1 | [
"MIT"
] | null | null | null | """Kata: Move Zeroes - Move all zeroes in list to end.
#1 Best Practices Solution by riyakayal
def move_zeros(arr):
l = [i for i in arr if isinstance(i, bool) or i!=0]
return l+[0]*(len(arr)-len(l))
"""
def move_zeroes(array):
all_zeroes = list(filter((lambda x: x == 0 and type(x) is not bool), array))
non_zeroes = list(filter((lambda x: x != 0 or type(x) is bool), array))
return non_zeroes + all_zeroes
| 28.733333 | 80 | 0.649652 | 78 | 431 | 3.512821 | 0.461538 | 0.09854 | 0.116788 | 0.160584 | 0.182482 | 0.182482 | 0.182482 | 0 | 0 | 0 | 0 | 0.01462 | 0.206497 | 431 | 14 | 81 | 30.785714 | 0.78655 | 0.475638 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0.25 | false | 0 | 0 | 0 | 0.5 | 0 | 0 | 0 | 0 | null | 0 | 0 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 2 |
4e729f32acf47f2b43734d8cd3e291f10f1cdb19 | 778 | py | Python | bookings/views.py | nintran1995/python-example | f755a498b1dd7d3374dd99d73b6412524850f4bb | [
"MIT"
] | null | null | null | bookings/views.py | nintran1995/python-example | f755a498b1dd7d3374dd99d73b6412524850f4bb | [
"MIT"
] | null | null | null | bookings/views.py | nintran1995/python-example | f755a498b1dd7d3374dd99d73b6412524850f4bb | [
"MIT"
] | null | null | null | from django.shortcuts import render
from django.http import HttpResponse
from django.template import loader
from .models import Boarding
from django.http import HttpResponseRedirect
from django.urls import reverse
from django.views import generic
class IndexView(generic.ListView):
model = Boarding
template_name = 'bookings/index.html'
def search(request, boarding_zip_code, boarding_start, boarding_end, boarding_size):
# selected_choice = question.choice_set.get(pk=request.POST['choice'])
# return HttpResponse("You're looking at question %s." % boarding_zip_code)
boardings = Boarding.objects.filter(
size=boarding_size).order_by('-start_date')[:5]
return render(request, 'bookings/search.html', {
'boardings': boardings,
})
| 33.826087 | 84 | 0.758355 | 98 | 778 | 5.887755 | 0.530612 | 0.103986 | 0.048527 | 0.069324 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0.001506 | 0.14653 | 778 | 22 | 85 | 35.363636 | 0.86747 | 0.182519 | 0 | 0 | 0 | 0 | 0.093207 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0.0625 | false | 0 | 0.4375 | 0 | 0.75 | 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 |
4e7ceea74ab82cda6db85cbae0b181deb6124e8d | 287 | py | Python | ores/task_tracker/null_task_tracker.py | elukey/ores | 18f6e2da642dd124daf4dc122d58032eb15485c9 | [
"MIT"
] | 69 | 2015-07-15T15:04:12.000Z | 2018-08-20T15:00:27.000Z | ores/task_tracker/null_task_tracker.py | elukey/ores | 18f6e2da642dd124daf4dc122d58032eb15485c9 | [
"MIT"
] | 146 | 2015-06-13T18:56:49.000Z | 2018-08-17T22:38:52.000Z | ores/task_tracker/null_task_tracker.py | elukey/ores | 18f6e2da642dd124daf4dc122d58032eb15485c9 | [
"MIT"
] | 34 | 2018-10-15T16:58:50.000Z | 2022-03-08T20:01:34.000Z | """
Null implementation of task tracker.
"""
from .task_tracker import TaskTracker
class NullTaskTracker(TaskTracker):
def lock(self, key, task_id):
return True
def get_in_progress_task(self, key):
return None
def release(self, key):
return True
| 16.882353 | 40 | 0.672474 | 36 | 287 | 5.222222 | 0.611111 | 0.111702 | 0.138298 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0.243902 | 287 | 16 | 41 | 17.9375 | 0.866359 | 0.125436 | 0 | 0.25 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0.375 | false | 0 | 0.125 | 0.375 | 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 | 1 | 0 | 0 | 0 | 1 | 0 | 0 | 0 | 2 |
4e81fa21c14ea27b1d64f593d6979dc083de9d5b | 256 | py | Python | experiments/ab_tmd/run_experiment.py | eltonfss/TMDLibrary | 2eaca21d61ae4d012435c2dc8b65be0b62a2afd3 | [
"MIT"
] | null | null | null | experiments/ab_tmd/run_experiment.py | eltonfss/TMDLibrary | 2eaca21d61ae4d012435c2dc8b65be0b62a2afd3 | [
"MIT"
] | null | null | null | experiments/ab_tmd/run_experiment.py | eltonfss/TMDLibrary | 2eaca21d61ae4d012435c2dc8b65be0b62a2afd3 | [
"MIT"
] | null | null | null | from experiments.tmd_experiment_base import TMDExperiment
from os import path
from detectors.ab_tmd import AdaBoostTMD
experiment = TMDExperiment(
experiment_path=path.abspath(path.dirname(__file__)),
detector_type=AdaBoostTMD
)
experiment.run()
| 23.272727 | 57 | 0.820313 | 31 | 256 | 6.483871 | 0.580645 | 0.208955 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0.113281 | 256 | 10 | 58 | 25.6 | 0.885463 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | false | 0 | 0.375 | 0 | 0.375 | 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 |
4e86768afd0fb613f63a542728393571ba36c71c | 2,292 | py | Python | paths.py | zelbo/US_mapping | ac905edcc726cb546d829f011da438e3c6cfbffb | [
"MIT"
] | null | null | null | paths.py | zelbo/US_mapping | ac905edcc726cb546d829f011da438e3c6cfbffb | [
"MIT"
] | 16 | 2020-07-25T05:30:33.000Z | 2020-08-09T01:12:58.000Z | paths.py | zelbo/US_mapping | ac905edcc726cb546d829f011da438e3c6cfbffb | [
"MIT"
] | null | null | null | import os
class PathClass:
# -Folders-
relative_path = os.path.dirname(__file__)
debug_path = os.path.join(relative_path, "debug")
data_path = os.path.join(relative_path, "data")
image_path = os.path.join(relative_path, "images")
if not os.path.exists(image_path):
os.makedirs(image_path)
shape_path = os.path.join(data_path, "shapes")
covid_path = os.path.join(data_path, "covid")
election_results_path = os.path.join(data_path, "election_results")
# -Files-
# TODO: don't like this at all. How to declare a blank path?
no_file = os.path.join(data_path, "")
election_results = no_file
glue_file = no_file
political_file = no_file
covid_political_file = no_file
debug_file = no_file
state_shapefile = no_file
county_shapefile = no_file
state_covid_cases_file = no_file
state_covid_deaths_file = no_file
county_covid_cases_file = no_file
county_covid_deaths_file = no_file
def __init__(self, detail_level, data_option):
detail_covid = detail_level + "_covid_" + data_option
PathClass.election_results = os.path.join(PathClass.election_results_path, detail_level + "_results.csv")
PathClass.glue_file = os.path.join(PathClass.election_results_path, detail_level + "_glue.csv")
PathClass.political_file = os.path.join(PathClass.data_path, detail_level + "_political.csv")
PathClass.covid_political_file = os.path.join(PathClass.data_path, detail_covid + "_political.csv")
PathClass.debug_file = os.path.join(PathClass.debug_path, detail_covid + "_debug_data.csv")
PathClass.state_shapefile = os.path.join(PathClass.shape_path, "cb_2019_us_state_5m.shp")
PathClass.county_shapefile = os.path.join(PathClass.shape_path, "cb_2019_us_county_5m.shp")
PathClass.state_covid_cases_file = os.path.join(PathClass.covid_path, "COVID-19-Cases-USA-By-State.csv")
PathClass.state_covid_deaths_file = os.path.join(PathClass.covid_path, "COVID-19-Deaths-USA-By-State.csv")
PathClass.county_covid_cases_file = os.path.join(PathClass.covid_path, "COVID-19-Cases-USA-By-County.csv")
PathClass.county_covid_deaths_file = os.path.join(PathClass.covid_path, "COVID-19-Deaths-USA-By-County.csv")
return
| 48.765957 | 116 | 0.730803 | 332 | 2,292 | 4.692771 | 0.180723 | 0.077022 | 0.115533 | 0.134146 | 0.556483 | 0.456996 | 0.376123 | 0.333761 | 0.333761 | 0.21181 | 0 | 0.00936 | 0.160995 | 2,292 | 46 | 117 | 49.826087 | 0.800832 | 0.033159 | 0 | 0 | 0 | 0 | 0.130199 | 0.079114 | 0 | 0 | 0 | 0.021739 | 0 | 1 | 0.027027 | false | 0 | 0.027027 | 0 | 0.621622 | 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 |
4ea031470abad7b9fa447bf289ad9f136f15e8a6 | 277 | py | Python | blaze/config/train.py | henry1jin/alohamora | e51e2488ecdf3e9692d5bb6b25ebc88622087c20 | [
"MIT"
] | 5 | 2020-12-16T03:13:59.000Z | 2022-03-06T07:16:39.000Z | blaze/config/train.py | henry1jin/alohamora | e51e2488ecdf3e9692d5bb6b25ebc88622087c20 | [
"MIT"
] | 9 | 2020-09-25T23:25:59.000Z | 2022-03-11T23:45:14.000Z | blaze/config/train.py | henry1jin/alohamora | e51e2488ecdf3e9692d5bb6b25ebc88622087c20 | [
"MIT"
] | 3 | 2019-10-16T21:22:07.000Z | 2020-07-21T13:38:22.000Z | """ This module defines the training configuration """
from typing import NamedTuple, Union
class TrainConfig(NamedTuple):
""" TrainConfig is a configuration for training with ray """
experiment_name: str
num_workers: int
resume: Union[bool, str] = "prompt"
| 25.181818 | 64 | 0.718412 | 33 | 277 | 5.969697 | 0.818182 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0.191336 | 277 | 10 | 65 | 27.7 | 0.879464 | 0.361011 | 0 | 0 | 0 | 0 | 0.03681 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | true | 0 | 0.2 | 0 | 1 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 0 | 1 | 0 | 0 | 2 |
4eafe98cce9120ae4a95728795076857a7fe8ea3 | 295 | py | Python | domains/gym_craft/tests/teleport.py | AndrewPaulChester/sage-code | 9fe676bfbcbc6f642eca29b30a1027fba2a426a0 | [
"MIT"
] | null | null | null | domains/gym_craft/tests/teleport.py | AndrewPaulChester/sage-code | 9fe676bfbcbc6f642eca29b30a1027fba2a426a0 | [
"MIT"
] | null | null | null | domains/gym_craft/tests/teleport.py | AndrewPaulChester/sage-code | 9fe676bfbcbc6f642eca29b30a1027fba2a426a0 | [
"MIT"
] | null | null | null |
from domains.gym_craft.simulator.craft_world import CraftWorldSimulator
from domains.gym_craft.utils.representations import json_to_symbolic,json_to_screen,json_to_mixed
from domains.gym_craft.envs.teleport_env import TeleportEnv
env = TeleportEnv()
env.reset()
env.act([5,8])
env.act([-3,4]) | 29.5 | 97 | 0.830508 | 46 | 295 | 5.086957 | 0.543478 | 0.141026 | 0.179487 | 0.24359 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0.014545 | 0.067797 | 295 | 10 | 98 | 29.5 | 0.836364 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | false | 0 | 0.428571 | 0 | 0.428571 | 0 | 0 | 0 | 0 | null | 0 | 0 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 0 | 0 | 2 |
4eb1c7cf12e29f9c5092a395797d050dcd561221 | 252 | py | Python | app.py | KurtSanders/heroku | aa7edf92d82126ab699debdc729163e4aa1fe20c | [
"Apache-2.0"
] | null | null | null | app.py | KurtSanders/heroku | aa7edf92d82126ab699debdc729163e4aa1fe20c | [
"Apache-2.0"
] | null | null | null | app.py | KurtSanders/heroku | aa7edf92d82126ab699debdc729163e4aa1fe20c | [
"Apache-2.0"
] | null | null | null | import os
from bottle import route, run
@route('/hello/:name')
def index(name='World'):
return '<b>Hello %s!</b>' % name
# Get required port, default to 5000.
port = os.environ.get('PORT', 5000)
# Run the app.
run(host='0.0.0.0', port=port)
| 19.384615 | 37 | 0.638889 | 43 | 252 | 3.744186 | 0.581395 | 0.037267 | 0.037267 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0.057416 | 0.170635 | 252 | 12 | 38 | 21 | 0.712919 | 0.190476 | 0 | 0 | 0 | 0 | 0.218905 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0.142857 | false | 0 | 0.285714 | 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 | 0 | 0 | 0 | 0 | 1 | 1 | 0 | 0 | 2 |
4eb6ccbb7bd1dd41e4908629163c500ec1666e2d | 34,492 | py | Python | WebMirror/management/rss_parser_funcs/feed_parse_extractWwwAsianhobbyistCom.py | fake-name/ReadableWebProxy | ed5c7abe38706acc2684a1e6cd80242a03c5f010 | [
"BSD-3-Clause"
] | 193 | 2016-08-02T22:04:35.000Z | 2022-03-09T20:45:41.000Z | WebMirror/management/rss_parser_funcs/feed_parse_extractWwwAsianhobbyistCom.py | fake-name/ReadableWebProxy | ed5c7abe38706acc2684a1e6cd80242a03c5f010 | [
"BSD-3-Clause"
] | 533 | 2016-08-23T20:48:23.000Z | 2022-03-28T15:55:13.000Z | WebMirror/management/rss_parser_funcs/feed_parse_extractWwwAsianhobbyistCom.py | rrosajp/ReadableWebProxy | ed5c7abe38706acc2684a1e6cd80242a03c5f010 | [
"BSD-3-Clause"
] | 19 | 2015-08-13T18:01:08.000Z | 2021-07-12T17:13:09.000Z | def extractWwwAsianhobbyistCom(item):
'''
Parser for 'www.asianhobbyist.com'
'''
vol, chp, frag, postfix = extractVolChapterFragmentPostfix(item['title'])
if not (chp or vol) or "preview" in item['title'].lower():
return None
if "Anime" in item['tags']:
return None
if "Articles" in item['tags']:
return None
if "L’Apprivoisement D’une Yandere" in item['tags']:
return None
tagmap = [
('Boku wa Isekai', 'Boku wa Isekai de Fuyo Mahou to Shoukan Mahou wo Tenbin ni Kakeru', 'translated'),
('Traitor and Hero Party', 'Traitor and Hero Party', 'translated'),
('The God Slaying Hero and the Seven Covenants', 'The God Slaying Hero and the Seven Covenants', 'translated'),
('First Hunter', 'The First Hunter', 'translated'),
('Revolution of the 8th Class Mage', 'Revolution of the 8th Class Mage', 'translated'),
('The Villainess Is Being Doted on by the Crown Prince', 'The Villainess Is Being Doted on by the Crown Prince', 'translated'),
('The Lazy Swordmaster', 'The Lazy Swordmaster', 'translated'),
('My Pet Is a Holy Maiden', 'My Pet Is a Holy Maiden', 'translated'),
('I Will Quit the Entourage of the Villainess', 'I Will Quit the Entourage of the Villainess', 'translated'),
('The Archer of A Fictitious World', 'The Archer of A Fictitious World', 'translated'),
('The Spoilt Village Beauty', 'The Spoilt Village Beauty', 'translated'),
('Golden Word Master', 'Golden Word Master', 'translated'),
('Shadow Rogue', 'Shadow Rogue', 'translated'),
('LV999 Villager', 'LV999 Villager', 'translated'),
('Evil God Average', 'Evil God Average', 'translated'),
('Maou Ni', 'Maou ni Nattanode, Dungeon Tsukutte Jingai Musume to Honobono Suru', 'translated'),
('Uchi Musume', 'Uchi no Musume no Tame naraba, Ore wa Moshikashitara Maou mo Taoseru kamo Shirenai', 'translated'),
('Botsuraku', 'Botsuraku Youtei Nanode, Kajishokunin wo Mezasu', 'translated'),
('Akuya', 'Akuyaku Tensei Dakedo Doushite Kou Natta.', 'translated'),
('The Strong The Few Cultivators On Campus', 'The Strong The Few Cultivators On Campus', 'translated'),
('Magicraft Meister', 'Magi Craft Meister', 'translated'),
('A Tale of Two Phoenixes', 'A Tale of Two Phoenixes', 'translated'),
('The Taming of the Yandere', 'The Taming of the Yandere', 'translated'),
('Abyss Domination', 'Abyss Domination', 'translated'),
('Yuusha, Aruiwa Bakemono to Yobareta Shoujo', 'Yuusha, Aruiwa Bakemono to Yobareta Shoujo', 'translated'),
('The Manual of Duke\'s Daughter', 'The Manual of Duke\'s Daughter', 'translated'),
('That Time I Got Reincarnated As A Slime', 'That Time I Got Reincarnated As A Slime', 'translated'),
('Every Day the Protagonist Wants to Capture Me', 'Every Day the Protagonist Wants to Capture Me', 'translated'),
('kuro no maou', 'kuro no maou', 'translated'),
('Me, Her, and the Ballistic Weaponry', 'Me, Her, and the Ballistic Weaponry', 'translated'),
('Hilarious pampered consort: Lord I will wait for your divorce', 'Hilarious pampered consort: Lord I will wait for your divorce', 'translated'),
('Beastly Fēi that Go Against the Heaven: Coerced by the Huáng Shū', 'Beastly Fēi that Go Against the Heaven: Coerced by the Huáng Shū', 'translated'),
('One Man Army', 'One Man Army', 'translated'),
('Rebirth Junior High School: The Exceling Top Student Goddess', 'Rebirth Junior High School: The Exceling Top Student Goddess', 'translated'),
('Itai No Wa', 'Itai No Wa', 'translated'),
('Slime', 'Tensei Shitara Slime Datta Ken', 'translated'),
('Hero without Blood or Tear', 'Hero without Blood or Tear', 'translated'),
('The Magnificent Battle Records of a Former Noble Lady', 'The Magnificent Battle Records of a Former Noble Lady', 'translated'),
('Chiyu Mahou no Machigatta Tsukaikata ~Senjou wo Kakeru Kaifuku Youin~', 'Chiyu Mahou no Machigatta Tsukaikata ~Senjou wo Kakeru Kaifuku Youin~', 'translated'),
('The Daughter of the Albert House Wishes for Ruin', 'The Daughter of the Albert House Wishes for Ruin', 'translated'),
('The Black Demon King', 'The Black Demon King', 'translated'),
('Spice of Life', 'Spice of Life', 'translated'),
('Unexpected Marriage', 'Unexpected Marriage', 'translated'),
('Heavenly Star', 'Heavenly Star', 'translated'),
('Overlord of Blood and Iron', 'Overlord of Blood and Iron', 'translated'),
('Zhu Xian', 'Zhu Xian', 'translated'),
('Awakening', 'Awakening', 'translated'),
('I Somehow Got Strong By Raising Skills Related To Farming', 'I Somehow Got Strong By Raising Skills Related To Farming', 'translated'),
('I\'m a Villager So What?', 'I\'m a Villager So What?', 'translated'),
('Big Landlord', 'Big Landlord', 'translated'),
('Common Sense of a Duke\'s Daughter', 'Common Sense of a Duke\'s Daughter', 'translated'),
('The Traitor of the Hero Party', 'The Traitor of the Hero Party', 'translated'),
('Hiki Neet', '10 nen goshi no HikiNiito o Yamete Gaishutsushitara Jitaku goto Isekai ni Ten\'ishiteta', 'translated'),
('100 cheats', 'Because There Were 100 Goddesses in Charge of Reincarnation, I Received 100 Cheat Skills', 'translated'),
('Even Posing as a Hero is Easy', 'Yuusha no Furi mo Raku Janai–Riyuu? Ore ga Kami dakara–', 'translated'),
('Large Tit Stepdaughter', 'What’s Wrong With Liking My Busty Adopted Daughter', 'translated'),
('Busty Adopted Daughter', 'What’s Wrong With Liking My Busty Adopted Daughter', 'translated'),
('Virgin Demon King', '400 Years Old Virgin Demon King', 'translated'),
('400 Year Old Virgin Demon King', '400 Years Old Virgin Demon King', 'translated'),
('Dancer In The Shadow', 'Dancer In The Shadow', 'translated'),
('Reformation of the Checkmated Reincarnated Feudal Lord', 'Reformation of the Checkmated Reincarnated Feudal Lord', 'translated'),
('History\'s Strongest Manager', 'History\'s Strongest Manager', 'translated'),
('Black Belly Wife', 'Black Belly Wife', 'translated'),
('I Said Make My Abilities Average!', 'I Said Make My Abilities Average!', 'translated'),
('God of Cooking', 'God of Cooking', 'translated'),
('The Reincarnated Vampire Wants an Afternoon Nap', 'The Reincarnated Vampire Wants an Afternoon Nap', 'translated'),
('Possessing Nothing', 'Possessing Nothing', 'translated'),
('God-level Bodyguard in the City', 'God-level Bodyguard in the City', 'translated'),
('I am an alchemist. I have discarded self-restraint in the trash', 'I am an alchemist. I have discarded self-restraint in the trash', 'translated'),
('The Ability to Make Town!? ~Let’s Make a Japanese Town in Different World~', 'The Ability to Make Town!? ~Let’s Make a Japanese Town in Different World~', 'translated'),
('Lovable Package', 'Lovable Package', 'translated'),
('God of Thunder', 'God of Thunder', 'translated'),
('Max Level Newbie', 'Max Level Newbie', 'translated'),
('Because I’m a Weapon Shop Uncle', 'Because I\'m a Weapon Shop Uncle', 'translated'),
('Game Market 1983', 'Game Market 1983', 'translated'),
('My Castle My Castellian', 'My Castle My Castellian', 'translated'),
('Oda', 'Mysterious Job Called Oda Nobunaga', 'translated'),
('Defense Build', 'I hate being in pain, so I think I’ll make a full defense build.', 'translated'),
('Return of the 8th Class Mage', 'Return of the 8th Class Mage', 'translated'),
('di daughter’s rebirth: sheng shi wang fei', 'di daughter’s rebirth: sheng shi wang fei', 'translated'),
('rebirth: noble woman, poisonous concubine', 'rebirth: noble woman, poisonous concubine', 'translated'),
('Thousand Face Demonic Concubine', 'Thousand Face Demonic Concubine', 'translated'),
('how do i fix it?', 'i’ve led the villain astray', 'translated'),
('i’ve led the villain astray', 'i’ve led the villain astray', 'translated'),
('the tale of the ghost eyes', 'the tale of the ghost eyes', 'translated'),
('rebirth of the national male god', 'rebirth of the national male god', 'translated'),
('pulling together a villain reformation strategy', 'pulling together a villain reformation strategy', 'translated'),
('Assassin Landlord & Beauty Tenants', 'Assassin Landlord & Beauty Tenants', 'translated'),
('My Entire Class Was Summoned to Another World Except for Me', 'My Entire Class Was Summoned to Another World Except for Me', 'translated'),
('bringing along a ball and hiding from foreign devils', 'bringing along a ball and hiding from foreign devils', 'translated'),
('get lost! i don’t have a traitorous disciple like you', 'get lost! i don’t have a traitorous disciple like you', 'translated'),
('I Am An NPC', 'I Am An NPC', 'translated'),
('the wizard of the tower', 'the wizard of the tower', 'translated'),
('The Strange Adventure of a Broke Mercenary', 'The Strange Adventure of a Broke Mercenary', 'translated'),
('a mistaken marriage match: pursuit of murderer in liao yue', 'a mistaken marriage match: pursuit of murderer in liao yue', 'translated'),
('my c.e.o wife', 'my c.e.o wife', 'translated'),
('Strongest Naruto System', 'Strongest Naruto System', 'translated'),
('Instant Death', 'Instant Death', 'translated'),
('haunted duke’s daughter', 'haunted duke’s daughter', 'translated'),
('Arena', 'Arena', 'translated'),
('MEMORIZE', 'M E M O R I Z E', 'translated'),
('fanning the flames of war!', 'fanning the flames of war!', 'translated'),
('I’ve Led the Villain Astray, How Do I Fix It?', 'I’ve Led the Villain Astray, How Do I Fix It?', 'translated'),
('the lover’s prattle', 'the lover’s prattle', 'translated'),
('reborn only to love you again', 'reborn only to love you again', 'translated'),
('Counterattack of a White Lotus that was Reborn into an Apocalypse', 'Counterattack of a White Lotus that was Reborn into an Apocalypse', 'translated'),
('More Than A Few Blessings', 'More Than A Few Blessings', 'translated'),
('Online Game: Evil Dragon Against The Heaven', 'Online Game: Evil Dragon Against The Heaven', 'translated'),
('The King of the Battlefield', 'The King of the Battlefield', 'translated'),
('Golden Assistant', 'Golden Assistant', 'translated'),
('Rebirth of the Rich and Wealthy', 'Rebirth of the Rich and Wealthy', 'translated'),
('I Decided to Not Compete and Quietly Create Dolls Instead', 'I Decided to Not Compete and Quietly Create Dolls Instead', 'translated'),
('Otherworld Nation Founding Chronicles', 'Otherworld Nation Founding Chronicles', 'translated'),
('otoko nara ikkokuichijou no aruji o mezasa nakya', 'otoko nara ikkokuichijou no aruji o mezasa nakya', 'translated'),
('Being Able to Edit Skills in Another World, I Gained OP Waifus', 'Being Able to Edit Skills in Another World, I Gained OP Waifus', 'translated'),
('Boku wa Isekai de Fuyo Mahou to Shoukan Mahou wo Tenbin ni Kakeru', 'Boku wa Isekai de Fuyo Mahou to Shoukan Mahou wo Tenbin ni Kakeru', 'translated'),
('Other World’s Monster Breeder', 'Other World’s Monster Breeder', 'translated'),
('invincible saint ~salaryman', 'Invincible Saint ~Salaryman, the Path I Walk to Survive in This Other World~', 'translated'),
('qingge', 'qingge', 'translated'),
('Magi Craft Meister', 'Magi Craft Meister', 'translated'),
('albert ke no reijou wa botsuraku wo go shomou desu', 'albert ke no reijou wa botsuraku wo go shomou desu', 'translated'),
('sairin yuusha no fukushuu hanashi', 'sairin yuusha no fukushuu hanashi', 'translated'),
('kyuuketsu hime wa barairo no yume o miru', 'kyuuketsu hime wa barairo no yume o miru', 'translated'),
('Boundary Labyrinth and the Foreign Magician', 'Boundary Labyrinth and the Foreign Magician', 'translated'),
('let’s be an adventurer! ~defeating dungeons with a skill board~', 'let’s be an adventurer! ~defeating dungeons with a skill board~', 'translated'),
('tilea’s worries', 'Tilea no Nayamigoto', 'translated'),
('kaleidoscope of death', 'kaleidoscope of death', 'translated'),
('Magi’s Grandson', 'Magi’s Grandson', 'translated'),
('the man standing on top of the food chain', 'the man standing on top of the food chain', 'translated'),
('Shinka no Mi', 'Shinka no Mi', 'translated'),
('let’s be an adventurer! ~defeating dungeons with a skill board', 'let’s be an adventurer! ~defeating dungeons with a skill board', 'translated'),
('chinese almanac master', 'chinese almanac master', 'translated'),
('Helping with Adventurer Party Management', 'Helping with Adventurer Party Management', 'translated'),
('i’m scattering iq to the protagonist', 'i’m scattering iq to the protagonist', 'translated'),
('Blade Online', 'Blade Online', 'translated'),
('Real Cheat Online', 'Real Cheat Online', 'translated'),
('endo and kobayashi’s live commentary on the villainess', 'endo and kobayashi’s live commentary on the villainess', 'translated'),
('the s-classes that i raised', 'the s-classes that i raised', 'translated'),
('Thanks to a Different World Reincarnation', 'Thanks to a Different World Reincarnation', 'translated'),
('Reincarnation into the Barrier Master', 'Reincarnation into the Barrier Master', 'translated'),
('of course, i’ll claim palimony!', 'of course, i’ll claim palimony!', 'translated'),
('past life returner', 'past life returner', 'translated'),
('Green Skin', 'Green Skin', 'translated'),
('Chu Wang Fei', 'Chu Wang Fei', 'translated'),
('my castle my castellan', 'my castle my castellan', 'translated'),
('Waiting For You Online', 'Waiting For You Online', 'translated'),
('Liu Yao: The Revitalization of Fuyao Sect', 'Liu Yao: The Revitalization of Fuyao Sect', 'translated'),
('The Simple Life of Killing Demons', 'The Simple Life of Killing Demons', 'translated'),
('frontiers ~chronicles of bucket-san’s detailed pioneering~', 'frontiers ~chronicles of bucket-san’s detailed pioneering~', 'translated'),
('my 【repair】skill became an almighty cheat skill, so i thought i’d open up a weapon shop', 'my 【repair】skill became an almighty cheat skill, so i thought i’d open up a weapon shop', 'translated'),
]
for tagname, name, tl_type in tagmap:
if tagname in item['tags']:
return buildReleaseMessageWithType(item, name, vol, chp, frag=frag, postfix=postfix, tl_type=tl_type)
titlemap = [
('Because There Were 100 Goddesses ', 'Because There Were 100 Goddesses in Charge of Reincarnation, I Received 100 Cheat Skills', 'translated'),
('Botsuraku Youtei Volume', 'Botsuraku Youtei Nanode, Kajishokunin wo Mezasu', 'translated'),
('Reincarnated into a Werewolf', 'Jinrou e no Tensei, Maou no Fukukan', 'translated'),
('Reincarnated Into Werewolf ', 'Jinrou e no Tensei, Maou no Fukukan', 'translated'),
('Uchi no Musume no Tame naraba', 'Uchi no Musume no Tame Naraba, Ore Moshikashitara Maou mo Taoserukamo Shirenai.', 'translated'),
('Botsuraku Youtei Volume', 'Botsuraku Youtei Nanode, Kajishokunin wo Mezasu', 'translated'),
('Devouring The Heavens', 'Devouring The Heavens', 'translated'),
('The Taming of the Yandere', 'The Taming of the Yandere', 'translated'),
('Maou Ni', 'Maou ni Nattanode, Dungeon Tsukutte Jingai Musume to Honobono Suru', 'translated'),
('The Strong The Few Cultivators On Campus', 'The Strong The Few Cultivators On Campus', 'translated'),
('The Strong, The Few, True Cultivators on Campus', 'The Strong The Few Cultivators On Campus', 'translated'),
('Evolution Theory of the Hunter', 'Evolution Theory of the Hunter', 'translated'),
('Beast Piercing The Heavens', 'Beast Piercing The Heavens', 'translated'),
('Tower of Karma', 'Tower of Karma', 'translated'),
('400 Year Old Virgin Demon King', '400 Year Old Virgin Demon King', 'translated'),
('Expecting to Fall into Ruin Volume', 'Botsuraku Youtei Nanode, Kajishokunin wo Mezasu', 'translated'),
('Genius Sword Immortal', 'Genius Sword Immortal', 'translated'),
('Evil God Average', 'Evil God Average', 'translated'),
('The God Slaying Hero', 'The God Slaying Hero And The Seven Covenants', 'translated'),
('First Hunter', 'The First Hunter', 'translated'),
('Shadow Rogue', 'Shadow Rogue', 'translated'),
('Black Haired Knight', 'Black Haired Knight', 'translated'),
('The Lazy Swordmaster', 'The Lazy Swordmaster', 'translated'),
('Uchi Musume', 'Uchi Musume', 'translated'),
('Hero without Blood or Tear', 'Hero without Blood or Tear', 'translated'),
]
for titlecomponent, name, tl_type in titlemap:
if titlecomponent.lower() in item['title'].lower():
return buildReleaseMessageWithType(item, name, vol, chp, frag=frag, postfix=postfix, tl_type=tl_type)
return False | 165.033493 | 255 | 0.338745 | 2,258 | 34,492 | 5.172719 | 0.25465 | 0.012842 | 0.006164 | 0.007705 | 0.675514 | 0.603596 | 0.491096 | 0.428339 | 0.354366 | 0.30214 | 0 | 0.003815 | 0.597269 | 34,492 | 209 | 256 | 165.033493 | 0.836873 | 0.000986 | 0 | 0.122449 | 0 | 0.010204 | 0.377892 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0.005102 | false | 0 | 0 | 0 | 0.040816 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 0 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 2 |
4ecb50b48ea0c3719f37b2cbab9a9a6e975c57c7 | 773 | py | Python | tbase/common/optimizers.py | iminders/TradeBaselines | 26eb87f2bcd5f6ff479149219b38b17002be6a40 | [
"MIT"
] | 16 | 2020-03-19T15:12:28.000Z | 2021-12-20T06:02:32.000Z | tbase/common/optimizers.py | iminders/TradeBaselines | 26eb87f2bcd5f6ff479149219b38b17002be6a40 | [
"MIT"
] | 14 | 2020-03-23T03:57:00.000Z | 2021-12-20T05:53:33.000Z | tbase/common/optimizers.py | iminders/TradeBaselines | 26eb87f2bcd5f6ff479149219b38b17002be6a40 | [
"MIT"
] | 7 | 2020-03-25T00:30:18.000Z | 2021-01-31T18:45:09.000Z | import torch
mapping = {}
def register(name):
def _thunk(func):
mapping[name] = func
return func
return _thunk
@register("rmsprop")
def rmsprop():
return torch.optim.RMSprop
@register("adam")
def adam():
return torch.optim.Adam
def get_optimizer_func(name):
"""
If you want to register your own optimizer function, you just need:
Usage Example:
-------------
from tbase.common.optimizers import register
@register("your_reward_function_name")
def your_optimizer_func(**kwargs):
...
return optimizer_func
"""
if callable(name):
return name
elif name in mapping:
return mapping[name]
else:
raise ValueError('Unknown optimizer_func: {}'.format(name))
| 19.325 | 71 | 0.6326 | 90 | 773 | 5.311111 | 0.433333 | 0.108787 | 0.066946 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0.252264 | 773 | 39 | 72 | 19.820513 | 0.82699 | 0.322122 | 0 | 0 | 0 | 0 | 0.077083 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0.25 | false | 0 | 0.05 | 0.1 | 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 | 1 | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 2 |
4ed1ef6d966cd33a3ae55eee7892f9fb53f0e03e | 1,008 | py | Python | pyminer/network/regressors.py | rbrecheisen/pyminer | c1b088cd9eddf0347b5c3e9354991374c7344a33 | [
"Apache-2.0"
] | null | null | null | pyminer/network/regressors.py | rbrecheisen/pyminer | c1b088cd9eddf0347b5c3e9354991374c7344a33 | [
"Apache-2.0"
] | 1 | 2015-05-15T12:06:25.000Z | 2015-10-18T15:43:34.000Z | pyminer/network/regressors.py | rbrecheisen/pyminer | c1b088cd9eddf0347b5c3e9354991374c7344a33 | [
"Apache-2.0"
] | null | null | null | __author__ = 'Ralph'
import pandas as pd
from base import Node
from base import InputPort
from base import OutputPort
class Regressor(Node):
def __init__(self, name):
super(Regressor, self).__init__(name)
self.add_input_port(
InputPort(name='input', data_type=pd.DataFrame))
self.add_output_port(
OutputPort(name='mode', data_type=str))
self.add_output_port(
OutputPort(name='performance', data_type=str))
class LinearRegression(Regressor):
def __init__(self):
super(LinearRegression, self).__init__('LinearRegression')
def execute(self):
pass
class SupportVectorRegression(Regressor):
def __init__(self):
super(SupportVectorRegression, self).__init__('SupportVectorRegression')
def execute(self):
pass
class GaussianProcesses(Regressor):
def __init__(self):
super(GaussianProcesses, self).__init__('GaussianProcesses')
def execute(self):
pass | 20.16 | 80 | 0.678571 | 106 | 1,008 | 6.028302 | 0.311321 | 0.043818 | 0.068858 | 0.093897 | 0.286385 | 0.097027 | 0 | 0 | 0 | 0 | 0 | 0 | 0.224206 | 1,008 | 50 | 81 | 20.16 | 0.817136 | 0 | 0 | 0.37931 | 0 | 0 | 0.080278 | 0.022795 | 0 | 0 | 0 | 0 | 0 | 1 | 0.241379 | false | 0.103448 | 0.137931 | 0 | 0.517241 | 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 |
14c25c69a864a8f7ef44dc7b92bbf950eea201bd | 564 | py | Python | wxalarmlib/utils/path.py | sanderiana/wxAlarm | 6abc4a8851ce83fa7d3ee30d89a773d9952f87ed | [
"MIT"
] | null | null | null | wxalarmlib/utils/path.py | sanderiana/wxAlarm | 6abc4a8851ce83fa7d3ee30d89a773d9952f87ed | [
"MIT"
] | null | null | null | wxalarmlib/utils/path.py | sanderiana/wxAlarm | 6abc4a8851ce83fa7d3ee30d89a773d9952f87ed | [
"MIT"
] | null | null | null | # -*- coding: utf-8 -*-
# ---------------------------------------------------------------
# wxalarm.py
#
# Copyright (c) 2019 sanderiana https://github.com/sanderiana
#
# This software is released under the MIT License.
# http://opensource.org/licenses/mit-license.php
# ---------------------------------------------------------------
# Icon made by Freepik from www.flaticon.com
# ---------------------------------------------------------------
import os
def absdir(filepath):
abspath = os.path.abspath(filepath)
return os.path.dirname(abspath) + '/'
| 28.2 | 65 | 0.45922 | 51 | 564 | 5.078431 | 0.803922 | 0.07722 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0.00996 | 0.109929 | 564 | 19 | 66 | 29.684211 | 0.505976 | 0.75 | 0 | 0 | 0 | 0 | 0.007752 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0.25 | false | 0 | 0.25 | 0 | 0.75 | 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 |
14d58ae05a7fec999529b333a503d3fac25153bc | 695 | py | Python | MechOS/simple_messages/float_array.py | PierceATronics/MechOS | 8eeb68b65b8c20b642db52baad1379fd0847b362 | [
"MIT"
] | null | null | null | MechOS/simple_messages/float_array.py | PierceATronics/MechOS | 8eeb68b65b8c20b642db52baad1379fd0847b362 | [
"MIT"
] | null | null | null | MechOS/simple_messages/float_array.py | PierceATronics/MechOS | 8eeb68b65b8c20b642db52baad1379fd0847b362 | [
"MIT"
] | null | null | null | '''
'''
import struct
class Float_Array:
'''
'''
def __init__(self, number_of_floats):
'''
'''
#construct the message format
self.message_constructor = ''
for i in range(number_of_floats):
self.message_constructor += 'f'
#number of bytes for this message
self.size = 4 * number_of_floats
def _pack(self, message):
'''
'''
encoded_message = struct.pack(self.message_constructor, *message)
return(encoded_message)
def _unpack(self, encoded_message):
'''
'''
message = struct.unpack(self.message_constructor, encoded_message)
return(message)
| 23.166667 | 74 | 0.581295 | 71 | 695 | 5.394366 | 0.408451 | 0.143603 | 0.229765 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0.002079 | 0.307914 | 695 | 29 | 75 | 23.965517 | 0.794179 | 0.086331 | 0 | 0 | 0 | 0 | 0.001754 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0.230769 | false | 0 | 0.076923 | 0 | 0.384615 | 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 |
14e5f836655e649b98f06142548eb1ccf113fc48 | 3,287 | py | Python | taco/aws_wrappers/sqs_wrapper/exceptions.py | Intsights/taco | f9a912d146d74a6539d31c33ec289eff3fbfca8f | [
"Apache-2.0"
] | 18 | 2019-09-05T07:53:26.000Z | 2021-02-15T18:23:45.000Z | taco/aws_wrappers/sqs_wrapper/exceptions.py | Intsights/taco | f9a912d146d74a6539d31c33ec289eff3fbfca8f | [
"Apache-2.0"
] | null | null | null | taco/aws_wrappers/sqs_wrapper/exceptions.py | Intsights/taco | f9a912d146d74a6539d31c33ec289eff3fbfca8f | [
"Apache-2.0"
] | null | null | null | import taco.common.exceptions
class SQSWrapperException(taco.common.exceptions.DataDictException):
pass
class SQSClientException(SQSWrapperException):
def __init__(self, message='SQS client error', data_dict=None, exc=None):
super().__init__(message, data_dict=data_dict, exc=exc)
class SendMessageException(SQSWrapperException):
def __init__(self, data, queue_name, exc=None):
data_dict = {
'data': data,
'queue_name': queue_name
}
super().__init__('Failed to send message', data_dict=data_dict, exc=exc)
class ListQueuesClientException(SQSClientException):
def __init__(self, exc=None):
super().__init__('SQS list queues client error', exc=exc)
class CreateQueuesClientException(SQSClientException):
def __init__(self, queue_creation_config, exc=None):
super().__init__('SQS create queue client error',
data_dict={'queue_creation_config': queue_creation_config},
exc=exc)
class GetQueueClientException(SQSClientException):
def __init__(self, queue_name, exc=None):
super().__init__('SQS get queue by name client error', data_dict={'queue_name': queue_name}, exc=exc)
class ClearQueueClientException(SQSClientException):
def __init__(self, queue_name, exc=None):
super().__init__('SQS clear queue client error', data_dict={'queue_name': queue_name}, exc=exc)
class DeleteQueueClientException(SQSClientException):
def __init__(self, queue_name, exc=None):
super().__init__('SQS delete queue client error', data_dict={'queue_name': queue_name}, exc=exc)
class SendMessageClientException(SQSClientException):
def __init__(self, queue_name, data_messages, exc=None):
data_dict = {
'queue_name': queue_name,
'data_messages': data_messages
}
super().__init__('SQS send messages client error', data_dict=data_dict, exc=exc)
class ReadMessageClientException(SQSClientException):
def __init__(self, queue_name, exc=None):
super().__init__('SQS read messages client error', data_dict={'queue_name': queue_name}, exc=exc)
class DeleteMessageClientException(SQSClientException):
def __init__(self, exc=None):
super().__init__('SQS delete messages client error', exc=exc)
class SQSNonExistingQueueException(SQSWrapperException):
def __init__(self, queue_name, exc=None):
super().__init__('None existing queue name', data_dict={'queue_name': queue_name}, exc=exc)
class SQSInvalidParamsException(SQSWrapperException):
def __init__(self, params, exc=None):
super().__init__('AWS invalid param exception',
data_dict={'params': params}, exc=exc)
class SQSCreateExistingQueueParamsErrorException(SQSWrapperException):
def __init__(self, params, exc=None):
super().__init__('A queue already exists with the same name and a different value for an attribute',
data_dict={'params': params}, exc=exc)
class SQSMessageWrapperException(SQSWrapperException):
pass
class SQSDecodingException(SQSMessageWrapperException):
def __init__(self, exc=None):
super().__init__('SQS Message decoding exception', exc=exc)
| 31.304762 | 109 | 0.706115 | 362 | 3,287 | 5.972376 | 0.19337 | 0.091582 | 0.07123 | 0.088807 | 0.517576 | 0.460222 | 0.411656 | 0.37049 | 0.325162 | 0.19889 | 0 | 0 | 0.188318 | 3,287 | 104 | 110 | 31.605769 | 0.810345 | 0 | 0 | 0.271186 | 0 | 0 | 0.170064 | 0.006389 | 0 | 0 | 0 | 0 | 0 | 1 | 0.237288 | false | 0.033898 | 0.016949 | 0 | 0.525424 | 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 |
14f0f4ba6fb449935fe4b6b2c8e2cc876959765c | 499 | py | Python | cloud/urls.py | uestc-msc/uestcmsc_webapp_backend | fce859899346598f5a263b6fabb74deec816bc8c | [
"MIT"
] | 1 | 2021-01-04T01:56:26.000Z | 2021-01-04T01:56:26.000Z | cloud/urls.py | uestc-msc/uestcmsc_webapp_backend | fce859899346598f5a263b6fabb74deec816bc8c | [
"MIT"
] | null | null | null | cloud/urls.py | uestc-msc/uestcmsc_webapp_backend | fce859899346598f5a263b6fabb74deec816bc8c | [
"MIT"
] | null | null | null | from django.urls import path
from cloud.views.login import onedrive_login, onedrive_login_callback
from cloud.views.status import onedrive_status
from cloud.views.file import OnedriveFileView
urlpatterns = [
path('login/', onedrive_login, name='onedrive_login'),
path('login_callback/', onedrive_login_callback, name='onedrive_login_callback'),
path('status/', onedrive_status, name='onedrive_status'),
path('file/', OnedriveFileView.as_view(), name='onedrive_file')
]
| 38.384615 | 86 | 0.759519 | 61 | 499 | 5.967213 | 0.278689 | 0.214286 | 0.115385 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0.126253 | 499 | 12 | 87 | 41.583333 | 0.834862 | 0 | 0 | 0 | 0 | 0 | 0.201232 | 0.047228 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | false | 0 | 0.4 | 0 | 0.4 | 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 |
14f295b56da000b965b3e581d530d9e2d92989aa | 1,440 | py | Python | re_special_sequences.py | godontop/python-work | ea22e0df8b0b17605f5a434e556a388d1f75aa47 | [
"MIT"
] | null | null | null | re_special_sequences.py | godontop/python-work | ea22e0df8b0b17605f5a434e556a388d1f75aa47 | [
"MIT"
] | null | null | null | re_special_sequences.py | godontop/python-work | ea22e0df8b0b17605f5a434e556a388d1f75aa47 | [
"MIT"
] | null | null | null | import re
pattern = r"(.+) \1"
"""Note, that "(.+) \1" is not the same as "(.+) (.+)", because \1 refers to
the first group's subexpression, which is the matched expression itself, and
not the regex pattern."""
match = re.match(pattern, "word word")
if match:
print("Match 1")
print(match.group(1))
print(match.group())
match = re.match(pattern, "?! ?!")
if match:
print("Match 2")
print(match.group(1))
print(match.group())
match = re.match(pattern, "abc cde")
if match:
print("Match 3")
print(match.group(1))
print(match.group())
pattern = r"(.+) (.+) (.+) \1"
match = re.match(pattern, "abc bca cab abc") # \1 represent abc
if match:
print("Match 1-1")
match = re.match(pattern, "abc bca cab bca")
if match:
print("Match 1-2")
match = re.match(pattern, "abc bca cab cab")
if match:
print("Match 1-3")
pattern = r"(.+) (.+) (.+) \2"
match = re.match(pattern, "abc bca cab abc")
if match:
print("Match 2-1")
match = re.match(pattern, "abc bca cab bca") # \2 represent bca
if match:
print("Match 2-2")
match = re.match(pattern, "abc bca cab cab")
if match:
print("Match 2-3")
pattern = r"(.+) (.+) (.+) \3"
match = re.match(pattern, "abc bca cab abc")
if match:
print("Match 3-1")
match = re.match(pattern, "abc bca cab bca")
if match:
print("Match 3-2")
match = re.match(pattern, "abc bca cab cab") # \3 represent cab
if match:
print("Match 3-3")
| 21.176471 | 76 | 0.604861 | 229 | 1,440 | 3.803493 | 0.157205 | 0.206659 | 0.165327 | 0.261768 | 0.741676 | 0.597015 | 0.597015 | 0.561424 | 0.523536 | 0.450057 | 0 | 0.028696 | 0.201389 | 1,440 | 67 | 77 | 21.492537 | 0.728696 | 0.034722 | 0 | 0.574468 | 0 | 0 | 0.261806 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | false | 0 | 0.021277 | 0 | 0.021277 | 0.382979 | 0 | 0 | 0 | null | 1 | 0 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 2 |
14fd87c96809a3d3c2fffb122332a8841a898ea1 | 750 | py | Python | magicclass/ext/qtconsole/__init__.py | hanjinliu/magic-class | 2a9d8af3d385ec3870ebcade9f2dbc03115bed22 | [
"BSD-3-Clause"
] | 15 | 2021-09-07T10:18:59.000Z | 2022-03-23T14:55:45.000Z | magicclass/ext/qtconsole/__init__.py | hanjinliu/magic-class | 2a9d8af3d385ec3870ebcade9f2dbc03115bed22 | [
"BSD-3-Clause"
] | 12 | 2021-09-10T08:54:43.000Z | 2022-03-31T02:43:50.000Z | magicclass/ext/qtconsole/__init__.py | hanjinliu/magic-class | 2a9d8af3d385ec3870ebcade9f2dbc03115bed22 | [
"BSD-3-Clause"
] | 1 | 2022-02-13T15:51:51.000Z | 2022-02-13T15:51:51.000Z | """
Jupyter QtConsole widget with callback signals.
You can embed a console widget in a magic class.
.. code-block:: python
from magicclass import magicclass
from magicclass.widgets import QtConsole
class Main:
console = QtConsole()
ui = Main()
ui.show()
There are some additional methods that would be very useful for developing a Python script
executable GUI.
.. code-block:: python
# programmatically add code to console.
ui.console.value = "a = 1"
# callback when code is executed.
@console.executed.connect
def _():
print("executed!")
# programmatically execute code.
ui.console.execute()
"""
from .widgets import QtConsole
__all__ = ["QtConsole"] | 20.27027 | 91 | 0.665333 | 89 | 750 | 5.550562 | 0.58427 | 0.036437 | 0.060729 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0.001779 | 0.250667 | 750 | 37 | 92 | 20.27027 | 0.877224 | 0.906667 | 0 | 0 | 0 | 0 | 0.155172 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | false | 0 | 0.5 | 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 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 0 | 0 | 2 |
09021381df5a3be4386f02ab347a16b720c9ab70 | 830 | py | Python | transport/req_quick_setup.py | c-thaler/opat | b7cb40572c8566e2791d2c7c54c55c4504de311f | [
"MIT"
] | 3 | 2021-09-03T10:21:39.000Z | 2021-12-17T22:42:56.000Z | transport/req_quick_setup.py | c-thaler/opat | b7cb40572c8566e2791d2c7c54c55c4504de311f | [
"MIT"
] | 2 | 2021-06-23T09:19:59.000Z | 2021-11-19T21:02:39.000Z | transport/req_quick_setup.py | c-thaler/opat | b7cb40572c8566e2791d2c7c54c55c4504de311f | [
"MIT"
] | null | null | null | from .request import Request
from .response import Response
class RequestQuickSetup(Request):
def __init__(self):
super().__init__('qs_component_nego')
def parse_response(self, resp):
return ResponseQuickSetup(resp)
class ResponseQuickSetup(Response):
def __init__(self, bytes):
self.device_type = ''
self.device_model = ''
self.components = []
super().__init__(bytes)
def parse_result(self, result):
self.device_type = result['extra_info']['device_type']
self.device_model = result['extra_info']['device_model']
self.components = result['component_list']
def get_model(self):
return self.device_model
def get_type(self):
return self.device_type
def get_components(self):
return self.components
| 23.714286 | 64 | 0.663855 | 94 | 830 | 5.5 | 0.287234 | 0.116054 | 0.081238 | 0.077369 | 0.096712 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0.231325 | 830 | 34 | 65 | 24.411765 | 0.810345 | 0 | 0 | 0 | 0 | 0 | 0.089157 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0.304348 | false | 0 | 0.086957 | 0.173913 | 0.652174 | 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 |
0907f6023a957727078f080c4709f844c2913ae9 | 4,214 | py | Python | qc_database_create.py | dev-ev/qc-script-PD24 | b3195fef31edc8bc0a12ef3395648e2abf3ca446 | [
"BSD-2-Clause"
] | null | null | null | qc_database_create.py | dev-ev/qc-script-PD24 | b3195fef31edc8bc0a12ef3395648e2abf3ca446 | [
"BSD-2-Clause"
] | null | null | null | qc_database_create.py | dev-ev/qc-script-PD24 | b3195fef31edc8bc0a12ef3395648e2abf3ca446 | [
"BSD-2-Clause"
] | null | null | null | import sqlite3
def create_tables(sql_cursor, table_names):
for table in table_names:
table_command = (''' CREATE TABLE IF NOT EXISTS ''' + table +
''' (
search_id INTEGER PRIMARY KEY,
raw_file TEXT NOT NULL,
file_date TEXT,
search_date TEXT,
instrument TEXT,
protein_number INTEGER,
peptide_number INTEGER NOT NULL,
psm_number INTEGER NOT NULL,
msms_number INTEGER NOT NULL,
id_rate REAL,
mean_psm_it_ms REAL,
median_psm_it_ms REAL,
mean_msms_it_ms REAL,
median_msms_it_ms REAL,
mean_mz_err_ppm REAL,
median_mz_err_ppm REAL,
mz_err_ppm_stdev REAL,
total_prec_intensity REAL,
mean_prec_intensity REAL,
mean_sengine_score REAL,
mean_peak_width REAL,
peak_width_stdev REAL,
pept_416 REAL,
pept_425 REAL,
pept_488 REAL,
pept_495 REAL,
pept_567 REAL,
pept_652 REAL,
pept_655 REAL,
comment TEXT
)''')
sql_cursor.execute(table_command)
populate_with_simulated_vals(sql_cursor, table)
return True
def populate_with_simulated_vals(sql_cursor, table_name):
sql_command = ("INSERT INTO " + table_name +
" VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)")
d = '2019/10/24'
s = '2019/11/07'
i = 'Virtual HF'
simulated_vals_tuple = ((None,'Nothing_01.raw',d,s,i,2000,9000,9500,25000,9500/25000
,20,18,25,22,-3.2,-2.2,1,2500000,65685,25.5,20,5.5,
28,24,19,35,16,32,40,'Simulated'),
(None,'Nothing_02.raw',d,s,i,2000,10000,10000,30000,10000/30000
,18.2,17.5,20.1,19.5,-1.2,-0.8,0.26,2800000,80000,26.2,21.1,6.8,
28,24,19,35,16,32,40,'Simulated'),
(None,'Nothing_03.raw',d,s,i,1500,6000,6200,22000,6200/22000
,35.1,32.6,43.1,35,1.6,1.5,0.6,2900000,91000,28.1,20.3,7.1,
28,24,19,35,16,32,40,'Simulated'),
(None,'Nothing_04.raw',d,s,i,1826,7586,8123,29365,8123/29365
,20,19,23,18.6,0.78,0.65,0.1,30000000,100020,25.17,18.6,5.5,
28,24,19,35,16,32,40,'Simulated'),
(None,'Nothing_05.raw',d,s,i,2230,11258,12000,32000,12000/32000
,13,12.8,15.6,15.6,4.6,4.2,1.6,3100000,120055,28.42,19.35,4.78,
28,24,19,35,16,32,40,'Simulated'))
for val_tuple in simulated_vals_tuple:
sql_cursor.execute(sql_command, val_tuple)
return True
if __name__ == '__main__':
## db_file = 'qc_lumos_st191029.db'
## tables = ('lumos','lumos_faims')
db_file = 'qc_qehf_st191107.db'
tables = ('qehf',)
conn = sqlite3.connect(db_file)
cur = conn.cursor()
create_tables(cur, tables)
conn.commit()
conn.close()
| 47.348315 | 121 | 0.395823 | 440 | 4,214 | 3.575 | 0.359091 | 0.035601 | 0.015893 | 0.019072 | 0.165925 | 0.15321 | 0.15321 | 0.103624 | 0.089002 | 0.089002 | 0 | 0.216936 | 0.501187 | 4,214 | 88 | 122 | 47.886364 | 0.531399 | 0.016137 | 0 | 0.15 | 0 | 0.025 | 0.144834 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0.05 | false | 0 | 0.025 | 0 | 0.125 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 1 | 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 |
0931b205a63853f15d25dd02b11cd46fe5f849fb | 5,732 | py | Python | mocha/contrib/auth/decorators.py | mardix/Mocha | bce481cb31a0972061dd99bc548701411dcb9de3 | [
"MIT"
] | 7 | 2017-05-14T02:21:48.000Z | 2020-11-07T20:12:01.000Z | mocha/contrib/auth/decorators.py | mardix/Mocha | bce481cb31a0972061dd99bc548701411dcb9de3 | [
"MIT"
] | 6 | 2019-11-04T02:52:17.000Z | 2021-05-06T19:00:33.000Z | mocha/contrib/auth/decorators.py | mardix/Mocha | bce481cb31a0972061dd99bc548701411dcb9de3 | [
"MIT"
] | null | null | null | import functools
import flask_login
import signals
import inspect
from mocha import (utils,
abort,
request,
)
from mocha.core import apply_function_to_members
from . import (is_authenticated,
not_authenticated,
ROLES_ADMIN,
ROLES_MANAGER,
ROLES_CONTRIBUTOR,
ROLES_MODERATOR,
__options__,
login_manager)
def login_required(func):
"""
A wrapper around the flask_login.login_required.
But it also checks the presence of the decorator: @login_not_required
On a "@login_required" class, method containing "@login_not_required" will
still be able to access without authentication
:param func:
:return:
"""
if inspect.isclass(func):
apply_function_to_members(func, login_required)
return func
else:
@functools.wraps(func)
def decorated_view(*args, **kwargs):
if "login_not_required" not in utils.get_decorators_list(func) \
and not_authenticated():
return login_manager.unauthorized()
return func(*args, **kwargs)
return decorated_view
def login_not_required(func):
"""
Dummy decorator. @login_required will inspect the method
to look for this decorator
Use this decorator when you want do not require login in a "@login_required" class/method
:param func:
:return:
"""
@functools.wraps(func)
def decorated_view(*args, **kwargs):
return func(*args, **kwargs)
return decorated_view
def logout_user(f):
"""
Decorator to logout user
:param f:
:return:
"""
@functools.wraps(f)
def deco(*a, **kw):
signals.user_logout(lambda: flask_login.current_user)
flask_login.logout_user()
return f(*a, **kw)
return deco
def require_verified_email(f):
pass
def require_login_allowed(f):
"""
Decorator to abort if login is not allowed
:param f:
:return:
"""
@functools.wraps(f)
def deco(*a, **kw):
if not __options__.get("allow_login"):
abort(403, "Login not allowed. Contact admin if it's a mistake")
return f(*a, **kw)
return deco
def require_register_allowed(f):
"""
Decorator to abort if register is not allowed
:param f:
:return:
"""
@functools.wraps(f)
def deco(*a, **kw):
if not __options__.get("allow_register"):
abort(403, "Signup not allowed. Contact admin if it's a mistake")
return f(*a, **kw)
return deco
def require_social_login_allowed(f):
"""
Decorator to abort if social login is not allowed
:param f:
:return:
"""
@functools.wraps(f)
def deco(*a, **kw):
if not __options__.get("allow_social_login"):
abort(403,
"Social login not allowed. Contact admin if it's a mistake")
return f(*a, **kw)
return deco
def accepts_roles(*roles):
"""
A decorator to check if user has any of the roles specified
@roles_accepted('superadmin', 'admin')
def fn():
pass
"""
def wrapper(f):
@functools.wraps(f)
def wrapped(*args, **kwargs):
if is_authenticated():
if not flask_login.current_user.has_any_roles(*roles):
return abort(403)
else:
return abort(401)
return f(*args, **kwargs)
return wrapped
return wrapper
def accepts_admin_roles(func):
"""
Decorator that accepts only admin roles
:param func:
:return:
"""
if inspect.isclass(func):
apply_function_to_members(func, accepts_admin_roles)
return func
else:
@functools.wraps(func)
def decorator(*args, **kwargs):
return accepts_roles(*ROLES_ADMIN)(func)(*args, **kwargs)
return decorator
def accepts_manager_roles(func):
"""
Decorator that accepts only manager roles
:param func:
:return:
"""
if inspect.isclass(func):
apply_function_to_members(func, accepts_manager_roles)
return func
else:
@functools.wraps(func)
def decorator(*args, **kwargs):
return accepts_roles(*ROLES_MANAGER)(func)(*args, **kwargs)
return decorator
def accepts_contributor_roles(func):
"""
Decorator that accepts only contributor roles
:param func:
:return:
"""
if inspect.isclass(func):
apply_function_to_members(func, accepts_contributor_roles)
return func
else:
@functools.wraps(func)
def decorator(*args, **kwargs):
return accepts_roles(*ROLES_CONTRIBUTOR)(func)(*args, **kwargs)
return decorator
def accepts_moderator_roles(func):
"""
Decorator that accepts only moderator roles
:param func:
:return:
"""
if inspect.isclass(func):
apply_function_to_members(func, accepts_moderator_roles)
return func
else:
@functools.wraps(func)
def decorator(*args, **kwargs):
return accepts_roles(*ROLES_MODERATOR)(func)(*args, **kwargs)
return decorator
def jwt_required(func):
"""
Checks if the Authorization barer exists. Otherwise throw 401
:param func:
:return:
"""
if inspect.isclass(func):
apply_function_to_members(func, jwt_required)
return func
else:
@functools.wraps(func)
def deco(*a, **kw):
if not "Authorization" in request.headers:
abort(401, "Not Authorized")
return func(*a, **kw)
return deco
| 24.185654 | 93 | 0.605373 | 669 | 5,732 | 5.007474 | 0.171898 | 0.041791 | 0.057313 | 0.04597 | 0.564776 | 0.549851 | 0.489552 | 0.436119 | 0.356418 | 0.356418 | 0 | 0.005214 | 0.297278 | 5,732 | 236 | 94 | 24.288136 | 0.826465 | 0.202547 | 0 | 0.475806 | 0 | 0 | 0.057611 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0.209677 | false | 0.008065 | 0.056452 | 0.040323 | 0.540323 | 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 |
0936cbc9db6a2f168c576414260f1de745b212f0 | 248 | py | Python | chapter03/knock23.py | m-star18/NLP100 | e199814f81943f7fb693fd5fe87d6df21da07f5b | [
"MIT"
] | 1 | 2020-07-15T17:21:13.000Z | 2020-07-15T17:21:13.000Z | chapter03/knock23.py | m-star18/NLP100 | e199814f81943f7fb693fd5fe87d6df21da07f5b | [
"MIT"
] | 1 | 2021-05-04T01:04:57.000Z | 2021-05-04T01:05:32.000Z | chapter03/knock23.py | m-star18/NLP100 | e199814f81943f7fb693fd5fe87d6df21da07f5b | [
"MIT"
] | null | null | null | import re
import pandas as pd
df = pd.read_json('jawiki-country.json', lines=True)
text = df.query('title=="イギリス"')['text'].values[0]
for section in re.findall(r'(=+)([^=]+)\1\n', text):
print('{}: {}'.format(section[0], len(section[0]) - 1))
| 31 | 59 | 0.616935 | 40 | 248 | 3.8 | 0.7 | 0.105263 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0.022727 | 0.112903 | 248 | 7 | 60 | 35.428571 | 0.668182 | 0 | 0 | 0 | 0 | 0 | 0.229839 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | false | 0 | 0.333333 | 0 | 0.333333 | 0.166667 | 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 |
09399832f6abda5bf7a701a221666d2db88de5e7 | 663 | py | Python | portfolio/views.py | notandrewdev/dennispham.me | e3e66dde3594d76d43db30b25c1feecca50b8207 | [
"MIT"
] | 1 | 2021-09-24T22:48:33.000Z | 2021-09-24T22:48:33.000Z | portfolio/views.py | notandrewdev/dennispham.me | e3e66dde3594d76d43db30b25c1feecca50b8207 | [
"MIT"
] | null | null | null | portfolio/views.py | notandrewdev/dennispham.me | e3e66dde3594d76d43db30b25c1feecca50b8207 | [
"MIT"
] | null | null | null | from django.shortcuts import render
from django.views import View
from portfolio.utils import get_repo_data
class IndexView(View):
template_name = 'portfolio/index.html'
def get(self, request):
repos = get_repo_data()
return render(request, self.template_name, {'repos': repos[:6]})
class ProjectsView(View):
template_name = 'portfolio/projects.html'
def get(self, request):
repos = get_repo_data()
return render(request, self.template_name, {'repos': repos})
class AboutView(View):
template_name = 'portfolio/about.html'
def get(self, request):
return render(request, self.template_name)
| 23.678571 | 72 | 0.696833 | 84 | 663 | 5.357143 | 0.333333 | 0.16 | 0.073333 | 0.166667 | 0.488889 | 0.442222 | 0.364444 | 0.364444 | 0.364444 | 0.364444 | 0 | 0.001873 | 0.19457 | 663 | 27 | 73 | 24.555556 | 0.840824 | 0 | 0 | 0.294118 | 0 | 0 | 0.110106 | 0.034691 | 0 | 0 | 0 | 0 | 0 | 1 | 0.176471 | false | 0 | 0.176471 | 0.058824 | 0.882353 | 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 |
09410169f52885dff457b7efb72d7cee3582a94d | 1,358 | py | Python | class4/ex4.py | jordanwimb/kbpython | 01620098fb17df6b2b3b31a2c1b0b645df3a3e0a | [
"MIT"
] | null | null | null | class4/ex4.py | jordanwimb/kbpython | 01620098fb17df6b2b3b31a2c1b0b645df3a3e0a | [
"MIT"
] | null | null | null | class4/ex4.py | jordanwimb/kbpython | 01620098fb17df6b2b3b31a2c1b0b645df3a3e0a | [
"MIT"
] | null | null | null | #!/usr/bin/env python
from __future__ import print_function
import pexpect
import getpass
import time
def show_ip_int_brief(remote_conn):
remote_conn.sendline('show ip int brief')
remote_conn.expect('#')
print(remote_conn.before)
def set_logging(remote_conn):
remote_conn.sendline('config t')
remote_conn.expect('#')
remote_conn.sendline('logging buffered 20011')
remote_conn.expect('#')
print(remote_conn.before)
remote_conn.sendline('exit')
remote_conn.expect('#')
def verify_config(remote_conn):
remote_conn.sendline('sh run | i logging')
time.sleep(2)
remote_conn.expect('#')
print(remote_conn.before)
def main():
#Establish SSH connection
ip_address = '50.76.53.27'
user = 'pyclass'
password = getpass.getpass()
port = 8022
passphrase = "Enter passphrase for key"
remote_conn = pexpect.spawn('ssh -l {} {} -p {}'.format(user,ip_address,port))
remote_conn.timeout = 6
remote_conn.expect(":")
remote_conn.sendline()
time.sleep(1)
remote_conn.sendline()
time.sleep(1)
remote_conn.expect('ssword:')
remote_conn.sendline(password)
remote_conn.expect('#')
print(remote_conn.before)
#Send and verify commands
set_logging(remote_conn)
verify_config(remote_conn)
if __name__ == '__main__':
main()
| 24.690909 | 82 | 0.681149 | 176 | 1,358 | 4.977273 | 0.375 | 0.308219 | 0.164384 | 0.09589 | 0.436073 | 0.351598 | 0.251142 | 0.166667 | 0 | 0 | 0 | 0.019143 | 0.192194 | 1,358 | 54 | 83 | 25.148148 | 0.779398 | 0.050074 | 0 | 0.333333 | 0 | 0 | 0.117327 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0.095238 | false | 0.095238 | 0.095238 | 0 | 0.190476 | 0.119048 | 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 | 1 | 0 | 0 | 0 | 0 | 0 | 2 |
095adf95fb1490031c56ba76283d60003d5ff783 | 1,254 | py | Python | combinations_tuple.py | luk-f/10-mille | 629d2ef8b3519e5999b4e13064aa4cc4beb35bed | [
"MIT"
] | null | null | null | combinations_tuple.py | luk-f/10-mille | 629d2ef8b3519e5999b4e13064aa4cc4beb35bed | [
"MIT"
] | null | null | null | combinations_tuple.py | luk-f/10-mille | 629d2ef8b3519e5999b4e13064aa4cc4beb35bed | [
"MIT"
] | null | null | null | import sys
from typing import List
from combination import _Combination
from collections import Counter
if sys.version_info < (3,9):
ListCombinations = List[_Combination]
else:
ListCombinations = list[_Combination]
class CombinationsTuple(ListCombinations):
"""
Contient une liste de combinaisons
"""
def __init__(self, list_combi: ListCombinations = None) -> None:
if list_combi is None:
super().__init__()
else:
super().__init__(list_combi)
def total_score(self) -> int:
return sum([x._score for x in self])
def number_of_dices(self) -> int:
return sum([x.count_dices() for x in self])
def combination_of_dices(self) -> Counter:
new_counter = Counter()
for x in self:
new_counter += x._combi
return new_counter
def __add__(self, ct_right):
return CombinationsTuple(super().__add__(ct_right))
def __eq__(self, ct_right) -> bool:
if self.combination_of_dices() == ct_right.combination_of_dices() \
and self.total_score() == ct_right.total_score():
return True
else:
return False
def __hash__(self):
return hash(tuple(sorted(self))) | 27.26087 | 75 | 0.636364 | 151 | 1,254 | 4.907285 | 0.350993 | 0.047233 | 0.024292 | 0.040486 | 0.080972 | 0 | 0 | 0 | 0 | 0 | 0 | 0.002176 | 0.267145 | 1,254 | 46 | 76 | 27.26087 | 0.804135 | 0.027113 | 0 | 0.090909 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0.212121 | false | 0 | 0.121212 | 0.121212 | 0.575758 | 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 |
095d50fac06c41e853895c759e14f78dffd688b5 | 573 | py | Python | v1/menu/migrations/0009_auto_20190301_1353.py | homemdasneves/openeats-api | 602c9b638f1861a95e736ba730bfc6045a4680ee | [
"MIT"
] | 11 | 2018-03-04T18:03:30.000Z | 2021-09-04T17:03:24.000Z | v1/menu/migrations/0009_auto_20190301_1353.py | homemdasneves/openeats-api | 602c9b638f1861a95e736ba730bfc6045a4680ee | [
"MIT"
] | 42 | 2020-06-05T14:55:57.000Z | 2021-07-14T05:58:09.000Z | v1/menu/migrations/0009_auto_20190301_1353.py | jzyrobert/openeats-api | 35e1f1c8e61812e405ec15cc66d8e543d15409b6 | [
"MIT"
] | 40 | 2018-06-22T18:58:19.000Z | 2022-01-31T08:34:05.000Z | # Generated by Django 2.1.7 on 2019-03-01 13:53
from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
('menu', '0008_auto_20181120_0041'),
]
operations = [
migrations.AlterField(
model_name='menuitem',
name='all_day',
field=models.BooleanField(blank=True, default=False),
),
migrations.AlterField(
model_name='menuitem',
name='complete',
field=models.BooleanField(blank=True, default=False),
),
]
| 23.875 | 65 | 0.588133 | 58 | 573 | 5.706897 | 0.672414 | 0.120846 | 0.151057 | 0.175227 | 0.513595 | 0.513595 | 0.265861 | 0 | 0 | 0 | 0 | 0.076923 | 0.296684 | 573 | 23 | 66 | 24.913043 | 0.744417 | 0.078534 | 0 | 0.470588 | 1 | 0 | 0.110266 | 0.043726 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | false | 0 | 0.058824 | 0 | 0.235294 | 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 |
11764c529ee65199056902b8e8e08f948c209391 | 1,198 | py | Python | RdP/RdP_Class.py | TheLopezepoL/Elecciones | 7cfd4983e772312602dba081563147c1c02f38b9 | [
"MIT"
] | null | null | null | RdP/RdP_Class.py | TheLopezepoL/Elecciones | 7cfd4983e772312602dba081563147c1c02f38b9 | [
"MIT"
] | null | null | null | RdP/RdP_Class.py | TheLopezepoL/Elecciones | 7cfd4983e772312602dba081563147c1c02f38b9 | [
"MIT"
] | null | null | null | class Persona:
cedula = 0
nombre = ''
telefono = 0
voto = 0
def __init__(self, cd, nm, tl, vt):
self.cedula = cd
self.nombre = nm
self.telefono = tl
self.voto = vt
def getCedula(self):
return self.cedula
def getNombre(self):
return self.nombre
def getTelefono(self):
return self.telefono
def getVoto(self):
return self.voto
def getTodo(self):
return self.cedula, self.nombre, self.telefono, self.voto
class Estudiante(Persona):
carnet = ''
carrera = ''
def __init__(self, cd, nm, tl, vt):
self.carnet = ''
self.carrera = ''
Persona.__init__(self, cd, nm, tl, vt)
def setCarnet(self, cn):
self.carnet = cn
def setCarrera(self, cr):
self.carrera = cr
def getCarnet(self):
return self.carnet
def getCarrera(self):
return self.carrera
def getTodo(self):
datos = []
datos.append(Estudiante.getCarnet(self))
datos.append(Estudiante.getCarrera(self))
persona = Persona.getTodo(self)
for p in persona:
datos.append(p)
return datos
| 20.305085 | 65 | 0.568447 | 140 | 1,198 | 4.778571 | 0.242857 | 0.104634 | 0.146487 | 0.053812 | 0.092676 | 0.092676 | 0.068759 | 0.068759 | 0 | 0 | 0 | 0.003722 | 0.327212 | 1,198 | 58 | 66 | 20.655172 | 0.826303 | 0 | 0 | 0.093023 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0.27907 | false | 0 | 0 | 0.162791 | 0.651163 | 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 |
118f47131391517129004dabb1fe7a4d689eddaf | 800 | py | Python | idp_user/schema_extensions.py | CardoAI/django-idp-user | 8f0d3e04e5c6dd7b94a9afe41bb20ad0ffe214ad | [
"MIT"
] | 5 | 2022-01-06T15:18:45.000Z | 2022-02-21T11:12:06.000Z | idp_user/schema_extensions.py | CardoAI/django-idp-user | 8f0d3e04e5c6dd7b94a9afe41bb20ad0ffe214ad | [
"MIT"
] | null | null | null | idp_user/schema_extensions.py | CardoAI/django-idp-user | 8f0d3e04e5c6dd7b94a9afe41bb20ad0ffe214ad | [
"MIT"
] | 1 | 2022-03-29T07:50:15.000Z | 2022-03-29T07:50:15.000Z | from drf_spectacular.extensions import OpenApiAuthenticationExtension
from drf_spectacular.openapi import AutoSchema
from drf_spectacular.utils import OpenApiParameter
from idp_user.auth.authentication import AuthenticationBackend
class BearerTokenScheme(OpenApiAuthenticationExtension):
target_class = AuthenticationBackend # full import path OR class ref
name = 'IDPAuthentication' # name used in the schema
def get_security_definition(self, auto_schema):
return {
"type": "http",
"scheme": "bearer",
"bearerFormat": "JWT",
}
class AutoSchemaWithRole(AutoSchema):
def get_override_parameters(self):
return [
OpenApiParameter("role", type=str, location=OpenApiParameter.QUERY, required=True),
]
| 32 | 95 | 0.7225 | 76 | 800 | 7.473684 | 0.657895 | 0.036972 | 0.09507 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0.205 | 800 | 24 | 96 | 33.333333 | 0.893082 | 0.06625 | 0 | 0 | 0 | 0 | 0.075269 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0.111111 | false | 0 | 0.222222 | 0.111111 | 0.666667 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 1 | 0 | 0 | 2 |
1190b00af78d3a99ea4b6ed230cb748a790b8a25 | 999 | py | Python | integration/settings_spec.py | tek/ribosome-py | 8bd22e549ddff1ee893d6e3a0bfba123a09e96c6 | [
"MIT"
] | null | null | null | integration/settings_spec.py | tek/ribosome-py | 8bd22e549ddff1ee893d6e3a0bfba123a09e96c6 | [
"MIT"
] | null | null | null | integration/settings_spec.py | tek/ribosome-py | 8bd22e549ddff1ee893d6e3a0bfba123a09e96c6 | [
"MIT"
] | null | null | null | from kallikrein import Expectation
from amino import do, Do
from amino.test.spec import SpecBase
from ribosome.nvim.api.variable import variable_set
from ribosome.nvim.api.exists import command_once_defined
from ribosome.test.klk.matchers.variable import var_must_become
from ribosome.nvim.io.compute import NvimIO
from ribosome.test.integration.embed import TestConfig, plugin_test
from ribosome.nvim.api.function import nvim_call_function
from test.settings import settings_spec_config
@do(NvimIO[Expectation])
def settings_spec() -> Do:
yield nvim_call_function('PlugCheck')
yield var_must_become('counter', 21)
@do(NvimIO[None])
def pre() -> Do:
yield variable_set('counter', 7)
yield variable_set('inc', 14)
test_config = TestConfig.cons(settings_spec_config, pre=pre)
class SettingsSpec(SpecBase):
'''
update a setting $update
'''
def update(self) -> Expectation:
return plugin_test(test_config, settings_spec)
__all__ = ('SettingsSpec',)
| 24.365854 | 67 | 0.767768 | 137 | 999 | 5.40146 | 0.386861 | 0.097297 | 0.086486 | 0.077027 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0.005814 | 0.139139 | 999 | 40 | 68 | 24.975 | 0.854651 | 0.024024 | 0 | 0 | 0 | 0 | 0.039625 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0.130435 | false | 0 | 0.434783 | 0.043478 | 0.652174 | 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 |
1194282a6eece41089b2a6a1cedaacbeda88927b | 2,828 | py | Python | camd3/infrastructure/component/statebroker.py | mamrhein/CAmD3 | d20f62295771a297c3fbb314beef314e5ec7a2b5 | [
"BSD-2-Clause"
] | null | null | null | camd3/infrastructure/component/statebroker.py | mamrhein/CAmD3 | d20f62295771a297c3fbb314beef314e5ec7a2b5 | [
"BSD-2-Clause"
] | null | null | null | camd3/infrastructure/component/statebroker.py | mamrhein/CAmD3 | d20f62295771a297c3fbb314beef314e5ec7a2b5 | [
"BSD-2-Clause"
] | null | null | null | # -*- coding: utf-8 -*-
# ----------------------------------------------------------------------------
# Name: statebroker
# Purpose: Extensions used to notify state changes
#
# Author: Michael Amrhein (michael@adrhinum.de)
#
# Copyright: (c) 2018 Michael Amrhein
# License: This program is part of a larger application. For license
# details please read the file LICENSE.TXT provided together
# with the application.
# ----------------------------------------------------------------------------
# $Source$
# $Revision$
"""Extensions used to notify state changes"""
# standard library imports
from abc import abstractmethod
# third-party imports
# local imports
from .component import Component, implementer
from .attribute import MultiValueAttribute
from .extension import TransientExtension
class StateChangedListener(Component):
"""Abstract base class for listeners on state changes of components.
"""
@abstractmethod
def register_state_changed(self, obj: Component) -> None:
"""Called when an associated instance changes its state."""
class StateChangedNotifyer(Component):
"""Abstract base class of components notifying state changes of
components.
"""
@abstractmethod
def add_listener(self, listener: StateChangedListener) -> None:
"""Add `listener` to the set of registered listeners."""
@abstractmethod
def remove_listener(self, listener: StateChangedListener) -> None:
"""Remove `listener` from the set of registered listeners."""
@abstractmethod
def notify_state_changed(self, obj: Component):
"""Notify all registered listeners about a state change.
Calls `register_state_changed` of each listener.
"""
@implementer(StateChangedNotifyer)
class StateChangedNotifyerExtension(TransientExtension):
"""Base class for notifyers of state changes of components,
attached to the component as transient extension.
"""
__slots__ = ('_listeners_',)
_listeners = MultiValueAttribute(default=set())
def __new__(cls, obj: Component) -> 'StateChangedNotifyer':
try: # an instance already attached to `obj`?
return cls.get_from(obj)
except ValueError:
notifyer = super().__new__(cls)
notifyer.attach_to(obj)
return notifyer
def __init__(self, obj: Component) -> None:
pass
def add_listener(self, listener: StateChangedListener) -> None:
self._listeners.add(listener)
def remove_listener(self, listener: StateChangedListener) -> None:
self._listeners.remove(listener)
def notify_state_changed(self, obj: Component):
for listener in self._listeners:
listener.register_state_changed(obj)
| 29.768421 | 78 | 0.648161 | 280 | 2,828 | 6.410714 | 0.389286 | 0.033426 | 0.035655 | 0.089136 | 0.313649 | 0.29805 | 0.216156 | 0 | 0 | 0 | 0 | 0.002256 | 0.216407 | 2,828 | 94 | 79 | 30.085106 | 0.807762 | 0.42256 | 0 | 0.294118 | 0 | 0 | 0.02013 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0.264706 | false | 0.029412 | 0.117647 | 0 | 0.588235 | 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 |
1197cd2679fc97fd3f99a975dfc9f5a63df7fd3a | 2,449 | py | Python | intermol/forces/quartic_angle_type.py | ctk3b/intermol | 5224b0a01e6db02ecb9dc1e6996a6df5e9bf630d | [
"MIT"
] | null | null | null | intermol/forces/quartic_angle_type.py | ctk3b/intermol | 5224b0a01e6db02ecb9dc1e6996a6df5e9bf630d | [
"MIT"
] | 5 | 2015-01-06T13:21:51.000Z | 2015-01-20T21:39:11.000Z | intermol/forces/quartic_angle_type.py | ctk3b/intermol | 5224b0a01e6db02ecb9dc1e6996a6df5e9bf630d | [
"MIT"
] | null | null | null | import simtk.unit as units
from intermol.decorators import accepts_compatible_units
from intermol.forces.abstract_angle_type import AbstractAngleType
class QuarticAngleType(AbstractAngleType):
__slots__ = ['theta', 'C0', 'C1', 'C2', 'C3', 'C4', 'c']
@accepts_compatible_units(None, None, None,
theta=units.degrees,
C0=units.kilojoules_per_mole,
C1=units.kilojoules_per_mole * units.radians ** (-1),
C2=units.kilojoules_per_mole * units.radians ** (-2),
C3=units.kilojoules_per_mole * units.radians ** (-3),
C4=units.kilojoules_per_mole * units.radians ** (-4),
c=None)
def __init__(self, bondingtype1, bondingtype2, bondingtype3,
theta=0.0 * units.degrees,
C0=0.0 * units.kilojoules_per_mole,
C1=0.0 * units.kilojoules_per_mole * units.radians ** (-1),
C2=0.0 * units.kilojoules_per_mole * units.radians ** (-2),
C3=0.0 * units.kilojoules_per_mole * units.radians ** (-3),
C4=0.0 * units.kilojoules_per_mole * units.radians ** (-4),
c=False):
AbstractAngleType.__init__(self, bondingtype1, bondingtype2, bondingtype3, c)
self.theta = theta
self.C0 = C0
self.C1 = C1
self.C2 = C2
self.C3 = C3
self.C4 = C4
class QuarticAngle(QuarticAngleType):
"""
stub documentation
"""
def __init__(self, atom1, atom2, atom3, bondingtype1=None, bondingtype2=None, bondingtype3=None,
theta=0.0 * units.degrees,
C0=0.0 * units.kilojoules_per_mole,
C1=0.0 * units.kilojoules_per_mole * units.radians ** (-1),
C2=0.0 * units.kilojoules_per_mole * units.radians ** (-2),
C3=0.0 * units.kilojoules_per_mole * units.radians ** (-3),
C4=0.0 * units.kilojoules_per_mole * units.radians ** (-4),
c=False):
self.atom1 = atom1
self.atom2 = atom2
self.atom3 = atom3
QuarticAngleType.__init__(self, bondingtype1, bondingtype2, bondingtype3,
theta=theta,
C0=C0,
C1=C1,
C2=C2,
C3=C3,
C4=C4,
c=c) | 42.964912 | 101 | 0.534096 | 264 | 2,449 | 4.742424 | 0.185606 | 0.179712 | 0.215655 | 0.263578 | 0.576677 | 0.522364 | 0.448083 | 0.448083 | 0.330671 | 0.330671 | 0 | 0.061276 | 0.353614 | 2,449 | 57 | 102 | 42.964912 | 0.729627 | 0.00735 | 0 | 0.291667 | 0 | 0 | 0.006623 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0.041667 | false | 0 | 0.0625 | 0 | 0.166667 | 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 |
119cbfbd1c3bff3a22b6251d3ca6506e4ea53bbf | 921 | py | Python | tests/conftest.py | sterin/lektor-markdown-header-anchors | 6d086a43aef36838869f11a1ebda1817326f3174 | [
"BSD-3-Clause"
] | 1 | 2018-02-24T23:32:43.000Z | 2018-02-24T23:32:43.000Z | tests/conftest.py | sterin/lektor-markdown-header-anchors | 6d086a43aef36838869f11a1ebda1817326f3174 | [
"BSD-3-Clause"
] | null | null | null | tests/conftest.py | sterin/lektor-markdown-header-anchors | 6d086a43aef36838869f11a1ebda1817326f3174 | [
"BSD-3-Clause"
] | null | null | null | import os
import py
import pytest
import time
from lektor.project import Project
from lektor.environment import Environment
from lektor_markdown_header_anchors import MarkdownHeaderAnchorsPlugin
def pytest_generate_tests(metafunc):
if 'project' in metafunc.fixturenames:
cwd = os.path.dirname(__file__)
metafunc.parametrize(
"project_path", [
os.path.join(cwd, 'demo-project'),
os.path.join(cwd, 'demo-project-random'),
], indirect=True)
@pytest.fixture(scope='function')
def project_path(request):
return request.param
@pytest.fixture(scope='function')
def project(project_path):
return Project.from_path(project_path, 'demo-project')
@pytest.fixture(scope='function')
def env(project):
return Environment(project)
@pytest.fixture
def plugin(env):
return MarkdownHeaderAnchorsPlugin(env, "markdown-header-anchors")
| 23.025 | 70 | 0.717698 | 107 | 921 | 6.046729 | 0.35514 | 0.068006 | 0.083462 | 0.120556 | 0.230294 | 0.185471 | 0 | 0 | 0 | 0 | 0 | 0 | 0.179153 | 921 | 39 | 71 | 23.615385 | 0.85582 | 0 | 0 | 0.111111 | 0 | 0 | 0.11835 | 0.024973 | 0 | 0 | 0 | 0 | 0 | 1 | 0.185185 | false | 0 | 0.259259 | 0.148148 | 0.592593 | 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 |
11aa9259f3ef9e45b5591ccecd8d843e6e1cb323 | 92 | py | Python | output/models/saxon_data/open/open016_xsd/__init__.py | tefra/xsdata-w3c-tests | b6b6a4ac4e0ab610e4b50d868510a8b7105b1a5f | [
"MIT"
] | 1 | 2021-08-14T17:59:21.000Z | 2021-08-14T17:59:21.000Z | output/models/saxon_data/open/open016_xsd/__init__.py | tefra/xsdata-w3c-tests | b6b6a4ac4e0ab610e4b50d868510a8b7105b1a5f | [
"MIT"
] | 4 | 2020-02-12T21:30:44.000Z | 2020-04-15T20:06:46.000Z | output/models/saxon_data/open/open016_xsd/__init__.py | tefra/xsdata-w3c-tests | b6b6a4ac4e0ab610e4b50d868510a8b7105b1a5f | [
"MIT"
] | null | null | null | from output.models.saxon_data.open.open016_xsd.open016 import Doc
__all__ = [
"Doc",
]
| 15.333333 | 65 | 0.728261 | 13 | 92 | 4.692308 | 0.846154 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0.076923 | 0.152174 | 92 | 5 | 66 | 18.4 | 0.705128 | 0 | 0 | 0 | 0 | 0 | 0.032609 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | false | 0 | 0.25 | 0 | 0.25 | 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 |
11c2445a34287d690d27b4365c47cf2a41a75a94 | 9,993 | py | Python | tests/test_posthocs.py | theavey/scikit-posthocs | 80a67998342c128f2490e4a70b714e157314af1b | [
"BSD-3-Clause"
] | null | null | null | tests/test_posthocs.py | theavey/scikit-posthocs | 80a67998342c128f2490e4a70b714e157314af1b | [
"BSD-3-Clause"
] | null | null | null | tests/test_posthocs.py | theavey/scikit-posthocs | 80a67998342c128f2490e4a70b714e157314af1b | [
"BSD-3-Clause"
] | null | null | null | import os, sys
sys.path.append(os.path.abspath(os.path.join(os.path.dirname(__file__), '..')))
import unittest
import scikit_posthocs._posthocs as sp
import seaborn as sb
import numpy as np
class TestPosthocs(unittest.TestCase):
df = sb.load_dataset("exercise")
df_bn = np.array([[4,3,4,4,5,6,3],
[1,2,3,5,6,7,7],
[1,2,6,4,1,5,1]])
def test_posthoc_conover(self):
r_results = np.array([[-1, 1.131263e-02, 9.354690e-11],
[1.131263e-02, -1, 5.496288e-06],
[9.354690e-11, 5.496288e-06, -1]])
results = sp.posthoc_conover(self.df, val_col = 'pulse', group_col = 'kind', p_adjust = 'holm')
self.assertTrue(np.allclose(results, r_results))
def test_posthoc_dunn(self):
r_results = np.array([[-1, 4.390066e-02, 9.570998e-09],
[4.390066e-02, -1, 1.873208e-04],
[9.570998e-09, 1.873208e-04, -1]])
results = sp.posthoc_dunn(self.df, val_col = 'pulse', group_col = 'kind', p_adjust = 'holm')
self.assertTrue(np.allclose(results, r_results, atol=1.e-4))
def test_posthoc_nemenyi(self):
r_results = np.array([[-1, 1.313107e-01, 2.431833e-08],
[1.313107e-01, -1, 4.855675e-04],
[2.431833e-08, 4.855675e-04, -1]])
results = sp.posthoc_nemenyi(self.df, val_col = 'pulse', group_col = 'kind')
self.assertTrue(np.allclose(results, r_results, atol=1.e-4))
def test_posthoc_nemenyi_friedman(self):
p_results = np.array([[-1., 0.9, 0.82163255, 0.9, 0.9, 0.21477876, 0.9],
[0.9, -1., 0.87719193, 0.9, 0.9, 0.25967965, 0.9],
[0.82163255, 0.87719193, -1., 0.9, 0.9, 0.9, 0.9],
[0.9, 0.9, 0.9, -1., 0.9, 0.87719193, 0.9],
[0.9, 0.9, 0.9, 0.9, -1., 0.87719193, 0.9],
[0.21477876, 0.25967965, 0.9, 0.87719193, 0.87719193, -1., 0.54381888],
[0.9, 0.9, 0.9, 0.9, 0.9, 0.54381888, -1.]])
results = sp.posthoc_nemenyi_friedman(self.df_bn)
self.assertTrue(np.allclose(results, p_results, atol=1.e-4))
def test_posthoc_conover_friedman(self):
results = sp.posthoc_conover_friedman(self.df_bn)
p_results = np.array([[-1.000000, 0.935333, 0.268619, 0.339721, 0.339721, 0.060540, 0.628079],
[0.935333, -1.000000, 0.302605, 0.380025, 0.380025, 0.070050, 0.685981],
[0.268619, 0.302605, -1.000000, 0.871144, 0.871144, 0.380025, 0.519961],
[0.339721, 0.380025, 0.871144, -1.000000, 1.000000, 0.302605, 0.628079],
[0.339721, 0.380025, 0.871144, 1.000000, -1.000000, 0.302605, 0.628079],
[0.060540, 0.070050, 0.380025, 0.302605, 0.302605, -1.000000, 0.141412],
[0.628079, 0.685981, 0.519961, 0.628079, 0.628079, 0.141412, -1.000000]])
self.assertTrue(np.allclose(results, p_results))
def test_posthoc_miller_friedman(self):
results = sp.posthoc_miller_friedman(self.df_bn)
p_results = np.array([[-1.0, 1.0, 0.9411963, 0.9724396000000001, 0.9724396000000001, 0.4717981, 0.9993864],
[1.0, -1.0, 0.9588993, 0.9823818000000001, 0.9823818000000001, 0.5256257, 0.9997869],
[0.9411963, 0.9588993, -1.0, 0.9999991, 0.9999991, 0.9823818000000001, 0.9968575999999999],
[0.9724396000000001, 0.9823818000000001, 0.9999991, -1.0, 1.0, 0.9588993, 0.9993864],
[0.9724396000000001, 0.9823818000000001, 0.9999991, 1.0, -1.0, 0.9588993, 0.9993864],
[0.4717981, 0.5256257, 0.9823818000000001, 0.9588993, 0.9588993, -1.0, 0.7803545999999999],
[0.9993864, 0.9997869, 0.9968575999999999, 0.9993864, 0.9993864, 0.7803545999999999, -1.0]])
self.assertTrue(np.allclose(results, p_results))
def test_posthoc_siegel_friedman(self):
results = sp.posthoc_siegel_friedman(self.df_bn)
p_results = np.array([[-1.000000, 0.92471904, 0.18587673, 0.25683926, 0.25683926, 0.01816302, 0.57075039],
[0.92471904, -1.0000000, 0.2193026, 0.2986177, 0.2986177, 0.0233422, 0.6366016],
[0.18587673, 0.2193026, -1.0000000, 0.8501067, 0.8501067, 0.2986177, 0.4496918],
[0.25683926, 0.2986177, 0.8501067, -1.000000, 1.0000000, 0.2193026, 0.5707504],
[0.25683926, 0.2986177, 0.8501067, 1.0000000, -1.0000000, 0.2193026, 0.5707504],
[0.01816302, 0.0233422, 0.2986177, 0.2193026, 0.2193026, -1.000000, 0.07260094],
[0.57075039, 0.6366016, 0.4496918, 0.5707504, 0.5707504, 0.07260094, -1.000000]])
self.assertTrue(np.allclose(results, p_results))
def test_posthoc_durbin(self):
results = sp.posthoc_durbin(self.df_bn, p_adjust = 'holm')
p_results = np.array([[-1.000000, 1.000000, 1.0, 1.0, 1.0, 0.381364, 1.0],
[1.000000, -1.000000, 1.0, 1.0, 1.0, 0.444549, 1.0],
[1.000000, 1.000000, -1.0, 1.0, 1.0, 1.000000, 1.0],
[1.000000, 1.000000, 1.0, -1.0, 1.0, 1.000000, 1.0],
[1.000000, 1.000000, 1.0, 1.0, -1.0, 1.000000, 1.0],
[0.381364, 0.444549, 1.0, 1.0, 1.0, -1.000000, 1.0],
[1.000000, 1.000000, 1.0, 1.0, 1.0, 1.000000, -1.0]])
self.assertTrue(np.allclose(results, p_results))
def test_posthoc_quade(self):
results = sp.posthoc_quade(self.df_bn)
p_results = np.array([[-1.00000000, 0.67651326, 0.15432143, 0.17954686, 0.2081421 , 0.02267043, 0.2081421],
[ 0.67651326,-1.00000000, 0.29595042, 0.33809987, 0.38443835, 0.0494024 , 0.38443835],
[ 0.15432143, 0.29595042,-1.00000000, 0.92586499, 0.85245022, 0.29595042, 0.85245022],
[ 0.17954686, 0.33809987, 0.92586499,-1.00000000, 0.92586499, 0.25789648, 0.92586499],
[ 0.2081421 , 0.38443835, 0.85245022, 0.92586499,-1.00000000, 0.22378308, 1.00000000],
[ 0.02267043, 0.0494024 , 0.29595042, 0.25789648, 0.22378308,-1.00000000, 0.22378308],
[ 0.2081421 , 0.38443835, 0.85245022, 0.92586499, 1.00000000, 0.22378308,-1.00000000]])
self.assertTrue(np.allclose(results, p_results))
def test_posthoc_vanwaerden(self):
r_results = np.array([[-1, 1.054709e-02, 6.476665e-11],
[1.054709e-02, -1, 4.433141e-06],
[6.476665e-11, 4.433141e-06, -1]])
results = sp.posthoc_vanwaerden(self.df, val_col = 'pulse', group_col = 'kind', p_adjust='holm')
self.assertTrue(np.allclose(results, r_results))
def test_posthoc_ttest(self):
r_results = np.array([[-1, 9.757069e-03, 4.100954e-07],
[9.757069e-03, -1, 1.556010e-05],
[4.100954e-07, 1.556010e-05, -1]])
results = sp.posthoc_ttest(self.df, val_col = 'pulse', group_col = 'kind', equal_var = False, p_adjust='holm')
self.assertTrue(np.allclose(results, r_results))
def test_posthoc_tukey_hsd(self):
x = [[1,2,3,4,5], [35,31,75,40,21], [10,6,9,6,1]]
g = [['a'] * 5, ['b'] * 5, ['c'] * 5]
results = sp.posthoc_tukey_hsd(np.concatenate(x), np.concatenate(g))
n_results = np.array([[-1, 1, 0],[ 1, -1, 1],[ 0, 1, -1]])
self.assertTrue(np.allclose(n_results, results))
def test_posthoc_mannwhitney(self):
r_results = np.array([[-1, 1.714393e-02, 3.420508e-08],
[1.714393e-02, -1, 1.968352e-05],
[3.420508e-08, 1.968352e-05, -1]])
results = sp.posthoc_mannwhitney(self.df, val_col = 'pulse', group_col = 'kind')
self.assertTrue(np.allclose(results, r_results))
def test_posthoc_wilcoxon(self):
r_results = np.array([[-1, 2.337133e-03, 2.857818e-06],
[2.337133e-03, -1, 1.230888e-05],
[2.857818e-06, 1.230888e-05, -1]])
results = sp.posthoc_wilcoxon(self.df.sort_index(), val_col = 'pulse', group_col = 'kind')
self.assertTrue(np.allclose(results, r_results))
def test_posthoc_scheffe(self):
r_results = np.array([[-1, 3.378449e-01, 3.047472e-10],
[3.378449e-01, -1, 2.173209e-07],
[3.047472e-10, 2.173209e-07, -1]])
results = sp.posthoc_scheffe(self.df.sort_index(), val_col = 'pulse', group_col = 'kind')
self.assertTrue(np.allclose(results, r_results))
def test_posthoc_tamhane(self):
r_results = np.array([[-1, 2.898653e-02, 4.100954e-07],
[2.898653e-02, -1, 2.333996e-05],
[4.100954e-07, 2.333996e-05, -1]])
results = sp.posthoc_tamhane(self.df.sort_index(), val_col = 'pulse', group_col = 'kind')
self.assertTrue(np.allclose(results, r_results))
def test_posthoc_tukey(self):
r_results = np.array([[-1, 3.042955e-01, 4.308631e-10],
[3.042955e-01, -1, 9.946571e-08],
[4.308631e-10, 9.946571e-08, -1]])
results = sp.posthoc_tukey(self.df.sort_index(), val_col = 'pulse', group_col = 'kind')
print(results)
self.assertTrue(np.allclose(results, r_results, atol=1.e-3))
if __name__ == '__main__':
unittest.main()
| 51.510309 | 122 | 0.539678 | 1,392 | 9,993 | 3.768678 | 0.136494 | 0.017918 | 0.017156 | 0.013725 | 0.551468 | 0.450438 | 0.436523 | 0.374571 | 0.359131 | 0.353031 | 0 | 0.378401 | 0.297608 | 9,993 | 193 | 123 | 51.777202 | 0.368998 | 0 | 0 | 0.1 | 0 | 0 | 0.013109 | 0 | 0 | 0 | 0 | 0 | 0.121429 | 1 | 0.121429 | false | 0 | 0.035714 | 0 | 0.178571 | 0.007143 | 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 |
11c90659f16ae49e7bb856c343efb42deeac93ac | 463 | py | Python | src/Classes/MSDS400/Module 8/flights.py | bmoretz/Python-Playground | a367ec7659b85c24363c21b5c0ac25db08ffa1f6 | [
"MIT"
] | null | null | null | src/Classes/MSDS400/Module 8/flights.py | bmoretz/Python-Playground | a367ec7659b85c24363c21b5c0ac25db08ffa1f6 | [
"MIT"
] | null | null | null | src/Classes/MSDS400/Module 8/flights.py | bmoretz/Python-Playground | a367ec7659b85c24363c21b5c0ac25db08ffa1f6 | [
"MIT"
] | null | null | null | # In February, a major airline had 77.8% of their flights arrive on time. Assume that the event that a given flight arrives on time is independent of the event that another flight arrives on time.
# A writer plans to take four separate flights for her publisher next month. Assuming the airline has the same on-time performance as in February, what is the probability that all four flights arrive on time?
prob = .778
round( prob * prob * prob * prob, 4 ) | 66.142857 | 211 | 0.760259 | 80 | 463 | 4.4 | 0.5875 | 0.085227 | 0.085227 | 0.107955 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0.018617 | 0.187905 | 463 | 7 | 212 | 66.142857 | 0.917553 | 0.87689 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | false | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 0 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 2 |
11cb57a31e9c96add22d7af2732d40f2f697c3e3 | 3,032 | py | Python | pyiron_contrib/__init__.py | pyiron/pyiron_contrib | e1a9be9927dfcbd242dfe58f4eba854f5b241d7c | [
"BSD-3-Clause"
] | 5 | 2020-02-20T13:44:52.000Z | 2021-06-22T12:59:23.000Z | pyiron_contrib/__init__.py | pyiron/pyiron_contrib | e1a9be9927dfcbd242dfe58f4eba854f5b241d7c | [
"BSD-3-Clause"
] | 325 | 2020-01-13T11:39:14.000Z | 2022-03-30T20:40:16.000Z | pyiron_contrib/__init__.py | pyiron/pyiron_contrib | e1a9be9927dfcbd242dfe58f4eba854f5b241d7c | [
"BSD-3-Clause"
] | 5 | 2020-09-09T14:51:09.000Z | 2021-02-17T04:14:29.000Z | __version__ = "0.1"
__all__ = []
import warnings
try:
from pyiron import Project
except:
warnings.warn("pyiron module not found, importing Project from pyiron_base")
from pyiron_base import Project
from pyiron_base import JOB_CLASS_DICT
# Make classes available for new pyiron version
JOB_CLASS_DICT['ProtoMinimGradDes'] = 'pyiron_contrib.protocol.compound.minimize'
JOB_CLASS_DICT['ProtoMD'] = 'pyiron_contrib.protocol.compound.molecular_dynamics'
JOB_CLASS_DICT['ProtoConfinedMD'] = 'pyiron_contrib.protocol.compound.molecular_dynamics'
JOB_CLASS_DICT['ProtoHarmMD'] = 'pyiron_contrib.protocol.compound.molecular_dynamics'
JOB_CLASS_DICT['ProtoNEBSer'] = 'pyiron_contrib.protocol.compound.nudged_elastic_band'
JOB_CLASS_DICT['ProtocolQMMM'] = 'pyiron_contrib.protocol.compound.qmmm'
JOB_CLASS_DICT['ProtoHarmTILDSer'] = 'pyiron_contrib.protocol.compound.thermodynamic_integration'
JOB_CLASS_DICT['ProtoHarmTILDPar'] = 'pyiron_contrib.protocol.compound.thermodynamic_integration'
JOB_CLASS_DICT['ProtoVacTILDSer'] = 'pyiron_contrib.protocol.compound.thermodynamic_integration'
JOB_CLASS_DICT['ProtoVacTILDPar'] = 'pyiron_contrib.protocol.compound.thermodynamic_integration'
JOB_CLASS_DICT['ProtoVacForm'] = 'pyiron_contrib.protocol.compound.thermodynamic_integration'
JOB_CLASS_DICT['ProtoFTSEvoSer'] = 'pyiron_contrib.protocol.compound.finite_temperature_string'
JOB_CLASS_DICT['ProtoFTSEvoPar'] = 'pyiron_contrib.protocol.compound.finite_temperature_string'
JOB_CLASS_DICT['ImageJob'] = 'pyiron_contrib.image.job'
JOB_CLASS_DICT['LangevinAse'] = 'pyiron_contrib.atomistics.interactive.langevin'
JOB_CLASS_DICT['Mixer'] = 'pyiron_contrib.atomistics.interactive.mixer'
JOB_CLASS_DICT['ParameterMaster'] = 'pyiron_contrib.atomistics.dft.parametermaster'
JOB_CLASS_DICT['MonteCarloMaster'] = 'pyiron_contrib.atomistics.interactive.montecarlo'
JOB_CLASS_DICT['RandSpg'] = 'pyiron_contrib.atomistics.randspg.randspg'
JOB_CLASS_DICT['Fenics'] = 'pyiron_contrib.continuum.fenics.job.generic'
JOB_CLASS_DICT['FenicsLinearElastic'] = 'pyiron_contrib.continuum.fenics.job.elastic'
JOB_CLASS_DICT['TrainingContainer'] = 'pyiron_contrib.atomistics.atomistics.job.trainingcontainer'
JOB_CLASS_DICT['RandomDisMaster'] = 'pyiron_contrib.atomistics.mlip.masters'
JOB_CLASS_DICT['RandomMDMaster'] = 'pyiron_contrib.atomistics.mlip.masters'
JOB_CLASS_DICT['RunnerFit'] = 'pyiron_contrib.atomistics.runner.job'
JOB_CLASS_DICT['MlipSelect'] = 'pyiron_contrib.atomistics.mlip.mlipselect'
JOB_CLASS_DICT['Mlip'] = 'pyiron_contrib.atomistics.mlip.mlip'
JOB_CLASS_DICT['LammpsMlip'] = 'pyiron_contrib.atomistics.mlip.lammps'
JOB_CLASS_DICT['MlipJob'] = 'pyiron_contrib.atomistics.mlip.mlipjob'
JOB_CLASS_DICT['Atomicrex'] = 'pyiron_contrib.atomistics.atomicrex.atomicrex_job'
JOB_CLASS_DICT['StructureMasterInt'] = 'pyiron_contrib.atomistics.atomistics.job.structurelistmasterinteractive'
JOB_CLASS_DICT['StorageJob'] = 'pyiron_contrib.RDM.storagejob'
from ._version import get_versions
__version__ = get_versions()["version"]
del get_versions
| 57.207547 | 112 | 0.835422 | 359 | 3,032 | 6.688022 | 0.245125 | 0.109954 | 0.164931 | 0.157018 | 0.355269 | 0.299459 | 0.299459 | 0.299459 | 0.261141 | 0.053311 | 0 | 0.000695 | 0.050462 | 3,032 | 52 | 113 | 58.307692 | 0.833275 | 0.014842 | 0 | 0 | 0 | 0 | 0.651926 | 0.499833 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | false | 0 | 0.136364 | 0 | 0.136364 | 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 |
11d6b2db5147fc4bd2deabade1249652535fbe21 | 1,218 | py | Python | Mainapp/models.py | swasthikshetty10/EPAX-AI | 7d8d0103c82ecf3d6396f51cc2fad234ee7880be | [
"MIT"
] | 9 | 2021-01-31T05:23:58.000Z | 2021-10-05T06:38:36.000Z | Mainapp/models.py | swasthikshetty10/EPAX-AI | 7d8d0103c82ecf3d6396f51cc2fad234ee7880be | [
"MIT"
] | 1 | 2021-01-31T05:56:38.000Z | 2021-01-31T05:56:38.000Z | Mainapp/models.py | swasthikshetty10/EPAX-AI | 7d8d0103c82ecf3d6396f51cc2fad234ee7880be | [
"MIT"
] | 2 | 2021-02-01T03:11:18.000Z | 2022-01-16T11:09:58.000Z | from django.db import models
from django.utils import timezone
# Create your models here.
from django.contrib.auth.models import User
class feedback(models.Model):
user = models.CharField('name', max_length=100)
value = models.CharField('value', max_length=1000)
class UserNotes(models.Model):
user = models.ForeignKey(User, on_delete=models.CASCADE)
date = models.DateTimeField(auto_now_add=True)
title = models.CharField('title', max_length=1000)
value = models.TextField()
def __str__(self):
return self.title
class Todo(models.Model):
user = models.ForeignKey(User, on_delete=models.CASCADE)
title = models.CharField(max_length=100)
details = models.TextField()
date = models.DateTimeField(auto_now_add=True)
def __str__(self):
return self.title
# class UserData(models.Model):
# user = models.CharField('userid', max_length=100)
# notes = models.ForeignKey(
# UserNotes, on_delete=models.CASCADE, default=None, null=True)
# todo = models.ForeignKey(
# Todo, on_delete=models.CASCADE, default=None, null=True)
# def __str__(self):
# return self.user
# class Meta:
# ordering = ['user']
| 27.681818 | 71 | 0.692118 | 153 | 1,218 | 5.346405 | 0.326797 | 0.091687 | 0.07335 | 0.102689 | 0.496333 | 0.422983 | 0.398533 | 0.234719 | 0.136919 | 0.136919 | 0 | 0.017259 | 0.191297 | 1,218 | 43 | 72 | 28.325581 | 0.813198 | 0.325123 | 0 | 0.4 | 0 | 0 | 0.017284 | 0 | 0 | 0 | 0 | 0.023256 | 0 | 1 | 0.1 | false | 0 | 0.15 | 0.1 | 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 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 2 |
11dacfae236bb2868be6d98eb259c100abed2c5c | 1,275 | py | Python | seminars/seminar06/python/account.py | andrewt0301/QA_Testing_Course | 630daa76af40eccdec45362b588e1ef5dece8cce | [
"Apache-2.0"
] | 10 | 2018-10-14T21:35:20.000Z | 2020-09-08T16:15:00.000Z | seminars/seminar06/python/account.py | andrewt0301/QA_Testing_Course | 630daa76af40eccdec45362b588e1ef5dece8cce | [
"Apache-2.0"
] | 5 | 2018-09-22T08:57:10.000Z | 2019-09-13T21:38:05.000Z | seminars/seminar06/python/account.py | andrewt0301/QA_Testing_Course | 630daa76af40eccdec45362b588e1ef5dece8cce | [
"Apache-2.0"
] | 3 | 2018-10-14T21:37:51.000Z | 2019-10-05T07:40:19.000Z | class Account:
def __init__(self):
self.__blocked: bool = False
self.__bound: int = 1000000
self.__balance: int = 0
self.__max_credit: int = -1000
def deposit(self, _sum: int) -> bool:
if self.__blocked :
return False
if _sum < 0 or _sum > self.__bound:
return False
self.__balance += _sum
return True
def withdraw(self, _sum: int) -> bool:
if self.__blocked :
return False
if _sum < 0 or _sum > self.__bound :
return False
if self.__balance <= self.__max_credit + _sum:
return False
self.__balance -= _sum
return True
def get_balance(self) -> int:
return self.__balance
def get_max_credit(self) -> int:
return -self.__max_credit
def is_blocked(self) -> bool:
return self.__blocked
def block(self) -> None:
self.__blocked = True
def unblock(self) -> bool:
if self.__balance < self.__max_credit:
return False
self.__blocked = False
return True
def set_max_credit(self, mc: int) -> bool:
if abs(mc) > self.__bound:
return False
self.__max_credit = -mc
return True
| 26.020408 | 54 | 0.562353 | 152 | 1,275 | 4.282895 | 0.203947 | 0.096774 | 0.099846 | 0.092166 | 0.428571 | 0.391705 | 0.311828 | 0.311828 | 0.211982 | 0.211982 | 0 | 0.01699 | 0.353725 | 1,275 | 48 | 55 | 26.5625 | 0.773058 | 0 | 0 | 0.375 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0.225 | false | 0 | 0 | 0.075 | 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 | 1 | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 2 |
11eba2cc36dc80f215242ef0328cad7e7a88c0da | 219 | py | Python | setup.py | winstvn/bgone | 6f5a91933de5b4a9f1a178f725e58e3730cd0ab4 | [
"MIT"
] | null | null | null | setup.py | winstvn/bgone | 6f5a91933de5b4a9f1a178f725e58e3730cd0ab4 | [
"MIT"
] | null | null | null | setup.py | winstvn/bgone | 6f5a91933de5b4a9f1a178f725e58e3730cd0ab4 | [
"MIT"
] | null | null | null | from distutils.core import setup
setup(name='bgone',
version='0.1',
packages=['utility', 'cogs'],
package_dir={
'utility': 'bgone/utility',
'cogs': 'bgone/cogs'
}
)
| 19.909091 | 39 | 0.515982 | 22 | 219 | 5.090909 | 0.681818 | 0.196429 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0.013333 | 0.315068 | 219 | 10 | 40 | 21.9 | 0.733333 | 0 | 0 | 0 | 0 | 0 | 0.242009 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | true | 0 | 0.111111 | 0 | 0.111111 | 0 | 1 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 2 |
11ee1089300eedd6ef201213395ccaa077a3ddcd | 955 | py | Python | alfastaff_account/services/activate_handler.py | spanickroon/Alfa-Staff | 4db9332634f278bac2fb7b543bcd86a2651214e2 | [
"MIT"
] | 1 | 2020-12-22T12:14:44.000Z | 2020-12-22T12:14:44.000Z | alfastaff_account/services/activate_handler.py | ZayJob/Alfa-Staff | 4db9332634f278bac2fb7b543bcd86a2651214e2 | [
"MIT"
] | 6 | 2020-12-20T01:32:44.000Z | 2021-07-08T10:11:14.000Z | alfastaff_account/services/activate_handler.py | spanickroon/Alfa-Staff | 4db9332634f278bac2fb7b543bcd86a2651214e2 | [
"MIT"
] | 1 | 2020-12-06T18:28:36.000Z | 2020-12-06T18:28:36.000Z | """This module contain functions for activate user."""
from django.contrib.auth import login
from django.contrib.auth.models import User
from django.contrib.auth.hashers import check_password, make_password
from django.utils.encoding import force_bytes, force_text
from django.utils.http import urlsafe_base64_encode, urlsafe_base64_decode
from .tokens import account_activation_token
def activate_processing(request: object, uidb64: str, token: str) -> bool:
"""Check user in database after decoding params and changes is_active status and login user."""
try:
uid = force_text(urlsafe_base64_decode(uidb64))
user = User.objects.get(pk=uid)
except(TypeError, ValueError, OverflowError, User.DoesNotExist):
user = None
if user is not None and account_activation_token.check_token(user, token):
user.is_active = True
user.save()
login(request, user)
return True
return False
| 35.37037 | 99 | 0.744503 | 129 | 955 | 5.364341 | 0.511628 | 0.072254 | 0.073699 | 0.09104 | 0.072254 | 0 | 0 | 0 | 0 | 0 | 0 | 0.012755 | 0.179058 | 955 | 26 | 100 | 36.730769 | 0.869898 | 0.144503 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0.055556 | false | 0.055556 | 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 |
11fd94d35a84a34d30e1e632de8268de67ad47c1 | 171 | py | Python | config.py | DryDockTestOrganization/cuda | 83df8f6781485ae75cdfd984e33c4ce01b376faa | [
"BSD-3-Clause"
] | null | null | null | config.py | DryDockTestOrganization/cuda | 83df8f6781485ae75cdfd984e33c4ce01b376faa | [
"BSD-3-Clause"
] | null | null | null | config.py | DryDockTestOrganization/cuda | 83df8f6781485ae75cdfd984e33c4ce01b376faa | [
"BSD-3-Clause"
] | null | null | null | import logging
from beeprint import pp
log = logging.getLogger()
HTTP_RETRY_ATTEMPTS = 3
HTTP_RETRY_WAIT_SECS = 30
SUPPORTED_DISTRO_LIST = ["ubuntu", "ubi", "centos"]
| 15.545455 | 51 | 0.760234 | 24 | 171 | 5.125 | 0.833333 | 0.146341 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0.020408 | 0.140351 | 171 | 10 | 52 | 17.1 | 0.816327 | 0 | 0 | 0 | 0 | 0 | 0.087719 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | false | 0 | 0.333333 | 0 | 0.333333 | 0.166667 | 1 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 0 | 0 | 2 |
11fe7fcdda5b58e6be5aa8ce96dde3cd1c7350f1 | 464 | py | Python | parking_permits/tests/factories/product.py | SuviVappula/parking-permits | fb8689384ce4732de5a550778994ad63e88796e1 | [
"MIT"
] | null | null | null | parking_permits/tests/factories/product.py | SuviVappula/parking-permits | fb8689384ce4732de5a550778994ad63e88796e1 | [
"MIT"
] | 102 | 2021-04-14T06:25:15.000Z | 2022-03-31T12:04:50.000Z | parking_permits/tests/factories/product.py | SuviVappula/parking-permits | fb8689384ce4732de5a550778994ad63e88796e1 | [
"MIT"
] | 5 | 2021-04-29T09:55:26.000Z | 2022-03-07T08:38:36.000Z | from datetime import date
from decimal import Decimal
import factory
from parking_permits.models import Product
from .zone import ParkingZoneFactory
class ProductFactory(factory.django.DjangoModelFactory):
zone = factory.SubFactory(ParkingZoneFactory)
start_date = date(2021, 1, 1)
end_date = date(2021, 12, 31)
unit_price = Decimal(30)
vat = Decimal(0.24)
low_emission_discount = Decimal(0.5)
class Meta:
model = Product
| 22.095238 | 56 | 0.734914 | 59 | 464 | 5.677966 | 0.59322 | 0.077612 | 0.071642 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0.056 | 0.19181 | 464 | 20 | 57 | 23.2 | 0.837333 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | false | 0 | 0.357143 | 0 | 0.928571 | 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 |
ee98ef192b45aa8e88f7aaffd165c01e45f24a30 | 243 | py | Python | main/urls.py | srinidhibhat45/yearbook | 03675508df7967eb1ea85e87b9671ab605fa088d | [
"MIT"
] | 7 | 2021-05-15T11:38:46.000Z | 2021-08-14T13:20:45.000Z | main/urls.py | srinidhibhat45/yearbook | 03675508df7967eb1ea85e87b9671ab605fa088d | [
"MIT"
] | 4 | 2021-06-09T15:30:54.000Z | 2021-09-08T07:38:28.000Z | main/urls.py | srinidhibhat45/yearbook | 03675508df7967eb1ea85e87b9671ab605fa088d | [
"MIT"
] | null | null | null | from django.contrib import admin
from django.urls import path
from main import views
urlpatterns = [
path('', views.index, name='home'),
path('about/', views.about, name='about'),
path('gallery/', views.gallery, name='gallery'),
] | 27 | 52 | 0.683128 | 32 | 243 | 5.1875 | 0.46875 | 0.120482 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0.152263 | 243 | 9 | 53 | 27 | 0.805825 | 0 | 0 | 0 | 0 | 0 | 0.122951 | 0 | 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 |
ee98f4cd074f2baec7575eb62295f72c9cd24123 | 263 | py | Python | XtDac/ChandraUtils/setup_ftools.py | giacomov/XtDac | 60eb1f1d492c7ab3099731738c257955502194a6 | [
"BSD-3-Clause"
] | 1 | 2020-01-08T19:57:19.000Z | 2020-01-08T19:57:19.000Z | chandra_suli/setup_ftools.py | nitikayad96/chandra_suli | 905ded69825f8b3d4fa29a84661697abdb827a87 | [
"BSD-3-Clause"
] | null | null | null | chandra_suli/setup_ftools.py | nitikayad96/chandra_suli | 905ded69825f8b3d4fa29a84661697abdb827a87 | [
"BSD-3-Clause"
] | null | null | null | import os
def setup_ftools_non_interactive():
"""
Setup the environment so the FTOOLS can be run in the batch farm without a terminal attached to them.
:return: none
"""
os.environ['HEADASNOQUERY'] = ''
os.environ['HEADASPROMPT'] = ''
| 20.230769 | 105 | 0.661597 | 34 | 263 | 5.029412 | 0.794118 | 0.105263 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0.231939 | 263 | 12 | 106 | 21.916667 | 0.846535 | 0.441065 | 0 | 0 | 0 | 0 | 0.19685 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0.25 | true | 0 | 0.25 | 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 | 1 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 2 |
ee9d2c0e5de73a9ac806a4e5c047f311e45a92c1 | 2,265 | py | Python | src/Channel.py | AndryGamingYT/TwitchChannelAnalyzer | be4080f51b0bcdcae776e86718b1076688ddfdae | [
"MIT"
] | null | null | null | src/Channel.py | AndryGamingYT/TwitchChannelAnalyzer | be4080f51b0bcdcae776e86718b1076688ddfdae | [
"MIT"
] | null | null | null | src/Channel.py | AndryGamingYT/TwitchChannelAnalyzer | be4080f51b0bcdcae776e86718b1076688ddfdae | [
"MIT"
] | null | null | null | from datetime import datetime
class Channel:
__broadcaster_language: str
__broadcaster_login: str
__display_name: str
__game_id: str
__game_name: str
__id: str
__is_live: bool
__tags_ids: list[str]
__thumbnail_url: str
__title: str
__started_at: datetime
def __init__(self, broadcaster_language: str = None, broadcaster_login: str = None, display_name: str = None, game_id: str = None, game_name: str = None, id: str = None, is_live: bool = None, tags_ids: list[str] = None, thumbnail_url: str = None, title: str = None, started_at: datetime = None):
self.__broadcaster_language = broadcaster_language
self.__broadcaster_login = broadcaster_login
self.__display_name = display_name
self.__game_id = game_id
self.__game_name = game_name
self.__id = id
self.__is_live = is_live
self.__tags_ids = tags_ids
self.__thumbnail_url = thumbnail_url
self.__title = title
self.started_at = started_at
@property
def broadcaster_language(self):
return self.__broadcaster_language
@property
def broadcaster_login(self):
return self.__broadcaster_login
@property
def display_name(self):
return self.__display_name
@property
def game_id(self):
return self.__game_id
@property
def game_name(self):
return self.__game_name
@property
def id(self):
return self.__id
@property
def is_live(self):
return self.__is_live
@property
def tags_ids(self):
return self.__tags_ids
@property
def thumbnail_url(self):
return self.__thumbnail_url
@property
def title(self):
return self.__title
@property
def started_at(self):
return self.__started_at
@started_at.setter
def started_at(self, value: datetime):
"""
Args:
started_at (datetime): UTC datetime
"""
self.__started_at = value
@started_at.setter
def started_at(self, value: str):
"""
Args:
started_at (str): UTC datetime
"""
self.__started_at = datetime.strptime(value, "%Y-%m-%dT%H:%M:%SZ") if value else ""
| 25.449438 | 299 | 0.640618 | 279 | 2,265 | 4.72043 | 0.150538 | 0.095672 | 0.116932 | 0.036446 | 0.117692 | 0.05467 | 0.05467 | 0.05467 | 0 | 0 | 0 | 0 | 0.277704 | 2,265 | 88 | 300 | 25.738636 | 0.805012 | 0.037969 | 0 | 0.203125 | 0 | 0 | 0.008507 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0.21875 | false | 0 | 0.015625 | 0.171875 | 0.59375 | 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 |
eea22febbb608a549e0591dcefec0948532b0388 | 686 | py | Python | opendht_rest/core.py | mongoishere/opendht_rest | e2acb4b37c16efcee9f09386fde1804cafde9a51 | [
"BSD-2-Clause"
] | 4 | 2018-12-28T04:51:16.000Z | 2019-10-19T22:44:42.000Z | opendht_rest/core.py | mongoishere/opendht_rest | e2acb4b37c16efcee9f09386fde1804cafde9a51 | [
"BSD-2-Clause"
] | 1 | 2018-12-29T03:37:12.000Z | 2018-12-29T03:37:12.000Z | opendht_rest/core.py | mongoishere/opendht_rest | e2acb4b37c16efcee9f09386fde1804cafde9a51 | [
"BSD-2-Clause"
] | null | null | null | import connexion
from flask import Flask, render_template, request
# Create app instance and specify specification dir for Swagger
app = connexion.App(__name__, specification_dir='./')
# Provide Swagger specification YAML or JSON file
app.add_api('swagger.yml')
@app.route('/test_button.html', methods=['GET'])
def button():
return render_template('test_button.html');
# Route '/' to home.html
@app.route('/api', methods=['GET', 'POST', 'PUT'])
def homeA():
return render_template('home.html')
@app.route('/', methods=['GET', 'POST', 'PUT'])
def homeB():
return render_template('home.html')
if __name__ == '__main__':
app.run(host='0.0.0.0', port=5000, debug=True) | 28.583333 | 63 | 0.699708 | 96 | 686 | 4.791667 | 0.5 | 0.121739 | 0.130435 | 0.069565 | 0.208696 | 0 | 0 | 0 | 0 | 0 | 0 | 0.013333 | 0.125364 | 686 | 24 | 64 | 28.583333 | 0.753333 | 0.19242 | 0 | 0.133333 | 0 | 0 | 0.194192 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0.2 | false | 0 | 0.133333 | 0.2 | 0.533333 | 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 |
eea59054b3c29d9d76bf9ec81c545fbc2b73a725 | 7,004 | py | Python | src/runner/runner_transform.py | k-harada/abstraction-and-reasoning-challenge | 42828a3f39be3c77bd0f4e1648b2cb1d9d15ed95 | [
"MIT"
] | 3 | 2020-05-28T03:46:23.000Z | 2020-05-29T22:53:32.000Z | src/runner/runner_transform.py | k-harada/abstraction-and-reasoning-challenge | 42828a3f39be3c77bd0f4e1648b2cb1d9d15ed95 | [
"MIT"
] | null | null | null | src/runner/runner_transform.py | k-harada/abstraction-and-reasoning-challenge | 42828a3f39be3c77bd0f4e1648b2cb1d9d15ed95 | [
"MIT"
] | 2 | 2020-05-29T07:22:22.000Z | 2020-05-29T22:53:36.000Z | from src.data import Problem
from src.operator.transformer.interior import Interior
from src.operator.transformer.fill_rectangle import FillRectangle
from src.operator.transformer.diff_color import DiffColor
from src.operator.transformer.align import Align
from src.operator.transformer.connect_line.row import ConnectRow
from src.operator.transformer.connect_line.col import ConnectCol
from src.operator.transformer.connect_line.row_col import ConnectRowCol
from src.operator.transformer.connect_line.diagonal import ConnectDiagonal
from src.operator.transformer.reducer.fill_pattern.periodicity_row_col import AutoFillRowColPeriodicity
from src.operator.transformer.reducer.fill_pattern.symmetry_delete import AutoFillLineSymmetryDelete
from src.operator.transformer.reducer.fill_pattern.symmetry_add import AutoFillLineSymmetryAdd
from src.operator.transformer.reducer.fill_pattern.symmetry_full import AutoFillLineSymmetryFull
from src.operator.transformer.reducer.fill_pattern.symmetry_rot import AutoFillRotSymmetry
from src.operator.transformer.reducer.trim_background import TrimBackground
from src.operator.transformer.reducer.collect_mesh import CollectMax
from src.operator.transformer.reducer.fractal import Fractal
from src.operator.transformer.paste_color import PasteColor
from src.operator.transformer.switch_color import SwitchColor
from src.operator.transformer.keep_max_color import KeepMaxColor
from src.operator.transformer.change_background import ChangeBackground
from src.operator.transformer.arithmetic.n_cell import NCell
from src.operator.transformer.arithmetic.n_color import NColor
from src.operator.transformer.arithmetic.min_max import MinMax
from src.operator.transformer.arithmetic.mod_2 import Mod2
from src.operator.transformer.arithmetic.arg_sort import ArgSort
from src.operator.transformer.arithmetic.max_color import MaxColor
from src.operator.transformer.arithmetic.count_hole import CountHole
from src.operator.transformer.zoom import ZoomTransformer
from src.operator.transformer.rectangle_hole import RectangleHole
from src.operator.transformer.duplicate import DuplicateTransformer
from src.operator.transformer.shadow import Shadow
from src.operator.transformer.keep_mesh import KeepMesh
from src.operator.transformer.arithmetic.find_rectangle import RectangleFinder
from src.operator.transformer.arithmetic.find_symmetry import SymmetryFinder
from src.operator.transformer.reducer.drop_duplicates import DropDuplicates
from src.operator.transformer.arithmetic.sort import Sort
from src.operator.transformer.arithmetic.hash_count import HashFreq
from src.operator.transformer.arithmetic.frequency import Freq
from src.operator.transformer.keeper.keep_rectangle import RectangleKeeper
from src.operator.transformer.keeper.keep_max import MaxKeeper
def run_transform(p: Problem, command: str) -> Problem:
if command == "diff_color":
return DiffColor.problem(p)
elif command == "connect_row":
return ConnectRow.problem(p)
elif command == "connect_col":
return ConnectCol.problem(p)
elif command == "connect_row_col":
return ConnectRowCol.problem(p)
elif command == "connect_diagonal":
return ConnectDiagonal.problem(p)
elif command == "auto_fill_row_col_periodicity":
return AutoFillRowColPeriodicity.problem(p)
elif command == "auto_fill_line_symmetry_del":
return AutoFillLineSymmetryDelete.problem(p)
elif command == "auto_fill_line_symmetry_add":
return AutoFillLineSymmetryAdd.problem(p)
elif command == "auto_fill_line_symmetry_full":
return AutoFillLineSymmetryFull.problem(p)
elif command == "auto_fill_rot":
return AutoFillRotSymmetry.problem(p, False)
elif command == "auto_fill_rot_full":
return AutoFillRotSymmetry.problem(p, True)
elif command == "trim_background":
return TrimBackground.problem(p)
elif command == "collect_max":
return CollectMax.problem(p)
elif command == "fractal":
return Fractal.problem(p)
elif command == "paste_color":
return PasteColor.problem(p, False)
elif command == "paste_color_full":
return PasteColor.problem(p, True)
elif command == "switch_color":
return SwitchColor.problem(p)
elif command == "keep_max_color":
return KeepMaxColor.problem(p)
elif command == "change_background":
return ChangeBackground.problem(p)
elif command == "arg_sort":
return ArgSort.problem(p)
elif command == "n_cell":
return NCell.problem(p)
elif command == "n_cell_keep_none":
return NCell.problem(p, True)
elif command == "n_color":
return NColor.problem(p)
elif command == "max_color":
return MaxColor.problem(p)
elif command == "min_max":
return MinMax.problem(p)
elif command == "mod_2":
return Mod2.problem(p)
elif command == "count_hole":
return CountHole.problem(p)
elif command == "fill_rectangle":
return FillRectangle.problem(p)
elif command == "interior_dir4_zero":
return Interior.problem(p)
elif command == "shadow_bool":
return Shadow.problem(p, "bool")
elif command == "shadow_same":
return Shadow.problem(p, "same")
elif command == "shadow_max":
return Shadow.problem(p, "max")
elif command == "shadow_min":
return Shadow.problem(p, "min")
elif command == "shadow_mesh":
return Shadow.problem(p, "mesh")
elif command == "shadow_ones":
return Shadow.problem(p, "ones")
elif command == "shadow_problem_max":
return Shadow.problem(p, "problem_max")
elif command == "keep_mesh":
return KeepMesh.problem(p)
elif command == "find_rectangle":
return RectangleFinder.problem(p)
elif command == "find_symmetry":
return SymmetryFinder.problem(p)
elif command == "transform_zoom":
return ZoomTransformer.problem(p)
elif command == "transform_duplicate":
return DuplicateTransformer.problem(p)
elif command == "drop_duplicates":
return DropDuplicates.problem(p)
elif command == "sort_ascending":
return Sort.problem(p, descending=False)
elif command == "sort_descending":
return Sort.problem(p, descending=True)
elif command == "freq":
return Freq.problem(p)
elif command == "hash_freq":
return HashFreq.problem(p)
elif command == "rectangle_hole_simple":
return RectangleHole.problem(p, hole_type="simple")
elif command == "rectangle_hole_mesh":
return RectangleHole.problem(p, hole_type="mesh")
elif command == "rectangle_hole_mesh_x":
return RectangleHole.problem(p, hole_type="mesh_x")
elif command == "keep_rectangle":
return RectangleKeeper.problem(p)
elif command == "keep_max":
return MaxKeeper.problem(p)
elif command == "align":
return Align.problem(p)
else:
raise NotImplementedError
| 46.384106 | 103 | 0.748572 | 834 | 7,004 | 6.141487 | 0.140288 | 0.081218 | 0.117142 | 0.203046 | 0.389887 | 0.209684 | 0.10289 | 0.063452 | 0 | 0 | 0 | 0.000853 | 0.162907 | 7,004 | 150 | 104 | 46.693333 | 0.872761 | 0 | 0 | 0 | 0 | 0 | 0.10751 | 0.021845 | 0 | 0 | 0 | 0 | 0 | 1 | 0.006757 | false | 0 | 0.277027 | 0 | 0.635135 | 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 |
eeabe424d714545335a7300eba313b5f99b437ba | 927 | py | Python | src/modules/synker/providers/errors.py | Ja7ad/MoeinBackup | bf94c2b23bd13c7275872497d424ecbb2dab177d | [
"Apache-2.0"
] | null | null | null | src/modules/synker/providers/errors.py | Ja7ad/MoeinBackup | bf94c2b23bd13c7275872497d424ecbb2dab177d | [
"Apache-2.0"
] | null | null | null | src/modules/synker/providers/errors.py | Ja7ad/MoeinBackup | bf94c2b23bd13c7275872497d424ecbb2dab177d | [
"Apache-2.0"
] | null | null | null | # internal
from src.translation import _
from src.errors import ModuleError
class ProviderError(ModuleError):
"""Provider Error"""
msg = _('cloud provider base error')
class ProviderBadInputError(ProviderError):
"""Provider Bad Input Error"""
msg = _('cloud provider bad input parameter')
class ProviderAuthError(ProviderError):
"""Provider Auth Error"""
msg = _('cloud provider invalid authentication credentials')
class ProviderAccessError(ProviderError):
"""Provider Access Error"""
msg = _('cloud provider access dined')
class ProviderAPIError(ProviderError):
"""Provider API Error"""
msg = _('cloud provider api error')
class ProviderLimitReachError(ProviderError):
"""Provider Limit Reach Error"""
msg = _('cloud provider limit reach')
class ProviderInternalError(ProviderError):
"""Provider Internal Error"""
msg = _('cloud provider internal error')
| 23.769231 | 64 | 0.718447 | 90 | 927 | 7.311111 | 0.355556 | 0.085106 | 0.138298 | 0.223404 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0.1726 | 927 | 38 | 65 | 24.394737 | 0.857888 | 0.173679 | 0 | 0 | 0 | 0 | 0.293151 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | false | 0 | 0.125 | 0 | 1 | 0 | 0 | 0 | 0 | null | 0 | 0 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 2 |
eec61262d6a7353125ce161f33869bc6a05e3091 | 10,964 | py | Python | observation_modes.py | sariel85/intrinsic-isometric-manifold-learning | f9636abbd20073b16ea68cad917d4d62178cdc4d | [
"Apache-2.0"
] | 2 | 2018-05-18T15:49:19.000Z | 2019-03-25T13:07:53.000Z | observation_modes.py | sariel85/intrinsic-isometric-manifold-learning | f9636abbd20073b16ea68cad917d4d62178cdc4d | [
"Apache-2.0"
] | null | null | null | observation_modes.py | sariel85/intrinsic-isometric-manifold-learning | f9636abbd20073b16ea68cad917d4d62178cdc4d | [
"Apache-2.0"
] | null | null | null | import numpy
from sklearn import preprocessing
def linear(intrinsic_process):
assert intrinsic_process.shape[0] == 2
observed_process = numpy.empty((3, intrinsic_process.shape[1]), dtype=numpy.float64)
observed_process[0] = intrinsic_process[0]
observed_process[1] = intrinsic_process[1]
observed_process[2] = 0
return observed_process
def s_curve(intrinsic_process, k=1):
assert intrinsic_process.shape[0] == 2
intrinsic_process_temp = numpy.copy(intrinsic_process)
intrinsic_process_temp = (intrinsic_process_temp.T-0).T/2
observed_process = numpy.empty((3, intrinsic_process_temp.shape[1]), dtype=numpy.float64)
t = 3 * numpy.pi * k * intrinsic_process_temp[0]
observed_process[0] = numpy.sin(t)
observed_process[1] = intrinsic_process[1]*1
observed_process[2] = numpy.sign(t) * (numpy.cos(t) - 1)
return observed_process
def severed_sphere(intrinsic_process, k1=5.5, k2=2):
assert intrinsic_process.shape[0] == 2
intrinsic_process_temp = numpy.copy(intrinsic_process)
#intrinsic_process_temp = (intrinsic_process_temp.T-numpy.mean(intrinsic_process_temp, axis=1).T).T
observed_process = numpy.empty((3, intrinsic_process_temp.shape[1]), dtype=numpy.float64)
observed_process[0] = numpy.sin(intrinsic_process_temp[0]*k1)*numpy.cos(intrinsic_process_temp[1]*k2)
observed_process[1] = numpy.cos(intrinsic_process_temp[0]*k1)*numpy.cos(intrinsic_process_temp[1]*k2)
observed_process[2] = numpy.sin(intrinsic_process_temp[1]*k2)
return observed_process
def twin_peaks(intrinsic_process, k=1):
assert intrinsic_process.shape[0] == 2
intrinsic_process_temp = numpy.copy(intrinsic_process)
intrinsic_process_temp = (intrinsic_process_temp.T-0).T/2
observed_process = numpy.empty((3, intrinsic_process_temp.shape[1]), dtype=numpy.float64)
observed_process[0] = intrinsic_process_temp[0]
observed_process[1] = intrinsic_process_temp[1]
observed_process[2] = numpy.sin(k*intrinsic_process_temp[0])*numpy.sin(k*intrinsic_process_temp[1])/3
return observed_process
def parabola2d2d(intrinsic_process, k=2):
assert intrinsic_process.shape[0] == 2
scale_x = numpy.max(intrinsic_process[0]) - numpy.min(intrinsic_process[0])
scale_y = numpy.max(intrinsic_process[1]) - numpy.min(intrinsic_process[1])
scale = max(scale_x, scale_y)
origin = numpy.mean(intrinsic_process, axis=1)
intrinsic_process_temp = (intrinsic_process.T-origin.T).T/scale
observed_process = numpy.empty((2, intrinsic_process.shape[1]), dtype=numpy.float64)
observed_process[0, :] = intrinsic_process_temp[0, :]
observed_process[1, :] = intrinsic_process_temp[1, :] - k * intrinsic_process_temp[0, :] ** 2
return observed_process
def parabola2d3d(intrinsic_process, k=3):
assert intrinsic_process.shape[0] == 2
observed_process = numpy.empty((3, intrinsic_process.shape[1]), dtype=numpy.float64)
intrinsic_process = intrinsic_process - 0.5
observed_process[0, :] = intrinsic_process[0, :]
observed_process[1, :] = intrinsic_process[1, :]
observed_process[2, :] = k * numpy.sum(intrinsic_process ** 2, axis=0)
return observed_process
def singers_mushroom(intrinsic_process):
assert intrinsic_process.shape[0] == 2
intrinsic_process_temp = numpy.copy(intrinsic_process)
intrinsic_process_temp = (intrinsic_process_temp.T-numpy.min(intrinsic_process_temp, axis=1).T).T
observed_process = numpy.empty((2, intrinsic_process_temp.shape[1]), dtype=numpy.float64)
observed_process[0] = intrinsic_process_temp[0]+numpy.power(intrinsic_process_temp[1], 3)
observed_process[1] = intrinsic_process_temp[1]-numpy.power(intrinsic_process_temp[0], 3)
return observed_process
def singers_sphere(intrinsic_process):
assert intrinsic_process.shape[0] == 2
intrinsic_process_temp = intrinsic_process
observed_process = numpy.empty((3, intrinsic_process_temp.shape[1]), dtype=numpy.float64)
radius = numpy.sqrt(intrinsic_process_temp[0]**2+intrinsic_process_temp[1]**2+1)
observed_process[0] = intrinsic_process_temp[0]/radius
observed_process[1] = intrinsic_process_temp[1]/radius
observed_process[2] = 1/radius
return observed_process
def whole_sphere(intrinsic_process, k=0.5):
assert intrinsic_process.shape[0] == 2
intrinsic_process_temp = numpy.copy(intrinsic_process)
intrinsic_process_temp = (intrinsic_process_temp.T-numpy.mean(intrinsic_process_temp, axis=1).T).T
observed_process = numpy.empty((3, intrinsic_process_temp.shape[1]), dtype=numpy.float64)
radius = numpy.sqrt(intrinsic_process_temp[0]**2+intrinsic_process_temp[1]**2)
theta = numpy.arctan(intrinsic_process[1, :] / intrinsic_process[0, :])
theta[numpy.where(intrinsic_process[0, :] < 0)] = theta[numpy.where(intrinsic_process[0, :] < 0)]+numpy.pi
observed_process[0] = numpy.sin(k*radius)*numpy.sin(theta)
observed_process[1] = numpy.sin(k*radius)*numpy.cos(theta)
observed_process[2] = -numpy.cos(k*radius)
return observed_process
def photo_dist(intrinsic_process, k=1.5):
assert intrinsic_process.shape[0] == 2
observed_process = numpy.empty((2, intrinsic_process.shape[1]), dtype=numpy.float64)
intrinsic_process = intrinsic_process - 0.5
r = numpy.sqrt(intrinsic_process[0, :] ** 2 + intrinsic_process[1, :] ** 2)
observed_process[0, :] = intrinsic_process[0, :]*(1 + k * r ** 2)
observed_process[1, :] = intrinsic_process[1, :]*(1 + k * r ** 2)
observed_process = observed_process + 0.5
return observed_process
def twirl(intrinsic_process, k=6):
assert intrinsic_process.shape[0] == 2
observed_process = numpy.empty((2, intrinsic_process.shape[1]), dtype=numpy.float64)
temp_mean = numpy.mean(intrinsic_process, 1)
intrinsic_process = (intrinsic_process.T - temp_mean.T).T
r = numpy.sqrt(intrinsic_process[0, :]**2 + intrinsic_process[1, :]**2)
theta = numpy.arctan(intrinsic_process[1, :] / intrinsic_process[0, :])
theta[numpy.where(intrinsic_process[0, :] < 0)] = theta[intrinsic_process[0, :] < 0]+numpy.pi
newr = r
newtheta = theta + newr * k
newtheta = -newtheta
observed_process[0, :] = newr * numpy.cos(newtheta)
observed_process[1, :] = newr * numpy.sin(newtheta)
observed_process = (observed_process.T + temp_mean.T).T
return observed_process
def bend(intrinsic_process, k=45):
assert intrinsic_process.shape[0] == 2
deg = 2*numpy.pi*(k/360)
observed_process = numpy.empty((3, intrinsic_process.shape[1]), dtype=numpy.float64)
for x in range(0, intrinsic_process.shape[1]):
if intrinsic_process[0, x] < 0.5:
observed_process[0, x] = intrinsic_process[0, x]
observed_process[1, x] = intrinsic_process[1, x]
observed_process[2, x] = 0
else:
observed_process[0, x] = 0.5 + numpy.cos(deg)*(intrinsic_process[0, x] - 0.5)
observed_process[1, x] = intrinsic_process[1, x]
observed_process[2, x] = numpy.sin(deg) * (intrinsic_process[0, x] - 0.5)
return observed_process
def swissroll(intrinsic_process, k_r=8, k_twist=8):
assert intrinsic_process.shape[0] == 2
intrinsic_process_temp = numpy.copy(intrinsic_process)
intrinsic_process_temp = (intrinsic_process_temp.T-numpy.min(intrinsic_process_temp, axis=1).T).T
observed_process = numpy.empty((3, intrinsic_process_temp.shape[1]), dtype=numpy.float64)
observed_process[0] = k_r*intrinsic_process_temp[0] * numpy.cos(k_twist * intrinsic_process_temp[0])
observed_process[1] = intrinsic_process_temp[1]*2
observed_process[2] = k_r*intrinsic_process_temp[0] * numpy.sin(k_twist * intrinsic_process_temp[0])
return observed_process
def tube(intrinsic_process, k=160):
assert intrinsic_process.shape[0] == 2
scale = numpy.max(intrinsic_process[0]) - numpy.min(intrinsic_process[0])
radius = (360/k)/(2*numpy.pi)
observed_process = numpy.empty((3, intrinsic_process.shape[1]), dtype=numpy.float64)
observed_process[0] = radius * numpy.cos(2*numpy.pi*(k/360) * (intrinsic_process[0]/scale))
observed_process[1] = intrinsic_process[1]
observed_process[2] = radius * numpy.sin(2*numpy.pi*(k/360) * (intrinsic_process[0]/scale))
min_max_scaler = preprocessing.MinMaxScaler(feature_range=(0, 1))
observed_process = min_max_scaler.fit_transform(observed_process.T).T
return observed_process
def helix(intrinsic_process, k=2):
assert intrinsic_process.shape[0] == 2
observed_process = numpy.empty((3, intrinsic_process.shape[1]), dtype=numpy.float64)
intrinsic_process = intrinsic_process - 0.5
observed_process[0, :] = intrinsic_process[0, :]
observed_process[1, :] = intrinsic_process[1, :] * numpy.cos(k * numpy.pi * (intrinsic_process[0, :]))
observed_process[2, :] = intrinsic_process[1, :] * numpy.sin(k * numpy.pi * (intrinsic_process[0, :]))
observed_process = observed_process + 0.5
return observed_process
def papillon(intrinsic_process, k=8):
assert intrinsic_process.shape[0] == 2
observed_process = numpy.empty((2, intrinsic_process.shape[1]), dtype=numpy.float64)
intrinsic_process = intrinsic_process - 0.5
observed_process[0, :] = intrinsic_process[0, :] + 0.5
observed_process[1, :] = intrinsic_process[1, :] + k * intrinsic_process[1, :] * intrinsic_process[0, :] ** 2 + 0.5
return observed_process
def twist(intrinsic_process, k=6):
assert intrinsic_process.shape[0] == 3
intrinsic_process = intrinsic_process - 0.5
r = numpy.sqrt(intrinsic_process[0, :]**2 + intrinsic_process[1, :]**2)
theta = numpy.arctan(intrinsic_process[1, :] / intrinsic_process[0, :])
theta[numpy.where(intrinsic_process[0, :] < 0)] = theta[numpy.where(intrinsic_process[0, :] < 0)]+numpy.pi
observed_process = numpy.empty([3, intrinsic_process.shape[1]])
observed_process[0, :] = r*numpy.cos(theta + intrinsic_process[2, :]*k)
observed_process[1, :] = r*numpy.sin(theta + intrinsic_process[2, :]*k)
observed_process[2, :] = intrinsic_process[2, :]
observed_process = observed_process + 0.5
return observed_process
def antenna(intrinsic_process, centers, amplitudes, width, angles, range_factor, reg_fact):
n_antenas = centers.shape[1]
observed_process = numpy.zeros([n_antenas, intrinsic_process.shape[1]])
assert intrinsic_process.shape[0] == centers.shape[0]
for i_antena in range(0, n_antenas):
dists = (intrinsic_process.T - centers[:, i_antena].T).T
angle = numpy.angle([dists[0, :]+1j*dists[1, :]])
dists = dists * dists
dists = numpy.sqrt(numpy.sum(dists, axis=0))
observed_process[i_antena, :] = amplitudes[i_antena]*((1/(reg_fact[i_antena]+dists*range_factor[i_antena])))**(1/5)*(1/(0.5+width[i_antena]*numpy.abs(numpy.exp(1j*angle)-numpy.exp(1j*(angles[i_antena])))))
#observed_process[i_antena, :] = dists
return observed_process
| 49.836364 | 213 | 0.719172 | 1,545 | 10,964 | 4.856958 | 0.066667 | 0.390192 | 0.157249 | 0.064765 | 0.785581 | 0.707889 | 0.651652 | 0.596215 | 0.578092 | 0.553971 | 0 | 0.039688 | 0.145111 | 10,964 | 219 | 214 | 50.063927 | 0.760909 | 0.012313 | 0 | 0.447514 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0.099448 | 1 | 0.099448 | false | 0 | 0.01105 | 0 | 0.209945 | 0 | 0 | 0 | 0 | null | 1 | 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 | 0 | 0 | 0 | 0 | 0 | 0 | 2 |
eec7f13e91031d79ebfd1756d60c240a43dd41d1 | 899 | py | Python | ludo/migrations/0003_auto_20200110_1910.py | jonpas/FERI-WebApps | 27e4fa0e741af31ac9344c72cf7e8a5e6289725d | [
"MIT"
] | null | null | null | ludo/migrations/0003_auto_20200110_1910.py | jonpas/FERI-WebApps | 27e4fa0e741af31ac9344c72cf7e8a5e6289725d | [
"MIT"
] | null | null | null | ludo/migrations/0003_auto_20200110_1910.py | jonpas/FERI-WebApps | 27e4fa0e741af31ac9344c72cf7e8a5e6289725d | [
"MIT"
] | null | null | null | # Generated by Django 3.0.2 on 2020-01-10 18:10
from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
('ludo', '0002_auto_20200110_1845'),
]
operations = [
migrations.RemoveField(
model_name='profile',
name='played',
),
migrations.RemoveField(
model_name='profile',
name='points',
),
migrations.AddField(
model_name='profile',
name='fourths',
field=models.IntegerField(default='0'),
),
migrations.AddField(
model_name='profile',
name='seconds',
field=models.IntegerField(default='0'),
),
migrations.AddField(
model_name='profile',
name='thirds',
field=models.IntegerField(default='0'),
),
]
| 24.297297 | 51 | 0.529477 | 79 | 899 | 5.924051 | 0.481013 | 0.096154 | 0.17094 | 0.213675 | 0.617521 | 0.551282 | 0.294872 | 0.294872 | 0.294872 | 0.294872 | 0 | 0.05802 | 0.348165 | 899 | 36 | 52 | 24.972222 | 0.740614 | 0.050056 | 0 | 0.6 | 1 | 0 | 0.11385 | 0.026995 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | false | 0 | 0.033333 | 0 | 0.133333 | 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 |
eedce0cd1e916beee2d688b6f22f001e683be72e | 778 | py | Python | tests/test_released_form.py | mdalesio/traveler-client-python | 57951b1e56a7d333080f3f755c98968dc2b89ea5 | [
"MIT"
] | null | null | null | tests/test_released_form.py | mdalesio/traveler-client-python | 57951b1e56a7d333080f3f755c98968dc2b89ea5 | [
"MIT"
] | null | null | null | tests/test_released_form.py | mdalesio/traveler-client-python | 57951b1e56a7d333080f3f755c98968dc2b89ea5 | [
"MIT"
] | 1 | 2021-02-05T20:07:48.000Z | 2021-02-05T20:07:48.000Z | import logging
from traveler_client import released_form, client
def test_get_all():
form_client = released_form.ReleasedForm('https://localhost:3443', 'api_write', 'api_write_password')
form_response = form_client.get_all()
assert client.Client.is_json(form_response)
# logging.info(form_response.json())
def test_get():
form_client = released_form.ReleasedForm('https://localhost:3443', 'api_write', 'api_write_password')
all_form_response = form_client.get_all()
assert client.Client.is_json(all_form_response)
all_form = all_form_response.json()
assert len(all_form) > 0
form_id = all_form[0]['_id']
form_response = form_client.get(form_id)
assert client.Client.is_json(form_response)
logging.info(form_response.json()) | 38.9 | 105 | 0.751928 | 111 | 778 | 4.900901 | 0.234234 | 0.198529 | 0.088235 | 0.121324 | 0.704044 | 0.658088 | 0.658088 | 0.658088 | 0.658088 | 0.658088 | 0 | 0.014815 | 0.132391 | 778 | 20 | 106 | 38.9 | 0.791111 | 0.043702 | 0 | 0.25 | 0 | 0 | 0.135935 | 0 | 0 | 0 | 0 | 0 | 0.25 | 1 | 0.125 | false | 0.125 | 0.125 | 0 | 0.25 | 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 | 1 | 0 | 0 | 0 | 0 | 0 | 2 |
e103a8cbac2f17e0d2f1547002db909f65e676ee | 1,853 | py | Python | var/spack/repos/builtin/packages/py-fastavro/package.py | robertodr/spack | 9b809e01b47d48f01b3d257912fe1b752943cd3d | [
"ECL-2.0",
"Apache-2.0",
"MIT-0",
"MIT"
] | 9 | 2018-04-18T07:51:40.000Z | 2021-09-10T03:56:57.000Z | var/spack/repos/builtin/packages/py-fastavro/package.py | robertodr/spack | 9b809e01b47d48f01b3d257912fe1b752943cd3d | [
"ECL-2.0",
"Apache-2.0",
"MIT-0",
"MIT"
] | 907 | 2018-04-18T11:17:57.000Z | 2022-03-31T13:20:25.000Z | var/spack/repos/builtin/packages/py-fastavro/package.py | robertodr/spack | 9b809e01b47d48f01b3d257912fe1b752943cd3d | [
"ECL-2.0",
"Apache-2.0",
"MIT-0",
"MIT"
] | 29 | 2018-11-05T16:14:23.000Z | 2022-02-03T16:07:09.000Z | # Copyright 2013-2020 Lawrence Livermore National Security, LLC and other
# Spack Project Developers. See the top-level COPYRIGHT file for details.
#
# SPDX-License-Identifier: (Apache-2.0 OR MIT)
from spack import *
class PyFastavro(PythonPackage):
"""Fastavro for Python."""
homepage = "https://github.com/fastavro/fastavro"
url = "https://github.com/fastavro/fastavro/archive/1.0.0.post1.tar.gz"
version('1.0.0.post1', sha256='74f9bf0f9bc9e484c6d42fad603d6e6f907e716a78189873761dc86ce64cc6c5')
version('1.0.0', sha256='9aca6f425dd898f40e2c4e10714276604e610c6ad3df53109d6fb3ad49761b5e')
version('0.24.2', sha256='6ccd711a0c6960c3263a7c1c0e0e3bf7c5e949e11c3a676edece36138c62caba')
version('0.24.1', sha256='8b109b4f564f6fe7fd82d3e2d582fba8da58167bcf2fa65e27fd3c4e49afddf9')
version('0.24.0', sha256='d60c2a90d7bbe7a70aab30d3b772faedcbd9487bc1f7e2cd65a93a555688965e')
version('0.23.6', sha256='b511dc55a9514205765f96b4d964f1d74fca9696dbac91229cef6100a028a29f')
version('0.23.5', sha256='5542b69a99a74a57988c2a48da9be4356db4223cebac599ec3e9bf1b74ef534b')
version('0.23.4', sha256='e699940a06fc713d56ba8b9cb88665e2fa2a6abc2c342cd540ee7cd4428af973')
version('0.23.3', sha256='4e4bebe7b43b5cdad030bdbeb7f7f0ccb537ea025a9e28c7a4826876872fc84b')
version('0.23.2', sha256='3b31707d6eaa1e98fc60536d0b3483bafb78be39bf9f0a1affe1b353e70bd5b2')
def setup_build_environment(self, env):
# Use cython for building as *.c files are missing from repo
env.set('FASTAVRO_USE_CYTHON', 1)
depends_on('python@3.5:', type=('build', 'run'))
depends_on('py-setuptools', type='build')
depends_on('py-snappy', type=('build', 'run'))
depends_on('py-lz4', type=('build', 'run'))
depends_on('py-cython', type=('build', 'run'))
| 52.942857 | 101 | 0.739881 | 176 | 1,853 | 7.738636 | 0.494318 | 0.04699 | 0.036711 | 0.04185 | 0.094714 | 0.050661 | 0 | 0 | 0 | 0 | 0 | 0.28616 | 0.134377 | 1,853 | 34 | 102 | 54.5 | 0.562968 | 0.14517 | 0 | 0 | 0 | 0.047619 | 0.576239 | 0.406607 | 0 | 0 | 0 | 0 | 0 | 1 | 0.047619 | false | 0 | 0.047619 | 0 | 0.238095 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | null | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 2 |
e10ac1608ebc48ca2bd88fc4ecc82182efc87927 | 3,156 | py | Python | editor/tests/factories.py | CivicKnowledge/metaeditor | f1132dccb76fd75580ea772cbedd1f8f0871195b | [
"MIT"
] | 1 | 2015-05-04T14:02:38.000Z | 2015-05-04T14:02:38.000Z | editor/tests/factories.py | CivicKnowledge/metaeditor | f1132dccb76fd75580ea772cbedd1f8f0871195b | [
"MIT"
] | 39 | 2015-01-25T00:17:32.000Z | 2015-05-03T08:20:55.000Z | editor/tests/factories.py | CivicKnowledge/metaeditor | f1132dccb76fd75580ea772cbedd1f8f0871195b | [
"MIT"
] | null | null | null | # -*- coding: utf-8 -*-
import factory
from accounts.tests.factories import UserFactory
from editor.constants import REGION_CHOICES
from editor.models import Dataset, Format, Category, Source, Extension, DataFile
class CategoryFactory(factory.django.DjangoModelFactory):
class Meta:
model = Category
name = factory.Sequence(lambda n: 'Test dataset %03d' % n)
class SourceFactory(factory.django.DjangoModelFactory):
class Meta:
model = Source
name = factory.Sequence(lambda n: 'Test source %03d' % n)
abbreviation = factory.Sequence(lambda n: 'Test source %03d abbreviation' % n)
domain = factory.Sequence(lambda n: 'test.source-%03d.org' % n)
homepage = factory.Sequence(lambda n: 'http://test.source-%03d.org' % n)
about = factory.Sequence(lambda n: 'Test source %03d about' % n)
@factory.post_generation
def categories(self, create, extracted, **kwargs):
if not create:
# Simple build, do nothing.
return
if extracted:
# A list of categories were passed in, use them
for category in extracted:
self.categories.add(category)
class FormatFactory(factory.django.DjangoModelFactory):
class Meta:
model = Format
name = factory.Sequence(lambda n: 'Test format %03d' % n)
class ExtensionFactory(factory.django.DjangoModelFactory):
class Meta:
model = Extension
name = factory.Sequence(lambda n: 'ext%03d' % n)
class DatasetFactory(factory.django.DjangoModelFactory):
class Meta:
model = Dataset
title = factory.Sequence(lambda n: 'Test dataset %03d' % n)
source = factory.SubFactory(SourceFactory)
variant = factory.Sequence(lambda n: 'Test dataset %03d variant' % n)
start_year = 1976
end_year = 1976
coverage = ''
region = REGION_CHOICES[0][0]
page = factory.Sequence(lambda n: 'Test dataset %03d page' % n)
download_page = factory.Sequence(lambda n: 'Test dataset %03d download page' % n)
contacts = factory.Sequence(lambda n: 'Test dataset %03d contacts' % n)
entry_time_minutes = 11
user = factory.SubFactory(UserFactory)
vid = factory.Sequence(lambda n: 'd0%03d' % n)
@factory.post_generation
def categories(self, create, extracted, **kwargs):
if not create:
# Simple build, do nothing.
return
if extracted:
# A list of categories were passed in, use them
for category in extracted:
self.categories.add(category)
@factory.post_generation
def formats(self, create, extracted, **kwargs):
if not create:
# Simple build, do nothing.
return
if extracted:
# A list of formats were passed in, use them
for format_ in extracted:
self.categories.add(format_)
class DataFileFactory(factory.django.DjangoModelFactory):
class Meta:
model = DataFile
name = factory.Sequence(lambda n: 'Test datafile %03d' % n)
dataset = factory.SubFactory(DatasetFactory)
file_format = factory.SubFactory(FormatFactory)
| 29.222222 | 85 | 0.65621 | 366 | 3,156 | 5.622951 | 0.248634 | 0.109329 | 0.153061 | 0.16035 | 0.613703 | 0.577259 | 0.402332 | 0.29932 | 0.22449 | 0.22449 | 0 | 0.018581 | 0.249683 | 3,156 | 107 | 86 | 29.495327 | 0.850507 | 0.074144 | 0 | 0.358209 | 0 | 0 | 0.102608 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0.044776 | false | 0 | 0.059701 | 0 | 0.686567 | 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 |
e119fad1c32bff511a4673bb96a053623dc1949a | 363 | py | Python | kaffepause/breaks/test/factories.py | Eirsteir/kaffepause | 77535f057e68d575831e3a44f36285ab2fe621d4 | [
"MIT"
] | null | null | null | kaffepause/breaks/test/factories.py | Eirsteir/kaffepause | 77535f057e68d575831e3a44f36285ab2fe621d4 | [
"MIT"
] | 2 | 2022-02-28T21:04:22.000Z | 2022-03-01T21:05:37.000Z | kaffepause/breaks/test/factories.py | Eirsteir/kaffepause | 77535f057e68d575831e3a44f36285ab2fe621d4 | [
"MIT"
] | null | null | null | import factory
from kaffepause.breaks.models import Break, BreakInvitation
from kaffepause.common.bases import NeomodelFactory
from kaffepause.common.utils import fifteen_minutes_from_now
class BreakFactory(NeomodelFactory):
class Meta:
model = Break
class BreakInvitationFactory(NeomodelFactory):
class Meta:
model = BreakInvitation
| 22.6875 | 60 | 0.793388 | 38 | 363 | 7.5 | 0.526316 | 0.147368 | 0.140351 | 0.203509 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0.15978 | 363 | 15 | 61 | 24.2 | 0.934426 | 0 | 0 | 0.2 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | false | 0 | 0.4 | 0 | 0.8 | 0 | 0 | 0 | 0 | null | 0 | 0 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 0 | 0 | 2 |
e1211f10866f54510157887db38cdf447ba9fb3c | 752 | py | Python | src/core/service/employee_service.py | lucassaporetti/car-rental | 6e37032df3a399b78ed3d7998a2cb31a2a84d033 | [
"MIT"
] | 1 | 2021-02-11T18:45:12.000Z | 2021-02-11T18:45:12.000Z | src/core/service/employee_service.py | lucassaporetti/car-rental | 6e37032df3a399b78ed3d7998a2cb31a2a84d033 | [
"MIT"
] | null | null | null | src/core/service/employee_service.py | lucassaporetti/car-rental | 6e37032df3a399b78ed3d7998a2cb31a2a84d033 | [
"MIT"
] | null | null | null | from src.core.enum.database_type import DatabaseType
from src.core.enum.model import Model
from src.core.enum.repository_type import RepositoryType
from src.core.service.service import Service
from core.model.employee import Employee
class EmployeeService(Service):
def __init__(self, repository_type: RepositoryType, database_type: DatabaseType):
super().__init__(repository_type, database_type, Model.EMPLOYEE)
def save(self, employee: Employee):
super().save(employee)
def remove(self, employee: Employee):
super().remove(employee)
def get(self, uuid: str) -> Employee:
entity = super().get(uuid)
employee = Employee()
employee.__dict__ = entity.__dict__
return employee
| 31.333333 | 85 | 0.724734 | 90 | 752 | 5.811111 | 0.3 | 0.053537 | 0.08413 | 0.086042 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0.180851 | 752 | 23 | 86 | 32.695652 | 0.849026 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0.235294 | false | 0 | 0.294118 | 0 | 0.647059 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 2 |
e12a9844b5eedd54e5a7cfc60cc0668a1315154c | 2,565 | py | Python | tasks/test_django/quiz/migrations/0002_auto_20160803_2257.py | ihoru/play-with-python | 17ea283a05e59be188d491404bf4aca15e30b87a | [
"MIT"
] | null | null | null | tasks/test_django/quiz/migrations/0002_auto_20160803_2257.py | ihoru/play-with-python | 17ea283a05e59be188d491404bf4aca15e30b87a | [
"MIT"
] | null | null | null | tasks/test_django/quiz/migrations/0002_auto_20160803_2257.py | ihoru/play-with-python | 17ea283a05e59be188d491404bf4aca15e30b87a | [
"MIT"
] | null | null | null | # -*- coding: utf-8 -*-
# Generated by Django 1.10 on 2016-08-03 19:57
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 = [
('quiz', '0001_initial'),
]
operations = [
migrations.AlterModelOptions(
name='choice',
options={'verbose_name': 'Ответ', 'verbose_name_plural': 'Ответы'},
),
migrations.AlterModelOptions(
name='question',
options={'verbose_name': 'Вопрос', 'verbose_name_plural': 'Вопросы'},
),
migrations.RemoveField(
model_name='choice',
name='active',
),
migrations.RemoveField(
model_name='question',
name='active',
),
migrations.AddField(
model_name='choice',
name='is_active',
field=models.BooleanField(default=True, verbose_name='Отображать?'),
),
migrations.AddField(
model_name='question',
name='is_active',
field=models.BooleanField(default=True, verbose_name='Отображать?'),
),
migrations.AlterField(
model_name='choice',
name='position',
field=models.IntegerField(default=0, verbose_name='Сортировка'),
),
migrations.AlterField(
model_name='choice',
name='question',
field=models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='quiz.Question', verbose_name='Вопрос'),
),
migrations.AlterField(
model_name='choice',
name='text',
field=models.TextField(verbose_name='Текст'),
),
migrations.AlterField(
model_name='choice',
name='title',
field=models.CharField(max_length=200, verbose_name='Название'),
),
migrations.AlterField(
model_name='question',
name='author',
field=models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to=settings.AUTH_USER_MODEL, verbose_name='Автор'),
),
migrations.AlterField(
model_name='question',
name='text',
field=models.TextField(verbose_name='Текст'),
),
migrations.AlterField(
model_name='question',
name='title',
field=models.CharField(max_length=200, verbose_name='Название'),
),
]
| 32.468354 | 132 | 0.573879 | 235 | 2,565 | 6.093617 | 0.319149 | 0.09986 | 0.122207 | 0.14176 | 0.513268 | 0.513268 | 0.377095 | 0.377095 | 0.377095 | 0.377095 | 0 | 0.015067 | 0.301365 | 2,565 | 78 | 133 | 32.884615 | 0.78404 | 0.025731 | 0 | 0.746479 | 1 | 0 | 0.137821 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | false | 0 | 0.056338 | 0 | 0.098592 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 1 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 2 |
01013e63c43c13588471ae3fe1a0e228aa252b7f | 868 | py | Python | tcli/commands/configure/credentials/credentials.py | farooq-teqniqly/typer-cli | 2c24c62e9e31cfc84d11a8019eae04be0ef5b013 | [
"MIT"
] | null | null | null | tcli/commands/configure/credentials/credentials.py | farooq-teqniqly/typer-cli | 2c24c62e9e31cfc84d11a8019eae04be0ef5b013 | [
"MIT"
] | null | null | null | tcli/commands/configure/credentials/credentials.py | farooq-teqniqly/typer-cli | 2c24c62e9e31cfc84d11a8019eae04be0ef5b013 | [
"MIT"
] | null | null | null | from click import secho
from typer import Typer
from config_helpers import save_config
from credentials_helper import set_password, delete_password
from tcli.typer_app import TyperApp
class CredentialsApp(TyperApp):
def on_create_app(self, app: Typer, *args, **kwargs) -> Typer:
@app.command()
def set(user_name: str, password: str):
"""Configure the credentials the CLI commands run under."""
set_password(user_name, password)
self.config.username = user_name
save_config(self.config)
secho(f"Username: {self.config.username}", fg="green")
@app.command()
def delete(user_name: str):
"""Delete stored CLI credentials."""
delete_password(user_name)
self.config.username = ""
save_config(self.config)
return app
| 31 | 71 | 0.645161 | 104 | 868 | 5.221154 | 0.384615 | 0.073665 | 0.099448 | 0.073665 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0.261521 | 868 | 27 | 72 | 32.148148 | 0.847114 | 0.096774 | 0 | 0.210526 | 0 | 0 | 0.047865 | 0.028461 | 0 | 0 | 0 | 0 | 0 | 1 | 0.157895 | false | 0.210526 | 0.263158 | 0 | 0.526316 | 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 |
01523d8afecd8a8a85171e9809a631c19a5ac5b1 | 537 | py | Python | resources/preparation.py | frank690/greenhouse-server | f32b3426e9855f978069fd02ca9b2d578d3f7eaa | [
"Apache-2.0"
] | null | null | null | resources/preparation.py | frank690/greenhouse-server | f32b3426e9855f978069fd02ca9b2d578d3f7eaa | [
"Apache-2.0"
] | null | null | null | resources/preparation.py | frank690/greenhouse-server | f32b3426e9855f978069fd02ca9b2d578d3f7eaa | [
"Apache-2.0"
] | null | null | null | #!/usr/bin/python3
"""
Use this script to prepare the postgresql service for its upcoming tasks.
"""
from sqlalchemy.schema import CreateSchema
from sqlalchemy_utils import create_database, database_exists
from garden.config.target import SCHEMA
from garden.database.base import Base, Engine
if __name__ == "__main__":
if not database_exists(Engine.url):
create_database(Engine.url)
if not Engine.dialect.has_schema(Engine, SCHEMA):
Engine.execute(CreateSchema(SCHEMA))
Base.metadata.create_all(Engine)
| 25.571429 | 73 | 0.763501 | 71 | 537 | 5.56338 | 0.549296 | 0.070886 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0.002193 | 0.150838 | 537 | 20 | 74 | 26.85 | 0.864035 | 0.16946 | 0 | 0 | 0 | 0 | 0.018265 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | true | 0 | 0.4 | 0 | 0.4 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 1 | 0 | 0 | 0 | 0 | 2 |
0154b6583b7d89ecefdde8cf92df7673a0466c6e | 730 | py | Python | csrv/model/actions/gain_a_credit.py | mrroach/CentralServer | e377c65d8f3adf5a2d3273acd4f459be697aea56 | [
"Apache-2.0"
] | null | null | null | csrv/model/actions/gain_a_credit.py | mrroach/CentralServer | e377c65d8f3adf5a2d3273acd4f459be697aea56 | [
"Apache-2.0"
] | null | null | null | csrv/model/actions/gain_a_credit.py | mrroach/CentralServer | e377c65d8f3adf5a2d3273acd4f459be697aea56 | [
"Apache-2.0"
] | 1 | 2020-09-20T11:26:20.000Z | 2020-09-20T11:26:20.000Z | """Base actions for the players to take."""
from csrv.model.actions import action
from csrv.model import cost
from csrv.model import errors
from csrv.model import events
from csrv.model import game_object
from csrv.model import parameters
class GainACredit(action.Action):
DESCRIPTION = '[click]: Gain 1[cred] (one credit)'
COST_CLASS = cost.BasicActionCost
def resolve(self, response=None, ignore_clicks=False, ignore_all_costs=False):
action.Action.resolve(
self,
ignore_clicks=ignore_clicks,
ignore_all_costs=ignore_all_costs)
self.player.credits.gain(1)
self.game.log('The %s gains 1[cred]' % self.player, None)
self.trigger_event(events.GainACredit(self.game, self.player))
| 30.416667 | 80 | 0.745205 | 105 | 730 | 5.066667 | 0.428571 | 0.090226 | 0.146617 | 0.178571 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0.004862 | 0.154795 | 730 | 23 | 81 | 31.73913 | 0.857374 | 0.050685 | 0 | 0 | 0 | 0 | 0.078603 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0.058824 | false | 0 | 0.352941 | 0 | 0.588235 | 0 | 0 | 0 | 0 | null | 0 | 0 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 0 | 0 | 2 |
015aba0d39a6388dcdbf848d335adfc6ec132344 | 621 | py | Python | people/views.py | vaibhav-87/website-4 | 371a97b52e77c56f25cca0f1967e80625d279f3c | [
"WTFPL"
] | null | null | null | people/views.py | vaibhav-87/website-4 | 371a97b52e77c56f25cca0f1967e80625d279f3c | [
"WTFPL"
] | null | null | null | people/views.py | vaibhav-87/website-4 | 371a97b52e77c56f25cca0f1967e80625d279f3c | [
"WTFPL"
] | null | null | null | from django.contrib import messages
from django.urls import reverse
from django.views.generic import CreateView, ListView
from people.forms import PersonForm
from people.models import Person
class PeopleView(ListView):
queryset = Person.objects.active()
class CreatePeopleView(CreateView):
model = Person
form_class = PersonForm
success_message = 'Kişi başarıyla eklendi.'
def form_valid(self, form):
messages.success(self.request, self.success_message)
return super(CreatePeopleView, self).form_valid(form)
def get_success_url(self):
return reverse("people:index")
| 25.875 | 61 | 0.752013 | 75 | 621 | 6.133333 | 0.506667 | 0.065217 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0.170692 | 621 | 23 | 62 | 27 | 0.893204 | 0 | 0 | 0 | 0 | 0 | 0.056361 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0.125 | false | 0 | 0.3125 | 0.0625 | 0.9375 | 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 |
0168455bceeb69c6203c16ba60868c2ae6a0c84d | 386 | py | Python | packages/search_services/searchNearby/helper/search.py | nipunayf/journey | 2c6b10e792184e6c25ab4324831bd91d7d8df8b7 | [
"MIT"
] | null | null | null | packages/search_services/searchNearby/helper/search.py | nipunayf/journey | 2c6b10e792184e6c25ab4324831bd91d7d8df8b7 | [
"MIT"
] | null | null | null | packages/search_services/searchNearby/helper/search.py | nipunayf/journey | 2c6b10e792184e6c25ab4324831bd91d7d8df8b7 | [
"MIT"
] | 1 | 2021-11-12T13:08:17.000Z | 2021-11-12T13:08:17.000Z | from . import map
def search(id):
id = id['id']
place_details = map.placeDetails(id)
data = {'location': {
'lat': place_details['geometry']['location']['lat'],
'lng': place_details['geometry']['location']['lng']
}
}
nearby = map.nearbySearch(data)
result = {'place_details': place_details,
'nearby': nearby}
return result
| 24.125 | 60 | 0.57772 | 41 | 386 | 5.317073 | 0.439024 | 0.275229 | 0.055046 | 0.256881 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0.251295 | 386 | 15 | 61 | 25.733333 | 0.754325 | 0 | 0 | 0 | 0 | 0 | 0.189119 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0.076923 | false | 0 | 0.076923 | 0 | 0.230769 | 0 | 0 | 0 | 0 | null | 1 | 0 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 2 |
0180a19479e89d3d7f062b3ff3780a6912a024eb | 4,507 | py | Python | pieces.py | dboures/Hive | 73314335c42341bdc8f34bbc1af00f9fdf1fe25d | [
"MIT"
] | null | null | null | pieces.py | dboures/Hive | 73314335c42341bdc8f34bbc1af00f9fdf1fe25d | [
"MIT"
] | 1 | 2021-11-14T10:58:28.000Z | 2021-11-14T16:04:22.000Z | pieces.py | dboures/Hive | 73314335c42341bdc8f34bbc1af00f9fdf1fe25d | [
"MIT"
] | null | null | null | #!/usr/bin/python
# -*- coding: utf-8 -*-
import numpy as np
import pygame as pg
from move_checker import axial_distance, move_is_not_blocked_or_jump, \
path_exists, is_straight_line
from settings import PIECE_WHITE
class Piece:
def __init__(self, color=PIECE_WHITE):
self.old_pos = None
self.color = color
def update_pos(self, pos):
self.old_pos = pos
def move_is_valid(self, state, old_tile, new_tile):
pass
class Queen(Piece):
def __init__(self, color=PIECE_WHITE):
super().__init__(color)
def draw(self, surface, hex_pos):
image = \
pg.image.load('images/{}.png'.format(type(self).__name__))
(x, y) = hex_pos
pos = (x - 16, y - 14)
surface.blit(image, pos)
def move_is_valid(self, state, old_tile, new_tile):
dist = axial_distance(old_tile.axial_coords,
new_tile.axial_coords)
if dist == 1 and move_is_not_blocked_or_jump(state, old_tile,
new_tile):
return True
else:
return False
class Ant(Piece):
def __init__(self, color=PIECE_WHITE):
super().__init__(color)
def draw(self, surface, hex_pos):
image = \
pg.image.load('images/{}.png'.format(type(self).__name__))
(x, y) = hex_pos
pos = (x - 16, y - 17)
surface.blit(image, pos)
def move_is_valid(self, state, old_tile, new_tile):
if path_exists(state, old_tile, new_tile):
return True
else:
return False
class Spider(Piece):
def __init__(self, color=PIECE_WHITE):
super().__init__(color)
def draw(self, surface, hex_pos):
image = \
pg.image.load('images/{}.png'.format(type(self).__name__))
(x, y) = hex_pos
pos = (x - 16, y - 17)
surface.blit(image, pos)
def move_is_valid(self, state, old_tile, new_tile):
if path_exists(state, old_tile, new_tile, spider=True) \
and move_is_not_blocked_or_jump(state, old_tile, new_tile):
return True
else:
return False
class Beetle(Piece):
def __init__(self, color=PIECE_WHITE):
super().__init__(color)
def draw(self, surface, hex_pos):
image = \
pg.image.load('images/{}.png'.format(type(self).__name__))
(x, y) = hex_pos
pos = (x - 16, y - 16)
surface.blit(image, pos)
def move_is_valid(self, state, old_tile, new_tile):
dist = axial_distance(old_tile.axial_coords,
new_tile.axial_coords)
if dist == 1 and (move_is_not_blocked_or_jump(state, old_tile,
new_tile) or new_tile.has_pieces()
or len(old_tile.pieces) > 1):
# can't slide into a blocked hex but it can go up or down into one
return True
else:
return False
class Grasshopper(Piece):
def __init__(self, color=PIECE_WHITE):
super().__init__(color)
def draw(self, surface, hex_pos):
image = \
pg.image.load('images/{}.png'.format(type(self).__name__))
(x, y) = hex_pos
pos = (x - 12, y - 14)
surface.blit(image, pos)
def move_is_valid(self, state, old_tile, new_tile):
# dist > 1, straight line, must hop over pieces
dist = axial_distance(old_tile.axial_coords,
new_tile.axial_coords)
if dist > 1:
visited = [old_tile]
queue = [old_tile]
while queue and new_tile not in visited:
current_tile = queue.pop(0)
for neighbor_tile in [x for x in
current_tile.adjacent_tiles if x.has_pieces()
and is_straight_line(old_tile.axial_coords,
x.axial_coords)]:
if neighbor_tile not in visited:
visited.append(neighbor_tile)
queue.append(neighbor_tile)
# have to check last tile seperately bc it will never have a piece
for penultimate_tile in [x for x in new_tile.adjacent_tiles
if x.has_pieces()]:
if penultimate_tile in visited \
and is_straight_line(old_tile.axial_coords,
new_tile.axial_coords):
return True
else:
return False
| 29.651316 | 78 | 0.565121 | 588 | 4,507 | 4.008503 | 0.192177 | 0.056428 | 0.056003 | 0.070004 | 0.725074 | 0.714468 | 0.681375 | 0.643615 | 0.606279 | 0.606279 | 0 | 0.009051 | 0.338141 | 4,507 | 151 | 79 | 29.847682 | 0.781093 | 0.047482 | 0 | 0.614679 | 0 | 0 | 0.015159 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0.165138 | false | 0.009174 | 0.036697 | 0 | 0.348624 | 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 |
0180ebf5effcc17eda0b2f9fafa0217ca2911e6e | 314 | py | Python | trac/Scripts/pygmentize-script.py | thinkbase/PortableTrac | 9ea0210f6b88f135ef73f370b48127af0495b2d7 | [
"BSD-3-Clause"
] | 2 | 2015-08-06T04:19:21.000Z | 2020-04-29T23:52:10.000Z | trac/Scripts/pygmentize-script.py | thinkbase/PortableTrac | 9ea0210f6b88f135ef73f370b48127af0495b2d7 | [
"BSD-3-Clause"
] | null | null | null | trac/Scripts/pygmentize-script.py | thinkbase/PortableTrac | 9ea0210f6b88f135ef73f370b48127af0495b2d7 | [
"BSD-3-Clause"
] | null | null | null | #!"E:\PortableTrac\Portable Python 2.7.3.1\App\python.exe"
# EASY-INSTALL-ENTRY-SCRIPT: 'Pygments==1.5','console_scripts','pygmentize'
__requires__ = 'Pygments==1.5'
import sys
from pkg_resources import load_entry_point
sys.exit(
load_entry_point('Pygments==1.5', 'console_scripts', 'pygmentize')()
)
| 31.4 | 76 | 0.726115 | 45 | 314 | 4.822222 | 0.622222 | 0.124424 | 0.138249 | 0.156682 | 0.313364 | 0.313364 | 0 | 0 | 0 | 0 | 0 | 0.035587 | 0.105096 | 314 | 9 | 77 | 34.888889 | 0.736655 | 0.417197 | 0 | 0 | 0 | 0 | 0.296512 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | false | 0 | 0.333333 | 0 | 0.333333 | 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 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.