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 |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
2409809f52381eda91b816cba44c4d7b62d503a9 | 3,379 | py | Python | cloudshell/devices/cli_handler_impl.py | QualiSystems/cloudshell-networking-devices | f316cefca174975424ec21854b672335feaf8f87 | [
"Apache-2.0"
] | null | null | null | cloudshell/devices/cli_handler_impl.py | QualiSystems/cloudshell-networking-devices | f316cefca174975424ec21854b672335feaf8f87 | [
"Apache-2.0"
] | 34 | 2016-11-28T10:52:44.000Z | 2019-10-01T08:52:59.000Z | cloudshell/devices/cli_handler_impl.py | QualiSystems/cloudshell-networking-devices | f316cefca174975424ec21854b672335feaf8f87 | [
"Apache-2.0"
] | 1 | 2017-05-23T08:46:45.000Z | 2017-05-23T08:46:45.000Z | #!/usr/bin/python
# -*- coding: utf-8 -*-
from abc import abstractproperty
from cloudshell.cli.cli import CLI
from cloudshell.cli.cli_service_impl import CommandModeContextManager
from cloudshell.cli.command_mode import CommandMode
from cloudshell.cli.session.ssh_session import SSHSession
from cloudshell.cli.session.telnet_session import TelnetSession
from cloudshell.devices.cli_handler_interface import CliHandlerInterface
class CliHandlerImpl(CliHandlerInterface):
def __init__(self, cli, resource_config, logger, api):
"""
Helps to create cli handler
:param cli:
:type cli: CLI
:param context:
:param logger:
:param api:
:return:
"""
self._cli = cli
self.resource_config = resource_config
self._logger = logger
self._api = api
self._password = None
@abstractproperty
def enable_mode(self):
"""Define Default Command Mode
:return: Default Command Mode
:rtype: CommandMode
"""
pass
@abstractproperty
def config_mode(self):
"""Define Config Command Mode
:return: Config Command Mode
:rtype: CommandMode
"""
pass
@property
def username(self):
return self.resource_config.user
@property
def password(self):
if not self._password:
password = self.resource_config.password
self._password = self._api.DecryptPassword(password).Value
return self._password
@property
def resource_address(self):
"""Resource IP
:return:
"""
return self.resource_config.address
@property
def port(self):
"""Connection port property, to open socket on
:return:
"""
return self.resource_config.cli_tcp_port
@property
def cli_type(self):
"""Connection type property [ssh|telnet|console|auto]
:return:
"""
return self.resource_config.cli_connection_type
def on_session_start(self, session, logger):
"""Perform some default commands when session just opened (like 'no logging console')
:param session:
:param logger:
:return:
"""
pass
def _ssh_session(self):
return SSHSession(self.resource_address, self.username, self.password, self.port, self.on_session_start)
def _telnet_session(self):
return TelnetSession(self.resource_address, self.username, self.password, self.port, self.on_session_start)
def _new_sessions(self):
if self.cli_type.lower() == SSHSession.SESSION_TYPE.lower():
new_sessions = self._ssh_session()
elif self.cli_type.lower() == TelnetSession.SESSION_TYPE.lower():
new_sessions = self._telnet_session()
else:
new_sessions = [self._ssh_session(), self._telnet_session()]
return new_sessions
def get_cli_service(self, command_mode):
"""Use cli.get_session to open CLI connection and switch into required mode
:param CommandMode command_mode: operation mode, can be default_mode/enable_mode/config_mode/etc.
:return: created session in provided mode
:rtype: CommandModeContextManager
"""
return self._cli.get_session(self._new_sessions(), command_mode, self._logger)
| 28.394958 | 115 | 0.654336 | 378 | 3,379 | 5.640212 | 0.251323 | 0.050657 | 0.050657 | 0.045028 | 0.187148 | 0.12758 | 0.067542 | 0.067542 | 0.067542 | 0.067542 | 0 | 0.0004 | 0.25984 | 3,379 | 118 | 116 | 28.635593 | 0.852059 | 0.239716 | 0 | 0.185185 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0.240741 | false | 0.203704 | 0.12963 | 0.055556 | 0.555556 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 1 | 0 | 0 | 1 | 0 | 0 | 3 |
24109ea9b054cabc6aeb5b4e0cd675ba17b43ac8 | 182 | py | Python | apps/contents/urls.py | mkdir700/Marilyn | 49d735f61914b0e57410ec2d73d583c422bccaa5 | [
"MIT"
] | null | null | null | apps/contents/urls.py | mkdir700/Marilyn | 49d735f61914b0e57410ec2d73d583c422bccaa5 | [
"MIT"
] | 4 | 2021-04-08T20:57:24.000Z | 2021-09-22T19:12:13.000Z | apps/contents/urls.py | mkdir700/Marilyn | 49d735f61914b0e57410ec2d73d583c422bccaa5 | [
"MIT"
] | null | null | null | from rest_framework import routers
from .views import *
router = routers.DefaultRouter()
router.register('contents', ContentsViewSet, basename='contents')
urlpatterns = router.urls
| 26 | 65 | 0.802198 | 20 | 182 | 7.25 | 0.7 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0.098901 | 182 | 6 | 66 | 30.333333 | 0.884146 | 0 | 0 | 0 | 0 | 0 | 0.087912 | 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 |
24197896843d75bc0277125d57a2e00f603d45c0 | 326 | py | Python | snippet/utils.py | aither64/havesnippet | 283bf2c66141b3950f93407c67f1e60a4100978b | [
"MIT"
] | 4 | 2016-08-15T18:20:08.000Z | 2022-01-02T18:08:42.000Z | snippet/utils.py | aither64/havesnippet | 283bf2c66141b3950f93407c67f1e60a4100978b | [
"MIT"
] | null | null | null | snippet/utils.py | aither64/havesnippet | 283bf2c66141b3950f93407c67f1e60a4100978b | [
"MIT"
] | null | null | null | import random
import string
def gen_string(size=8, chars=string.ascii_lowercase + string.ascii_uppercase + string.digits):
return ''.join(random.choice(chars) for _ in range(size))
def return_url(request, default):
if 'HTTP_REFERER' in request.META:
return request.META['HTTP_REFERER']
return default
| 23.285714 | 94 | 0.733129 | 45 | 326 | 5.155556 | 0.555556 | 0.094828 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0.003663 | 0.162577 | 326 | 13 | 95 | 25.076923 | 0.846154 | 0 | 0 | 0 | 0 | 0 | 0.07362 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0.25 | false | 0 | 0.25 | 0.125 | 0.875 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 0 | 1 | 1 | 0 | 0 | 3 |
243c87e3cf7764fd7c8078e7bc2478c69519f0be | 3,013 | py | Python | tests/vpn/test_vpn.py | jamesregis/ibmcloud-python-sdk | 90d00d9ac903c68b1e3084f4aab5f58614cea89b | [
"Apache-2.0"
] | 1 | 2021-07-21T11:46:40.000Z | 2021-07-21T11:46:40.000Z | tests/vpn/test_vpn.py | jamesregis/ibmcloud-python-sdk | 90d00d9ac903c68b1e3084f4aab5f58614cea89b | [
"Apache-2.0"
] | null | null | null | tests/vpn/test_vpn.py | jamesregis/ibmcloud-python-sdk | 90d00d9ac903c68b1e3084f4aab5f58614cea89b | [
"Apache-2.0"
] | null | null | null | # import unittest
# from mock import patch
# # import ibmcloud_python_sdk.config
# from ibmcloud_python_sdk.vpc.vpn import Vpn
# import tests.Common as Common
# class VpnTestCase(unittest.TestCase):
# """Test case for the client methods."""
# def setUp(self):
# self.patcher = patch('ibmcloud_python_sdk.auth.get_token',
# common.fake_auth)
# self.patcher.start()
# self.vpn = Vpn()
# self.fake_vpn = {}
# def tearDown(self):
# self.patcher.stop()
# @patch('ibmcloud_python_sdk.vpc.vpn.qw', common.fake_get_call)
# def test_get_vpn_gateways(self):
# """Test get_vpns ."""
# response = self.vpn.get_vpn_gateways()
# self.assertNotEqual(len(response), 0)
# @patch('ibmcloud_python_sdk.vpc.vpn.qw', common.fake_get_call)
# def test_get_vpn_with_name(self):
# """Test get_vpn with name as parameter."""
# response = self.vpn.get_vpn(self.fake_vpn['name'])
# print(response)
# self.assertEqual(response['name'], self.fake_vpn['name'])
#
# TODO: to verify
# @patch('ibmcloud_python_sdk.auth.get_token', common.fake_auth)
# @patch('ibmcloud_python_sdk.vpn.vpn.qw', common.fake_get_one)
# def test_get_vpn_with_id(self):
# """Test get_vpn with id as parameter."""
# response = self.vpn.get_vpn(self.fake_vpn['id'])
# self.assertEqual(response['id'], self.fake_vpn['id'])
#
# @patch('ibmcloud_python_sdk.vpc.vpn.qw', common.fake_get_one)
# def test_get_vpn_default_security_group(self):
# """Test get_vpn_default_security_group."""
# response = self.vpn.get_\
# vpn_default_security_group(self.fake_vpn['id'])
# print(response)
# self.assertEqual(response['default_security_group']['name'],
# self.fake_vpn['default_security_group'])
#
# @patch('ibmcloud_python_sdk.vpc.vpn.qw', common.fake_get_one)
# def test_get_vpn_default_network_acl(self):
# """Test get_vpn_default_network_acl."""
# response = self.vpn.get_vpn_default_network_acl(self.fake_vpn['id'])
# self.assertEqual(response['default_network_acl']['name'],
# self.fake_vpn['default_network_acl'])
#
# @patch('ibmcloud_python_sdk.vpc.vpn.qw', common.fake_create)
# def test_create_vpn_working(self):
# """Test create_vpn should work."""
# response = self.vpn.create_vpn(name=self.fake_vpn['name'],
# operating_system='operating_system=',
# file='file')
# print(response)
# self.assertEqual(response['name'], self.fake_vpn['name'])
#
# @patch('ibmcloud_python_sdk.vpc.vpn.qw', common.fake_create)
# def test_create_vpn_not_working(self):
# """Test create_vpn should not work."""
# response = self.vpn.create_vpn(name=self.fake_vpn['name'],
# operating_system='operating_system=',
# file='file')
# self.assertNotEqual(response['id'], self.fake_vpn['name'])
| 39.12987 | 77 | 0.645868 | 390 | 3,013 | 4.687179 | 0.166667 | 0.045952 | 0.078228 | 0.108315 | 0.753829 | 0.636761 | 0.510394 | 0.477024 | 0.477024 | 0.477024 | 0 | 0.000418 | 0.205111 | 3,013 | 76 | 78 | 39.644737 | 0.762839 | 0.951875 | 0 | null | 0 | null | 0 | 0 | null | 0 | 0 | 0.013158 | null | 1 | null | true | 0 | 0 | null | null | null | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | null | 0 | 0 | 1 | 0 | 0 | 0 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 3 |
244446e7672916b2a17318b5732b56e0d9868951 | 50 | py | Python | mmtrack/models/losses/__init__.py | sht47/mmtracking | 5a25e418e9c598d1b576bce8702f5e156cbbefe7 | [
"Apache-2.0"
] | 12 | 2021-09-05T20:47:16.000Z | 2022-03-23T07:00:35.000Z | mmtrack/models/losses/__init__.py | hellock/mmtracking | a22a36b2055d80cf4a7a5ef3913849abb56defcb | [
"Apache-2.0"
] | 2 | 2021-09-06T13:20:09.000Z | 2022-01-13T05:36:14.000Z | mmtrack/models/losses/__init__.py | hellock/mmtracking | a22a36b2055d80cf4a7a5ef3913849abb56defcb | [
"Apache-2.0"
] | 1 | 2022-02-28T19:33:49.000Z | 2022-02-28T19:33:49.000Z | from .l2_loss import L2Loss
__all__ = ['L2Loss']
| 12.5 | 27 | 0.72 | 7 | 50 | 4.428571 | 0.857143 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0.071429 | 0.16 | 50 | 3 | 28 | 16.666667 | 0.666667 | 0 | 0 | 0 | 0 | 0 | 0.12 | 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 |
244f7006bb45576c004c82d8f39627fbee494a67 | 62 | py | Python | src/spaceone/identity/conf/proto_conf.py | spaceone-dev/plugin-googleoauth2-identity-auth | e30e2032aa68a7f3f70fb8afbd1e39aa30d259f9 | [
"Apache-2.0"
] | 1 | 2020-09-16T01:19:21.000Z | 2020-09-16T01:19:21.000Z | src/spaceone/identity/conf/proto_conf.py | spaceone-dev/plugin-googleoauth2-identity-auth | e30e2032aa68a7f3f70fb8afbd1e39aa30d259f9 | [
"Apache-2.0"
] | 1 | 2021-02-02T12:50:22.000Z | 2021-02-02T12:50:22.000Z | src/spaceone/identity/conf/proto_conf.py | spaceone-dev/plugin-keycloak-identity-auth | 0299560d7df328cc1d801ff78f243dea6edb0aa8 | [
"Apache-2.0"
] | 1 | 2021-08-19T02:13:02.000Z | 2021-08-19T02:13:02.000Z | PROTO = {
'spaceone.identity.api.plugin.auth': ['Auth']
}
| 15.5 | 49 | 0.612903 | 7 | 62 | 5.428571 | 0.857143 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0.16129 | 62 | 3 | 50 | 20.666667 | 0.730769 | 0 | 0 | 0 | 0 | 0 | 0.596774 | 0.532258 | 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 |
245c04bdedff868e542d03f840a0ec81226e3959 | 174 | py | Python | src/ecuacionesAlgebraicas/apps.py | MendozaEmerson/AriMath | 97e75db6d3508d78d103eda07afbbfeb525958a9 | [
"Apache-2.0"
] | null | null | null | src/ecuacionesAlgebraicas/apps.py | MendozaEmerson/AriMath | 97e75db6d3508d78d103eda07afbbfeb525958a9 | [
"Apache-2.0"
] | 2 | 2021-12-22T21:32:08.000Z | 2021-12-22T21:32:09.000Z | src/ecuacionesAlgebraicas/apps.py | MendozaEmerson/AriMath | 97e75db6d3508d78d103eda07afbbfeb525958a9 | [
"Apache-2.0"
] | 2 | 2021-12-02T20:35:45.000Z | 2021-12-05T19:03:24.000Z | from django.apps import AppConfig
class EcuacionesalgebraicasConfig(AppConfig):
default_auto_field = 'django.db.models.BigAutoField'
name = 'ecuacionesAlgebraicas'
| 24.857143 | 56 | 0.798851 | 17 | 174 | 8.058824 | 0.882353 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0.126437 | 174 | 6 | 57 | 29 | 0.901316 | 0 | 0 | 0 | 0 | 0 | 0.287356 | 0.287356 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | false | 0 | 0.25 | 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 | 0 | 0 | 1 | 0 | 0 | 3 |
79e159f583c779d1b58f6263f2608d8ac8e24b77 | 308 | py | Python | goldsrc/mdl_v4/structs/bodypart.py | tltneon/SourceIO | 418224918c2b062a4c78a41d4d65329ba2decb22 | [
"MIT"
] | 1 | 2021-07-12T12:55:27.000Z | 2021-07-12T12:55:27.000Z | goldsrc/mdl_v4/structs/bodypart.py | syborg64/SourceIO | e4ba86d801f518e192260af08ef533759c2e1cc3 | [
"MIT"
] | null | null | null | goldsrc/mdl_v4/structs/bodypart.py | syborg64/SourceIO | e4ba86d801f518e192260af08ef533759c2e1cc3 | [
"MIT"
] | null | null | null | from typing import List
from .model import StudioModel
from ....source_shared.base import Base
from ....utilities.byte_io_mdl import ByteIO
class StudioBodypart(Base):
def __init__(self):
self.model_count = 0
def read(self, reader: ByteIO):
self.model_count = reader.read_int32()
| 22 | 46 | 0.717532 | 42 | 308 | 5.02381 | 0.571429 | 0.085308 | 0.132701 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0.012 | 0.188312 | 308 | 13 | 47 | 23.692308 | 0.832 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0.222222 | false | 0 | 0.444444 | 0 | 0.777778 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 1 | 0 | 1 | 0 | 0 | 3 |
79eedbd462e133f877f73d894fef64901de3dfe7 | 1,661 | py | Python | leetcode/0840_magic_squares_in_grid.py | jacquerie/leetcode | a05e6b832eb0e0740aaff7b2eb3109038ad404bf | [
"MIT"
] | 3 | 2018-05-10T09:56:49.000Z | 2020-11-07T18:09:42.000Z | leetcode/0840_magic_squares_in_grid.py | jacquerie/leetcode | a05e6b832eb0e0740aaff7b2eb3109038ad404bf | [
"MIT"
] | null | null | null | leetcode/0840_magic_squares_in_grid.py | jacquerie/leetcode | a05e6b832eb0e0740aaff7b2eb3109038ad404bf | [
"MIT"
] | null | null | null | # -*- coding: utf-8 -*-
class Solution:
def isMagicSquareCenteredHere(self, grid, i, j):
all_nine_numbers = sorted([
grid[i - 1][j - 1], grid[i - 1][j], grid[i - 1][j + 1],
grid[i][j - 1], grid[i][j], grid[i][j + 1],
grid[i + 1][j - 1], grid[i + 1][j], grid[i + 1][j + 1],
]) == list(range(1, 10))
all_sums_equal = len(set([
# rows
grid[i - 1][j - 1] + grid[i - 1][j] + grid[i - 1][j + 1],
grid[i][j - 1] + grid[i][j] + grid[i][j + 1],
grid[i + 1][j - 1] + grid[i + 1][j] + grid[i + 1][j + 1],
# cols
grid[i - 1][j - 1] + grid[i][j - 1] + grid[i + 1][j - 1],
grid[i - 1][j] + grid[i][j] + grid[i + 1][j],
grid[i - 1][j + 1] + grid[i][j + 1] + grid[i + 1][j + 1],
# diags
grid[i - 1][j - 1] + grid[i][j] + grid[i + 1][j + 1],
grid[i + 1][j - 1] + grid[i][j] + grid[i - 1][j + 1],
])) == 1
return all_nine_numbers and all_sums_equal
def numMagicSquaresInside(self, grid):
result = 0
num_rows, num_cols = len(grid), len(grid[0])
for i in range(1, num_rows - 1):
for j in range(1, num_cols - 1):
if self.isMagicSquareCenteredHere(grid, i, j):
result += 1
return result
if __name__ == '__main__':
solution = Solution()
assert 1 == solution.numMagicSquaresInside([
[4, 3, 8, 4],
[9, 5, 1, 9],
[2, 7, 6, 2],
])
assert 0 == solution.numMagicSquaresInside([
[10, 3, 5],
[1, 6, 11],
[7, 9, 2],
])
| 31.339623 | 69 | 0.425647 | 254 | 1,661 | 2.704724 | 0.181102 | 0.254731 | 0.19214 | 0.224163 | 0.352256 | 0.352256 | 0.352256 | 0.350801 | 0.350801 | 0.350801 | 0 | 0.077661 | 0.372065 | 1,661 | 52 | 70 | 31.942308 | 0.581016 | 0.022276 | 0 | 0.052632 | 0 | 0 | 0.004941 | 0 | 0 | 0 | 0 | 0 | 0.052632 | 1 | 0.052632 | false | 0 | 0 | 0 | 0.131579 | 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 |
03018a8dbe685decdebb34501d2a2c9fbb8798be | 4,219 | py | Python | api/metadata/migrations/0017_add_gov_organisations.py | uktrade/market-access-api | 850a59880f8f62263784bcd9c6b3362e447dbc7a | [
"MIT"
] | null | null | null | api/metadata/migrations/0017_add_gov_organisations.py | uktrade/market-access-api | 850a59880f8f62263784bcd9c6b3362e447dbc7a | [
"MIT"
] | 51 | 2018-05-31T12:16:31.000Z | 2022-03-08T09:36:48.000Z | api/metadata/migrations/0017_add_gov_organisations.py | uktrade/market-access-api | 850a59880f8f62263784bcd9c6b3362e447dbc7a | [
"MIT"
] | 2 | 2019-12-24T09:47:42.000Z | 2021-02-09T09:36:51.000Z | from django.db import migrations
from api.metadata.constants import OrganisationType
ORGANISATIONS = [
{
"name": "Attorney General's Office",
"organisation_type": OrganisationType.MINISTERIAL_DEPARTMENTS,
},
{
"name": "Cabinet Office",
"organisation_type": OrganisationType.MINISTERIAL_DEPARTMENTS,
},
{
"name": "Department for Business, Energy & Industrial Strategy",
"organisation_type": OrganisationType.MINISTERIAL_DEPARTMENTS,
},
{
"name": "Department for Digital, Culture, Media & Sport",
"organisation_type": OrganisationType.MINISTERIAL_DEPARTMENTS,
},
{
"name": "Department for Education",
"organisation_type": OrganisationType.MINISTERIAL_DEPARTMENTS,
},
{
"name": "Department for Environment Food & Rural Affairs",
"organisation_type": OrganisationType.MINISTERIAL_DEPARTMENTS,
},
{
"name": "Department for International Trade",
"organisation_type": OrganisationType.MINISTERIAL_DEPARTMENTS,
},
{
"name": "Department for Transport",
"organisation_type": OrganisationType.MINISTERIAL_DEPARTMENTS,
},
{
"name": "Department for Work & Pensions",
"organisation_type": OrganisationType.MINISTERIAL_DEPARTMENTS,
},
{
"name": "Department of Health & Social Care",
"organisation_type": OrganisationType.MINISTERIAL_DEPARTMENTS,
},
{
"name": "Foreign, Commonwealth & Development Office",
"organisation_type": OrganisationType.MINISTERIAL_DEPARTMENTS,
},
{
"name": "HM Treasury",
"organisation_type": OrganisationType.MINISTERIAL_DEPARTMENTS,
},
{
"name": "Home Office",
"organisation_type": OrganisationType.MINISTERIAL_DEPARTMENTS,
},
{
"name": "Ministry of Defence",
"organisation_type": OrganisationType.MINISTERIAL_DEPARTMENTS,
},
{
"name": "Ministry of Housing, Communities & Local Government",
"organisation_type": OrganisationType.MINISTERIAL_DEPARTMENTS,
},
{
"name": "Ministry of Justice",
"organisation_type": OrganisationType.MINISTERIAL_DEPARTMENTS,
},
{
"name": "Northern Ireland Office",
"organisation_type": OrganisationType.MINISTERIAL_DEPARTMENTS,
},
{
"name": "Office of the Advocate General for Scotland",
"organisation_type": OrganisationType.MINISTERIAL_DEPARTMENTS,
},
{
"name": "Office of the Leader of the House of Commons",
"organisation_type": OrganisationType.MINISTERIAL_DEPARTMENTS,
},
{
"name": "Office of the Leader of the House of Lords",
"organisation_type": OrganisationType.MINISTERIAL_DEPARTMENTS,
},
{
"name": "Office of the Secretary of State for Scotland",
"organisation_type": OrganisationType.MINISTERIAL_DEPARTMENTS,
},
{
"name": "Office of the Secretary of State for Wales",
"organisation_type": OrganisationType.MINISTERIAL_DEPARTMENTS,
},
{
"name": "UK Export Finance",
"organisation_type": OrganisationType.MINISTERIAL_DEPARTMENTS,
},
{
"name": "Northern Ireland Executive ",
"organisation_type": OrganisationType.DEVOLVED_ADMINISTRATIONS,
},
{
"name": "The Scottish Government",
"organisation_type": OrganisationType.DEVOLVED_ADMINISTRATIONS,
},
{
"name": "Welsh Government",
"organisation_type": OrganisationType.DEVOLVED_ADMINISTRATIONS,
},
]
def create_organisations(apps, schema_editor):
Organisation = apps.get_model("metadata", "Organisation")
for item in ORGANISATIONS:
Organisation.objects.create(**item)
def delete_organisations(apps, schema_editor):
Organisation = apps.get_model("metadata", "Organisation")
for item in ORGANISATIONS:
Organisation.objects.delete(**item)
class Migration(migrations.Migration):
dependencies = [
("metadata", "0016_organisation"),
]
operations = [
migrations.RunPython(create_organisations, reverse_code=delete_organisations),
]
| 31.022059 | 86 | 0.655843 | 343 | 4,219 | 7.886297 | 0.279883 | 0.153789 | 0.307579 | 0.365619 | 0.774122 | 0.774122 | 0.638447 | 0.559335 | 0.246211 | 0.220702 | 0 | 0.001245 | 0.238208 | 4,219 | 135 | 87 | 31.251852 | 0.840386 | 0 | 0 | 0.243902 | 0 | 0 | 0.335862 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0.01626 | false | 0 | 0.01626 | 0 | 0.056911 | 0 | 0 | 0 | 0 | null | 0 | 1 | 1 | 0 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 3 |
031877202973a6ac735bf87a87e55fa1e59e3a18 | 347 | py | Python | src/Neuron/Perceptron.py | JVZELLER/neural_network | 66962493637ad80b60001922871d661c36249097 | [
"MIT"
] | null | null | null | src/Neuron/Perceptron.py | JVZELLER/neural_network | 66962493637ad80b60001922871d661c36249097 | [
"MIT"
] | null | null | null | src/Neuron/Perceptron.py | JVZELLER/neural_network | 66962493637ad80b60001922871d661c36249097 | [
"MIT"
] | null | null | null | #!/usr/bin/env python
# -*- coding: utf-8 -*-
from Neuron.Neuron import Neuron
## Imports
from random import randint
class Perceptron(Neuron):
def __init__(self, input_range, Validator):
self.input_range = input_range
super().__init__([ [randint(0, 10) for i in range(2)] ] * self.input_range, randint(0, 10), Validator) | 28.916667 | 110 | 0.674352 | 48 | 347 | 4.625 | 0.583333 | 0.18018 | 0.189189 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0.028369 | 0.18732 | 347 | 12 | 110 | 28.916667 | 0.758865 | 0.144092 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0.166667 | false | 0 | 0.333333 | 0 | 0.666667 | 0 | 0 | 0 | 0 | null | 0 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 1 | 0 | 0 | 3 |
034667a05d1d033f49ab4c9058c577ff1f4fb2aa | 2,547 | py | Python | tests/draw/svg/test_clip.py | rianmcguire/WeasyPrint | 7e400663236d16121e14cf3183ce53828d056092 | [
"BSD-3-Clause"
] | 4,512 | 2015-01-02T16:40:59.000Z | 2022-03-31T17:26:28.000Z | tests/draw/svg/test_clip.py | rianmcguire/WeasyPrint | 7e400663236d16121e14cf3183ce53828d056092 | [
"BSD-3-Clause"
] | 1,420 | 2015-01-07T21:17:01.000Z | 2022-03-31T10:23:45.000Z | tests/draw/svg/test_clip.py | rianmcguire/WeasyPrint | 7e400663236d16121e14cf3183ce53828d056092 | [
"BSD-3-Clause"
] | 640 | 2015-01-30T18:07:09.000Z | 2022-03-24T20:17:42.000Z | """
weasyprint.tests.test_draw.svg.test_clip
----------------------------------------
Test clip-path attribute.
"""
import pytest
from ...testing_utils import assert_no_logs
from .. import assert_pixels
@assert_no_logs
def test_clip_path():
assert_pixels('clip_path', 9, 9, '''
_________
_________
__RRRRR__
__RBBBR__
__RBBBR__
__RBBBR__
__RRRRR__
_________
_________
''', '''
<style>
@page { size: 9px }
svg { display: block }
</style>
<svg width="9px" height="9px" xmlns="http://www.w3.org/2000/svg">
<defs>
<clipPath id="clip">
<rect x="2" y="2" width="5" height="5" />
</clipPath>
</defs>
<rect x="2" y="2" width="5" height="5" stroke-width="2"
stroke="red" fill="blue" clip-path="url(#clip)" />
</svg>
''')
@assert_no_logs
def test_clip_path_on_group():
assert_pixels('clip_path_on_group', 9, 9, '''
_________
_________
__BBBB___
__BRRRR__
__BRRRR__
__BRRRR__
___RRRR__
_________
_________
''', '''
<style>
@page { size: 9px }
svg { display: block }
</style>
<svg width="9px" height="9px" xmlns="http://www.w3.org/2000/svg">
<defs>
<clipPath id="clip">
<rect x="2" y="2" width="5" height="5" />
</clipPath>
</defs>
<g clip-path="url(#clip)">
<rect x="1" y="1" width="5" height="5" fill="blue" />
<rect x="3" y="3" width="5" height="5" fill="red" />
</g>
</svg>
''')
@pytest.mark.xfail
@assert_no_logs
def test_clip_path_group_on_group():
assert_pixels('clip_path_group_on_group', 9, 9, '''
_________
_________
__BB_____
__BR_____
_________
_____RR__
_____RR__
_________
_________
''', '''
<style>
@page { size: 9px }
svg { display: block }
</style>
<svg width="9px" height="9px" xmlns="http://www.w3.org/2000/svg">
<defs>
<clipPath id="clip">
<rect x="2" y="2" width="2" height="2" />
<rect x="3" y="3" width="2" height="2" />
</clipPath>
</defs>
<g clip-path="url(#clip)">
<rect x="1" y="1" width="5" height="5" fill="blue" />
<rect x="3" y="3" width="5" height="5" fill="red" />
</g>
</svg>
''')
| 24.028302 | 71 | 0.485277 | 283 | 2,547 | 3.586572 | 0.215548 | 0.078818 | 0.082759 | 0.089655 | 0.714286 | 0.697537 | 0.631527 | 0.551724 | 0.551724 | 0.531034 | 0 | 0.039551 | 0.334904 | 2,547 | 105 | 72 | 24.257143 | 0.559622 | 0.042403 | 0 | 0.8 | 0 | 0.088889 | 0.840778 | 0.038048 | 0 | 0 | 0 | 0 | 0.088889 | 1 | 0.033333 | true | 0 | 0.033333 | 0 | 0.066667 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 1 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 3 |
035d2bdbbb26232913723773c653b8e68edc892f | 610 | py | Python | equipment/framework/tests/Queue/AbstractQueueTest.py | didacelgueta/equipment | 12cd86bfe4b70bce3e2578e3ec79fc4c0f76c322 | [
"MIT"
] | 1 | 2022-03-02T11:32:10.000Z | 2022-03-02T11:32:10.000Z | equipment/framework/tests/Queue/AbstractQueueTest.py | didacelgueta/equipment | 12cd86bfe4b70bce3e2578e3ec79fc4c0f76c322 | [
"MIT"
] | 35 | 2022-03-02T14:33:49.000Z | 2022-03-30T08:14:26.000Z | equipment/framework/tests/Queue/AbstractQueueTest.py | didacelgueta/equipment | 12cd86bfe4b70bce3e2578e3ec79fc4c0f76c322 | [
"MIT"
] | 1 | 2022-03-24T11:52:01.000Z | 2022-03-24T11:52:01.000Z | import unittest
from datetime import datetime
from equipment.framework.Queue.AbstractQueue import AbstractQueue
from equipment.framework.tests.TestCase import TestCase
class AbstractQueueTest(TestCase):
def test_abstract_methods(self):
class TestQueue(AbstractQueue):
pass
def test_method():
return True
with self.assertRaises(NotImplementedError):
TestQueue().push(test_method)
with self.assertRaises(NotImplementedError):
TestQueue().pushOn(datetime.now(), test_method)
if __name__ == '__main__':
unittest.main()
| 25.416667 | 65 | 0.704918 | 60 | 610 | 6.95 | 0.516667 | 0.071942 | 0.105516 | 0.18705 | 0.230216 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0.216393 | 610 | 23 | 66 | 26.521739 | 0.872385 | 0 | 0 | 0.125 | 0 | 0 | 0.013115 | 0 | 0 | 0 | 0 | 0 | 0.125 | 1 | 0.125 | false | 0.0625 | 0.25 | 0.0625 | 0.5625 | 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 | 1 | 0 | 0 | 1 | 0 | 0 | 3 |
035fa2534da6aa385ed5d28ac0cb2791b4ac814c | 872 | py | Python | djangoproject/tiantianshengxian/tiantianshengxian/apps/user/models.py | Aruiaimantianxing/myproject | e28728493651b6e74d3ed767810e44d0893ec060 | [
"MIT"
] | null | null | null | djangoproject/tiantianshengxian/tiantianshengxian/apps/user/models.py | Aruiaimantianxing/myproject | e28728493651b6e74d3ed767810e44d0893ec060 | [
"MIT"
] | null | null | null | djangoproject/tiantianshengxian/tiantianshengxian/apps/user/models.py | Aruiaimantianxing/myproject | e28728493651b6e74d3ed767810e44d0893ec060 | [
"MIT"
] | null | null | null | from django.db import models
from db.base import BaseModel
from django.contrib.auth.models import AbstractUser
class User(AbstractUser, BaseModel):
'''用户的模型类'''
class Meta:
db_table = 'tt_user'
verbose_name = '用户'
verbose_name_plural = verbose_name
class Address(BaseModel):
recv_name = models.CharField(max_length=20, verbose_name='收件人')
recv_address = models.CharField(max_length=256, verbose_name='收件地址')
zip_code = models.CharField(max_length=6, null=True, verbose_name='邮政编码')
phone = models.CharField(max_length=11, verbose_name='手机')
user = models.ForeignKey('User', verbose_name='用户ID')
is_default = models.BooleanField(default=False, verbose_name='是否默认')
class Meta:
db_table = 'tt_address'
verbose_name = '地址表'
verbose_name_plural = verbose_name
| 32.296296 | 78 | 0.688073 | 110 | 872 | 5.218182 | 0.418182 | 0.229965 | 0.125436 | 0.167247 | 0.160279 | 0 | 0 | 0 | 0 | 0 | 0 | 0.011577 | 0.207569 | 872 | 26 | 79 | 33.538462 | 0.819103 | 0.006881 | 0 | 0.210526 | 0 | 0 | 0.056355 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | false | 0 | 0.157895 | 0 | 0.684211 | 0 | 0 | 0 | 0 | null | 1 | 0 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 3 |
036557340446f71367da09cf035ff1b10947442d | 488 | py | Python | app/calculation.py | thiere18/lists | 4fe91468ac6775b62b0caa6aa2c026c45e5b593b | [
"MIT"
] | 1 | 2021-12-30T18:33:42.000Z | 2021-12-30T18:33:42.000Z | app/calculation.py | thiere18/lists | 4fe91468ac6775b62b0caa6aa2c026c45e5b593b | [
"MIT"
] | null | null | null | app/calculation.py | thiere18/lists | 4fe91468ac6775b62b0caa6aa2c026c45e5b593b | [
"MIT"
] | null | null | null | def add(num1:int,num2:int):
return num1 + num2
class InsufficientFunds(Exception):
pass
class BankAccount():
def __init__(self,starting_balance=0):
self.balance = starting_balance
def deposit(self,amount):
self.balance += amount
def withdraw(self,amount):
if amount > self.balance:
raise InsufficientFunds("insufficient balane")
self.balance -= amount
def collect_interest(self):
self.balance *=1.1 | 23.238095 | 58 | 0.643443 | 55 | 488 | 5.581818 | 0.472727 | 0.179153 | 0.110749 | 0.130293 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0.019337 | 0.258197 | 488 | 21 | 59 | 23.238095 | 0.828729 | 0 | 0 | 0 | 0 | 0 | 0.038855 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0.333333 | false | 0.066667 | 0 | 0.066667 | 0.533333 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 1 | 0 | 0 | 1 | 0 | 0 | 3 |
037bbb595fe19b4fe482677c3b65b344a1ba8eb9 | 378 | py | Python | tetris/spec/tetromino_factory_spec.py | sjbecque/tetris-python | 76d43f332f4299b9acc676dbc13e1e05ea0939ad | [
"MIT"
] | null | null | null | tetris/spec/tetromino_factory_spec.py | sjbecque/tetris-python | 76d43f332f4299b9acc676dbc13e1e05ea0939ad | [
"MIT"
] | null | null | null | tetris/spec/tetromino_factory_spec.py | sjbecque/tetris-python | 76d43f332f4299b9acc676dbc13e1e05ea0939ad | [
"MIT"
] | null | null | null | # author: Stephan Becque (https://github.com/sjbecque)
from expects import expect, equal, be_a, be
from tetris.src.tetromino_factory import TetrominoFactory
from tetris.src.cube_sets.tetromino import Tetromino
with describe(Cube) as self:
with describe('produce'):
with it('produces tetrominos'):
expect(TetrominoFactory().produce()).to(be_a(Tetromino)) | 42 | 68 | 0.746032 | 49 | 378 | 5.673469 | 0.612245 | 0.021583 | 0.093525 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0.142857 | 378 | 9 | 68 | 42 | 0.858025 | 0.137566 | 0 | 0 | 0 | 0 | 0.08 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | true | 0 | 0.428571 | 0 | 0.428571 | 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 | 1 | 0 | 1 | 0 | 0 | 0 | 0 | 3 |
037c5fb4d250de92c555f995f2b632bfbd77ad99 | 472 | py | Python | src/utils/my_exceptions.py | TLouf/multiling-twitter | 9a39b5b70da53ca717cb74480697f3756a95b8e4 | [
"RSA-MD"
] | 1 | 2021-05-09T15:42:04.000Z | 2021-05-09T15:42:04.000Z | src/utils/my_exceptions.py | TLouf/multiling-twitter | 9a39b5b70da53ca717cb74480697f3756a95b8e4 | [
"RSA-MD"
] | 3 | 2020-10-21T09:04:03.000Z | 2021-06-02T02:05:13.000Z | src/utils/my_exceptions.py | TLouf/multiling-twitter | 9a39b5b70da53ca717cb74480697f3756a95b8e4 | [
"RSA-MD"
] | null | null | null | class InputError(Exception):
"""Exception raised for errors in the input.
Attributes:
expression -- input expression in which the error occurred
message -- explanation of the error
"""
def __init__(self, expression, options):
self.expression = expression
self.message = (f"{expression} isn't a valid input, available options "
f"are {options}.")
def __str__(self):
return self.message
| 29.5 | 79 | 0.625 | 52 | 472 | 5.519231 | 0.576923 | 0.055749 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0.288136 | 472 | 15 | 80 | 31.466667 | 0.854167 | 0.332627 | 0 | 0 | 0 | 0 | 0.226027 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0.285714 | false | 0 | 0 | 0.142857 | 0.571429 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 0 | 1 | 1 | 0 | 0 | 3 |
cee34b884cf661602f6336ccebbeaaac5bf109e3 | 351 | py | Python | Layers/__init__.py | rjnp2/deep_learning_from_scratch | 9983379e5ec95ec497a62af182c16264cf737323 | [
"MIT"
] | 2 | 2021-02-22T09:08:22.000Z | 2021-07-29T14:23:35.000Z | Layers/__init__.py | rjnp2/deep_learning_from_scratch | 9983379e5ec95ec497a62af182c16264cf737323 | [
"MIT"
] | null | null | null | Layers/__init__.py | rjnp2/deep_learning_from_scratch | 9983379e5ec95ec497a62af182c16264cf737323 | [
"MIT"
] | null | null | null | #!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
Created on Fri Oct 2 15:30:05 2020
@author: rjn
"""
from .layer import Layer
from .conv2d import Conv2D
from .dense import Dense
from .dropout import Dropout
from .flatten import Flatten
from .neural_network import NeuralNetwork
from .pooling import MaxPooling2D
from .activation import Activation
| 21.9375 | 41 | 0.760684 | 51 | 351 | 5.215686 | 0.607843 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0.053512 | 0.148148 | 351 | 15 | 42 | 23.4 | 0.83612 | 0.264957 | 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 |
cee910642fc034a1d378e37965823afc321917e2 | 147 | py | Python | back/laudos/urls.py | ldurans/app-prontuario-tasy | 51098806e289326d7afdd9f4908b1aab75f6d308 | [
"Apache-2.0"
] | null | null | null | back/laudos/urls.py | ldurans/app-prontuario-tasy | 51098806e289326d7afdd9f4908b1aab75f6d308 | [
"Apache-2.0"
] | null | null | null | back/laudos/urls.py | ldurans/app-prontuario-tasy | 51098806e289326d7afdd9f4908b1aab75f6d308 | [
"Apache-2.0"
] | null | null | null | from django.urls import path
from .views import ListarLaudos
urlpatterns = [
path(r'lista/<int:cd_pessoa_fisica>/', ListarLaudos.as_view())
]
| 21 | 66 | 0.748299 | 20 | 147 | 5.35 | 0.8 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0.129252 | 147 | 6 | 67 | 24.5 | 0.835938 | 0 | 0 | 0 | 0 | 0 | 0.197279 | 0.197279 | 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 |
cef9cfd50069b01bb03df7803792b504f9f5b212 | 175 | py | Python | funcao1.py | welykPereira/pythonExerciciosFaculdade | 614f08d2951064e8ed991f238263624620e1696e | [
"MIT"
] | null | null | null | funcao1.py | welykPereira/pythonExerciciosFaculdade | 614f08d2951064e8ed991f238263624620e1696e | [
"MIT"
] | null | null | null | funcao1.py | welykPereira/pythonExerciciosFaculdade | 614f08d2951064e8ed991f238263624620e1696e | [
"MIT"
] | null | null | null | def soma(x1, y1):
res = x1 + y1
print('O resultado da soma e {}'.format(res))
x = int(input('Digite um valor!'))
y = int(input('Digite um outro valor!'))
soma(x, y)
| 19.444444 | 49 | 0.594286 | 31 | 175 | 3.354839 | 0.612903 | 0.076923 | 0.269231 | 0.307692 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0.028986 | 0.211429 | 175 | 8 | 50 | 21.875 | 0.724638 | 0 | 0 | 0 | 0 | 0 | 0.354286 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0.166667 | false | 0 | 0 | 0 | 0.166667 | 0.166667 | 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 |
3003cc8e3a01faa3c921f282959b4e319a7a2c20 | 213 | py | Python | make/photon/prepare/main.py | n-marton/harbor | 2859cd8b6981d329d2ef6720b90bbb074d370708 | [
"Apache-2.0"
] | null | null | null | make/photon/prepare/main.py | n-marton/harbor | 2859cd8b6981d329d2ef6720b90bbb074d370708 | [
"Apache-2.0"
] | null | null | null | make/photon/prepare/main.py | n-marton/harbor | 2859cd8b6981d329d2ef6720b90bbb074d370708 | [
"Apache-2.0"
] | null | null | null | from commands.prepare import prepare
from commands.gencerts import gencert
import click
@click.group()
def cli():
pass
cli.add_command(prepare)
cli.add_command(gencert)
if __name__ == '__main__':
cli()
| 15.214286 | 37 | 0.746479 | 29 | 213 | 5.137931 | 0.551724 | 0.161074 | 0.174497 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0.150235 | 213 | 13 | 38 | 16.384615 | 0.823204 | 0 | 0 | 0 | 0 | 0 | 0.037559 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0.1 | true | 0.1 | 0.3 | 0 | 0.4 | 0 | 1 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 1 | 0 | 0 | 0 | 0 | 0 | 3 |
300516fbcba2bfa83213892bb62c588afe19b868 | 1,290 | py | Python | models/parallel.py | yikaiw/AsymFusion | 25dbb6fddc02900dce86f50f87d3a498dc190351 | [
"MIT"
] | 6 | 2021-08-14T16:16:53.000Z | 2022-03-13T15:04:47.000Z | models/parallel.py | YaoAnbang/AsymFusion | 25dbb6fddc02900dce86f50f87d3a498dc190351 | [
"MIT"
] | null | null | null | models/parallel.py | YaoAnbang/AsymFusion | 25dbb6fddc02900dce86f50f87d3a498dc190351 | [
"MIT"
] | 3 | 2021-08-21T08:03:51.000Z | 2022-02-20T08:49:22.000Z | import torch.nn as nn
class ModuleParallel(nn.Module):
def __init__(self, module):
super(ModuleParallel, self).__init__()
self.module = module
def forward(self, x_parallel):
return [self.module(x) for x in x_parallel]
class ModuleIndivParallel(nn.Module):
def __init__(self, module, num_parallel, **kwargs):
super(ModuleIndivParallel, self).__init__()
for i in range(num_parallel):
setattr(self, 'module_' + str(i), module(**kwargs))
def forward(self, x_parallel):
return [getattr(self, 'module_' + str(i))(x) for i, x in enumerate(x_parallel)]
class BatchNorm2dParallel(nn.Module):
def __init__(self, num_features, num_parallel):
super(BatchNorm2dParallel, self).__init__()
for i in range(num_parallel):
setattr(self, 'bn_' + str(i), nn.BatchNorm2d(num_features))
def forward(self, x_parallel):
return [getattr(self, 'bn_' + str(i))(x) for i, x in enumerate(x_parallel)]
class ShareBatchNorm2dParallel(nn.Module):
def __init__(self, num_features, num_parallel):
super(ShareBatchNorm2dParallel, self).__init__()
self.bn_0 = nn.BatchNorm2d(num_features)
def forward(self, x_parallel):
return [self.bn_0(x) for x in x_parallel]
| 32.25 | 87 | 0.670543 | 167 | 1,290 | 4.850299 | 0.191617 | 0.088889 | 0.054321 | 0.074074 | 0.641975 | 0.641975 | 0.540741 | 0.495062 | 0.432099 | 0.432099 | 0 | 0.007828 | 0.207752 | 1,290 | 39 | 88 | 33.076923 | 0.784736 | 0 | 0 | 0.296296 | 0 | 0 | 0.015504 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0.296296 | false | 0 | 0.037037 | 0.148148 | 0.62963 | 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 |
300610f4c10d29f6b8e85c1eb3c923a7accfe293 | 271 | py | Python | examples/low-level/exception_manager.py | tezmen/vkbottle | 23740f3f65b8f255592db1f6145e8d9182b00021 | [
"MIT"
] | null | null | null | examples/low-level/exception_manager.py | tezmen/vkbottle | 23740f3f65b8f255592db1f6145e8d9182b00021 | [
"MIT"
] | null | null | null | examples/low-level/exception_manager.py | tezmen/vkbottle | 23740f3f65b8f255592db1f6145e8d9182b00021 | [
"MIT"
] | null | null | null | from vkbottle.exception_factory import VKAPIError
try:
raise VKAPIError(2, "Some exception occurred")
except VKAPIError(3):
print("Oh, third exception.")
except VKAPIError(2):
print("Oh, second exception.")
except VKAPIError():
print("Unknown vk error")
| 24.636364 | 50 | 0.726937 | 33 | 271 | 5.939394 | 0.606061 | 0.244898 | 0.255102 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0.0131 | 0.154982 | 271 | 10 | 51 | 27.1 | 0.842795 | 0 | 0 | 0 | 0 | 0 | 0.295203 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | true | 0 | 0.111111 | 0 | 0.111111 | 0.333333 | 0 | 0 | 0 | null | 1 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 3 |
301d9c0b1acec197ca6e08f7593020cec01117ad | 229 | py | Python | rsstodolist/urls.py | johanvo/rsstodolist-server | 5f6b8ba24b34e04c145ec27ac5559ecccdb41772 | [
"MIT"
] | 8 | 2015-03-14T12:51:25.000Z | 2020-12-14T09:45:15.000Z | rsstodolist/urls.py | paulgreg/rsstodolist-django-server | bbb23b8fbb579b6bac5add08b915a5d2cee592fa | [
"MIT"
] | null | null | null | rsstodolist/urls.py | paulgreg/rsstodolist-django-server | bbb23b8fbb579b6bac5add08b915a5d2cee592fa | [
"MIT"
] | 2 | 2015-10-03T02:35:37.000Z | 2019-02-24T11:04:33.000Z | from django.conf.urls import patterns, include, url
from django.contrib.staticfiles.urls import staticfiles_urlpatterns
urlpatterns = patterns('',
url(r'', include('feeds.urls')),
)
urlpatterns += staticfiles_urlpatterns()
| 25.444444 | 67 | 0.768559 | 26 | 229 | 6.692308 | 0.5 | 0.114943 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0.10917 | 229 | 8 | 68 | 28.625 | 0.852941 | 0 | 0 | 0 | 0 | 0 | 0.043668 | 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 |
304c5ea470f99a4924d23d56caffe41c64f29d21 | 181 | py | Python | component/__init__.py | kaiseu/pat-data-processing | 26cf8c8d4c4de4fa563bfba32309392a70418547 | [
"Apache-2.0"
] | 1 | 2018-03-23T03:03:04.000Z | 2018-03-23T03:03:04.000Z | component/__init__.py | kaiseu/pat-data-processing | 26cf8c8d4c4de4fa563bfba32309392a70418547 | [
"Apache-2.0"
] | 1 | 2017-09-22T05:42:47.000Z | 2017-09-22T06:47:20.000Z | utils/__init__.py | kaiseu/pat-data-processing | 26cf8c8d4c4de4fa563bfba32309392a70418547 | [
"Apache-2.0"
] | 2 | 2017-08-21T08:19:42.000Z | 2018-03-23T03:09:41.000Z | #!/usr/bin/python
# encoding: utf-8
"""
@author: xuk1
@license: (C) Copyright 2013-2017
@contact: kai.a.xu@intel.com
@file: test.py
@time: 8/15/2017 10:38
@desc:
"""
| 13.923077 | 34 | 0.60221 | 29 | 181 | 3.758621 | 0.931034 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0.143836 | 0.19337 | 181 | 12 | 35 | 15.083333 | 0.60274 | 0.856354 | 0 | null | 0 | null | 0 | 0 | null | 0 | 0 | 0 | null | 1 | null | true | 0 | 0 | null | null | null | 1 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 3 |
305016a85c24f83283cf507e68a4ed6e63f6b996 | 154 | py | Python | lewis_emulators/lakeshore340/__init__.py | ISISComputingGroup/EPICS-DeviceEmulator | 026c2a14a16bb204ea7527e3765daa182cafa814 | [
"BSD-3-Clause"
] | 2 | 2020-10-20T16:49:13.000Z | 2021-02-19T10:41:44.000Z | lewis_emulators/lakeshore340/__init__.py | ISISComputingGroup/EPICS-DeviceEmulator | 026c2a14a16bb204ea7527e3765daa182cafa814 | [
"BSD-3-Clause"
] | 9 | 2019-03-22T15:35:15.000Z | 2021-07-28T11:05:43.000Z | lewis_emulators/lakeshore340/__init__.py | ISISComputingGroup/EPICS-DeviceEmulator | 026c2a14a16bb204ea7527e3765daa182cafa814 | [
"BSD-3-Clause"
] | 1 | 2020-10-21T17:02:44.000Z | 2020-10-21T17:02:44.000Z | from .device import SimulatedLakeshore340
from ..lewis_versions import LEWIS_LATEST
framework_version = LEWIS_LATEST
__all__ = ['SimulatedLakeshore340']
| 25.666667 | 41 | 0.844156 | 16 | 154 | 7.625 | 0.625 | 0.180328 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0.043165 | 0.097403 | 154 | 5 | 42 | 30.8 | 0.834532 | 0 | 0 | 0 | 0 | 0 | 0.136364 | 0.136364 | 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 |
305ca745e839bcc1de48f3bc2a4b31e33e41ae51 | 291 | py | Python | eqcharinfo/models/specificsearchresult.py | Preocts/eqcharinfo | 424c1441cb0b1e4032f891d6a8895aa3b0a8316b | [
"MIT"
] | null | null | null | eqcharinfo/models/specificsearchresult.py | Preocts/eqcharinfo | 424c1441cb0b1e4032f891d6a8895aa3b0a8316b | [
"MIT"
] | 17 | 2021-09-21T21:33:07.000Z | 2022-03-28T18:56:17.000Z | eqcharinfo/models/specificsearchresult.py | Preocts/eqcharinfo | 424c1441cb0b1e4032f891d6a8895aa3b0a8316b | [
"MIT"
] | null | null | null | """Model of a returned search result"""
from dataclasses import dataclass
from eqcharinfo.models.generalsearchresult import GeneralSearchResult
@dataclass
class SpecificSearchResult(GeneralSearchResult):
"""Empty model of a specific search result"""
location: str
count: str
| 22.384615 | 69 | 0.780069 | 31 | 291 | 7.322581 | 0.645161 | 0.061674 | 0.070485 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0.151203 | 291 | 12 | 70 | 24.25 | 0.919028 | 0.250859 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | true | 0 | 0.333333 | 0 | 0.833333 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 1 | 0 | 1 | 0 | 0 | 3 |
306b6e5bc9beec0590235aa4805ed472409c4d2e | 769 | py | Python | commands/__init__.py | dnh-bot/dnh-werewolf-bot | b2a006a30819a3e1274360f61a6b5d299ca5b53e | [
"Unlicense"
] | 2 | 2022-03-27T00:13:16.000Z | 2022-03-27T06:19:37.000Z | commands/__init__.py | dnh-bot/dnh-werewolf-bot | b2a006a30819a3e1274360f61a6b5d299ca5b53e | [
"Unlicense"
] | 11 | 2021-09-14T10:58:05.000Z | 2021-10-02T06:54:36.000Z | commands/__init__.py | dnh-bot/dnh-werewolf-bot | b2a006a30819a3e1274360f61a6b5d299ca5b53e | [
"Unlicense"
] | 2 | 2021-09-23T08:08:28.000Z | 2021-09-29T16:59:48.000Z | """Add cmd decorator here for parsing command parameters"""
from config import TEXT_LANGUAGE
import utils
command_info = utils.common.read_json_file("json/command_info.json")
def get_all_commands():
return [*command_info.keys()]
def get_command_description(command):
# TODO: command == status: description = Show status of current phase.
if command in command_info:
return command_info[command]["description"][TEXT_LANGUAGE]
return None
def get_command_exclusive_roles(command):
if command in command_info:
return command_info[command]["exclusive_roles"]
return None
def get_command_param_number(command):
if command in command_info:
return command_info[command]["required_param_number"]
return None
| 23.30303 | 74 | 0.746424 | 101 | 769 | 5.425743 | 0.39604 | 0.180657 | 0.124088 | 0.09854 | 0.361314 | 0.277372 | 0.277372 | 0.277372 | 0.277372 | 0.193431 | 0 | 0 | 0.171652 | 769 | 32 | 75 | 24.03125 | 0.860283 | 0.159948 | 0 | 0.352941 | 0 | 0 | 0.107813 | 0.067188 | 0 | 0 | 0 | 0.03125 | 0 | 1 | 0.235294 | false | 0 | 0.117647 | 0.058824 | 0.764706 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | null | 0 | 0 | 1 | 0 | 0 | 1 | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 3 |
3072a5f243128ad7fe38f1e4daffaa746a02616b | 273 | py | Python | tests/test_pvaapi.py | sasaki77/pvarpc2web | 819fdbfdea4651fa4661c693ec38551f8c3a71e8 | [
"MIT"
] | null | null | null | tests/test_pvaapi.py | sasaki77/pvarpc2web | 819fdbfdea4651fa4661c693ec38551f8c3a71e8 | [
"MIT"
] | null | null | null | tests/test_pvaapi.py | sasaki77/pvarpc2web | 819fdbfdea4651fa4661c693ec38551f8c3a71e8 | [
"MIT"
] | null | null | null | from .context import pvarpc2web
from .context import config
from .context import pvaapi
class PvaRpcTimeoutConfig(config.DefaultConfig):
PVA_RPC_TIMEOUT = 3
def test_set_timeout():
app = pvarpc2web.create_app(PvaRpcTimeoutConfig)
assert pvaapi.timeout == 3
| 21 | 52 | 0.78022 | 33 | 273 | 6.30303 | 0.575758 | 0.158654 | 0.245192 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0.017316 | 0.153846 | 273 | 12 | 53 | 22.75 | 0.883117 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0.125 | 1 | 0.125 | false | 0 | 0.375 | 0 | 0.75 | 0 | 0 | 0 | 0 | null | 0 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 1 | 0 | 0 | 3 |
061e49dcba1ea0fc0e19a02798b156b24f901aa9 | 297 | py | Python | sofart/serializers/_json.py | toxinu/sofart | ec93cee5979ec02ea15955def837aed8f8804970 | [
"BSD-3-Clause"
] | 1 | 2018-03-02T17:49:44.000Z | 2018-03-02T17:49:44.000Z | sofart/serializers/_json.py | toxinu/sofart | ec93cee5979ec02ea15955def837aed8f8804970 | [
"BSD-3-Clause"
] | null | null | null | sofart/serializers/_json.py | toxinu/sofart | ec93cee5979ec02ea15955def837aed8f8804970 | [
"BSD-3-Clause"
] | null | null | null | import json
class Serializer(object):
def __init__(self, path):
self.path = path
def init(self, schema):
self.dump(schema)
def dump(self, dump):
with open(self.path, 'w') as f:
json.dump(dump, f)
f.closed
def load(self):
with open(self.path, 'r') as f:
return json.load(f)
| 16.5 | 33 | 0.653199 | 50 | 297 | 3.8 | 0.4 | 0.168421 | 0.115789 | 0.168421 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0.195286 | 297 | 17 | 34 | 17.470588 | 0.794979 | 0 | 0 | 0 | 0 | 0 | 0.006734 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0.307692 | false | 0 | 0.076923 | 0 | 0.538462 | 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 |
0625804b1720b6b0ed3269f17c907ede354720b1 | 215 | py | Python | vim/bundle/vim-template/templates/=template=.py | zruibin/vim_setting | 6829b004beb88b9d42e5a71d0c226291e9f0f7a7 | [
"MIT"
] | null | null | null | vim/bundle/vim-template/templates/=template=.py | zruibin/vim_setting | 6829b004beb88b9d42e5a71d0c226291e9f0f7a7 | [
"MIT"
] | null | null | null | vim/bundle/vim-template/templates/=template=.py | zruibin/vim_setting | 6829b004beb88b9d42e5a71d0c226291e9f0f7a7 | [
"MIT"
] | null | null | null | #! /usr/bin/env python
# -*- coding: utf-8 -*-
#
# %FFILE%
#
# Created by %USER% on %YEAR%/%MONTH%/%DAY%.
# Copyright (c) %YEAR%年 %USER% All rights reserved.
#
"""
%HERE%
"""
if __name__ == '__main__':
pass | 13.4375 | 51 | 0.553488 | 28 | 215 | 3.964286 | 0.928571 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0.005814 | 0.2 | 215 | 16 | 52 | 13.4375 | 0.639535 | 0.706977 | 0 | 0 | 0 | 0 | 0.166667 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | true | 0.5 | 0 | 0 | 0 | 0 | 1 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 1 | 0 | 0 | 0 | 0 | 0 | 3 |
065b1f997c3c002e3e4647638866e0ff0c5e43b1 | 150 | py | Python | src/Python3/A131610/exsample.py | umyuu/Sample | 66e8cd725b682db4c9bf93fb80786eea8cbad19d | [
"MIT"
] | null | null | null | src/Python3/A131610/exsample.py | umyuu/Sample | 66e8cd725b682db4c9bf93fb80786eea8cbad19d | [
"MIT"
] | null | null | null | src/Python3/A131610/exsample.py | umyuu/Sample | 66e8cd725b682db4c9bf93fb80786eea8cbad19d | [
"MIT"
] | null | null | null | # -*- coding: utf-8 -*-
import twitter
def main() -> None:
print(twitter.__path__)
print(dir(twitter))
if __name__ == '__main__':
main()
| 16.666667 | 27 | 0.606667 | 18 | 150 | 4.388889 | 0.722222 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0.008403 | 0.206667 | 150 | 8 | 28 | 18.75 | 0.655462 | 0.14 | 0 | 0 | 0 | 0 | 0.062992 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0.166667 | true | 0 | 0.166667 | 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 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 3 |
066014a87e5eee52c3d5b409b0f1d75035133d7a | 615 | py | Python | mods/mcpython/Item/Stone.py | uuk0/mcpython-a-minecraft-clone-in-python | c16cd66f319efdeec4130e1a43f5a857caf1ea13 | [
"MIT"
] | 2 | 2020-04-23T16:25:51.000Z | 2020-08-27T17:56:16.000Z | mods/mcpython/Item/Stone.py | uuk0/mcpython-a-minecraft-clone-in-python | c16cd66f319efdeec4130e1a43f5a857caf1ea13 | [
"MIT"
] | null | null | null | mods/mcpython/Item/Stone.py | uuk0/mcpython-a-minecraft-clone-in-python | c16cd66f319efdeec4130e1a43f5a857caf1ea13 | [
"MIT"
] | null | null | null | from .Item import *
class Stone(Item):
def getName(self):
return "minecraft:stone"
def getTexturFile(self):
return "./assets/textures/items/stone.png"
handler.register(Stone)
class Diorit(Item):
def getName(self):
return "minecraft:diorit"
def getTexturFile(self):
return "./assets/textures/items/diorite.png"
handler.register(Diorit)
class PolishedDiorit(Item):
def getName(self):
return "minecraft:polished_diorit"
def getTexturFile(self):
return "./assets/textures/items/polished_diorit.png"
handler.register(PolishedDiorit)
| 17.571429 | 60 | 0.682927 | 68 | 615 | 6.147059 | 0.308824 | 0.143541 | 0.100478 | 0.129187 | 0.588517 | 0.588517 | 0.351675 | 0.244019 | 0 | 0 | 0 | 0 | 0.201626 | 615 | 34 | 61 | 18.088235 | 0.851324 | 0 | 0 | 0.315789 | 0 | 0 | 0.271545 | 0.221138 | 0 | 0 | 0 | 0 | 0 | 1 | 0.315789 | false | 0 | 0.052632 | 0.315789 | 0.842105 | 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 |
06622f36b649c9b61db4bd5bfeb0c5a3b57884f2 | 105 | py | Python | ComputationalFinance/blackScholes.py | jetpotion/Python-Algorithms | e92b8950ced0bed46edf6c4a4a7558839205093c | [
"MIT"
] | null | null | null | ComputationalFinance/blackScholes.py | jetpotion/Python-Algorithms | e92b8950ced0bed46edf6c4a4a7558839205093c | [
"MIT"
] | null | null | null | ComputationalFinance/blackScholes.py | jetpotion/Python-Algorithms | e92b8950ced0bed46edf6c4a4a7558839205093c | [
"MIT"
] | null | null | null | # -*- coding: utf-8 -*-
"""
Spyder Editor
This is black scholes model
"""
def main():
def blackscholes:
| 11.666667 | 27 | 0.638095 | 14 | 105 | 4.785714 | 0.928571 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0.011628 | 0.180952 | 105 | 8 | 28 | 13.125 | 0.767442 | 0.2 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | null | null | 0 | 0 | null | null | 0 | 1 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 3 |
0678353cf6dbb5ad6fb3a0f08a3088ba6b13692d | 14,246 | py | Python | tests/components/mjpeg/test_config_flow.py | MrDelik/core | 93a66cc357b226389967668441000498a10453bb | [
"Apache-2.0"
] | 3 | 2021-11-22T22:37:43.000Z | 2022-03-17T00:55:28.000Z | tests/components/mjpeg/test_config_flow.py | MrDelik/core | 93a66cc357b226389967668441000498a10453bb | [
"Apache-2.0"
] | 25 | 2021-11-24T06:24:10.000Z | 2022-03-31T06:23:06.000Z | tests/components/mjpeg/test_config_flow.py | MrDelik/core | 93a66cc357b226389967668441000498a10453bb | [
"Apache-2.0"
] | 3 | 2022-01-02T18:49:54.000Z | 2022-01-25T02:03:54.000Z | """Tests for the MJPEG IP Camera config flow."""
from unittest.mock import AsyncMock
import requests
from requests_mock import Mocker
from homeassistant.components.mjpeg.const import (
CONF_MJPEG_URL,
CONF_STILL_IMAGE_URL,
DOMAIN,
)
from homeassistant.config_entries import SOURCE_IMPORT, SOURCE_USER
from homeassistant.const import (
CONF_AUTHENTICATION,
CONF_NAME,
CONF_PASSWORD,
CONF_USERNAME,
CONF_VERIFY_SSL,
HTTP_BASIC_AUTHENTICATION,
HTTP_DIGEST_AUTHENTICATION,
)
from homeassistant.core import HomeAssistant
from homeassistant.data_entry_flow import (
RESULT_TYPE_ABORT,
RESULT_TYPE_CREATE_ENTRY,
RESULT_TYPE_FORM,
)
from tests.common import MockConfigEntry
async def test_full_user_flow(
hass: HomeAssistant,
mock_mjpeg_requests: Mocker,
mock_setup_entry: AsyncMock,
) -> None:
"""Test the full user configuration flow."""
result = await hass.config_entries.flow.async_init(
DOMAIN, context={"source": SOURCE_USER}
)
assert result.get("type") == RESULT_TYPE_FORM
assert result.get("step_id") == SOURCE_USER
assert "flow_id" in result
result2 = await hass.config_entries.flow.async_configure(
result["flow_id"],
user_input={
CONF_NAME: "Spy cam",
CONF_MJPEG_URL: "https://example.com/mjpeg",
CONF_STILL_IMAGE_URL: "https://example.com/still",
CONF_USERNAME: "frenck",
CONF_PASSWORD: "omgpuppies",
CONF_VERIFY_SSL: False,
},
)
assert result2.get("type") == RESULT_TYPE_CREATE_ENTRY
assert result2.get("title") == "Spy cam"
assert result2.get("data") == {}
assert result2.get("options") == {
CONF_AUTHENTICATION: HTTP_BASIC_AUTHENTICATION,
CONF_MJPEG_URL: "https://example.com/mjpeg",
CONF_PASSWORD: "omgpuppies",
CONF_STILL_IMAGE_URL: "https://example.com/still",
CONF_USERNAME: "frenck",
CONF_VERIFY_SSL: False,
}
assert len(mock_setup_entry.mock_calls) == 1
assert mock_mjpeg_requests.call_count == 2
async def test_full_flow_with_authentication_error(
hass: HomeAssistant,
mock_mjpeg_requests: Mocker,
mock_setup_entry: AsyncMock,
) -> None:
"""Test the full user configuration flow with invalid credentials.
This tests tests a full config flow, with a case the user enters an invalid
credentials, but recovers by entering the correct ones.
"""
result = await hass.config_entries.flow.async_init(
DOMAIN, context={"source": SOURCE_USER}
)
assert result.get("type") == RESULT_TYPE_FORM
assert result.get("step_id") == SOURCE_USER
assert "flow_id" in result
mock_mjpeg_requests.get(
"https://example.com/mjpeg", text="Access Denied!", status_code=401
)
result2 = await hass.config_entries.flow.async_configure(
result["flow_id"],
user_input={
CONF_NAME: "Sky cam",
CONF_MJPEG_URL: "https://example.com/mjpeg",
CONF_PASSWORD: "omgpuppies",
CONF_USERNAME: "frenck",
},
)
assert result2.get("type") == RESULT_TYPE_FORM
assert result2.get("step_id") == SOURCE_USER
assert result2.get("errors") == {"username": "invalid_auth"}
assert "flow_id" in result2
assert len(mock_setup_entry.mock_calls) == 0
assert mock_mjpeg_requests.call_count == 2
mock_mjpeg_requests.get("https://example.com/mjpeg", text="resp")
result3 = await hass.config_entries.flow.async_configure(
result2["flow_id"],
user_input={
CONF_NAME: "Sky cam",
CONF_MJPEG_URL: "https://example.com/mjpeg",
CONF_PASSWORD: "supersecret",
CONF_USERNAME: "frenck",
},
)
assert result3.get("type") == RESULT_TYPE_CREATE_ENTRY
assert result3.get("title") == "Sky cam"
assert result3.get("data") == {}
assert result3.get("options") == {
CONF_AUTHENTICATION: HTTP_BASIC_AUTHENTICATION,
CONF_MJPEG_URL: "https://example.com/mjpeg",
CONF_PASSWORD: "supersecret",
CONF_STILL_IMAGE_URL: None,
CONF_USERNAME: "frenck",
CONF_VERIFY_SSL: True,
}
assert len(mock_setup_entry.mock_calls) == 1
assert mock_mjpeg_requests.call_count == 3
async def test_connection_error(
hass: HomeAssistant,
mock_mjpeg_requests: Mocker,
mock_setup_entry: AsyncMock,
) -> None:
"""Test connection error."""
result = await hass.config_entries.flow.async_init(
DOMAIN, context={"source": SOURCE_USER}
)
assert result.get("type") == RESULT_TYPE_FORM
assert result.get("step_id") == SOURCE_USER
assert "flow_id" in result
# Test connectione error on MJPEG url
mock_mjpeg_requests.get(
"https://example.com/mjpeg", exc=requests.exceptions.ConnectionError
)
result2 = await hass.config_entries.flow.async_configure(
result["flow_id"],
user_input={
CONF_NAME: "My cam",
CONF_MJPEG_URL: "https://example.com/mjpeg",
CONF_STILL_IMAGE_URL: "https://example.com/still",
},
)
assert result2.get("type") == RESULT_TYPE_FORM
assert result2.get("step_id") == SOURCE_USER
assert result2.get("errors") == {"mjpeg_url": "cannot_connect"}
assert "flow_id" in result2
assert len(mock_setup_entry.mock_calls) == 0
assert mock_mjpeg_requests.call_count == 1
# Reset
mock_mjpeg_requests.get("https://example.com/mjpeg", text="resp")
# Test connectione error on still url
mock_mjpeg_requests.get(
"https://example.com/still", exc=requests.exceptions.ConnectionError
)
result3 = await hass.config_entries.flow.async_configure(
result2["flow_id"],
user_input={
CONF_NAME: "My cam",
CONF_MJPEG_URL: "https://example.com/mjpeg",
CONF_STILL_IMAGE_URL: "https://example.com/still",
},
)
assert result3.get("type") == RESULT_TYPE_FORM
assert result3.get("step_id") == SOURCE_USER
assert result3.get("errors") == {"still_image_url": "cannot_connect"}
assert "flow_id" in result3
assert len(mock_setup_entry.mock_calls) == 0
assert mock_mjpeg_requests.call_count == 3
# Reset
mock_mjpeg_requests.get("https://example.com/still", text="resp")
# Finish
result4 = await hass.config_entries.flow.async_configure(
result3["flow_id"],
user_input={
CONF_NAME: "My cam",
CONF_MJPEG_URL: "https://example.com/mjpeg",
CONF_STILL_IMAGE_URL: "https://example.com/still",
},
)
assert result4.get("type") == RESULT_TYPE_CREATE_ENTRY
assert result4.get("title") == "My cam"
assert result4.get("data") == {}
assert result4.get("options") == {
CONF_AUTHENTICATION: HTTP_BASIC_AUTHENTICATION,
CONF_MJPEG_URL: "https://example.com/mjpeg",
CONF_PASSWORD: "",
CONF_STILL_IMAGE_URL: "https://example.com/still",
CONF_USERNAME: None,
CONF_VERIFY_SSL: True,
}
assert len(mock_setup_entry.mock_calls) == 1
assert mock_mjpeg_requests.call_count == 5
async def test_already_configured(
hass: HomeAssistant,
mock_mjpeg_requests: Mocker,
mock_config_entry: MockConfigEntry,
mock_setup_entry: AsyncMock,
) -> None:
"""Test we abort if the MJPEG IP Camera is already configured."""
mock_config_entry.add_to_hass(hass)
result = await hass.config_entries.flow.async_init(
DOMAIN, context={"source": SOURCE_USER}
)
assert "flow_id" in result
result2 = await hass.config_entries.flow.async_configure(
result["flow_id"],
user_input={
CONF_NAME: "My cam",
CONF_MJPEG_URL: "https://example.com/mjpeg",
},
)
assert result2.get("type") == RESULT_TYPE_ABORT
assert result2.get("reason") == "already_configured"
async def test_import_flow(
hass: HomeAssistant,
mock_mjpeg_requests: Mocker,
mock_setup_entry: AsyncMock,
) -> None:
"""Test the import configuration flow."""
result = await hass.config_entries.flow.async_init(
DOMAIN,
context={"source": SOURCE_IMPORT},
data={
CONF_AUTHENTICATION: HTTP_DIGEST_AUTHENTICATION,
CONF_MJPEG_URL: "http://example.com/mjpeg",
CONF_NAME: "Imported Camera",
CONF_PASSWORD: "omgpuppies",
CONF_STILL_IMAGE_URL: "http://example.com/still",
CONF_USERNAME: "frenck",
CONF_VERIFY_SSL: False,
},
)
assert result.get("type") == RESULT_TYPE_CREATE_ENTRY
assert result.get("title") == "Imported Camera"
assert result.get("data") == {}
assert result.get("options") == {
CONF_AUTHENTICATION: HTTP_DIGEST_AUTHENTICATION,
CONF_MJPEG_URL: "http://example.com/mjpeg",
CONF_PASSWORD: "omgpuppies",
CONF_STILL_IMAGE_URL: "http://example.com/still",
CONF_USERNAME: "frenck",
CONF_VERIFY_SSL: False,
}
assert len(mock_setup_entry.mock_calls) == 1
assert mock_mjpeg_requests.call_count == 0
async def test_import_flow_already_configured(
hass: HomeAssistant,
mock_config_entry: MockConfigEntry,
mock_setup_entry: AsyncMock,
) -> None:
"""Test the import configuration flow for an already configured entry."""
mock_config_entry.add_to_hass(hass)
result = await hass.config_entries.flow.async_init(
DOMAIN,
context={"source": SOURCE_IMPORT},
data={
CONF_AUTHENTICATION: HTTP_DIGEST_AUTHENTICATION,
CONF_MJPEG_URL: "https://example.com/mjpeg",
CONF_NAME: "Imported Camera",
CONF_PASSWORD: "omgpuppies",
CONF_STILL_IMAGE_URL: "https://example.com/still",
CONF_USERNAME: "frenck",
CONF_VERIFY_SSL: False,
},
)
assert result.get("type") == RESULT_TYPE_ABORT
assert result.get("reason") == "already_configured"
assert len(mock_setup_entry.mock_calls) == 0
async def test_options_flow(
hass: HomeAssistant,
mock_mjpeg_requests: Mocker,
init_integration: MockConfigEntry,
) -> None:
"""Test options config flow."""
result = await hass.config_entries.options.async_init(init_integration.entry_id)
assert result.get("type") == RESULT_TYPE_FORM
assert result.get("step_id") == "init"
assert "flow_id" in result
# Register a second camera
mock_mjpeg_requests.get("https://example.com/second_camera", text="resp")
mock_second_config_entry = MockConfigEntry(
title="Another Camera",
domain=DOMAIN,
data={},
options={
CONF_AUTHENTICATION: HTTP_BASIC_AUTHENTICATION,
CONF_MJPEG_URL: "https://example.com/second_camera",
CONF_PASSWORD: "",
CONF_STILL_IMAGE_URL: None,
CONF_USERNAME: None,
CONF_VERIFY_SSL: True,
},
)
mock_second_config_entry.add_to_hass(hass)
# Try updating options to already existing secondary camera
result2 = await hass.config_entries.options.async_configure(
result["flow_id"],
user_input={
CONF_MJPEG_URL: "https://example.com/second_camera",
},
)
assert result2.get("type") == RESULT_TYPE_FORM
assert result2.get("step_id") == "init"
assert result2.get("errors") == {"mjpeg_url": "already_configured"}
assert "flow_id" in result2
assert mock_mjpeg_requests.call_count == 1
# Test connectione error on MJPEG url
mock_mjpeg_requests.get(
"https://example.com/invalid_mjpeg", exc=requests.exceptions.ConnectionError
)
result3 = await hass.config_entries.options.async_configure(
result2["flow_id"],
user_input={
CONF_MJPEG_URL: "https://example.com/invalid_mjpeg",
CONF_STILL_IMAGE_URL: "https://example.com/still",
},
)
assert result3.get("type") == RESULT_TYPE_FORM
assert result3.get("step_id") == "init"
assert result3.get("errors") == {"mjpeg_url": "cannot_connect"}
assert "flow_id" in result3
assert mock_mjpeg_requests.call_count == 2
# Test connectione error on still url
mock_mjpeg_requests.get(
"https://example.com/invalid_still", exc=requests.exceptions.ConnectionError
)
result4 = await hass.config_entries.options.async_configure(
result3["flow_id"],
user_input={
CONF_MJPEG_URL: "https://example.com/mjpeg",
CONF_STILL_IMAGE_URL: "https://example.com/invalid_still",
},
)
assert result4.get("type") == RESULT_TYPE_FORM
assert result4.get("step_id") == "init"
assert result4.get("errors") == {"still_image_url": "cannot_connect"}
assert "flow_id" in result4
assert mock_mjpeg_requests.call_count == 4
# Invalid credentials
mock_mjpeg_requests.get(
"https://example.com/invalid_auth", text="Access Denied!", status_code=401
)
result5 = await hass.config_entries.options.async_configure(
result4["flow_id"],
user_input={
CONF_MJPEG_URL: "https://example.com/invalid_auth",
CONF_PASSWORD: "omgpuppies",
CONF_USERNAME: "frenck",
},
)
assert result5.get("type") == RESULT_TYPE_FORM
assert result5.get("step_id") == "init"
assert result5.get("errors") == {"username": "invalid_auth"}
assert "flow_id" in result5
assert mock_mjpeg_requests.call_count == 6
# Finish
result6 = await hass.config_entries.options.async_configure(
result5["flow_id"],
user_input={
CONF_MJPEG_URL: "https://example.com/mjpeg",
CONF_PASSWORD: "evenmorepuppies",
CONF_USERNAME: "newuser",
},
)
assert result6.get("type") == RESULT_TYPE_CREATE_ENTRY
assert result6.get("data") == {
CONF_AUTHENTICATION: HTTP_BASIC_AUTHENTICATION,
CONF_MJPEG_URL: "https://example.com/mjpeg",
CONF_PASSWORD: "evenmorepuppies",
CONF_STILL_IMAGE_URL: None,
CONF_USERNAME: "newuser",
CONF_VERIFY_SSL: True,
}
assert mock_mjpeg_requests.call_count == 7
| 32.230769 | 84 | 0.657097 | 1,701 | 14,246 | 5.209877 | 0.08642 | 0.046265 | 0.062627 | 0.054841 | 0.816746 | 0.778154 | 0.730986 | 0.648386 | 0.621079 | 0.593433 | 0 | 0.0081 | 0.228766 | 14,246 | 441 | 85 | 32.303855 | 0.798489 | 0.022182 | 0 | 0.579545 | 0 | 0 | 0.160319 | 0 | 0 | 0 | 0 | 0 | 0.235795 | 1 | 0 | false | 0.039773 | 0.045455 | 0 | 0.045455 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 1 | 1 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 3 |
06a206463d1ddf241fc7c83638ef9c4b1b74b6e7 | 169 | py | Python | apps/carts/admin.py | xeroz/gshop | d1bd0920d8ffaae9e7f52fcf8d60dd2d009cde2a | [
"MIT"
] | null | null | null | apps/carts/admin.py | xeroz/gshop | d1bd0920d8ffaae9e7f52fcf8d60dd2d009cde2a | [
"MIT"
] | 4 | 2020-02-11T21:31:46.000Z | 2020-06-05T00:43:08.000Z | apps/carts/admin.py | xeroz/gshop | d1bd0920d8ffaae9e7f52fcf8d60dd2d009cde2a | [
"MIT"
] | null | null | null | from django.contrib import admin
from .models import Cart
@admin.register(Cart)
class CartAdmin(admin.ModelAdmin):
filter_horizontal = (
'products',
)
| 16.9 | 34 | 0.704142 | 19 | 169 | 6.210526 | 0.736842 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0.201183 | 169 | 9 | 35 | 18.777778 | 0.874074 | 0 | 0 | 0 | 0 | 0 | 0.047337 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | false | 0 | 0.285714 | 0 | 0.571429 | 0 | 1 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 3 |
ebf7979b28c6f9ffcf00578c1b17ce1ea3e14658 | 401 | py | Python | otter/util/math.py | pathob/odoo-otter | 1bf5dbab3c3ef12a12cae604d82d4e6f855f37fc | [
"Apache-2.0"
] | null | null | null | otter/util/math.py | pathob/odoo-otter | 1bf5dbab3c3ef12a12cae604d82d4e6f855f37fc | [
"Apache-2.0"
] | 1 | 2022-01-10T15:05:53.000Z | 2022-01-10T15:05:53.000Z | otter/util/math.py | pathob/odoo-otter | 1bf5dbab3c3ef12a12cae604d82d4e6f855f37fc | [
"Apache-2.0"
] | null | null | null | import math
THIRD = 1.0/3
def float_mod(num):
return (int(num * 1000) % 1000) / 1000.0
def ceil_third(num):
if float_mod(num) < THIRD:
return math.floor(num)
return math.ceil(num)
def round_duration(num):
return ceil_third(num * 4.0) / 4.0
def ceil_duration(num):
return math.ceil(num * 4.0) / 4.0
def floor_duration(num):
return math.floor(num * 4.0) / 4.0
| 15.423077 | 44 | 0.630923 | 70 | 401 | 3.514286 | 0.271429 | 0.04878 | 0.158537 | 0.073171 | 0.260163 | 0.081301 | 0 | 0 | 0 | 0 | 0 | 0.090615 | 0.229426 | 401 | 25 | 45 | 16.04 | 0.705502 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0.357143 | false | 0 | 0.071429 | 0.285714 | 0.857143 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 0 | 1 | 1 | 0 | 0 | 3 |
232d0664b1be0db827cca9e98b6d93459bf2af74 | 41 | py | Python | fleming/version.py | ambitioninc/fleming | 9989afe0c932735442bac61f852e0584da0abc9e | [
"MIT"
] | 12 | 2015-01-25T21:45:32.000Z | 2020-03-26T10:47:35.000Z | fleming/version.py | ambitioninc/fleming | 9989afe0c932735442bac61f852e0584da0abc9e | [
"MIT"
] | 5 | 2015-01-25T21:53:56.000Z | 2021-11-19T14:36:51.000Z | fleming/version.py | ambitioninc/fleming | 9989afe0c932735442bac61f852e0584da0abc9e | [
"MIT"
] | 9 | 2015-01-25T22:27:08.000Z | 2019-03-18T17:25:02.000Z | # pragma: no cover
__version__ = '0.7.0'
| 13.666667 | 21 | 0.658537 | 7 | 41 | 3.285714 | 0.857143 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0.088235 | 0.170732 | 41 | 2 | 22 | 20.5 | 0.588235 | 0.390244 | 0 | 0 | 0 | 0 | 0.217391 | 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 |
233bf504a69bc169b88108595b0cdcba3501d612 | 197 | py | Python | setup.py | mwhit74/mlob | 8b999047c0ea00be3d9e74e9894b8f335db9e9b7 | [
"MIT"
] | 4 | 2019-08-30T12:09:00.000Z | 2020-09-03T13:24:21.000Z | setup.py | mwhit74/mlob | 8b999047c0ea00be3d9e74e9894b8f335db9e9b7 | [
"MIT"
] | null | null | null | setup.py | mwhit74/mlob | 8b999047c0ea00be3d9e74e9894b8f335db9e9b7 | [
"MIT"
] | null | null | null | # -*- coding: utf-8 -*-
"""
Created on Wed Aug 14 20:43:59 2019
@author: mwhitten
"""
from setuptools import setup, find_packages
setup(name='myproject', version='1.0', packages=find_packages()) | 19.7 | 64 | 0.695431 | 29 | 197 | 4.655172 | 0.862069 | 0.177778 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0.087719 | 0.13198 | 197 | 10 | 64 | 19.7 | 0.701754 | 0.390863 | 0 | 0 | 0 | 0 | 0.106195 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | true | 0 | 0.5 | 0 | 0.5 | 0 | 1 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 1 | 0 | 0 | 0 | 0 | 3 |
23429ab7017b05536849021b120baf27cf608581 | 732 | py | Python | unfolders/annealing/annealers/dwave_based/dwave_base_annealer.py | peguerosdc/unfolding_benchmark | 58c278c00317d8900f5f3cd986610f2f1c538f28 | [
"MIT"
] | null | null | null | unfolders/annealing/annealers/dwave_based/dwave_base_annealer.py | peguerosdc/unfolding_benchmark | 58c278c00317d8900f5f3cd986610f2f1c538f28 | [
"MIT"
] | null | null | null | unfolders/annealing/annealers/dwave_based/dwave_base_annealer.py | peguerosdc/unfolding_benchmark | 58c278c00317d8900f5f3cd986610f2f1c538f28 | [
"MIT"
] | null | null | null | from ..annealer import Annealer
from dwave.system import DWaveSampler
import minorminer
class DWaveBaseAnnealer(Annealer):
def __init__(self, topology, solver_parameters={}):
super().__init__(solver_parameters)
# Check if the topology is valid
if topology not in ["chimera", "pegasus"]:
raise ValueError("Topology must be either 'chimera' or 'pegasus'")
self.topology = topology
self.hardware_sampler = self.get_hardware_sampler()
def get_hardware_sampler(self):
return DWaveSampler(solver={"topology__type": self.topology})
def get_best_embedding(self, source_edges):
return minorminer.find_embedding(source_edges, self.hardware_sampler.edgelist)
| 36.6 | 86 | 0.721311 | 84 | 732 | 6.011905 | 0.5 | 0.118812 | 0.075248 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0.189891 | 732 | 19 | 87 | 38.526316 | 0.851602 | 0.040984 | 0 | 0 | 0 | 0 | 0.105714 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0.214286 | false | 0 | 0.214286 | 0.142857 | 0.642857 | 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 |
235e1081be9cf80081712c03cd6331bd80b3a665 | 1,224 | py | Python | fourparts/structures/voices/Voice.py | ruixuantan/FourParts | d28f7fa87830406a08e618bdfcb25d5d87e3e2a1 | [
"MIT"
] | null | null | null | fourparts/structures/voices/Voice.py | ruixuantan/FourParts | d28f7fa87830406a08e618bdfcb25d5d87e3e2a1 | [
"MIT"
] | 6 | 2020-10-09T04:25:07.000Z | 2021-04-20T20:29:03.000Z | fourparts/structures/voices/Voice.py | ruixuantan/FourParts | d28f7fa87830406a08e618bdfcb25d5d87e3e2a1 | [
"MIT"
] | null | null | null | BASS = "Bass"
TENOR = "Tenor"
ALTO = "Alto"
SOPRANO = "Soprano"
class Voice:
"""Represents the type of voice.
Attributes
----------
note : int
The note of the voice.
"""
def __init__(self, note):
"""Constructor method.
Parameters
----------
note : int
The note of the voice.
"""
self.note = note
def __eq__(self, other):
return self.__class__ == other.__class__ and self.note == other.note
def __str__(self):
return str(self.note)
def get_voice_name(self):
"""Gets the name of the class.
Returns
-------
"""
pass
class Soprano(Voice):
def __init__(self, note):
super().__init__(note)
def get_voice_name(self):
return SOPRANO
class Alto(Voice):
def __init__(self, note):
super().__init__(note)
def get_voice_name(self):
return ALTO
class Tenor(Voice):
def __init__(self, note):
super().__init__(note)
def get_voice_name(self):
return TENOR
class Bass(Voice):
def __init__(self, note):
super().__init__(note)
def get_voice_name(self):
return BASS
| 16.767123 | 76 | 0.553105 | 142 | 1,224 | 4.330986 | 0.211268 | 0.104065 | 0.097561 | 0.130081 | 0.517073 | 0.492683 | 0.455285 | 0.377236 | 0.377236 | 0.377236 | 0 | 0 | 0.322712 | 1,224 | 72 | 77 | 17 | 0.741858 | 0.176471 | 0 | 0.424242 | 0 | 0 | 0.022099 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0.363636 | false | 0.030303 | 0 | 0.181818 | 0.69697 | 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 |
23679b88c2ac4aad96514805e98a751c9456ad60 | 384 | py | Python | tests/ColorsTests.py | rubenafo/ay | 8351bfcd7a42d04839fe73d642a6808722e1920b | [
"Apache-2.0"
] | 2 | 2022-01-09T10:32:15.000Z | 2022-03-12T21:18:03.000Z | tests/ColorsTests.py | rubenafo/ay | 8351bfcd7a42d04839fe73d642a6808722e1920b | [
"Apache-2.0"
] | null | null | null | tests/ColorsTests.py | rubenafo/ay | 8351bfcd7a42d04839fe73d642a6808722e1920b | [
"Apache-2.0"
] | null | null | null |
import unittest
import colour
from ay.utils import Colors
class ColorsTests (unittest.TestCase):
def test_range_colors (self):
color_range = Colors.color("#000000", "#00aabb", 10)
self.assertEqual(10, len(color_range))
self.assertEqual(colour.Color("black").hex, color_range[0])
self.assertEqual(colour.Color("#00aabb").hex, color_range[9])
| 22.588235 | 69 | 0.690104 | 49 | 384 | 5.285714 | 0.489796 | 0.15444 | 0.162162 | 0.200772 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0.050633 | 0.177083 | 384 | 16 | 70 | 24 | 0.768987 | 0 | 0 | 0 | 0 | 0 | 0.068063 | 0 | 0 | 0 | 0 | 0 | 0.333333 | 1 | 0.111111 | false | 0 | 0.333333 | 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 | 0 | 0 | 0 | 1 | 0 | 1 | 0 | 0 | 3 |
2379592956529e9b2745e06fa612db5f2767b0bf | 793 | py | Python | configs/docker/settings_local.py | AnnaSvalova/anytask | f814b43c496f67a2efe2a150873a1ae32ad97449 | [
"MIT"
] | 31 | 2015-03-24T21:11:44.000Z | 2022-03-28T22:55:12.000Z | configs/docker/settings_local.py | AnnaSvalova/anytask | f814b43c496f67a2efe2a150873a1ae32ad97449 | [
"MIT"
] | 286 | 2015-06-11T10:32:16.000Z | 2022-03-28T12:01:04.000Z | configs/docker/settings_local.py | AnnaSvalova/anytask | f814b43c496f67a2efe2a150873a1ae32ad97449 | [
"MIT"
] | 44 | 2015-05-23T21:30:51.000Z | 2021-11-07T12:56:59.000Z | import os
# from anytask.settings_common import INSTALLED_APPS
DEBUG = os.environ.setdefault('DJANGO_DEBUG', 'False')
TEMPLATE_DEBUG = DEBUG
INSTALLED_APPS = list(INSTALLED_APPS) + ['jupyter']
DATABASES = {
'default': {
'ENGINE': 'django.db.backends.postgresql_psycopg2',
'NAME': os.environ.setdefault('DATABASE_NAME', 'postgres'),
'USER': os.environ.setdefault('DATABASE_USER', 'postgres'),
'PASSWORD': os.environ.setdefault('DATABASE_PASS', ''),
'HOST': os.environ.setdefault('DATABASE_HOST', ''),
'PORT': os.environ.setdefault('DATABASE_PORT', ''),
}
}
JUPYTER_NBGRADER_API_URL = 'http://localhost:8089'
JUPYTER_NBGRADER_AUTH_TOKEN = 'your-nbgradersk-token'
# JUPYTER_NBGRADER_DISABLED = True
JUPYTERHUB_URL = 'http://localhost' | 31.72 | 67 | 0.697352 | 87 | 793 | 6.114943 | 0.505747 | 0.101504 | 0.214286 | 0.253759 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0.007396 | 0.147541 | 793 | 25 | 68 | 31.72 | 0.779586 | 0.104666 | 0 | 0 | 0 | 0 | 0.336158 | 0.083333 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | false | 0.058824 | 0.058824 | 0 | 0.058824 | 0 | 0 | 0 | 0 | null | 0 | 1 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 0 | 0 | 0 | 3 |
88c1f0cad4db51991b7a7ffd77f0084a2b530d52 | 2,072 | py | Python | jacdac/dual_motors/client.py | microsoft/jacdac-python | 712ad5559e29065f5eccb5dbfe029c039132df5a | [
"MIT"
] | 1 | 2022-02-15T21:30:36.000Z | 2022-02-15T21:30:36.000Z | jacdac/dual_motors/client.py | microsoft/jacdac-python | 712ad5559e29065f5eccb5dbfe029c039132df5a | [
"MIT"
] | null | null | null | jacdac/dual_motors/client.py | microsoft/jacdac-python | 712ad5559e29065f5eccb5dbfe029c039132df5a | [
"MIT"
] | 1 | 2022-02-08T19:32:45.000Z | 2022-02-08T19:32:45.000Z | # Autogenerated file. Do not edit.
from jacdac.bus import Bus, Client
from .constants import *
from typing import Optional, Tuple
class DualMotorsClient(Client):
"""
A synchronized pair of motors.
Implements a client for the `Dual Motors <https://microsoft.github.io/jacdac-docs/services/dualmotors>`_ service.
"""
def __init__(self, bus: Bus, role: str) -> None:
super().__init__(bus, JD_SERVICE_CLASS_DUAL_MOTORS, JD_DUAL_MOTORS_PACK_FORMATS, role)
@property
def speed(self) -> Optional[Tuple[float, float]]:
"""
Relative speed of the motors. Use positive/negative values to run the motor forwards and backwards.
A speed of ``0`` while ``enabled`` acts as brake., left: /,right: /
"""
return self.register(JD_DUAL_MOTORS_REG_SPEED).value()
@speed.setter
def speed(self, value: Tuple[float, float]) -> None:
self.enabled = True
self.register(JD_DUAL_MOTORS_REG_SPEED).set_values(*value)
@property
def enabled(self) -> Optional[bool]:
"""
Turn the power to the motors on/off.,
"""
return self.register(JD_DUAL_MOTORS_REG_ENABLED).bool_value()
@enabled.setter
def enabled(self, value: bool) -> None:
self.register(JD_DUAL_MOTORS_REG_ENABLED).set_values(value)
@property
def load_torque(self) -> Optional[float]:
"""
(Optional) Torque required to produce the rated power of an each electrical motor at load speed., _: kg/cm
"""
return self.register(JD_DUAL_MOTORS_REG_LOAD_TORQUE).value()
@property
def load_rotation_speed(self) -> Optional[float]:
"""
(Optional) Revolutions per minute of the motor under full load., _: rpm
"""
return self.register(JD_DUAL_MOTORS_REG_LOAD_ROTATION_SPEED).value()
@property
def reversible(self) -> Optional[bool]:
"""
(Optional) Indicates if the motors can run backwards.,
"""
return self.register(JD_DUAL_MOTORS_REG_REVERSIBLE).bool_value()
| 31.393939 | 117 | 0.657336 | 263 | 2,072 | 4.961977 | 0.376426 | 0.076628 | 0.073563 | 0.096552 | 0.230651 | 0.192337 | 0.192337 | 0.056705 | 0 | 0 | 0 | 0.000631 | 0.234556 | 2,072 | 65 | 118 | 31.876923 | 0.822194 | 0.299228 | 0 | 0.178571 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0.285714 | false | 0 | 0.107143 | 0 | 0.607143 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 3 |
88cb007d60a287f6b2a63979292d21e6a42af9ca | 315 | py | Python | samsa/db/__init__.py | tombasche/samsa | c7e55f9cbc2f87df310a3ed8246b4c5784937984 | [
"MIT"
] | null | null | null | samsa/db/__init__.py | tombasche/samsa | c7e55f9cbc2f87df310a3ed8246b4c5784937984 | [
"MIT"
] | null | null | null | samsa/db/__init__.py | tombasche/samsa | c7e55f9cbc2f87df310a3ed8246b4c5784937984 | [
"MIT"
] | 1 | 2019-07-01T12:03:51.000Z | 2019-07-01T12:03:51.000Z | from enum import Enum
try:
from samsa.db.rocksdb import RocksDBClient
except ImportError:
pass
from samsa.db.sqldb import SQLiteClient
class ConnectionType(Enum):
"""
Defines the available connection types when defining the stateful consumer
"""
sqlite = 'sqlite'
rocksdb = 'rocksdb'
| 19.6875 | 78 | 0.720635 | 37 | 315 | 6.135135 | 0.675676 | 0.079295 | 0.096916 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0.212698 | 315 | 15 | 79 | 21 | 0.915323 | 0.234921 | 0 | 0 | 0 | 0 | 0.057778 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | false | 0.111111 | 0.444444 | 0 | 0.777778 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 1 | 0 | 1 | 0 | 0 | 3 |
88ce03d70cc7090fe65889af1a0086f995c78686 | 581 | py | Python | event_collector/app/__init__.py | RavenKyu/event-collector | 4a6dba7e46684af739b6160897638625715567e5 | [
"MIT"
] | null | null | null | event_collector/app/__init__.py | RavenKyu/event-collector | 4a6dba7e46684af739b6160897638625715567e5 | [
"MIT"
] | 4 | 2021-05-11T09:55:05.000Z | 2021-07-16T07:09:41.000Z | event_collector/app/__init__.py | RavenKyu/event-collector | 4a6dba7e46684af739b6160897638625715567e5 | [
"MIT"
] | null | null | null | from flask import Blueprint
class CustomBlueprint(Blueprint):
gv = dict()
def __init__(self, name, import_name, **kwargs):
Blueprint.__init__(self, name, import_name, **kwargs)
###############################################################################
class ExceptionResponse(Exception):
pass
###############################################################################
class NotFound(Exception):
pass
###############################################################################
class ExceptionScheduleReduplicated(Exception):
pass
| 23.24 | 79 | 0.421687 | 35 | 581 | 6.714286 | 0.514286 | 0.165957 | 0.102128 | 0.153191 | 0.238298 | 0.238298 | 0 | 0 | 0 | 0 | 0 | 0 | 0.11704 | 581 | 24 | 80 | 24.208333 | 0.45809 | 0 | 0 | 0.272727 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0.090909 | false | 0.272727 | 0.272727 | 0 | 0.818182 | 0.272727 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 1 | 0 | 0 | 3 |
88d7a20a891c1905c55e3ca7a35a15f1f00ce3d3 | 159 | py | Python | GUI/credentials.py | ProjectBlackFalcon/BlackFalconCore | 23af1829224738c06092e3e513a0bf2753b4c35f | [
"MIT"
] | 8 | 2019-05-26T19:44:28.000Z | 2021-01-31T14:53:17.000Z | GUI/credentials.py | ProjectBlackFalcon/BlackFalconCore | 23af1829224738c06092e3e513a0bf2753b4c35f | [
"MIT"
] | 8 | 2019-07-17T21:19:47.000Z | 2019-09-28T12:52:39.000Z | GUI/credentials.py | ProjectBlackFalcon/BlackFalconCore | 23af1829224738c06092e3e513a0bf2753b4c35f | [
"MIT"
] | null | null | null | import json
import os
with open(os.path.join(os.path.abspath(os.path.dirname(__file__)), '..', 'credentials.json'), 'r') as f:
credentials = json.load(f)
| 26.5 | 104 | 0.685535 | 25 | 159 | 4.2 | 0.6 | 0.171429 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0.119497 | 159 | 5 | 105 | 31.8 | 0.75 | 0 | 0 | 0 | 0 | 0 | 0.119497 | 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 |
88d8807afbade69645ffc5695935b989fbaae361 | 226 | py | Python | analytics.py | vote/gaballot | 27a4bad1bcb7e6284d7b00b69420a421e7a846bc | [
"MIT"
] | 2 | 2020-11-23T22:26:08.000Z | 2020-12-04T16:07:04.000Z | analytics.py | vote/gaballot | 27a4bad1bcb7e6284d7b00b69420a421e7a846bc | [
"MIT"
] | 15 | 2020-12-11T03:49:15.000Z | 2021-11-17T22:57:44.000Z | analytics.py | vote/gaballot | 27a4bad1bcb7e6284d7b00b69420a421e7a846bc | [
"MIT"
] | 1 | 2020-12-17T03:57:00.000Z | 2020-12-17T03:57:00.000Z | from datadog import DogStatsd
class GAStatsd(DogStatsd):
def __init__(self, *args, **kwargs):
super().__init__(*args, **kwargs)
self.constant_tags = self.constant_tags + ["env:prod"]
statsd = GAStatsd()
| 22.6 | 62 | 0.668142 | 26 | 226 | 5.423077 | 0.653846 | 0.141844 | 0.22695 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0.190265 | 226 | 9 | 63 | 25.111111 | 0.770492 | 0 | 0 | 0 | 0 | 0 | 0.035398 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0.166667 | false | 0 | 0.166667 | 0 | 0.5 | 0 | 1 | 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 | 0 | 0 | 0 | 3 |
88df12c69ba3e7f343bf97dfa20a657875c8e4f0 | 149 | py | Python | mokocchi/tomoko/lib/equal.py | mvasilkov/scrapheap | 53e30b88879ab8e4d80867b0ec7fa631ce46e55e | [
"MIT"
] | 2 | 2021-11-29T13:51:27.000Z | 2021-12-12T14:59:42.000Z | mokocchi/tomoko/lib/equal.py | mvasilkov/scrapheap | 53e30b88879ab8e4d80867b0ec7fa631ce46e55e | [
"MIT"
] | null | null | null | mokocchi/tomoko/lib/equal.py | mvasilkov/scrapheap | 53e30b88879ab8e4d80867b0ec7fa631ce46e55e | [
"MIT"
] | null | null | null | from PIL import ImageChops
def equal(a, b):
if a.size != b.size:
return False
return ImageChops.difference(a, b).getbbox() is None
| 18.625 | 56 | 0.651007 | 23 | 149 | 4.217391 | 0.695652 | 0.041237 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0.241611 | 149 | 7 | 57 | 21.285714 | 0.858407 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0.2 | false | 0 | 0.2 | 0 | 0.8 | 0 | 1 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 3 |
88ec9de9a45f1eb1c2afed31a389d58af1316427 | 348 | py | Python | src/kgm/models/matching/__init__.py | mberr/rank-based-evaluation | 76a0847eecf4350d92783e9773d6fc6b6c69ca51 | [
"MIT"
] | 5 | 2021-02-16T01:04:39.000Z | 2021-09-01T01:36:02.000Z | src/kgm/models/matching/__init__.py | mberr/rank-based-evaluation | 76a0847eecf4350d92783e9773d6fc6b6c69ca51 | [
"MIT"
] | null | null | null | src/kgm/models/matching/__init__.py | mberr/rank-based-evaluation | 76a0847eecf4350d92783e9773d6fc6b6c69ca51 | [
"MIT"
] | null | null | null | # coding=utf-8
"""Models for (knowledge) graph matching."""
from .base import GraphBasedKGMatchingModel, KGMatchingModel, PureEmbeddingModel, get_matching_model_by_name
from .gcn_align import GCNAlign
__all__ = [
'GraphBasedKGMatchingModel',
'GCNAlign',
'KGMatchingModel',
'PureEmbeddingModel',
'get_matching_model_by_name',
]
| 26.769231 | 108 | 0.761494 | 34 | 348 | 7.411765 | 0.647059 | 0.261905 | 0.285714 | 0.349206 | 0.436508 | 0.436508 | 0.436508 | 0 | 0 | 0 | 0 | 0.003333 | 0.137931 | 348 | 12 | 109 | 29 | 0.836667 | 0.149425 | 0 | 0 | 0 | 0 | 0.317241 | 0.175862 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | false | 0 | 0.222222 | 0 | 0.222222 | 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 |
00004cc4d438ac480f3f26243c6c5d545ed5e3fa | 234 | py | Python | Flipping an Image/Solution.py | veken1199/Coding-Challenges | f2b013056cb097b0a6950cab7d14e8970ca3cd6f | [
"MIT"
] | null | null | null | Flipping an Image/Solution.py | veken1199/Coding-Challenges | f2b013056cb097b0a6950cab7d14e8970ca3cd6f | [
"MIT"
] | null | null | null | Flipping an Image/Solution.py | veken1199/Coding-Challenges | f2b013056cb097b0a6950cab7d14e8970ca3cd6f | [
"MIT"
] | null | null | null | class Solution(object):
def flipAndInvertImage(self, A):
"""
:type A: List[List[int]]
:rtype: List[List[int]]
"""
return [[1-element for element in nested_array][::-1] for nested_array in A] | 33.428571 | 84 | 0.57265 | 30 | 234 | 4.4 | 0.6 | 0.121212 | 0.166667 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0.011834 | 0.277778 | 234 | 7 | 84 | 33.428571 | 0.769231 | 0.205128 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0.333333 | false | 0 | 0 | 0 | 1 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 3 |
00183342be339d00ee86266c1fc073e7bf2805f2 | 801 | py | Python | config.py | Salvi0/DiscordGods | f23355d5f7ed17a5102b9a697ce2a5321a00acd1 | [
"MIT"
] | null | null | null | config.py | Salvi0/DiscordGods | f23355d5f7ed17a5102b9a697ce2a5321a00acd1 | [
"MIT"
] | null | null | null | config.py | Salvi0/DiscordGods | f23355d5f7ed17a5102b9a697ce2a5321a00acd1 | [
"MIT"
] | null | null | null | import os
# Bot Setup
os.environ["prefix"] = "g!"
os.environ["token"] = "NzM5Mjc0NjkxMDg4MjIwMzEw.XyYFNQ.Mb6wJSHhpj9LP5bqO2Hb0w8NBQM"
os.environ["botlog"] = "603894328212848651"
os.environ["debugEnabled"] = "False"
# Database Setup
os.environ["db_type"] = "MySQL" # Either MySQL or Flat (or just leave empty for Flat SQLite)
os.environ["db_user"] = "USERNAME" # Defaults to root if empty
os.environ["db_pword"] = "PASSWORD" # Defaults to none if empty
os.environ["db_host"] = "HOST" # Defaults to localhost if empty
os.environ["db_port"] = "PORT" # Defaults to 3306
# Bot list API tokens
os.environ["top.gg_token"] = ""
os.environ["discord.bots.gg_token"] = ""
os.environ["discordbotlist.com_token"] = ""
os.environ["bots.ondiscord.xyz_token"] = ""
os.environ["botsfordiscord.com_token"] = ""
| 36.409091 | 93 | 0.714107 | 109 | 801 | 5.155963 | 0.477064 | 0.224199 | 0.097865 | 0.085409 | 0.096085 | 0 | 0 | 0 | 0 | 0 | 0 | 0.044034 | 0.121099 | 801 | 21 | 94 | 38.142857 | 0.754261 | 0.253433 | 0 | 0 | 0 | 0 | 0.480475 | 0.258065 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | true | 0.066667 | 0.066667 | 0 | 0.066667 | 0 | 0 | 0 | 0 | null | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 1 | 0 | 0 | 0 | 0 | 0 | 3 |
00237ed8fc8c00a6296b5bef0eeafc53633aa1db | 585 | py | Python | backend-service/users-service/app/app/utils.py | abhishek70/python-petclinic-microservices | e15a41a668958f35f1b962487cd2360c5c150f0b | [
"MIT"
] | 2 | 2021-05-19T07:21:59.000Z | 2021-09-15T17:30:08.000Z | backend-service/users-service/app/app/utils.py | abhishek70/python-petclinic-microservices | e15a41a668958f35f1b962487cd2360c5c150f0b | [
"MIT"
] | null | null | null | backend-service/users-service/app/app/utils.py | abhishek70/python-petclinic-microservices | e15a41a668958f35f1b962487cd2360c5c150f0b | [
"MIT"
] | null | null | null | from typing import Any, Dict, Optional
def send_email(
email_to: str,
subject_template: str = "",
html_template: str = "",
environment: Dict[str, Any] = {},
) -> None:
pass
def send_test_email(email_to: str) -> None:
pass
def send_reset_password_email(email_to: str, email: str, token: str) -> None:
pass
def send_new_account_email(email_to: str, username: str, password: str) -> None:
pass
def generate_password_reset_token(email: str) -> str:
pass
def verify_password_reset_token(token: str) -> Optional[str]:
pass
| 18.870968 | 80 | 0.65812 | 80 | 585 | 4.55 | 0.325 | 0.096154 | 0.131868 | 0.164835 | 0.098901 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0.22735 | 585 | 30 | 81 | 19.5 | 0.80531 | 0 | 0 | 0.333333 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0.333333 | false | 0.555556 | 0.055556 | 0 | 0.388889 | 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 |
0031bdf5e5bc7f116ec291228a46ba7c2de0a11a | 427 | py | Python | prettyqt/location/geocodingmanager.py | phil65/PrettyQt | 26327670c46caa039c9bd15cb17a35ef5ad72e6c | [
"MIT"
] | 7 | 2019-05-01T01:34:36.000Z | 2022-03-08T02:24:14.000Z | prettyqt/location/geocodingmanager.py | phil65/PrettyQt | 26327670c46caa039c9bd15cb17a35ef5ad72e6c | [
"MIT"
] | 141 | 2019-04-16T11:22:01.000Z | 2021-04-14T15:12:36.000Z | prettyqt/location/geocodingmanager.py | phil65/PrettyQt | 26327670c46caa039c9bd15cb17a35ef5ad72e6c | [
"MIT"
] | 5 | 2019-04-17T11:48:19.000Z | 2021-11-21T10:30:19.000Z | from __future__ import annotations
from prettyqt import core
from prettyqt.qt import QtLocation
QtLocation.QGeoCodingManager.__bases__ = (core.Object,)
class GeoCodingManager:
def __init__(self, item: QtLocation.QGeoCodingManager):
self.item = item
def __getattr__(self, val):
return getattr(self.item, val)
def get_locale(self) -> core.Locale:
return core.Locale(self.item.locale())
| 22.473684 | 59 | 0.725995 | 50 | 427 | 5.86 | 0.44 | 0.109215 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0.185012 | 427 | 18 | 60 | 23.722222 | 0.841954 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0.272727 | false | 0 | 0.272727 | 0.181818 | 0.818182 | 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 |
003e379b98a735b9edc0ed5b0879555f0f360df6 | 176 | py | Python | CodeChef/TWODISH/Solution.py | Pyush146/Hacktoberfest-Hack-Codes | 37480481e0ee07410c549a2a84984778a72de8d5 | [
"MIT"
] | 15 | 2021-10-06T07:34:15.000Z | 2022-01-25T06:58:59.000Z | CodeChef/TWODISH/Solution.py | Pyush146/Hacktoberfest-Hack-Codes | 37480481e0ee07410c549a2a84984778a72de8d5 | [
"MIT"
] | 55 | 2021-10-01T19:23:51.000Z | 2021-10-06T04:29:41.000Z | CodeChef/TWODISH/Solution.py | Pyush146/Hacktoberfest-Hack-Codes | 37480481e0ee07410c549a2a84984778a72de8d5 | [
"MIT"
] | 41 | 2021-10-01T19:30:51.000Z | 2021-10-05T19:36:15.000Z | for __ in range(int(input())):
N,A,B,C = map(int,input().split( ))
if A+C >= N and B>=N:
print("YES")
else:
print("NO")
| 25.142857 | 43 | 0.392045 | 25 | 176 | 2.68 | 0.68 | 0.238806 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0.414773 | 176 | 6 | 44 | 29.333333 | 0.650485 | 0 | 0 | 0 | 0 | 0 | 0.028409 | 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 |
004320ffa0112303762fd9b28a718ee921eb9066 | 151 | py | Python | webapps/website/urls.py | freewayz/django-starter | 3367ae9508f3715d53d6ddd0d72c9caf316e1ded | [
"MIT"
] | 2 | 2018-10-21T22:13:31.000Z | 2019-11-09T22:42:09.000Z | webapps/website/urls.py | Timtech4u/django-starter | c06a0a1940d101ba88295271af2432eca2e0f12a | [
"MIT"
] | 1 | 2018-10-10T10:45:29.000Z | 2018-10-10T10:45:29.000Z | webapps/website/urls.py | Timtech4u/django-starter | c06a0a1940d101ba88295271af2432eca2e0f12a | [
"MIT"
] | 1 | 2018-10-10T10:38:48.000Z | 2018-10-10T10:38:48.000Z | from django.conf.urls import url
from webapps.website import views
urlpatterns = [
url(r'^$', view=views.LandingPageView.as_view(), name="home")
] | 25.166667 | 65 | 0.728477 | 21 | 151 | 5.190476 | 0.761905 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0.125828 | 151 | 6 | 66 | 25.166667 | 0.825758 | 0 | 0 | 0 | 0 | 0 | 0.039474 | 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 |
00464a56071d43ebc2d5868e046b803d6247257e | 684 | py | Python | webfront/migrations/0008_dw_changes.py | ProteinsWebTeam/project-skeleton | 7aeb971ba2d9bfe272e0590bd4484afb61336b96 | [
"Apache-2.0"
] | 6 | 2020-05-25T17:35:52.000Z | 2022-03-26T00:45:55.000Z | webfront/migrations/0008_dw_changes.py | ProteinsWebTeam/project-skeleton | 7aeb971ba2d9bfe272e0590bd4484afb61336b96 | [
"Apache-2.0"
] | 76 | 2016-07-29T09:22:34.000Z | 2022-03-15T07:57:17.000Z | webfront/migrations/0008_dw_changes.py | ProteinsWebTeam/project-skeleton | 7aeb971ba2d9bfe272e0590bd4484afb61336b96 | [
"Apache-2.0"
] | 1 | 2017-04-09T20:08:30.000Z | 2017-04-09T20:08:30.000Z | # Generated by Django 3.0.1 on 2020-04-09 15:04
from django.db import migrations
import jsonfield.fields
class Migration(migrations.Migration):
dependencies = [("webfront", "0007_history")]
operations = [
migrations.RemoveField(model_name="set", name="integrated"),
migrations.RemoveField(model_name="set", name="is_set"),
migrations.RemoveField(model_name="structure", name="other_names"),
migrations.RemoveField(model_name="structure", name="short_name"),
migrations.AlterField(
model_name="protein",
name="structure",
field=jsonfield.fields.JSONField(default={}, null=True),
),
]
| 31.090909 | 75 | 0.662281 | 74 | 684 | 6 | 0.540541 | 0.101351 | 0.234234 | 0.27027 | 0.36036 | 0.36036 | 0 | 0 | 0 | 0 | 0 | 0.034862 | 0.203216 | 684 | 21 | 76 | 32.571429 | 0.779817 | 0.065789 | 0 | 0 | 1 | 0 | 0.152276 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | false | 0 | 0.133333 | 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 | 1 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 3 |
cc3687838bd1c1940e14df739873c6e9c69d4fe6 | 157 | py | Python | tests/integration/lib/ait_exceptions.py | afharo/elastic-stack-testing | 3aea11ea4627dc20a0578408191961ff11b5aa0b | [
"Apache-2.0"
] | 44 | 2018-03-10T19:43:47.000Z | 2022-03-13T09:41:56.000Z | tests/integration/lib/ait_exceptions.py | afharo/elastic-stack-testing | 3aea11ea4627dc20a0578408191961ff11b5aa0b | [
"Apache-2.0"
] | 144 | 2018-03-09T21:44:03.000Z | 2022-03-31T23:21:12.000Z | tests/integration/lib/ait_exceptions.py | afharo/elastic-stack-testing | 3aea11ea4627dc20a0578408191961ff11b5aa0b | [
"Apache-2.0"
] | 32 | 2018-03-06T19:56:47.000Z | 2021-11-03T11:27:27.000Z | '''
Created on Oct 3, 2017
@author: Liza Dayoub
'''
class IndexPatternDoesNotExist(Exception):
"""Raise when index pattern does not exist"""
pass
| 14.272727 | 49 | 0.687898 | 19 | 157 | 5.684211 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0.039683 | 0.197452 | 157 | 10 | 50 | 15.7 | 0.81746 | 0.535032 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | true | 0.5 | 0 | 0 | 0.5 | 0 | 1 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 1 | 0 | 0 | 0 | 0 | 0 | 3 |
cc4ac6d7539cd9a0b74cc06845ad0734b7605f3f | 4,623 | py | Python | datas/draw_pictures.py | Droliven/MSRGCN | 5d8d8e3365d3b23ca2ac734ace7e84135a6e3a9e | [
"MIT"
] | 28 | 2021-08-21T12:02:12.000Z | 2022-03-07T03:54:55.000Z | datas/draw_pictures.py | Droliven/MSRGCN | 5d8d8e3365d3b23ca2ac734ace7e84135a6e3a9e | [
"MIT"
] | 6 | 2021-09-07T03:05:51.000Z | 2022-02-24T03:00:04.000Z | datas/draw_pictures.py | Droliven/MSRGCN | 5d8d8e3365d3b23ca2ac734ace7e84135a6e3a9e | [
"MIT"
] | 6 | 2021-08-21T12:02:16.000Z | 2021-11-22T14:22:57.000Z | #!/usr/bin/env python
# encoding: utf-8
'''
@project : MSRGCN
@file : draw_pictures.py
@author : Droliven
@contact : droliven@163.com
@ide : PyCharm
@time : 2021-07-27 21:22
'''
import numpy as np
import matplotlib
matplotlib.use('agg')
import matplotlib.pyplot as plt
from mpl_toolkits.mplot3d import Axes3D
import seaborn as sns
def draw_pic_single(mydata, I, J, LR, full_path):
# 22, 3
# I
# J
# LR
# # ****************************
# # 调整坐标,规范数据格式,:这里由于转换过来后本身应满足需求,不需要专门 revert_coordinate 或者交换坐标轴
mydata = mydata[:, [0, 2, 1]]
# # ****************************
x = mydata[:, 0]
y = mydata[:, 1]
z = mydata[:, 2]
plt.figure()
ax = plt.subplot(111, projection='3d')
ax.grid(False)
ax.set_xlabel('x')
ax.set_ylabel('y')
ax.set_zlabel('z')
ax.set_xlim3d([-1000, 1000])
ax.set_ylim3d([-1000, 1000])
ax.set_zlim3d([-1000, 1000])
ax.scatter(x, y, z, c='b')
# (250, 40, 40) #FA2828 红
# (245, 125, 125) #F57D7D 粉
# (11, 11, 11) #0B0B0B 黑色
# (180, 180, 180) #B4B4B4 灰色
# Make connection matrix
for i in np.arange(len(I)):
x, y, z = [np.array([mydata[I[i], j], mydata[J[i], j]]) for j in range(3)]
ax.plot(x, y, z, lw=2, c='#B4B4B4' if LR[i] else '#B4B4B4')
plt.savefig(full_path)
plt.close()
def draw_pic_single_2d(mydata, I, J, LR, full_path):
x = mydata[:, 0]
y = mydata[:, 1]
plt.figure(figsize=(6, 6))
plt.scatter(x, y, c='r')
# (250, 40, 40) #FA2828 红
# (245, 125, 125) #F57D7D 粉
# (11, 11, 11) #0B0B0B 黑色
# (180, 180, 180) #B4B4B4 灰色
# Make connection matrix
for i in np.arange(len(I)):
x, y = [np.array([mydata[I[i], j], mydata[J[i], j]]) for j in range(2)]
# ax.plot(x, y, z, lw=2, color='#FA2828' if LR[i] else '#F57D7D')
# ax.plot(x, y, z, lw=2, color='#0B0B0B' if LR[i] else '#B4B4B4')
plt.plot(x, y, lw=2, color='g' if LR[i] else 'b')
plt.xlim((-800, 800))
plt.ylim((-1500, 800))
# 设置坐标轴名称
plt.xlabel('x')
plt.ylabel('y')
# 设置坐标轴刻度
my_x_ticks = np.arange(-1000, 1000, 200)
my_y_ticks = np.arange(-1000, 1000, 200)
plt.xticks(my_x_ticks)
plt.yticks(my_y_ticks)
plt.grid(False)
plt.savefig(full_path)
plt.close(1)
def draw_pic_gt_pred(gt, pred, I, J, LR, full_path):
# # ****************************
# # 调整坐标,规范数据格式,:这里由于转换过来后本身应满足需求,不需要专门 revert_coordinate 或者交换坐标轴
gt = gt[:, [0, 2, 1]]
pred = pred[:, [0, 2, 1]]
# # ****************************
plt.figure()
ax = plt.subplot(111, projection='3d')
ax.set_xlabel('x')
ax.set_ylabel('y')
ax.set_zlabel('z')
ax.set_xlim3d([-1000, 1000])
ax.set_ylim3d([-1000, 1000])
ax.set_zlim3d([-1000, 1000])
ax.scatter(gt[:, 0], gt[:, 1], gt[:, 2], c='k', linewidths=1)
ax.scatter(pred[:, 0], pred[:, 1], pred[:, 2], c='r', linewidths=1)
# (250, 40, 40) #FA2828 红
# (245, 125, 125) #F57D7D 粉
# (11, 11, 11) #0B0B0B 黑色
# (180, 180, 180) #B4B4B4 灰色
# Make connection matrix
for i in np.arange(len(I)):
x, y, z = [np.array([gt[I[i], j], gt[J[i], j]]) for j in range(3)]
ax.plot(x, y, z, lw=1, color='#0B0B0B' if LR[i] else '#B4B4B4')
for i in np.arange(len(I)):
x, y, z = [np.array([pred[I[i], j], pred[J[i], j]]) for j in range(3)]
ax.plot(x, y, z, lw=2, color='#FA2828' if LR[i] else '#F57D7D')
plt.savefig(full_path)
plt.close()
def draw_pic_gt_pred_2d(gt, pred, I, J, LR, full_path):
plt.figure(figsize=(6, 6))
plt.scatter(gt[:, 0], gt[:, 1], c='k', linewidths=1)
plt.scatter(pred[:, 0], pred[:, 1], c='r', linewidths=1)
# (250, 40, 40) #FA2828 红
# (245, 125, 125) #F57D7D 粉
# (11, 11, 11) #0B0B0B 黑色
# (180, 180, 180) #B4B4B4 灰色
# Make connection matrix
for i in np.arange(len(I)):
x, y = [np.array([gt[I[i], j], gt[J[i], j]]) for j in range(2)]
plt.plot(x, y, lw=1, color='#0B0B0B' if LR[i] else '#B4B4B4')
for i in np.arange(len(I)):
x, y = [np.array([pred[I[i], j], pred[J[i], j]]) for j in range(2)]
plt.plot(x, y, lw=2, color='#FA2828' if LR[i] else '#F57D7D')
plt.xlim((-800, 800))
plt.ylim((-1500, 800))
# 设置坐标轴名称
plt.xlabel('x')
plt.ylabel('y')
# 设置坐标轴刻度
my_x_ticks = np.arange(-1000, 1000, 200)
my_y_ticks = np.arange(-1000, 1000, 200)
plt.xticks(my_x_ticks)
plt.yticks(my_y_ticks)
plt.grid(False)
plt.savefig(full_path)
plt.close(1)
if __name__ == "__main__":
import numpy as np
data = np.random.randn(220, 220)
| 27.035088 | 82 | 0.542289 | 763 | 4,623 | 3.207077 | 0.183486 | 0.013895 | 0.011034 | 0.029424 | 0.819371 | 0.791582 | 0.757662 | 0.6604 | 0.653045 | 0.594606 | 0 | 0.122437 | 0.24032 | 4,623 | 170 | 83 | 27.194118 | 0.574317 | 0.231884 | 0 | 0.622222 | 0 | 0 | 0.029606 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0.044444 | false | 0 | 0.066667 | 0 | 0.111111 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 1 | 1 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 3 |
cc5253a9abe12b6e9a6523adb43097213f7ee788 | 1,393 | py | Python | cupy/testing/_attr.py | Onkar627/cupy | 8eef1ad5393c0a92c5065bc05137bf997f37044a | [
"MIT"
] | 6,180 | 2016-11-01T14:22:30.000Z | 2022-03-31T08:39:20.000Z | cupy/testing/_attr.py | Onkar627/cupy | 8eef1ad5393c0a92c5065bc05137bf997f37044a | [
"MIT"
] | 6,281 | 2016-12-22T07:42:31.000Z | 2022-03-31T19:57:02.000Z | cupy/testing/_attr.py | Onkar627/cupy | 8eef1ad5393c0a92c5065bc05137bf997f37044a | [
"MIT"
] | 829 | 2017-02-23T05:46:12.000Z | 2022-03-27T17:40:03.000Z | import os
from cupy.testing._pytest_impl import is_available, check_available
if is_available():
import pytest
_gpu_limit = int(os.getenv('CUPY_TEST_GPU_LIMIT', '-1'))
def gpu(*args, **kwargs):
return pytest.mark.gpu(*args, **kwargs)
def cudnn(*args, **kwargs):
return pytest.mark.cudnn(*args, **kwargs)
def slow(*args, **kwargs):
return pytest.mark.slow(*args, **kwargs)
else:
def _dummy_callable(*args, **kwargs):
check_available('pytest attributes')
assert False # Not reachable
gpu = _dummy_callable
cudnn = _dummy_callable
slow = _dummy_callable
def multi_gpu(gpu_num):
"""Decorator to indicate number of GPUs required to run the test.
Tests can be annotated with this decorator (e.g., ``@multi_gpu(2)``) to
declare number of GPUs required to run. When running tests, if
``CUPY_TEST_GPU_LIMIT`` environment variable is set to value greater
than or equals to 0, test cases that require GPUs more than the limit will
be skipped.
"""
check_available('multi_gpu attribute')
# at this point we know pytest is available for sure
assert 1 < gpu_num
def _wrapper(f):
return pytest.mark.skipif(
0 <= _gpu_limit < gpu_num,
reason='{} GPUs required'.format(gpu_num))(
pytest.mark.multi_gpu(f))
return _wrapper
| 26.788462 | 78 | 0.659727 | 192 | 1,393 | 4.604167 | 0.427083 | 0.079186 | 0.072398 | 0.074661 | 0.144796 | 0.056561 | 0 | 0 | 0 | 0 | 0 | 0.004721 | 0.23977 | 1,393 | 51 | 79 | 27.313725 | 0.830028 | 0.301508 | 0 | 0 | 0 | 0 | 0.077577 | 0 | 0 | 0 | 0 | 0 | 0.074074 | 1 | 0.222222 | false | 0 | 0.111111 | 0.148148 | 0.518519 | 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 |
cc610f013fe3ae9c1b117b1e4b24b8df42776916 | 144 | py | Python | scripts/cluster-serving/cluster-serving-py-setup.py | thalvari/analytics-zoo | 4f4c5095c3db9363f5a23ca312a95bbdc6a3db91 | [
"Apache-2.0"
] | 1 | 2021-06-06T02:26:15.000Z | 2021-06-06T02:26:15.000Z | scripts/cluster-serving/cluster-serving-py-setup.py | thalvari/analytics-zoo | 4f4c5095c3db9363f5a23ca312a95bbdc6a3db91 | [
"Apache-2.0"
] | 1 | 2021-01-20T15:41:01.000Z | 2021-01-20T15:41:01.000Z | scripts/cluster-serving/cluster-serving-py-setup.py | thalvari/analytics-zoo | 4f4c5095c3db9363f5a23ca312a95bbdc6a3db91 | [
"Apache-2.0"
] | 2 | 2020-09-10T04:24:37.000Z | 2021-06-06T02:26:47.000Z | #!/usr/bin/python3
from zoo.serving.server import ClusterServing
serving = ClusterServing()
print("Cluster Serving has been properly set up.") | 24 | 50 | 0.784722 | 19 | 144 | 5.947368 | 0.842105 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0.007813 | 0.111111 | 144 | 6 | 50 | 24 | 0.875 | 0.118056 | 0 | 0 | 0 | 0 | 0.322835 | 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 |
cc711c6c32001179331b62b53b7e8341d3eb2683 | 147 | py | Python | kinopoisk_unofficial/model/box_office.py | masterWeber/kinopoisk-api-unofficial-client | 5c95e1ec6e43bd302399b63a1525ee7e61724155 | [
"MIT"
] | 2 | 2021-11-13T12:23:41.000Z | 2021-12-24T14:09:49.000Z | kinopoisk_unofficial/model/box_office.py | masterWeber/kinopoisk-api-unofficial-client | 5c95e1ec6e43bd302399b63a1525ee7e61724155 | [
"MIT"
] | 1 | 2022-03-29T19:13:24.000Z | 2022-03-30T18:57:23.000Z | kinopoisk_unofficial/model/box_office.py | masterWeber/kinopoisk-api-unofficial-client | 5c95e1ec6e43bd302399b63a1525ee7e61724155 | [
"MIT"
] | 1 | 2021-11-13T12:30:01.000Z | 2021-11-13T12:30:01.000Z | from dataclasses import dataclass
@dataclass
class BoxOffice:
type: str
amount: int
currency_code: str
name: str
symbol: str
| 13.363636 | 33 | 0.687075 | 18 | 147 | 5.555556 | 0.777778 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0.265306 | 147 | 10 | 34 | 14.7 | 0.925926 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | true | 0 | 0.125 | 0 | 0.875 | 0 | 1 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 0 | 1 | 0 | 0 | 3 |
cc91c22591bb470e98c8637b289b8ee27d3789a6 | 176 | py | Python | aulas/aula10a.py | CarlosWillian/python | f863578245fbf402e5b46f844a247355afed0d62 | [
"MIT"
] | null | null | null | aulas/aula10a.py | CarlosWillian/python | f863578245fbf402e5b46f844a247355afed0d62 | [
"MIT"
] | null | null | null | aulas/aula10a.py | CarlosWillian/python | f863578245fbf402e5b46f844a247355afed0d62 | [
"MIT"
] | null | null | null | tempo = int(input('Quantos anos tem seu carro? '))
if tempo <=3:
print('Tá novinho hein')
else:
print('Tá na hora de trocar essa lata velha hein!')
print('---FIM---')
| 22 | 55 | 0.630682 | 28 | 176 | 3.964286 | 0.821429 | 0.126126 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0.007042 | 0.193182 | 176 | 7 | 56 | 25.142857 | 0.774648 | 0 | 0 | 0 | 0 | 0 | 0.537143 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | false | 0 | 0 | 0 | 0 | 0.5 | 1 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 3 |
cc9a56356734ad23d5c824b33899f1d41f737e4c | 214 | py | Python | graph_coloring/approx1.py | rasakereh/my_DataStructure_practice | 9b36c4ac9a0c67fa0f751e22273dfffc88e4e416 | [
"MIT"
] | null | null | null | graph_coloring/approx1.py | rasakereh/my_DataStructure_practice | 9b36c4ac9a0c67fa0f751e22273dfffc88e4e416 | [
"MIT"
] | null | null | null | graph_coloring/approx1.py | rasakereh/my_DataStructure_practice | 9b36c4ac9a0c67fa0f751e22273dfffc88e4e416 | [
"MIT"
] | null | null | null | #datastructures and algoorithm fundamentals, Dr M.Ghodsi, page6, a greedy solution:
# I use adjacency matrix to implement the graph, because we frequently check adjacency of two vertex
class Graph:
adjMatrix =
| 30.571429 | 100 | 0.78972 | 30 | 214 | 5.633333 | 0.933333 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0.005587 | 0.163551 | 214 | 6 | 101 | 35.666667 | 0.938547 | 0.845794 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | null | null | 0 | 0 | null | null | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 0 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 3 |
cca7195cb683672d3a990b9aa09641e0494757cf | 1,610 | py | Python | gencode/python/udmi/schema/config_localnet.py | johnrandolph/udmi | 5e9de32fc71de8d006cda2eba4d3372eaf24c7c0 | [
"Apache-2.0"
] | 1 | 2022-02-24T22:57:37.000Z | 2022-02-24T22:57:37.000Z | gencode/python/udmi/schema/config_localnet.py | johnrandolph/udmi | 5e9de32fc71de8d006cda2eba4d3372eaf24c7c0 | [
"Apache-2.0"
] | 5 | 2022-02-24T21:32:24.000Z | 2022-03-23T15:52:25.000Z | gencode/python/udmi/schema/config_localnet.py | johnrandolph/udmi | 5e9de32fc71de8d006cda2eba4d3372eaf24c7c0 | [
"Apache-2.0"
] | null | null | null | """Generated class for config_localnet.json"""
class Object75D54154:
"""Generated schema class"""
def __init__(self):
self.id = None
@staticmethod
def from_dict(source):
if not source:
return None
result = Object75D54154()
result.id = source.get('id')
return result
@staticmethod
def map_from(source):
if not source:
return None
result = {}
for key in source:
result[key] = Object75D54154.from_dict(source[key])
return result
@staticmethod
def expand_dict(input):
result = {}
for property in input:
result[property] = input[property].to_dict() if input[property] else {}
return result
def to_dict(self):
result = {}
if self.id:
result['id'] = self.id # 5
return result
class LocalnetConfig:
"""Generated schema class"""
def __init__(self):
self.families = None
@staticmethod
def from_dict(source):
if not source:
return None
result = LocalnetConfig()
result.families = Object75D54154.map_from(source.get('families'))
return result
@staticmethod
def map_from(source):
if not source:
return None
result = {}
for key in source:
result[key] = LocalnetConfig.from_dict(source[key])
return result
@staticmethod
def expand_dict(input):
result = {}
for property in input:
result[property] = input[property].to_dict() if input[property] else {}
return result
def to_dict(self):
result = {}
if self.families:
result['families'] = Object75D54154.expand_dict(self.families) # 2
return result
| 21.184211 | 77 | 0.650311 | 194 | 1,610 | 5.278351 | 0.175258 | 0.09375 | 0.054688 | 0.066406 | 0.697266 | 0.697266 | 0.697266 | 0.628906 | 0.628906 | 0.628906 | 0 | 0.030378 | 0.243478 | 1,610 | 75 | 78 | 21.466667 | 0.810345 | 0.056522 | 0 | 0.758621 | 1 | 0 | 0.013316 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0.172414 | false | 0 | 0 | 0 | 0.413793 | 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 | 1 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 3 |
ccbc676c3dcd9756a7ee8192a9c1c6a373bb15ba | 5,131 | py | Python | temboo/core/Library/Facebook/Publishing/PublishLink.py | jordanemedlock/psychtruths | 52e09033ade9608bd5143129f8a1bfac22d634dd | [
"Apache-2.0"
] | 7 | 2016-03-07T02:07:21.000Z | 2022-01-21T02:22:41.000Z | temboo/core/Library/Facebook/Publishing/PublishLink.py | jordanemedlock/psychtruths | 52e09033ade9608bd5143129f8a1bfac22d634dd | [
"Apache-2.0"
] | null | null | null | temboo/core/Library/Facebook/Publishing/PublishLink.py | jordanemedlock/psychtruths | 52e09033ade9608bd5143129f8a1bfac22d634dd | [
"Apache-2.0"
] | 8 | 2016-06-14T06:01:11.000Z | 2020-04-22T09:21:44.000Z | # -*- coding: utf-8 -*-
###############################################################################
#
# PublishLink
# Publishes a link on a given profile.
#
# Python versions 2.6, 2.7, 3.x
#
# Copyright 2014, Temboo Inc.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing,
# software distributed under the License is distributed on an
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND,
# either express or implied. See the License for the specific
# language governing permissions and limitations under the License.
#
#
###############################################################################
from temboo.core.choreography import Choreography
from temboo.core.choreography import InputSet
from temboo.core.choreography import ResultSet
from temboo.core.choreography import ChoreographyExecution
import json
class PublishLink(Choreography):
def __init__(self, temboo_session):
"""
Create a new instance of the PublishLink Choreo. A TembooSession object, containing a valid
set of Temboo credentials, must be supplied.
"""
super(PublishLink, self).__init__(temboo_session, '/Library/Facebook/Publishing/PublishLink')
def new_input_set(self):
return PublishLinkInputSet()
def _make_result_set(self, result, path):
return PublishLinkResultSet(result, path)
def _make_execution(self, session, exec_id, path):
return PublishLinkChoreographyExecution(session, exec_id, path)
class PublishLinkInputSet(InputSet):
"""
An InputSet with methods appropriate for specifying the inputs to the PublishLink
Choreo. The InputSet object is used to specify input parameters when executing this Choreo.
"""
def set_AccessToken(self, value):
"""
Set the value of the AccessToken input for this Choreo. ((required, string) The access token retrieved from the final step of the OAuth process.)
"""
super(PublishLinkInputSet, self)._set_input('AccessToken', value)
def set_Caption(self, value):
"""
Set the value of the Caption input for this Choreo. ((optional, string) Deprecated (retained for backward compatibility only).)
"""
super(PublishLinkInputSet, self)._set_input('Caption', value)
def set_Description(self, value):
"""
Set the value of the Description input for this Choreo. ((optional, string) Deprecated (retained for backward compatibility only).)
"""
super(PublishLinkInputSet, self)._set_input('Description', value)
def set_Link(self, value):
"""
Set the value of the Link input for this Choreo. ((required, string) The link to publish.)
"""
super(PublishLinkInputSet, self)._set_input('Link', value)
def set_Message(self, value):
"""
Set the value of the Message input for this Choreo. ((optional, string) A message about the link.)
"""
super(PublishLinkInputSet, self)._set_input('Message', value)
def set_Name(self, value):
"""
Set the value of the Name input for this Choreo. ((optional, string) Deprecated (retained for backward compatibility only).)
"""
super(PublishLinkInputSet, self)._set_input('Name', value)
def set_Picture(self, value):
"""
Set the value of the Picture input for this Choreo. ((optional, string) Deprecated (retained for backward compatibility only).)
"""
super(PublishLinkInputSet, self)._set_input('Picture', value)
def set_ProfileID(self, value):
"""
Set the value of the ProfileID input for this Choreo. ((optional, string) The id of the profile that the link will be published to. Defaults to "me" indicating the authenticated user.)
"""
super(PublishLinkInputSet, self)._set_input('ProfileID', value)
def set_ResponseFormat(self, value):
"""
Set the value of the ResponseFormat input for this Choreo. ((optional, string) The format that the response should be in. Can be set to xml or json. Defaults to json.)
"""
super(PublishLinkInputSet, self)._set_input('ResponseFormat', value)
class PublishLinkResultSet(ResultSet):
"""
A ResultSet with methods tailored to the values returned by the PublishLink Choreo.
The ResultSet object is used to retrieve the results of a Choreo execution.
"""
def getJSONFromString(self, str):
return json.loads(str)
def get_Response(self):
"""
Retrieve the value for the "Response" output from this Choreo execution. (The response from Facebook. Corresponds to the ResponseFormat input. Defaults to JSON.)
"""
return self._output.get('Response', None)
class PublishLinkChoreographyExecution(ChoreographyExecution):
def _make_result_set(self, response, path):
return PublishLinkResultSet(response, path)
| 41.715447 | 192 | 0.676281 | 617 | 5,131 | 5.541329 | 0.286872 | 0.019011 | 0.031588 | 0.039485 | 0.351272 | 0.249488 | 0.240129 | 0.133372 | 0.133372 | 0.133372 | 0 | 0.003447 | 0.208341 | 5,131 | 122 | 193 | 42.057377 | 0.838257 | 0.483726 | 0 | 0 | 0 | 0 | 0.056221 | 0.018433 | 0 | 0 | 0 | 0 | 0 | 1 | 0.390244 | false | 0 | 0.121951 | 0.121951 | 0.756098 | 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 |
ccbf1a9aaea1d667a60309b78ab003c0ab18fc3a | 991 | py | Python | chapter4/docs.py | rongpenl/design-patterns-python | cbe7e6da6ae94604abad256bd807af1642fee915 | [
"MIT"
] | 1 | 2020-09-21T14:33:55.000Z | 2020-09-21T14:33:55.000Z | chapter4/docs.py | rongpenl/design-patterns-python | cbe7e6da6ae94604abad256bd807af1642fee915 | [
"MIT"
] | null | null | null | chapter4/docs.py | rongpenl/design-patterns-python | cbe7e6da6ae94604abad256bd807af1642fee915 | [
"MIT"
] | null | null | null | # factory pattern and abstract factory pattern
from abc import ABC, abstractmethod
'''
DocGenerator(ABC)
Letter(ABC)
Resume(ABC)
FancyLetter(Letter)
FancyResume(Resume)
ModernLetter(Letter)
ModernResume(Resume)
ModernDocGenerator(DocGenerator)
FancyDocGenerator(DocGenerator)
'''
# interfaces
class DocGenerator(ABC):
@abstractmethod
def create_letter(self):
pass
@abstractmethod
def create_resume(self):
pass
class Letter(ABC):
pass
class Resume(ABC):
pass
# classes
class FancyLetter(Letter):
pass
class FancyResume(Resume):
pass
class ModernLetter(Letter):
pass
class ModernResume(Letter):
pass
class FancyDocGenerator(DocGenerator):
def create_letter(self):
return FancyLetter()
def create_resume(self):
return FancyResume()
class ModernDocGenerator(DocGenerator):
def create_letter(self):
return ModernLetter()
def create_resume(self):
return ModernResume()
| 14.362319 | 46 | 0.711403 | 100 | 991 | 6.99 | 0.25 | 0.077253 | 0.064378 | 0.081545 | 0.177396 | 0.105866 | 0 | 0 | 0 | 0 | 0 | 0 | 0.204844 | 991 | 68 | 47 | 14.573529 | 0.887056 | 0.063572 | 0 | 0.533333 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0.2 | false | 0.266667 | 0.033333 | 0.133333 | 0.666667 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 1 | 1 | 0 | 0 | 3 |
ccc2d90b678a7eddfc66e08d714a04aa3883ab93 | 422 | py | Python | tests/checks/test_allow.py | docker-leash/docker-leash | d98c0a98ddecac2c9775e839d1e64382b811a3cf | [
"MIT"
] | 1 | 2018-01-15T12:29:20.000Z | 2018-01-15T12:29:20.000Z | tests/checks/test_allow.py | docker-leash/docker-leash | d98c0a98ddecac2c9775e839d1e64382b811a3cf | [
"MIT"
] | 92 | 2018-01-12T21:04:42.000Z | 2018-04-08T17:25:26.000Z | tests/checks/test_allow.py | docker-leash/docker-leash | d98c0a98ddecac2c9775e839d1e64382b811a3cf | [
"MIT"
] | 2 | 2018-01-13T16:52:54.000Z | 2020-04-24T22:45:46.000Z | # vim:set ts=4 sw=4 et:
'''
CheckAllowTests
---------------
'''
import unittest
from docker_leash.checks.allow import Allow
from docker_leash.config import Config
class CheckAllowTests(unittest.TestCase):
"""Validation of :cls:`docker_leash.checks.Allow`
"""
@classmethod
def test_init(cls):
"""Validate Allow initialization
"""
allow = Allow()
allow.run(Config(), {})
| 18.347826 | 53 | 0.630332 | 47 | 422 | 5.574468 | 0.574468 | 0.125954 | 0.114504 | 0.167939 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0.006024 | 0.21327 | 422 | 22 | 54 | 19.181818 | 0.783133 | 0.343602 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0.125 | false | 0 | 0.375 | 0 | 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 | 0 | 0 | 0 | 1 | 0 | 1 | 0 | 0 | 3 |
cccd63ed6152bd1606b8322fb17f7268819151fa | 700 | py | Python | db/models.py | ravshanyusupov/polling_bot | c020c44f27cce456fe6742a2683204a31b0b7d66 | [
"MIT",
"Unlicense"
] | null | null | null | db/models.py | ravshanyusupov/polling_bot | c020c44f27cce456fe6742a2683204a31b0b7d66 | [
"MIT",
"Unlicense"
] | null | null | null | db/models.py | ravshanyusupov/polling_bot | c020c44f27cce456fe6742a2683204a31b0b7d66 | [
"MIT",
"Unlicense"
] | null | null | null | import sys
try:
from django.db import models
except Exception:
print('Exception: Django Not Found, please install it with "pip install django".')
sys.exit()
# Sample User model
class Test(models.Model):
question = models.TextField()
a = models.CharField(max_length=255)
b = models.CharField(max_length=255)
c = models.CharField(max_length=255)
d = models.CharField(max_length=255)
def __str__(self):
return self.question
class Users(models.Model):
username = models.CharField(max_length=255)
test_name = models.CharField(max_length=255)
date = models.DateTimeField(auto_now_add=True)
def __str__(self):
return self.username
| 23.333333 | 86 | 0.702857 | 94 | 700 | 5.053191 | 0.489362 | 0.189474 | 0.227368 | 0.303158 | 0.425263 | 0 | 0 | 0 | 0 | 0 | 0 | 0.031972 | 0.195714 | 700 | 29 | 87 | 24.137931 | 0.811723 | 0.024286 | 0 | 0.1 | 0 | 0 | 0.107353 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0.1 | false | 0 | 0.1 | 0.1 | 0.8 | 0.05 | 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 |
aea5962656717d03e531c72122559de62e058006 | 121 | py | Python | Investigations/blink.py | Steve-Fisher/PiExperiments | 81a08b99b53ed9921353cf436b09b40650032a2b | [
"MIT"
] | null | null | null | Investigations/blink.py | Steve-Fisher/PiExperiments | 81a08b99b53ed9921353cf436b09b40650032a2b | [
"MIT"
] | null | null | null | Investigations/blink.py | Steve-Fisher/PiExperiments | 81a08b99b53ed9921353cf436b09b40650032a2b | [
"MIT"
] | null | null | null | from machine import Pin
import time
led = Pin(25, Pin.OUT)
while True:
led.toggle()
time.sleep_ms(200)
| 13.444444 | 24 | 0.636364 | 19 | 121 | 4 | 0.736842 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0.05618 | 0.264463 | 121 | 8 | 25 | 15.125 | 0.797753 | 0 | 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 | 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 |
aebafcdde369d2668d76ab358d7e5c45151de8cb | 116 | py | Python | nose2/tests/functional/support/scenario/dundertest_attribute/test.py | deeplow/nose2 | eb0394160e24afe760e984d93dbece8351dbae7a | [
"BSD-2-Clause"
] | 637 | 2015-01-12T02:02:53.000Z | 2022-03-30T19:47:48.000Z | nose2/tests/functional/support/scenario/dundertest_attribute/test.py | deeplow/nose2 | eb0394160e24afe760e984d93dbece8351dbae7a | [
"BSD-2-Clause"
] | 276 | 2015-01-02T19:14:06.000Z | 2022-03-18T04:03:08.000Z | nose2/tests/functional/support/scenario/dundertest_attribute/test.py | deeplow/nose2 | eb0394160e24afe760e984d93dbece8351dbae7a | [
"BSD-2-Clause"
] | 127 | 2015-01-08T12:02:10.000Z | 2022-01-10T20:52:29.000Z | import unittest
class TestDunderTest(unittest.TestCase):
__test__ = False
def test_a(self):
pass
| 12.888889 | 40 | 0.681034 | 13 | 116 | 5.692308 | 0.846154 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0.25 | 116 | 8 | 41 | 14.5 | 0.850575 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0.2 | false | 0.2 | 0.2 | 0 | 0.8 | 0 | 1 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 0 | 0 | 0 | 3 |
aebbbc3ccb478b5ee0c020d3329684c483eb7823 | 3,363 | py | Python | pykazoo/phonenumbers.py | diarmuidw/PyKazoo | 4b6e22c56400c6da1cdd6949c27b687b51712017 | [
"MIT"
] | 3 | 2015-10-16T07:45:38.000Z | 2016-05-19T18:11:42.000Z | pykazoo/phonenumbers.py | diarmuidw/PyKazoo | 4b6e22c56400c6da1cdd6949c27b687b51712017 | [
"MIT"
] | 35 | 2015-08-29T17:33:05.000Z | 2021-06-06T15:53:52.000Z | pykazoo/phonenumbers.py | diarmuidw/PyKazoo | 4b6e22c56400c6da1cdd6949c27b687b51712017 | [
"MIT"
] | 10 | 2015-08-29T17:33:51.000Z | 2021-06-04T20:54:56.000Z | class PhoneNumbers:
""" 2600hz Kazoo PhoneNumbers API.
:param rest_request: The request client to use.
(optional, default: pykazoo.RestRequest())
:type rest_request: pykazoo.restrequest.RestRequest
"""
def __init__(self, rest_request):
self.rest_request = rest_request
def get_phone_numbers(self, account_id, filters=None):
""" Get all Phone Numbers for an Account.
:param account_id: ID of Account to get Phone Numbers for.
:param filters: Kazoo Filter Parameters (see official API docs).
:return: Kazoo Data (see official API docs).
:type account_id: str
:type filters: dict, None
:rtype: dict
"""
return self.rest_request.get('accounts/' + str(account_id) +
'/phone_numbers', filters)
def get_phone_number(self, account_id, phone_number, filters=None):
""" Get a specific Phone Number for an Account.
:param account_id: ID of Account to get Phone Number for.
:param phone_number: ID of the Phone Number to get.
:param filters: Kazoo Filter Parameters (see official API docs).
:return: Kazoo Data (see official API docs).
:type account_id: str
:type phone_number: str
:type filters: dict, None
:rtype: dict
"""
return self.rest_request.get('accounts/' + str(account_id) +
'/phone_numbers/' + str(phone_number),
filters)
def create_phone_number(self, account_id, phone_number, data):
""" Create a Phone Number
:param account_id: ID of Account to create device for.
:param phone_number: Phone Number to create.
:param data: Kazoo Device data (see official API Docs).
:return: Kazoo Data (see official API docs).
:type account_id: str
:type phone_number: str
:type data: dict
:rtype: dict
"""
return self.rest_request.put('accounts/' + str(account_id) +
'/phone_numbers/' + str(phone_number),
data)
def update_phone_number(self, account_id, phone_number, data):
""" Updates a Phone Number
:param account_id: ID of Account to update device for.
:param phone_number: ID of Phone Number to update.
:param data: Kazoo Account data (see official API Docs).
:return: Kazoo Data (see official API docs).
:type account_id: str
:type phone_number: str
:type data: dict
:rtype: dict
"""
return self.rest_request.post('accounts/' + str(account_id) +
'/phone_numbers/' + str(phone_number),
data)
def delete_phone_number(self, account_id, phone_number):
""" Deletes a Device
:param account_id: ID of Account to delete device from.
:param phone_number: Phone Number to delete.
:return: Kazoo Data (see official API docs).
:type account_id: str
:type phone_number: str
:rtype: dict
"""
return self.rest_request.delete('accounts/' + str(account_id) +
'/phone_numbers/' + str(phone_number))
| 39.564706 | 78 | 0.581921 | 396 | 3,363 | 4.777778 | 0.136364 | 0.162791 | 0.066596 | 0.085624 | 0.727801 | 0.719873 | 0.649049 | 0.59778 | 0.556554 | 0.524841 | 0 | 0.00178 | 0.331847 | 3,363 | 84 | 79 | 40.035714 | 0.840231 | 0.484092 | 0 | 0.333333 | 0 | 0 | 0.089139 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0.285714 | false | 0 | 0 | 0 | 0.571429 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 3 |
aed170f13ebd2aace33baa2948b6c548e3b0cb5b | 347 | py | Python | src/sentry/models/__init__.py | lauryndbrown/sentry | c5304e303966566386f5e61df1b72624a30803b4 | [
"BSD-3-Clause"
] | 1 | 2020-02-27T02:46:25.000Z | 2020-02-27T02:46:25.000Z | src/sentry/models/__init__.py | lauryndbrown/sentry | c5304e303966566386f5e61df1b72624a30803b4 | [
"BSD-3-Clause"
] | 1 | 2020-11-05T14:54:44.000Z | 2020-11-19T21:54:19.000Z | src/sentry/models/__init__.py | lauryndbrown/sentry | c5304e303966566386f5e61df1b72624a30803b4 | [
"BSD-3-Clause"
] | 1 | 2017-02-09T06:36:57.000Z | 2017-02-09T06:36:57.000Z | from __future__ import absolute_import
from django.conf import settings
from sentry.utils.imports import import_submodules
import_submodules(globals(), __name__, __path__)
if 'south' in settings.INSTALLED_APPS:
from south.modelsinspector import add_introspection_rules
add_introspection_rules([], ["^social_auth\.fields\.JSONField"])
| 26.692308 | 68 | 0.809798 | 42 | 347 | 6.190476 | 0.642857 | 0.123077 | 0.161538 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0.10951 | 347 | 12 | 69 | 28.916667 | 0.841424 | 0 | 0 | 0 | 0 | 0 | 0.103746 | 0.089337 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | true | 0 | 0.714286 | 0 | 0.714286 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 1 | 0 | 1 | 0 | 0 | 3 |
aee190b795dc3dc63ab2577f22a0e981393255a1 | 538 | py | Python | simulator/scripts/test-battery.py | LEGO-Robotics/SPIKE-Prime | 90673d1b650877df9b4df5c18fbcb609ddf35402 | [
"MIT"
] | 1 | 2021-11-28T06:44:30.000Z | 2021-11-28T06:44:30.000Z | simulator/scripts/test-battery.py | LEGO-Robotics/SPIKE-Prime | 90673d1b650877df9b4df5c18fbcb609ddf35402 | [
"MIT"
] | null | null | null | simulator/scripts/test-battery.py | LEGO-Robotics/SPIKE-Prime | 90673d1b650877df9b4df5c18fbcb609ddf35402 | [
"MIT"
] | null | null | null | from hub import battery
# Returns:
# - temperature: The current temperature of the battery in degree Celsius.
# - charge_voltage: The voltage being used for charging.
# - charge_current: The current being used for charging.
# - charge_voltage_filtered: The battery voltage after filtering in millivolts.
# - error_state: Enum of battery errors.
# - charger_state: Enum of the charger state.
# - battery_capacity_left: Percentage of battery charge remaining, 0 to 100.
battery.info()
| 44.833333 | 86 | 0.698885 | 67 | 538 | 5.492537 | 0.522388 | 0.054348 | 0.065217 | 0.108696 | 0.141304 | 0 | 0 | 0 | 0 | 0 | 0 | 0.009756 | 0.237918 | 538 | 11 | 87 | 48.909091 | 0.887805 | 0.894052 | 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 |
aee8215a465df514733188ccd39b9e99277f2209 | 305 | py | Python | app/main/views.py | KevinJared/code_chef | 48f8e04ddc95b980422022ba9c96714a17fb7bcc | [
"MIT"
] | null | null | null | app/main/views.py | KevinJared/code_chef | 48f8e04ddc95b980422022ba9c96714a17fb7bcc | [
"MIT"
] | null | null | null | app/main/views.py | KevinJared/code_chef | 48f8e04ddc95b980422022ba9c96714a17fb7bcc | [
"MIT"
] | 2 | 2018-09-18T07:09:35.000Z | 2018-09-18T07:11:32.000Z | from flask import render_template
from . import main
@main.route('/')
def index():
'''
view root page function that returns the index page
'''
title = 'Home - Welcome to The Best Blog Site Worldwide You Think of It We help share It.'
return render_template('index.html',title = title)
| 30.5 | 94 | 0.691803 | 45 | 305 | 4.644444 | 0.733333 | 0.133971 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0.213115 | 305 | 9 | 95 | 33.888889 | 0.870833 | 0.167213 | 0 | 0 | 0 | 0 | 0.382353 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0.166667 | false | 0 | 0.333333 | 0 | 0.666667 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 1 | 0 | 0 | 3 |
4e071e80baf26306bdc18c106eb37b8ff23f0b10 | 17,173 | py | Python | tests/test_balance.py | Sytten/artis | fd407b4558212c435abf8f697ea7891c5375a10e | [
"MIT"
] | 6 | 2018-12-17T19:43:26.000Z | 2021-12-19T22:49:13.000Z | tests/test_balance.py | Sytten/artis | fd407b4558212c435abf8f697ea7891c5375a10e | [
"MIT"
] | null | null | null | tests/test_balance.py | Sytten/artis | fd407b4558212c435abf8f697ea7891c5375a10e | [
"MIT"
] | 1 | 2019-09-19T05:30:53.000Z | 2019-09-19T05:30:53.000Z | import unittest
import unittest.mock as mock
import os
from strategies.balance import Balance
from strategies.balance import Analysis
from strategies.trader import Trader
from strategies.analyser import Analyser
from strategies.reporter import Reporter
from strategies.helper import Helper
from database.database import Database
from database.models.trade import Trade
from database.models.types import Types
from database.models.coins import Coins
from database.models.markets import Markets
from database.models.status import Status
from tests.orders import *
from dynaconf import settings
ETH = "ETH"
COIN = "TRX"
LIQUI = "LIQUI"
BINANCE = "BINANCE"
AMOUNT_COIN = 1000
SMALL_AMOUNT_COIN = 100
AMOUNT_ETH = 0.5
SMALL_AMOUNT_ETH = 0.01
PRICE_ASK = 0.000052
PRICE_BID = 0.000055
BUY_ORDER_ID = '183892657'
SELL_ORDER_ID = '5256209'
ANOTHER_ORDER_ID = '6183482'
ORDER_AMOUNT = 5000
EXPOSURE = 1.057692308
HALF_EXPOSURE = 1 + (EXPOSURE - 1)/2
VOLUME_BUY = 600
SMALL_VOLUME_BUY = 100
VOLUME_SELL = 500
SMALL_VOLUME_SELL = 110
SERVICE_FEE = 0.001
SELL_PRICE = 8.762e-05
class AsyncMock(mock.MagicMock):
async def __call__(self, *args, **kwargs):
return super(AsyncMock, self).__call__(*args, **kwargs)
class TestBalance(unittest.TestCase):
def setUp(self):
settings.configure(settings_module=os.path.dirname(os.path.realpath(__file__)) + '/settings.yml')
self.mock_trader = mock.create_autospec(Trader)
self.mock_analyser = mock.create_autospec(Analyser)
self.mock_reporter = mock.create_autospec(Reporter)
self.mock_database = mock.create_autospec(Database)
self.mock_helper = mock.create_autospec(Helper)
self.strategy = Balance(COIN, LIQUI, BINANCE,
self.mock_trader,
self.mock_analyser,
self.mock_reporter,
self.mock_database,
self.mock_helper)
# TESTS UPDATE
def test_update_pending_sells(self):
trade = Trade(None, Markets[BINANCE], Types.SELL, Coins[COIN], AMOUNT_COIN, PRICE_ASK, BUY_ORDER_ID, Status.ONGOING)
self.mock_database.fetch_pending_sells.return_value = [trade]
self.mock_trader.fetch_order.return_value = BINANCE_FETCH_SELL_ORDER
pending_sells = self.strategy._update_pending_sells()
self.mock_database.upsert_trade.assert_called_once()
assert trade.status == Status.DONE
assert pending_sells == 0
def test_update_pending_canceled_sells(self):
trade = Trade(None, Markets[BINANCE], Types.SELL, Coins[COIN], AMOUNT_COIN, PRICE_ASK, BUY_ORDER_ID, Status.ONGOING)
self.mock_database.fetch_pending_sells.return_value = [trade]
self.mock_trader.fetch_order.return_value = BINANCE_FETCH_CANCELED_SELL_ORDER
pending_sells = self.strategy._update_pending_sells()
self.mock_database.upsert_trade.assert_called_once()
assert trade.status == Status.CANCELLED
assert pending_sells == 0
def test_update_balance_without_transaction(self):
self.mock_analyser.get_balance = AsyncMock(return_value={ETH: {"free": AMOUNT_ETH}, COIN: {"free": AMOUNT_COIN}})
self.strategy._update_balance()
self.mock_database.upsert_balance.assert_not_called()
assert self.strategy.balance_eth.get(LIQUI) == AMOUNT_ETH
assert self.strategy.balance_eth.get(BINANCE) == AMOUNT_ETH
assert self.strategy.balance_coin.get(LIQUI) == AMOUNT_COIN
assert self.strategy.balance_coin.get(BINANCE) == AMOUNT_COIN
def test_update_balance_twice(self):
self.mock_analyser.get_balance = AsyncMock(return_value={ETH: {"free": AMOUNT_ETH}, COIN: {"free": AMOUNT_COIN}})
self.strategy._update_balance()
status = self.strategy._update_balance()
self.mock_database.upsert_balance.assert_not_called()
assert status is False
# TESTS BUY
@mock.patch('strategies.analyser.Analyser.is_filled', return_value=True)
def test_buy_filled(self, mock_filled):
self.mock_trader.buy.return_value = LIQUI_BUY_ORDER
order = self.strategy._buy(LIQUI, ORDER_AMOUNT, PRICE_ASK)
self.mock_trader.buy.assert_called_once_with(LIQUI, COIN, ORDER_AMOUNT, PRICE_ASK)
self.mock_trader.cancel_order.assert_not_called()
assert order.id == BUY_ORDER_ID
def test_buy_exception(self):
self.mock_trader.buy.side_effect = Exception('timeout')
order = self.strategy._buy(LIQUI, ORDER_AMOUNT, PRICE_ASK)
self.mock_trader.buy.assert_called_once_with(LIQUI, COIN, ORDER_AMOUNT, PRICE_ASK)
assert order is None
@mock.patch('strategies.analyser.Analyser.is_filled', return_value=False)
def test_miss_buy(self, mock_filled):
self.mock_trader.buy.return_value = LIQUI_BUY_ORDER
self.strategy._handle_miss_buy = mock.Mock(return_value=Trader.fill_fetch_order(LIQUI_FETCH_BUY_ORDER, LIQUI))
order = self.strategy._buy(LIQUI, ORDER_AMOUNT, PRICE_ASK)
self.mock_trader.buy.assert_called_once_with(LIQUI, COIN, ORDER_AMOUNT, PRICE_ASK)
self.strategy._handle_miss_buy.assert_called_once_with(LIQUI_BUY_ORDER, LIQUI)
assert order.id == BUY_ORDER_ID
# TESTS HANDLE MISS BUY
@mock.patch('time.sleep', return_value=None)
def test_handle_miss_buy(self, mock_sleep):
self.mock_trader.cancel_order.return_value = {}
self.mock_trader.fetch_order.return_value = LIQUI_FETCH_BUY_ORDER
order = self.strategy._handle_miss_buy(LIQUI_BUY_ORDER, LIQUI)
self.mock_trader.cancel_order.assert_called_once_with(LIQUI, COIN, BUY_ORDER_ID)
self.mock_trader.fetch_order.assert_called_with(LIQUI, COIN, BUY_ORDER_ID)
assert order.id == BUY_ORDER_ID
@mock.patch('time.sleep', return_value=None)
def test_handle_miss_buy_cancellation_exception(self, mock_sleep):
self.mock_trader.cancel_order.side_effect = Exception('Order does not exist')
self.mock_trader.fetch_order.return_value = LIQUI_FETCH_BUY_ORDER
order = self.strategy._handle_miss_buy(LIQUI_BUY_ORDER, LIQUI)
self.mock_trader.cancel_order.assert_called_once_with(LIQUI, COIN, BUY_ORDER_ID)
self.mock_trader.fetch_order.assert_called_with(LIQUI, COIN, BUY_ORDER_ID)
assert order.id == BUY_ORDER_ID
@mock.patch('time.sleep', return_value=None)
def test_handle_miss_buy_cancel_partial_order(self, mock_sleep):
self.mock_trader.cancel_order.side_effect = Exception('Order does not exist')
self.mock_trader.fetch_order.return_value = LIQUI_FETCH_PARTIAL_BUY_ORDER
order = self.strategy._handle_miss_buy(LIQUI_BUY_ORDER, LIQUI)
self.mock_trader.cancel_order.assert_called_once_with(LIQUI, COIN, BUY_ORDER_ID)
self.mock_trader.fetch_order.assert_called_with(LIQUI, COIN, BUY_ORDER_ID)
assert order.id == BUY_ORDER_ID
assert order.remaining_amount > 0
# TESTS SELL
def test_sell_filled(self):
self.mock_trader.sell.return_value = BINANCE_SELL_ORDER
self.mock_analyser.is_filled.return_value = True
analysis = Analysis(LIQUI, BINANCE, EXPOSURE)
volumes_wanted = {'sell': ORDER_AMOUNT}
bids = {BINANCE: [PRICE_BID]}
asks = {LIQUI: [PRICE_ASK]}
done, order, cancelled_order = self.strategy._sell(analysis, volumes_wanted, bids, asks)
self.mock_trader.sell.assert_called_once_with(BINANCE, COIN, ORDER_AMOUNT, PRICE_BID)
self.mock_trader.cancel_order.assert_not_called()
assert done is True
assert order.id == SELL_ORDER_ID
assert cancelled_order is None
def test_miss_sell(self):
initial_order = {'id': BUY_ORDER_ID}
self.mock_trader.sell.return_value = initial_order
self.mock_analyser.is_filled.return_value = False
self.strategy._handle_miss_sell = mock.Mock(return_value=(True, initial_order, None))
analysis = Analysis(LIQUI, BINANCE, EXPOSURE)
volumes_wanted = {'sell': ORDER_AMOUNT}
bids = {BINANCE: [PRICE_BID]}
asks = {LIQUI: [PRICE_ASK]}
done, order, cancelled_order = self.strategy._sell(analysis, volumes_wanted, bids, asks)
self.mock_trader.sell.assert_called_once_with(BINANCE, COIN, ORDER_AMOUNT, PRICE_BID)
self.strategy._handle_miss_sell.assert_called_once_with(order, analysis, asks)
assert done is True
assert order.get('id') == BUY_ORDER_ID
assert cancelled_order is None
def test_sell_exception(self):
self.mock_trader.sell.side_effect = Exception("Market timeout")
analysis = Analysis(LIQUI, BINANCE, EXPOSURE)
volumes_wanted = {'sell': ORDER_AMOUNT}
bids = {BINANCE: [PRICE_BID]}
asks = {LIQUI: [PRICE_ASK]}
done, order, cancelled_order = self.strategy._sell(analysis, volumes_wanted, bids, asks)
self.mock_trader.sell.assert_called_once_with(BINANCE, COIN, ORDER_AMOUNT, PRICE_BID)
self.mock_trader.cancel_order.assert_not_called()
assert done is False
assert order is None
assert cancelled_order is None
# TESTS HANDLE MISS SELL
def test_handle_miss_sell(self):
initial_order = {'id': SELL_ORDER_ID}
self.mock_trader.fetch_order.return_value = BINANCE_FETCH_SELL_ORDER
analysis = Analysis(LIQUI, BINANCE, EXPOSURE)
asks = {LIQUI: [PRICE_ASK]}
done, order, cancelled_order = self.strategy._handle_miss_sell(initial_order, analysis, asks)
self.mock_trader.fetch_order.assert_called_once_with(BINANCE, COIN, SELL_ORDER_ID)
self.mock_trader.cancel_order.assert_not_called()
assert done is True
assert order.id == SELL_ORDER_ID
assert cancelled_order is None
def test_handle_miss_sell_fetch_throw(self):
pass
@mock.patch('time.sleep', return_value=None)
def test_handle_miss_sell_cancellation(self, mock_sleep):
initial_order = {'id': SELL_ORDER_ID}
self.mock_trader.fetch_order.return_value = BINANCE_FETCH_NEW_SELL_ORDER
self.mock_trader.sell.return_value = BINANCE_ANOTHER_SELL_ORDER
analysis = Analysis(LIQUI, BINANCE, EXPOSURE)
asks = {BINANCE: [PRICE_ASK]}
done, order, cancelled_order = self.strategy._handle_miss_sell(initial_order, analysis, asks)
self.mock_trader.fetch_order.assert_called_with(BINANCE, COIN, SELL_ORDER_ID)
self.mock_trader.cancel_order.assert_called_once_with(BINANCE, COIN, SELL_ORDER_ID)
self.mock_trader.sell.assert_called_once_with(BINANCE, COIN, 101, 0.00008575)
assert done is True
assert order.id == ANOTHER_ORDER_ID
assert cancelled_order.id == SELL_ORDER_ID
@mock.patch('time.sleep', return_value=None)
def test_handle_miss_sell_too_small_amount_to_cancel(self, mock_sleep):
settings.MINIMUM_AMOUNT_TO_TRADE = 0.01
initial_order = {'id': SELL_ORDER_ID}
self.mock_trader.fetch_order.return_value = BINANCE_FETCH_NEW_SELL_ORDER
analysis = Analysis(LIQUI, BINANCE, EXPOSURE)
asks = {BINANCE: [PRICE_ASK]}
done, order, cancelled_order = self.strategy._handle_miss_sell(initial_order, analysis, asks)
self.mock_trader.fetch_order.assert_called_with(BINANCE, COIN, SELL_ORDER_ID)
self.mock_trader.cancel_order.assert_not_called()
assert done is True
assert order.id == SELL_ORDER_ID
assert cancelled_order is None
def test_handle_miss_sell_cancellation_exception(self):
pass
def test_handle_miss_sell_resell_exception(self):
pass
# TESTS GET TRADE VOLUMES
def test_get_trade_volumes_no_reduction(self):
self.strategy.balance_eth = {"LIQUI": 1, "BINANCE": 1}
self.strategy.balance_coin = {"LIQUI": 10000, "BINANCE": 10000}
asks = {LIQUI: [PRICE_ASK, VOLUME_BUY]}
bids = {BINANCE: [PRICE_BID, VOLUME_SELL]}
analysis = Analysis(LIQUI, BINANCE, EXPOSURE)
volumes_wanted = self.strategy._get_trade_volumes(asks, bids, analysis)
assert volumes_wanted.get('buy') == Helper.round_down(settings.AMOUNT_TO_TRADE / PRICE_ASK)
assert volumes_wanted.get('sell') == Helper.round_down(volumes_wanted.get('buy') / HALF_EXPOSURE)
def test_get_trade_volumes_ask_too_small(self):
self.strategy.balance_eth = {"LIQUI": 1, "BINANCE": 1}
self.strategy.balance_coin = {"LIQUI": 10000, "BINANCE": 10000}
asks = {LIQUI: [PRICE_ASK, SMALL_VOLUME_BUY]}
bids = {BINANCE: [PRICE_BID, VOLUME_SELL]}
analysis = Analysis(LIQUI, BINANCE, EXPOSURE)
volumes_wanted = self.strategy._get_trade_volumes(asks, bids, analysis)
assert volumes_wanted.get('buy') == SMALL_VOLUME_BUY
assert volumes_wanted.get('sell') == round(SMALL_VOLUME_BUY / HALF_EXPOSURE)
def test_get_trade_volumes_bid_too_small(self):
self.strategy.balance_eth = {"LIQUI": 1, "BINANCE": 1}
self.strategy.balance_coin = {"LIQUI": 10000, "BINANCE": 10000}
asks = {LIQUI: [PRICE_ASK, VOLUME_BUY]}
bids = {BINANCE: [PRICE_BID, SMALL_VOLUME_SELL]}
analysis = Analysis(LIQUI, BINANCE, EXPOSURE)
volumes_wanted = self.strategy._get_trade_volumes(asks, bids, analysis)
assert volumes_wanted.get('buy') == round(SMALL_VOLUME_SELL * HALF_EXPOSURE)
assert volumes_wanted.get('sell') == SMALL_VOLUME_SELL
def test_get_trade_volumes_wallet_eth_too_small(self):
self.strategy.balance_eth = {"LIQUI": SMALL_AMOUNT_ETH, "BINANCE": 1}
self.strategy.balance_coin = {"LIQUI": 10000, "BINANCE": 10000}
asks = {LIQUI: [PRICE_ASK, VOLUME_BUY]}
bids = {BINANCE: [PRICE_BID, VOLUME_SELL]}
analysis = Analysis(LIQUI, BINANCE, EXPOSURE)
volumes_wanted = self.strategy._get_trade_volumes(asks, bids, analysis)
assert volumes_wanted.get('buy') == Helper.round_down(SMALL_AMOUNT_ETH / PRICE_ASK)
assert volumes_wanted.get('sell') == Helper.round_down(volumes_wanted.get('buy') / HALF_EXPOSURE)
def test_get_trade_volumes_wallet_coin_too_small(self):
self.strategy.balance_eth = {"LIQUI": 1, "BINANCE": 1}
self.strategy.balance_coin = {"LIQUI": 10000, "BINANCE": SMALL_AMOUNT_COIN}
asks = {LIQUI: [PRICE_ASK, VOLUME_BUY]}
bids = {BINANCE: [PRICE_BID, VOLUME_SELL]}
analysis = Analysis(LIQUI, BINANCE, EXPOSURE)
volumes_wanted = self.strategy._get_trade_volumes(asks, bids, analysis)
assert volumes_wanted.get('buy') == Helper.round_down(SMALL_AMOUNT_COIN * HALF_EXPOSURE)
assert volumes_wanted.get('sell') == Helper.round_down(SMALL_AMOUNT_COIN)
def test_get_trade_volumes_wallet_eth_below_minimum(self):
self.strategy.balance_eth = {"LIQUI": 0.0005, "BINANCE": 1}
self.strategy.balance_coin = {"LIQUI": 10000, "BINANCE": 10000}
asks = {LIQUI: [PRICE_ASK, VOLUME_BUY]}
bids = {BINANCE: [PRICE_BID, VOLUME_SELL]}
analysis = Analysis(LIQUI, BINANCE, EXPOSURE)
volumes_wanted = self.strategy._get_trade_volumes(asks, bids, analysis)
assert volumes_wanted is None
def test_get_trade_volumes_wallet_coin_below_minimum(self):
settings.MINIMUM_AMOUNT_TO_TRADE = 0.01
self.strategy.balance_eth = {"LIQUI": 1, "BINANCE": 1}
self.strategy.balance_coin = {"LIQUI": 10000, "BINANCE": 30}
asks = {LIQUI: [PRICE_ASK, VOLUME_BUY]}
bids = {BINANCE: [PRICE_BID, VOLUME_SELL]}
analysis = Analysis(LIQUI, BINANCE, EXPOSURE)
volumes_wanted = self.strategy._get_trade_volumes(asks, bids, analysis)
assert volumes_wanted is None
def test_get_trade_volumes_with_fees(self):
settings.LIQUI.SERVICE_FEE_HIGH = SERVICE_FEE
settings.BINANCE.SERVICE_FEE_HIGH = SERVICE_FEE
self.strategy.balance_eth = {"LIQUI": 1, "BINANCE": 1}
self.strategy.balance_coin = {"LIQUI": 10000, "BINANCE": 10000}
asks = {LIQUI: [PRICE_ASK, VOLUME_BUY]}
bids = {BINANCE: [PRICE_BID, VOLUME_SELL]}
analysis = Analysis(LIQUI, BINANCE, EXPOSURE)
volumes_wanted = self.strategy._get_trade_volumes(asks, bids, analysis)
assert volumes_wanted.get('buy') == round(settings.AMOUNT_TO_TRADE / PRICE_ASK * (1 - SERVICE_FEE))
assert volumes_wanted.get('sell') == round(settings.AMOUNT_TO_TRADE / PRICE_ASK / HALF_EXPOSURE * (1 - SERVICE_FEE))
def test_get_trade_volumes_zero_ask_volume(self):
asks = {LIQUI: [PRICE_ASK, 0]}
bids = {BINANCE: [PRICE_BID, VOLUME_SELL]}
analysis = Analysis(LIQUI, BINANCE, EXPOSURE)
volumes_wanted = self.strategy._get_trade_volumes(asks, bids, analysis)
assert volumes_wanted is None
def test_get_trade_volumes_zero_bid_volume(self):
asks = {LIQUI: [PRICE_ASK, VOLUME_BUY]}
bids = {BINANCE: [PRICE_BID, 0]}
analysis = Analysis(LIQUI, BINANCE, EXPOSURE)
volumes_wanted = self.strategy._get_trade_volumes(asks, bids, analysis)
assert volumes_wanted is None
| 42.612903 | 124 | 0.709428 | 2,262 | 17,173 | 5.04023 | 0.06985 | 0.047013 | 0.051574 | 0.039295 | 0.795807 | 0.76467 | 0.716604 | 0.677484 | 0.653715 | 0.637049 | 0 | 0.014754 | 0.194841 | 17,173 | 402 | 125 | 42.718905 | 0.809792 | 0.00594 | 0 | 0.54 | 0 | 0 | 0.030415 | 0.004454 | 0 | 0 | 0 | 0 | 0.26 | 1 | 0.1 | false | 0.01 | 0.056667 | 0 | 0.166667 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 1 | 1 | 0 | 0 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 3 |
4e0cb131cae50f843bddd32a7d01e689d43f0969 | 5,092 | py | Python | airbyte-integrations/connectors/source-sentry/source_sentry/streams.py | onaio/airbyte | 38302e82a25f1b66742c3febfbff0668556920f2 | [
"MIT"
] | 22 | 2020-08-27T00:47:20.000Z | 2020-09-17T15:39:39.000Z | airbyte-integrations/connectors/source-sentry/source_sentry/streams.py | onaio/airbyte | 38302e82a25f1b66742c3febfbff0668556920f2 | [
"MIT"
] | 116 | 2020-08-27T01:11:27.000Z | 2020-09-19T02:47:52.000Z | airbyte-integrations/connectors/source-sentry/source_sentry/streams.py | onaio/airbyte | 38302e82a25f1b66742c3febfbff0668556920f2 | [
"MIT"
] | 1 | 2020-09-15T06:10:01.000Z | 2020-09-15T06:10:01.000Z | #
# Copyright (c) 2022 Airbyte, Inc., all rights reserved.
#
from abc import ABC
from typing import Any, Iterable, Mapping, MutableMapping, Optional
import requests
from airbyte_cdk.sources.streams.http import HttpStream
class SentryStream(HttpStream, ABC):
API_VERSION = "0"
URL_TEMPLATE = "https://{hostname}/api/{api_version}/"
primary_key = "id"
def __init__(self, hostname: str, **kwargs):
super().__init__(**kwargs)
self._url_base = self.URL_TEMPLATE.format(hostname=hostname, api_version=self.API_VERSION)
@property
def url_base(self) -> str:
return self._url_base
def next_page_token(self, response: requests.Response) -> Optional[Mapping[str, Any]]:
return None
def request_params(
self,
stream_state: Mapping[str, Any],
stream_slice: Optional[Mapping[str, Any]] = None,
next_page_token: Optional[Mapping[str, Any]] = None,
) -> MutableMapping[str, Any]:
return {}
class SentryStreamPagination(SentryStream):
def next_page_token(self, response: requests.Response) -> Optional[Mapping[str, Any]]:
"""
Expect the link header field to always contain the values for `rel`, `results`, and `cursor`.
If there is actually the next page, rel="next"; results="true"; cursor="<next-page-token>".
"""
if response.links["next"]["results"] == "true":
return {"cursor": response.links["next"]["cursor"]}
else:
return None
def request_params(
self,
stream_state: Mapping[str, Any],
stream_slice: Optional[Mapping[str, Any]] = None,
next_page_token: Optional[Mapping[str, Any]] = None,
) -> MutableMapping[str, Any]:
params = super().request_params(stream_state, stream_slice, next_page_token)
if next_page_token:
params.update(next_page_token)
return params
def parse_response(self, response: requests.Response, **kwargs) -> Iterable[Mapping]:
yield from response.json()
class Events(SentryStreamPagination):
"""
Docs: https://docs.sentry.io/api/events/list-a-projects-events/
"""
def __init__(self, organization: str, project: str, **kwargs):
super().__init__(**kwargs)
self._organization = organization
self._project = project
def path(
self,
stream_state: Optional[Mapping[str, Any]] = None,
stream_slice: Optional[Mapping[str, Any]] = None,
next_page_token: Optional[Mapping[str, Any]] = None,
) -> str:
return f"projects/{self._organization}/{self._project}/events/"
def request_params(
self,
stream_state: Mapping[str, Any],
stream_slice: Optional[Mapping[str, Any]] = None,
next_page_token: Optional[Mapping[str, Any]] = None,
) -> MutableMapping[str, Any]:
params = super().request_params(stream_state, stream_slice, next_page_token)
params.update({"full": "true"})
return params
class Issues(SentryStreamPagination):
"""
Docs: https://docs.sentry.io/api/events/list-a-projects-issues/
"""
def __init__(self, organization: str, project: str, **kwargs):
super().__init__(**kwargs)
self._organization = organization
self._project = project
def path(
self,
stream_state: Optional[Mapping[str, Any]] = None,
stream_slice: Optional[Mapping[str, Any]] = None,
next_page_token: Optional[Mapping[str, Any]] = None,
) -> str:
return f"projects/{self._organization}/{self._project}/issues/"
def request_params(
self,
stream_state: Mapping[str, Any],
stream_slice: Optional[Mapping[str, Any]] = None,
next_page_token: Optional[Mapping[str, Any]] = None,
) -> MutableMapping[str, Any]:
params = super().request_params(stream_state, stream_slice, next_page_token)
params.update({"statsPeriod": "", "query": ""})
return params
class Projects(SentryStreamPagination):
"""
Docs: https://docs.sentry.io/api/projects/list-your-projects/
"""
def path(
self,
stream_state: Optional[Mapping[str, Any]] = None,
stream_slice: Optional[Mapping[str, Any]] = None,
next_page_token: Optional[Mapping[str, Any]] = None,
) -> str:
return "projects/"
class ProjectDetail(SentryStream):
"""
Docs: https://docs.sentry.io/api/projects/retrieve-a-project/
"""
def __init__(self, organization: str, project: str, **kwargs):
super().__init__(**kwargs)
self._organization = organization
self._project = project
def path(
self,
stream_state: Optional[Mapping[str, Any]] = None,
stream_slice: Optional[Mapping[str, Any]] = None,
next_page_token: Optional[Mapping[str, Any]] = None,
) -> str:
return f"projects/{self._organization}/{self._project}/"
def parse_response(self, response: requests.Response, **kwargs) -> Iterable[Mapping]:
yield response.json()
| 32.025157 | 103 | 0.636685 | 580 | 5,092 | 5.386207 | 0.17069 | 0.057618 | 0.108195 | 0.147887 | 0.71991 | 0.711908 | 0.702945 | 0.675416 | 0.675416 | 0.675416 | 0 | 0.001276 | 0.230165 | 5,092 | 158 | 104 | 32.227848 | 0.795663 | 0.097211 | 0 | 0.695238 | 0 | 0 | 0.056851 | 0.033755 | 0 | 0 | 0 | 0 | 0 | 1 | 0.161905 | false | 0 | 0.038095 | 0.066667 | 0.4 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 1 | 1 | 0 | 0 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 3 |
4e2432b861ba4093f5be8de05dff875f070855ca | 533 | py | Python | mytests.py | morticiaCoder/Ola-Mundo | 2c50ee65186e4b8e2272a84f8d81a463cfd27ae1 | [
"MIT"
] | null | null | null | mytests.py | morticiaCoder/Ola-Mundo | 2c50ee65186e4b8e2272a84f8d81a463cfd27ae1 | [
"MIT"
] | 1 | 2021-06-30T14:01:08.000Z | 2021-07-04T16:18:30.000Z | mytests.py | morticiaCoder/Ola-Mundo | 2c50ee65186e4b8e2272a84f8d81a463cfd27ae1 | [
"MIT"
] | null | null | null | import unittest
from mycode import *
class MyFirstTests(unittest.TestCase):
def test_hello(self):
self.assertEqual(hello_world(), 'hello_world')
def test_custom_num_list(self):
self.assertEqual(len(create_num_list(10)), 10)
def test_custom_func_x(self):
self.assertEqual(custom_func_x(3, 2, 3), 54)
def test_custom_non_lin_num_list(self):
self.assertEqual(custom_non_lin_num_list(5, 2, 3)[2], 16)
self.assertEqual(custom_non_lin_num_list(5, 3, 2)[4], 48)
if __name__ == "__main__":
unittest.main() | 26.65 | 61 | 0.73546 | 85 | 533 | 4.211765 | 0.388235 | 0.209497 | 0.212291 | 0.125698 | 0.332402 | 0.195531 | 0.195531 | 0.195531 | 0 | 0 | 0 | 0.045553 | 0.135084 | 533 | 20 | 62 | 26.65 | 0.73102 | 0 | 0 | 0 | 0 | 0 | 0.035581 | 0 | 0 | 0 | 0 | 0 | 0.357143 | 1 | 0.285714 | false | 0 | 0.142857 | 0 | 0.5 | 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 |
4e2d89ea1a1a23dd905b748737162e79a535f5db | 2,511 | py | Python | tests/test_statistics_from_file.py | tokarzmaciej/school-register_TDD | aa0cda4bc1d78b31025278ec416372a33414b505 | [
"MIT"
] | null | null | null | tests/test_statistics_from_file.py | tokarzmaciej/school-register_TDD | aa0cda4bc1d78b31025278ec416372a33414b505 | [
"MIT"
] | null | null | null | tests/test_statistics_from_file.py | tokarzmaciej/school-register_TDD | aa0cda4bc1d78b31025278ec416372a33414b505 | [
"MIT"
] | null | null | null | import unittest
from src.statistics import *
from src.exampleData import Data
class StatisticsParameterizedFile(unittest.TestCase):
def test_average_subject_from_file(self):
fileTest = open("data/test_statistics_subject.txt")
tmp = Statistics(Data().example)
for line in fileTest:
if line.startswith("#") or line.startswith(" ") or line.startswith("\n"):
continue
else:
data = line.split(" ")
inp1, inp2, inp3, inp4, message = (data[0], data[1], data[2], data[3], int(data[4].strip("\n")))
self.assertGreaterEqual(message, tmp.averageSubject(inp1, inp2, inp3, inp4)[1])
fileTest.close()
def test_average_subjects_from_file(self):
fileTest = open("data/test_statistics_subjects.txt")
tmp = Statistics(Data().example)
for line in fileTest:
if line.startswith("#") or line.startswith(" ") or line.startswith("\n"):
continue
else:
data = line.split(" ")
inp1, inp2, inp3, message = (data[0], data[1], data[2], int(data[3].strip("\n")))
self.assertLessEqual(message, tmp.averageSubjects(inp1, inp2, inp3)[1])
fileTest.close()
def test_average_subject_from_file_exceptions(self):
fileTest = open("data/test_statistics_subject_exceptions.txt")
tmp = Statistics(Data().example)
for line in fileTest:
if line.startswith("#") or line.startswith(" ") or line.startswith("\n"):
continue
else:
data = line.split(" ")
inp1, inp2, inp3, inp4, message = (data[0], data[1], data[2], data[3], data[4].strip("\n"))
self.assertRaisesRegex(Exception, message, tmp.averageSubject, inp1, inp2, inp3, inp4)
fileTest.close()
def test_average_subjects_from_file_exceptions(self):
fileTest = open("data/test_statistics_subjects_exceptions.txt")
tmp = Statistics(Data().example)
for line in fileTest:
if line.startswith("#") or line.startswith(" ") or line.startswith("\n"):
continue
else:
data = line.split(" ")
inp1, inp2, inp3, message = (data[0], data[1], data[2], data[3].strip("\n"))
self.assertRaisesRegex(Exception, message, tmp.averageSubjects, inp1, inp2, inp3)
fileTest.close()
if __name__ == '__main__':
unittest.main()
| 43.293103 | 112 | 0.589407 | 282 | 2,511 | 5.120567 | 0.191489 | 0.116343 | 0.088643 | 0.110803 | 0.870499 | 0.84626 | 0.762465 | 0.629501 | 0.522853 | 0.447368 | 0 | 0.026359 | 0.274791 | 2,511 | 57 | 113 | 44.052632 | 0.766612 | 0 | 0 | 0.56 | 0 | 0 | 0.074871 | 0.060534 | 0 | 0 | 0 | 0 | 0.08 | 1 | 0.08 | false | 0 | 0.06 | 0 | 0.16 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 1 | 1 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 3 |
9d82bc68f650b6ae6662f9d1f0c8d1e46afb2646 | 5,295 | py | Python | tests/routes/test_api_leases.py | Biosystems-Analytics-Lab/shellcast | 8d578bfa3d66d75502f1a133fe6263d376694247 | [
"CC-BY-4.0"
] | 5 | 2021-03-24T19:19:48.000Z | 2022-01-11T09:27:13.000Z | tests/routes/test_api_leases.py | Biosystems-Analytics-Lab/shellcast | 8d578bfa3d66d75502f1a133fe6263d376694247 | [
"CC-BY-4.0"
] | 1 | 2022-01-13T15:11:09.000Z | 2022-01-13T21:16:10.000Z | tests/routes/test_api_leases.py | Biosystems-Analytics-Lab/shellcast | 8d578bfa3d66d75502f1a133fe6263d376694247 | [
"CC-BY-4.0"
] | null | null | null | import pytest
from models.User import User
from models.UserLease import UserLease
from models.NCDMFLease import NCDMFLease
from firebase_admin import auth
def test_get_leases(client, dbSession, addMockFbUser):
# add a mock Firebase user
addMockFbUser(dict(uid='3sH9so5Y3DP72QA1XqbWw9J6I8o1', email='blah@gmail.com', phone_number='1234567890'), 'validUser1')
# add the user to the db
user = User(firebase_uid='3sH9so5Y3DP72QA1XqbWw9J6I8o1', email='blah@gmail.com', phone_number='1234567890')
dbSession.add(user)
dbSession.commit()
# add some leases to the database
leases = [
UserLease(user_id=user.id, ncdmf_lease_id='45678', grow_area_name='A01', cmu_name='U001', rainfall_thresh_in=1.5, geometry=(34.404497, -77.567573)),
UserLease(user_id=user.id, ncdmf_lease_id='12345', grow_area_name='B02', cmu_name='U002', rainfall_thresh_in=2.5, geometry=(35.207332, -76.523872)),
UserLease(user_id=user.id, ncdmf_lease_id='82945', grow_area_name='C01', cmu_name='U003', rainfall_thresh_in=1.5, geometry=(36.164344, -75.927864))
]
dbSession.add_all(leases)
dbSession.commit()
res = client.get('/leases', headers={'Authorization': 'validUser1'})
assert res.status_code == 200
json = res.get_json()
assert len(json) == 3
assert json[0]['ncdmf_lease_id'] == '45678'
assert json[0]['grow_area_name'] == 'A01'
assert json[0]['cmu_name'] == 'U001'
assert json[0]['rainfall_thresh_in'] == 1.5
assert json[0]['geometry'] == [34.404497, -77.567573]
assert json[1]['ncdmf_lease_id'] == '12345'
assert json[1]['grow_area_name'] == 'B02'
assert json[1]['cmu_name'] == 'U002'
assert json[1]['rainfall_thresh_in'] == 2.5
assert json[1]['geometry'] == [35.207332, -76.523872]
assert json[2]['ncdmf_lease_id'] == '82945'
assert json[2]['grow_area_name'] == 'C01'
assert json[2]['cmu_name'] == 'U003'
assert json[2]['rainfall_thresh_in'] == 1.5
assert json[2]['geometry'] == [36.164344, -75.927864]
def test_add_lease(client, dbSession, addMockFbUser):
# add a mock Firebase user
addMockFbUser(dict(uid='3sH9so5Y3DP72QA1XqbWw9J6I8o1', email='blah@gmail.com'), 'validUser1')
# add the user to the db
user = User(firebase_uid='3sH9so5Y3DP72QA1XqbWw9J6I8o1', email='blah@gmail.com')
dbSession.add(user)
dbSession.commit()
# add one existing lease for the user
lease = UserLease(user_id=user.id, ncdmf_lease_id='45678', grow_area_name='A01', cmu_name='U001', rainfall_thresh_in=1.5, geometry=(34.404497, -77.567573))
dbSession.add(lease)
dbSession.commit()
# add some NCDMF leases
ncdmfLeases = [
NCDMFLease(ncdmf_lease_id='819401', grow_area_name='D11', cmu_name='U011', rainfall_thresh_in=2.5, geometry=(34.404497, -77.567573)),
NCDMFLease(ncdmf_lease_id='123456', grow_area_name='B05', cmu_name='U021', rainfall_thresh_in=3.5, geometry=(35.923741, -76.239482)),
NCDMFLease(ncdmf_lease_id='4-C-89', grow_area_name='A01', cmu_name='U031', rainfall_thresh_in=1.5, geometry=(36.303915, -75.864693))
]
dbSession.add_all(ncdmfLeases)
dbSession.commit()
# make a request to add the given lease
res = client.post('/leases', headers={'Authorization': 'validUser1'}, json={'ncdmf_lease_id': '4-C-89'})
assert res.status_code == 200
json = res.get_json()
assert json['ncdmf_lease_id'] == '4-C-89'
assert json['grow_area_name'] == 'A01'
assert json['cmu_name'] == 'U031'
assert json['rainfall_thresh_in'] == 1.5
assert json['geometry'] == [36.303915, -75.864693]
# get the user's leases
res = client.get('/leases', headers={'Authorization': 'validUser1'})
assert res.status_code == 200
json = res.get_json()
assert len(json) == 2
assert json[1]['ncdmf_lease_id'] == '45678'
assert json[1]['grow_area_name'] == 'A01'
assert json[1]['cmu_name'] == 'U001'
assert json[1]['rainfall_thresh_in'] == 1.5
assert json[1]['geometry'] == [34.404497, -77.567573]
assert json[0]['ncdmf_lease_id'] == '4-C-89'
assert json[0]['grow_area_name'] == 'A01'
assert json[0]['cmu_name'] == 'U031'
assert json[0]['rainfall_thresh_in'] == 1.5
assert json[0]['geometry'] == [36.303915, -75.864693]
def test_add_invalid_lease(client, dbSession, addMockFbUser):
# add a mock Firebase user
addMockFbUser(dict(uid='3sH9so5Y3DP72QA1XqbWw9J6I8o1', email='blah@gmail.com'), 'validUser1')
# add the user to the db
user = User(firebase_uid='3sH9so5Y3DP72QA1XqbWw9J6I8o1', email='blah@gmail.com')
dbSession.add(user)
dbSession.commit()
# add one existing lease for the user
lease = UserLease(user_id=user.id, ncdmf_lease_id='45678', grow_area_name='A01', cmu_name='U001', rainfall_thresh_in=1.5, geometry=(34.404497, -77.567573))
dbSession.add(lease)
dbSession.commit()
# make a request to add the given lease
res = client.post('/leases', headers={'Authorization': 'validUser1'}, json={'ncdmf_lease_id': '123-CD'})
assert res.status_code == 400
# get the user's leases
res = client.get('/leases', headers={'Authorization': 'validUser1'})
assert res.status_code == 200
json = res.get_json()
assert len(json) == 1
assert json[0]['ncdmf_lease_id'] == '45678'
assert json[0]['grow_area_name'] == 'A01'
assert json[0]['cmu_name'] == 'U001'
assert json[0]['rainfall_thresh_in'] == 1.5
assert json[0]['geometry'] == [34.404497, -77.567573]
| 39.514925 | 157 | 0.701605 | 778 | 5,295 | 4.597686 | 0.142674 | 0.097847 | 0.057031 | 0.052278 | 0.817724 | 0.761532 | 0.676545 | 0.625105 | 0.592675 | 0.580934 | 0 | 0.122263 | 0.128801 | 5,295 | 133 | 158 | 39.81203 | 0.653154 | 0.073466 | 0 | 0.445652 | 0 | 0 | 0.227152 | 0.034349 | 0 | 0 | 0 | 0 | 0.467391 | 1 | 0.032609 | false | 0 | 0.054348 | 0 | 0.086957 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 1 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 3 |
9d8a95d7886da3f38bb262334c72238915caa799 | 8,820 | py | Python | networks/equivariant_sac_net.py | nsortur/equi_rl | 83bd2ee9dfaab715e51b71ffff90ab990aaed5f8 | [
"MIT"
] | 9 | 2022-02-20T18:18:51.000Z | 2022-03-24T03:04:44.000Z | networks/equivariant_sac_net.py | nsortur/equi_rl | 83bd2ee9dfaab715e51b71ffff90ab990aaed5f8 | [
"MIT"
] | null | null | null | networks/equivariant_sac_net.py | nsortur/equi_rl | 83bd2ee9dfaab715e51b71ffff90ab990aaed5f8 | [
"MIT"
] | 2 | 2022-02-19T05:17:06.000Z | 2022-02-21T20:53:26.000Z | import torch
from e2cnn import gspaces
from e2cnn import nn
from networks.sac_net import SACGaussianPolicyBase
LOG_SIG_MAX = 2
LOG_SIG_MIN = -20
epsilon = 1e-6
class EquivariantEncoder128(torch.nn.Module):
"""
Equivariant Encoder. The input is a trivial representation with obs_channel channels.
The output is a regular representation with n_out channels
"""
def __init__(self, obs_channel=2, n_out=128, initialize=True, N=4):
super().__init__()
self.obs_channel = obs_channel
self.c4_act = gspaces.Rot2dOnR2(N)
self.conv = torch.nn.Sequential(
# 128x128
nn.R2Conv(nn.FieldType(self.c4_act, obs_channel * [self.c4_act.trivial_repr]),
nn.FieldType(self.c4_act, n_out//8 * [self.c4_act.regular_repr]),
kernel_size=3, padding=1, initialize=initialize),
nn.ReLU(nn.FieldType(self.c4_act, n_out//8 * [self.c4_act.regular_repr]), inplace=True),
nn.PointwiseMaxPool(nn.FieldType(self.c4_act, n_out//8 * [self.c4_act.regular_repr]), 2),
# 64x64
nn.R2Conv(nn.FieldType(self.c4_act, n_out//8 * [self.c4_act.regular_repr]),
nn.FieldType(self.c4_act, n_out//4 * [self.c4_act.regular_repr]),
kernel_size=3, padding=1, initialize=initialize),
nn.ReLU(nn.FieldType(self.c4_act, n_out//4 * [self.c4_act.regular_repr]), inplace=True),
nn.PointwiseMaxPool(nn.FieldType(self.c4_act, n_out//4 * [self.c4_act.regular_repr]), 2),
# 32x32
nn.R2Conv(nn.FieldType(self.c4_act, n_out//4 * [self.c4_act.regular_repr]),
nn.FieldType(self.c4_act, n_out//2 * [self.c4_act.regular_repr]),
kernel_size=3, padding=1, initialize=initialize),
nn.ReLU(nn.FieldType(self.c4_act, n_out//2 * [self.c4_act.regular_repr]), inplace=True),
nn.PointwiseMaxPool(nn.FieldType(self.c4_act, n_out//2 * [self.c4_act.regular_repr]), 2),
# 16x16
nn.R2Conv(nn.FieldType(self.c4_act, n_out//2 * [self.c4_act.regular_repr]),
nn.FieldType(self.c4_act, n_out * [self.c4_act.regular_repr]),
kernel_size=3, padding=1, initialize=initialize),
nn.ReLU(nn.FieldType(self.c4_act, n_out * [self.c4_act.regular_repr]), inplace=True),
nn.PointwiseMaxPool(nn.FieldType(self.c4_act, n_out * [self.c4_act.regular_repr]), 2),
# 8x8
nn.R2Conv(nn.FieldType(self.c4_act, n_out * [self.c4_act.regular_repr]),
nn.FieldType(self.c4_act, n_out*2 * [self.c4_act.regular_repr]),
kernel_size=3, padding=1, initialize=initialize),
nn.ReLU(nn.FieldType(self.c4_act, n_out*2 * [self.c4_act.regular_repr]), inplace=True),
nn.R2Conv(nn.FieldType(self.c4_act, n_out*2 * [self.c4_act.regular_repr]),
nn.FieldType(self.c4_act, n_out * [self.c4_act.regular_repr]),
kernel_size=3, padding=0, initialize=initialize),
nn.ReLU(nn.FieldType(self.c4_act, n_out * [self.c4_act.regular_repr]), inplace=True),
nn.PointwiseMaxPool(nn.FieldType(self.c4_act, n_out * [self.c4_act.regular_repr]), 2),
# 3x3
nn.R2Conv(nn.FieldType(self.c4_act, n_out * [self.c4_act.regular_repr]),
nn.FieldType(self.c4_act, n_out * [self.c4_act.regular_repr]),
kernel_size=3, padding=0, initialize=initialize),
nn.ReLU(nn.FieldType(self.c4_act, n_out * [self.c4_act.regular_repr]), inplace=True),
# 1x1
)
def forward(self, geo):
return self.conv(geo)
def getEnc(obs_size, enc_id):
assert obs_size in [128]
assert enc_id in [1]
return EquivariantEncoder128
class EquivariantSACCritic(torch.nn.Module):
"""
Equivariant SAC's invariant critic
"""
def __init__(self, obs_shape=(2, 128, 128), action_dim=5, n_hidden=128, initialize=True, N=4, enc_id=1):
super().__init__()
self.obs_channel = obs_shape[0]
self.n_hidden = n_hidden
self.c4_act = gspaces.Rot2dOnR2(N)
enc = getEnc(obs_shape[1], enc_id)
self.img_conv = enc(self.obs_channel, n_hidden, initialize, N)
self.n_rho1 = 2 if N==2 else 1
self.critic_1 = torch.nn.Sequential(
# mixed representation including n_hidden regular representations (for the state),
# (action_dim-2) trivial representations (for the invariant actions)
# and 1 standard representation (for the equivariant actions)
nn.R2Conv(nn.FieldType(self.c4_act, n_hidden * [self.c4_act.regular_repr] + (action_dim-2) * [self.c4_act.trivial_repr] + self.n_rho1*[self.c4_act.irrep(1)]),
nn.FieldType(self.c4_act, n_hidden * [self.c4_act.regular_repr]),
kernel_size=1, padding=0, initialize=initialize),
nn.ReLU(nn.FieldType(self.c4_act, n_hidden * [self.c4_act.regular_repr]), inplace=True),
nn.GroupPooling(nn.FieldType(self.c4_act, n_hidden * [self.c4_act.regular_repr])),
nn.R2Conv(nn.FieldType(self.c4_act, n_hidden * [self.c4_act.trivial_repr]),
nn.FieldType(self.c4_act, 1 * [self.c4_act.trivial_repr]),
kernel_size=1, padding=0, initialize=initialize),
)
self.critic_2 = torch.nn.Sequential(
nn.R2Conv(nn.FieldType(self.c4_act, n_hidden * [self.c4_act.regular_repr] + (action_dim-2) * [self.c4_act.trivial_repr] + self.n_rho1*[self.c4_act.irrep(1)]),
nn.FieldType(self.c4_act, n_hidden * [self.c4_act.regular_repr]),
kernel_size=1, padding=0, initialize=initialize),
nn.ReLU(nn.FieldType(self.c4_act, n_hidden * [self.c4_act.regular_repr]), inplace=True),
nn.GroupPooling(nn.FieldType(self.c4_act, n_hidden * [self.c4_act.regular_repr])),
nn.R2Conv(nn.FieldType(self.c4_act, n_hidden * [self.c4_act.trivial_repr]),
nn.FieldType(self.c4_act, 1 * [self.c4_act.trivial_repr]),
kernel_size=1, padding=0, initialize=initialize),
)
def forward(self, obs, act):
batch_size = obs.shape[0]
obs_geo = nn.GeometricTensor(obs, nn.FieldType(self.c4_act, self.obs_channel*[self.c4_act.trivial_repr]))
conv_out = self.img_conv(obs_geo)
dxy = act[:, 1:3]
inv_act = torch.cat((act[:, 0:1], act[:, 3:]), dim=1)
n_inv = inv_act.shape[1]
cat = torch.cat((conv_out.tensor, inv_act.reshape(batch_size, n_inv, 1, 1), dxy.reshape(batch_size, 2, 1, 1)), dim=1)
cat_geo = nn.GeometricTensor(cat, nn.FieldType(self.c4_act, self.n_hidden * [self.c4_act.regular_repr] + n_inv * [self.c4_act.trivial_repr] + self.n_rho1*[self.c4_act.irrep(1)]))
out1 = self.critic_1(cat_geo).tensor.reshape(batch_size, 1)
out2 = self.critic_2(cat_geo).tensor.reshape(batch_size, 1)
return out1, out2
class EquivariantSACActor(SACGaussianPolicyBase):
"""
Equivariant SAC's equivariant actor
"""
def __init__(self, obs_shape=(2, 128, 128), action_dim=5, n_hidden=128, initialize=True, N=4, enc_id=1):
super().__init__()
assert obs_shape[1] in [128, 64]
self.obs_channel = obs_shape[0]
self.action_dim = action_dim
self.c4_act = gspaces.Rot2dOnR2(N)
enc = getEnc(obs_shape[1], enc_id)
self.n_rho1 = 2 if N==2 else 1
self.conv = torch.nn.Sequential(
enc(self.obs_channel, n_hidden, initialize, N),
nn.R2Conv(nn.FieldType(self.c4_act, n_hidden * [self.c4_act.regular_repr]),
# mixed representation including action_dim trivial representations (for the std of all actions),
# (action_dim-2) trivial representations (for the mu of invariant actions),
# and 1 standard representation (for the mu of equivariant actions)
nn.FieldType(self.c4_act, self.n_rho1 * [self.c4_act.irrep(1)] + (action_dim*2-2) * [self.c4_act.trivial_repr]),
kernel_size=1, padding=0, initialize=initialize)
)
def forward(self, obs):
batch_size = obs.shape[0]
obs_geo = nn.GeometricTensor(obs, nn.FieldType(self.c4_act, self.obs_channel*[self.c4_act.trivial_repr]))
conv_out = self.conv(obs_geo).tensor.reshape(batch_size, -1)
dxy = conv_out[:, 0:2]
inv_act = conv_out[:, 2:self.action_dim]
mean = torch.cat((inv_act[:, 0:1], dxy, inv_act[:, 1:]), dim=1)
log_std = conv_out[:, self.action_dim:]
log_std = torch.clamp(log_std, min=LOG_SIG_MIN, max=LOG_SIG_MAX)
return mean, log_std
| 56.178344 | 186 | 0.629138 | 1,277 | 8,820 | 4.097886 | 0.09397 | 0.110071 | 0.165106 | 0.13969 | 0.752341 | 0.737244 | 0.721575 | 0.664819 | 0.628511 | 0.625454 | 0 | 0.0446 | 0.239909 | 8,820 | 156 | 187 | 56.538462 | 0.735979 | 0.079138 | 0 | 0.445378 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0.02521 | 1 | 0.058824 | false | 0 | 0.033613 | 0.008403 | 0.151261 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 1 | 1 | 0 | 0 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 3 |
9d8fcd65980e63fe2f8b532ab9d4e441ec3954ec | 2,136 | py | Python | src/word_vector_tool.py | zzq142/News_Classification-master | d9039fc8c205991783e16acac3e7e3017e2da9c3 | [
"Apache-2.0"
] | 7 | 2021-06-03T09:38:38.000Z | 2022-02-07T06:15:59.000Z | src/word_vector_tool.py | zzq142/News_Classification-master | d9039fc8c205991783e16acac3e7e3017e2da9c3 | [
"Apache-2.0"
] | null | null | null | src/word_vector_tool.py | zzq142/News_Classification-master | d9039fc8c205991783e16acac3e7e3017e2da9c3 | [
"Apache-2.0"
] | 1 | 2021-12-04T06:46:22.000Z | 2021-12-04T06:46:22.000Z | import multiprocessing
import os
import numpy
from gensim.models import Word2Vec
from gensim.models.word2vec import LineSentence
module_path = os.path.dirname(__file__)
# 词向量模型
model_path = module_path + '/data/word_vector/words_vector.model'
# 得到的词向量是ndArray类型的,不是list, .tolist()
# vector_path = './data/all_words.txt'
# 获取word2vec词向量模型
def get_vector_model():
return Word2Vec.load(model_path)
# # 实际上 model_save.wv 也是一样的,而且更快
# def get_vector():
# return gensim.models.KeyedVectors.load_word2vec_format(vector_path, binary=False)
# 先获取 model = get_vector_model(), 然后 sentences = words_to_sentences(['word1','word2'..]))
# 或者 sentences = file_to_sentences(file_path)
# 往已有模型中添加词汇
def add_sentences(model, sentences):
model.build_vocab(sentences, update=True)
model.train(sentences, total_words=model.corpus_count, epochs=model.epochs)
model_save(model)
return model
# 没有模型,新建一个词向量模型
def build_model(sentences):
model = Word2Vec(sentences=sentences, window=1, min_count=1,
workers=multiprocessing.cpu_count(), sg=1)
model_save(model)
return model
# ./data/all_words.txt
def file_to_sentences(file):
return LineSentence(file)
# ['word1','word2'...]
def words_to_sentences(words):
return [words]
# 获取词汇的词向量, 返回类型是 ndArray, 可以.tolist()转化为list
def get_vector_of_text(model, text):
if has_text(model, text):
return model.wv.get_vector(text)
return get_empty_vector()
# 保存模型
def model_save(model):
model.save(model_path)
# 下面这个保存太占空间了
# model_save.wv.save_word2vec_format(vector_path, binary=True)
# 空向量
def get_empty_vector():
v = numpy.zeros(100, dtype=float, order='C')
return v
# 词text在模型词库中的索引值
def get_index(model, text):
if has_text(model, text):
return model.wv.get_index(text)
return 0
# 根据索引查找词
def get_text_of_index(model, index):
# index_to_key 是list,key_to_index是dict
return model.wv.index_to_key[index]
# 给embedding层用,返回的是Word2Vec的权重参数
def get_vector_weight(model):
return model.wv.vectors
# 是否有这个词
def has_text(model, text):
return model.wv.has_index_for(text)
| 21.795918 | 89 | 0.731742 | 295 | 2,136 | 5.054237 | 0.328814 | 0.028169 | 0.043595 | 0.032193 | 0.150905 | 0.077129 | 0.077129 | 0.057679 | 0.057679 | 0.057679 | 0 | 0.010573 | 0.158708 | 2,136 | 97 | 90 | 22.020619 | 0.819143 | 0.30618 | 0 | 0.142857 | 0 | 0 | 0.025395 | 0.024708 | 0 | 0 | 0 | 0 | 0 | 1 | 0.285714 | false | 0 | 0.119048 | 0.142857 | 0.714286 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 0 | 1 | 1 | 0 | 0 | 3 |
9dbacb29320f3db83e35c075e03c33323d513996 | 157 | py | Python | app/__init__.py | jeanazuos/calculapitor | 639db1e299b1c5dbbdd90ad022e378f3202dfe5f | [
"MIT"
] | null | null | null | app/__init__.py | jeanazuos/calculapitor | 639db1e299b1c5dbbdd90ad022e378f3202dfe5f | [
"MIT"
] | null | null | null | app/__init__.py | jeanazuos/calculapitor | 639db1e299b1c5dbbdd90ad022e378f3202dfe5f | [
"MIT"
] | null | null | null | from flask import Flask, jsonify
app = Flask(__name__)
app.config.from_object('config')
from .routes import routes
if __name__ == '__main__':
app.run() | 19.625 | 32 | 0.732484 | 22 | 157 | 4.636364 | 0.545455 | 0.196078 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0.146497 | 157 | 8 | 33 | 19.625 | 0.761194 | 0 | 0 | 0 | 0 | 0 | 0.088608 | 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 |
9dbee8127d36b7ff81608e7fc8e902e6e466ef7d | 118 | py | Python | home/urls.py | sumit4613/codetronics_website | c967092ebeed6665de2b83d642397a6fa5f41a73 | [
"MIT"
] | 3 | 2019-10-14T13:13:42.000Z | 2020-08-07T04:58:20.000Z | home/urls.py | sumit4613/codetronics_website | c967092ebeed6665de2b83d642397a6fa5f41a73 | [
"MIT"
] | 9 | 2020-01-08T16:40:49.000Z | 2022-02-10T12:42:47.000Z | home/urls.py | sumit4613/codetronics_website | c967092ebeed6665de2b83d642397a6fa5f41a73 | [
"MIT"
] | 5 | 2019-09-11T10:21:37.000Z | 2020-07-08T14:30:49.000Z | from django.urls import path
from .views import homepage
urlpatterns = [
path('', homepage, name='homepage'),
]
| 14.75 | 40 | 0.694915 | 14 | 118 | 5.857143 | 0.642857 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0.177966 | 118 | 7 | 41 | 16.857143 | 0.845361 | 0 | 0 | 0 | 0 | 0 | 0.067797 | 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 |
9dc06dc668e929676ffb5956d78944e23ce96bc5 | 19,614 | py | Python | sympy/mpmath/tests/test_functions2.py | gnulinooks/sympy | 46f63841f96cd025289b91ba9db3e261138d720a | [
"BSD-3-Clause"
] | 1 | 2016-05-09T10:08:18.000Z | 2016-05-09T10:08:18.000Z | sympy/mpmath/tests/test_functions2.py | gnulinooks/sympy | 46f63841f96cd025289b91ba9db3e261138d720a | [
"BSD-3-Clause"
] | null | null | null | sympy/mpmath/tests/test_functions2.py | gnulinooks/sympy | 46f63841f96cd025289b91ba9db3e261138d720a | [
"BSD-3-Clause"
] | null | null | null | import math
from sympy.mpmath import *
def test_bessel():
mp.dps = 15
assert j0(1).ae(0.765197686557966551)
assert j0(pi).ae(-0.304242177644093864)
assert j0(1000).ae(0.0247866861524201746)
assert j0(-25).ae(0.0962667832759581162)
assert j1(1).ae(0.440050585744933516)
assert j1(pi).ae(0.284615343179752757)
assert j1(1000).ae(0.00472831190708952392)
assert j1(-25).ae(0.125350249580289905)
assert besselj(5,1).ae(0.000249757730211234431)
assert besselj(5,pi).ae(0.0521411843671184747)
assert besselj(5,1000).ae(0.00502540694523318607)
assert besselj(5,-25).ae(0.0660079953984229934)
assert besselj(-3,2).ae(-0.128943249474402051)
assert besselj(-4,2).ae(0.0339957198075684341)
assert besselj(3,3+2j).ae(0.424718794929639595942 + 0.625665327745785804812j)
assert besselj(0.25,4).ae(-0.374760630804249715)
assert besselj(1+2j,3+4j).ae(0.319247428741872131 - 0.669557748880365678j)
assert bessely(0,0) == -inf
assert bessely(1,0) == -inf
assert bessely(2,0) == -inf
assert bessely(-1,0) == +inf
assert bessely(-2,0) == -inf
assert bessely(0,0.5).ae(-0.44451873350670655715)
assert bessely(1,0.5).ae(-1.4714723926702430692)
assert bessely(-1,0.5).ae(1.4714723926702430692)
assert bessely(3.5,0.5).ae(-138.86400867242488443)
assert bessely(0,3+4j).ae(4.6047596915010138655-8.8110771408232264208j)
assert bessely(0,j).ae(-0.26803248203398854876+1.26606587775200833560j)
assert besseli(0,0) == 1
assert besseli(1,0) == 0
assert besseli(2,0) == 0
assert besseli(-1,0) == 0
assert besseli(-2,0) == 0
assert besseli(0,0.5).ae(1.0634833707413235193)
assert besseli(1,0.5).ae(0.25789430539089631636)
assert besseli(-1,0.5).ae(0.25789430539089631636)
assert besseli(3.5,0.5).ae(0.00068103597085793815863)
assert besseli(0,3+4j).ae(-3.3924877882755196097-1.3239458916287264815j)
assert besseli(0,j).ae(besselj(0,1))
assert besselk(0,0) == inf
assert besselk(1,0) == inf
assert besselk(2,0) == inf
assert besselk(-1,0) == inf
assert besselk(-2,0) == inf
assert besselk(0,0.5).ae(0.92441907122766586178)
assert besselk(1,0.5).ae(1.6564411200033008937)
assert besselk(-1,0.5).ae(1.6564411200033008937)
assert besselk(3.5,0.5).ae(207.48418747548460607)
assert besselk(0,3+4j).ae(-0.007239051213570155013+0.026510418350267677215j)
assert besselk(0,j).ae(-0.13863371520405399968-1.20196971531720649914j)
def test_hankel():
mp.dps = 15
assert hankel1(0,0.5).ae(0.93846980724081290423-0.44451873350670655715j)
assert hankel1(1,0.5).ae(0.2422684576748738864-1.4714723926702430692j)
assert hankel1(-1,0.5).ae(-0.2422684576748738864+1.4714723926702430692j)
assert hankel1(1.5,0.5).ae(0.0917016996256513026-2.5214655504213378514j)
assert hankel1(1.5,3+4j).ae(0.0066806866476728165382-0.0036684231610839127106j)
assert hankel2(0,0.5).ae(0.93846980724081290423+0.44451873350670655715j)
assert hankel2(1,0.5).ae(0.2422684576748738864+1.4714723926702430692j)
assert hankel2(-1,0.5).ae(-0.2422684576748738864-1.4714723926702430692j)
assert hankel2(1.5,0.5).ae(0.0917016996256513026+2.5214655504213378514j)
assert hankel2(1.5,3+4j).ae(14.783528526098567526-7.397390270853446512j)
def test_hyper_misc():
assert hyp2f1((1,3),(2,3),(5,6),mpf(27)/32).ae(1.6)
assert hyp2f1((1,4),(1,2),(3,4),mpf(80)/81).ae(1.8)
assert hyp2f1((2,3),(1,1),(3,2),(2+j)/3).ae(1.327531603558679093+0.439585080092769253j)
mp.dps = 25
v = mpc('1.2282306665029814734863026', '-0.1225033830118305184672133')
assert hyper([(3,4),2+j,1],[1,5,j/3],mpf(1)/5+j/8).ae(v)
mp.dps = 15
def test_elliptic_integrals():
mp.dps = 15
assert ellipk(0).ae(pi/2)
assert ellipk(0.5).ae(gamma(0.25)**2/(4*sqrt(pi)))
assert ellipk(1) == inf
assert ellipk(1+0j) == inf
assert ellipk(-1).ae('1.3110287771460599052')
assert ellipk(-2).ae('1.1714200841467698589')
assert isinstance(ellipk(-2), mpf)
assert isinstance(ellipe(-2), mpf)
assert ellipk(-50).ae('0.47103424540873331679')
mp.dps = 30
n1 = +fraction(99999,100000)
n2 = +fraction(100001,100000)
mp.dps = 15
assert ellipk(n1).ae('7.1427724505817781901')
assert ellipk(n2).ae(mpc('7.1427417367963090109', '-1.5707923998261688019'))
assert ellipe(n1).ae('1.0000332138990829170')
v = ellipe(n2)
assert v.real.ae('0.999966786328145474069137')
assert (v.imag*10**6).ae('7.853952181727432')
assert ellipk(2).ae(mpc('1.3110287771460599052', '-1.3110287771460599052'))
assert ellipk(50).ae(mpc('0.22326753950210985451', '-0.47434723226254522087'))
assert ellipk(3+4j).ae(mpc('0.91119556380496500866', '0.63133428324134524388'))
assert ellipk(3-4j).ae(mpc('0.91119556380496500866', '-0.63133428324134524388'))
assert ellipk(-3+4j).ae(mpc('0.95357894880405122483', '0.23093044503746114444'))
assert ellipk(-3-4j).ae(mpc('0.95357894880405122483', '-0.23093044503746114444'))
assert isnan(ellipk(nan))
assert isnan(ellipe(nan))
assert ellipk(inf) == 0
assert isinstance(ellipk(inf), mpc)
assert ellipk(-inf) == 0
assert ellipk(1+0j) == inf
assert ellipe(0).ae(pi/2)
assert ellipe(0.5).ae(pi**(mpf(3)/2)/gamma(0.25)**2 +gamma(0.25)**2/(8*sqrt(pi)))
assert ellipe(1) == 1
assert ellipe(1+0j) == 1
assert ellipe(inf) == mpc(0,inf)
assert ellipe(-inf) == inf
assert ellipe(3+4j).ae(1.4995535209333469543-1.5778790079127582745j)
assert ellipe(3-4j).ae(1.4995535209333469543+1.5778790079127582745j)
assert ellipe(-3+4j).ae(2.5804237855343377803-0.8306096791000413778j)
assert ellipe(-3-4j).ae(2.5804237855343377803+0.8306096791000413778j)
assert ellipe(2).ae(0.59907011736779610372+0.59907011736779610372j)
assert ellipe('1e-1000000000').ae(pi/2)
assert ellipk('1e-1000000000').ae(pi/2)
assert ellipe(-pi).ae(2.4535865983838923)
mp.dps = 50
assert ellipk(1/pi).ae('1.724756270009501831744438120951614673874904182624739673')
assert ellipe(1/pi).ae('1.437129808135123030101542922290970050337425479058225712')
assert ellipk(-10*pi).ae('0.5519067523886233967683646782286965823151896970015484512')
assert ellipe(-10*pi).ae('5.926192483740483797854383268707108012328213431657645509')
v = ellipk(pi)
assert v.real.ae('0.973089521698042334840454592642137667227167622330325225')
assert v.imag.ae('-1.156151296372835303836814390793087600271609993858798016')
v = ellipe(pi)
assert v.real.ae('0.4632848917264710404078033487934663562998345622611263332')
assert v.imag.ae('1.0637961621753130852473300451583414489944099504180510966')
mp.dps = 15
def test_exp_integrals():
mp.dps = 15
x = +e
z = e + sqrt(3)*j
assert ei(x).ae(8.21168165538361560)
assert li(x).ae(1.89511781635593676)
assert si(x).ae(1.82104026914756705)
assert ci(x).ae(0.213958001340379779)
assert shi(x).ae(4.11520706247846193)
assert chi(x).ae(4.09647459290515367)
assert fresnels(x).ae(0.437189718149787643)
assert fresnelc(x).ae(0.401777759590243012)
assert airyai(x).ae(0.0108502401568586681)
assert airybi(x).ae(8.98245748585468627)
assert ei(z).ae(3.72597969491314951 + 7.34213212314224421j)
assert li(z).ae(2.28662658112562502 + 1.50427225297269364j)
assert si(z).ae(2.48122029237669054 + 0.12684703275254834j)
assert ci(z).ae(0.169255590269456633 - 0.892020751420780353j)
assert shi(z).ae(1.85810366559344468 + 3.66435842914920263j)
assert chi(z).ae(1.86787602931970484 + 3.67777369399304159j)
assert fresnels(z/3).ae(0.034534397197008182 + 0.754859844188218737j)
assert fresnelc(z/3).ae(1.261581645990027372 + 0.417949198775061893j)
assert airyai(z).ae(-0.0162552579839056062 - 0.0018045715700210556j)
assert airybi(z).ae(-4.98856113282883371 + 2.08558537872180623j)
assert li(0) == 0.0
assert li(1) == -inf
assert li(inf) == inf
assert isinstance(li(0.7), mpf)
assert si(inf).ae(pi/2)
assert si(-inf).ae(-pi/2)
assert ci(inf) == 0
assert ci(0) == -inf
assert isinstance(ei(-0.7), mpf)
assert ei(inf) == inf
assert ei(-inf) == -0.0
assert airyai(inf) == 0
assert airybi(inf) == inf
assert airyai(-inf) == 0
assert airybi(-inf) == 0
assert fresnels(inf) == 0.5
assert fresnelc(inf) == 0.5
assert fresnels(-inf) == -0.5
assert fresnelc(-inf) == -0.5
assert shi(0) == 0
assert shi(inf) == inf
assert shi(-inf) == -inf
assert chi(0) == -inf
assert chi(inf) == inf
assert ei(0) == -inf
assert ei(20+70j).ae(6.1041351911152984397e6 - 2.7324109310519928872e6j)
# tests for the asymptotic expansion
# values checked with Mathematica ExpIntegralEi
mp.dps = 50
r = ei(20000)
s = '3.8781962825045010930273870085501819470698476975019e+8681'
assert str(r) == s
r = ei(-200)
s = '-6.8852261063076355977108174824557929738368086933303e-90'
assert str(r) == s
r =ei(20000 + 10*j)
sre = '-3.255138234032069402493850638874410725961401274106e+8681'
sim = '-2.1081929993474403520785942429469187647767369645423e+8681'
assert str(r.real) == sre and str(r.imag) == sim
mp.dps = 15
def test_trig_integrals():
mp.dps = 30
assert si(mpf(1)/1000000).ae('0.000000999999999999944444444444446111')
assert ci(mpf(1)/1000000).ae('-13.2382948930629912435014366276')
assert si(10**10).ae('1.5707963267075846569685111517747537')
assert ci(10**10).ae('-4.87506025174822653785729773959e-11')
assert si(10**100).ae(pi/2)
assert (ci(10**100)*10**100).ae('-0.372376123661276688262086695553')
assert si(-3) == -si(3)
assert ci(-3).ae(ci(3) + pi*j)
def test_airy():
mp.dps = 15
assert (airyai(10)*10**10).ae(1.1047532552898687)
assert (airybi(10)/10**9).ae(0.45564115354822515)
def test_hyper_0f1():
v = 8.63911136507950465
assert hyper([],[(1,3)],1.5).ae(v)
assert hyper([],[1/3.],1.5).ae(v)
assert hyp0f1(1/3.,1.5).ae(v)
assert hyp0f1((1,3),1.5).ae(v)
def test_hyper_1f1():
v = 1.2917526488617656673
assert hyper([(1,2)],[(3,2)],0.7).ae(v)
assert hyper([(1,2)],[(3,2)],0.7+0j).ae(v)
assert hyper([0.5],[(3,2)],0.7).ae(v)
assert hyper([0.5],[1.5],0.7).ae(v)
assert hyper([0.5],[(3,2)],0.7+0j).ae(v)
assert hyper([0.5],[1.5],0.7+0j).ae(v)
assert hyper([(1,2)],[1.5+0j],0.7).ae(v)
assert hyper([0.5+0j],[1.5],0.7).ae(v)
assert hyper([0.5+0j],[1.5+0j],0.7+0j).ae(v)
assert hyp1f1(0.5,1.5,0.7).ae(v)
assert hyp1f1((1,2),1.5,0.7).ae(v)
def test_hyper_2f1():
v = 1.0652207633823291032
assert hyper([(1,2), (3,4)], [2], 0.3).ae(v)
assert hyper([(1,2), 0.75], [2], 0.3).ae(v)
assert hyper([0.5, 0.75], [2.0], 0.3).ae(v)
assert hyper([0.5, 0.75], [2.0], 0.3+0j).ae(v)
assert hyper([0.5+0j, (3,4)], [2.0], 0.3+0j).ae(v)
assert hyper([0.5+0j, (3,4)], [2.0], 0.3).ae(v)
assert hyper([0.5, (3,4)], [2.0+0j], 0.3).ae(v)
assert hyper([0.5+0j, 0.75+0j], [2.0+0j], 0.3+0j).ae(v)
v = 1.09234681096223231717 + 0.18104859169479360380j
assert hyper([(1,2),0.75+j], [2], 0.5).ae(v)
assert hyper([0.5,0.75+j], [2.0], 0.5).ae(v)
assert hyper([0.5,0.75+j], [2.0], 0.5+0j).ae(v)
assert hyper([0.5,0.75+j], [2.0+0j], 0.5+0j).ae(v)
v = 0.9625 - 0.125j
assert hyper([(3,2),-1],[4], 0.1+j/3).ae(v)
assert hyper([1.5,-1.0],[4], 0.1+j/3).ae(v)
assert hyper([1.5,-1.0],[4+0j], 0.1+j/3).ae(v)
assert hyper([1.5+0j,-1.0+0j],[4+0j], 0.1+j/3).ae(v)
v = 1.02111069501693445001 - 0.50402252613466859521j
assert hyper([(2,10),(3,10)],[(4,10)],1.5).ae(v)
assert hyper([0.2,(3,10)],[0.4+0j],1.5).ae(v)
assert hyper([0.2,(3,10)],[0.4+0j],1.5+0j).ae(v)
v = 0.76922501362865848528 + 0.32640579593235886194j
assert hyper([(2,10),(3,10)],[(4,10)],4+2j).ae(v)
assert hyper([0.2,(3,10)],[0.4+0j],4+2j).ae(v)
assert hyper([0.2,(3,10)],[(4,10)],4+2j).ae(v)
def test_orthpoly():
mp.dps = 15
assert jacobi(-4,2,3,0.7).ae(22800./4913)
assert jacobi(3,2,4,5.5) == 4133.125
assert jacobi(1.5,5/6.,4,0).ae(-1.0851951434075508417)
assert legendre(5, 7) == 129367
assert legendre(0.5,0).ae(0.53935260118837935667)
assert legendre(-1,-1) == 1
assert legendre(0,-1) == 1
assert legendre(0, 1) == 1
assert legendre(1, -1) == -1
assert legendre(7, 1) == 1
assert legendre(7, -1) == -1
assert legendre(8,1.5).ae(15457523./32768)
assert legendre(j,-j).ae(2.4448182735671431011 + 0.6928881737669934843j)
assert chebyu(5,1) == 6
assert chebyt(3,2) == 26
assert legendre(3.5,-1) == inf
assert legendre(4.5,-1) == -inf
assert legendre(3.5+1j,-1) == inf
assert legendre(4.5+1j,-1) == -inf
def test_agm():
mp.dps = 15
assert agm(0,0) == 0
assert agm(0,1) == 0
assert agm(1,1) == 1
assert agm(7,7) == 7
assert agm(j,j) == j
assert (1/agm(1,sqrt(2))).ae(0.834626841674073186)
assert agm(1,2).ae(1.4567910310469068692)
assert agm(1,3).ae(1.8636167832448965424)
assert agm(1,j).ae(0.599070117367796104+0.599070117367796104j)
assert agm(2) == agm(1,2)
assert agm(-3,4).ae(0.63468509766550907+1.3443087080896272j)
def test_incomplete_gamma():
mp.dps = 15
assert gammainc(2,5).ae(6*exp(-5))
assert gammainc(2,0,5).ae(1-6*exp(-5))
assert gammainc(2,3,5).ae(-6*exp(-5)+4*exp(-3))
assert gammainc(-2.5,-0.5).ae(-0.9453087204829418812-5.3164237738936178621j)
assert gammainc(0,2,4).ae(0.045121158298212213088)
assert gammainc(0,3).ae(0.013048381094197037413)
assert gammainc(0,2+j,1-j).ae(0.00910653685850304839-0.22378752918074432574j)
assert gammainc(0,1-j).ae(0.00028162445198141833+0.17932453503935894015j)
assert gammainc(3,4,5,True).ae(0.11345128607046320253)
assert gammainc(3.5,0,inf).ae(gamma(3.5))
def test_erf():
mp.dps = 15
assert erf(0) == 0
assert erf(1).ae(0.84270079294971486934)
assert erf(3+4j).ae(-120.186991395079444098 - 27.750337293623902498j)
assert erf(-4-3j).ae(-0.99991066178539168236 + 0.00004972026054496604j)
assert erf(pi).ae(0.99999112385363235839)
assert erf(1j).ae(1.6504257587975428760j)
assert erf(-1j).ae(-1.6504257587975428760j)
assert isinstance(erf(1), mpf)
assert isinstance(erf(-1), mpf)
assert isinstance(erf(0), mpf)
assert isinstance(erf(0j), mpc)
assert erf(inf) == 1
assert erf(-inf) == -1
assert erfi(0) == 0
assert erfi(1/pi).ae(0.371682698493894314)
assert erfi(inf) == inf
assert erfi(-inf) == -inf
assert erf(1+0j) == erf(1)
assert erfc(1+0j) == erfc(1)
assert erf(0.2+0.5j).ae(1 - erfc(0.2+0.5j))
assert erfc(0) == 1
assert erfc(1).ae(1-erf(1))
assert erfc(-1).ae(1-erf(-1))
assert erfc(1/pi).ae(1-erf(1/pi))
assert erfc(-10) == 2
assert erfc(-1000000) == 2
assert erfc(-inf) == 2
assert erfc(inf) == 0
assert isnan(erfc(nan))
assert (erfc(10**4)*mpf(10)**43429453).ae('3.63998738656420')
mp.dps = 50
# This one does not use the asymptotic series
assert (erfc(10)*10**45).ae('2.0884875837625447570007862949577886115608181193212')
# This one does
assert (erfc(50)*10**1088).ae('2.0709207788416560484484478751657887929322509209954')
mp.dps = 15
assert str(erfc(10**50)) == '3.66744826532555e-4342944819032518276511289189166050822943970058036665661144537831658646492088707747292249493384317534'
assert erfinv(0) == 0
assert erfinv(0.5).ae(0.47693627620446987338)
assert erfinv(-0.5).ae(-0.47693627620446987338)
assert erfinv(1) == inf
assert erfinv(-1) == -inf
assert erf(erfinv(0.95)).ae(0.95)
assert erf(erfinv(0.999999999995)).ae(0.999999999995)
assert erf(erfinv(-0.999999999995)).ae(-0.999999999995)
mp.dps = 50
assert erf(erfinv('0.99999999999999999999999999999995')).ae('0.99999999999999999999999999999995')
assert erf(erfinv('0.999999999999999999999999999999995')).ae('0.999999999999999999999999999999995')
assert erf(erfinv('-0.999999999999999999999999999999995')).ae('-0.999999999999999999999999999999995')
def test_pdf():
mp.dps = 15
assert npdf(-inf) == 0
assert npdf(inf) == 0
assert npdf(5,0,2).ae(5+4,4,2)
assert quadts(lambda x: npdf(x,-0.5,0.8), [-inf, inf]) == 1
assert ncdf(0) == 0.5
assert ncdf(3,3) == 0.5
assert ncdf(-inf) == 0
assert ncdf(inf) == 1
assert ncdf(10) == 1
# Verify that this is computed accurately
assert (ncdf(-10)*10**24).ae(7.619853024160526)
def test_lambertw():
mp.dps = 15
assert lambertw(0) == 0
assert lambertw(0+0j) == 0
assert lambertw(inf) == inf
assert isnan(lambertw(nan))
assert lambertw(inf,1).real == inf
assert lambertw(inf,1).imag.ae(2*pi)
assert lambertw(-inf,1).real == inf
assert lambertw(-inf,1).imag.ae(3*pi)
assert lambertw(0,-1) == -inf
assert lambertw(0,1) == -inf
assert lambertw(0,3) == -inf
assert lambertw(e).ae(1)
assert lambertw(1).ae(0.567143290409783873)
assert lambertw(-pi/2).ae(j*pi/2)
assert lambertw(-log(2)/2).ae(-log(2))
assert lambertw(0.25).ae(0.203888354702240164)
assert lambertw(-0.25).ae(-0.357402956181388903)
assert lambertw(-1./10000,0).ae(-0.000100010001500266719)
assert lambertw(-0.25,-1).ae(-2.15329236411034965)
assert lambertw(0.25,-1).ae(-3.00899800997004620-4.07652978899159763j)
assert lambertw(-0.25,-1).ae(-2.15329236411034965)
assert lambertw(0.25,1).ae(-3.00899800997004620+4.07652978899159763j)
assert lambertw(-0.25,1).ae(-3.48973228422959210+7.41405453009603664j)
assert lambertw(-4).ae(0.67881197132094523+1.91195078174339937j)
assert lambertw(-4,1).ae(-0.66743107129800988+7.76827456802783084j)
assert lambertw(-4,-1).ae(0.67881197132094523-1.91195078174339937j)
assert lambertw(1000).ae(5.24960285240159623)
assert lambertw(1000,1).ae(4.91492239981054535+5.44652615979447070j)
assert lambertw(1000,-1).ae(4.91492239981054535-5.44652615979447070j)
assert lambertw(1000,5).ae(3.5010625305312892+29.9614548941181328j)
assert lambertw(3+4j).ae(1.281561806123775878+0.533095222020971071j)
assert lambertw(-0.4+0.4j).ae(-0.10396515323290657+0.61899273315171632j)
assert lambertw(3+4j,1).ae(-0.11691092896595324+5.61888039871282334j)
assert lambertw(3+4j,-1).ae(0.25856740686699742-3.85211668616143559j)
assert lambertw(-0.5,-1).ae(-0.794023632344689368-0.770111750510379110j)
assert lambertw(-1./10000,1).ae(-11.82350837248724344+6.80546081842002101j)
assert lambertw(-1./10000,-1).ae(-11.6671145325663544)
assert lambertw(-1./10000,-2).ae(-11.82350837248724344-6.80546081842002101j)
assert lambertw(-1./100000,4).ae(-14.9186890769540539+26.1856750178782046j)
assert lambertw(-1./100000,5).ae(-15.0931437726379218666+32.5525721210262290086j)
assert lambertw((2+j)/10).ae(0.173704503762911669+0.071781336752835511j)
assert lambertw((2+j)/10,1).ae(-3.21746028349820063+4.56175438896292539j)
assert lambertw((2+j)/10,-1).ae(-3.03781405002993088-3.53946629633505737j)
assert lambertw((2+j)/10,4).ae(-4.6878509692773249+23.8313630697683291j)
assert lambertw(-(2+j)/10).ae(-0.226933772515757933-0.164986470020154580j)
assert lambertw(-(2+j)/10,1).ae(-2.43569517046110001+0.76974067544756289j)
assert lambertw(-(2+j)/10,-1).ae(-3.54858738151989450-6.91627921869943589j)
assert lambertw(-(2+j)/10,4).ae(-4.5500846928118151+20.6672982215434637j)
mp.dps = 50
assert lambertw(pi).ae('1.073658194796149172092178407024821347547745350410314531')
mp.dps = 15
| 44.678815 | 152 | 0.675793 | 2,931 | 19,614 | 4.514159 | 0.136472 | 0.019273 | 0.020407 | 0.027511 | 0.371476 | 0.331267 | 0.301716 | 0.266495 | 0.213136 | 0.188497 | 0 | 0.429569 | 0.145814 | 19,614 | 438 | 153 | 44.780822 | 0.360153 | 0.009075 | 0 | 0.072115 | 0 | 0 | 0.097581 | 0.094545 | 0 | 0 | 0 | 0 | 0.84375 | 1 | 0.038462 | false | 0 | 0.004808 | 0 | 0.043269 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 3 |
9dcdc08880b6646fef6081c758eed750cbb657e2 | 233 | py | Python | compile_cython.py | federicoparroni/IACV_background_subtractor | ba35ebdfe2e59f4d38723c9292b5dea76be5b9ef | [
"MIT"
] | 2 | 2021-12-12T14:35:16.000Z | 2022-02-07T02:42:34.000Z | compile_cython.py | keyblade95/IACV_background_subtractor | ba35ebdfe2e59f4d38723c9292b5dea76be5b9ef | [
"MIT"
] | null | null | null | compile_cython.py | keyblade95/IACV_background_subtractor | ba35ebdfe2e59f4d38723c9292b5dea76be5b9ef | [
"MIT"
] | 2 | 2019-09-06T15:09:13.000Z | 2019-10-19T08:27:46.000Z | # cython
from distutils.core import setup
from Cython.Build import cythonize
# run:
# python compile_cython.py build_ext --inplace
if __name__ == '__main__':
setup(name='PBAS', ext_modules=cythonize('pbas.pyx', annotate=True))
| 23.3 | 72 | 0.751073 | 32 | 233 | 5.125 | 0.6875 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0.128755 | 233 | 9 | 73 | 25.888889 | 0.807882 | 0.240343 | 0 | 0 | 0 | 0 | 0.115607 | 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 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 1 | 0 | 0 | 0 | 0 | 3 |
9dd93c532daa3346ac61dfaa1bb0b4ed487f1425 | 306 | py | Python | Admission Counselling For Direct Second Year/Web-Application/AdmissionDirectSecondYear/AllIndiaColleges/models.py | atharvaagrawal/direct-second-year-admission-analysis | 4744753c5b69d5e06211f006d56150997793c5bf | [
"MIT"
] | null | null | null | Admission Counselling For Direct Second Year/Web-Application/AdmissionDirectSecondYear/AllIndiaColleges/models.py | atharvaagrawal/direct-second-year-admission-analysis | 4744753c5b69d5e06211f006d56150997793c5bf | [
"MIT"
] | 1 | 2020-03-25T11:06:18.000Z | 2020-03-25T11:06:18.000Z | Admission Counselling For Direct Second Year/Web-Application/AdmissionDirectSecondYear/AllIndiaColleges/models.py | atharvaagrawal/direct-second-year-admission-analysis | 4744753c5b69d5e06211f006d56150997793c5bf | [
"MIT"
] | null | null | null | from django.db import models
# Create your models here.
class AllIndiaCollegeModel(models.Model):
name = models.CharField(max_length=300)
city = models.CharField(max_length=300)
state = models.CharField(max_length=300)
class Meta:
db_table = "ALLINDIACOLLEGE2019"
| 25.5 | 46 | 0.696078 | 36 | 306 | 5.805556 | 0.583333 | 0.215311 | 0.258373 | 0.344498 | 0.38756 | 0 | 0 | 0 | 0 | 0 | 0 | 0.054393 | 0.218954 | 306 | 12 | 47 | 25.5 | 0.820084 | 0.078431 | 0 | 0 | 0 | 0 | 0.07037 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | false | 0 | 0.142857 | 0 | 0.857143 | 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 |
9df8065db761163894d3144b16b7d1c26968a436 | 191 | py | Python | Algorithms/Implementation/sequence-equation.py | vishu006/Hackerrank | 927bc370b668aa568d17ee96ac2a3728568d437e | [
"CC-BY-4.0"
] | 1 | 2017-08-12T19:18:12.000Z | 2017-08-12T19:18:12.000Z | Algorithms/Implementation/sequence-equation.py | vishu006/Hackerrank | 927bc370b668aa568d17ee96ac2a3728568d437e | [
"CC-BY-4.0"
] | null | null | null | Algorithms/Implementation/sequence-equation.py | vishu006/Hackerrank | 927bc370b668aa568d17ee96ac2a3728568d437e | [
"CC-BY-4.0"
] | null | null | null | # Author : Rajanikant Tenguria
import sys
n=int(raw_input())
a=map(int,raw_input().split())
h=[0]*(n+1)
for i in range (n+1):
h[a[a[i-1]-1]]=i
for i in range(0,n):
print h[i+1]
| 15.916667 | 30 | 0.586387 | 42 | 191 | 2.619048 | 0.47619 | 0.109091 | 0.2 | 0.2 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0.045161 | 0.188482 | 191 | 11 | 31 | 17.363636 | 0.664516 | 0.146597 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | null | null | 0 | 0.125 | null | null | 0.125 | 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 |
9dfcdf1f550bb79d40c80e1b5c1feb7845a945fe | 22 | py | Python | pcfg_evaluation/pipeline/pcfg/__init__.py | PhilippGawlik/compoundtree | 174e009c8a3114695a02b8674dad87903c76f5f8 | [
"MIT"
] | 2 | 2017-03-14T20:12:24.000Z | 2020-06-01T11:49:20.000Z | pcfg_evaluation/pipeline/pcfg/__init__.py | PhilippGawlik/compoundtree | 174e009c8a3114695a02b8674dad87903c76f5f8 | [
"MIT"
] | null | null | null | pcfg_evaluation/pipeline/pcfg/__init__.py | PhilippGawlik/compoundtree | 174e009c8a3114695a02b8674dad87903c76f5f8 | [
"MIT"
] | null | null | null | __all__ = ["annoate"]
| 11 | 21 | 0.636364 | 2 | 22 | 5 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0.136364 | 22 | 1 | 22 | 22 | 0.526316 | 0 | 0 | 0 | 0 | 0 | 0.318182 | 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 |
d177415c44462738dfd711da5d2b5ea5b655a8fc | 541 | py | Python | Session_01/py101/2_variables.py | weighanchor4414/DigitalWorldWorkshop2020 | 9eca3a789e5532680ab032c20fe892bdbd47b891 | [
"MIT"
] | 9 | 2020-06-05T17:01:23.000Z | 2022-03-16T19:55:50.000Z | Session_01/py101/2_variables.py | weighanchor4414/DigitalWorldWorkshop2020 | 9eca3a789e5532680ab032c20fe892bdbd47b891 | [
"MIT"
] | null | null | null | Session_01/py101/2_variables.py | weighanchor4414/DigitalWorldWorkshop2020 | 9eca3a789e5532680ab032c20fe892bdbd47b891 | [
"MIT"
] | 2 | 2020-02-20T16:48:35.000Z | 2020-03-18T14:36:04.000Z | a = 12
print(f"a is {a}")
print(f"Data Type of a is {type(a)}")
b = 3.1415926
print(f"b is {b}")
print(f"Data Type of b is {type(b)}")
c = "message"
print(f"c is {c}")
print(f"Data Type of c is {type(c)}")
d = True
print(f"d is {d}")
print(f"Data Type of d is {type(d)}")
e = None
print(f"e is {e}")
print(f"Data Type of e is {type(e)}")
# type conversion
print("------------------")
print(b, type(b), sep=" | ")
b = int(b)
print(b, type(b), sep=" | ")
b = float(b)
print(b, type(b), sep=" | ")
b = str(b)
print(b, type(b), sep=" | ")
| 17.451613 | 37 | 0.539741 | 113 | 541 | 2.584071 | 0.19469 | 0.205479 | 0.171233 | 0.239726 | 0.486301 | 0.212329 | 0.109589 | 0 | 0 | 0 | 0 | 0.022624 | 0.182994 | 541 | 30 | 38 | 18.033333 | 0.638009 | 0.027726 | 0 | 0.173913 | 0 | 0 | 0.40458 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | false | 0 | 0 | 0 | 0 | 0.652174 | 0 | 0 | 0 | null | 1 | 0 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 3 |
d17caa4db910f615d3c4f7a8c9ccf2668aeee219 | 558 | py | Python | LinkedList/141 Detect Loop in linked list.py | ikaushikpal/DS-450-python | 9466f77fb9db9e6a5bb3f20aa89ba6332f49e848 | [
"MIT"
] | 3 | 2021-06-28T12:04:19.000Z | 2021-09-07T07:23:41.000Z | LinkedList/141 Detect Loop in linked list.py | SupriyoDam/DS-450-python | 5dc21ce61b3279e9bd9d6ef3ad236667227ca283 | [
"MIT"
] | null | null | null | LinkedList/141 Detect Loop in linked list.py | SupriyoDam/DS-450-python | 5dc21ce61b3279e9bd9d6ef3ad236667227ca283 | [
"MIT"
] | 1 | 2021-06-28T15:42:55.000Z | 2021-06-28T15:42:55.000Z | def detectLoop(head):
if head == None:
return False
start = head
next_next_start = head.next
if next_next_start == None:
return False
next_next_start = head.next.next
while next_next_start != None:
start = start.next
next_next_start = next_next_start.next
if next_next_start == None:
return False
next_next_start = next_next_start.next
if start == next_next_start:
return True
return False
| 21.461538 | 46 | 0.555556 | 66 | 558 | 4.393939 | 0.166667 | 0.331034 | 0.448276 | 0.234483 | 0.565517 | 0.47931 | 0.47931 | 0.47931 | 0.324138 | 0.324138 | 0 | 0 | 0.390681 | 558 | 25 | 47 | 22.32 | 0.852941 | 0 | 0 | 0.470588 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0.058824 | false | 0 | 0 | 0 | 0.352941 | 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 |
d182b004094d9d92721d17125669d28978a7c7f0 | 215 | py | Python | d6tflow/tasks/torch.py | Mozin/d6tflow | e332e2244d5d98362eb7d15b4c7800a14a4a56e5 | [
"MIT"
] | 1,004 | 2019-01-11T09:59:26.000Z | 2022-03-31T17:48:50.000Z | d6tflow/tasks/torch.py | Mozin/d6tflow | e332e2244d5d98362eb7d15b4c7800a14a4a56e5 | [
"MIT"
] | 27 | 2019-03-28T02:29:40.000Z | 2022-02-07T12:38:17.000Z | d6tflow/tasks/torch.py | Mozin/d6tflow | e332e2244d5d98362eb7d15b4c7800a14a4a56e5 | [
"MIT"
] | 73 | 2019-02-27T03:13:15.000Z | 2021-08-29T06:10:25.000Z | from d6tflow.tasks import TaskData
from d6tflow.targets.torch import PyTorchModel
class PyTorch(TaskData):
"""
Task which saves to .pt models
"""
target_class = PyTorchModel
target_ext = '.pt'
| 19.545455 | 46 | 0.702326 | 26 | 215 | 5.730769 | 0.692308 | 0.147651 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0.011834 | 0.213953 | 215 | 10 | 47 | 21.5 | 0.869822 | 0.139535 | 0 | 0 | 0 | 0 | 0.017857 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | false | 0 | 0.4 | 0 | 1 | 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 | 1 | 0 | 1 | 0 | 0 | 3 |
d1897d6aafb96e8dcabbe39665ca8f88206e7b2c | 201 | py | Python | coffin/conf/urls/defaults.py | spothero/coffin | 9ea6a9173cbfed592c5b4776c489dba8d9280d52 | [
"BSD-3-Clause"
] | null | null | null | coffin/conf/urls/defaults.py | spothero/coffin | 9ea6a9173cbfed592c5b4776c489dba8d9280d52 | [
"BSD-3-Clause"
] | null | null | null | coffin/conf/urls/defaults.py | spothero/coffin | 9ea6a9173cbfed592c5b4776c489dba8d9280d52 | [
"BSD-3-Clause"
] | null | null | null | from django.conf.urls import (handler403, handler404, handler500,
include, patterns, url)
handler404 = 'coffin.views.defaults.page_not_found'
handler500 = 'coffin.views.defaults.server_error'
| 33.5 | 65 | 0.776119 | 24 | 201 | 6.375 | 0.791667 | 0.143791 | 0.248366 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0.084746 | 0.119403 | 201 | 5 | 66 | 40.2 | 0.779661 | 0 | 0 | 0 | 0 | 0 | 0.348259 | 0.348259 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | false | 0 | 0.25 | 0 | 0.25 | 0 | 1 | 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 | 0 | 0 | 0 | 3 |
d1a95e4123db8d5eb163b8f981a8c4012609a768 | 165 | py | Python | script.py | kotbegemot/call-cost | 4b69da73fc546aed974f2185ad07a337b4c8f967 | [
"MIT"
] | null | null | null | script.py | kotbegemot/call-cost | 4b69da73fc546aed974f2185ad07a337b4c8f967 | [
"MIT"
] | null | null | null | script.py | kotbegemot/call-cost | 4b69da73fc546aed974f2185ad07a337b4c8f967 | [
"MIT"
] | null | null | null | #import sys, os
#from importlib import import_module
from fast_calc import rbp
def run(a,b):
return rbp(a, b)
def fcn2( a ):
a.id = a.id2
return a
| 13.75 | 36 | 0.642424 | 30 | 165 | 3.466667 | 0.566667 | 0.038462 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0.016393 | 0.260606 | 165 | 11 | 37 | 15 | 0.836066 | 0.29697 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0.333333 | false | 0 | 0.166667 | 0.166667 | 0.833333 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 0 | 1 | 1 | 0 | 0 | 3 |
d1ab33cbf73b07ffd46a7fa5b169cc780dcf1947 | 610 | py | Python | tests/prompts/challenges/choice_test.py | nkrot/paukenator | d7d188dd4bc283208c544f2b29530046768df7ee | [
"MIT"
] | null | null | null | tests/prompts/challenges/choice_test.py | nkrot/paukenator | d7d188dd4bc283208c544f2b29530046768df7ee | [
"MIT"
] | null | null | null | tests/prompts/challenges/choice_test.py | nkrot/paukenator | d7d188dd4bc283208c544f2b29530046768df7ee | [
"MIT"
] | null | null | null | import pytest
from paukenator.prompts.challenges import Choice
@pytest.fixture
def correct_choice():
return Choice("1", "Love", True)
@pytest.fixture
def wrong_choice():
return Choice("2", "Hate", False)
def test_correct_choice(correct_choice):
assert "1", correct_choice.name
assert "Love", correct_choice.value
assert correct_choice.correct
def test_wrong_choice(wrong_choice):
assert "2", wrong_choice.name
assert "Hate", wrong_choice.value
assert not wrong_choice.correct
def test_serialization(correct_choice):
assert "option 1: Love" == str(correct_choice)
| 20.333333 | 50 | 0.740984 | 81 | 610 | 5.37037 | 0.320988 | 0.23908 | 0.073563 | 0.091954 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0.009728 | 0.157377 | 610 | 29 | 51 | 21.034483 | 0.836576 | 0 | 0 | 0.111111 | 0 | 0 | 0.055738 | 0 | 0 | 0 | 0 | 0 | 0.388889 | 1 | 0.277778 | false | 0 | 0.111111 | 0.111111 | 0.5 | 0 | 0 | 0 | 0 | null | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 0 | 1 | 0 | 0 | 0 | 3 |
d1e485f4d2964fb490ef19419a559824b85157f3 | 1,016 | py | Python | uer/targets/__init__.py | zhengmidon/jingju_baseline | 4c6ef80ac14b4640efb1f81cde38df2ac35eacd2 | [
"Apache-2.0"
] | 2 | 2022-01-14T06:43:07.000Z | 2022-01-14T15:10:40.000Z | uer/targets/__init__.py | zhengmidon/jingju_baseline | 4c6ef80ac14b4640efb1f81cde38df2ac35eacd2 | [
"Apache-2.0"
] | null | null | null | uer/targets/__init__.py | zhengmidon/jingju_baseline | 4c6ef80ac14b4640efb1f81cde38df2ac35eacd2 | [
"Apache-2.0"
] | null | null | null | from uer.targets.mlm_target import MlmTarget
from uer.targets.lm_target import LmTarget
from uer.targets.bert_target import BertTarget
from uer.targets.cls_target import ClsTarget
from uer.targets.bilm_target import BilmTarget
from uer.targets.albert_target import AlbertTarget
from uer.targets.seq2seq_target import Seq2seqTarget
from uer.targets.t5_target import T5Target
from uer.targets.gsg_target import GsgTarget
from uer.targets.bart_target import BartTarget
from uer.targets.prefixlm_target import PrefixlmTarget
str2target = {"bert": BertTarget, "mlm": MlmTarget, "lm": LmTarget,
"bilm": BilmTarget, "albert": AlbertTarget, "seq2seq": Seq2seqTarget,
"t5": T5Target, "gsg": GsgTarget, "bart": BartTarget,
"cls": ClsTarget, "prefixlm": PrefixlmTarget}
__all__ = ["BertTarget", "MlmTarget", "LmTarget", "BilmTarget", "AlbertTarget",
"Seq2seqTarget", "T5Target", "GsgTarget", "BartTarget", "ClsTarget", "PrefixlmTarget", "str2target"]
| 48.380952 | 112 | 0.740157 | 113 | 1,016 | 6.522124 | 0.256637 | 0.104478 | 0.208955 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0.013986 | 0.155512 | 1,016 | 20 | 113 | 50.8 | 0.844988 | 0 | 0 | 0 | 0 | 0 | 0.168675 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | false | 0 | 0.647059 | 0 | 0.647059 | 0 | 0 | 0 | 0 | null | 0 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 1 | 0 | 0 | 3 |
0601b905a2f85482f4a72c35cf47670546734711 | 339 | py | Python | flask_discord_interactions/tests/test_command.py | TheJaffaMeme/flask-discord-interactions | ae80f2e6d302911a5b46303ebbe1fedd00355aa4 | [
"MIT"
] | null | null | null | flask_discord_interactions/tests/test_command.py | TheJaffaMeme/flask-discord-interactions | ae80f2e6d302911a5b46303ebbe1fedd00355aa4 | [
"MIT"
] | null | null | null | flask_discord_interactions/tests/test_command.py | TheJaffaMeme/flask-discord-interactions | ae80f2e6d302911a5b46303ebbe1fedd00355aa4 | [
"MIT"
] | null | null | null | import pytest
def test_invalid_name(discord):
with pytest.raises(ValueError):
@discord.command()
def sh(ctx):
return "this shouldn't work..."
def test_provided_name(discord, client):
@discord.command(name="other")
def fn(ctx):
return "hi"
assert client.run("other").content == "hi"
| 19.941176 | 46 | 0.622419 | 42 | 339 | 4.928571 | 0.619048 | 0.067633 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0.241888 | 339 | 16 | 47 | 21.1875 | 0.805447 | 0 | 0 | 0 | 0 | 0 | 0.106195 | 0 | 0 | 0 | 0 | 0 | 0.090909 | 1 | 0.363636 | false | 0 | 0.090909 | 0.181818 | 0.636364 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 0 | 1 | 1 | 0 | 0 | 3 |
ae0cc9232c0e1503617117b48733adf6a0314650 | 19 | py | Python | bing-wallpaper/wallpaper/__init__.py | LogicJake/tools | 9630dcdbeec92ccc1548bb527fc5268039bb79b8 | [
"MIT"
] | null | null | null | bing-wallpaper/wallpaper/__init__.py | LogicJake/tools | 9630dcdbeec92ccc1548bb527fc5268039bb79b8 | [
"MIT"
] | null | null | null | bing-wallpaper/wallpaper/__init__.py | LogicJake/tools | 9630dcdbeec92ccc1548bb527fc5268039bb79b8 | [
"MIT"
] | null | null | null | name = "wallpaper"
| 9.5 | 18 | 0.684211 | 2 | 19 | 6.5 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0.157895 | 19 | 1 | 19 | 19 | 0.8125 | 0 | 0 | 0 | 0 | 0 | 0.473684 | 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 |
ae0d98de0b233ba5384b8fa3205f68e4e2785016 | 727 | py | Python | videoSources.py | mralext20/neos-video-backend | 959118040e2385eb0d89e255787a27b8cf597858 | [
"MIT"
] | 1 | 2020-12-20T22:06:32.000Z | 2020-12-20T22:06:32.000Z | videoSources.py | mralext20/neos-video-backend | 959118040e2385eb0d89e255787a27b8cf597858 | [
"MIT"
] | 5 | 2020-12-20T21:53:10.000Z | 2021-03-08T20:39:15.000Z | videoSources.py | mralext20/neos-video-backend | 959118040e2385eb0d89e255787a27b8cf597858 | [
"MIT"
] | 4 | 2020-12-20T22:07:24.000Z | 2021-03-14T02:09:36.000Z | youtubePlaylists = [
"PLxAzjHbHvNcUvcajBsGW2VI6fyIWa4sVl", # ProbablePrime
"PLjux6EKYfu0045V_-s5l9biu55fzbWFAO", # Deloious Jax
"PLoAvz0_U4_3wuXXrl8IbyJIYZFdeIgyHm", # Frooxius
"PLSa764cPPsV9saKq_9Sb_izfwgI9cY-8u", # CuriosVR.. coffee
"PLWhfKbDgR4zD-o31sgHqesncjt49Jxou7", # AMoB tutorials
"PLFYjCoKo3ivA67rj20lIsmUG2AQoavYHG", # Alex Drypy Avali
"PLwitPMCdx0xu2KQ7vwoccaPUp-31qfdjK", # Turk
"PLSB-6Ok84ZR0Ow4ziNWuFLGTgf3M1JDKT", # sirkitree
"PLa82mLNo3G469kqA5avK5A2bAyycT6BuJ", # dev tips from Mystic Forge
"PLxzYbxVivbzR5z8FQGfXOmOhx7lfnMxFs", # jiink's neos tutorials
"PLpwEkiuuwBpACPqbsPKuJOLTQsFz4Q-7C", # Nicole+
"PLh_pMt0Xa7j8UQJ3fzJMvdTHduACp4jpP", # Engi
]
| 48.466667 | 71 | 0.763411 | 48 | 727 | 11.4375 | 0.979167 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0.108766 | 0.152682 | 727 | 14 | 72 | 51.928571 | 0.782468 | 0.224209 | 0 | 0 | 0 | 0 | 0.740472 | 0.740472 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | false | 0 | 0 | 0 | 0 | 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 | 1 | 1 | null | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 3 |
ae253dfee53af79a6057cb5880930583a58867ef | 114 | py | Python | terrascript/provider/dme.py | amlodzianowski/python-terrascript | 1111affe6cd30d9b8b7bc74ae4e27590f7d4dc49 | [
"BSD-2-Clause"
] | null | null | null | terrascript/provider/dme.py | amlodzianowski/python-terrascript | 1111affe6cd30d9b8b7bc74ae4e27590f7d4dc49 | [
"BSD-2-Clause"
] | null | null | null | terrascript/provider/dme.py | amlodzianowski/python-terrascript | 1111affe6cd30d9b8b7bc74ae4e27590f7d4dc49 | [
"BSD-2-Clause"
] | null | null | null | # terrascript/provider/dme.py
import terrascript
class dme(terrascript.Provider):
pass
__all__ = ["dme"]
| 10.363636 | 32 | 0.719298 | 13 | 114 | 6 | 0.615385 | 0.487179 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0.166667 | 114 | 10 | 33 | 11.4 | 0.821053 | 0.236842 | 0 | 0 | 0 | 0 | 0.035294 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | false | 0.25 | 0.25 | 0 | 0.5 | 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 | 1 | 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.