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 |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
79ecb3b2b428677d25caa28181e21cb16577807d | 259 | py | Python | poem/urls.py | zakris/wordsworth | 271031822284c72079bc67261310546f83f0aab9 | [
"MIT"
] | null | null | null | poem/urls.py | zakris/wordsworth | 271031822284c72079bc67261310546f83f0aab9 | [
"MIT"
] | null | null | null | poem/urls.py | zakris/wordsworth | 271031822284c72079bc67261310546f83f0aab9 | [
"MIT"
] | null | null | null | from . import views
from django.urls import path
urlpatterns = [
path('', views.PoemList.as_view(), name='home'),
# path('<slug:slug>/', views.PoemDetail.as_view(), name='poem_detail'),
path('<slug:slug>/', views.post_detail, name='poem_detail')
] | 32.375 | 74 | 0.671815 | 35 | 259 | 4.828571 | 0.485714 | 0.071006 | 0.118343 | 0.201183 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0.127413 | 259 | 8 | 75 | 32.375 | 0.747788 | 0.266409 | 0 | 0 | 0 | 0 | 0.143617 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | false | 0 | 0.333333 | 0 | 0.333333 | 0 | 0 | 0 | 0 | null | 0 | 0 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 0 | 0 | 3 |
79f7e55b99c31debc7e7f8f0757ca4a2a57a59f5 | 1,345 | py | Python | .nix/pkgs/development/python-modules/nsf-test-lib/src/nsft_pgp_utils/errors.py | jraygauthier/nixos_secure_factory | 67adb93b153902226301d4a68e7b6e3a0af660c2 | [
"Apache-2.0"
] | 1 | 2021-04-17T10:13:42.000Z | 2021-04-17T10:13:42.000Z | .nix/pkgs/development/python-modules/nsf-test-lib/src/nsft_pgp_utils/errors.py | jraygauthier/nixos_secure_factory | 67adb93b153902226301d4a68e7b6e3a0af660c2 | [
"Apache-2.0"
] | 4 | 2019-10-21T17:40:17.000Z | 2021-11-11T13:46:20.000Z | .nix/pkgs/development/python-modules/nsf-test-lib/src/nsft_pgp_utils/errors.py | jraygauthier/nixos_secure_factory | 67adb93b153902226301d4a68e7b6e3a0af660c2 | [
"Apache-2.0"
] | 2 | 2019-10-10T18:32:01.000Z | 2021-08-24T16:02:09.000Z |
import shlex
from typing import Optional, List, Union
from subprocess import CalledProcessError
class GpgError(Exception):
pass
_CmdT = Union[str, List[str]]
def _format_cmd(cmd: _CmdT) -> str:
if isinstance(cmd, str):
return cmd
if not isinstance(cmd, list):
return f"{cmd}"
return " ".join(map(lambda x: shlex.quote(x), cmd))
class GpgProcessError(GpgError):
@classmethod
def mk_from(cls, other: CalledProcessError) -> 'GpgProcessError':
return GpgProcessError(**other.__dict__)
def __init__(
self,
returncode: int,
cmd: _CmdT,
output: Optional[str] = None,
stderr: Optional[str] = None
) -> None:
cmd_str = _format_cmd(cmd)
self._impl = CalledProcessError(returncode, cmd_str, output, stderr)
self._cmd = cmd
def __str__(self) -> str:
return self._impl.__str__()
@property
def returncode(self) -> int:
return self._impl.returncode
@property
def cmd(self) -> _CmdT:
return self._cmd
@property
def output(self) -> Optional[str]:
return self._impl.output
@property
def stderr(self) -> Optional[str]:
return self._impl.stderr
@property
def stdout(self) -> Optional[str]:
return self._impl.output
| 21.693548 | 76 | 0.615613 | 152 | 1,345 | 5.217105 | 0.289474 | 0.06053 | 0.088272 | 0.08575 | 0.124842 | 0.124842 | 0.088272 | 0 | 0 | 0 | 0 | 0 | 0.277323 | 1,345 | 61 | 77 | 22.04918 | 0.815844 | 0 | 0 | 0.162791 | 0 | 0 | 0.015625 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0.209302 | false | 0.023256 | 0.069767 | 0.162791 | 0.55814 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 0 | 1 | 1 | 0 | 0 | 3 |
03131bcc981d78e2f90fd7f46e7290664d32c41d | 71 | py | Python | rulo/rulo.py | iremlaya/brainhack17 | 95e0374785dd7aa7856cac149e04c2949d3ee852 | [
"MIT"
] | 2 | 2017-06-04T10:01:49.000Z | 2017-10-23T23:40:09.000Z | rulo/rulo.py | iremlaya/brainhack17 | 95e0374785dd7aa7856cac149e04c2949d3ee852 | [
"MIT"
] | 3 | 2017-10-23T22:54:43.000Z | 2018-10-02T15:57:22.000Z | rulo/rulo.py | iremlaya/brainhack17 | 95e0374785dd7aa7856cac149e04c2949d3ee852 | [
"MIT"
] | 2 | 2018-10-02T16:00:23.000Z | 2018-10-02T18:05:27.000Z | N=int(input())
V=list(map(int,input().split()))
print(V.count(max(V)))
| 17.75 | 32 | 0.633803 | 14 | 71 | 3.214286 | 0.714286 | 0.355556 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0.042254 | 71 | 3 | 33 | 23.666667 | 0.661765 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | false | 0 | 0 | 0 | 0 | 0.333333 | 1 | 0 | 0 | null | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 3 |
03219d78ace5c18a08e1f81e4b9b52d1f74911eb | 138 | py | Python | test/input/020.py | EliRibble/pyfmt | e84a5531a7c06703eddd9dbc2072b0c8deae8c57 | [
"MIT"
] | null | null | null | test/input/020.py | EliRibble/pyfmt | e84a5531a7c06703eddd9dbc2072b0c8deae8c57 | [
"MIT"
] | null | null | null | test/input/020.py | EliRibble/pyfmt | e84a5531a7c06703eddd9dbc2072b0c8deae8c57 | [
"MIT"
] | null | null | null | import time
from datetime import datetime
SOME_CONSTANT = True
ANOTHER_CONSTNAT = False
def main():
"Nothing here but us chickens"
| 13.8 | 34 | 0.76087 | 19 | 138 | 5.421053 | 0.894737 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0.188406 | 138 | 9 | 35 | 15.333333 | 0.919643 | 0.202899 | 0 | 0 | 0 | 0 | 0.202899 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0.166667 | false | 0 | 0.333333 | 0 | 0.5 | 0 | 1 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 0 | 0 | 3 |
0329f72cb8a5711d6e842c84700883fac49ca334 | 94 | py | Python | riskapi/apps.py | MaheshBodas/BriteCorePOCAPI | 2f189bbcea64aa707992f7fa139eac71dd3e9c7c | [
"MIT"
] | null | null | null | riskapi/apps.py | MaheshBodas/BriteCorePOCAPI | 2f189bbcea64aa707992f7fa139eac71dd3e9c7c | [
"MIT"
] | 3 | 2020-06-05T18:17:25.000Z | 2022-02-10T10:11:13.000Z | riskapi/apps.py | MaheshBodas/BriteCorePOCAPI | 2f189bbcea64aa707992f7fa139eac71dd3e9c7c | [
"MIT"
] | null | null | null | from django.apps import AppConfig
class RiskapiConfig(AppConfig):
name = 'riskapi'
| 15.666667 | 34 | 0.712766 | 10 | 94 | 6.7 | 0.9 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0.212766 | 94 | 5 | 35 | 18.8 | 0.905405 | 0 | 0 | 0 | 0 | 0 | 0.078652 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | false | 0 | 0.333333 | 0 | 1 | 0 | 1 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 0 | 0 | 3 |
032ad04d1de8fdf947200e4fc9bea01766cb5991 | 2,170 | py | Python | utils/boilerplate/test_butterfly.py | cfginn/sap-simulation-package | 73314e5380cec5c61a9fe5ff5fbafa25b9e2beac | [
"MIT"
] | null | null | null | utils/boilerplate/test_butterfly.py | cfginn/sap-simulation-package | 73314e5380cec5c61a9fe5ff5fbafa25b9e2beac | [
"MIT"
] | null | null | null | utils/boilerplate/test_butterfly.py | cfginn/sap-simulation-package | 73314e5380cec5c61a9fe5ff5fbafa25b9e2beac | [
"MIT"
] | null | null | null |
import unittest
from pysapets.butterfly import Butterfly
from pysapets.animal import Animal
import pysapets.constants as constants
from unittest.mock import patch
from io import StringIO
from copy import deepcopy
class ButterflyTest(unittest.TestCase):
def setUp(self):
self.butterfly = Butterfly()
self.friends = [self.butterfly, Animal(2, 2), Animal(2, 2), Animal(2, 2), Animal(2, 2)]
# test that get_type returns the correct type
def test_get_type(self):
self.assertEqual(self.butterfly.get_type(), constants.BUTTERFLY)
# test that butterfly starts with base health of 1
def test_get_health(self):
self.assertEqual(self.butterfly.get_health(), 1)
# test that butterfly starts with base attack of 1
def test_get_attack(self):
self.assertEqual(self.butterfly.get_attack(), 1)
# test that initializing butterfly with additional health increases health
def test_init_add_health(self):
newButterfly = Butterfly(addHealth = 3)
self.assertEqual(newButterfly.get_health(), 1 + 3)
# test that initializing an butterfly with additional attack increases attack
def test_init_add_attack(self):
newButterfly = Butterfly(addAttack = 3)
self.assertEqual(newButterfly.get_attack(), 1 + 3)
# test that initializing butterfly with additional health and attack increases health and attack
def test_init_add_health_attack(self):
newButterfly = Butterfly(addHealth = 3, addAttack = 3)
self.assertEqual(newButterfly.get_health(), 1 + 3)
self.assertEqual(newButterfly.get_attack(), 1 + 3)
# test that butterfly ability has correct trigger
def test_get_ability_trigger(self):
self.assertEqual(self.butterfly.get_ability_trigger(), constants.SUMMONED)
# test that butterfly ability has correct triggeredBy
def test_get_ability_triggeredBy(self):
self.assertEqual(self.butterfly.get_ability_triggeredBy(), constants.SELF)
# TODO add relevant tests for butterfly ability
def test_run_ability(self):
pass
def test_run_ability_level_1(self):
pass
def test_run_ability_level_2(self):
pass
def test_run_ability_level_3(self):
pass
| 32.38806 | 98 | 0.751152 | 293 | 2,170 | 5.399317 | 0.204778 | 0.053097 | 0.031606 | 0.072693 | 0.564475 | 0.450063 | 0.295196 | 0.128319 | 0.079646 | 0.059418 | 0 | 0.015 | 0.170507 | 2,170 | 67 | 99 | 32.38806 | 0.863889 | 0.245161 | 0 | 0.205128 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0.014925 | 0.230769 | 1 | 0.333333 | false | 0.102564 | 0.179487 | 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 | 1 | 0 | 0 | 1 | 0 | 1 | 0 | 0 | 0 | 0 | 0 | 3 |
036b68ec391233902bb037964aaf4dee18d68831 | 1,044 | py | Python | Server/src/RoomHandler.py | peauc/VLC-together | 51a34fe55c5d42b7bc145a421bfd7ef5af4198ae | [
"MIT"
] | null | null | null | Server/src/RoomHandler.py | peauc/VLC-together | 51a34fe55c5d42b7bc145a421bfd7ef5af4198ae | [
"MIT"
] | null | null | null | Server/src/RoomHandler.py | peauc/VLC-together | 51a34fe55c5d42b7bc145a421bfd7ef5af4198ae | [
"MIT"
] | null | null | null | import logging
from .User import User
from .Room import Room
class RoomHandler:
def __init__(self):
self.__rooms = {}
def __len__(self):
return len(self.__rooms)
def add_user_to_room(self, user: User, room_name: str, password=""):
if room_name not in self.__rooms:
logging.debug(f"Added user {user.sock.getpeername()} to room {room_name}")
self.__rooms[room_name] = Room(room_name, password)
self.__rooms[room_name].add_user(user, password)
def remove_user_from_room(self, user: User, room: Room):
if room in self.__rooms and room.has_user(user):
room.remove_user(user)
def is_user_in_room(self, user: User) -> bool:
for room in self.__rooms:
if room.has_user(user):
return True
return False
def get_room_from_user(self, user: User) -> Room or None:
for room in self.__rooms.values():
if room.has_user(user):
return room
return None
| 30.705882 | 90 | 0.613985 | 144 | 1,044 | 4.125 | 0.263889 | 0.13468 | 0.080808 | 0.080808 | 0.205387 | 0.077441 | 0 | 0 | 0 | 0 | 0 | 0 | 0.29023 | 1,044 | 33 | 91 | 31.636364 | 0.801619 | 0 | 0 | 0.076923 | 0 | 0 | 0.05364 | 0.023946 | 0 | 0 | 0 | 0 | 0 | 1 | 0.230769 | false | 0.115385 | 0.115385 | 0.038462 | 0.576923 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 1 | 0 | 0 | 1 | 0 | 0 | 3 |
cee2f6e3487a79c32b2d01d33a8b6efba3797133 | 164 | py | Python | sources/boltun/engine/environment/extension/nlp/namespaces/slot.py | meiblorn/boltun | d141f555b4f0ed604d8d71883c0bc8811e74370e | [
"MIT"
] | 1 | 2019-12-06T04:19:37.000Z | 2019-12-06T04:19:37.000Z | sources/boltun/engine/environment/extension/nlp/namespaces/slot.py | meiblorn/boltun | d141f555b4f0ed604d8d71883c0bc8811e74370e | [
"MIT"
] | null | null | null | sources/boltun/engine/environment/extension/nlp/namespaces/slot.py | meiblorn/boltun | d141f555b4f0ed604d8d71883c0bc8811e74370e | [
"MIT"
] | null | null | null | from boltun.engine.environment.extension import Namespace
class SlotNamespace(Namespace):
@classmethod
def __boltun_name__(cls):
return ['slot']
| 18.222222 | 57 | 0.731707 | 17 | 164 | 6.764706 | 0.882353 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0.182927 | 164 | 8 | 58 | 20.5 | 0.858209 | 0 | 0 | 0 | 0 | 0 | 0.02439 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0.2 | false | 0 | 0.2 | 0.2 | 0.8 | 0 | 1 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 0 | 3 |
301645eded63a950c9ab527c496ffc2fd60fa4fc | 916 | py | Python | netpyne/cell/NML2Cell.py | pabloabur/netpyne | 7763d835eb89b9c3c1d0b49489e215ceaceafd82 | [
"MIT"
] | 1 | 2018-01-23T00:05:57.000Z | 2018-01-23T00:05:57.000Z | netpyne/cell/NML2Cell.py | pabloabur/netpyne | 7763d835eb89b9c3c1d0b49489e215ceaceafd82 | [
"MIT"
] | 2 | 2019-11-05T00:05:56.000Z | 2019-11-18T00:16:24.000Z | netpyne/cell/NML2Cell.py | pabloabur/netpyne | 7763d835eb89b9c3c1d0b49489e215ceaceafd82 | [
"MIT"
] | null | null | null | """
cell/NML2Cell.py
Contains pointCell class
Contributors: salvadordura@gmail.com
"""
from __future__ import unicode_literals
from __future__ import print_function
from __future__ import division
from __future__ import absolute_import
from future import standard_library
standard_library.install_aliases()
from copy import deepcopy
from neuron import h # Import NEURON
import numpy as np
from .compartCell import CompartCell
from ..specs import Dict
###############################################################################
#
# NeuroML2 CELL CLASS
#
###############################################################################
class NML2Cell (CompartCell):
''' Class for NeuroML2 neuron models: No different than CompartCell '''
''' Might this be useful to show better name for cell when psection() called?
def __str__():
return "%s"%self.tags['cellType']
'''
| 26.171429 | 81 | 0.618996 | 95 | 916 | 5.694737 | 0.6 | 0.092421 | 0.147874 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0.005148 | 0.151747 | 916 | 35 | 82 | 26.171429 | 0.69112 | 0.19869 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | true | 0 | 0.833333 | 0 | 0.916667 | 0.083333 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 1 | 0 | 1 | 0 | 0 | 3 |
3017fbeea4dd1c0e2fbaf9adbbd7a9211b8af8b4 | 450 | py | Python | OpenGLCffi/EGL/EXT/NV/stream_metadata.py | cydenix/OpenGLCffi | c78f51ae5e6b655eb2ea98f072771cf69e2197f3 | [
"MIT"
] | null | null | null | OpenGLCffi/EGL/EXT/NV/stream_metadata.py | cydenix/OpenGLCffi | c78f51ae5e6b655eb2ea98f072771cf69e2197f3 | [
"MIT"
] | null | null | null | OpenGLCffi/EGL/EXT/NV/stream_metadata.py | cydenix/OpenGLCffi | c78f51ae5e6b655eb2ea98f072771cf69e2197f3 | [
"MIT"
] | null | null | null | from OpenGLCffi.EGL import params
@params(api='egl', prms=['dpy', 'attribute', 'value'])
def eglQueryDisplayAttribNV(dpy, attribute):
pass
@params(api='egl', prms=['dpy', 'stream', 'n', 'offset', 'size', 'data'])
def eglSetStreamMetadataNV(dpy, stream, n, offset, size, data):
pass
@params(api='egl', prms=['dpy', 'stream', 'name', 'n', 'offset', 'size', 'data'])
def eglQueryStreamMetadataNV(dpy, stream, name, n, offset, size, data):
pass
| 26.470588 | 81 | 0.666667 | 57 | 450 | 5.263158 | 0.368421 | 0.12 | 0.146667 | 0.2 | 0.576667 | 0.48 | 0.35 | 0 | 0 | 0 | 0 | 0 | 0.117778 | 450 | 16 | 82 | 28.125 | 0.755668 | 0 | 0 | 0.3 | 0 | 0 | 0.174107 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0.3 | false | 0.3 | 0.1 | 0 | 0.4 | 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 | 1 | 0 | 0 | 0 | 0 | 0 | 3 |
302076412b9e8a39f7fca0d150090503586f64a2 | 179 | py | Python | slackbot_settings.py | nexusz99/eastpot_slackbot | d7e67abf6f722cdcd06a39d4f6d89d920d7f2e25 | [
"Apache-2.0"
] | null | null | null | slackbot_settings.py | nexusz99/eastpot_slackbot | d7e67abf6f722cdcd06a39d4f6d89d920d7f2e25 | [
"Apache-2.0"
] | null | null | null | slackbot_settings.py | nexusz99/eastpot_slackbot | d7e67abf6f722cdcd06a39d4f6d89d920d7f2e25 | [
"Apache-2.0"
] | null | null | null | # -*- coding: utf-8 -*-
API_TOKEN = ""
DEFAULT_REPLY = "잘못된 명령어입니다. 고갱님"
PLUGINS = [
'eastbot.plugins.basic',
'eastbot.plugins.ethereum',
'eastbot.plugins.miner',
]
| 16.272727 | 33 | 0.620112 | 20 | 179 | 5.45 | 0.75 | 0.385321 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0.006897 | 0.189944 | 179 | 10 | 34 | 17.9 | 0.744828 | 0.117318 | 0 | 0 | 0 | 0 | 0.519231 | 0.423077 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | false | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 0 | null | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 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 | 3 |
302477f7160abb2240d40039131d7f78d819c173 | 597 | py | Python | visualizers/kibana.py | bfortuner/VOCdetect | f11e363d60b1d91bd36bc98d69496f847287ad28 | [
"MIT"
] | 336 | 2017-08-22T18:54:19.000Z | 2022-03-22T04:07:08.000Z | visualizers/kibana.py | emeraldic/kaggle-starter | 7f993161afca8809e8a6ea46bffe76b4d6163082 | [
"MIT"
] | 1 | 2020-02-14T14:12:15.000Z | 2020-02-14T14:12:15.000Z | visualizers/kibana.py | emeraldic/kaggle-starter | 7f993161afca8809e8a6ea46bffe76b4d6163082 | [
"MIT"
] | 73 | 2017-08-26T22:09:58.000Z | 2022-03-29T13:00:02.000Z | import json
import pandas as pd
import config
import constants as c
import clients.client_constants as cc
import clients.es_client as es
import copy
class Kibana():
def __init__(self, exp_name):
self.name = exp_name
self.classname = 'Kibana'
def init(self, exp_config):
assert config.ES_ENABLED is True
assert es.ping() is True
def update(self, exp_config, exp_history, msg=None):
es.upload_experiment_history(exp_config, exp_history)
es.upload_experiment_config(exp_config)
def load(config):
return Kibana(config.name)
| 20.586207 | 61 | 0.705193 | 86 | 597 | 4.674419 | 0.395349 | 0.089552 | 0.064677 | 0.084577 | 0.099502 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0.222781 | 597 | 28 | 62 | 21.321429 | 0.866379 | 0 | 0 | 0 | 0 | 0 | 0.010084 | 0 | 0 | 0 | 0 | 0 | 0.105263 | 1 | 0.210526 | false | 0 | 0.368421 | 0.052632 | 0.684211 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 1 | 0 | 1 | 0 | 0 | 3 |
302d31e462b899a5687253372e142ec9fd1abf57 | 91 | py | Python | tyrell/venv/lib/python3.8/site-packages/rpy2/__init__.py | YuehanLee/CS190I | c5e3dca9f3b936a15b254abfd0c245c470e8c27e | [
"Apache-2.0"
] | null | null | null | tyrell/venv/lib/python3.8/site-packages/rpy2/__init__.py | YuehanLee/CS190I | c5e3dca9f3b936a15b254abfd0c245c470e8c27e | [
"Apache-2.0"
] | null | null | null | tyrell/venv/lib/python3.8/site-packages/rpy2/__init__.py | YuehanLee/CS190I | c5e3dca9f3b936a15b254abfd0c245c470e8c27e | [
"Apache-2.0"
] | null | null | null | __version_vector__ = (3, 4, 4)
__version__ = '.'.join(str(x) for x in __version_vector__)
| 22.75 | 58 | 0.703297 | 14 | 91 | 3.571429 | 0.642857 | 0.52 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0.038462 | 0.142857 | 91 | 3 | 59 | 30.333333 | 0.602564 | 0 | 0 | 0 | 0 | 0 | 0.010989 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | false | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 0 | null | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 3 |
303ed30db37a315d0acda3cfe354394914f4ddd0 | 347 | py | Python | hylite/analyse/__init__.py | npucino/hylite | dff1314a2a0c281fd2fc1a5ee03bdba3e0c49f28 | [
"MIT"
] | 18 | 2020-11-19T12:53:44.000Z | 2022-02-21T21:02:02.000Z | hylite/analyse/__init__.py | npucino/hylite | dff1314a2a0c281fd2fc1a5ee03bdba3e0c49f28 | [
"MIT"
] | 1 | 2022-02-22T07:02:26.000Z | 2022-03-01T10:55:32.000Z | hylite/analyse/__init__.py | npucino/hylite | dff1314a2a0c281fd2fc1a5ee03bdba3e0c49f28 | [
"MIT"
] | 7 | 2021-01-12T09:46:40.000Z | 2022-02-23T12:36:33.000Z | """
This package implements common analysis methods for hyperspectral datasets, including:
- supervised and unsupervised classification.
- minimum wavelength mapping.
- endmember extraction and unmixing.
- commonly used band ratios (e.g. NDVI).
"""
from .indices import *
from .mwl import *
from .sam import *
from .dtree import * | 28.916667 | 86 | 0.731988 | 40 | 347 | 6.35 | 0.825 | 0.11811 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0.18732 | 347 | 12 | 87 | 28.916667 | 0.900709 | 0.737752 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | true | 0 | 1 | 0 | 1 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 1 | 0 | 1 | 0 | 0 | 3 |
30576a1c9c719f59f13bcf613b81967c5c07ce88 | 166 | py | Python | django_graphene_utils/types.py | amille44420/django-graphene-utils | 8ea588c5b141282d38c6f6743f988c06a32cd138 | [
"MIT"
] | 1 | 2018-02-28T19:23:08.000Z | 2018-02-28T19:23:08.000Z | django_graphene_utils/types.py | amille44420/django-graphene-utils | 8ea588c5b141282d38c6f6743f988c06a32cd138 | [
"MIT"
] | null | null | null | django_graphene_utils/types.py | amille44420/django-graphene-utils | 8ea588c5b141282d38c6f6743f988c06a32cd138 | [
"MIT"
] | null | null | null | import graphene
__all__ = ['FormError']
"""
Form error type
"""
class FormError(graphene.ObjectType):
key = graphene.String()
message = graphene.String()
| 12.769231 | 37 | 0.680723 | 17 | 166 | 6.411765 | 0.705882 | 0.256881 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0.180723 | 166 | 12 | 38 | 13.833333 | 0.801471 | 0 | 0 | 0 | 0 | 0 | 0.062937 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | false | 0 | 0.2 | 0 | 0.8 | 0 | 1 | 0 | 0 | null | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 3 |
30585d6d042849dad5f93f2d9f22e4d90bd497d6 | 226 | py | Python | iplantauth/__init__.py | Duke-GCB/django-iplant-auth | 8f2012649759193cbd1e7590aa65d5701968e7cf | [
"BSD-3-Clause"
] | null | null | null | iplantauth/__init__.py | Duke-GCB/django-iplant-auth | 8f2012649759193cbd1e7590aa65d5701968e7cf | [
"BSD-3-Clause"
] | null | null | null | iplantauth/__init__.py | Duke-GCB/django-iplant-auth | 8f2012649759193cbd1e7590aa65d5701968e7cf | [
"BSD-3-Clause"
] | null | null | null | # -*- coding: utf-8 -*-
from collections import namedtuple
version_info = namedtuple("version_info", ["major", "minor", "patch"])
version = version_info(0, 1, 14)
__version__ = "{0.major}.{0.minor}.{0.patch}".format(version)
| 32.285714 | 70 | 0.685841 | 30 | 226 | 4.933333 | 0.533333 | 0.222973 | 0.283784 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0.039604 | 0.106195 | 226 | 6 | 71 | 37.666667 | 0.693069 | 0.09292 | 0 | 0 | 0 | 0 | 0.275862 | 0.142857 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | false | 0 | 0.25 | 0 | 0.25 | 0 | 0 | 0 | 0 | null | 1 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 3 |
3063e52ee5fe17c44b4e3ed4060b6ec3b6206a0e | 1,571 | py | Python | scripts/pyBusPirateLite/pyBusPirateLite/rawwire.py | bopopescu/Bus-Pirate-1 | 62a449f4aa6edb2160e00537f06024b2e1ce6c48 | [
"CC0-1.0"
] | 1 | 2019-12-27T11:45:11.000Z | 2019-12-27T11:45:11.000Z | scripts/pyBusPirateLite/pyBusPirateLite/rawwire.py | bopopescu/Bus-Pirate-1 | 62a449f4aa6edb2160e00537f06024b2e1ce6c48 | [
"CC0-1.0"
] | 1 | 2020-07-24T15:59:56.000Z | 2020-07-24T15:59:56.000Z | scripts/pyBusPirateLite/pyBusPirateLite/rawwire.py | bopopescu/Bus-Pirate-1 | 62a449f4aa6edb2160e00537f06024b2e1ce6c48 | [
"CC0-1.0"
] | 1 | 2020-07-24T12:54:33.000Z | 2020-07-24T12:54:33.000Z | from .BinBang import *
class RawWireCfg:
NA = 0x01
LSB = 0x02
_3WIRE = 0x04
OUTPUT = 0x08
class RawWire(BBIO):
def __init__(self, port, speed):
BBIO.__init__(self, port, speed)
def start_bit(self):
self.port.write("\x02")
self.timeout(0.1)
return self.response(1)
def stop_bit(self):
self.port.write("\x03")
self.timeout(0.1)
return self.response(1)
def cs_low(self):
self.port.write("\x04")
self.timeout(0.1)
return self.response(1)
def cs_high(self):
self.port.write("\x05")
self.timeout(0.1)
return self.response(1)
def read_byte(self):
self.port.write("\x06")
self.timeout(0.1)
return self.response(1)
def read_bit(self):
self.port.write("\x07")
self.timeout(0.1)
return self.response(1)
def peek(self):
self.port.write("\x08")
self.timeout(0.1)
return self.response(1)
def clock_tick(self):
self.port.write("\x09")
self.timeout(0.1)
return self.response(1)
def clock_low(self):
self.port.write("\x0A")
self.timeout(0.1)
return self.response(1)
def clock_high(self):
self.port.write("\x0B")
self.timeout(0.1)
return self.response(1)
def data_low(self):
self.port.write("\x0C")
self.timeout(0.1)
return self.response(1)
def data_high(self):
self.port.write("\x0D")
self.timeout(0.1)
return self.response(1)
def wire_cfg(self, pins=0):
self.port.write(0x80 | pins)
self.timeout(0.1)
return self.response(1)
def bulk_clock_ticks(self, ticks=1):
self.port.write(0x20 | (ticks-1))
self.timeout(0.1)
return self.response(1)
| 19.158537 | 37 | 0.664545 | 257 | 1,571 | 3.972763 | 0.22179 | 0.125367 | 0.178257 | 0.178257 | 0.6905 | 0.511263 | 0.511263 | 0.511263 | 0.479922 | 0.342801 | 0 | 0.064368 | 0.169319 | 1,571 | 82 | 38 | 19.158537 | 0.718008 | 0 | 0 | 0.430769 | 0 | 0 | 0.030534 | 0 | 0 | 0 | 0.015267 | 0 | 0 | 1 | 0.230769 | false | 0 | 0.015385 | 0 | 0.553846 | 0 | 0 | 0 | 0 | null | 0 | 0 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 3 |
061cad37b03805e8f97ee62c43e93618f315bbe1 | 441 | py | Python | c2dh_nerd/ned/ned.py | theorm/c2dh-nerd | 790c945a75d25735e826fbbebb0441a00627dc1c | [
"MIT"
] | null | null | null | c2dh_nerd/ned/ned.py | theorm/c2dh-nerd | 790c945a75d25735e826fbbebb0441a00627dc1c | [
"MIT"
] | null | null | null | c2dh_nerd/ned/ned.py | theorm/c2dh-nerd | 790c945a75d25735e826fbbebb0441a00627dc1c | [
"MIT"
] | null | null | null | from typing import TypeVar, List, Tuple
from segtok.segmenter import split_single
from ..ner.ner import text_to_sentences, sentences_to_text, TextOrSentences
from .result import NedResult, NedResource
class NED:
async def extract(self, text: TextOrSentences, **kwargs) -> NedResult:
raise NotImplementedError()
async def expand_resource(self, model_name, resource_id, label = None) -> NedResource:
raise NotImplementedError()
| 33.923077 | 88 | 0.786848 | 54 | 441 | 6.277778 | 0.62963 | 0.112094 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0.136054 | 441 | 12 | 89 | 36.75 | 0.889764 | 0 | 0 | 0.222222 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | true | 0 | 0.444444 | 0 | 0.555556 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 1 | 0 | 1 | 0 | 0 | 3 |
0648c48894663796abf8415ae349d01c407295d8 | 2,605 | py | Python | py/legacy/selectZipcodeGeoJson.py | yenchiah/smell-pittsburgh-prediction | 09f9c865ffa81eef4fbc0122ed915c66355c44a6 | [
"BSD-3-Clause"
] | 4 | 2019-08-17T01:06:26.000Z | 2022-01-24T07:26:25.000Z | py/legacy/selectZipcodeGeoJson.py | yenchiah/smell-pittsburgh-prediction | 09f9c865ffa81eef4fbc0122ed915c66355c44a6 | [
"BSD-3-Clause"
] | null | null | null | py/legacy/selectZipcodeGeoJson.py | yenchiah/smell-pittsburgh-prediction | 09f9c865ffa81eef4fbc0122ed915c66355c44a6 | [
"BSD-3-Clause"
] | 6 | 2019-08-15T18:24:00.000Z | 2022-03-30T12:12:01.000Z | import numpy as np
import json
import sys
sys.path.append("../analysis/")
from util import *
# This function is used for the heatmap visualization
# Select only zipcode GeoJSON bounds in the Allegany county in PA
# INPUT: GeoJSON of all zipcode bounds in the US
# OUTPUT: GeoJSON of zipcode bounds (plus latlng bounds) in the Allegany county in PA
def main():
p = "../../data/"
file_path_in = p+"geo/zcta5.json"
file_path_out = p+"geo/zipcode_bound_geoJson_allegany_county_PA.json"
# Check output directory
checkAndCreateDir(file_path_out)
# All unique zipcodes for the Allegany county in PA
zipcodes_unique = [15006, 15007, 15014, 15015, 15017, 15018, 15020, 15024, 15025,
15028, 15030, 15031, 15032, 15034, 15035, 15037, 15044, 15045, 15046, 15047,
15049, 15051, 15056, 15064, 15065, 15071, 15075, 15076, 15082, 15084, 15086,
15088, 15090, 15091, 15095, 15096, 15101, 15102, 15104, 15106, 15108, 15110,
15112, 15116, 15120, 15122, 15123, 15126, 15127, 15129, 15131, 15132, 15133,
15134, 15135, 15136, 15137, 15139, 15140, 15142, 15143, 15144, 15145, 15146,
15147, 15148, 15201, 15202, 15203, 15204, 15205, 15206, 15207, 15208, 15209,
15210, 15211, 15212, 15213, 15214, 15215, 15216, 15217, 15218, 15219, 15220,
15221, 15222, 15223, 15224, 15225, 15226, 15227, 15228, 15229, 15230, 15231,
15232, 15233, 15234, 15235, 15236, 15237, 15238, 15239, 15240, 15241, 15242,
15243, 15244, 15250, 15251, 15252, 15253, 15254, 15255, 15257, 15258, 15259,
15260, 15261, 15262, 15264, 15265, 15267, 15268, 15270, 15272, 15274, 15275,
15276, 15277, 15278, 15279, 15281, 15282, 15283, 15286, 15289, 15290, 15295]
# Read the geoJSON file that contains all zipcode bounds in USA
print "Read the zipcode boundaries from " + file_path_in
with open(file_path_in, "r") as in_file:
zipcode_bound_all = json.load(in_file)
# Select only the boundaries in the Allegany county in PA
print "Select only the boundaries in the Allegany county in PA"
zipcode_bound_ac = {
"type": "FeatureCollection",
"features": []
}
for feature in zipcode_bound_all["features"]:
zipcode = int(feature["properties"]["ZCTA5CE10"])
if zipcode in zipcodes_unique:
zipcode_bound_ac["features"].append(feature)
# Write to a GeoJSON file
print "Write the boundaries to GeoJSON file " + file_path_out
with open(file_path_out, "w") as out_file:
json.dump(zipcode_bound_ac, out_file)
if __name__ == "__main__":
main()
| 44.913793 | 85 | 0.679079 | 360 | 2,605 | 4.794444 | 0.597222 | 0.032445 | 0.049247 | 0.055041 | 0.099073 | 0.086906 | 0.086906 | 0.053302 | 0.053302 | 0.053302 | 0 | 0.348232 | 0.218426 | 2,605 | 57 | 86 | 45.701754 | 0.499509 | 0.176967 | 0 | 0 | 0 | 0 | 0.133552 | 0.022962 | 0 | 0 | 0 | 0 | 0 | 0 | null | null | 0 | 0.1 | null | null | 0.075 | 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 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 3 |
0669a17c51a6ce36db18640545cedc13bf17f914 | 86 | py | Python | punto1.py | SebastianH03/TallerHerramineta | 019832772bc4d7007ee99f88399386a56e689f69 | [
"CNRI-Python"
] | null | null | null | punto1.py | SebastianH03/TallerHerramineta | 019832772bc4d7007ee99f88399386a56e689f69 | [
"CNRI-Python"
] | null | null | null | punto1.py | SebastianH03/TallerHerramineta | 019832772bc4d7007ee99f88399386a56e689f69 | [
"CNRI-Python"
] | null | null | null | #punto1
def triangulo(a,b):
area = (b * a)/2
print(area)
triangulo(30,50)
| 8.6 | 20 | 0.569767 | 14 | 86 | 3.5 | 0.714286 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0.09375 | 0.255814 | 86 | 9 | 21 | 9.555556 | 0.671875 | 0.069767 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0.25 | false | 0 | 0 | 0 | 0.25 | 0.25 | 1 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 3 |
068b8a559129dfc3500d0b4d0afd2b84b0b87992 | 378 | py | Python | backend/api_v3/utils.py | AstroMatt/subjective-time-perception | cbe222b86d2ec98065038d2f7a55c2c6b9518b9e | [
"MIT"
] | null | null | null | backend/api_v3/utils.py | AstroMatt/subjective-time-perception | cbe222b86d2ec98065038d2f7a55c2c6b9518b9e | [
"MIT"
] | null | null | null | backend/api_v3/utils.py | AstroMatt/subjective-time-perception | cbe222b86d2ec98065038d2f7a55c2c6b9518b9e | [
"MIT"
] | 1 | 2021-02-08T17:13:56.000Z | 2021-02-08T17:13:56.000Z | from backend.api_v3.models import Result
from backend.logger.models import HTTPRequest
def http_requests_without_results():
all_results = Result.objects.all().values_list('request_sha1', flat=True)
requests_without_results = HTTPRequest.objects.filter(api_version=3, data__isnull=False).exclude(
sha1__in=list(all_results))
return requests_without_results
| 37.8 | 101 | 0.798942 | 51 | 378 | 5.588235 | 0.607843 | 0.157895 | 0.231579 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0.01194 | 0.113757 | 378 | 9 | 102 | 42 | 0.838806 | 0 | 0 | 0 | 0 | 0 | 0.031746 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0.142857 | false | 0 | 0.285714 | 0 | 0.571429 | 0 | 0 | 0 | 0 | null | 0 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 3 |
23038c640c0433479f2bdf90b1bd117eebeff516 | 228 | py | Python | keyword_cluster_validation/urls.py | rohanjsuresh/extracted_keyword_validation | 94e56c645c066d9d20097433b1716b3e76625b3d | [
"MIT"
] | null | null | null | keyword_cluster_validation/urls.py | rohanjsuresh/extracted_keyword_validation | 94e56c645c066d9d20097433b1716b3e76625b3d | [
"MIT"
] | null | null | null | keyword_cluster_validation/urls.py | rohanjsuresh/extracted_keyword_validation | 94e56c645c066d9d20097433b1716b3e76625b3d | [
"MIT"
] | 1 | 2021-05-18T16:40:55.000Z | 2021-05-18T16:40:55.000Z | from django.urls import path
from . import views
from django.conf import settings
from django.conf.urls.static import static
urlpatterns = [
path('cluster_validation', views.cluster_validation, name='cluster_validation'),
] | 28.5 | 84 | 0.79386 | 30 | 228 | 5.933333 | 0.433333 | 0.168539 | 0.157303 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0.118421 | 228 | 8 | 85 | 28.5 | 0.885572 | 0 | 0 | 0 | 0 | 0 | 0.157205 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | false | 0 | 0.571429 | 0 | 0.571429 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 1 | 0 | 0 | 3 |
232024fdf36e7f84ec08131bf350a384f1211dfb | 863 | py | Python | src/singleton/singleton_decor.py | paulbodean88/automation-design-patterns | b160f317a0c0a1de409908f938fbeab0772c8147 | [
"MIT"
] | 14 | 2017-07-25T10:11:06.000Z | 2022-03-25T10:17:25.000Z | src/singleton/singleton_decor.py | paulbodean88/automation-design-patterns | b160f317a0c0a1de409908f938fbeab0772c8147 | [
"MIT"
] | 3 | 2017-07-23T17:19:14.000Z | 2017-07-24T19:54:52.000Z | src/singleton/singleton_decor.py | paulbodean88/automation-design-patterns | b160f317a0c0a1de409908f938fbeab0772c8147 | [
"MIT"
] | 5 | 2019-08-29T02:35:04.000Z | 2020-02-24T14:39:09.000Z | """
Description: Singleton implementation using decorators
@author: Paul Bodean
@date: 23.01.2018
"""
from selenium import webdriver
from singleton_decorator import singleton
def my_singleton(*args):
"""
:param cls: class to be changed as a singleton
:return: instance of the singleton
"""
instances = dict()
def get_instance():
if args[0] not in instances:
instances[args[0]] = args[0]()
# else: #uncomment this part in order to raise a warning related to instantiation
# raise UserWarning("An instantiation already exists!")
return instances[args[0]]
return get_instance
@my_singleton
class MyDriver:
@staticmethod
def get_driver():
return webdriver.Chrome()
@singleton
class Driver:
@staticmethod
def get_driver():
return webdriver.Chrome()
| 20.547619 | 89 | 0.668598 | 102 | 863 | 5.588235 | 0.54902 | 0.035088 | 0.049123 | 0.084211 | 0.157895 | 0.157895 | 0.157895 | 0 | 0 | 0 | 0 | 0.018377 | 0.243337 | 863 | 41 | 90 | 21.04878 | 0.854518 | 0.363847 | 0 | 0.315789 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0.210526 | false | 0 | 0.105263 | 0.105263 | 0.631579 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 0 | 1 | 1 | 0 | 0 | 3 |
232595f8dba9d50b98cba7c2ba1017a6c15fbf2c | 953 | py | Python | app/__init__.py | yogeshwaran01/Projects | 281d760b140d5fe212b8e3819aebbe3117ef2ead | [
"MIT"
] | 2 | 2021-03-08T15:19:51.000Z | 2021-04-13T01:30:29.000Z | app/__init__.py | yogeshwaran01/Projects | 281d760b140d5fe212b8e3819aebbe3117ef2ead | [
"MIT"
] | 7 | 2021-02-22T04:55:51.000Z | 2022-03-12T00:54:47.000Z | app/__init__.py | yogeshwaran01/Projects | 281d760b140d5fe212b8e3819aebbe3117ef2ead | [
"MIT"
] | null | null | null | from flask import Flask
from flask import render_template
from flask_sqlalchemy import SQLAlchemy
from flask_migrate import Migrate
from flask_login import LoginManager
from config import Configuartion
app = Flask(__name__)
app.config.from_object(Configuartion)
database = SQLAlchemy(app)
migrate = Migrate(app, database)
login = LoginManager(app)
login.login_view = "auth.login"
from .views import auth
from .views import todo
from .views import tools
from .views import fun
from .views import image
from .views import github
from .views import redirecter
@app.route("/")
def index():
return render_template("index.html", title="Home")
app.register_blueprint(auth.bp)
app.register_blueprint(todo.bp)
app.register_blueprint(tools.bp)
app.register_blueprint(fun.bp)
app.register_blueprint(image.bp)
app.register_blueprint(github.bp)
app.register_blueprint(redirecter.bp)
from .models.users import User, Todo
from .models.image import Codes
| 22.690476 | 54 | 0.804827 | 136 | 953 | 5.507353 | 0.279412 | 0.084112 | 0.140187 | 0.176235 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0.110178 | 953 | 41 | 55 | 23.243902 | 0.883255 | 0 | 0 | 0 | 0 | 0 | 0.026233 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0.032258 | false | 0 | 0.483871 | 0.032258 | 0.548387 | 0.225806 | 0 | 0 | 0 | null | 0 | 0 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 1 | 0 | 0 | 3 |
234a62c6a388e9f9c0fa5312c374f5bc2bbbbbb6 | 8,412 | py | Python | tests/python/relay/test_primal_gradients.py | sgrechanik-h/tvm | 8cad2d1e62272b3e192bfe08b896e07bc9550e94 | [
"Apache-2.0"
] | null | null | null | tests/python/relay/test_primal_gradients.py | sgrechanik-h/tvm | 8cad2d1e62272b3e192bfe08b896e07bc9550e94 | [
"Apache-2.0"
] | null | null | null | tests/python/relay/test_primal_gradients.py | sgrechanik-h/tvm | 8cad2d1e62272b3e192bfe08b896e07bc9550e94 | [
"Apache-2.0"
] | 3 | 2018-10-31T07:14:13.000Z | 2020-01-13T02:23:19.000Z | import tvm
import numpy as np
from tvm import relay
def to_int_array(arr, param_values=None):
if param_values is None:
param_values = {}
return [tvm.ir_pass.Simplify(tvm.ir_pass.Substitute(s, param_values)).value
for s in arr]
def tvm2numpy(something):
if isinstance(something, (tvm.ndarray.NDArray, relay.backend.interpreter.TensorValue)):
return something.asnumpy()
elif isinstance(something, list):
return [tvm2numpy(s) for s in something]
elif isinstance(something, (tuple, relay.backend.interpreter.TupleValue)):
return tuple(tvm2numpy(s) for s in something)
return something
def check_relay_grad(expr, in_range=(-10,10), acceptable_fail_fraction=None):
expr = relay.frontend.common.infer_type(expr)
if len(expr.checked_type.shape) != 0:
expr = relay.op.sum(expr)
input_vars = relay.analysis.free_vars(expr)
func = relay.Function(input_vars, expr)
func = relay.frontend.common.infer_type(func)
gfunc = relay.transform.gradient(func)
gfunc = relay.frontend.common.infer_type(gfunc)
executor = relay.create_executor()
tvm_func = executor.evaluate(func)
tvm_gfunc = executor.evaluate(gfunc)
np_func = lambda *a: tvm2numpy(tvm_func(*a))
np_gfunc = lambda *a: tvm2numpy(tvm_gfunc(*a))
input_vals = [np.random.uniform(in_range[0], in_range[1],
size=to_int_array(a.type_annotation.shape))
.astype(a.type_annotation.dtype)
for a in input_vars]
tvm.testing.check_numerical_grads(np_func, input_vals, np_gfunc(*input_vals)[1],
acceptable_fail_fraction=acceptable_fail_fraction)
def test_autogenerated_primal_gradients():
relay._base.AutogeneratePrimalGradientForAll(100)
x = relay.var("x", shape=(5,), dtype='float64')
y = relay.var("y", shape=(5,), dtype='float64')
check_relay_grad(x*x)
check_relay_grad(x*y)
check_relay_grad(x*y + x + y)
k = relay.var("k", shape=())
x = relay.var("x", shape=(5,))
y = relay.var("y", shape=(5,))
ix = relay.var("ix", shape=(5,), dtype='int32')
iy = relay.var("iy", shape=(5,), dtype='int32')
ind = relay.var("ind", shape=(10,), dtype='int32')
x1 = relay.var("x1", shape=(5,))
y1 = relay.var("y1", shape=(5,))
X = relay.var("X", shape=(5, 7))
Y = relay.var("Y", shape=(5, 10))
Y1 = relay.var("Y1", shape=(1, 2, 5, 5))
Y2 = relay.var("Y2", shape=(3, 2, 5, 5))
W = relay.var("W", shape=(7, 10))
A = relay.var("A", shape=(2, 5, 7, 7))
w = relay.var("w", shape=(4, 5, 3, 3))
w1 = relay.var("w1", shape=(5, 4, 3, 3))
check_relay_grad(x*x)
check_relay_grad(x*y)
check_relay_grad(x*y + x + y)
check_relay_grad(relay.op.log(x), in_range=(0.1, 10))
check_relay_grad(relay.op.sqrt(x), in_range=(0.1, 10))
check_relay_grad(relay.op.exp(x))
check_relay_grad(relay.op.sigmoid(x))
check_relay_grad(relay.op.add(x, y))
check_relay_grad(relay.op.subtract(x, y))
check_relay_grad(relay.op.multiply(x, y))
check_relay_grad(relay.op.divide(x, y))
#check_relay_grad(relay.op.mod(x, y))
check_relay_grad(relay.op.tanh(x))
#check_relay_grad(relay.op.concatenate([x, y], 0))
#check_relay_grad(relay.op.concatenate([X, Y], 1))
check_relay_grad(relay.op.expand_dims(X, 1, 1))
check_relay_grad(relay.op.expand_dims(X, 2, 3))
check_relay_grad(relay.nn.softmax(x))
check_relay_grad(relay.nn.log_softmax(X))
check_relay_grad(relay.nn.relu(x))
#check_relay_grad(relay.nn.dropout(x))
#check_relay_grad(relay.nn.batch_norm(A, x, y, x1, y1)[0])
check_relay_grad(relay.nn.bias_add(X, x, 0))
check_relay_grad(relay.nn.conv2d(A, w))
check_relay_grad(relay.nn.conv2d(A, w, strides=(2, 1)))
check_relay_grad(relay.nn.conv2d(A, w, padding=(1, 0)))
check_relay_grad(relay.nn.conv2d(A, w, dilation=(1, 2)))
check_relay_grad(relay.nn.conv2d_transpose(A, w1))
check_relay_grad(relay.nn.conv2d_transpose(A, w1, strides=(2, 1)))
check_relay_grad(relay.nn.conv2d_transpose(A, w1, padding=(1, 0)))
#check_relay_grad(relay.nn.conv2d_transpose(A, w1, dilation=(1, 2)))
check_relay_grad(relay.nn.dense(X, W))
check_relay_grad(relay.nn.max_pool2d(A))
check_relay_grad(relay.nn.max_pool2d(A, pool_size=(2, 2)))
check_relay_grad(relay.nn.max_pool2d(A, pool_size=(2, 2), strides=(2, 1)))
check_relay_grad(relay.nn.max_pool2d(A, pool_size=(3, 3), strides=(3, 2), padding=(1, 1)))
check_relay_grad(relay.nn.avg_pool2d(A))
check_relay_grad(relay.nn.avg_pool2d(A, pool_size=(2, 2)))
check_relay_grad(relay.nn.avg_pool2d(A, pool_size=(2, 2), strides=(2, 1)))
check_relay_grad(relay.nn.avg_pool2d(A, pool_size=(3, 3), strides=(3, 2), padding=(1, 1)))
check_relay_grad(relay.nn.global_max_pool2d(A))
check_relay_grad(relay.nn.global_avg_pool2d(A))
check_relay_grad(relay.nn.upsampling(A, scale=2))
check_relay_grad(relay.nn.batch_flatten(A))
check_relay_grad(relay.nn.pad(A, ((0, 0), (0, 1), (1, 2), (2, 3))))
check_relay_grad(relay.nn.lrn(A))
check_relay_grad(relay.nn.l2_normalize(A, 0.01, axis=[1]))
#check_relay_grad(relay.nn.contrib_conv2d_winograd_without_weight_transform(...))
check_relay_grad(relay.nn.contrib_conv2d_winograd_weight_transform(w, 4))
check_relay_grad(relay.nn.leaky_relu(x, 0.1))
check_relay_grad(relay.nn.prelu(A, x))
check_relay_grad(relay.reshape(Y, (2, 5, 5)))
check_relay_grad(relay.reshape_like(Y, Y1))
check_relay_grad(relay.copy(x))
check_relay_grad(relay.transpose(Y))
check_relay_grad(relay.squeeze(Y1))
check_relay_grad(relay.floor(x), acceptable_fail_fraction=0.2)
check_relay_grad(relay.ceil(x), acceptable_fail_fraction=0.2)
check_relay_grad(relay.trunc(x), acceptable_fail_fraction=0.2)
#check_relay_grad(relay.clip(x, -2, 2))
check_relay_grad(relay.round(x), acceptable_fail_fraction=0.2)
check_relay_grad(relay.abs(x))
check_relay_grad(relay.negative(x))
#check_relay_grad(relay.take(x, ind), in_range=(0, 4))
check_relay_grad(relay.zeros((5, 6), 'float32'))
check_relay_grad(relay.zeros_like(x))
check_relay_grad(relay.ones((5, 6), 'float32'))
check_relay_grad(relay.ones_like(x))
check_relay_grad(relay.full(k, (5, 6), 'float32'))
check_relay_grad(relay.full_like(x, k))
#check_relay_grad(relay.cast(x, 'float64'))
#check_relay_grad(relay.split(x, (1, 3)))
#check_relay_grad(relay.right_shift(ix, iy))
#check_relay_grad(relay.left_shift(ix, iy))
#check_relay_grad(relay.equal(ix, iy))
#check_relay_grad(relay.not_equal(ix, iy))
#check_relay_grad(relay.greater(x, y))
#check_relay_grad(relay.greater_equal(x, y))
#check_relay_grad(relay.less(x, y))
#check_relay_grad(relay.less_equal(x, y))
check_relay_grad(relay.maximum(x, y))
check_relay_grad(relay.minimum(x, y))
check_relay_grad(relay.power(relay.abs(x), y))
#check_relay_grad(relay.where(ix, x, y))
#check_relay_grad(relay.where(relay.greater(x, y), x, y))
#check_relay_grad(relay.argmax(x))
#check_relay_grad(relay.argmin(X, axis=1))
check_relay_grad(relay.sum(x))
check_relay_grad(relay.max(x))
check_relay_grad(relay.min(x))
check_relay_grad(relay.mean(x))
check_relay_grad(relay.prod(x))
check_relay_grad(relay.strided_slice(A, (0, 4, 2, 0), (1, 1, 5, 6), (1, -1, 2, 3)))
check_relay_grad(relay.broadcast_to(Y1, (3, 2, 5, 5)))
check_relay_grad(relay.image.resize(A, (12, 10), method='BILINEAR'))
check_relay_grad(relay.image.resize(A, (12, 10), method='BILINEAR', align_corners=True))
#check_relay_grad(relay.image.resize(A, (12, 10), method='NEAREST_NEIGHBOR'))
#check_relay_grad(relay.vision.multibox_prior(A))
#check_relay_grad(relay.vision.multibox_transform_loc(...))
#check_relay_grad(relay.vision.nms(...))
check_relay_grad(relay.broadcast_to_like(Y1, Y2))
check_relay_grad(relay.collapse_sum_like(X, x))
t1 = relay.var("t1", shape=(3, 4, 5))
t2 = relay.var("t2", shape=(1, 2, 3))
check_relay_grad(relay.slice_like(t1, t2))
check_relay_grad(relay.layout_transform(w1, 'NCHW', 'NHCW2c'))
#check_relay_grad(relay.device_copy(...))
#check_relay_grad(relay.annotation.on_device(...))
if __name__ == "__main__":
test_autogenerated_primal_gradients()
| 43.8125 | 94 | 0.681526 | 1,372 | 8,412 | 3.922012 | 0.157434 | 0.204423 | 0.286192 | 0.363687 | 0.621632 | 0.518863 | 0.400483 | 0.285449 | 0.218733 | 0.152946 | 0 | 0.034836 | 0.153709 | 8,412 | 191 | 95 | 44.041885 | 0.721028 | 0.159772 | 0 | 0.042857 | 0 | 0 | 0.016338 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0.028571 | false | 0.007143 | 0.021429 | 0 | 0.085714 | 0 | 0 | 0 | 0 | null | 1 | 1 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 3 |
2358514fa403e0d08ff8447b0371eb5e1b0d7496 | 17,621 | py | Python | src/javaproperties_cli/__main__.py | jwodder/javaproperties-cli | e1bbe04bbb961bf0832a591bdb8edc6f240cc950 | [
"MIT"
] | 4 | 2017-04-27T02:11:05.000Z | 2021-12-14T14:53:30.000Z | src/javaproperties_cli/__main__.py | jwodder/javaproperties-cli | e1bbe04bbb961bf0832a591bdb8edc6f240cc950 | [
"MIT"
] | null | null | null | src/javaproperties_cli/__main__.py | jwodder/javaproperties-cli | e1bbe04bbb961bf0832a591bdb8edc6f240cc950 | [
"MIT"
] | 2 | 2017-06-11T02:13:53.000Z | 2019-02-07T22:15:54.000Z | """
:program:`javaproperties`
-------------------------
NAME
^^^^
:program:`javaproperties` — Basic manipulation of Java ``.properties`` files
SYNOPSIS
^^^^^^^^
.. code-block:: shell
javaproperties get [<OPTIONS>] <file> <key> ...
javaproperties select [<OPTIONS>] <file> <key> ...
javaproperties set [<OPTIONS>] <file> <key> <value>
javaproperties delete [<OPTIONS>] <file> <key> ...
javaproperties format [<OPTIONS>] [<file>]
:command:`get`
^^^^^^^^^^^^^^
.. code-block:: shell
javaproperties get [<OPTIONS>] <file> <key> ...
Print out the values of the given keys in the given ``.properties`` file. Each
value is printed out on a separate line with escape sequences interpolated.
If you want the output to also be in ``.properties`` format, see :ref:`select`.
Options
'''''''
.. program:: javaproperties get
.. option:: -d <value>, --default-value <value>
Default value for undefined keys. If this option is not specified, keys
requested on the command line that are not defined in either the main
``.properties`` file or the :option:`--defaults` file will (unless the
:option:`--quiet` option is given) cause a warning to be printed to stderr
and the command to exit with a failure status.
.. option:: -D <file>, --defaults <file>
``.properties`` file of default values. If this option is specified, keys
requested on the command line that are not defined in the main
``.properties`` file will be looked up in this file.
.. option:: -e, --escaped
Parse the keys and default value specified on the command line for
``.properties``-style escape sequences (specifically, those supported by
`javaproperties.unescape`)
.. option:: -E <encoding>, --encoding <encoding>
Specifies the encoding of the input file(s); default value: ``iso-8859-1``
(a.k.a. Latin-1). Output always uses the locale's encoding.
.. option:: -q, --quiet
.. versionadded:: 0.7.0
Do not warn about or fail due to missing keys
.. _select:
:command:`select`
^^^^^^^^^^^^^^^^^
.. code-block:: shell
javaproperties select [<OPTIONS>] <file> <key> ...
Print out the key-value entries in the given ``.properties`` file for the given
keys. The output is in ``.properties`` format, reformatted as though by
:ref:`format`.
Options
'''''''
.. program:: javaproperties select
.. option:: -A, --ascii
.. versionadded:: 0.6.0
Escape all non-ASCII characters in the output with ``\\uXXXX`` escape
sequences. This overrides :option:`--unicode`. This is the default
behavior.
.. option:: -d <value>, --default-value <value>
Default value for undefined keys. If this option is not specified, keys
requested on the command line that are not defined in either the main
``.properties`` file or the :option:`--defaults` file will (unless the
:option:`--quiet` option is given) cause a warning to be printed to stderr
and the command to exit with a failure status.
.. option:: -D <file>, --defaults <file>
``.properties`` file of default values. If this option is specified, keys
requested on the command line that are not defined in the main
``.properties`` file will be looked up in this file.
.. option:: -e, --escaped
Parse the keys and default value specified on the command line for
``.properties``-style escape sequences (specifically, those supported by
`javaproperties.unescape`)
.. option:: -E <encoding>, --encoding <encoding>
Specifies the encoding of the input and output files; default value:
``iso-8859-1`` (a.k.a. Latin-1)
.. option:: -o <file>, --outfile <file>
Write output to this file instead of standard output
.. option:: -s <sep>, --separator <sep>
Use ``<sep>`` as the key-value separator in the output; default value:
``=``
.. option:: -q, --quiet
.. versionadded:: 0.7.0
Do not warn about or fail due to missing keys
.. option:: -U, --unicode
.. versionadded:: 0.6.0
Output non-ASCII characters literally, except for characters that are not
supported by the output encoding, which are escaped with ``\\uXXXX`` escape
sequences. This overrides :option:`--ascii`.
:command:`set`
^^^^^^^^^^^^^^
.. code-block:: shell
javaproperties set [<OPTIONS>] <file> <key> <value>
Set the value of ``<key>`` in the ``.properties`` file ``<file>`` to
``<value>`` and output the results. The other entries in the file (including
comments, possibly not including the timestamp; see below) will be left as-is.
Options
'''''''
.. program:: javaproperties set
.. option:: -A, --ascii
.. versionadded:: 0.6.0
Escape all non-ASCII characters in the new key & value with ``\\uXXXX``
escape sequences on output. This overrides :option:`--unicode`. This is
the default behavior.
.. option:: -e, --escaped
Parse ``<key>`` and ``<value>`` for ``.properties``-style escape sequences
(specifically, those supported by `javaproperties.unescape`)
.. option:: -E <encoding>, --encoding <encoding>
Specifies the encoding of the input and output files; default value:
``iso-8859-1`` (a.k.a. Latin-1)
.. option:: -o <file>, --outfile <file>
Write output to this file instead of standard output
.. option:: -s <sep>, --separator <sep>
Separate ``<key>`` and ``<value>`` in the output with ``<sep>``; default
value: ``=``
.. option:: -T, --preserve-timestamp
Do not modify the timestamp in the ``.properties`` file. By default, if a
timestamp is found, it is updated to the current time, even if the rest of
the file is unchanged.
.. option:: -U, --unicode
.. versionadded:: 0.6.0
Output non-ASCII characters in the new key & value literally, except for
characters that are not supported by the output encoding, which are escaped
with ``\\uXXXX`` escape sequences. This overrides :option:`--ascii`.
:command:`delete`
^^^^^^^^^^^^^^^^^
.. code-block:: shell
javaproperties delete [<OPTIONS>] <file> <key> ...
Remove all entries for the given keys from the given ``.properties`` file and
output the results. The other entries in the file (including comments,
possibly not including the timestamp; see below) will be left as-is.
Options
'''''''
.. program:: javaproperties delete
.. option:: -e, --escaped
Parse the keys specified on the command line for ``.properties``-style
escape sequences (specifically, those supported by
`javaproperties.unescape`)
.. option:: -E <encoding>, --encoding <encoding>
Specifies the encoding of the input and output files; default value:
``iso-8859-1`` (a.k.a. Latin-1)
.. option:: -o <file>, --outfile <file>
Write output to this file instead of standard output
.. option:: -T, --preserve-timestamp
Do not modify the timestamp in the ``.properties`` file. By default, if a
timestamp is found, it is updated to the current time, even if the rest of
the file is unchanged.
.. _format:
:command:`format`
^^^^^^^^^^^^^^^^^
.. code-block:: shell
javaproperties format [<OPTIONS>] [<file>]
Normalize the formatting of the given ``.properties`` file (or standard input
if no file is given) and output the results. All comments, excess whitespace,
invalid escapes, and duplicate keys are removed, and the entries are sorted
lexicographically.
Options
'''''''
.. program:: javaproperties format
.. option:: -A, --ascii
.. versionadded:: 0.6.0
Escape all non-ASCII characters in the output with ``\\uXXXX`` escape
sequences. This overrides :option:`--unicode`. This is the default
behavior.
.. option:: -E <encoding>, --encoding <encoding>
Specifies the encoding of the input and output files; default value:
``iso-8859-1`` (a.k.a. Latin-1)
.. option:: -o <file>, --outfile <file>
Write output to this file instead of standard output
.. option:: -s <sep>, --separator <sep>
Use ``<sep>`` as the key-value separator in the output; default value:
``=``
.. option:: -U, --unicode
.. versionadded:: 0.6.0
Output non-ASCII characters literally, except for characters that are not
supported by the output encoding, which are escaped with ``\\uXXXX`` escape
sequences. This overrides :option:`--ascii`.
"""
import click
from javaproperties import (
KeyValue,
dump,
java_timestamp,
join_key_value,
load,
parse,
to_comment,
unescape,
)
from .util import command, encoding_option, infile_type, outfile_type
@command(group=True)
def javaproperties():
"""Basic manipulation of Java .properties files"""
pass
@javaproperties.command()
@click.option(
"-d", "--default-value", metavar="VALUE", help="Default value for undefined keys"
)
@click.option(
"-D",
"--defaults",
metavar="FILE",
type=infile_type,
help=".properties file of default values",
)
@click.option(
"-e", "--escaped", is_flag=True, help="Parse command-line keys & values for escapes"
)
@encoding_option
@click.option("-q", "--quiet", is_flag=True, help="Don't warn on missing keys")
@click.argument("file", type=infile_type)
@click.argument("key", nargs=-1, required=True)
@click.pass_context
def get(ctx, default_value, defaults, escaped, file, key, encoding, quiet):
"""Query values from a Java .properties file"""
ok = True
for k, v in getselect(file, key, defaults, default_value, encoding, escaped):
if v is not None:
click.echo(v)
elif not quiet:
click.echo(f"{ctx.command_path}: {k}: key not found", err=True)
ok = False
ctx.exit(0 if ok else 1)
@javaproperties.command()
@click.option(
"-A/-U",
"--ascii/--unicode",
"ensure_ascii",
default=True,
help="Whether to escape non-ASCII characters or output raw",
)
@click.option(
"-d", "--default-value", metavar="VALUE", help="Default value for undefined keys"
)
@click.option(
"-D",
"--defaults",
metavar="FILE",
type=infile_type,
help=".properties file of default values",
)
@click.option(
"-e", "--escaped", is_flag=True, help="Parse command-line keys & values for escapes"
)
@encoding_option
@click.option(
"-o", "--outfile", type=outfile_type, default="-", help="Write output to this file"
)
@click.option("-q", "--quiet", is_flag=True, help="Don't warn on missing keys")
@click.option(
"-s",
"--separator",
default="=",
show_default=True,
help="Key-value separator to use in output",
)
@click.argument("file", type=infile_type)
@click.argument("key", nargs=-1, required=True)
@click.pass_context
def select(
ctx,
default_value,
defaults,
escaped,
separator,
file,
key,
encoding,
outfile,
ensure_ascii,
quiet,
):
"""Extract key-value pairs from a Java .properties file"""
ok = True
with click.open_file(
outfile,
"w",
encoding=encoding,
errors="javapropertiesreplace",
) as fpout:
print(to_comment(java_timestamp()), file=fpout)
for k, v in getselect(file, key, defaults, default_value, encoding, escaped):
if v is not None:
print(
join_key_value(
k, v, separator=separator, ensure_ascii=ensure_ascii
),
file=fpout,
)
elif not quiet:
click.echo(f"{ctx.command_path}: {k}: key not found", err=True)
ok = False
ctx.exit(0 if ok else 1)
@javaproperties.command("set")
@click.option(
"-A/-U",
"--ascii/--unicode",
"ensure_ascii",
default=True,
help="Whether to escape non-ASCII characters or output raw",
)
@click.option(
"-e", "--escaped", is_flag=True, help="Parse command-line keys & values for escapes"
)
@encoding_option
@click.option(
"-s",
"--separator",
default="=",
show_default=True,
help="Key-value separator to use in output",
)
@click.option(
"-o", "--outfile", type=outfile_type, default="-", help="Write output to this file"
)
@click.option(
"-T",
"--preserve-timestamp",
is_flag=True,
help="Keep the timestamp from the input file",
)
@click.argument("file", type=infile_type)
@click.argument("key")
@click.argument("value")
def setprop(
escaped,
separator,
outfile,
preserve_timestamp,
file,
key,
value,
encoding,
ensure_ascii,
):
"""Set values in a Java .properties file"""
if escaped:
key = unescape(key)
value = unescape(value)
with click.open_file(file, encoding=encoding) as fpin:
with click.open_file(
outfile,
"w",
encoding=encoding,
errors="javapropertiesreplace",
) as fpout:
setproperties(
fpin, fpout, {key: value}, preserve_timestamp, separator, ensure_ascii
)
@javaproperties.command()
@click.option(
"-e", "--escaped", is_flag=True, help="Parse command-line keys & values for escapes"
)
@encoding_option
@click.option(
"-o", "--outfile", type=outfile_type, default="-", help="Write output to this file"
)
@click.option(
"-T",
"--preserve-timestamp",
is_flag=True,
help="Keep the timestamp from the input file",
)
@click.argument("file", type=infile_type)
@click.argument("key", nargs=-1, required=True)
def delete(escaped, outfile, preserve_timestamp, file, key, encoding):
"""Remove values from a Java .properties file"""
if escaped:
key = list(map(unescape, key))
with click.open_file(file, encoding=encoding) as fpin:
with click.open_file(
outfile,
"w",
encoding=encoding,
errors="javapropertiesreplace",
) as fpout:
setproperties(fpin, fpout, dict.fromkeys(key), preserve_timestamp)
@javaproperties.command()
@click.option(
"-A/-U",
"--ascii/--unicode",
"ensure_ascii",
default=True,
help="Whether to escape non-ASCII characters or output raw",
)
@encoding_option
@click.option(
"-o", "--outfile", type=outfile_type, default="-", help="Write output to this file"
)
@click.option(
"-s",
"--separator",
default="=",
show_default=True,
help="Key-value separator to use in output",
)
@click.argument("file", type=infile_type, default="-")
def format(outfile, separator, file, encoding, ensure_ascii):
"""Format/"canonicalize" a Java .properties file"""
with click.open_file(file, encoding=encoding) as fpin:
with click.open_file(
outfile,
"w",
encoding=encoding,
errors="javapropertiesreplace",
) as fpout:
dump(
load(fpin),
fpout,
sort_keys=True,
separator=separator,
ensure_ascii=ensure_ascii,
)
def getproperties(fp, keys):
keys = set(keys)
def getprops(seq):
props = {}
for k, v in seq:
if k in keys:
props[k] = v
return props
return load(fp, object_pairs_hook=getprops)
def getselect(file, key, defaults, default_value, encoding, escaped):
if escaped:
key = list(map(unescape, key))
if default_value is not None:
default_value = unescape(default_value)
with click.open_file(file, encoding=encoding) as fp:
props = getproperties(fp, key)
if defaults is not None:
with click.open_file(defaults, encoding=encoding) as fp:
defaults = getproperties(fp, key)
else:
defaults = {}
for k in key:
v = default_value
if k in props:
v = props[k]
elif k in defaults:
v = defaults[k]
yield (k, v)
def setproperties(
fpin, fpout, newprops, preserve_timestamp=False, separator="=", ensure_ascii=True
):
in_header = True
prev = None
for kv in parse(fpin):
if in_header:
if not isinstance(kv, KeyValue):
if prev is not None:
print(prev.source, end="", file=fpout)
prev = kv
continue
else:
if prev is not None:
if preserve_timestamp:
print(prev.source, end="", file=fpout)
else:
if not prev.is_timestamp():
print(prev.source, end="", file=fpout)
print(to_comment(java_timestamp()), file=fpout)
elif not preserve_timestamp:
print(to_comment(java_timestamp()), file=fpout)
in_header = False
if kv.key in newprops:
if newprops[kv.key] is not None:
print(
join_key_value(
kv.key,
newprops[kv.key],
separator=separator,
ensure_ascii=ensure_ascii,
),
file=fpout,
)
newprops[kv.key] = None
else:
# Use `source_stripped` in case the last line of the file ends with
# a trailing line continuation:
print(kv.source_stripped, file=fpout)
for key, value in newprops.items():
if value is not None:
print(
join_key_value(
key, value, separator=separator, ensure_ascii=ensure_ascii
),
file=fpout,
)
if __name__ == "__main__":
javaproperties() # pragma: no cover
| 28.103668 | 88 | 0.617899 | 2,196 | 17,621 | 4.90847 | 0.113843 | 0.030058 | 0.015029 | 0.014194 | 0.762779 | 0.732907 | 0.705724 | 0.674367 | 0.642731 | 0.633268 | 0 | 0.004612 | 0.249418 | 17,621 | 626 | 89 | 28.148562 | 0.810298 | 0.489643 | 0 | 0.621711 | 0 | 0 | 0.155136 | 0.009389 | 0 | 0 | 0 | 0 | 0 | 1 | 0.032895 | false | 0.009868 | 0.009868 | 0 | 0.049342 | 0.032895 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 1 | 1 | 0 | 0 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 3 |
88cc9f193678e77b2beeca56f0e3fd1d39efafa6 | 111 | py | Python | 24/00/get_matching_blocks.py | pylangstudy/201708 | 126b1af96a1d1f57522d5a1d435b58597bea2e57 | [
"CC0-1.0"
] | null | null | null | 24/00/get_matching_blocks.py | pylangstudy/201708 | 126b1af96a1d1f57522d5a1d435b58597bea2e57 | [
"CC0-1.0"
] | 39 | 2017-07-31T22:54:01.000Z | 2017-08-31T00:19:03.000Z | 24/00/get_matching_blocks.py | pylangstudy/201708 | 126b1af96a1d1f57522d5a1d435b58597bea2e57 | [
"CC0-1.0"
] | null | null | null | #!python3.6
import difflib
s = difflib.SequenceMatcher(None, "abxcd", "abcd")
print(s.get_matching_blocks())
| 15.857143 | 50 | 0.738739 | 15 | 111 | 5.333333 | 0.866667 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0.02 | 0.099099 | 111 | 6 | 51 | 18.5 | 0.78 | 0.09009 | 0 | 0 | 0 | 0 | 0.091837 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | false | 0 | 0.333333 | 0 | 0.333333 | 0.333333 | 1 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 0 | 0 | 3 |
88da99a9de7207f49933d54f91d238581b41b718 | 516 | py | Python | conductance_congestion_approx.py | weinstein/FastMaxFlow | 482b2734f1f9952528b9856d8111dd2874861fef | [
"MIT"
] | null | null | null | conductance_congestion_approx.py | weinstein/FastMaxFlow | 482b2734f1f9952528b9856d8111dd2874861fef | [
"MIT"
] | null | null | null | conductance_congestion_approx.py | weinstein/FastMaxFlow | 482b2734f1f9952528b9856d8111dd2874861fef | [
"MIT"
] | 1 | 2020-12-26T08:59:54.000Z | 2020-12-26T08:59:54.000Z | from __future__ import division
import numpy as np
from congestion_approx import CongestionApprox
class ConductanceCongestionApprox(CongestionApprox):
def __init__(s, g):
s.vertex_degrees_inv = [
1.0 / g.degree(v) if g.degree(v) > 0 else 0 for v in g.nodes()]
def compute_dot(s, x):
return np.multiply(x, s.vertex_degrees_inv)
def compute_transpose_dot(s, x):
return np.multiply(x, s.vertex_degrees_inv)
def alpha(s):
# TODO: this probably isn't quite right.
return 1.0
| 22.434783 | 71 | 0.707364 | 81 | 516 | 4.283951 | 0.518519 | 0.060519 | 0.121037 | 0.146974 | 0.242075 | 0.242075 | 0.242075 | 0.242075 | 0.242075 | 0.242075 | 0 | 0.014493 | 0.197674 | 516 | 22 | 72 | 23.454545 | 0.823672 | 0.073643 | 0 | 0.153846 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0.045455 | 0 | 1 | 0.307692 | false | 0 | 0.230769 | 0.230769 | 0.846154 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | null | 0 | 0 | 1 | 0 | 0 | 1 | 0 | 0 | 0 | 1 | 0 | 0 | 0 | 3 |
000468f83ec7c5d828bce0f8cf192095eaa2c7a0 | 172 | py | Python | homepage/urls.py | lejbron/arkenstone | d5341c27ba81eaf116e5ee5983b4fa422437d294 | [
"MIT"
] | null | null | null | homepage/urls.py | lejbron/arkenstone | d5341c27ba81eaf116e5ee5983b4fa422437d294 | [
"MIT"
] | 4 | 2021-03-17T19:46:35.000Z | 2021-04-09T11:37:53.000Z | homepage/urls.py | lejbron/arkenstone | d5341c27ba81eaf116e5ee5983b4fa422437d294 | [
"MIT"
] | 1 | 2021-04-11T07:50:56.000Z | 2021-04-11T07:50:56.000Z | from django.urls import path
from . import views
urlpatterns = [
path('', views.index, name='index'),
path('users/', views.users_list_view, name='users-list'),
]
| 19.111111 | 61 | 0.668605 | 23 | 172 | 4.913043 | 0.521739 | 0.159292 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0.162791 | 172 | 8 | 62 | 21.5 | 0.784722 | 0 | 0 | 0 | 0 | 0 | 0.122093 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | false | 0 | 0.333333 | 0 | 0.333333 | 0 | 1 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 0 | 0 | 3 |
00073ebb06fd497dba69c147efdb20087341896a | 2,574 | py | Python | tools/gen_Jenkinsfile.py | das7pad/reparser | 9f4a40aa3deae8aa151aad1ffa0dc7b35f3181a2 | [
"MIT"
] | null | null | null | tools/gen_Jenkinsfile.py | das7pad/reparser | 9f4a40aa3deae8aa151aad1ffa0dc7b35f3181a2 | [
"MIT"
] | null | null | null | tools/gen_Jenkinsfile.py | das7pad/reparser | 9f4a40aa3deae8aa151aad1ffa0dc7b35f3181a2 | [
"MIT"
] | null | null | null | """Generate the declarative Jenkins pipeline"""
__author__ = 'Jakob Ackermann <das7pad@outlook.com>'
import pathlib
VERSIONS = [
'3.5.3',
'3.5.4',
'3.5.5',
'3.5.6',
'3.6.0',
'3.6.1',
'3.6.2',
'3.6.3',
'3.6.4',
'3.6.5',
'3.6.6',
'3.6.7',
'3.7.0',
'3.7.1',
]
PIPELINE = """
//
// This file is autogenerated.
// To update, run:
//
// make Jenkinsfile
//
pipeline {
agent none
environment {
GIT_COMMITTER_NAME = 'Joe Doe'
GIT_COMMITTER_EMAIL = 'joe.doe@example.com'
HOME = '/tmp/'
}
options {
timestamps()
skipDefaultCheckout(true)
}
stages {
stage('Parallel Stage') {
parallel {
%(stages)s
}
}
}
}
"""
STAGE = """
stage('Python:%(version)s') {
agent {
docker {
image 'python:%(version)s'
}
}
stages {
stage('Python:%(version)s Info') {
steps {
sh 'curl -sS httpbin.org/ip'
sh 'pwd'
}
}
stage('Python:%(version)s Checkout') {
steps {
checkout scm
sh 'make clean'
}
}
stage('Python:%(version)s Install') {
steps {
sh 'make venv-dev'
}
}
stage('Python:%(version)s Test') {
steps {
sh 'make lint'
sh 'make test'
}
}
stage('Python:%(version)s Cleanup') {
steps {
sh 'make clean'
}
}
}
}
"""
def main():
jenkinsfile = pathlib.Path(__file__).parent.parent / 'Jenkinsfile'
stages = '\n'.join(
STAGE.strip('\n') % dict(version=version)
for version in VERSIONS
)
pipeline = PIPELINE.lstrip('\n') % dict(stages=stages)
jenkinsfile.write_text(pipeline)
if __name__ == '__main__':
main()
| 23.189189 | 70 | 0.342657 | 200 | 2,574 | 4.305 | 0.435 | 0.018583 | 0.113821 | 0.132404 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0.036318 | 0.540016 | 2,574 | 110 | 71 | 23.4 | 0.690878 | 0.015929 | 0 | 0.148936 | 1 | 0 | 0.79818 | 0.086664 | 0 | 0 | 0 | 0 | 0 | 1 | 0.010638 | false | 0 | 0.010638 | 0 | 0.021277 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 1 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 3 |
cc492be3d9ca4a8afcf77b15c97f14e0bc81f6ce | 82 | py | Python | pycaprio/__init__.py | nipunsadvilkar/pycaprio | 1fd425e9dbbe1311bae513c896873040fa330379 | [
"MIT"
] | null | null | null | pycaprio/__init__.py | nipunsadvilkar/pycaprio | 1fd425e9dbbe1311bae513c896873040fa330379 | [
"MIT"
] | null | null | null | pycaprio/__init__.py | nipunsadvilkar/pycaprio | 1fd425e9dbbe1311bae513c896873040fa330379 | [
"MIT"
] | null | null | null | # flake8: noqa
from pycaprio.core.pycaprio import Pycaprio
__version__ = '0.0.4'
| 16.4 | 43 | 0.756098 | 12 | 82 | 4.833333 | 0.75 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0.056338 | 0.134146 | 82 | 4 | 44 | 20.5 | 0.760563 | 0.146341 | 0 | 0 | 0 | 0 | 0.073529 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | false | 0 | 0.5 | 0 | 0.5 | 0 | 1 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 0 | 0 | 3 |
cc4d7a79f2551e08af9f51409f6d24c6b782d61f | 651 | py | Python | 01 - 09/99_bottles_of_beer.py | MayaScarlet/rosetta-code-tasks | 83b0bfbc8c4de556af1ef9899eaea69d2bf8cc32 | [
"MIT"
] | null | null | null | 01 - 09/99_bottles_of_beer.py | MayaScarlet/rosetta-code-tasks | 83b0bfbc8c4de556af1ef9899eaea69d2bf8cc32 | [
"MIT"
] | null | null | null | 01 - 09/99_bottles_of_beer.py | MayaScarlet/rosetta-code-tasks | 83b0bfbc8c4de556af1ef9899eaea69d2bf8cc32 | [
"MIT"
] | null | null | null | """
Display the complete lyrics for the song: 99 Bottles of Beer on the Wall.
The lyrics follow this form:
99 bottles of beer on the wall
99 bottles of beer
Take one down, pass it around
98 bottles of beer on the wall
98 bottles of beer on the wall
98 bottles of beer
Take one down, pass it around
"""
def solution():
"""Using while loop"""
max = 99
while max > 1:
print(f"{max} bottles of beer on the wall")
print(f"{max} bottles of beer")
print(f"Take one down, pass it around")
max -= 1
print(f"{max} bottles of beer \n")
def main():
solution()
if __name__ == '__main__':
main()
| 19.147059 | 73 | 0.635945 | 109 | 651 | 3.724771 | 0.321101 | 0.199507 | 0.288177 | 0.184729 | 0.679803 | 0.679803 | 0.546798 | 0.428571 | 0.300493 | 0.155172 | 0 | 0.033684 | 0.270353 | 651 | 33 | 74 | 19.727273 | 0.821053 | 0.480799 | 0 | 0 | 0 | 0 | 0.354938 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0.166667 | false | 0.083333 | 0 | 0 | 0.166667 | 0.333333 | 0 | 0 | 0 | null | 0 | 1 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 0 | 0 | 0 | 3 |
cc6ac3459a21b631f0ced05a6422a5a09f041a28 | 199 | py | Python | __main__.py | tanvirtin/CIFAR-10-Convolutional-Neural-Network-Classifier | d4629511c26a9dbc7e02dc60d2e9751a070fa6e9 | [
"MIT"
] | null | null | null | __main__.py | tanvirtin/CIFAR-10-Convolutional-Neural-Network-Classifier | d4629511c26a9dbc7e02dc60d2e9751a070fa6e9 | [
"MIT"
] | null | null | null | __main__.py | tanvirtin/CIFAR-10-Convolutional-Neural-Network-Classifier | d4629511c26a9dbc7e02dc60d2e9751a070fa6e9 | [
"MIT"
] | null | null | null | from Model_A import Model_A
from Model_B import Model_B
def main():
model_A = Model_A()
model_A.train()
model_B = Model_B()
model_B.train()
if __name__ == "__main__":
main()
| 13.266667 | 27 | 0.648241 | 32 | 199 | 3.46875 | 0.3125 | 0.27027 | 0.198198 | 0.216216 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0.241206 | 199 | 14 | 28 | 14.214286 | 0.735099 | 0 | 0 | 0 | 0 | 0 | 0.040201 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0.111111 | false | 0 | 0.222222 | 0 | 0.333333 | 0 | 0 | 0 | 0 | null | 1 | 1 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 3 |
cc7ba5acb4140b100d1e87f3c052c88f4d6530a8 | 540 | py | Python | db/TableNoteType.py | eddiedb6/ej | 04e7d79aafadad87bcb99879ead7195a7aee6d0c | [
"MIT"
] | null | null | null | db/TableNoteType.py | eddiedb6/ej | 04e7d79aafadad87bcb99879ead7195a7aee6d0c | [
"MIT"
] | null | null | null | db/TableNoteType.py | eddiedb6/ej | 04e7d79aafadad87bcb99879ead7195a7aee6d0c | [
"MIT"
] | null | null | null | {
PDBConst.Name: "notetype",
PDBConst.Columns: [
{
PDBConst.Name: "ID",
PDBConst.Attributes: ["tinyint", "not null", "primary key"]
},
{
PDBConst.Name: "Type",
PDBConst.Attributes: ["varchar(128)", "not null"]
},
{
PDBConst.Name: "SID",
PDBConst.Attributes: ["varchar(128)", "not null"]
}],
PDBConst.Initials: [
{"Type": "'html'", "ID": "1", "SID": "'sidTableNoteType1'"},
{"Type": "'pdf'", "ID": "2", "SID": "'sidTableNoteType2'"}
]
}
| 25.714286 | 68 | 0.498148 | 47 | 540 | 5.723404 | 0.468085 | 0.178439 | 0.185874 | 0.208178 | 0.319703 | 0.319703 | 0.319703 | 0 | 0 | 0 | 0 | 0.025707 | 0.27963 | 540 | 20 | 69 | 27 | 0.66581 | 0 | 0 | 0.1 | 0 | 0 | 0.281481 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | true | 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 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 3 |
cc8f41d1b7b4abb906a0673dacf46ffb51ebd771 | 218 | py | Python | code/100_extras/100_09_text_generation/main.py | padmalcom/AISpeechAssistant | b7501a23a8f513acb5043f3c7bb06df129bdc2cc | [
"Apache-2.0"
] | 1 | 2021-09-08T09:21:16.000Z | 2021-09-08T09:21:16.000Z | code/100_extras/100_09_text_generation/main.py | padmalcom/AISpeechAssistant | b7501a23a8f513acb5043f3c7bb06df129bdc2cc | [
"Apache-2.0"
] | null | null | null | code/100_extras/100_09_text_generation/main.py | padmalcom/AISpeechAssistant | b7501a23a8f513acb5043f3c7bb06df129bdc2cc | [
"Apache-2.0"
] | 2 | 2022-02-06T09:54:40.000Z | 2022-03-01T07:52:51.000Z | from transformers import pipeline
text2text_generator = pipeline(
"text-generation",
model="dbmdz/german-gpt2",
tokenizer="dbmdz/german-gpt2"
)
print(text2text_generator("Wo steht der Triumfbogen? Er steht in ")) | 31.142857 | 68 | 0.775229 | 27 | 218 | 6.185185 | 0.740741 | 0.215569 | 0.179641 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0.020619 | 0.110092 | 218 | 7 | 68 | 31.142857 | 0.840206 | 0 | 0 | 0 | 0 | 0 | 0.39726 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | false | 0 | 0.142857 | 0 | 0.142857 | 0.142857 | 1 | 0 | 0 | null | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 3 |
cca9c7c0eae4370e01e20d6868402c6091e95c2d | 171 | py | Python | hello.py | SrutiBh/Learn-Python | fa232d7846622db0b6243e0bf77e6166a4bb79d2 | [
"MIT"
] | null | null | null | hello.py | SrutiBh/Learn-Python | fa232d7846622db0b6243e0bf77e6166a4bb79d2 | [
"MIT"
] | null | null | null | hello.py | SrutiBh/Learn-Python | fa232d7846622db0b6243e0bf77e6166a4bb79d2 | [
"MIT"
] | null | null | null | # -*- coding: utf-8 -*-
"""
Created on Mon Nov 20 20:51:09 2017
@author: sruti
"""
#python learning
# This program prints Hello, world!
print('Hello, world!') | 15.545455 | 36 | 0.608187 | 24 | 171 | 4.333333 | 0.875 | 0.192308 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0.097744 | 0.222222 | 171 | 11 | 37 | 15.545455 | 0.684211 | 0.719298 | 0 | 0 | 0 | 0 | 0.448276 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | true | 0 | 0 | 0 | 0 | 1 | 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 | 1 | 0 | 3 |
ccb1c225333df14555b9741bdf0957858b74252e | 688 | py | Python | eth2/beacon/fork_choice/__init__.py | Gauddel/trinity | 0b12943ac36f4090abc22fc965e9e9a4f42c6f35 | [
"MIT"
] | null | null | null | eth2/beacon/fork_choice/__init__.py | Gauddel/trinity | 0b12943ac36f4090abc22fc965e9e9a4f42c6f35 | [
"MIT"
] | null | null | null | eth2/beacon/fork_choice/__init__.py | Gauddel/trinity | 0b12943ac36f4090abc22fc965e9e9a4f42c6f35 | [
"MIT"
] | null | null | null | """
A blockchain has a way to pick a canonical chain from the block tree called a fork choice.
A fork choice works by using a scoring rule to attach a scalar quantity to a particular block
given our local view of the network.
The fork choice provides a "canonical" path through the block tree by recursively selecting the
highest scoring child of a given block until we terminate at the tip of the chain.
This module provides a variety of fork choice rules. Clients can introduce new rules here to
experiment with alternative fork choice methods.
"""
from .higher_slot import ( # noqa: F401
higher_slot_scoring,
)
from .fork_choice_scoring import ForkChoiceScoring # noqa: F401
| 38.222222 | 95 | 0.787791 | 113 | 688 | 4.752212 | 0.539823 | 0.111732 | 0.044693 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0.010638 | 0.180233 | 688 | 17 | 96 | 40.470588 | 0.941489 | 0.824128 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | true | 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 | 1 | 0 | 1 | 0 | 0 | 0 | 0 | 3 |
ccb2a9617a3101b005bca39123f8cd04d67bd6ba | 424 | py | Python | src/softframe/cli/__init__.py | pcastanha/frame | f3392e3660742db6beb3b6e1702d7aee6acedf62 | [
"BSD-2-Clause"
] | null | null | null | src/softframe/cli/__init__.py | pcastanha/frame | f3392e3660742db6beb3b6e1702d7aee6acedf62 | [
"BSD-2-Clause"
] | null | null | null | src/softframe/cli/__init__.py | pcastanha/frame | f3392e3660742db6beb3b6e1702d7aee6acedf62 | [
"BSD-2-Clause"
] | null | null | null | '''from flask import Flask
from flask_restful import Api
from ml_api.api import TaskAPI, TaskListAPI
__version__ = "0.1.0"
# Flask configurations
app = Flask(__name__, static_url_path="")
api = Api(app)
# Endpoint declarations
api.add_resource(TaskListAPI, '/todo/api/v1.0/tasks', endpoint='tasks')
api.add_resource(TaskAPI, '/todo/api/v1.0/tasks/<int:id>', endpoint='task')'''
from .cli import main
__all__ = ['main']
| 23.555556 | 78 | 0.735849 | 63 | 424 | 4.666667 | 0.47619 | 0.061224 | 0.095238 | 0.068027 | 0.102041 | 0 | 0 | 0 | 0 | 0 | 0 | 0.018568 | 0.110849 | 424 | 17 | 79 | 24.941176 | 0.761273 | 0.882075 | 0 | 0 | 0 | 0 | 0.090909 | 0 | 0 | 0 | 0 | 0.117647 | 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 | 1 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 0 | 0 | 3 |
ccc155306cc6eb428465c80756a6717eab64070a | 195 | py | Python | actions/client_history.py | cognifloyd/stackstorm-sensu | 445a2ec33618e7ac199034fa609e760d8377a936 | [
"Apache-2.0"
] | 164 | 2015-01-17T16:08:33.000Z | 2021-08-03T02:34:07.000Z | actions/client_history.py | cognifloyd/stackstorm-sensu | 445a2ec33618e7ac199034fa609e760d8377a936 | [
"Apache-2.0"
] | 442 | 2015-01-01T11:19:01.000Z | 2017-09-06T23:26:17.000Z | actions/client_history.py | cognifloyd/stackstorm-sensu | 445a2ec33618e7ac199034fa609e760d8377a936 | [
"Apache-2.0"
] | 202 | 2015-01-13T00:37:40.000Z | 2020-11-07T11:30:10.000Z | from lib.sensu import SensuAction
__all__ = [
'ClientHistoryAction'
]
class ClientHistoryAction(SensuAction):
def run(self, client):
return self.api.get_client_history(client)
| 17.727273 | 50 | 0.733333 | 21 | 195 | 6.52381 | 0.761905 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0.179487 | 195 | 10 | 51 | 19.5 | 0.85625 | 0 | 0 | 0 | 0 | 0 | 0.097436 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0.142857 | false | 0 | 0.142857 | 0.142857 | 0.571429 | 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 | 0 | 0 | 0 | 1 | 1 | 0 | 0 | 3 |
aea3c1d8b7e862ce163fa3e0ad5a7246d5c99cd9 | 219 | py | Python | disciplines/method/open_repositories.py | aidiss/disciplines | 999844a6305ae1584429d75e0d5260e6f1dcbf4a | [
"MIT"
] | 1 | 2018-02-11T02:09:05.000Z | 2018-02-11T02:09:05.000Z | disciplines/method/open_repositories.py | aidiss/disciplines | 999844a6305ae1584429d75e0d5260e6f1dcbf4a | [
"MIT"
] | null | null | null | disciplines/method/open_repositories.py | aidiss/disciplines | 999844a6305ae1584429d75e0d5260e6f1dcbf4a | [
"MIT"
] | null | null | null | # -*- coding: utf-8 -*-
# open repositories
"""Todo: move src for acquiring data"""
'http://www.opendoar.org/countrylist.php'
better = 'http://oaister.worldcat.org/'
# Should access Terms and Conditions all the time.
| 24.333333 | 50 | 0.69863 | 30 | 219 | 5.1 | 0.933333 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0.005263 | 0.13242 | 219 | 8 | 51 | 27.375 | 0.8 | 0.561644 | 0 | 0 | 0 | 0 | 0.761364 | 0 | 0 | 0 | 0 | 0.125 | 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 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | null | 0 | 0 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 3 |
aea443abf3d3c71b43a2ce85be257723c2cb57e2 | 344 | py | Python | server/tests/pyfiles/db/test_attributes.py | TheDarrenJoseph/AberWebMUD | c8b33e03a0c78e5d0aceaa1ce85a2924c71cdb1c | [
"MIT"
] | 2 | 2018-08-20T18:09:47.000Z | 2019-04-29T06:18:42.000Z | server/tests/pyfiles/db/test_attributes.py | TheDarrenJoseph/AberWebMUD | c8b33e03a0c78e5d0aceaa1ce85a2924c71cdb1c | [
"MIT"
] | 6 | 2019-04-28T20:56:25.000Z | 2022-02-12T04:33:23.000Z | server/tests/pyfiles/db/test_attributes.py | TheDarrenJoseph/AberWebMUD | c8b33e03a0c78e5d0aceaa1ce85a2924c71cdb1c | [
"MIT"
] | null | null | null | import unittest
from pyfiles.db import attributes
from pyfiles.db.attributes import ATTRIBUTE_NAMES
class TestAttributes(unittest.TestCase):
def test_get_json_attribute_score_options(self):
json_options = attributes.Attributes.get_json_attribute_score_options()
self.assertEqual(json_options, {'options': ATTRIBUTE_NAMES}) | 38.222222 | 79 | 0.811047 | 42 | 344 | 6.333333 | 0.452381 | 0.082707 | 0.097744 | 0.157895 | 0.240602 | 0.240602 | 0 | 0 | 0 | 0 | 0 | 0 | 0.119186 | 344 | 9 | 80 | 38.222222 | 0.877888 | 0 | 0 | 0 | 0 | 0 | 0.02029 | 0 | 0 | 0 | 0 | 0 | 0.142857 | 1 | 0.142857 | false | 0 | 0.428571 | 0 | 0.714286 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 1 | 0 | 0 | 3 |
aea74bbe51e0f4285cd4a59101bb63b7a3eccd03 | 266 | py | Python | run.py | wimjan123/AvidProjectSetup | 71a863fa4d416991ce066c29e9b81eba57b28205 | [
"MIT"
] | null | null | null | run.py | wimjan123/AvidProjectSetup | 71a863fa4d416991ce066c29e9b81eba57b28205 | [
"MIT"
] | null | null | null | run.py | wimjan123/AvidProjectSetup | 71a863fa4d416991ce066c29e9b81eba57b28205 | [
"MIT"
] | null | null | null | import wx
app = wx.App()
frmf = wx.Frame(None, title="NLE_KeyConvert")
def avid_button_clicked(event):
avid_button = wx.Button(frmf, label="Avid Media Composer", size=(0.4,3))
avid_button.Bind(wx.EVT_BUTTON, avid_button_clicked)
frmf.Show()
app.MainLoop()
| 14 | 72 | 0.729323 | 43 | 266 | 4.325581 | 0.581395 | 0.215054 | 0.182796 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0.012821 | 0.120301 | 266 | 18 | 73 | 14.777778 | 0.782051 | 0 | 0 | 0 | 0 | 0 | 0.12406 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | null | null | 0 | 0.125 | null | null | 0 | 0 | 0 | 0 | null | 1 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 3 |
aea844f68a57d33dbfb45f9d6d45a81cf9b6a368 | 59 | py | Python | App/hefesto_core/__init__.py | ZikloSolar/Hefesto | b04675d9c0a70bbf4a637780dd098b9c7e93549b | [
"MIT"
] | 1 | 2021-11-29T07:54:28.000Z | 2021-11-29T07:54:28.000Z | App/hefesto_core/__init__.py | ZikloSolar/Hefesto | b04675d9c0a70bbf4a637780dd098b9c7e93549b | [
"MIT"
] | null | null | null | App/hefesto_core/__init__.py | ZikloSolar/Hefesto | b04675d9c0a70bbf4a637780dd098b9c7e93549b | [
"MIT"
] | 3 | 2020-03-25T20:20:22.000Z | 2021-11-10T05:20:20.000Z | default_app_config = 'hefesto_core.apps.HefestoCoreConfig'
| 29.5 | 58 | 0.864407 | 7 | 59 | 6.857143 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0.050847 | 59 | 1 | 59 | 59 | 0.857143 | 0 | 0 | 0 | 0 | 0 | 0.59322 | 0.59322 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | false | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | null | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 3 |
aea8a6cfd02711dbe6f039936a9de1d40be46d49 | 128 | py | Python | pymisp/__init__.py | KennethAdamMiller/PyMISP | 497e874581afb7bdeb197df363b8cf8aa161cbda | [
"BSD-2-Clause"
] | 1 | 2019-08-14T21:09:57.000Z | 2019-08-14T21:09:57.000Z | pymisp/__init__.py | naxonez/PyMISP | 497e874581afb7bdeb197df363b8cf8aa161cbda | [
"BSD-2-Clause"
] | null | null | null | pymisp/__init__.py | naxonez/PyMISP | 497e874581afb7bdeb197df363b8cf8aa161cbda | [
"BSD-2-Clause"
] | 1 | 2019-11-21T10:36:32.000Z | 2019-11-21T10:36:32.000Z | __version__ = '2.4.49'
from .api import PyMISP, PyMISPError, NewEventError, NewAttributeError, MissingDependency, NoURL, NoKey
| 32 | 103 | 0.796875 | 14 | 128 | 7 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0.035088 | 0.109375 | 128 | 3 | 104 | 42.666667 | 0.824561 | 0 | 0 | 0 | 0 | 0 | 0.046875 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | false | 0 | 0.5 | 0 | 0.5 | 0 | 1 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 0 | 0 | 3 |
aeb8e5697b5f03b16df8d8b69bc0d8e201d38c6a | 7,604 | py | Python | python/pyspark_cassandra/types.py | gfronza/pyspark-cassandra | 7fa98bb27f460486805cf369306d28dcd9d364d7 | [
"Apache-2.0"
] | 67 | 2017-06-14T13:57:40.000Z | 2021-09-06T14:30:36.000Z | python/pyspark_cassandra/types.py | gfronza/pyspark-cassandra | 7fa98bb27f460486805cf369306d28dcd9d364d7 | [
"Apache-2.0"
] | 33 | 2017-06-13T10:37:38.000Z | 2022-02-06T18:25:12.000Z | python/pyspark_cassandra/types.py | gfronza/pyspark-cassandra | 7fa98bb27f460486805cf369306d28dcd9d364d7 | [
"Apache-2.0"
] | 32 | 2017-06-13T10:14:21.000Z | 2022-01-25T11:25:59.000Z | # Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
import struct
from datetime import datetime, tzinfo, timedelta
from itertools import chain
from operator import itemgetter
try:
# import accessed as globals, see _create_spanning_dataframe(...)
import numpy as np # @UnusedImport
import pandas as pd # @UnusedImport
except ImportError:
pass
def _create_row(fields, values):
return _create_struct(Row, fields, values)
def _create_udt(fields, values):
return _create_struct(UDT, fields, values)
def _create_struct(cls, fields, values):
d = {k: v for k, v in zip(fields, values)}
return cls(**d)
# TODO replace this datastructure with something faster
# but functionally equivalent!
#
# >>> %timeit dict(x=1, y=2, z=3)
# 1000000 loops, best of 3: 292 ns per loop
#
# >>> %timeit pyspark_cassandra.Row(x=1, y=2, z=3)
# 1000000 loops, best of 3: 1.41 µs per loop
#
# >>> %timeit FastRow(x=1, y=2, z=3)
# 1000000 loops, best of 3: 666 ns per loop
#
# where FastRow = namedtuple('FastRow', ['x', 'y', 'z'])
class Struct(tuple):
"""Adaptation from the pyspark.sql.Row which better supports adding fields.
"""
def __new__(cls, **kwargs):
if not kwargs:
raise ValueError("Cannot construct empty %s" % cls)
struct = tuple.__new__(cls)
struct.__FIELDS__ = kwargs
return struct
def asDict(self):
return self.__dict__()
def __dict__(self):
return self.__FIELDS__
def __iter__(self):
return iter(self.__FIELDS__.values())
@property
def _fields(self):
return self.keys()
def keys(self):
return self.__FIELDS__.keys()
def values(self):
return self.__FIELDS__.values()
def __len__(self):
return len(self.__FIELDS__)
def __hash__(self):
h = 1
for v in chain(self.keys(), self.values()):
h = 31 * h + hash(v)
return h
def __eq__(self, other):
try:
return self.__FIELDS__.__eq__(other.__FIELDS__)
except AttributeError:
return False
def __ne__(self, other):
return not self == other
def __add__(self, other):
d = dict(self.__FIELDS__)
d.update(other.__FIELDS__)
return self.__class__(**d)
def __sub__(self, other):
d = {k: v for k, v in self.__FIELDS__.items() if k not in other}
return self.__class__(**d)
def __and__(self, other):
d = {k: v for k, v in self.__FIELDS__.items() if k in other}
return self.__class__(**d)
def __contains__(self, name):
return name in self.__FIELDS__
def __setitem__(self, name, value):
self.__setattr__(name, value)
def __delitem__(self, name):
self.__delattr__(name)
def __getitem__(self, name):
return self.__getattr__(name)
def __getattr__(self, name):
try:
return self.__FIELDS__[name]
except KeyError:
raise AttributeError(name)
def __setattr__(self, name, value):
if name == "__FIELDS__":
tuple.__setattr__(self, name, value)
else:
self.__FIELDS__[name] = value
def __delattr__(self, name):
try:
del self.__FIELDS__[name]
except KeyError:
raise AttributeError(name)
def __getstate__(self):
return self.__dict__()
def __reduce__(self):
keys = list(self.__FIELDS__.keys())
values = list(self.__FIELDS__.values())
return (self._creator(), (keys, values,))
def __repr__(self):
fields = sorted(self.__FIELDS__.items(), key=itemgetter(0))
values = ", ".join(
"%s=%r" % (k, v) for k, v in fields if k != '__FIELDS__')
return "%s(%s)" % (self.__class__.__name__, values)
class Row(Struct):
def _creator(self):
return _create_row
class UDT(Struct):
def _creator(self):
return _create_udt
def _create_spanning_dataframe(cnames, ctypes, cvalues):
"""
Constructs a 'dataframe' from column names, numpy column types and
the column values.
@param cnames: An iterable of name strings
@param ctypes: An iterable of numpy dtypes as strings (e.g. '>f4')
@param cvalues: An iterable of
Note that cnames, ctypes and cvalues are expected to have equal length.
"""
if len(cnames) != len(ctypes) or len(ctypes) != len(cvalues):
raise ValueError(
"The lengths of cnames, ctypes and cvalues must equal")
# convert the column values to numpy arrays if numpy is available
# otherwise use lists
global np
convert = _to_nparrays if np else _to_list
arrays = {n: convert(t, v) for n, t, v in zip(cnames, ctypes, cvalues)}
# if pandas is available, provide the arrays / lists as DataFrame
# otherwise use pyspark_cassandra.Row
global pd
if pd:
return pd.DataFrame(arrays)
else:
return Row(**arrays)
def _to_nparrays(ctype, cvalue):
if isinstance(cvalue, (bytes, bytearray)):
# The array is byte swapped and set to little-endian. java encodes
# ints, longs, floats, etc. in big-endian.
# This costs some cycles (around 1 ms per 1*10^6 elements) but when
# using it it saves some when using the array (around 25 to 50 % which
# for summing amounts to half a ms)
# (the perf numbers above are on an Intel i5-4200M)
# Also it solves an issue with pickling datetime64 arrays see
# https://github.com/numpy/numpy/issues/5883
return np.frombuffer(cvalue, ctype).byteswap(True).newbyteorder('<')
else:
return np.fromiter(cvalue, None)
def _to_list(ctype, cvalue):
if isinstance(cvalue, (bytes, bytearray)):
return _decode_primitives(ctype, cvalue)
elif hasattr(cvalue, '__len__'):
return cvalue
else:
return list(cvalue)
# from https://docs.python.org/3/library/datetime.html
ZERO = timedelta(0)
class UTC(tzinfo):
def utcoffset(self, dt):
return ZERO
def tzname(self, dt):
return "UTC"
def dst(self, dt):
return ZERO
def __repr__(self):
return self.__class__.__name__
utc = UTC()
_numpy_to_struct_formats = {
'>b1': '?',
'i4': '>i',
'>i8': '>q',
'>f4': '>f',
'>f8': '>d',
'>M8[ms]': '>q',
}
def _decode_primitives(ctype, cvalue):
fmt = _numpy_to_struct_formats.get(ctype)
# if unsupported, return as the list if bytes it was
if not fmt:
return cvalue
primitives = _unpack(fmt, cvalue)
if ctype == '>M8[ms]':
return [datetime.utcfromtimestamp(l).replace(tzinfo=UTC) for l in
primitives]
else:
return primitives
def _unpack(fmt, cvalue):
stride = struct.calcsize(fmt)
if len(cvalue) % stride != 0:
raise ValueError(
'number of bytes must be a multiple of %s for format %s' % (
stride, fmt))
return [struct.unpack(cvalue[o:o + stride]) for o in
range(len(cvalue) / stride, stride)]
| 27.060498 | 79 | 0.628353 | 1,001 | 7,604 | 4.493506 | 0.306693 | 0.037795 | 0.021787 | 0.005336 | 0.141619 | 0.106269 | 0.09004 | 0.057137 | 0.057137 | 0.033126 | 0 | 0.014501 | 0.265387 | 7,604 | 280 | 80 | 27.157143 | 0.790727 | 0.274987 | 0 | 0.186335 | 0 | 0 | 0.039571 | 0 | 0 | 0 | 0 | 0.003571 | 0 | 1 | 0.236025 | false | 0.006211 | 0.043478 | 0.118012 | 0.559006 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 0 | 1 | 1 | 0 | 0 | 3 |
aed47510a4b88970d732a69e08d710f85bf7ee81 | 669 | py | Python | tests/test_match_cep.py | rennancockles/rastreio-correios | 689f2d5ea26e45983834b2192d249c35e3db90aa | [
"MIT"
] | 2 | 2021-11-16T16:54:19.000Z | 2022-03-17T19:10:08.000Z | tests/test_match_cep.py | rennancockles/rastreio-correios | 689f2d5ea26e45983834b2192d249c35e3db90aa | [
"MIT"
] | null | null | null | tests/test_match_cep.py | rennancockles/rastreio-correios | 689f2d5ea26e45983834b2192d249c35e3db90aa | [
"MIT"
] | null | null | null | def test_cep_match(correios):
matches = correios.match_cep(cep="28620000", cod="QC067757494BR")
assert matches
def test_cep_not_match_wrong_digit(correios):
matches = correios.match_cep(cep="28620000", cod="QC067757490BR")
assert not matches
def test_cep_not_match(correios):
matches = correios.match_cep(cep="28620001", cod="QC067757494BR")
assert not matches
def test_cod_not_match(correios):
matches = correios.match_cep(cep="28620000", cod="QC067757480BR")
assert not matches
def test_invalid_cod_not_match(correios):
matches = correios.match_cep(cep="28620000", cod="</objeto>QC067757480BR")
assert not matches
| 23.068966 | 78 | 0.745889 | 87 | 669 | 5.482759 | 0.206897 | 0.073375 | 0.24109 | 0.293501 | 0.725367 | 0.610063 | 0.522013 | 0.522013 | 0.339623 | 0.234801 | 0 | 0.148601 | 0.144993 | 669 | 28 | 79 | 23.892857 | 0.685315 | 0 | 0 | 0.266667 | 0 | 0 | 0.170404 | 0.032885 | 0 | 0 | 0 | 0 | 0.333333 | 1 | 0.333333 | false | 0 | 0 | 0 | 0.333333 | 0 | 0 | 0 | 0 | null | 0 | 1 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 3 |
aede05f7876f4e0e4e2f6fbab02c68b1aa7cff70 | 1,921 | py | Python | sk_dsp_comm/test/test_imports.py | toddrme2178/scikit-dsp-comm | e08427dfcf75d8389e921ab4d01ea3d2c7173a52 | [
"BSD-2-Clause"
] | null | null | null | sk_dsp_comm/test/test_imports.py | toddrme2178/scikit-dsp-comm | e08427dfcf75d8389e921ab4d01ea3d2c7173a52 | [
"BSD-2-Clause"
] | null | null | null | sk_dsp_comm/test/test_imports.py | toddrme2178/scikit-dsp-comm | e08427dfcf75d8389e921ab4d01ea3d2c7173a52 | [
"BSD-2-Clause"
] | null | null | null | from unittest import TestCase
class TestImports(TestCase):
_multiprocess_can_split_ = True
def test_coeff2header_import(self):
import sk_dsp_comm.coeff2header
def test_coeff2header_from(self):
from sk_dsp_comm import coeff2header
def test_digitalcom_import(self):
import sk_dsp_comm.digitalcom
def test_digitalcom_from(self):
from sk_dsp_comm import digitalcom
def test_fec_conv_import(self):
import sk_dsp_comm.fec_conv
def test_fec_conv_from(self):
from sk_dsp_comm import digitalcom
def test_fir_design_helper_import(self):
from sk_dsp_comm import fir_design_helper
def test_fir_design_helper_from(self):
import sk_dsp_comm.fir_design_helper
def test_iir_design_helper_from(self):
from sk_dsp_comm import iir_design_helper
def test_iir_design_helper_import(self):
import sk_dsp_comm.iir_design_helper
def test_multirate_helper_from(self):
from sk_dsp_comm import multirate_helper
def test_multirate_helper_import(self):
import sk_dsp_comm.multirate_helper
def test_optfir_from(self):
from sk_dsp_comm import optfir
def test_optfir_import(self):
import sk_dsp_comm.optfir
def test_pyaudio_helper_from(self):
from sk_dsp_comm import pyaudio_helper
def test_pyaudio_helper_import(self):
import sk_dsp_comm.pyaudio_helper
def test_rtlsdr_helper_from(self):
from sk_dsp_comm import rtlsdr_helper
def test_rtlsdr_helper_import(self):
import sk_dsp_comm.rtlsdr_helper
def test_sigsys_from(self):
from sk_dsp_comm import sigsys
def test_sigsys_import(self):
import sk_dsp_comm.sigsys
def test_synchronization_from(self):
from sk_dsp_comm import synchronization
def test_synchronization_import(self):
import sk_dsp_comm.synchronization | 27.056338 | 49 | 0.744404 | 273 | 1,921 | 4.787546 | 0.10989 | 0.117827 | 0.151492 | 0.126243 | 0.649579 | 0.521041 | 0.388676 | 0.168324 | 0.06733 | 0.06733 | 0 | 0.002647 | 0.213431 | 1,921 | 71 | 50 | 27.056338 | 0.862343 | 0 | 0 | 0.042553 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0.468085 | false | 0 | 0.744681 | 0 | 1.255319 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 1 | 0 | 1 | 0 | 0 | 3 |
aee12a8606af90886cbb9b24bdaba805549de981 | 531 | py | Python | Codewars/Test/Mexican_wave_test.py | maxcohen31/A-bored-math-student | 007beb4dabf7b4406f48e9a3a967c29d032eab89 | [
"MIT"
] | null | null | null | Codewars/Test/Mexican_wave_test.py | maxcohen31/A-bored-math-student | 007beb4dabf7b4406f48e9a3a967c29d032eab89 | [
"MIT"
] | null | null | null | Codewars/Test/Mexican_wave_test.py | maxcohen31/A-bored-math-student | 007beb4dabf7b4406f48e9a3a967c29d032eab89 | [
"MIT"
] | null | null | null | import unittest
from Mexican_wave_6_kyu import wave
class MexicanWave(unittest.TestCase):
def test_1(self):
people = 'hello'
result = ['Hello', 'hEllo', 'heLlo', 'helLo', 'hellO']
self.assertEqual(wave(people), result)
def test_2(self):
people = 'codewars'
result = ['Codewars', 'cOdewars', 'coDewars', 'codEwars', 'codeWars', 'codewArs', 'codewaRs', 'codewarS']
self.assertEqual(wave(people), result)
if __name__ == "__main__":
unittest.main()
| 33.1875 | 113 | 0.606403 | 55 | 531 | 5.618182 | 0.418182 | 0.36246 | 0.466019 | 0.517799 | 0.407767 | 0.20712 | 0.20712 | 0 | 0 | 0 | 0 | 0.007481 | 0.244821 | 531 | 16 | 114 | 33.1875 | 0.763092 | 0 | 0 | 0.153846 | 0 | 0 | 0.206767 | 0 | 0 | 0 | 0 | 0 | 0.153846 | 1 | 0.153846 | false | 0 | 0.153846 | 0 | 0.384615 | 0 | 0 | 0 | 0 | null | 1 | 1 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 3 |
aeee6fc5349e40a306002d7cd130a69ff7eccdee | 147 | py | Python | sum.py | Baibhabswain/pythonPrograms | 38380174f22e73b766b98754b00cd78a56b4bf59 | [
"MIT"
] | 1 | 2019-03-29T04:32:09.000Z | 2019-03-29T04:32:09.000Z | sum.py | Baibhabswain/pythonPrograms | 38380174f22e73b766b98754b00cd78a56b4bf59 | [
"MIT"
] | null | null | null | sum.py | Baibhabswain/pythonPrograms | 38380174f22e73b766b98754b00cd78a56b4bf59 | [
"MIT"
] | null | null | null | def main():
sum=0
no=input("Please enter the number : ")
while no>0:
last=n%10
sum=sum+last
no/=10
print "The sum is ",sum
main() | 16.333333 | 40 | 0.591837 | 27 | 147 | 3.222222 | 0.592593 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0.054545 | 0.251701 | 147 | 9 | 41 | 16.333333 | 0.736364 | 0 | 0 | 0 | 0 | 0 | 0.264286 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | null | null | 0 | 0 | null | null | 0.111111 | 1 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 3 |
4e2b473ae4106dced6cd574518ca13078eeaf9d1 | 283 | py | Python | crawler/forms.py | bkosawa/admin-recommendation | 8bc1acf20fde8e5e99b74da32cf426b037ccb98f | [
"Apache-2.0"
] | null | null | null | crawler/forms.py | bkosawa/admin-recommendation | 8bc1acf20fde8e5e99b74da32cf426b037ccb98f | [
"Apache-2.0"
] | null | null | null | crawler/forms.py | bkosawa/admin-recommendation | 8bc1acf20fde8e5e99b74da32cf426b037ccb98f | [
"Apache-2.0"
] | null | null | null | from django import forms
from crawler import models
class AppForm(forms.ModelForm):
class Meta:
model = models.App
fields = '__all__'
class AppDescriptionForm(forms.ModelForm):
class Meta:
model = models.AppDescription
fields = '__all__'
| 17.6875 | 42 | 0.671378 | 30 | 283 | 6.066667 | 0.533333 | 0.153846 | 0.208791 | 0.252747 | 0.373626 | 0.373626 | 0 | 0 | 0 | 0 | 0 | 0 | 0.257951 | 283 | 15 | 43 | 18.866667 | 0.866667 | 0 | 0 | 0.4 | 0 | 0 | 0.04947 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | false | 0 | 0.2 | 0 | 0.6 | 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 | 1 | 0 | 0 | 3 |
9d68401dd093630784da476f2ab574ea408410c2 | 215 | py | Python | optimesh/cvt/_helpers.py | jtpils/optimesh | 24a8276235b1f4e86f2fb92cf814bf81e7fdbc48 | [
"MIT"
] | 1 | 2019-11-20T16:50:34.000Z | 2019-11-20T16:50:34.000Z | optimesh/cvt/_helpers.py | jtpils/optimesh | 24a8276235b1f4e86f2fb92cf814bf81e7fdbc48 | [
"MIT"
] | null | null | null | optimesh/cvt/_helpers.py | jtpils/optimesh | 24a8276235b1f4e86f2fb92cf814bf81e7fdbc48 | [
"MIT"
] | null | null | null | def jac_uniform(mesh, mask):
# create Jacobian
cv = mesh.get_control_volumes(cell_mask=mask)
cvc = mesh.get_control_volume_centroids(cell_mask=mask)
return 2 * (mesh.node_coords - cvc) * cv[:, None]
| 35.833333 | 59 | 0.711628 | 32 | 215 | 4.5 | 0.625 | 0.097222 | 0.194444 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0.005618 | 0.172093 | 215 | 5 | 60 | 43 | 0.803371 | 0.069767 | 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 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 3 |
9d76a3888bec7f21950db366daeab78e546c46af | 403 | py | Python | usb_protocol/contextmgrs/descriptors/dfu.py | DX-MON/python-usb-protocol | ce0649683ee6a0839a3be8d2776b85fb1ec10dd6 | [
"BSD-3-Clause"
] | null | null | null | usb_protocol/contextmgrs/descriptors/dfu.py | DX-MON/python-usb-protocol | ce0649683ee6a0839a3be8d2776b85fb1ec10dd6 | [
"BSD-3-Clause"
] | null | null | null | usb_protocol/contextmgrs/descriptors/dfu.py | DX-MON/python-usb-protocol | ce0649683ee6a0839a3be8d2776b85fb1ec10dd6 | [
"BSD-3-Clause"
] | null | null | null | #
# This file is part of usb-protocol.
#
from ..manager import DescriptorContextManager
from ...emitters.descriptors.standard import InterfaceDescriptorEmitter
from ...emitters.descriptors.dfu import FunctionalDescriptorEmitter
class FunctionalDescriptor(DescriptorContextManager):
ParentDescriptor = InterfaceDescriptorEmitter
DescriptorEmitter = lambda self: FunctionalDescriptorEmitter()
| 28.785714 | 71 | 0.831266 | 32 | 403 | 10.46875 | 0.71875 | 0.071642 | 0.137313 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0.1067 | 403 | 13 | 72 | 31 | 0.930556 | 0.084367 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | false | 0 | 0.5 | 0 | 1 | 0 | 0 | 0 | 1 | null | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 1 | 0 | 0 | 3 |
9dd87dcbfb181c5580002b72ea627d596dfdecca | 1,494 | py | Python | MetaStone/EnumFields/DatabaseModels/Internal/DbModelMapping.py | mrumming/MetaStonePhenoPointer | fc0b837b509ffec2db374723079a6fc97791f8e3 | [
"BSD-3-Clause"
] | null | null | null | MetaStone/EnumFields/DatabaseModels/Internal/DbModelMapping.py | mrumming/MetaStonePhenoPointer | fc0b837b509ffec2db374723079a6fc97791f8e3 | [
"BSD-3-Clause"
] | null | null | null | MetaStone/EnumFields/DatabaseModels/Internal/DbModelMapping.py | mrumming/MetaStonePhenoPointer | fc0b837b509ffec2db374723079a6fc97791f8e3 | [
"BSD-3-Clause"
] | null | null | null | ###
# This file necessary due to cross importing errors if put to ./Uploads.py
###
from MetaStone.models import Genome, GenomeIdMapping, GenomeLineage, EcosystemRelatedCharacteristics, \
SamplingSiteCharacteristics, SequencingCharacteristics, SpeciesRelatedCharacteristics, \
InferredSpeciesRelatedCharacteristics, Pfam, Pfam2Genome
TASKS = {"Genomes": [Genome], "Genome_Lineage": [GenomeLineage], "Genome_Metadata":
[GenomeIdMapping, EcosystemRelatedCharacteristics,
SamplingSiteCharacteristics,
SequencingCharacteristics,
SpeciesRelatedCharacteristics], "Pfam": [Pfam], "Pfam2Genome": [Pfam2Genome],
"ALL": [Genome, GenomeLineage, GenomeIdMapping, EcosystemRelatedCharacteristics, SamplingSiteCharacteristics,
SequencingCharacteristics, SpeciesRelatedCharacteristics]}
TASK_FACTORY_ID = {"Genomes": "genome_oid", "Genome_Lineage": "genome_oid", "Genome_Metadata": "genome_oid",
"Pfam": "pfam_clans", "Pfam2Genome": "pfam_to_genome", "ALL": "genome_oid"}
# Possible since all phenotype information fields from IMG/GOLD are unique on their own and form a set with distinctive
# keys
IMG_MODELS = [EcosystemRelatedCharacteristics, SamplingSiteCharacteristics, SequencingCharacteristics,
SpeciesRelatedCharacteristics]
FIELDS_TO_MODEL = {name_: model for model in IMG_MODELS for name_ in model.img_name.values()}
MODEL_TO_INFERRED = {SpeciesRelatedCharacteristics: InferredSpeciesRelatedCharacteristics}
| 53.357143 | 119 | 0.777108 | 125 | 1,494 | 9.112 | 0.488 | 0.203687 | 0.291484 | 0.393327 | 0.223003 | 0 | 0 | 0 | 0 | 0 | 0 | 0.003101 | 0.136546 | 1,494 | 27 | 120 | 55.333333 | 0.879845 | 0.130522 | 0 | 0 | 0 | 0 | 0.133437 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | false | 0 | 0.0625 | 0 | 0.0625 | 0 | 0 | 0 | 0 | null | 1 | 1 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 3 |
9dfc40997d1e4478de499c2d8620c9d25304b235 | 1,271 | py | Python | core/views.py | PayPal-Opportunity-Hack-Chennai-2016/gramium | d41d8cd39728fc8816ea0ce444c7289d668947a6 | [
"Apache-2.0"
] | 1 | 2016-11-14T07:58:02.000Z | 2016-11-14T07:58:02.000Z | core/views.py | PayPal-Opportunity-Hack-Chennai-2016/gramium | d41d8cd39728fc8816ea0ce444c7289d668947a6 | [
"Apache-2.0"
] | null | null | null | core/views.py | PayPal-Opportunity-Hack-Chennai-2016/gramium | d41d8cd39728fc8816ea0ce444c7289d668947a6 | [
"Apache-2.0"
] | 6 | 2016-11-12T09:20:09.000Z | 2021-04-09T11:13:34.000Z | from django.shortcuts import render
# Create your views here.
from django.views.decorators.csrf import csrf_exempt
from rest_framework import viewsets
from core.models import Member, Group, Account, Identity, Loan, Repayment
from core.serializers import GroupSerializer, MemberSerializer, AccountSerializer, IdentitySerializer, LoanSerializer, \
RepaymentSerializer
class DisableCSRFOnDebug(object):
pass
class AccountViewSet(viewsets.ModelViewSet, DisableCSRFOnDebug):
serializer_class = AccountSerializer
queryset = Account.objects.all()
class GroupViewSet(viewsets.ModelViewSet, DisableCSRFOnDebug):
serializer_class = GroupSerializer
queryset = Group.objects.all()
class IdentityViewSet(viewsets.ModelViewSet, DisableCSRFOnDebug):
serializer_class = IdentitySerializer
queryset = Identity.objects.all()
class LoanViewSet(viewsets.ModelViewSet, DisableCSRFOnDebug):
serializer_class = LoanSerializer
queryset = Loan.objects.all()
class MemberViewSet(viewsets.ModelViewSet, DisableCSRFOnDebug):
serializer_class = MemberSerializer
queryset = Member.objects.all()
class RepaymentViewSet(viewsets.ModelViewSet, DisableCSRFOnDebug):
serializer_class = RepaymentSerializer
queryset = Repayment.objects.all() | 34.351351 | 120 | 0.806452 | 118 | 1,271 | 8.618644 | 0.381356 | 0.117994 | 0.224189 | 0.283186 | 0.312684 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0.124312 | 1,271 | 37 | 121 | 34.351351 | 0.913747 | 0.018096 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | false | 0.038462 | 0.192308 | 0 | 0.923077 | 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 | 1 | 0 | 0 | 3 |
d18d1045cf4fdc28660b3b80149d39f762e1724f | 113 | py | Python | garage/theano/baselines/__init__.py | shadiakiki1986/garage | 095bb5d25b32df1d44b47e99a78a9b01796941d9 | [
"MIT"
] | 3 | 2019-08-11T22:26:55.000Z | 2020-11-28T10:23:50.000Z | garage/theano/baselines/__init__.py | shadiakiki1986/garage | 095bb5d25b32df1d44b47e99a78a9b01796941d9 | [
"MIT"
] | null | null | null | garage/theano/baselines/__init__.py | shadiakiki1986/garage | 095bb5d25b32df1d44b47e99a78a9b01796941d9 | [
"MIT"
] | 2 | 2019-08-11T22:30:14.000Z | 2021-03-25T02:57:50.000Z | from garage.theano.baselines.gaussian_mlp_baseline import GaussianMLPBaseline
__all__ = ["GaussianMLPBaseline"]
| 28.25 | 77 | 0.858407 | 11 | 113 | 8.272727 | 0.909091 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0.070796 | 113 | 3 | 78 | 37.666667 | 0.866667 | 0 | 0 | 0 | 0 | 0 | 0.168142 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | false | 0 | 0.5 | 0 | 0.5 | 0 | 1 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 0 | 0 | 3 |
d1a5a894910a11b743cb56ef4728df4c9da9ba93 | 260 | py | Python | ramda/pick_by_test.py | jakobkolb/ramda.py | 982b2172f4bb95b9a5b09eff8077362d6f2f0920 | [
"MIT"
] | 56 | 2018-08-06T08:44:58.000Z | 2022-03-17T09:49:03.000Z | ramda/pick_by_test.py | jakobkolb/ramda.py | 982b2172f4bb95b9a5b09eff8077362d6f2f0920 | [
"MIT"
] | 28 | 2019-06-17T11:09:52.000Z | 2022-02-18T16:59:21.000Z | ramda/pick_by_test.py | jakobkolb/ramda.py | 982b2172f4bb95b9a5b09eff8077362d6f2f0920 | [
"MIT"
] | 5 | 2019-09-18T09:24:38.000Z | 2021-07-21T08:40:23.000Z | from ramda.pick_by import pick_by
from ramda.private.asserts import *
def is_upper_case(val, key):
return key.upper() == key
def pick_by_test():
assert_equal(
pick_by(is_upper_case, {"a": 1, "b": 2, "A": 3, "B": 4}), {"A": 3, "B": 4}
)
| 20 | 82 | 0.6 | 45 | 260 | 3.244444 | 0.511111 | 0.164384 | 0.150685 | 0.054795 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0.029412 | 0.215385 | 260 | 12 | 83 | 21.666667 | 0.686275 | 0 | 0 | 0 | 0 | 0 | 0.023077 | 0 | 0 | 0 | 0 | 0 | 0.25 | 1 | 0.25 | false | 0 | 0.25 | 0.125 | 0.625 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 0 | 1 | 1 | 0 | 0 | 3 |
d1b47fe9d979173faeb05c4e209b3ec829b03080 | 106 | py | Python | oasysapi/modules/annotation.py | SleepyCloud023/Oasys | 0a2072f711acb5965fed05b18cd69e4537090560 | [
"MIT"
] | null | null | null | oasysapi/modules/annotation.py | SleepyCloud023/Oasys | 0a2072f711acb5965fed05b18cd69e4537090560 | [
"MIT"
] | 1 | 2022-01-25T10:42:53.000Z | 2022-01-25T10:42:53.000Z | oasysapi/modules/annotation.py | SleepyCloud023/Oasys | 0a2072f711acb5965fed05b18cd69e4537090560 | [
"MIT"
] | 2 | 2022-01-20T15:07:24.000Z | 2022-01-20T15:10:44.000Z | import json
DEFAULT_ANNO = json.dumps(
{"category_list": [], "tag_list": [], "box_object_list": []})
| 21.2 | 65 | 0.632075 | 13 | 106 | 4.769231 | 0.769231 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0.150943 | 106 | 4 | 66 | 26.5 | 0.688889 | 0 | 0 | 0 | 0 | 0 | 0.339623 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | false | 0 | 0.333333 | 0 | 0.333333 | 0 | 1 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 0 | 0 | 3 |
d1b72ee4c4f7ab5a6ac349afe0b38efb7ac6d1dc | 357 | py | Python | bin/helper_asymmetric_ciphers.py | adisakshya/pycrypto | 0fd58ee9b76aec475720b068a32edde0d379ff75 | [
"MIT"
] | 2 | 2019-01-14T14:51:00.000Z | 2019-10-31T14:34:36.000Z | bin/helper_asymmetric_ciphers.py | adisakshya/cryptoid | 0fd58ee9b76aec475720b068a32edde0d379ff75 | [
"MIT"
] | null | null | null | bin/helper_asymmetric_ciphers.py | adisakshya/cryptoid | 0fd58ee9b76aec475720b068a32edde0d379ff75 | [
"MIT"
] | null | null | null | """
MODULE NAME: helper_asymmetric_ciphers
Author: Adisakshya Chauhan
"""
# import block ciphers from Crypto module
# to use thier functions to encrypt and decrypt
# messages
from Crypto.PublicKey import RSA
from Crypto.Cipher import PKCS1_OAEP
import string
# list of all supported ciphers
"""
ciphers = ['', RSA, viginere_cipher, caesar_cipher]
"""
| 21 | 51 | 0.764706 | 47 | 357 | 5.702128 | 0.680851 | 0.11194 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0.003322 | 0.156863 | 357 | 16 | 52 | 22.3125 | 0.887043 | 0.535014 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | true | 0 | 1 | 0 | 1 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 1 | 0 | 1 | 0 | 0 | 3 |
d1ca32e04beef00892f7f19ffa40eccfe01ce0bd | 1,082 | py | Python | Chapter3/exercise3.py | ion-training/python-practical-programming | 1b048da3c681ba534a6f0a8e3e1c3dc89f73694c | [
"MIT"
] | null | null | null | Chapter3/exercise3.py | ion-training/python-practical-programming | 1b048da3c681ba534a6f0a8e3e1c3dc89f73694c | [
"MIT"
] | null | null | null | Chapter3/exercise3.py | ion-training/python-practical-programming | 1b048da3c681ba534a6f0a8e3e1c3dc89f73694c | [
"MIT"
] | null | null | null | # define a function that:
# has one parameter, a number, and returns that number tripled.
# Q1: What do you name the function?
# A: number_tripled
# Q2: What are the parameters, and what types of information do they refer to?
# A: one parameter of type number
# Q2: What calculations are you doing with that information?
# A: the input number (parameter) is going to be multiplied 3 times
# Q3: What information does the function return?
# A: The function returns the result of the input trippled input parameter
# 1 Examples
# 2 Header: Decide param names and types, and return type. Write header of the func.
# 3 Description: short description of the function for others to read
# 4 Body: write body of the function
# 5 Test: run examples to make sure you function body is correct
def number_tripled(num: int) -> int:
"""
precondition: number is a number
take as input a number and multiply the number 3 times
>>> number_tripled(5)
125
>>> number_tripled(2.2)
6
"""
return num*3
# Q: Does it work like you expect it to?
# A:
| 25.761905 | 84 | 0.709797 | 175 | 1,082 | 4.365714 | 0.445714 | 0.085079 | 0.026178 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0.022646 | 0.224584 | 1,082 | 41 | 85 | 26.390244 | 0.887962 | 0.866913 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0.5 | false | 0 | 0 | 0 | 1 | 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 | 1 | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 3 |
d1ccce8127bf08b3f4c4712cf7fccd06abbe0cdd | 8,301 | py | Python | justin/sql_database/sqlite3_controller.py | emo8355/apple_music | 17cafdfa5f3fcbbac32c8238e176524d36ccd7cf | [
"MIT"
] | 1 | 2020-04-09T21:07:34.000Z | 2020-04-09T21:07:34.000Z | justin/sql_database/sqlite3_controller.py | emo8355/apple_music | 17cafdfa5f3fcbbac32c8238e176524d36ccd7cf | [
"MIT"
] | null | null | null | justin/sql_database/sqlite3_controller.py | emo8355/apple_music | 17cafdfa5f3fcbbac32c8238e176524d36ccd7cf | [
"MIT"
] | null | null | null | import sqlite3
database = './orange-music.db'
# #this line creates the file 'database = './file-name.db' - if it doesn't exist, if it does exist, it connects
# connection = sqlite3.connect(database)
# #cursor lets you execute sql commands
# cursor = connection.cursor()
default_album_cover = 'https://icons.iconarchive.com/icons/papirus-team/papirus-mimetypes/512/unknown-icon.png'
#insert_song_into_songs("Pick Me Up", "Perfume", 4, 2014)
#insert_song_into_songs("Future Pop", "Perfume", 4, 2018)
#print(select_songs())
#users
def select_users(select_by = '*', search_by = ''):
table = 'users'
connection = sqlite3.connect(database)
cursor = connection.cursor()
with connection:
cursor.execute(f"SELECT {select_by} FROM {table} {search_by}")
return cursor.fetchall()
def insert_user_into_users(email, password_hash, name, date_of_birth):
table = 'users'
connection = sqlite3.connect(database)
cursor = connection.cursor()
with connection:
cursor.execute(f"INSERT INTO {table} (email, password_hash, name, date_of_birth) VALUES (?, ?, ?, ?)", (email, password_hash, name, date_of_birth))
#artists
def select_artists(select_by = '*', search_by = ''):
table = 'artists'
connection = sqlite3.connect(database)
cursor = connection.cursor()
with connection:
cursor.execute(f"SELECT {select_by} FROM {table} {search_by}")
return cursor.fetchall()
def insert_artist_into_artists(name):
table = 'artists'
connection = sqlite3.connect(database)
cursor = connection.cursor()
with connection:
cursor.execute(f"INSERT INTO {table} (name) VALUES (?)", (name,))
#artist_songs
def select_artist_songs(select_by = '*', search_by = ''):
table = 'artist_songs'
connection = sqlite3.connect(database)
cursor = connection.cursor()
with connection:
cursor.execute(f"SELECT {select_by} FROM {table} {search_by}")
return cursor.fetchall()
def insert_into_artist_songs(artist_id, song_id):
table = 'artist_songs'
connection = sqlite3.connect(database)
cursor = connection.cursor()
with connection:
cursor.execute(f"INSERT INTO {table} (artist_id, song_id) VALUES (?,?)", (artist_id, song_id))
#songs
def select_songs(select_by = '*', search_by = ''):
table = 'songs'
connection = sqlite3.connect(database)
cursor = connection.cursor()
with connection:
cursor.execute(f"SELECT {select_by} FROM {table} {search_by}")
return cursor.fetchall()
def insert_song_into_songs(title, artist_id, duration, release_year):
table = 'songs'
connection = sqlite3.connect(database)
cursor = connection.cursor()
with connection:
cursor.execute(f"INSERT INTO {table} (title, artist_id, duration, release_year) VALUES (?, ?, ?, ?)", (title, artist_id, duration, release_year))
#song_user_likes
def select_song_user_likes(select_by = '*', search_by = ''):
table = 'song_user_likes'
connection = sqlite3.connect(database)
cursor = connection.cursor()
with connection:
cursor.execute(f"SELECT {select_by} FROM {table} {search_by}")
return cursor.fetchall()
def insert_like_into_song_user_likes(song_id, user_id):
table = 'song_user_likes'
connection = sqlite3.connect(database)
cursor = connection.cursor()
with connection:
cursor.execute(f"INSERT INTO {table} (song_id, user_id) VALUES (?,?)", (song_id, user_id))
#user_favorite_songs
def select_user_favorite_songs(select_by = '*', search_by = ''):
table = 'user_favorite_songs'
connection = sqlite3.connect(database)
cursor = connection.cursor()
with connection:
cursor.execute(f"SELECT {select_by} FROM {table} {search_by}")
return cursor.fetchall()
def insert_favorite_into_user_favorite_songs(user_id, song_id):
table = 'user_favorite_songs'
connection = sqlite3.connect(database)
cursor = connection.cursor()
with connection:
cursor.execute(f"INSERT INTO {table} (user_id, song_id) VALUES (?,?)", (user_id, song_id))
#albums
def select_albums(select_by = '*', search_by = ''):
table = 'albums'
connection = sqlite3.connect(database)
cursor = connection.cursor()
with connection:
cursor.execute(f"SELECT {select_by} FROM {table} {search_by}")
return cursor.fetchall()
#default album cover used here
def insert_album_into_albums(title, genre, release_year, cover_image = default_album_cover):
table = 'albums'
connection = sqlite3.connect(database)
cursor = connection.cursor()
with connection:
cursor.execute(f"INSERT INTO {table} (title, genre, release_year, cover_image) VALUES (?, ?, ?, ?)", (title, genre, release_year, cover_image))
#artist_albums
def select_artist_albums(select_by = '*', search_by = ''):
table = 'artist_albums'
connection = sqlite3.connect(database)
cursor = connection.cursor()
with connection:
cursor.execute(f"SELECT {select_by} FROM {table} {search_by}")
return cursor.fetchall()
def insert_into_artist_albums(artist_id, album_id):
table = 'artist_albums'
connection = sqlite3.connect(database)
cursor = connection.cursor()
with connection:
cursor.execute(f"INSERT INTO {table} (artist_id, album_id) VALUES (?, ?)", (artist_id, album_id))
#album_user_likes
def select_album_user_likes(select_by = '*', search_by = ''):
table = 'album_user_likes'
connection = sqlite3.connect(database)
cursor = connection.cursor()
with connection:
cursor.execute(f"SELECT {select_by} FROM {table} {search_by}")
return cursor.fetchall()
def insert_like_into_album_user_likes(album_id, user_id):
table = 'album_user_likes'
connection = sqlite3.connect(database)
cursor = connection.cursor()
with connection:
cursor.execute(f"INSERT INTO {table} (album_id, user_id) VALUES (?, ?)", (album_id, user_id))
#album_songs
def select_users(select_by = '*', search_by = ''):
table = 'album_songs'
connection = sqlite3.connect(database)
cursor = connection.cursor()
with connection:
cursor.execute(f"SELECT {select_by} FROM {table} {search_by}")
return cursor.fetchall()
def insert_into_album_songs(album_id, song_id):
table = 'album_songs'
connection = sqlite3.connect(database)
cursor = connection.cursor()
with connection:
cursor.execute(f"INSERT INTO {table} (album_id, song_id) VALUES (?, ?)", (album_id, song_id))
#lyrics
def select_lyrics(select_by = '*', search_by = ''):
table = 'lyrics'
connection = sqlite3.connect(database)
cursor = connection.cursor()
with connection:
cursor.execute(f"SELECT {select_by} FROM {table} {search_by}")
return cursor.fetchall()
def insert_lyric_into_lyrics(song_id, language, lyrics):
table = 'lyrics'
connection = sqlite3.connect(database)
cursor = connection.cursor()
with connection:
cursor.execute(f"INSERT INTO {table} (song_id, language, lyrics) VALUES (?, ?, ?)", (song_id, language, lyrics))
#playlists
def select_playlists(select_by = '*', search_by = ''):
table = 'playlists'
connection = sqlite3.connect(database)
cursor = connection.cursor()
with connection:
cursor.execute(f"SELECT {select_by} FROM {table} {search_by}")
return cursor.fetchall()
def insert_playlist_into_playlists(user_id, title, song_id):
table = 'playlists'
connection = sqlite3.connect(database)
cursor = connection.cursor()
with connection:
cursor.execute(f"INSERT INTO {table} (user_id, title, song_id) VALUES (?, ?, ?)", (user_id, title, song_id))
#playlist_songs
def select_playlist_songs(select_by = '*', search_by = ''):
table = 'playlist_songs'
connection = sqlite3.connect(database)
cursor = connection.cursor()
with connection:
cursor.execute(f"SELECT {select_by} FROM {table} {search_by}")
return cursor.fetchall()
def insert_into_playlist_songs(playlist_id, song_id):
table = 'playlist_songs'
connection = sqlite3.connect(database)
cursor = connection.cursor()
with connection:
cursor.execute(f"INSERT INTO {table} (playlist_id, song_id) VALUES (?,?)", (playlist_id, song_id))
| 33.881633 | 155 | 0.689555 | 1,016 | 8,301 | 5.405512 | 0.09252 | 0.154406 | 0.11799 | 0.15732 | 0.775674 | 0.747451 | 0.691551 | 0.664967 | 0.654042 | 0.654042 | 0 | 0.006042 | 0.182508 | 8,301 | 244 | 156 | 34.020492 | 0.803271 | 0.0618 | 0 | 0.767442 | 0 | 0.005814 | 0.223138 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0.151163 | false | 0.011628 | 0.005814 | 0 | 0.232558 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 0 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 3 |
d1f1cd3a32911da69b48aa30f8be2a093d351ce5 | 155 | py | Python | midi-player/main.py | njanirudh/air-drums | 07d0adddb70ae055d58efd2b0ae3a9f8fae3ae18 | [
"MIT"
] | null | null | null | midi-player/main.py | njanirudh/air-drums | 07d0adddb70ae055d58efd2b0ae3a9f8fae3ae18 | [
"MIT"
] | null | null | null | midi-player/main.py | njanirudh/air-drums | 07d0adddb70ae055d58efd2b0ae3a9f8fae3ae18 | [
"MIT"
] | null | null | null | from drum_service import DrumService
if __name__ == "__main__" :
drums_srv = DrumService()
drums_srv.initialize_services()
drums_srv.start()
| 19.375 | 36 | 0.729032 | 18 | 155 | 5.555556 | 0.722222 | 0.24 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0.180645 | 155 | 7 | 37 | 22.142857 | 0.787402 | 0 | 0 | 0 | 0 | 0 | 0.051613 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | false | 0 | 0.2 | 0 | 0.2 | 0 | 1 | 0 | 0 | null | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 3 |
0601d7ef09a23d682998050e14d62836cda2c502 | 467 | py | Python | tests/operations/context.py | AlanHorowitz/open-ended-capstone | 80590af5b09c2245f124cec20ed7594d62cff30e | [
"MIT"
] | null | null | null | tests/operations/context.py | AlanHorowitz/open-ended-capstone | 80590af5b09c2245f124cec20ed7594d62cff30e | [
"MIT"
] | null | null | null | tests/operations/context.py | AlanHorowitz/open-ended-capstone | 80590af5b09c2245f124cec20ed7594d62cff30e | [
"MIT"
] | null | null | null | import os
import sys
sys.path.insert(
0,
os.path.abspath(os.path.join(os.path.dirname(__file__), "../../WidgetsUnlimited")),
)
from model.metadata import Table, Column
from model.order import OrderTable
from model.order_line_item import OrderLineItemTable
from model.product import ProductTable
from model.customer import CustomerTable
from operations.generator import DataGenerator, DEFAULT_INSERT_VALUES
from operations.generator import GeneratorRequest
| 27.470588 | 87 | 0.815846 | 60 | 467 | 6.216667 | 0.516667 | 0.120643 | 0.075067 | 0.155496 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0.002398 | 0.107066 | 467 | 16 | 88 | 29.1875 | 0.892086 | 0 | 0 | 0 | 0 | 0 | 0.047109 | 0.047109 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | true | 0 | 0.692308 | 0 | 0.692308 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 1 | 0 | 1 | 0 | 0 | 3 |
ae0faf9742fd7f96fec1866d939e6b371fcedb94 | 80 | py | Python | text_classification_with_pytorch/src/demo.py | rakeshku93/nlpProjects | b478a8e7895bd62547cf613b9f6cba2776eee0de | [
"MIT"
] | null | null | null | text_classification_with_pytorch/src/demo.py | rakeshku93/nlpProjects | b478a8e7895bd62547cf613b9f6cba2776eee0de | [
"MIT"
] | null | null | null | text_classification_with_pytorch/src/demo.py | rakeshku93/nlpProjects | b478a8e7895bd62547cf613b9f6cba2776eee0de | [
"MIT"
] | null | null | null | import pandas as pd
from sklearn import metrics
acc = metrics.accuracy_score() | 16 | 30 | 0.8 | 12 | 80 | 5.25 | 0.833333 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0.15 | 80 | 5 | 30 | 16 | 0.926471 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | false | 0 | 0.666667 | 0 | 0.666667 | 0 | 1 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 0 | 0 | 3 |
ae18fe38ef6b4ba2804bffce89459d82f0fb843d | 336 | py | Python | corehq/apps/style/templatetags/hqstyle_tags.py | dslowikowski/commcare-hq | ad8885cf8dab69dc85cb64f37aeaf06106124797 | [
"BSD-3-Clause"
] | 1 | 2015-02-10T23:26:39.000Z | 2015-02-10T23:26:39.000Z | corehq/apps/style/templatetags/hqstyle_tags.py | SEL-Columbia/commcare-hq | 992ee34a679c37f063f86200e6df5a197d5e3ff6 | [
"BSD-3-Clause"
] | 1 | 2022-03-12T01:03:25.000Z | 2022-03-12T01:03:25.000Z | corehq/apps/style/templatetags/hqstyle_tags.py | johan--/commcare-hq | 86ee99c54f55ee94e4c8f2f6f30fc44e10e69ebd | [
"BSD-3-Clause"
] | null | null | null | from django import template
register = template.Library()
@register.inclusion_tag('hqstyle/forms/basic_fieldset.html')
def bootstrap_fieldset(form, fieldset_name=''):
return {'form':form, 'legend':fieldset_name}
@register.inclusion_tag('hqstyle/forms/basic_errors.html')
def bootstrap_form_errors(form):
return {'form':form}
| 28 | 60 | 0.77381 | 43 | 336 | 5.837209 | 0.465116 | 0.135458 | 0.159363 | 0.215139 | 0.294821 | 0.294821 | 0 | 0 | 0 | 0 | 0 | 0 | 0.089286 | 336 | 11 | 61 | 30.545455 | 0.820261 | 0 | 0 | 0 | 0 | 0 | 0.232143 | 0.190476 | 0 | 0 | 0 | 0 | 0 | 1 | 0.25 | false | 0 | 0.125 | 0.25 | 0.625 | 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 | 1 | 0 | 0 | 0 | 3 |
ae251d115d07be428b23887946cf216035783ed4 | 47 | py | Python | 3rd_party_software/pyca/Code/Python/__init__.py | ninamiolane/quicksilver | 1baf251360dadea0afa3daaa09942d9d2d7c71fb | [
"Apache-2.0"
] | 126 | 2017-04-06T03:19:03.000Z | 2022-03-08T07:44:09.000Z | 3rd_party_software/pyca/Code/Python/__init__.py | ninamiolane/quicksilver | 1baf251360dadea0afa3daaa09942d9d2d7c71fb | [
"Apache-2.0"
] | 7 | 2017-09-22T01:46:04.000Z | 2021-04-29T07:22:44.000Z | 3rd_party_software/pyca/Code/Python/__init__.py | ninamiolane/quicksilver | 1baf251360dadea0afa3daaa09942d9d2d7c71fb | [
"Apache-2.0"
] | 37 | 2017-04-03T17:14:44.000Z | 2022-03-09T16:00:03.000Z | __all__=[ "Core", "Common", "Display", "VTK" ]
| 23.5 | 46 | 0.574468 | 5 | 47 | 4.6 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0.12766 | 47 | 1 | 47 | 47 | 0.560976 | 0 | 0 | 0 | 0 | 0 | 0.425532 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | false | 0 | 0 | 0 | 0 | 0 | 1 | 1 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 3 |
ae27cc5f73e240e7d3659b0527aac1f2dc2dd837 | 381 | py | Python | ZhiHu-Spider/helper/launch_helper.py | xll-1994/ZhiHuSpider | f211cc24ad11ca632d0654812e17dd98088683cd | [
"MIT"
] | 1 | 2021-12-20T13:38:22.000Z | 2021-12-20T13:38:22.000Z | ZhiHu-Spider/helper/launch_helper.py | xll-1994/ZhiHuSpider | f211cc24ad11ca632d0654812e17dd98088683cd | [
"MIT"
] | 3 | 2022-01-07T05:49:44.000Z | 2022-01-17T07:31:16.000Z | ZhiHu-Spider/helper/launch_helper.py | xll-1994/ZhiHuSpider | f211cc24ad11ca632d0654812e17dd98088683cd | [
"MIT"
] | 1 | 2022-01-07T06:48:40.000Z | 2022-01-07T06:48:40.000Z | # -*- coding: utf-8 -*-
# ProjectName: ZhiHu-Spider
# FileName: launch_helper
# Description:
# CreateDate: 2021/12/25
def start_answer_spider(question_id):
from spider.answer_spider import AnswerSpider
AnswerSpider(question_id).run()
def start_article_spider(article_id):
from spider.article_spider import ArticleSpider
ArticleSpider(article_id).run()
| 23.8125 | 51 | 0.745407 | 46 | 381 | 5.934783 | 0.543478 | 0.058608 | 0.087912 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0.02795 | 0.154856 | 381 | 15 | 52 | 25.4 | 0.819876 | 0.304462 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0.333333 | false | 0 | 0.333333 | 0 | 0.666667 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 1 | 0 | 1 | 0 | 0 | 3 |
ae4dad3b040b26032da3c30327f615dd3fffb8f8 | 1,930 | py | Python | megfile/lib/stdio_handler.py | bbtfr/megfile | 7a0d4bd8fa6f52512e99dfd490bf404fb4f5ede0 | [
"Apache-2.0",
"MIT"
] | 69 | 2021-08-28T15:03:26.000Z | 2022-03-04T23:43:22.000Z | megfile/lib/stdio_handler.py | bbtfr/megfile | 7a0d4bd8fa6f52512e99dfd490bf404fb4f5ede0 | [
"Apache-2.0",
"MIT"
] | 75 | 2021-08-30T02:36:46.000Z | 2022-03-29T07:59:11.000Z | megfile/lib/stdio_handler.py | bbtfr/megfile | 7a0d4bd8fa6f52512e99dfd490bf404fb4f5ede0 | [
"Apache-2.0",
"MIT"
] | 9 | 2021-08-30T10:46:52.000Z | 2022-01-08T08:26:58.000Z | import sys
from io import UnsupportedOperation
from typing import AnyStr, Optional
from megfile.interfaces import Readable, Writable
class STDHandler:
def tell(self):
raise UnsupportedOperation('not tellable')
def _close(self):
pass
class STDReader(STDHandler, Readable):
""" megfile encapsulation of stdin. Avoid direct operation on sys.stdin
.. note ::
1. For convenience, use buffer by default
2. There is currently no demand and no design for seek, so seek is not allowed now
"""
def __init__(self, mode: str):
handler = sys.stdin
if 'b' in mode:
handler = handler.buffer
self._handler = handler
self._mode = mode
@property
def mode(self) -> str:
return self._mode
@property
def name(self) -> str:
return "stdin"
def read(self, size: Optional[int] = None) -> AnyStr:
return self._handler.read(size)
def readline(self, size: Optional[int] = None) -> AnyStr:
return self._handler.readline()
class STDWriter(STDHandler, Writable):
""" megfile encapsulation of stdin. Avoid direct operation on sys.stdin
.. note ::
1. For convenience, use buffer by default
2. There is currently no demand and no design for seek, so seek is not allowed now
"""
def __init__(self, path: str, mode: str):
if path == "stdio://2":
name = "stderr"
handler = sys.stderr
else:
name = "stdout"
handler = sys.stdout
if 'b' in mode:
handler = handler.buffer
self._handler = handler
self._name = name
self._mode = mode
@property
def mode(self) -> str:
return self._mode
@property
def name(self) -> str:
return self._name
def write(self, data: AnyStr) -> int:
return self._handler.write(data)
| 22.97619 | 90 | 0.604145 | 234 | 1,930 | 4.897436 | 0.311966 | 0.052356 | 0.052356 | 0.044503 | 0.593368 | 0.593368 | 0.593368 | 0.593368 | 0.593368 | 0.513089 | 0 | 0.003729 | 0.305181 | 1,930 | 83 | 91 | 23.253012 | 0.850858 | 0.22228 | 0 | 0.382979 | 0 | 0 | 0.02751 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0.234043 | false | 0.021277 | 0.085106 | 0.148936 | 0.531915 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 0 | 1 | 1 | 0 | 0 | 3 |
ae645048091ead434ffa8c67a0201efce2e83b64 | 68 | py | Python | kymatio/phaseexp1d/pyscatwave/scatwave/scattering1d/__init__.py | sixin-zh/kymatio_wph | 237c0d2009766cf83b2145420a14d3c6e90dc983 | [
"BSD-3-Clause"
] | 1 | 2019-11-08T22:48:28.000Z | 2019-11-08T22:48:28.000Z | kymatio/scattering1d/__init__.py | tingyuansen/kymatio | 0073d325ee508ac2236a992d9c2e29190d40595c | [
"BSD-3-Clause"
] | 3 | 2018-11-26T04:03:01.000Z | 2021-04-26T19:17:52.000Z | kymatio/scattering1d/__init__.py | tingyuansen/kymatio | 0073d325ee508ac2236a992d9c2e29190d40595c | [
"BSD-3-Clause"
] | 1 | 2019-03-16T04:42:17.000Z | 2019-03-16T04:42:17.000Z | __all__ = ['Scattering1D']
from .scattering1d import Scattering1D
| 13.6 | 38 | 0.779412 | 6 | 68 | 8.166667 | 0.666667 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0.050847 | 0.132353 | 68 | 4 | 39 | 17 | 0.779661 | 0 | 0 | 0 | 0 | 0 | 0.176471 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | false | 0 | 0.5 | 0 | 0.5 | 0 | 1 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 0 | 0 | 3 |
ae668eb8a275407e9ab21b8bc820a30b1d92b2c8 | 825 | py | Python | Python3/791.py | rakhi2001/ecom7 | 73790d44605fbd51e8f7e804b9808e364fcfc680 | [
"MIT"
] | 854 | 2018-11-09T08:06:16.000Z | 2022-03-31T06:05:53.000Z | Python3/791.py | rakhi2001/ecom7 | 73790d44605fbd51e8f7e804b9808e364fcfc680 | [
"MIT"
] | 29 | 2019-06-02T05:02:25.000Z | 2021-11-15T04:09:37.000Z | Python3/791.py | rakhi2001/ecom7 | 73790d44605fbd51e8f7e804b9808e364fcfc680 | [
"MIT"
] | 347 | 2018-12-23T01:57:37.000Z | 2022-03-12T14:51:21.000Z | __________________________________________________________________________________________________
sample 24 ms submission
class Solution:
def customSortString(self, s: str, t: str) -> str:
order, end = { c: i for i, c in enumerate(s) }, 100
return "".join(sorted(t, key=lambda c: order.get(c, end)))
__________________________________________________________________________________________________
sample 12896 kb submission
class Solution:
def customSortString(self, S: str, T: str) -> str:
order = dict()
i = 0
while len(S) > 0:
order[S[0]] = i
i += 1
S = S[1:]
return "".join(sorted(T, key=lambda x : order[x] if x in order else 0))
__________________________________________________________________________________________________
| 43.421053 | 98 | 0.705455 | 82 | 825 | 3.512195 | 0.439024 | 0.104167 | 0.159722 | 0.180556 | 0.611111 | 0.611111 | 0.430556 | 0.430556 | 0.430556 | 0.430556 | 0 | 0.02439 | 0.204848 | 825 | 18 | 99 | 45.833333 | 0.414634 | 0 | 0 | 0.277778 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | null | null | 0 | 0 | null | null | 0 | 0 | 0 | 0 | null | 0 | 0 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 3 |
ae7479634586747551e4d40882f78280c460768c | 222 | py | Python | real_trade/api/coincheck/trade.py | taka-mochi/cryptocurrency-autotrading | 16677018c793d7bd3fffdcd3575aecb3535dbd04 | [
"BSD-3-Clause"
] | 3 | 2018-05-22T22:45:23.000Z | 2020-02-13T16:45:03.000Z | real_trade/api/coincheck/trade.py | taka-mochi/cryptocurrency-autotrading | 16677018c793d7bd3fffdcd3575aecb3535dbd04 | [
"BSD-3-Clause"
] | null | null | null | real_trade/api/coincheck/trade.py | taka-mochi/cryptocurrency-autotrading | 16677018c793d7bd3fffdcd3575aecb3535dbd04 | [
"BSD-3-Clause"
] | null | null | null | from coincheck.servicebase import ServiceBase
class Trade(ServiceBase):
baseUrl = '/api/trades'
def all(self, params = {}):
return self.coinCheck.request(ServiceBase.METHOD_GET, self.baseUrl, params)
| 27.75 | 83 | 0.711712 | 25 | 222 | 6.28 | 0.68 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0.18018 | 222 | 7 | 84 | 31.714286 | 0.862637 | 0 | 0 | 0 | 0 | 0 | 0.04955 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0.2 | false | 0 | 0.2 | 0.2 | 1 | 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 | 1 | 0 | 0 | 0 | 3 |
ae7a17a272654e18a7f2b6b7510de652842a9e6b | 11,136 | py | Python | canvas/lib/dommatrixreadonly.py | elliottcarlson/pptx-canvas | 1223e4abbc30de76359c8deefd5463c4c0eb7712 | [
"MIT"
] | 6 | 2016-10-20T09:31:23.000Z | 2022-02-18T17:49:33.000Z | canvas/lib/dommatrixreadonly.py | elliottcarlson/pptx-canvas | 1223e4abbc30de76359c8deefd5463c4c0eb7712 | [
"MIT"
] | null | null | null | canvas/lib/dommatrixreadonly.py | elliottcarlson/pptx-canvas | 1223e4abbc30de76359c8deefd5463c4c0eb7712 | [
"MIT"
] | 4 | 2016-06-02T08:59:32.000Z | 2021-12-27T21:20:19.000Z | """
=================
DOMMatrixReadOnly
=================
"""
import numpy as np
import re
class DOMMatrixReadOnly(object):
"""
[Constructor(sequence<unrestricted double> numberSequence),
Exposed=(Window,Worker)]
interface DOMMatrixReadOnly {
// These attributes are simple aliases for certain elements of the 4x4
// matrix
readonly attribute unrestricted double a;
readonly attribute unrestricted double b;
readonly attribute unrestricted double c;
readonly attribute unrestricted double d;
readonly attribute unrestricted double e;
readonly attribute unrestricted double f;
readonly attribute unrestricted double m11;
readonly attribute unrestricted double m12;
readonly attribute unrestricted double m13;
readonly attribute unrestricted double m14;
readonly attribute unrestricted double m21;
readonly attribute unrestricted double m22;
readonly attribute unrestricted double m23;
readonly attribute unrestricted double m24;
readonly attribute unrestricted double m31;
readonly attribute unrestricted double m32;
readonly attribute unrestricted double m33;
readonly attribute unrestricted double m34;
readonly attribute unrestricted double m41;
readonly attribute unrestricted double m42;
readonly attribute unrestricted double m43;
readonly attribute unrestricted double m44;
readonly attribute boolean is2D;
readonly attribute boolean isIdentity;
// Immutable transform methods
DOMMatrix translate(unrestricted double tx, unrestricted double ty,
optional unrestricted double tz = 0);
DOMMatrix scale(unrestricted double scale, optional unrestricted double
originX = 0, optional unrestricted double originY = 0);
DOMMatrix scale3d(unrestricted double scale, optional unrestricted
double originX = 0, optional unrestricted double originY = 0,
optional unrestricted double originZ = 0);
DOMMatrix scaleNonUniform(unrestricted double scaleX, optional
unrestricted double scaleY = 1, optional unrestricted double
scaleZ = 1, optional unrestricted double originX = 0, optional
unrestricted double originY = 0, optional unrestricted double
originZ = 0);
DOMMatrix rotate(unrestricted double angle, optional unrestricted double
originX = 0, optional unrestricted double originY = 0);
DOMMatrix rotateFromVector(unrestricted double x, unrestricted double y);
DOMMatrix rotateAxisAngle(unrestricted double x, unrestricted double y,
unrestricted double z, unrestricted double angle);
DOMMatrix skewX(unrestricted double sx);
DOMMatrix skewY(unrestricted double sy);
DOMMatrix multiply(DOMMatrix other);
DOMMatrix flipX();
DOMMatrix flipY();
DOMMatrix inverse();
DOMPoint transformPoint(optional DOMPointInit point);
Float32Array toFloat32Array();
Float64Array toFloat64Array();
stringifier;
};
"""
#_is2D = False
def __init__(self, *args, **kwargs):
"""
The DOMMatrixReadOnly(sequence<unrestricted double> numberSequence)
constructor, when invoked, must run the following steps:
If numberSequence has 6 elements
* Set m11 element, m12 element, m21 element, m22 element, m41
element, m42 element to the values of numberSequence in order
starting with the first value. Furthermore, set m31 element, m32
element, m13 element, m23 element, m43 element, m14 element, m24
element, m34 element to 0 and m33 element, m44 element to 1.
* Set is2D to true.
* Return the new DOMMatrixReadOnly object.
If numberSequence has 16 elements
* Set m11 element to m44 element to the values of numberSequence in
column-major order.
* Set is2D to false.
* Return the new DOMMatrixReadOnly object.
Otherwise
Throw a TypeError exception.
Source: https://www.w3.org/TR/geometry-1/#dommatrixreadonly-constructors
"""
from .dommatrix import DOMMatrix
object.__setattr__(self, 'DOMMatrix', DOMMatrix)
object.__setattr__(self, '_matrix', {
'm11': 1, 'm12': 0, 'm13': 0, 'm14': 0,
'm21': 0, 'm22': 1, 'm23': 0, 'm24': 0,
'm31': 0, 'm32': 0, 'm33': 1, 'm34': 0,
'm41': 0, 'm42': 0, 'm43': 0, 'm44': 1
})
if len(args) is 6:
self._matrix['m11'] = args[0]
self._matrix['m12'] = args[1]
self._matrix['m21'] = args[2]
self._matrix['m22'] = args[3]
self._matrix['m41'] = args[4]
self._matrix['m42'] = args[5]
# Due to __setattr__ overloading in DOMMatrix
object.__setattr__(self, '_is2D', True)
elif len(args) is 16:
self._matrix['m11'] = args[0]
self._matrix['m12'] = args[1]
self._matrix['m13'] = args[2]
self._matrix['m14'] = args[3]
self._matrix['m21'] = args[4]
self._matrix['m22'] = args[5]
self._matrix['m23'] = args[6]
self._matrix['m24'] = args[7]
self._matrix['m31'] = args[8]
self._matrix['m32'] = args[9]
self._matrix['m33'] = args[10]
self._matrix['m34'] = args[11]
self._matrix['m41'] = args[12]
self._matrix['m42'] = args[13]
self._matrix['m43'] = args[14]
self._matrix['m44'] = args[15]
# Due to __setattr__ overloading in DOMMatrix
object.__setattr__(self, '_is2D', False)
elif kwargs is not None and bool(kwargs):
for key, value in kwargs.items():
match = re.search(r'^m[1-4][1-4]$', key)
if match and key in self._matrix:
self._matrix[key] = value
else:
raise TypeError()
else:
raise TypeError()
@property
def m11(self):
return self._matrix['m11']
@property
def m12(self):
return self._matrix['m12']
@property
def m13(self):
return self._matrix['m13']
@property
def m14(self):
return self._matrix['m14']
@property
def m21(self):
return self._matrix['m21']
@property
def m22(self):
return self._matrix['m22']
@property
def m23(self):
return self._matrix['m23']
@property
def m24(self):
return self._matrix['m24']
@property
def m31(self):
return self._matrix['m31']
@property
def m32(self):
return self._matrix['m32']
@property
def m33(self):
return self._matrix['m33']
@property
def m34(self):
return self._matrix['m34']
@property
def m41(self):
return self._matrix['m41']
@property
def m42(self):
return self._matrix['m42']
@property
def m43(self):
return self._matrix['m43']
@property
def m44(self):
return self._matrix['m44']
@property
def a(self):
return self._matrix['m11']
@property
def b(self):
return self._matrix['m12']
@property
def c(self):
return self._matrix['m21']
@property
def d(self):
return self._matrix['m22']
@property
def e(self):
return self._matrix['m41']
@property
def f(self):
return self._matrix['m42']
@property
def is2D(self):
return self._is2D
@property
def isIdentity(self):
"""
Returns true if m12, m13, m14, m21, m23, m24, m31, m32, m34, m41, m42,
m43 are 0 and m11, m22, m33, m44 are 1. Otherwise returns false.
"""
_m = self._matrix
if (_m['m12'] == _m['m13'] == _m['m14'] == _m['m21'] ==
_m['m23'] == _m['m24'] == _m['m31'] == _m['m32'] ==
_m['m34'] == _m['m41'] == _m['m42'] == _m['m42'] == 0) and (
_m['m11'] == _m['m22'] == _m['m33'] == _m['m44'] == 1):
return True
return False
def _np_array(self, other=None):
if other is not None:
_m = other._matrix
else:
_m = self._matrix
return np.array([
[ _m['m11'], _m['m12'], _m['m13'], _m['m14'] ],
[ _m['m21'], _m['m22'], _m['m23'], _m['m24'] ],
[ _m['m31'], _m['m32'], _m['m33'], _m['m34'] ],
[ _m['m41'], _m['m42'], _m['m43'], _m['m44'] ]
])
def translate(self, x, y):
#from .dommatrix import DOMMatrix
_other = self.DOMMatrix(1, 0, 0, 1, x, y)
return self.multiply(_other)
def scale(self, x, y):
#from .dommatrix import DOMMatrix
_other = self.DOMMatrix(x, 0, 0, 0, 0, y, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1)
print(_other)
return self.multiply(_other)
def multiply(self, other):
#from .dommatrix import DOMMatrix
_m = np.dot(self._np_array(other), self._np_array())
return self.DOMMatrix(*_m.flatten())
def translateSelf(self, tx, ty, tz=0):
pass
def scale3d(self, scale, ox=0, oy=0, oz=0):
pass
def scaleNonUniform(self, sx, sy=1, sz=1, ox=0, oy=0, oz=0):
#from .dommatrix import DOMMatrix
if sx == 1.0 and sy == 1.0 and sz == 1.0:
return self
_other = self.DOMMatrix(**self._matrix)
_other.translate(ox, oy) #, oz)
if not self.is2D or sz != 1.0 or oz != 0:
## TODO Ensure3DMatrix
_m2 = self.DOMMatrix(sx, 0, 0, 0, 0, sy, 0, 0, 0, 0, sz, 0, 0, 0, 0, 0)
else:
_m2 = self.DOMMatrix(sx, 0, 0, 0, sy, 0)
_out = _m2.multiply(_other)
_out2 = _out.translate(-ox, -oy) # , -oz)
return _out2
pass
def rotateSelf(self, angle, originX=0, originY=0):
pass
def rotateFromVectorSelf(self, x, y):
pass
def rotateAxisAngleSelf(self, x, y, z, angle):
pass
def skewXSelf(self, sx):
pass
def skewYSelf(self, sy):
pass
def invertSelf(self):
pass
def setMatrixValue(self, transformList):
pass
def __str__(self):
r = ""
r = r + "[ %s, %s, %s, %s ],\n" % (self.m11, self.m12, self.m13, self.m14)
r = r + "[ %s, %s, %s, %s ],\n" % (self.m21, self.m22, self.m23, self.m24)
r = r + "[ %s, %s, %s, %s ],\n" % (self.m31, self.m32, self.m33, self.m34)
r = r + "[ %s, %s, %s, %s ]\n" % (self.m41, self.m42, self.m43, self.m44)
r = r + "\n"
r = r + "a: %s\n" % self.a
r = r + "b: %s\n" % self.b
r = r + "c: %s\n" % self.c
r = r + "d: %s\n" % self.d
r = r + "e: %s\n" % self.e
r = r + "f: %s\n" % self.f
return r
| 31.546742 | 83 | 0.558639 | 1,315 | 11,136 | 4.620532 | 0.156654 | 0.151086 | 0.052995 | 0.126728 | 0.266129 | 0.243252 | 0.227781 | 0.138084 | 0.130843 | 0.119816 | 0 | 0.066544 | 0.318517 | 11,136 | 352 | 84 | 31.636364 | 0.734089 | 0.378592 | 0 | 0.314136 | 0 | 0 | 0.068326 | 0 | 0 | 0 | 0 | 0.002841 | 0 | 1 | 0.209424 | false | 0.052356 | 0.015707 | 0.120419 | 0.397906 | 0.005236 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 1 | 0 | 1 | 0 | 0 | 0 | 3 |
88156214dc1d99b87a5a6e20ff630a46d1e53f84 | 797 | py | Python | agentnet/environment/__init__.py | mraihan19/AgentNet | 240b7ac351d5c7a156a6c9c25432d5a7afffe3cc | [
"MIT"
] | 337 | 2016-04-20T09:34:06.000Z | 2022-03-23T10:09:15.000Z | agentnet/environment/__init__.py | 17minutes/AgentNet | a0df28f6110f0e492240e0264f8ccce6cde18f99 | [
"MIT"
] | 58 | 2016-04-04T10:21:10.000Z | 2017-08-09T07:47:37.000Z | agentnet/environment/__init__.py | 17minutes/AgentNet | a0df28f6110f0e492240e0264f8ccce6cde18f99 | [
"MIT"
] | 88 | 2016-04-28T01:18:11.000Z | 2021-12-05T02:48:28.000Z | """
Environment is an MDP abstraction that defines which observations does agent get and how does environment external state
change given agent actions and previous state.
There's a base class for environment definition, as well as special environments for Experience Replay.
When designing your own experiment,
- if it is done entirely in theano, implement BaseEnvironment. See ./experiments/wikicat or boolean_reasoning for example.
- if it isn't (which is probably the case), use SessionPoolEnvironment to train from recorded interactions as in Atari examples
"""
from __future__ import division, print_function, absolute_import
from .base import BaseEnvironment, EnvironmentStepLayer
from .session_pool import SessionPoolEnvironment
from .session_batch import SessionBatchEnvironment
| 41.947368 | 128 | 0.824341 | 106 | 797 | 6.113208 | 0.735849 | 0.012346 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0.139272 | 797 | 18 | 129 | 44.277778 | 0.944606 | 0.706399 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | true | 0 | 1 | 0 | 1 | 0.25 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 1 | 0 | 1 | 0 | 0 | 3 |
88279a7017aa712660762c7e1168632ed57352f7 | 588 | py | Python | src/auth/serializers/identifying_document_serializer.py | Midburn/midburn-profiles-django | e124a617986931baed0b17f5d7a1ba6c7d5528e9 | [
"MIT"
] | null | null | null | src/auth/serializers/identifying_document_serializer.py | Midburn/midburn-profiles-django | e124a617986931baed0b17f5d7a1ba6c7d5528e9 | [
"MIT"
] | 20 | 2019-10-05T13:23:47.000Z | 2022-03-11T23:37:37.000Z | src/auth/serializers/identifying_document_serializer.py | Midburn/midburn-profiles-django | e124a617986931baed0b17f5d7a1ba6c7d5528e9 | [
"MIT"
] | 1 | 2019-09-30T11:40:45.000Z | 2019-09-30T11:40:45.000Z | from rest_framework import serializers
from src.auth.auth_models.identifying_document import IdentifyingDocument
class IDSerializer(serializers.ModelSerializer):
user = serializers.HiddenField(
default=serializers.CurrentUserDefault()
)
def validate(self, data):
if data['identification_type'] != 'tz':
return data
else:
#TODO: validate Israeli TZ
return data
class Meta:
model = IdentifyingDocument
fields = ('id', 'identification_number', 'identification_type', 'passport_country', 'user')
| 29.4 | 99 | 0.678571 | 55 | 588 | 7.127273 | 0.672727 | 0.091837 | 0.061224 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0.236395 | 588 | 19 | 100 | 30.947368 | 0.873051 | 0.042517 | 0 | 0.142857 | 0 | 0 | 0.147687 | 0.037367 | 0 | 0 | 0 | 0.052632 | 0 | 1 | 0.071429 | false | 0.071429 | 0.142857 | 0 | 0.571429 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | null | 0 | 0 | 1 | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 1 | 0 | 0 | 3 |
884335dc7d76a819c2e9227ff5951cb34d066677 | 320 | py | Python | LineSync/__init__.py | l-mda/AsyncLine | 161044424ec17d683651ff26a4f6ca49c905760c | [
"MIT"
] | 2 | 2019-07-31T13:11:54.000Z | 2019-10-10T03:19:57.000Z | LineSync/__init__.py | l-mda/AsyncLine | 161044424ec17d683651ff26a4f6ca49c905760c | [
"MIT"
] | null | null | null | LineSync/__init__.py | l-mda/AsyncLine | 161044424ec17d683651ff26a4f6ca49c905760c | [
"MIT"
] | 2 | 2019-07-31T13:11:55.000Z | 2021-07-09T22:24:22.000Z | from .connections import Connection
from .main import LineNext
from .proto import *
from .filters import *
from .utils import *
from .auth import *
from .models import *
from .lib.Gen.ttypes import *
__author__ = "Dyseo"
__from_source__ = "Anysz"
__base__ = "Anysz"
__fixing__ = "Dyseo"
__version__ = "1.3" | 22.857143 | 36 | 0.7125 | 40 | 320 | 5.175 | 0.575 | 0.241546 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0.007692 | 0.1875 | 320 | 14 | 37 | 22.857143 | 0.788462 | 0 | 0 | 0 | 0 | 0 | 0.074675 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | false | 0 | 0.615385 | 0 | 0.615385 | 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 | 1 | 0 | 0 | 3 |
88482868aa55125971f66fa4a5ec7cfaf7859847 | 168 | py | Python | setup.py | huangyh09/limix | bed5b8e0aaa9b11f19bdd13b76d21510e56064be | [
"Apache-2.0"
] | 93 | 2017-05-25T21:54:45.000Z | 2022-03-30T14:51:01.000Z | setup.py | huangyh09/limix | bed5b8e0aaa9b11f19bdd13b76d21510e56064be | [
"Apache-2.0"
] | 90 | 2017-04-20T16:59:41.000Z | 2022-02-02T17:40:58.000Z | setup.py | huangyh09/limix | bed5b8e0aaa9b11f19bdd13b76d21510e56064be | [
"Apache-2.0"
] | 28 | 2017-05-31T21:59:19.000Z | 2022-02-09T18:12:51.000Z | from setuptools import setup
if __name__ == "__main__":
console_scripts = ["limix = limix:_cli.cli"]
setup(entry_points=dict(console_scripts=console_scripts))
| 28 | 61 | 0.75 | 21 | 168 | 5.380952 | 0.666667 | 0.371681 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0.136905 | 168 | 5 | 62 | 33.6 | 0.77931 | 0 | 0 | 0 | 0 | 0 | 0.178571 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | false | 0 | 0.25 | 0 | 0.25 | 0 | 1 | 0 | 0 | null | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 3 |
8852af946407b78e06fbdc5cbc9a445d918c4d2d | 319 | py | Python | ievv_opensource/utils/desktopnotifications/base.py | appressoas/ievv_opensource | 63e87827952ddc8f6f86145b79478ef21d6a0990 | [
"BSD-3-Clause"
] | null | null | null | ievv_opensource/utils/desktopnotifications/base.py | appressoas/ievv_opensource | 63e87827952ddc8f6f86145b79478ef21d6a0990 | [
"BSD-3-Clause"
] | 37 | 2015-10-26T09:14:12.000Z | 2022-02-10T10:35:33.000Z | ievv_opensource/utils/desktopnotifications/base.py | appressoas/ievv_opensource | 63e87827952ddc8f6f86145b79478ef21d6a0990 | [
"BSD-3-Clause"
] | 1 | 2015-11-06T07:56:34.000Z | 2015-11-06T07:56:34.000Z |
class AbstractNotification(object):
def show_message(self, title, message):
"""
Show message in the notification system of the OS.
Parameters:
title: The title of the notification.
message: The notification message.
"""
raise NotImplementedError()
| 24.538462 | 58 | 0.61442 | 31 | 319 | 6.290323 | 0.548387 | 0.230769 | 0.225641 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0.316614 | 319 | 12 | 59 | 26.583333 | 0.894495 | 0.451411 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0.333333 | false | 0 | 0 | 0 | 0.666667 | 0 | 0 | 0 | 0 | null | 1 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 3 |
88558dea4dc8bffaaa123559ea69c944fd27f66f | 574 | py | Python | py_abac/policy/conditions/logic/any_of.py | farhah/py-abac | 588ea2bba1cee4f6c234b5892d46faa34b2fc6e4 | [
"Apache-2.0"
] | 47 | 2019-10-17T03:23:01.000Z | 2022-02-26T03:27:03.000Z | py_abac/policy/conditions/logic/any_of.py | farhah/py-abac | 588ea2bba1cee4f6c234b5892d46faa34b2fc6e4 | [
"Apache-2.0"
] | 17 | 2020-02-24T02:17:34.000Z | 2022-02-15T20:11:19.000Z | py_abac/policy/conditions/logic/any_of.py | ketgo/pyabac | 8a44107a00f712bbb9c6cd3ecad155ef696cf035 | [
"Apache-2.0"
] | 10 | 2019-12-24T04:13:21.000Z | 2021-08-01T08:21:41.000Z | """
Logical OR conditions
"""
from marshmallow import post_load
from .base import LogicCondition, LogicConditionSchema
class AnyOf(LogicCondition):
"""
Condition for any of sub-rules are satisfied
"""
def is_satisfied(self, ctx) -> bool:
return any(value.is_satisfied(ctx) for value in self.values)
class AnyOfSchema(LogicConditionSchema):
"""
JSON schema for any of logical condition
"""
@post_load
def post_load(self, data, **_): # pylint: disable=missing-docstring,no-self-use
return AnyOf(**data)
| 21.259259 | 84 | 0.672474 | 68 | 574 | 5.588235 | 0.588235 | 0.063158 | 0.042105 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0.226481 | 574 | 26 | 85 | 22.076923 | 0.855856 | 0.268293 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0.222222 | false | 0 | 0.222222 | 0.222222 | 0.888889 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 0 | 1 | 1 | 0 | 0 | 3 |
889da015204c80ce918f4392cfc5a260118ec022 | 231 | py | Python | tarefas-poo/lista-01/calculos/programa.py | victoriaduarte/POO_UFSC | 0c65b4f26383d1e3038d8469bd91fd2c0cb98c1a | [
"MIT"
] | null | null | null | tarefas-poo/lista-01/calculos/programa.py | victoriaduarte/POO_UFSC | 0c65b4f26383d1e3038d8469bd91fd2c0cb98c1a | [
"MIT"
] | null | null | null | tarefas-poo/lista-01/calculos/programa.py | victoriaduarte/POO_UFSC | 0c65b4f26383d1e3038d8469bd91fd2c0cb98c1a | [
"MIT"
] | null | null | null | # --------------------------
# UFSC - CTC - INE - INE5603
# Exercício calculos
# --------------------------
# programa pincipal
from view.interface_com_usuario import InterfaceComUsuario
iu = InterfaceComUsuario()
iu.interaja()
| 21 | 59 | 0.584416 | 19 | 231 | 7 | 0.894737 | 0.315789 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0.019802 | 0.125541 | 231 | 10 | 60 | 23.1 | 0.638614 | 0.506494 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | false | 0 | 0.333333 | 0 | 0.333333 | 0 | 1 | 0 | 0 | null | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 0 | 0 | 3 |
88a6a4335da69c5a5f42caaeb3ae349dae80b9bb | 924 | py | Python | tests/test_challange2.py | joanlopez/tuenti-contest-5 | 4bb810013b75a6f0ba2892ecacd5bc6f2c2805b0 | [
"MIT"
] | null | null | null | tests/test_challange2.py | joanlopez/tuenti-contest-5 | 4bb810013b75a6f0ba2892ecacd5bc6f2c2805b0 | [
"MIT"
] | null | null | null | tests/test_challange2.py | joanlopez/tuenti-contest-5 | 4bb810013b75a6f0ba2892ecacd5bc6f2c2805b0 | [
"MIT"
] | null | null | null | from unittest import TestCase
from src.challange2.prime import Primes
class TestChallange2(TestCase):
def test_that_prime_factors_of_315_are_3_3_5_and_7(self):
self.assertEquals(Primes.get_primes_of(315), [3, 3, 5, 7])
def test_that_6_is_an_almost_prime(self):
self.assertTrue(Primes.is_almost_prime(6))
def test_that_25_is_an_almost_prime(self):
self.assertTrue(Primes.is_almost_prime(25))
def test_that_17_is_not_an_almost_prime(self):
self.assertFalse(Primes.is_almost_prime(17))
def test_that_81_is_not_an_almost_prime(self):
self.assertFalse(Primes.is_almost_prime(81))
def test_that_there_are_4_almost_primes_between_1_and_10(self):
self.assertEquals(4, len(Primes.almost_primes_between(1, 10)))
def test_that_there_are_3_almost_primes_between_10_and_20(self):
self.assertEquals(3, len(Primes.almost_primes_between(10, 20)))
| 34.222222 | 71 | 0.768398 | 150 | 924 | 4.26 | 0.273333 | 0.137715 | 0.120501 | 0.106416 | 0.485133 | 0.338028 | 0.338028 | 0.338028 | 0.338028 | 0.338028 | 0 | 0.060606 | 0.142857 | 924 | 26 | 72 | 35.538462 | 0.746212 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0.411765 | 1 | 0.411765 | false | 0 | 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 | 1 | 0 | 1 | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 3 |
88b085fa1d9dcc36b484a1a49396577252b876eb | 170 | pyde | Python | sketch_191010c.pyde | klimenkodasha/2019-fall-polytech-cs | 19777f6adf6848af257a74db751e96f914a5f7e6 | [
"MIT"
] | null | null | null | sketch_191010c.pyde | klimenkodasha/2019-fall-polytech-cs | 19777f6adf6848af257a74db751e96f914a5f7e6 | [
"MIT"
] | null | null | null | sketch_191010c.pyde | klimenkodasha/2019-fall-polytech-cs | 19777f6adf6848af257a74db751e96f914a5f7e6 | [
"MIT"
] | null | null | null | def setup():
size(500,500);
background(0);
smooth();
noLoop();
def draw():
strokeWeight(10);
stroke(200);
line(10, 10, 400, 400)
| 14.166667 | 27 | 0.5 | 20 | 170 | 4.25 | 0.75 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0.191304 | 0.323529 | 170 | 11 | 28 | 15.454545 | 0.547826 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0.222222 | true | 0 | 0 | 0 | 0.222222 | 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 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 3 |
ee0475e1a4461205fe0067a99777c052eb86bb64 | 597 | py | Python | word_vectorizer/tests/unittest/models/test_modelDataLoader.py | RodSernaPerez/WordVectorizer | 097b2ccfc284b39ad43f56047ee25e393b7525ec | [
"ECL-2.0",
"Apache-2.0"
] | null | null | null | word_vectorizer/tests/unittest/models/test_modelDataLoader.py | RodSernaPerez/WordVectorizer | 097b2ccfc284b39ad43f56047ee25e393b7525ec | [
"ECL-2.0",
"Apache-2.0"
] | null | null | null | word_vectorizer/tests/unittest/models/test_modelDataLoader.py | RodSernaPerez/WordVectorizer | 097b2ccfc284b39ad43f56047ee25e393b7525ec | [
"ECL-2.0",
"Apache-2.0"
] | null | null | null | from unittest import TestCase
from unittest.mock import patch, MagicMock
from word_vectorizer.models.model_data import ModelData
from word_vectorizer.models.model_data_loader import ModelDataLoader
class TestModelDataLoader(TestCase):
@patch('word_vectorizer.models.model_data_loader.ModelData')
def test_load_data_OK(self, mock_data_model):
mock_data_model.return_value = MagicMock(ModelData)
data_models = ModelDataLoader.load_data()
self.assertTrue(isinstance(data_models, list))
self.assertTrue(all([isinstance(x, ModelData) for x in data_models]))
| 37.3125 | 77 | 0.788945 | 76 | 597 | 5.934211 | 0.407895 | 0.093126 | 0.133038 | 0.166297 | 0.237251 | 0.237251 | 0 | 0 | 0 | 0 | 0 | 0 | 0.135678 | 597 | 15 | 78 | 39.8 | 0.874031 | 0 | 0 | 0 | 0 | 0 | 0.083752 | 0.083752 | 0 | 0 | 0 | 0 | 0.181818 | 1 | 0.090909 | false | 0 | 0.363636 | 0 | 0.545455 | 0 | 0 | 0 | 0 | null | 0 | 0 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 1 | 0 | 0 | 3 |
ee277a916a47b17afd4b5ede111ad49e9a3b5039 | 729 | py | Python | server/read_big_file.py | tangchengdong/tangchengdong.github.io | 62cc305481bc2df83d9db77be22ea13fcc181193 | [
"MIT"
] | null | null | null | server/read_big_file.py | tangchengdong/tangchengdong.github.io | 62cc305481bc2df83d9db77be22ea13fcc181193 | [
"MIT"
] | 1 | 2020-12-29T03:16:20.000Z | 2020-12-29T03:16:20.000Z | server/read_big_file.py | tangchengdong/tangchengdong.github.io | 62cc305481bc2df83d9db77be22ea13fcc181193 | [
"MIT"
] | null | null | null | def readlines(f, separator):
'''
读取大文件方法
:param f: 文件句柄
:param separator: 每一行的分隔符
:return:
'''
buf = ''
while True:
while separator in buf:
position = buf.index(separator) # 分隔符的位置
yield buf[:position] # 切片, 从开始位置到分隔符位置
buf = buf[position + len(separator):] # 再切片,将yield的数据切掉,保留剩下的数据
chunk = f.read(4096) # 一次读取4096的数据到buf中
if not chunk: # 如果没有读到数据
yield buf # 返回buf中的数据
break # 结束
buf += chunk # 如果read有数据 ,将read到的数据加入到buf中
with open('text.txt', encoding='utf-8') as f:
for line in readlines(f, '|||'):
# 为什么readlines函数能够使用for循环遍历呢, 因为这个函数里面有yield关键字呀, 有它就是一个生成器函数 ......
print(line)
| 729 | 729 | 0.578875 | 74 | 729 | 5.702703 | 0.662162 | 0.078199 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0.017751 | 0.304527 | 729 | 1 | 729 | 729 | 0.814596 | 0.246914 | 0 | 0 | 0 | 0 | 0.035242 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | null | null | 0 | 0 | null | null | 0.066667 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 3 |
ee4435e762a4141f5ea02e73ec4eb50b306f6d66 | 356 | py | Python | file_processing.py | kokapelli/Snake-AI | d214bac62b67e5cef5bda571aea9849e8a417696 | [
"MIT"
] | null | null | null | file_processing.py | kokapelli/Snake-AI | d214bac62b67e5cef5bda571aea9849e8a417696 | [
"MIT"
] | null | null | null | file_processing.py | kokapelli/Snake-AI | d214bac62b67e5cef5bda571aea9849e8a417696 | [
"MIT"
] | null | null | null | import json
# Load Game configurations
def loadGameConfig() -> dict:
with open('configurations/config.json') as json_file:
config = json.load(json_file)
return config
# Load network parameter config
def loadParams() -> dict:
with open('configurations/params.json') as json_file:
params = json.load(json_file)
return params | 27.384615 | 57 | 0.707865 | 45 | 356 | 5.511111 | 0.4 | 0.129032 | 0.096774 | 0.209677 | 0.177419 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0.196629 | 356 | 13 | 58 | 27.384615 | 0.867133 | 0.151685 | 0 | 0 | 0 | 0 | 0.173333 | 0.173333 | 0 | 0 | 0 | 0 | 0 | 1 | 0.222222 | false | 0 | 0.111111 | 0 | 0.555556 | 0 | 0 | 0 | 0 | null | 0 | 0 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 3 |
ee6d9e53dee1f7bd775a4b3d65ca783a8b49ad1b | 1,104 | py | Python | models/contract.py | muslax/aces-api | 9d56f68277c284bd6985e13dca7f993e9db1b70f | [
"MIT"
] | null | null | null | models/contract.py | muslax/aces-api | 9d56f68277c284bd6985e13dca7f993e9db1b70f | [
"MIT"
] | 1 | 2020-08-17T04:17:58.000Z | 2020-08-17T04:17:58.000Z | models/contract.py | muslax/aces-api | 9d56f68277c284bd6985e13dca7f993e9db1b70f | [
"MIT"
] | 2 | 2020-08-16T11:59:34.000Z | 2020-08-26T05:35:07.000Z | from typing import List
from datetime import date, datetime
from pydantic import BaseModel
from models.base import DBModel, WithClient, WithLicense
from models.client import Contact
# Module pricing model
class PackagePricing(BaseModel):
name: str = None
priceLevel1: int = None
priceLevel2: int = None
priceLevel3: int = None
# Shared properties
class ContractBase(BaseModel):
title: str = None
startDate: str = None
endDate: str = None
terms: str = None
status: str = None
type: str = None
contact: Contact = None
admin: str = None
pricing: List[PackagePricing] = []
class ContractRefs(BaseModel):
license: str
clientId: str
# Properties to receive on contract creation
class ContractCreate(ContractBase):
title: str
# Properties to persist in database
class ContractInDB(ContractCreate, WithClient, WithLicense):
pass
# Properties to receive on contract update
class ContractUpdate(ContractBase):
pricing: List[PackagePricing] = None
pass
# Properties to return
class Contract(ContractInDB, DBModel):
pass
| 20.444444 | 60 | 0.725543 | 126 | 1,104 | 6.357143 | 0.428571 | 0.069913 | 0.062422 | 0.052434 | 0.072409 | 0 | 0 | 0 | 0 | 0 | 0 | 0.003436 | 0.209239 | 1,104 | 53 | 61 | 20.830189 | 0.914089 | 0.160326 | 0 | 0.09375 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | true | 0.09375 | 0.15625 | 0 | 0.90625 | 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 | 1 | 0 | 0 | 3 |
c99426238bc9443767fa9effbff1c1ea20b26cf0 | 258 | py | Python | simplemath2.py | csamiselo/PythonScripsts | 8ac0c086fca691d9c2dd0d8f758059c02f44e3e4 | [
"MIT"
] | null | null | null | simplemath2.py | csamiselo/PythonScripsts | 8ac0c086fca691d9c2dd0d8f758059c02f44e3e4 | [
"MIT"
] | null | null | null | simplemath2.py | csamiselo/PythonScripsts | 8ac0c086fca691d9c2dd0d8f758059c02f44e3e4 | [
"MIT"
] | null | null | null | # csamiselo@github.com 15.10.2019
print("This is how i count my livestock")
print("Goats",12 + 30 + 60)
print("Cows", 13 + 15 + 10)
print ("Layers" ,1000 + 250 + 503 )
print ("Are the layers more than the goats")
print (12 + 30 + 60 < 1000 + 250 +503 )
| 19.846154 | 44 | 0.631783 | 44 | 258 | 3.704545 | 0.636364 | 0.04908 | 0.07362 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0.22549 | 0.209302 | 258 | 12 | 45 | 21.5 | 0.573529 | 0.120155 | 0 | 0 | 0 | 0 | 0.361607 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | true | 0 | 0 | 0 | 0 | 1 | 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 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 0 | 0 | 1 | 0 | 3 |
c994b46f59b511e7983256305291ea22eac2693c | 618 | py | Python | app.py | TheBotPlatform/POCInteractionEndPoint | d044a4d99d86c50fff635dad188130d21c3bc8fb | [
"MIT"
] | null | null | null | app.py | TheBotPlatform/POCInteractionEndPoint | d044a4d99d86c50fff635dad188130d21c3bc8fb | [
"MIT"
] | null | null | null | app.py | TheBotPlatform/POCInteractionEndPoint | d044a4d99d86c50fff635dad188130d21c3bc8fb | [
"MIT"
] | null | null | null | from thebotplatform import getBotResponse, BearerTokenGrab, CreateUserID
from flask import Flask, render_template, request
app = Flask(__name__)
app.config['SEND_FILE_MAX_AGE_DEFAULT'] = 0
app.static_folder = 'static'
@app.route("/")
def home():
return render_template("index.html")
@app.route("/example")
def testexample():
return render_template("example.html")
@app.route("/createuser")
def create_user():
return CreateUserID()
@app.route("/get")
def get_bot_response():
return getBotResponse(request.args.get('userID') , request.args.get('msg'))
if __name__ == "__main__":
app.run()
| 22.888889 | 79 | 0.723301 | 77 | 618 | 5.506494 | 0.532468 | 0.075472 | 0.09434 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0.001855 | 0.127832 | 618 | 26 | 80 | 23.769231 | 0.784787 | 0 | 0 | 0 | 0 | 0 | 0.152104 | 0.040453 | 0 | 0 | 0 | 0 | 0 | 1 | 0.210526 | false | 0 | 0.105263 | 0.210526 | 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 | 1 | 0 | 0 | 0 | 1 | 1 | 0 | 0 | 3 |
c9986a013735421e1b17254514a60b2e2193b959 | 151 | py | Python | orange3/doc/data-mining-library/source/reference/code/imputation-default.py | rgschmitz1/BioDepot-workflow-builder | f74d904eeaf91ec52ec9b703d9fb38e9064e5a66 | [
"MIT"
] | 54 | 2017-01-08T17:21:49.000Z | 2021-11-02T08:46:07.000Z | orange3/doc/data-mining-library/source/reference/code/imputation-default.py | Synthia-3/BioDepot-workflow-builder | 4ee93abe2d79465755e82a145af3b6a6e1e79fd4 | [
"MIT"
] | 22 | 2017-03-28T06:03:14.000Z | 2021-07-28T05:43:55.000Z | orange3/doc/data-mining-library/source/reference/code/imputation-default.py | Synthia-3/BioDepot-workflow-builder | 4ee93abe2d79465755e82a145af3b6a6e1e79fd4 | [
"MIT"
] | 21 | 2017-01-26T21:12:09.000Z | 2022-01-31T21:34:59.000Z | from Orange.data import Table
from Orange.preprocess import Impute
data = Table("heart-disease.tab")
imputer = Impute()
impute_heart = imputer(data)
| 18.875 | 36 | 0.774834 | 21 | 151 | 5.52381 | 0.52381 | 0.172414 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0.125828 | 151 | 7 | 37 | 21.571429 | 0.878788 | 0 | 0 | 0 | 0 | 0 | 0.112583 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | false | 0 | 0.4 | 0 | 0.4 | 0 | 1 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 0 | 0 | 3 |
c9afe0b4c494c13adb24a558e2baa809d9a553fd | 1,143 | py | Python | Others/medium/SpiralTraverse.py | GeorgianBadita/algorithmic-problems | 6b260050b7a1768b5e47a1d7d4ef7138a52db210 | [
"MIT"
] | 1 | 2021-07-05T16:32:14.000Z | 2021-07-05T16:32:14.000Z | Others/medium/SpiralTraverse.py | GeorgianBadita/algorithmic-problems | 6b260050b7a1768b5e47a1d7d4ef7138a52db210 | [
"MIT"
] | null | null | null | Others/medium/SpiralTraverse.py | GeorgianBadita/algorithmic-problems | 6b260050b7a1768b5e47a1d7d4ef7138a52db210 | [
"MIT"
] | 1 | 2021-05-14T15:40:09.000Z | 2021-05-14T15:40:09.000Z | def spiralTraverse(array):
num_elements = len(array) * len(array[0])
n = len(array)
m = len(array[0])
it = 0
result = []
while num_elements > 0:
# Up side
for j in range(it, m - it):
result.append(array[it][j])
num_elements -= 1
if num_elements == 0:
break
if num_elements == 0:
continue
# Right side
for i in range(it + 1, n - it):
result.append(array[i][m - 1 - it])
num_elements -= 1
if num_elements == 0:
break
if num_elements == 0:
continue
# Bottom side
for j in reversed(range(it, m - 1 - it)):
result.append(array[n - it - 1][j])
num_elements -= 1
if num_elements == 0:
break
if num_elements == 0:
continue
# Left side
for i in reversed(range(it + 1, n - it - 1)):
result.append(array[i][it])
num_elements -= 1
if num_elements == 0:
break
it += 1
return result
| 24.847826 | 53 | 0.449694 | 141 | 1,143 | 3.553191 | 0.205674 | 0.285429 | 0.191617 | 0.195609 | 0.43513 | 0.391218 | 0.391218 | 0.391218 | 0.391218 | 0.321357 | 0 | 0.0347 | 0.445319 | 1,143 | 45 | 54 | 25.4 | 0.755521 | 0.034996 | 0 | 0.514286 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0.028571 | false | 0 | 0 | 0 | 0.057143 | 0 | 0 | 0 | 0 | null | 1 | 1 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 3 |
c9c4558073b2ff6042a0b197e50722ee569738c1 | 176 | py | Python | squares.py | UCL-RITS/bisectdemo | dfdcd80b78c801b3974a910ac4f77ed1b1d51de6 | [
"MIT"
] | null | null | null | squares.py | UCL-RITS/bisectdemo | dfdcd80b78c801b3974a910ac4f77ed1b1d51de6 | [
"MIT"
] | null | null | null | squares.py | UCL-RITS/bisectdemo | dfdcd80b78c801b3974a910ac4f77ed1b1d51de6 | [
"MIT"
] | 2 | 2020-11-18T13:51:43.000Z | 2020-12-17T22:29:44.000Z | #!/usr/bin/env python
from __future__ import print_function
import sys
integer = int(sys.argv[1])
print(integer**2)
# vim: tabstop=8 expandtab shiftwidth=4 softtabstop=4
| 13.538462 | 53 | 0.75 | 27 | 176 | 4.703704 | 0.814815 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0.032895 | 0.136364 | 176 | 12 | 54 | 14.666667 | 0.802632 | 0.409091 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | false | 0 | 0.5 | 0 | 0.5 | 0.5 | 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 | 1 | 0 | 3 |
c9d06b78e433e7b980f6a22f982bf81875f86f90 | 124 | py | Python | parrot/forms.py | whidbeyisland/Parrot | db85caf2d3083c8e9ec4b9eb1dc8e0d1b5834495 | [
"MIT"
] | null | null | null | parrot/forms.py | whidbeyisland/Parrot | db85caf2d3083c8e9ec4b9eb1dc8e0d1b5834495 | [
"MIT"
] | null | null | null | parrot/forms.py | whidbeyisland/Parrot | db85caf2d3083c8e9ec4b9eb1dc8e0d1b5834495 | [
"MIT"
] | null | null | null | from django import forms
class TextEntryForm(forms.Form):
username = forms.CharField()
prompt = forms.CharField()
| 17.714286 | 32 | 0.725806 | 14 | 124 | 6.428571 | 0.714286 | 0.311111 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0.177419 | 124 | 6 | 33 | 20.666667 | 0.882353 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | false | 0 | 0.25 | 0 | 1 | 0 | 1 | 0 | 0 | null | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 3 |
c9e2f0a77e67491d0454c210a2bac88425709725 | 251 | py | Python | Week 4 Project - Adversarial Search and Games/BaseAI.py | edaaydinea/CSMM101X-Artificial-Intelligence | 2490fab2a4ecfbcf21a68a2d7c5a18522301edea | [
"MIT"
] | 3 | 2021-11-26T14:53:56.000Z | 2021-11-27T11:46:16.000Z | Week 4 Project - Adversarial Search and Games/BaseAI.py | edaaydinea/CSMM101X-Artificial-Intelligence | 2490fab2a4ecfbcf21a68a2d7c5a18522301edea | [
"MIT"
] | null | null | null | Week 4 Project - Adversarial Search and Games/BaseAI.py | edaaydinea/CSMM101X-Artificial-Intelligence | 2490fab2a4ecfbcf21a68a2d7c5a18522301edea | [
"MIT"
] | null | null | null | """
This is the base class for any AI component. All AIs inherit from this module, and
implement the getMove() function, which takes a Grid object as a parameter and
returns a move.
"""
class BaseAI:
def getMove(self,grid):
pass | 25.1 | 83 | 0.689243 | 39 | 251 | 4.435897 | 0.794872 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0.243028 | 251 | 10 | 84 | 25.1 | 0.910526 | 0.705179 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0.333333 | false | 0.333333 | 0 | 0 | 0.666667 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 1 | 0 | 0 | 1 | 0 | 0 | 3 |
a008383bf0fe00702632fd153081760547448321 | 6,540 | py | Python | branches/old/python/ansi-C-generator/generate_source_unroll.py | jeffhammond/spaghetty | e2dbe2dd2621110b899b21dff590906a579e8bf5 | [
"BSD-2-Clause"
] | 1 | 2018-01-05T16:13:08.000Z | 2018-01-05T16:13:08.000Z | branches/old/python/ansi-C-generator/generate_source_unroll.py | jeffhammond/spaghetty | e2dbe2dd2621110b899b21dff590906a579e8bf5 | [
"BSD-2-Clause"
] | null | null | null | branches/old/python/ansi-C-generator/generate_source_unroll.py | jeffhammond/spaghetty | e2dbe2dd2621110b899b21dff590906a579e8bf5 | [
"BSD-2-Clause"
] | null | null | null | import fileinput
import string
import sys
import os
c_compiler = 'icc'
c_link_flags = '-O1 -xT -march=core2 -mtune=core2 -align -strict-ansi'
c_opt_flags = '-O3 -xT -march=core2 -mtune=core2 -funroll-loops -align -strict-ansi'
fortran_compiler = 'ifort'
fortran_link_flags = '-O1 -xT -march=core2 -mtune=core2 -align '
fortran_opt_flags = '-O3 -xT -march=core2 -mtune=core2 -funroll-loops -align '
src_dir = '/home/jeff/code/spaghetty/trunk/source/ansi-C/'
obj_dir = '/home/jeff/code/spaghetty/trunk/object/ansi-C/'
exe_dir = '/home/jeff/code/spaghetty/trunk/binary/ansi-C/'
modlabel = 'unroll'
unrolling = 4
lib_name = 'tce_sort_'+modlabel+'.a'
cind = ' '
ctab = ' '
def perm(l):
sz = len(l)
if sz <= 1:
return [l]
return [p[:i]+[l[0]]+p[i:] for i in xrange(sz) for p in perm(l[1:])]
indices = ['1','2','3','4']
#indices = ['4','3','2','1']
all_permutations = perm(['1','2','3','4'])
#transpose_list = [indices]
#transpose_list = perm(indices)
transpose_list = all_permutations
#transpose_list = [['2','1','3','4'],['1','2','4','3']]
#loop_list = [indices]
#loop_list = perm(indices)
loop_list = all_permutations
for transpose_order in transpose_list:
A = transpose_order[0]
B = transpose_order[1]
C = transpose_order[2]
D = transpose_order[3]
for loop_order in loop_list:
a = loop_order[0]
b = loop_order[1]
c = loop_order[2]
d = loop_order[3]
if d is '4' and D is '4':
subroutine_name = 'transpose_'+A+B+C+D+'_loop_'+a+b+c+d+'_'
source_name = subroutine_name+'.c'
source_file = open(source_name,'w')
source_file.write(cind+'#include <math.h>\n\n')
source_file.write(cind+'void '+subroutine_name+'( double *unsorted, double *sorted,\n')
source_file.write(cind+8*ctab+'int *p_dim1, int *p_dim2, int *p_dim3, int *p_dim4, double *p_factor ) {\n\n')
source_file.write(cind+'int dim1,dim2,dim3,dim4;\n')
source_file.write(cind+'int dim1mod,dim2mod,dim3mod,dim4mod;\n')
#source_file.write(cind+'int dim1rem,dim2rem,dim3rem,dim4rem;\n')
source_file.write(cind+'unsigned int old_offset,new_offset;\n')
source_file.write(cind+'unsigned int j1,j2,j3,j4;\n')
source_file.write(cind+'double factor;\n')
source_file.write(cind+'factor = *p_factor;\n\n')
source_file.write(cind+'dim1 = *p_dim1;\n')
source_file.write(cind+'dim2 = *p_dim2;\n')
source_file.write(cind+'dim3 = *p_dim3;\n')
source_file.write(cind+'dim4 = *p_dim4;\n\n')
source_file.write(cind+'dim1mod = (int) floor( (float)dim1 / (float) '+str(unrolling)+');\n')
source_file.write(cind+'dim2mod = (int) floor( (float)dim2 / (float) '+str(unrolling)+');\n')
source_file.write(cind+'dim3mod = (int) floor( (float)dim3 / (float) '+str(unrolling)+');\n')
source_file.write(cind+'dim4mod = (int) floor( (float)dim4 / (float) '+str(unrolling)+');\n\n')
#source_file.write(cind+'dim1rem = dim1 - dim1mod;\n')
#source_file.write(cind+'dim2rem = dim2 - dim2mod;\n')
#source_file.write(cind+'dim3rem = dim3 - dim3mod;\n')
#source_file.write(cind+'dim4rem = dim4 - dim4mod;\n\n')
source_file.write(cind+'/* pluto start (dim1,dim2,dim3,dim4) */\n')
source_file.write(cind+0*ctab+'#pragma ivdep\n')
source_file.write(cind+0*ctab+'#pragma parallel\n')
source_file.write(cind+0*ctab+'#pragma loop count min(10) max(80) avg(40)\n')
source_file.write(cind+0*ctab+'#pragma unroll\n')
source_file.write(cind+0*ctab+'for( j'+a+' = 0; j'+a+'<dim'+a+'; j'+a+'++) {\n')
source_file.write(cind+1*ctab+'#pragma loop count min(10) max(80) avg(40)\n')
source_file.write(cind+1*ctab+'#pragma unroll\n')
source_file.write(cind+1*ctab+'for( j'+b+' = 0; j'+b+'<dim'+b+'; j'+b+'++) {\n')
source_file.write(cind+2*ctab+'#pragma loop count min(10) max(80) avg(40)\n')
source_file.write(cind+2*ctab+'#pragma unroll\n')
source_file.write(cind+2*ctab+'#pragma vector always\n')
source_file.write(cind+2*ctab+'for( j'+c+' = 0; j'+c+'<dim'+c+'; j'+c+'++) {\n')
if d is '4' and D is '4':
source_file.write(cind+3*ctab+'#pragma loop count min(4) max(20) avg(10)\n')
source_file.write(cind+3*ctab+'#pragma unroll\n')
source_file.write(cind+3*ctab+'#pragma vector always\n')
source_file.write(cind+3*ctab+'for( j'+d+' = 0; j'+d+'<dim'+d+'mod; j'+d+'+='+str(unrolling)+') {\n')
for offset in range(0,unrolling):
source_file.write(cind+4*ctab+'sorted['+str(offset)+'+j'+D+'+dim'+D+'*(j'+C+'+dim'+C+'*(j'+B+'+dim'+B+'*j'+A+'))] = unsorted['+str(offset)+'+j4+dim4*(j3+dim3*(j2+dim2*j1))] * factor;\n')
source_file.write(cind+3*ctab+'}\n')
source_file.write(cind+3*ctab+'#pragma loop count min(0) max(8) avg(2)\n')
source_file.write(cind+3*ctab+'#pragma unroll\n')
source_file.write(cind+3*ctab+'#pragma vector always\n')
source_file.write(cind+3*ctab+'for( j'+d+' = dim'+d+'mod; j'+d+'<dim'+d+'; j'+d+'++) {\n')
source_file.write(cind+4*ctab+'sorted[j'+D+'+dim'+D+'*(j'+C+'+dim'+C+'*(j'+B+'+dim'+B+'*j'+A+'))] = unsorted[j4+dim4*(j3+dim3*(j2+dim2*j1))] * factor;\n')
source_file.write(cind+3*ctab+'}\n')
if d is not '4' or D is not '4':
source_file.write(cind+3*ctab+'#pragma loop count min(10) max(80) avg(40)\n')
source_file.write(cind+3*ctab+'#pragma unroll\n')
source_file.write(cind+3*ctab+'#pragma vector always\n')
source_file.write(cind+3*ctab+'for( j'+d+' = 0; j'+d+'<dim'+d+'; j'+d+'++) {\n')
source_file.write(cind+4*ctab+'sorted[j'+D+'+dim'+D+'*(j'+C+'+dim'+C+'*(j'+B+'+dim'+B+'*j'+A+'))] = unsorted[j4+dim4*(j3+dim3*(j2+dim2*j1))] * factor;\n')
source_file.write(cind+3*ctab+'}\n')
source_file.write(cind+2*ctab+'}\n')
source_file.write(cind+1*ctab+'}\n')
source_file.write(cind+'}\n')
source_file.write(cind+'/* pluto end */\n')
source_file.write(cind+'return;\n')
source_file.write(cind+'}\n\n')
source_file.close()
print c_compiler+' '+c_opt_flags+' -c '+source_name
os.system(c_compiler+' '+c_opt_flags+' -c '+source_name)
os.system('ar -r '+lib_name+' '+subroutine_name+'.o')
os.system('mv '+subroutine_name+'.o '+obj_dir)
os.system('mv '+subroutine_name+'.c '+src_dir)
| 51.09375 | 196 | 0.600612 | 1,041 | 6,540 | 3.644573 | 0.136407 | 0.16078 | 0.233263 | 0.295467 | 0.642066 | 0.578282 | 0.5 | 0.460727 | 0.352926 | 0.302847 | 0 | 0.036336 | 0.183639 | 6,540 | 127 | 197 | 51.496063 | 0.674284 | 0.070489 | 0 | 0.125 | 0 | 0.038462 | 0.334432 | 0.057854 | 0 | 0 | 0 | 0 | 0 | 0 | null | null | 0 | 0.038462 | null | null | 0.009615 | 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 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 3 |
a01537870b51fa96b5ce424064af2988c6f35b45 | 135 | py | Python | examples/bell_state.py | VIVelev/Quantsim | cde37880508dc3bd1db91186d19f09d8b0c0f4ae | [
"MIT"
] | null | null | null | examples/bell_state.py | VIVelev/Quantsim | cde37880508dc3bd1db91186d19f09d8b0c0f4ae | [
"MIT"
] | 3 | 2020-03-31T02:55:21.000Z | 2020-12-11T16:26:31.000Z | examples/bell_state.py | VIVelev/Quantsim | cde37880508dc3bd1db91186d19f09d8b0c0f4ae | [
"MIT"
] | null | null | null | from quantsim import Qubit, H, CNOT, D
if __name__ == '__main__':
q1, q2 = Qubit(), Qubit()
q1 - H
q1@q2 - CNOT(1, 2) - D
| 19.285714 | 38 | 0.555556 | 22 | 135 | 3.045455 | 0.636364 | 0.119403 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0.072165 | 0.281481 | 135 | 6 | 39 | 22.5 | 0.618557 | 0 | 0 | 0 | 0 | 0 | 0.059259 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | true | 0 | 0.2 | 0 | 0.2 | 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 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 3 |
4e7447592d4e495ae23c3070e1bc068ee64d0c03 | 257 | py | Python | datasets/prudent_life_insurance/info.py | deveshcode/benchmarks | c99516c2f953d4cd1516717c5695d29649824f69 | [
"Apache-2.0"
] | null | null | null | datasets/prudent_life_insurance/info.py | deveshcode/benchmarks | c99516c2f953d4cd1516717c5695d29649824f69 | [
"Apache-2.0"
] | null | null | null | datasets/prudent_life_insurance/info.py | deveshcode/benchmarks | c99516c2f953d4cd1516717c5695d29649824f69 | [
"Apache-2.0"
] | null | null | null | from sklearn.metrics import r2_score
from benchmarks.helpers.confidence import confidence_from_range_v1
file = 'data.csv'
speed = 'medium'
active = True
accuracy_function = r2_score
confidence_function = confidence_from_range_v1
target = 'Response' | 28.555556 | 67 | 0.805447 | 34 | 257 | 5.794118 | 0.647059 | 0.071066 | 0.192893 | 0.213198 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0.017937 | 0.132296 | 257 | 9 | 68 | 28.555556 | 0.865471 | 0 | 0 | 0 | 0 | 0 | 0.088 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | false | 0 | 0.25 | 0 | 0.25 | 0 | 0 | 0 | 0 | null | 0 | 1 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 3 |
4e75780177d849ea37190a743a5c77f67e57c781 | 245 | py | Python | ddns_manager/ddns_updater/base.py | hbontempo-br/ddns-manager | 3d78ba540d433146fc61b4243c62a519830c1fb4 | [
"MIT"
] | null | null | null | ddns_manager/ddns_updater/base.py | hbontempo-br/ddns-manager | 3d78ba540d433146fc61b4243c62a519830c1fb4 | [
"MIT"
] | 15 | 2021-06-30T16:05:38.000Z | 2021-07-11T16:14:29.000Z | ddns_manager/ddns_updater/base.py | hbontempo-br/ddns-manager | 3d78ba540d433146fc61b4243c62a519830c1fb4 | [
"MIT"
] | null | null | null | from abc import ABC, abstractmethod
from typing import NoReturn
class DDNSUpdaterError(Exception):
pass
class DDNSUpdater(ABC):
@abstractmethod
def update_ddns_record(self, ip: str) -> NoReturn:
raise NotImplementedError
| 18.846154 | 54 | 0.746939 | 27 | 245 | 6.703704 | 0.740741 | 0.187845 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0.191837 | 245 | 12 | 55 | 20.416667 | 0.914141 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0.125 | false | 0.125 | 0.25 | 0 | 0.625 | 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 | 0 | 1 | 0 | 0 | 1 | 0 | 0 | 3 |
4e7a9644218c265c6d6edeba4364e82141b329c2 | 1,734 | py | Python | metrics.py | andres-soto-h/ml-tarea-competencia | a639deff099706e8fad6e68333b64f19471d8570 | [
"MIT"
] | null | null | null | metrics.py | andres-soto-h/ml-tarea-competencia | a639deff099706e8fad6e68333b64f19471d8570 | [
"MIT"
] | null | null | null | metrics.py | andres-soto-h/ml-tarea-competencia | a639deff099706e8fad6e68333b64f19471d8570 | [
"MIT"
] | 1 | 2021-06-20T14:37:49.000Z | 2021-06-20T14:37:49.000Z | """
In this module we store functions to measuer the performance of our model.
"""
import numpy as np
from numpy.core.numeric import argwhere
from sklearn.metrics import mean_absolute_error, make_scorer, f1_score, precision_score
def get_metric_name_mapping():
return {_mae(): mean_absolute_error, _cm(): custom_error, _f1_score(): f1_score , _precision_score(): precision_score}
def custom_error(
y_true, y_pred, *, overflow_cost: float = 0.7, underflow_cost: float = 0.3, aggregate : bool = True
):
"""A custom metric that is related to the business, the lower the better."""
diff = y_true - y_pred # negative if predicted value is greater than true value
sample_weight = np.ones_like(diff)
mask_underflow = diff > 0
sample_weight[mask_underflow] = underflow_cost
mask_overflow = diff <= 0
sample_weight[mask_overflow] = overflow_cost
if aggregate:
return mean_absolute_error(y_true, y_pred, sample_weight=sample_weight)
return np.abs(diff * sample_weight)
def get_metric_function(name: str, **params):
mapping = get_metric_name_mapping()
def fn(y, y_pred):
return mapping[name](y, y_pred, **params)
return fn
def get_scoring_function(name: str, **params):
mapping = {
_mae(): make_scorer(mean_absolute_error, greater_is_better=False, **params),
_f1_score(): make_scorer(f1_score, greater_is_better=True, **params),
_precision_score(): make_scorer(precision_score, greater_is_better=True, **params)
}
return mapping[name]
def _mae():
return "mean absolute error"
def _cm():
return "custom prediction error"
def _f1_score():
return "f1 score"
def _precision_score():
return "precision score" | 29.896552 | 122 | 0.71684 | 244 | 1,734 | 4.782787 | 0.32377 | 0.041988 | 0.072836 | 0.025707 | 0.161097 | 0.051414 | 0 | 0 | 0 | 0 | 0 | 0.009187 | 0.183968 | 1,734 | 58 | 123 | 29.896552 | 0.815548 | 0.115917 | 0 | 0 | 0 | 0 | 0.042763 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0.243243 | false | 0 | 0.081081 | 0.162162 | 0.594595 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 0 | 1 | 1 | 0 | 0 | 3 |
4e90258ee386df119964fc9a8cace80b75e3cda7 | 145 | py | Python | Bioinformatics_textbook/volumen_I/chapter_III/overlap.py | ugis22/bioinformatics_algorithm_text_book_problems | a0a5b24fca44aae8cb1cc3b0bd3b69bb76e1a09b | [
"MIT"
] | 1 | 2018-05-07T08:38:27.000Z | 2018-05-07T08:38:27.000Z | Bioinformatics_textbook/volumen_I/chapter_III/overlap.py | ugis22/bioinformatics_algorithm_text_book_problems | a0a5b24fca44aae8cb1cc3b0bd3b69bb76e1a09b | [
"MIT"
] | null | null | null | Bioinformatics_textbook/volumen_I/chapter_III/overlap.py | ugis22/bioinformatics_algorithm_text_book_problems | a0a5b24fca44aae8cb1cc3b0bd3b69bb76e1a09b | [
"MIT"
] | null | null | null | class Graph(object):
def __init__(self, graph_dict=None):
if graph_dict == None:
graph_dict = {}
self.__graph_dict = graph_dict
| 9.666667 | 37 | 0.668966 | 20 | 145 | 4.3 | 0.45 | 0.523256 | 0.302326 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0.22069 | 145 | 14 | 38 | 10.357143 | 0.761062 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0.2 | false | 0 | 0 | 0 | 0.4 | 0 | 1 | 0 | 0 | null | 1 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 3 |
4ead1eecd51def9d35f20b10b43d3d0377e8d3ef | 6,192 | py | Python | edwinServer/common/mail_helper.py | ljb-2000/edwin | 0c699709853f3ba469c905136a7de18df8bc4d78 | [
"Apache-2.0"
] | 71 | 2015-01-17T16:59:05.000Z | 2022-01-17T02:33:49.000Z | edwinServer/common/mail_helper.py | lucius-feng/edwin | 0c699709853f3ba469c905136a7de18df8bc4d78 | [
"Apache-2.0"
] | null | null | null | edwinServer/common/mail_helper.py | lucius-feng/edwin | 0c699709853f3ba469c905136a7de18df8bc4d78 | [
"Apache-2.0"
] | 45 | 2015-01-18T03:10:41.000Z | 2022-03-28T03:48:55.000Z | # -*- coding: utf-8 -*-
'''
'''
from __future__ import absolute_import
import logging
import os
class MailxMailSender(object):
logger = logging.getLogger(__name__)
def __init__(self):
# read mail settings from configure file
pass
def _send(self, to_list, cc_list, subject, body):
to_list.extend(cc_list)
mailTo = ','.join(to_list)
cmdFmt = "echo '%s' |mailx -s '%s' '%s'"
cmd = cmdFmt % (body, subject, mailTo)
self.logger.info("mailx cmd:%s" % cmd)
exitcode = 0
try:
exitcode = os.system(cmd)
return True
if (exitcode != 0):
self.logger.error("mailx exitcode =%d" % exitcode)
return False
except (Exception), ex:
self.logger.exception(ex)
return False
def send_plain_mail(self, to_list, cc_list, subject, body):
self.logger.info('send_plain_mail() called.')
self._send(to_list, cc_list, subject, body)
def send_html_mail(self, to_list, cc_list, subject, body):
self.logger.info('send_html_mail() called.')
self._send(to_list, cc_list, subject, body)
class LoggingMailSender(object):
logger = logging.getLogger(__name__)
def __init__(self):
# read mail settings from configure file
pass
def _send(self, to_list, cc_list, subject, body):
self.logger.info("""Mail sent to logging. Find details below,
to_list: %s
cc_list: %s
subject: %s
body: %s""" % (to_list, cc_list, subject, body))
return True
def send_plain_mail(self, to_list, cc_list, subject, body):
self.logger.info('send_plain_mail() called.')
self._send(to_list, cc_list, subject, body)
def send_html_mail(self, to_list, cc_list, subject, body):
self.logger.info('send_html_mail() called.')
self._send(to_list, cc_list, subject, body)
class SmtpMailSender(object):
logger = logging.getLogger(__name__)
def __init__(self, smtp_host, smtp_port, smtp_over_ssl, mail_user, mail_pwd):
# read mail settings from configure file
self.smtp_host = smtp_host
self.smtp_port = smtp_port
self.smtp_over_ssl = smtp_over_ssl
self.mail_user = mail_user
self.mail_pwd = mail_pwd
def send_plain_mail(self, to_list, cc_list, subject, body):
self.logger.info('send_plain_mail() called.')
import smtplib
from email.mime.text import MIMEText
# Construct email
msgRoot = MIMEText(body)
msgRoot['Subject'] = subject
msgRoot['From'] = self.mail_user
msgRoot['To'] = ",".join(to_list)
msgRoot['CC'] = ",".join(cc_list)
#msgRoot['BCC'] =",".join(cc_list)
try:
if not self.smtp_over_ssl:
if self.smtp_port == '':
s = smtplib.SMTP(self.smtp_host)
else:
s = smtplib.SMTP(self.smtp_host, self.smtp_port)
else:
if self.smtp_port == '':
s = smtplib.SMTP_SSL(self.smtp_host)
else:
s = smtplib.SMTP_SSL(self.smtp_host, self.smtp_port)
s.set_debuglevel(True) # print stmp actions to stdout
if self.mail_pwd:
s.login(self.mail_user, self.mail_pwd)
to_addrs = to_list + cc_list
s.sendmail(self.mail_user, to_addrs, msgRoot.as_string())
#s.sendmail(from_addr ,to_addrs, 'test message')
s.quit()
self.logger.info("""Mail sent. Find details below,
to_list: %s
cc_list: %s
subject: %s
body: %s""" % (to_list, cc_list, subject, body))
return True
except Exception, ex:
self.logger.exception(ex)
return False
def send_html_mail(self, to_list, cc_list, subject, body):
self.logger.info('send_html_mail() called.')
import smtplib
from email.mime.text import MIMEText
from email.mime.multipart import MIMEMultipart
# Construct email
msgRoot = MIMEMultipart('related')
msgRoot['Subject'] = subject
msgRoot['From'] = self.mail_user
msgRoot['To'] = ",".join(to_list)
msgRoot['CC'] = ",".join(cc_list)
#msgRoot['BCC'] =",".join(cc_list)
msgRoot.preamble = 'This is a multi-part message in MIME format.'
# Encapsulate the plain and HTML versions of the message body in an
# 'alternative' part, so message agents can decide which they want to display.
msgAlternative = MIMEMultipart('alternative')
msgRoot.attach(msgAlternative)
# Add plain content
msgText = MIMEText('This is HTML mail. If you see this message, which means you will not see the real mail content.', 'plain')
msgAlternative.attach(msgText)
# add html content
msgText = MIMEText(body, 'html')
msgAlternative.attach(msgText)
try:
if not self.smtp_over_ssl:
if self.smtp_port == '':
s = smtplib.SMTP(self.smtp_host)
else:
s = smtplib.SMTP(self.smtp_host, self.smtp_port)
else:
if self.smtp_port == '':
s = smtplib.SMTP_SSL(self.smtp_host)
else:
s = smtplib.SMTP_SSL(self.smtp_host, self.smtp_port)
s.set_debuglevel(True) # print stmp actions to stdout
if self.mail_pwd:
s.login(self.mail_user, self.mail_pwd)
to_addrs = to_list + cc_list
s.sendmail(self.mail_user, to_addrs, msgRoot.as_string())
#s.sendmail(from_addr ,to_addrs, 'test message')
s.quit()
self.logger.info("""Mail sent. Find details below,
to_list: %s
cc_list: %s
subject: %s
body: %s""" % (to_list, cc_list, subject, body))
return True
except Exception, ex:
self.logger.exception(ex)
return False
| 34.021978 | 134 | 0.574935 | 765 | 6,192 | 4.428758 | 0.168627 | 0.044274 | 0.040142 | 0.060213 | 0.711334 | 0.697462 | 0.687721 | 0.687721 | 0.67503 | 0.67503 | 0 | 0.000711 | 0.31896 | 6,192 | 181 | 135 | 34.209945 | 0.802703 | 0.091408 | 0 | 0.765152 | 0 | 0.007576 | 0.142653 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | null | null | 0.015152 | 0.060606 | null | null | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 3 |
4edb6e978ef3ac2991d42e824cd93de1ea7fe18c | 354 | py | Python | genelang/parsing/In.py | GabrielAmare/Genelang | af5294e900d2f79ff54375f9759c156a4b5a098a | [
"MIT"
] | null | null | null | genelang/parsing/In.py | GabrielAmare/Genelang | af5294e900d2f79ff54375f9759c156a4b5a098a | [
"MIT"
] | null | null | null | genelang/parsing/In.py | GabrielAmare/Genelang | af5294e900d2f79ff54375f9759c156a4b5a098a | [
"MIT"
] | null | null | null | from ._Name_Process import _Name_Process
from genelang.lexing import TokenList
from genelang.results import InResult
class In(_Name_Process):
def build(self, parser, tokens: TokenList, at_position: int) -> InResult:
process_result = self.process.build(parser, tokens, at_position)
return InResult(self, at_position, process_result)
| 35.4 | 77 | 0.771186 | 46 | 354 | 5.695652 | 0.456522 | 0.125954 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0.152542 | 354 | 9 | 78 | 39.333333 | 0.873333 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0.142857 | false | 0 | 0.428571 | 0 | 0.857143 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 1 | 0 | 0 | 3 |
14cdd30f850b6df676a57f2c4a0c7c3cfb8ad99c | 179 | py | Python | python-rrmngmnt-1/setup.py | evy972/bug-hunter | 07b130f5f7a02b72abc1783c3edcebd2e561aa19 | [
"Apache-2.0"
] | null | null | null | python-rrmngmnt-1/setup.py | evy972/bug-hunter | 07b130f5f7a02b72abc1783c3edcebd2e561aa19 | [
"Apache-2.0"
] | 4 | 2018-05-29T03:58:15.000Z | 2018-10-10T10:27:35.000Z | rrmng/setup.py | avihaie/bug-hunter | 9a2730d9a61b268f45e9d3115b8bbba039b954db | [
"Apache-2.0"
] | null | null | null | import os
from setuptools import setup
os.environ['SKIP_GENERATE_AUTHORS'] = '1'
if __name__ == "__main__":
setup(
setup_requires=['pbr'],
pbr=True,
)
| 13.769231 | 41 | 0.620112 | 21 | 179 | 4.761905 | 0.761905 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0.007463 | 0.251397 | 179 | 12 | 42 | 14.916667 | 0.738806 | 0 | 0 | 0 | 1 | 0 | 0.184358 | 0.117318 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | true | 0 | 0.25 | 0 | 0.25 | 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 | 1 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 3 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.