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 |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
53ec504a30d5694559e19b9891f338b0e6a4a72b | 15,539 | py | Python | tests/test_utils.py | harvard-vpal/canvas_python_sdk | 6c004d9bb8c207f0d227d6b1939e95603d0bf7b1 | [
"MIT"
] | 21 | 2015-06-12T13:49:04.000Z | 2021-11-08T05:37:44.000Z | tests/test_utils.py | harvard-vpal/canvas_python_sdk | 6c004d9bb8c207f0d227d6b1939e95603d0bf7b1 | [
"MIT"
] | 44 | 2015-02-04T15:26:52.000Z | 2021-12-03T17:47:00.000Z | tests/test_utils.py | harvard-vpal/canvas_python_sdk | 6c004d9bb8c207f0d227d6b1939e95603d0bf7b1 | [
"MIT"
] | 7 | 2015-07-20T23:56:03.000Z | 2021-02-23T17:13:00.000Z | import unittest
from unittest import mock
import requests
from unittest.mock import patch
from canvas_sdk import utils
from canvas_sdk.client import RequestContext
class TestUtils(unittest.TestCase):
def setUp(self):
self.path = '/v1/accounts'
self.req_ctx = mock.MagicMock(name='request-context', spec=RequestContext)
def build_response_mock(self, links=None, json_data=None):
"""
Build a MagicMock to imitate a requests.Response where the json call returns the input
json_data in a list
"""
response = mock.MagicMock(spec=requests.Response)
response.links = links or {} # Default to no header links
response.json.return_value = json_data if json_data else mock.DEFAULT
return response
def test_validate_any_invalid_input(self):
"""
validate_any should fail if no arguments are falsy
"""
self.assertRaises(AttributeError,
utils.validate_any,
[], None, None)
self.assertRaises(AttributeError,
utils.validate_any,
[], None, None, '')
self.assertRaises(AttributeError,
utils.validate_any,
[])
def test_validate_any_valid_input(self):
"""
validate_any should pass if any arguments are truthy
"""
try:
utils.validate_any([], 'a', None)
utils.validate_any([], 'a', 2)
except AttributeError:
self.fail()
def test_validate_any_param_choices(self):
"""
validate_any shouldn't care how many values are in param_choices,
or whether param_choices is a list or tuple.
"""
self.assertRaises(AttributeError,
utils.validate_any,
[], None, None)
self.assertRaises(AttributeError,
utils.validate_any,
['one'], None, None)
self.assertRaises(AttributeError,
utils.validate_any,
['one', 'two'], None, None)
self.assertRaises(AttributeError,
utils.validate_any,
(), None, None)
self.assertRaises(AttributeError,
utils.validate_any,
('one'), None, None)
self.assertRaises(AttributeError,
utils.validate_any,
('one', 'two'), None, None)
def test_validate_attr_is_acceptable_raises_attributeerror(self):
"""
Assert that validate_attr_is_acceptable raises an AttributeError if the given
value does not match an entry in the acceptable_values list
"""
self.assertRaises(AttributeError, utils.validate_attr_is_acceptable, 'a', ['b', 'c'])
def test_validate_attr_is_acceptable_raises_attributeerror_on_allow_none_false(self):
"""
Assert that validate_attr_is_acceptable raises an AttributeError if the value is None
and allow_none is False
"""
self.assertRaises(
AttributeError, utils.validate_attr_is_acceptable, None, ['b', 'c'], False)
def test_validate_attr_is_acceptable_raises_attributeerror_on_allow_none_true(self):
"""
Assert that validate_attr_is_acceptable does not raise an AttributeError if the value is None
and allow_none is True
"""
try:
utils.validate_attr_is_acceptable(None, ['b', 'c'], True)
except AttributeError:
print('assert None can be passed when allow_none=True failed')
raise
@patch('canvas_sdk.utils.client.get')
def test_get_next_for_response_without_a_next_link_yields_nothing(self, mock_client_get):
"""
Assert that call to get_next with a response that doesn't have any 'next' links doesn't iterate.
"""
initial_response = self.build_response_mock()
with self.assertRaises(StopIteration):
next(utils.get_next(self.req_ctx, initial_response))
self.assertTrue(not mock_client_get.called)
@patch('canvas_sdk.utils.client.get')
def test_get_next_for_response_with_a_next_link_calls_client_get_with_request_context(self, mock_client_get):
"""
Assert that call to get_next with a response that has 'next' links (in this case one additional
page) calls the client "get" method with the request context.
"""
initial_response = self.build_response_mock({'next': {'url': 'http://next-url'}})
next(utils.get_next(self.req_ctx, initial_response))
mock_client_get.assert_called_once_with(self.req_ctx, mock.ANY)
@patch('canvas_sdk.utils.client.get')
def test_get_next_for_response_with_a_next_link_calls_client_get_with_url(self, mock_client_get):
"""
Assert that call to get_next with a response that has 'next' links (in this case one additional
page) calls the client "get" method with the next url.
"""
next_url = 'http://next-url'
initial_response = self.build_response_mock({'next': {'url': next_url}})
next(utils.get_next(self.req_ctx, initial_response))
mock_client_get.assert_called_once_with(mock.ANY, next_url)
@patch('canvas_sdk.utils.client.get')
def test_get_next_for_response_with_a_next_link_returns_next_response(self, mock_client_get):
"""
Assert that call to get_next with a response that has a 'next' links returns the
next response on first yield.
"""
initial_response = self.build_response_mock({'next': {'url': 'http://next/url/1'}})
second_response = self.build_response_mock()
mock_client_get.return_value = second_response
result = next(utils.get_next(self.req_ctx, initial_response))
self.assertEqual(
result, second_response, "Result of get_next should be return value of client.get")
@patch('canvas_sdk.utils.client.get')
def test_get_next_for_response_with_a_next_link_stops_iterating_after_first_call(self, mock_client_get):
"""
Assert that call to get_next with a response that has a 'next' links stops iteration on second iteration
"""
initial_response = self.build_response_mock({'next': {'url': 'http://next/url/1'}})
second_response = self.build_response_mock()
mock_client_get.return_value = second_response
result = next(utils.get_next(self.req_ctx, initial_response))
with self.assertRaises(StopIteration):
next(utils.get_next(self.req_ctx, result))
@patch('canvas_sdk.utils.get_next')
def test_get_all_list_data_calls_function_parameter_with_context_args_and_kwargs(self, mock_next):
"""
Assert that call to get_all_list_data calls function parameter with context, args, and kwargs
"""
mock_next.return_value = iter([])
mock_function = mock.Mock(name='mock-function')
arg1, arg2 = 'arg1', 'arg2'
kwargs = {'kwarg1': 'val1', 'kwarg2': 'val2'}
utils.get_all_list_data(self.req_ctx, mock_function, arg1, arg2, **kwargs)
mock_function.assert_called_once_with(self.req_ctx, arg1, arg2, **kwargs)
@patch('canvas_sdk.utils.get_next')
def test_get_all_list_data_calls_json_on_function_return_value(self, mock_next):
"""
Assert that call to get_all_list_data makes call to json method on result of function call
"""
mock_next.return_value = iter([])
mock_function = mock.Mock(name='mock-function')
mock_response = self.build_response_mock()
mock_function.return_value = mock_response
utils.get_all_list_data(self.req_ctx, mock_function)
mock_response.json.assert_called_once_with()
@patch('canvas_sdk.utils.get_next')
def test_get_all_list_data_calls_get_next_with_request_context_and_response(self, mock_next):
"""
Assert that call to get_all_list_data makes a call to get_next with context and function response
"""
mock_next.return_value = iter([])
mock_function = mock.Mock(name='mock-function')
mock_response = self.build_response_mock()
mock_function.return_value = mock_response
utils.get_all_list_data(self.req_ctx, mock_function)
mock_next.assert_called_once_with(self.req_ctx, mock_response)
@patch('canvas_sdk.utils.get_next')
def test_get_all_list_data_returns_initial_response_json_when_response_has_no_paged_results(self, mock_next):
"""
Assert that result of call to get_all_list_data for a request that's not a list and has no paged results returns
the json response as is.
"""
expected_json = {'first': 'json'}
mock_next.return_value = iter([])
mock_function = mock.Mock(name='mock-function')
mock_response = self.build_response_mock(json_data=expected_json)
mock_function.return_value = mock_response
results = utils.get_all_list_data(self.req_ctx, mock_function)
self.assertEqual(
results, expected_json, "The json data returned by get_all function should match up with expected_json")
@patch('canvas_sdk.utils.get_next')
def test_get_all_list_data_returns_initial_response_list_json_when_response_has_no_paged_results(self, mock_next):
"""
Assert that result of call to get_all_list_data for a request that's a list of data and has no paged results returns
the json list.
"""
expected_json = [{'first': 'json'}]
mock_next.return_value = iter([])
mock_function = mock.Mock(name='mock-function')
mock_response = self.build_response_mock(json_data=expected_json)
mock_function.return_value = mock_response
results = utils.get_all_list_data(self.req_ctx, mock_function)
self.assertEqual(
results, expected_json, "The json data returned by get_all function should match up with expected_json list")
@patch('canvas_sdk.utils.get_next')
def test_get_all_list_data_raises_attribute_error_on_paged_results_if_initial_result_not_a_list(self, mock_next):
"""
Assert that call to get_all_list_data will raise an AttributeError in the event that the initial response is something
other than a list (i.e., a json string or dict)
"""
# Simulate an initial response with 3 additional pages
mock_next.return_value = iter([
self.build_response_mock(json_data=['test-data']),
])
mock_function = mock.Mock(name='mock-function')
mock_response = self.build_response_mock(json_data={'dict': 'data'})
mock_function.return_value = mock_response
with self.assertRaises(AttributeError):
utils.get_all_list_data(self.req_ctx, mock_function)
@patch('canvas_sdk.utils.get_next')
def test_get_all_list_data_returns_concatenated_list_of_json_results(self, mock_next):
"""
Assert that result of call to get_all_list_data is a single concatenated list of json data from
series of "next" responses.
"""
expected_json = [
{'first': 'json'}, {'second': 'json'}, {'third': 'json'}, {'fourth': 'json'}]
# Simulate an initial response with 3 additional pages
mock_next.return_value = iter([
self.build_response_mock(json_data=[expected_json[1]]),
self.build_response_mock(json_data=[expected_json[2]]),
self.build_response_mock(json_data=[expected_json[3]]),
])
mock_function = mock.Mock(name='mock-function')
mock_response = self.build_response_mock(json_data=[expected_json[0]])
mock_function.return_value = mock_response
results = utils.get_all_list_data(self.req_ctx, mock_function)
self.assertEqual(
results, expected_json, "The json list of data returned by get_all function should be the fully concatenated list of json")
def test_masquerade_returns_function_response(self):
"""
Assert that result of call to masquerade is the API function response.
"""
mock_function = mock.Mock(name='mock-function')
results = utils.masquerade(self.req_ctx, mock_function, "test-user-id")
self.assertEqual(
results, mock_function.return_value, "Masquerading should return result of API method call")
def test_masquerade_makes_function_call_with_context(self):
"""
Assert that masquerade calls the API function with the request_context.
"""
mock_function = mock.Mock(name='mock-function')
utils.masquerade(self.req_ctx, mock_function, "test-user-id")
mock_function.assert_called_once_with(self.req_ctx, params=mock.ANY)
def test_masquerade_makes_function_call_with_user_id_params_kwarg(self):
"""
Assert that masquerade adds a "params" keyword argument containing the 'as_user_id' parameter.
"""
as_user_id = "test-user-id"
mock_function = mock.Mock(name='mock-function')
utils.masquerade(self.req_ctx, mock_function, as_user_id)
mock_function.assert_called_once_with(mock.ANY, params={'as_user_id': as_user_id})
def test_masquerade_makes_function_call_with_merged_user_id_params_kwarg(self):
"""
Assert that masquerade will merge the 'as_user_id' parameter into an existing "params" kwarg
that was passed in to the call.
"""
params_kwarg = {'params': {'foo': 'bar'}}
as_user_id = "test-user-id"
mock_function = mock.Mock(name='mock-function')
utils.masquerade(self.req_ctx, mock_function, as_user_id, **params_kwarg)
mock_function.assert_called_once_with(
mock.ANY, params={'as_user_id': as_user_id, 'foo': 'bar'})
@patch('canvas_sdk.utils.get_all_list_data')
def test_get_count_calls_get_all_list_data_with_request_context_and_function(self, mock_get_all):
"""
Assert that call to get_count makes a call to get_all_list_data with context and function
"""
mock_function = mock.Mock(name='mock-function')
utils.get_count(self.req_ctx, mock_function)
mock_get_all.assert_called_once_with(self.req_ctx, mock_function)
@patch('canvas_sdk.utils.get_all_list_data')
def test_get_count_calls_get_all_list_data_with_args_and_kwargs(self, mock_get_all):
"""
Assert that call to get_count makes a call to get_all_list_data with args and kwargs
"""
mock_function = mock.Mock(name='mock-function')
arg1, arg2 = 'arg1', 'arg2'
kwargs = {'kwarg1': 'val1', 'kwarg2': 'val2'}
utils.get_count(self.req_ctx, mock_function, arg1, arg2, **kwargs)
mock_get_all.assert_called_once_with(mock.ANY, mock.ANY, arg1, arg2, **kwargs)
@patch('canvas_sdk.utils.get_all_list_data')
def test_get_count_returns_length_of_get_all_list_data(self, mock_get_all):
"""
Assert that call to get_count makes a call to get_all_list_data with args and kwargs
"""
mock_get_all.return_value = [1, 2, 3, 4, 5]
mock_function = mock.Mock(name='mock-function')
result = utils.get_count(self.req_ctx, mock_function)
self.assertEqual(result, 5, "The result of get_count should match length of result set")
| 45.702941 | 135 | 0.671407 | 2,065 | 15,539 | 4.726877 | 0.100726 | 0.066387 | 0.030735 | 0.043028 | 0.745211 | 0.730663 | 0.719496 | 0.687839 | 0.614384 | 0.600246 | 0 | 0.003384 | 0.239269 | 15,539 | 339 | 136 | 45.837758 | 0.82235 | 0.187206 | 0 | 0.504951 | 0 | 0 | 0.119685 | 0.034555 | 0 | 0 | 0 | 0 | 0.158416 | 1 | 0.133663 | false | 0.004951 | 0.029703 | 0 | 0.173267 | 0.004951 | 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 |
53ef17d6b18d5e764451c3f73e1c858032c16715 | 216 | py | Python | brabeion/urls.py | radicalgraphics/brabeion | 7d69a061e3d37adbf805693624a8c8bbd43d4388 | [
"BSD-3-Clause"
] | 1 | 2016-02-07T16:17:14.000Z | 2016-02-07T16:17:14.000Z | brabeion/urls.py | ivirabyan/brabeion | cf5bf05edcae4dab1cf6d8212a27cf5f2f76a56b | [
"BSD-3-Clause"
] | null | null | null | brabeion/urls.py | ivirabyan/brabeion | cf5bf05edcae4dab1cf6d8212a27cf5f2f76a56b | [
"BSD-3-Clause"
] | 1 | 2020-01-08T09:06:26.000Z | 2020-01-08T09:06:26.000Z | from django.conf.urls.defaults import *
urlpatterns = patterns("",
url(r"^$", "brabeion.views.badge_list", name="badge_list"),
url(r"^(\w+)/(\d+)/$", "brabeion.views.badge_detail", name="badge_detail"),
)
| 24 | 79 | 0.643519 | 28 | 216 | 4.821429 | 0.642857 | 0.059259 | 0.266667 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0.115741 | 216 | 8 | 80 | 27 | 0.706806 | 0 | 0 | 0 | 0 | 0 | 0.416667 | 0.240741 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | false | 0 | 0.2 | 0 | 0.2 | 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 |
53f6d9ace418d3591dc47290b836cd70575ca246 | 245 | py | Python | gammapy/morphology/__init__.py | joleroi/gammapy | c4e0c4bd74c79d30e0837559d18b7a1a269f70d9 | [
"BSD-3-Clause"
] | 3 | 2019-01-28T12:21:14.000Z | 2019-02-10T19:58:07.000Z | gammapy/morphology/__init__.py | joleroi/gammapy | c4e0c4bd74c79d30e0837559d18b7a1a269f70d9 | [
"BSD-3-Clause"
] | null | null | null | gammapy/morphology/__init__.py | joleroi/gammapy | c4e0c4bd74c79d30e0837559d18b7a1a269f70d9 | [
"BSD-3-Clause"
] | null | null | null | # Licensed under a 3-clause BSD style license - see LICENSE.rst
"""Morphology and PSF methods.
Some parts of this package use Sherpa.
"""
from .gauss import *
from .model import *
from .models import *
from .theta import *
from .utils import *
| 22.272727 | 63 | 0.730612 | 37 | 245 | 4.837838 | 0.756757 | 0.223464 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0.004975 | 0.179592 | 245 | 10 | 64 | 24.5 | 0.885572 | 0.530612 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | true | 0 | 1 | 0 | 1 | 0 | 0 | 0 | 0 | null | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 1 | 0 | 0 | 0 | 0 | 3 |
54d2ae5fd0e73c75ba8cc5722c306d4e393e69dc | 253 | py | Python | src/lol_scrapers/utils/dataclasses/__init__.py | Melzak252/lol_scrapers | c083b766a970ad61bda68102a66d3a6303dda93d | [
"MIT"
] | null | null | null | src/lol_scrapers/utils/dataclasses/__init__.py | Melzak252/lol_scrapers | c083b766a970ad61bda68102a66d3a6303dda93d | [
"MIT"
] | null | null | null | src/lol_scrapers/utils/dataclasses/__init__.py | Melzak252/lol_scrapers | c083b766a970ad61bda68102a66d3a6303dda93d | [
"MIT"
] | null | null | null | from dataclasses import dataclass
@dataclass
class Stats:
win_rate: str
pick_rate: str
times_picked: str
@dataclass
class TftStats:
win_rate: str
top4: str
avg_placement: str
@dataclass
class RipChamp:
rip: bool = True
| 12.047619 | 33 | 0.695652 | 33 | 253 | 5.181818 | 0.606061 | 0.245614 | 0.116959 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0.005263 | 0.249012 | 253 | 20 | 34 | 12.65 | 0.894737 | 0 | 0 | 0.357143 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | true | 0 | 0.071429 | 0 | 0.785714 | 0 | 0 | 0 | 0 | null | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 0 | 1 | 0 | 0 | 3 |
54db7ee37fce019810dc3533863ebf080d75fe57 | 139 | py | Python | run.py | BidulaxStudio/bidulaxstudio-links | 1ef8e19c6ccce1b69e3704ea3eebf0577c958027 | [
"MIT"
] | null | null | null | run.py | BidulaxStudio/bidulaxstudio-links | 1ef8e19c6ccce1b69e3704ea3eebf0577c958027 | [
"MIT"
] | null | null | null | run.py | BidulaxStudio/bidulaxstudio-links | 1ef8e19c6ccce1b69e3704ea3eebf0577c958027 | [
"MIT"
] | null | null | null | from uvicorn import run
from app import app
HOST = "localhost"
PORT = 8000
if __name__ == "__main__":
run(app, host=HOST, port=PORT)
| 15.444444 | 34 | 0.697842 | 21 | 139 | 4.238095 | 0.571429 | 0.157303 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0.035714 | 0.194245 | 139 | 8 | 35 | 17.375 | 0.758929 | 0 | 0 | 0 | 0 | 0 | 0.122302 | 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 |
54ee15596aad98981a86792bc6b52f54679cad95 | 301 | py | Python | components/gear.py | 3299/2017 | 72f4db48688ce8f4a9df83ee64400e948a649e6e | [
"MIT"
] | 1 | 2017-04-10T00:46:27.000Z | 2017-04-10T00:46:27.000Z | components/gear.py | 3299/2017 | 72f4db48688ce8f4a9df83ee64400e948a649e6e | [
"MIT"
] | null | null | null | components/gear.py | 3299/2017 | 72f4db48688ce8f4a9df83ee64400e948a649e6e | [
"MIT"
] | null | null | null | """
Pops the gear onto the peg. Uses solenoids.
"""
class GearSol(object):
def __init__(self, sol):
self.sol = sol
def run(self, trigger):
if (trigger == True):
self.sol.set(self.sol.Value.kForward)
else:
self.sol.set(self.sol.Value.kReverse)
| 21.5 | 49 | 0.578073 | 40 | 301 | 4.25 | 0.575 | 0.247059 | 0.117647 | 0.164706 | 0.258824 | 0.258824 | 0 | 0 | 0 | 0 | 0 | 0 | 0.285714 | 301 | 13 | 50 | 23.153846 | 0.790698 | 0.142857 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0.25 | false | 0 | 0 | 0 | 0.375 | 0 | 0 | 0 | 0 | null | 1 | 0 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 3 |
54f584b38d6ba60d60d811304d68661a61a163a1 | 25 | py | Python | preprocess_web/code/ravens_metadata/settings/deploy_settings.py | TwoRavens/raven-metadata-service | 9461522219f5ef0f4877f24c8f5923e462bd9557 | [
"Apache-2.0"
] | null | null | null | preprocess_web/code/ravens_metadata/settings/deploy_settings.py | TwoRavens/raven-metadata-service | 9461522219f5ef0f4877f24c8f5923e462bd9557 | [
"Apache-2.0"
] | 103 | 2018-03-13T20:43:59.000Z | 2021-02-06T19:27:16.000Z | preprocess_web/code/ravens_metadata/settings/deploy_settings.py | TwoRavens/raven-metadata-service | 9461522219f5ef0f4877f24c8f5923e462bd9557 | [
"Apache-2.0"
] | 1 | 2019-09-11T22:36:14.000Z | 2019-09-11T22:36:14.000Z | ALLOW_FAB_DELETE = False
| 12.5 | 24 | 0.84 | 4 | 25 | 4.75 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0.12 | 25 | 1 | 25 | 25 | 0.863636 | 0 | 0 | 0 | 0 | 0 | 0 | 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 |
0710aebdc00c5cbce99dec0528cfc97c97579ca2 | 289 | py | Python | starlette/_utils.py | synodriver/starlette | 9ef1b91c9c043197da6c3f38aa153fd874b95527 | [
"BSD-3-Clause"
] | null | null | null | starlette/_utils.py | synodriver/starlette | 9ef1b91c9c043197da6c3f38aa153fd874b95527 | [
"BSD-3-Clause"
] | 9 | 2022-02-01T11:04:41.000Z | 2022-03-10T03:37:39.000Z | starlette/_utils.py | sthagen/encode-starlette | ba31df75daac7cc3b5fcfea89939372768a166cb | [
"BSD-3-Clause"
] | null | null | null | import asyncio
import functools
import typing
def is_async_callable(obj: typing.Any) -> bool:
while isinstance(obj, functools.partial):
obj = obj.func
return asyncio.iscoroutinefunction(obj) or (
callable(obj) and asyncio.iscoroutinefunction(obj.__call__)
)
| 22.230769 | 67 | 0.719723 | 34 | 289 | 5.941176 | 0.588235 | 0.108911 | 0.287129 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0.193772 | 289 | 12 | 68 | 24.083333 | 0.866953 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0.111111 | false | 0 | 0.333333 | 0 | 0.555556 | 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 |
072c0f2b2ab72d507cad9a5be50911eba04fac48 | 103 | py | Python | python/testData/quickFixes/PyRemoveUnusedLocalQuickFixTest/twoWithItemsSecondUnused.py | alexey-anufriev/intellij-community | ffcd46f14e630acdefcc76e2bfc7c43d2449013a | [
"Apache-2.0"
] | 2 | 2019-04-28T07:48:50.000Z | 2020-12-11T14:18:08.000Z | python/testData/quickFixes/PyRemoveUnusedLocalQuickFixTest/twoWithItemsSecondUnused.py | alexey-anufriev/intellij-community | ffcd46f14e630acdefcc76e2bfc7c43d2449013a | [
"Apache-2.0"
] | 1 | 2020-07-30T19:04:47.000Z | 2020-07-30T19:04:47.000Z | python/testData/quickFixes/PyRemoveUnusedLocalQuickFixTest/twoWithItemsSecondUnused.py | bradleesand/intellij-community | 750ff9c10333c9c1278c00dbe8d88c877b1b9749 | [
"Apache-2.0"
] | 1 | 2020-10-15T05:56:42.000Z | 2020-10-15T05:56:42.000Z | def func():
with open('file1.txt') as used, open('file2.txt') as <caret>unused:
print(used) | 34.333333 | 71 | 0.61165 | 16 | 103 | 3.9375 | 0.75 | 0.15873 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0.02439 | 0.203884 | 103 | 3 | 72 | 34.333333 | 0.743902 | 0 | 0 | 0 | 0 | 0 | 0.173077 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | null | null | 0 | 0 | null | null | 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 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 3 |
072f9c7ecf904fe092155a7aa86baa70fd0f9d62 | 201 | py | Python | setup.py | constant-c/gym-kafka | 32cb58a4a37acc9444ad8700d1c6ff124e8a98a8 | [
"MIT"
] | null | null | null | setup.py | constant-c/gym-kafka | 32cb58a4a37acc9444ad8700d1c6ff124e8a98a8 | [
"MIT"
] | null | null | null | setup.py | constant-c/gym-kafka | 32cb58a4a37acc9444ad8700d1c6ff124e8a98a8 | [
"MIT"
] | 1 | 2020-03-03T13:10:46.000Z | 2020-03-03T13:10:46.000Z | from setuptools import setup
setup(name='gym_kafka',
version='0.0.1',
install_requires=['gym', 'numpy', 'kafka-python', 'jsonschema'] # And any other dependencies gym kafka needs
)
| 28.714286 | 115 | 0.666667 | 26 | 201 | 5.076923 | 0.769231 | 0.121212 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0.018519 | 0.19403 | 201 | 6 | 116 | 33.5 | 0.796296 | 0.208955 | 0 | 0 | 0 | 0 | 0.280255 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | true | 0 | 0.2 | 0 | 0.2 | 0 | 1 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 3 |
0730d6bb91a76966a6fe8e1dbae39de1ca2c7ee5 | 1,619 | py | Python | src/the_tale/the_tale/game/heroes/abilities/prototypes.py | Alacrate/the-tale | 43b211f3a99e93964e95abc20a8ed649a205ffcf | [
"BSD-3-Clause"
] | 85 | 2017-11-21T12:22:02.000Z | 2022-03-27T23:07:17.000Z | src/the_tale/the_tale/game/heroes/abilities/prototypes.py | Alacrate/the-tale | 43b211f3a99e93964e95abc20a8ed649a205ffcf | [
"BSD-3-Clause"
] | 545 | 2017-11-04T14:15:04.000Z | 2022-03-27T14:19:27.000Z | src/the_tale/the_tale/game/heroes/abilities/prototypes.py | Alacrate/the-tale | 43b211f3a99e93964e95abc20a8ed649a205ffcf | [
"BSD-3-Clause"
] | 45 | 2017-11-11T12:36:30.000Z | 2022-02-25T06:10:44.000Z |
import smart_imports
smart_imports.all()
class AbilityPrototype(object):
TYPE = None
ACTIVATION_TYPE = None
LOGIC_TYPE = None
PRIORITY = []
AVAILABILITY = relations.ABILITY_AVAILABILITY.FOR_ALL
HAS_DAMAGE = False
NAME = ''
normalized_name = ''
DESCRIPTIN = ''
MAX_LEVEL = 5
__slots__ = ('level', )
def __init__(self, level=1):
self.level = level
def serialize(self):
return {'level': self.level}
@classmethod
def deserialize(cls, data):
return cls(level=data['level'])
@property
def type(self): return self.TYPE
@property
def availability(self): return self.AVAILABILITY
@property
def activation_type(self): return self.ACTIVATION_TYPE
@property
def has_max_level(self): return self.level == self.MAX_LEVEL
@property
def priority(self): return self.PRIORITY[self.level - 1]
@classmethod
def get_id(cls): return cls.__name__.lower()
def modify_attribute(self, name, value): return value # pylint: disable=W0613
def update_context(self, actor, enemy): pass
def check_attribute(self, name): return False # pylint: disable=W0613
def can_be_used(self, actor): return True # pylint: disable=W0613
def use(self, *argv):
raise NotImplementedError('you should declare use method in child classes')
def on_miss(self, *argv):
raise NotImplementedError('you should declare on_miss method in child classes')
def __eq__(self, other):
return (self.__class__ == other.__class__ and
self.level == other.level)
| 23.808824 | 87 | 0.666461 | 198 | 1,619 | 5.217172 | 0.363636 | 0.052275 | 0.067764 | 0.060987 | 0.137464 | 0.092933 | 0.092933 | 0 | 0 | 0 | 0 | 0.012116 | 0.23533 | 1,619 | 67 | 88 | 24.164179 | 0.822294 | 0.040148 | 0 | 0.159091 | 0 | 0 | 0.071659 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0.363636 | false | 0.022727 | 0.045455 | 0.272727 | 0.75 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 0 | 1 | 1 | 0 | 0 | 3 |
0731cf69cbb9d4ad58e00e19e868394167edeb07 | 1,942 | py | Python | Chapter18/hw/libhw/hw_sensors/lis331dlh.py | haohaoxiao/Deep-Reinforcement-Learning-Hands-On-Second-Edition | 1cbdff216fdc5cec02cc0da8664b788941f025c1 | [
"MIT"
] | 621 | 2019-07-27T19:24:56.000Z | 2022-03-31T14:19:52.000Z | Chapter18/hw/libhw/hw_sensors/lis331dlh.py | haohaoxiao/Deep-Reinforcement-Learning-Hands-On-Second-Edition | 1cbdff216fdc5cec02cc0da8664b788941f025c1 | [
"MIT"
] | 40 | 2019-09-01T09:45:22.000Z | 2022-03-24T13:13:00.000Z | Chapter18/hw/libhw/hw_sensors/lis331dlh.py | haohaoxiao/Deep-Reinforcement-Learning-Hands-On-Second-Edition | 1cbdff216fdc5cec02cc0da8664b788941f025c1 | [
"MIT"
] | 346 | 2019-07-26T15:16:56.000Z | 2022-03-30T15:33:20.000Z | """
Accelerometer sensor, datasheet: https://www.st.com/resource/en/datasheet/cd00213470.pdf
"""
from . import st_family
import math as m
class Lis331DLH(st_family.STSensor):
WHOAMI_VAL = 0x32
RANGE_2G_DIVISOR = 16380
def __init__(self, i2c, addr=24):
super(Lis331DLH, self).__init__(i2c, self.WHOAMI_VAL, addr)
self._init()
def __repr__(self):
return "Lis331DLH(addr=%r)" % self.addr
def __str__(self):
return "Lis331DLH"
def _init(self):
# reg4: set range 2G, enable BDU (to avoid reading low and high from diff samples), disable self-test
self.i2c.writeto_mem(self.addr, self.CTRL4_REG, bytes([0b10000000]))
# reg1: normal power mode, data rate=400Hz, all three axises enabled
self.i2c.writeto_mem(self.addr, self.CTRL1_REG, bytes([0b00110111]))
def __len__(self):
return 6
def refresh(self):
self.i2c.readfrom_mem_into(self.addr, self.AXIS_X_REG, self._byte[0])
self.i2c.readfrom_mem_into(self.addr, self.AXIS_X_REG+1, self._byte[1])
self.i2c.readfrom_mem_into(self.addr, self.AXIS_Y_REG, self._byte[2])
self.i2c.readfrom_mem_into(self.addr, self.AXIS_Y_REG+1, self._byte[3])
self.i2c.readfrom_mem_into(self.addr, self.AXIS_Z_REG, self._byte[4])
self.i2c.readfrom_mem_into(self.addr, self.AXIS_Z_REG+1, self._byte[5])
@classmethod
def decode(cls, b):
return [
st_family.decode_s16(b[ofs:ofs + 2]) / cls.RANGE_2G_DIVISOR
for ofs in range(0, 6, 2)
]
@classmethod
def preprocess(cls, vals):
# Subtract g vector (having magnitude of 1). Not the best way of doing such normalization
# as error could be significant.
l = m.sqrt(vals[0] * vals[0] + vals[1] * vals[1] + vals[2] * vals[2])
if abs(l) > 1e-5:
c = (l - 1) / l
return [c * v for v in vals]
return vals
| 35.309091 | 109 | 0.639547 | 295 | 1,942 | 3.986441 | 0.410169 | 0.053571 | 0.081633 | 0.091837 | 0.263605 | 0.263605 | 0.263605 | 0.214286 | 0.214286 | 0.214286 | 0 | 0.063514 | 0.237899 | 1,942 | 54 | 110 | 35.962963 | 0.731081 | 0.1931 | 0 | 0.054054 | 0 | 0 | 0.017352 | 0 | 0 | 0 | 0.002571 | 0 | 0 | 1 | 0.216216 | false | 0 | 0.054054 | 0.108108 | 0.513514 | 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 |
073e22d0d8335dc1953490ab7bc589cf0631aff3 | 235 | py | Python | fluent_comments/urls.py | ephes/django-fluent-comments | a375a6704da76f1abc15261c51c9b02929b73934 | [
"Apache-2.0"
] | 88 | 2016-07-06T13:26:15.000Z | 2022-02-24T07:41:25.000Z | fluent_comments/urls.py | ephes/django-fluent-comments | a375a6704da76f1abc15261c51c9b02929b73934 | [
"Apache-2.0"
] | 64 | 2016-06-30T15:29:59.000Z | 2022-02-22T22:40:39.000Z | fluent_comments/urls.py | ephes/django-fluent-comments | a375a6704da76f1abc15261c51c9b02929b73934 | [
"Apache-2.0"
] | 44 | 2016-06-30T20:28:24.000Z | 2022-03-14T15:41:16.000Z | from django.urls import path, include
import django_comments.urls
from . import views
urlpatterns = [
path("post/ajax/", views.post_comment_ajax, name="comments-post-comment-ajax"),
path("", include(django_comments.urls)),
]
| 23.5 | 83 | 0.73617 | 31 | 235 | 5.451613 | 0.419355 | 0.130178 | 0.213018 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0.12766 | 235 | 9 | 84 | 26.111111 | 0.82439 | 0 | 0 | 0 | 0 | 0 | 0.153191 | 0.110638 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | false | 0 | 0.428571 | 0 | 0.428571 | 0 | 0 | 0 | 0 | null | 0 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 0 | 0 | 3 |
07553a29726c4eb214d81e2414c5780c04453520 | 217 | py | Python | architect/pmscloud/DisplayLib.py | ibmcuijunluke/software-dockerhome | 21c9b3d29ede2b94a62f86931822d10854b368b2 | [
"MIT"
] | 5 | 2018-04-25T11:13:01.000Z | 2019-11-11T06:36:01.000Z | architect/pmscloud/DisplayLib.py | ibmcuijunluke/software-devopsengineer | 79c9d9e9b4e376f42b5ae0730d81c82cea33fd7b | [
"MIT"
] | null | null | null | architect/pmscloud/DisplayLib.py | ibmcuijunluke/software-devopsengineer | 79c9d9e9b4e376f42b5ae0730d81c82cea33fd7b | [
"MIT"
] | 3 | 2018-04-25T11:13:02.000Z | 2018-07-30T00:53:07.000Z | # -*- coding: utf-8 -*-
from pyvirtualdisplay import Display
display = Display(visible=0, size=(1024, 768))
##启动虚拟显示
def start():
display.start()
##关闭虚拟显示
def stop():
display.stop()
| 16.692308 | 48 | 0.580645 | 24 | 217 | 5.25 | 0.708333 | 0.222222 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0.05625 | 0.262673 | 217 | 12 | 49 | 18.083333 | 0.73125 | 0.170507 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0.333333 | false | 0 | 0.166667 | 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 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 3 |
076a0ec8bda97e99d8e503da54dd2902ff0c58f9 | 246 | py | Python | src/m1_hangman.py | hegarnn/21-FunctionalDecomposition | eaade6623cd4d4823d56042a1080600b3a37407c | [
"MIT"
] | null | null | null | src/m1_hangman.py | hegarnn/21-FunctionalDecomposition | eaade6623cd4d4823d56042a1080600b3a37407c | [
"MIT"
] | null | null | null | src/m1_hangman.py | hegarnn/21-FunctionalDecomposition | eaade6623cd4d4823d56042a1080600b3a37407c | [
"MIT"
] | null | null | null | """
Hangman.
Authors: Nasser Hegar and YOUR_PARTNERS_NAME_HERE.
""" # TODO: 1. PUT YOUR NAME IN THE ABOVE LINE.
# TODO: 2. Implement Hangman using your Iterative Enhancement Plan.
####### Do NOT attempt this assignment before class! #######
| 22.363636 | 67 | 0.699187 | 34 | 246 | 4.970588 | 0.852941 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0.009804 | 0.170732 | 246 | 10 | 68 | 24.6 | 0.818627 | 0.869919 | 0 | null | 0 | null | 0 | 0 | null | 0 | 0 | 0.1 | 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 |
4adebe234c7b385500e966bad29d444ee8360909 | 153 | py | Python | kivyauth/providers.py | khanfarhan10/social-auth-kivy | fecf542e12601af143d8b4dcbc5ebd6a29ce59bf | [
"MIT"
] | null | null | null | kivyauth/providers.py | khanfarhan10/social-auth-kivy | fecf542e12601af143d8b4dcbc5ebd6a29ce59bf | [
"MIT"
] | null | null | null | kivyauth/providers.py | khanfarhan10/social-auth-kivy | fecf542e12601af143d8b4dcbc5ebd6a29ce59bf | [
"MIT"
] | null | null | null | class LoginProviders:
google = "google"
facebook = "facebook"
github = "github"
twitter = "twitter"
login_providers = LoginProviders()
| 17 | 34 | 0.666667 | 13 | 153 | 7.769231 | 0.615385 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0.228758 | 153 | 8 | 35 | 19.125 | 0.855932 | 0 | 0 | 0 | 0 | 0 | 0.176471 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | false | 0 | 0 | 0 | 0.833333 | 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 |
4ae0d7dfef145958a556452fcb0cd5294a7b5f5d | 1,294 | py | Python | home/Calamity/init/iniStartRightHand.py | rv8flyboy/pyrobotlab | 4e04fb751614a5cb6044ea15dcfcf885db8be65a | [
"Apache-2.0"
] | 63 | 2015-02-03T18:49:43.000Z | 2022-03-29T03:52:24.000Z | home/Calamity/init/iniStartRightHand.py | hirwaHenryChristian/pyrobotlab | 2debb381fc2db4be1e7ea6e5252a50ae0de6f4a9 | [
"Apache-2.0"
] | 16 | 2016-01-26T19:13:29.000Z | 2018-11-25T21:20:51.000Z | home/Calamity/init/iniStartRightHand.py | hirwaHenryChristian/pyrobotlab | 2debb381fc2db4be1e7ea6e5252a50ae0de6f4a9 | [
"Apache-2.0"
] | 151 | 2015-01-03T18:55:54.000Z | 2022-03-04T07:04:23.000Z | def startRightHand():
##############
i01.startRightHand(rightPort)
i01.rightHand.thumb.setMinMax(0,115)
i01.rightHand.index.setMinMax(35,130)
i01.rightHand.majeure.setMinMax(35,130)
i01.rightHand.ringFinger.setMinMax(35,130)
i01.rightHand.pinky.setMinMax(35,130)
i01.rightHand.wrist.map(90,90,90,90)
#i01.rightHand.thumb.map(0,180,0,115)
#i01.rightHand.index.map(0,180,35,130)
#i01.rightHand.majeure.map(0,180,35,130)
#i01.rightHand.ringFinger.map(0,180,35,130)
#i01.rightHand.pinky.map(0,180,35,130)
i01.rightHand.thumb.setVelocity(250)
i01.rightHand.index.setVelocity(250)
i01.rightHand.majeure.setVelocity(250)
i01.rightHand.ringFinger.setVelocity(250)
i01.rightHand.pinky.setVelocity(250)
i01.rightHand.wrist.setVelocity(250)
i01.rightHand.thumb.setMaxVelocity(250)
i01.rightHand.index.setMaxVelocity(250)
i01.rightHand.majeure.setMaxVelocity(250)
i01.rightHand.ringFinger.setMaxVelocity(250)
i01.rightHand.pinky.setMaxVelocity(250)
i01.rightHand.wrist.setMaxVelocity(250)
i01.rightHand.thumb.setRest(10)
i01.rightHand.index.setRest(40)
i01.rightHand.majeure.setRest(40)
i01.rightHand.ringFinger.setRest(40)
i01.rightHand.pinky.setRest(40)
i01.rightHand.wrist.setRest(90)
i01.rightHand.rest()
| 38.058824 | 47 | 0.746522 | 176 | 1,294 | 5.488636 | 0.147727 | 0.372671 | 0.186335 | 0.140787 | 0.296066 | 0.099379 | 0.099379 | 0 | 0 | 0 | 0 | 0.159931 | 0.101236 | 1,294 | 33 | 48 | 39.212121 | 0.670679 | 0.147604 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0.037037 | true | 0 | 0 | 0 | 0.037037 | 0 | 0 | 0 | 0 | null | 1 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 3 |
4ae67000ed58f9000bbd547776fa713a6b1a1a88 | 7,052 | py | Python | opnsense_cli/commands/plugin/haproxy/group.py | jan-win1993/opn-cli | 83c4792571dacbe6483722a95276954c7a2d0b3c | [
"BSD-2-Clause"
] | 13 | 2021-05-17T10:42:25.000Z | 2022-02-21T02:10:41.000Z | opnsense_cli/commands/plugin/haproxy/group.py | jan-win1993/opn-cli | 83c4792571dacbe6483722a95276954c7a2d0b3c | [
"BSD-2-Clause"
] | 14 | 2021-05-17T13:53:27.000Z | 2021-12-16T12:45:44.000Z | opnsense_cli/commands/plugin/haproxy/group.py | jan-win1993/opn-cli | 83c4792571dacbe6483722a95276954c7a2d0b3c | [
"BSD-2-Clause"
] | 2 | 2021-04-28T08:41:07.000Z | 2022-03-28T10:20:51.000Z | import click
from opnsense_cli.formatters.cli_output import CliOutputFormatter
from opnsense_cli.callbacks.click import \
formatter_from_formatter_name, bool_as_string, available_formats, resolve_linked_names_to_uuids
from opnsense_cli.commands.plugin.haproxy import haproxy
from opnsense_cli.api.client import ApiClient
from opnsense_cli.api.plugin.haproxy import Settings, Service
from opnsense_cli.facades.commands.plugin.haproxy.group import HaproxyGroupFacade
pass_api_client = click.make_pass_decorator(ApiClient)
pass_haproxy_group_svc = click.make_pass_decorator(HaproxyGroupFacade)
@haproxy.group()
@pass_api_client
@click.pass_context
def group(ctx, api_client: ApiClient, **kwargs):
"""
HTTP basic authentication groups.
"""
settings_api = Settings(api_client)
service_api = Service(api_client)
ctx.obj = HaproxyGroupFacade(settings_api, service_api)
@group.command()
@click.option(
'--output', '-o',
help='Specifies the Output format.',
default="table",
type=click.Choice(available_formats()),
callback=formatter_from_formatter_name,
show_default=True,
)
@click.option(
'--cols', '-c',
help='Which columns should be printed? Pass empty string (-c '') to show all columns',
default=(
"uuid,enabled,name,description,Users,add_userlist"
),
show_default=True,
)
@pass_haproxy_group_svc
def list(haproxy_group_svc: HaproxyGroupFacade, **kwargs):
"""
Show all group
"""
result = haproxy_group_svc.list_groups()
CliOutputFormatter(result, kwargs['output'], kwargs['cols'].split(",")).echo()
@group.command()
@click.argument('uuid')
@click.option(
'--output', '-o',
help='Specifies the Output format.',
default="table",
type=click.Choice(available_formats()),
callback=formatter_from_formatter_name,
show_default=True,
)
@click.option(
'--cols', '-c',
help='Which columns should be printed? Pass empty string (-c '') to show all columns',
default=(
"enabled,name,description,Users,add_userlist"
),
show_default=True,
)
@pass_haproxy_group_svc
def show(haproxy_group_svc: HaproxyGroupFacade, **kwargs):
"""
Show details for group
"""
result = haproxy_group_svc.show_group(kwargs['uuid'])
CliOutputFormatter(result, kwargs['output'], kwargs['cols'].split(",")).echo()
@group.command()
@click.argument('name')
@click.option(
'--enabled/--no-enabled',
help=('Enable this group.'),
show_default=True,
is_flag=True,
callback=bool_as_string,
default=True,
required=True,
)
@click.option(
'--description',
help=('Description for this group.'),
show_default=True,
default=None,
required=False,
)
@click.option(
'--members',
help=('The comma seperated user uuids of the group.'),
callback=resolve_linked_names_to_uuids,
show_default=True,
default=None,
required=False,
)
@click.option(
'--add_userlist/--no-add_userlist',
help=(
'Usually HAproxy userlists are created automatically in a context sensitive way. "'
'"This option adds this group as userlist, so that it can be referenced in rules/conditions. "'
'"All special and non-alphanumeric characters will be removed from the userlist name.'
),
show_default=True,
is_flag=True,
callback=bool_as_string,
default=True,
required=False,
)
@click.option(
'--output', '-o',
help='Specifies the Output format.',
default="plain",
type=click.Choice(available_formats()),
callback=formatter_from_formatter_name,
show_default=True,
)
@click.option(
'--cols', '-c',
help='Which columns should be printed? Pass empty string (-c '') to show all columns',
default="result,validations",
show_default=True,
)
@pass_haproxy_group_svc
def create(haproxy_group_svc: HaproxyGroupFacade, **kwargs):
"""
Create a new group
"""
json_payload = {
'group': {
"enabled": kwargs['enabled'],
"name": kwargs['name'],
"description": kwargs['description'],
"members": kwargs['members'],
"add_userlist": kwargs['add_userlist'],
}
}
result = haproxy_group_svc.create_group(json_payload)
CliOutputFormatter(result, kwargs['output'], kwargs['cols'].split(",")).echo()
@group.command()
@click.argument('uuid')
@click.option(
'--enabled/--no-enabled',
help=('Enable this group.'),
show_default=True,
is_flag=True,
callback=bool_as_string,
default=None
)
@click.option(
'--name',
help=('Name to identify this group.'),
show_default=True,
default=None
)
@click.option(
'--description',
help=('Description for this group.'),
show_default=True,
default=None
)
@click.option(
'--members',
help=('The comma seperated user uuids of the group'),
callback=resolve_linked_names_to_uuids,
show_default=True,
default=None
)
@click.option(
'--add_userlist/--no-add_userlist',
help=(
'Usually HAproxy userlists are created automatically in a context sensitive way. "'
'"This option adds this group as userlist, so that it can be referenced in rules/conditions. "'
'"All special and non-alphanumeric characters will be removed from the userlist name.'
),
show_default=True,
is_flag=True,
callback=bool_as_string,
default=None
)
@click.option(
'--output', '-o',
help='Specifies the Output format.',
default="plain",
type=click.Choice(available_formats()),
callback=formatter_from_formatter_name,
show_default=True,
)
@click.option(
'--cols', '-c',
help='Which columns should be printed? Pass empty string (-c '') to show all columns',
default="result,validations",
show_default=True,
)
@pass_haproxy_group_svc
def update(haproxy_group_svc: HaproxyGroupFacade, **kwargs):
"""
Update a group.
"""
json_payload = {
'group': {}
}
options = ['enabled', 'name', 'description', 'members', 'add_userlist']
for option in options:
if kwargs[option.lower()] is not None:
json_payload['group'][option] = kwargs[option.lower()]
result = haproxy_group_svc.update_group(kwargs['uuid'], json_payload)
CliOutputFormatter(result, kwargs['output'], kwargs['cols'].split(",")).echo()
@group.command()
@click.argument('uuid')
@click.option(
'--output', '-o',
help='Specifies the Output format.',
default="plain",
type=click.Choice(available_formats()),
callback=formatter_from_formatter_name,
show_default=True,
)
@click.option(
'--cols', '-c',
help='Which columns should be printed? Pass empty string (-c '') to show all columns',
default="result,validations",
show_default=True,
)
@pass_haproxy_group_svc
def delete(haproxy_group_svc: HaproxyGroupFacade, **kwargs):
"""
Delete group
"""
result = haproxy_group_svc.delete_group(kwargs['uuid'])
CliOutputFormatter(result, kwargs['output'], kwargs['cols'].split(",")).echo()
| 28.095618 | 103 | 0.678106 | 843 | 7,052 | 5.495848 | 0.155397 | 0.04986 | 0.061515 | 0.028707 | 0.747896 | 0.70041 | 0.681848 | 0.681848 | 0.681848 | 0.668681 | 0 | 0 | 0.18321 | 7,052 | 250 | 104 | 28.208 | 0.80434 | 0.016875 | 0 | 0.679245 | 0 | 0.009434 | 0.274773 | 0.029085 | 0 | 0 | 0 | 0 | 0 | 1 | 0.028302 | false | 0.066038 | 0.033019 | 0 | 0.061321 | 0.023585 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 0 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 0 | 0 | 0 | 3 |
4af4c32fb5f4946a197f8c59dadff6dc123ca849 | 197 | py | Python | snimpy/__init__.py | maugier/snimpy | 6ee08c608c2794632a512f6b632fb27c10abe1e8 | [
"ISC"
] | 129 | 2015-01-14T10:22:32.000Z | 2022-03-11T20:07:30.000Z | snimpy/__init__.py | maugier/snimpy | 6ee08c608c2794632a512f6b632fb27c10abe1e8 | [
"ISC"
] | 81 | 2015-01-25T22:25:42.000Z | 2021-07-01T16:21:54.000Z | snimpy/__init__.py | maugier/snimpy | 6ee08c608c2794632a512f6b632fb27c10abe1e8 | [
"ISC"
] | 38 | 2015-01-30T22:09:02.000Z | 2020-12-16T17:40:38.000Z | """interactive SNMP tool"""
__author__ = 'Vincent Bernat'
__email__ = 'bernat@luffy.cx'
try:
from snimpy._version import __version__ # nopep8
except ImportError:
__version__ = '0.0~dev'
| 19.7 | 53 | 0.715736 | 23 | 197 | 5.391304 | 0.826087 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0.018293 | 0.167513 | 197 | 9 | 54 | 21.888889 | 0.737805 | 0.147208 | 0 | 0 | 0 | 0 | 0.222222 | 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 |
ab1475b3bdd62e36ded430b11eb95952038c9894 | 1,169 | py | Python | todo_widget.py | VANADAIN/drop-down-todo | 80d5e242856536de5d2cb16410d69d9c6e0299b4 | [
"MIT"
] | null | null | null | todo_widget.py | VANADAIN/drop-down-todo | 80d5e242856536de5d2cb16410d69d9c6e0299b4 | [
"MIT"
] | null | null | null | todo_widget.py | VANADAIN/drop-down-todo | 80d5e242856536de5d2cb16410d69d9c6e0299b4 | [
"MIT"
] | null | null | null | # from PyQt5.QtWidgets import QWidget, QPushButton, QLabel, QHBoxLayout
# from PyQt5.QtGui import QCursor, QFont
# from PyQt5.QtCore import Qt
# from todo import TodoApp
# class TodoWidget(QWidget, TodoApp):
# def __init__(self, text):
# super().__init__()
# done_button = QPushButton("✓")
# done_button.clicked.connect(self.done)
# done_button.setStyleSheet("color: white; height:30px; Font: 14px;")
# done_button.setFixedWidth(30)
# done_button.setCursor(QCursor(Qt.PointingHandCursor))
# delete_button = QPushButton("x")
# delete_button.setStyleSheet("color: white; height:30px; Font: 14px")
# delete_button.setFixedWidth(30)
# delete_button.setCursor(QCursor(Qt.PointingHandCursor))
# label = QLabel(text)
# label.setFont(QFont('Monospace', 12))
# label.setWordWrap(True);
# label.setStyleSheet(f'padding-left: 3px; color: white; max-width: 400;')
# hbox = QHBoxLayout()
# hbox.addWidget(label)
# hbox.addWidget(done_button)
# hbox.addWidget(delete_button)
# self.setLayout(hbox)
| 31.594595 | 82 | 0.640719 | 123 | 1,169 | 5.943089 | 0.455285 | 0.082079 | 0.065663 | 0.079343 | 0.243502 | 0.128591 | 0.128591 | 0.128591 | 0 | 0 | 0 | 0.023543 | 0.236955 | 1,169 | 36 | 83 | 32.472222 | 0.794843 | 0.933276 | 0 | null | 0 | null | 0 | 0 | null | 0 | 0 | 0.027778 | 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 |
ab212ca8a5cc523e57d9f1a4ac50d503cb2de84f | 364 | py | Python | python_modules/libraries/dagster-pandas/dagster_pandas/__init__.py | flowersw/dagster | 0de6baf2bd6a41bfacf0be532b954e23305fb6b4 | [
"Apache-2.0"
] | 3 | 2020-09-09T04:10:23.000Z | 2021-11-08T02:10:42.000Z | python_modules/libraries/dagster-pandas/dagster_pandas/__init__.py | flowersw/dagster | 0de6baf2bd6a41bfacf0be532b954e23305fb6b4 | [
"Apache-2.0"
] | 2 | 2021-05-11T13:36:27.000Z | 2021-09-03T01:53:11.000Z | python_modules/libraries/dagster-pandas/dagster_pandas/__init__.py | flowersw/dagster | 0de6baf2bd6a41bfacf0be532b954e23305fb6b4 | [
"Apache-2.0"
] | null | null | null | from .constraints import RowCountConstraint, StrictColumnsConstraint
from .data_frame import DataFrame, create_dagster_pandas_dataframe_type
from .validation import PandasColumn
from .version import __version__
__all__ = [
'DataFrame',
'create_dagster_pandas_dataframe_type',
'PandasColumn',
'RowCountConstraint',
'StrictColumnsConstraint',
]
| 28 | 71 | 0.802198 | 33 | 364 | 8.333333 | 0.484848 | 0.298182 | 0.16 | 0.203636 | 0.298182 | 0.298182 | 0 | 0 | 0 | 0 | 0 | 0 | 0.131868 | 364 | 12 | 72 | 30.333333 | 0.870253 | 0 | 0 | 0 | 0 | 0 | 0.269231 | 0.162088 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | false | 0 | 0.363636 | 0 | 0.363636 | 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 | 1 | 0 | 0 | 0 | 0 | 3 |
ab300d8161fc669d30a514efdde1c5726b9f12de | 195 | py | Python | typeidea/typeidea/custom_site.py | abnormalmakers/typeidea | 9348e85414ac06ed67fe7238d8060c29e3d59d12 | [
"MIT"
] | null | null | null | typeidea/typeidea/custom_site.py | abnormalmakers/typeidea | 9348e85414ac06ed67fe7238d8060c29e3d59d12 | [
"MIT"
] | 2 | 2020-06-05T20:36:07.000Z | 2021-06-10T21:24:42.000Z | typeidea/typeidea/custom_site.py | abnormalmakers/typeidea | 9348e85414ac06ed67fe7238d8060c29e3d59d12 | [
"MIT"
] | null | null | null | from django.contrib.admin import AdminSite
class CustomSite(AdminSite):
site_header='Typeidea'
site_title='Typeideal管理后台'
index_title = '首页'
custom_site=CustomSite(name='cus_admin') | 24.375 | 42 | 0.769231 | 24 | 195 | 6.041667 | 0.75 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0.128205 | 195 | 8 | 43 | 24.375 | 0.852941 | 0 | 0 | 0 | 0 | 0 | 0.163265 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | false | 0 | 0.166667 | 0 | 0.833333 | 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 |
ab4167865eb2b2c6e7ea0a1cd0d5ca14b919ecbb | 2,836 | py | Python | serializeme/exceptions.py | jroosenschoon/serialize-me | 654dd76abd86e21d43d8bb517a70efb318c8f493 | [
"MIT"
] | 2 | 2021-04-11T10:58:18.000Z | 2021-05-12T01:41:45.000Z | serializeme/exceptions.py | jroosenschoon/serialize-me | 654dd76abd86e21d43d8bb517a70efb318c8f493 | [
"MIT"
] | 1 | 2021-07-11T16:42:01.000Z | 2021-07-11T16:42:01.000Z | serializeme/exceptions.py | jroosenschoon/serialize-me | 654dd76abd86e21d43d8bb517a70efb318c8f493 | [
"MIT"
] | 1 | 2021-05-12T20:33:29.000Z | 2021-05-12T20:33:29.000Z | class InvalidIPv4Address(Exception):
"""
Exception raised for invalid IPv4 addresses.
Attributes:
ipv4: IPv4 address that triggered the error.
msg : Explanation of the error.
"""
def __init__(self, ipv4, msg="Invalid IPv4 Address"):
self.ipv4 = ipv4
self.msg = msg
def __str__(self):
return "{}: {}".format(self.msg, self.ipv4)
class ValueTooBig(Exception):
"""
Exception raised for trying to fit a value that cannot be fit in the specified
number of bytes or bits.
Attributes:
size : Specified size user entered.
value: Value user tried to fit in that size, but was too big.
unit : bit or byte, depending on how size was specified.
msg : Explanation of the error.
"""
def __init__(self, size, value, unit, msg="Cannot fit in"):
self.size = size
self.value = value
self.unit = unit
self.msg = msg
def __str__(self):
return "{} {} {} {}".format(self.value, self.msg, self.size, self.unit)
class InvalidValue(Exception):
"""
Exception raised for invalid values for Field.py.
Attributes:
value: value that triggered the error.
msg : Explanation of the error.
"""
def __init__(self, value, msg="Invalid type for value. Expecting int or bytes. Received"):
self.value = value
self.msg = msg
def __str__(self):
return "{}: {}".format(self.msg, self.value)
class InvalidSize(Exception):
"""
Exception raised for invalid sizes for Field.py.
Attributes:
size: size that triggered the error.
msg : Explanation of the error.
"""
def __init__(self, size, msg="Invalid type for size. Expecting str, int, or bytes. Received"):
self.size = size
self.msg = msg
def __str__(self):
return "{}: {}".format(self.msg, self.size)
class InvalidField(Exception):
"""
Exception raised for an invalid field for Field.py.
Attributes:
item: What was used to trigger error.
msg : Explanation of the error.
"""
def __init__(self, item, msg="Invalid Field. Recieved"):
self.item = item
self.msg = msg
def __str__(self):
return "{}: {}".format(self.msg, self.item)
class FieldNotFound(Exception):
"""
Exception raised when user tries to access nonexistent field.
Attributes:
name: name of field user tried to access, but does not exist.
msg : Explanation of the error.
"""
def __init__(self, name, msg="Field not found."):
self.name = name
self.msg = msg
def __str__(self):
return "{} -> {}".format(self.name, self.msg)
| 31.865169 | 99 | 0.589563 | 343 | 2,836 | 4.734694 | 0.227405 | 0.051724 | 0.08867 | 0.070197 | 0.416256 | 0.326355 | 0.326355 | 0.326355 | 0.304803 | 0.20936 | 0 | 0.004587 | 0.308181 | 2,836 | 88 | 100 | 32.227273 | 0.82314 | 0.374471 | 0 | 0.421053 | 0 | 0 | 0.153541 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0.315789 | false | 0 | 0 | 0.157895 | 0.631579 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 0 | 1 | 1 | 0 | 0 | 3 |
ab4c6a36b0e6730262d3ca3d70d063c23934337d | 1,997 | py | Python | ietf/secr/meetings/urls.py | MatheusProla/Codestand | f9f13f2b6e8f9a1500f93ab54da977bb7de0bf9e | [
"BSD-3-Clause-No-Nuclear-License-2014",
"BSD-3-Clause"
] | 2 | 2021-11-20T03:40:40.000Z | 2021-11-20T03:40:42.000Z | ietf/secr/meetings/urls.py | MatheusProla/Codestand | f9f13f2b6e8f9a1500f93ab54da977bb7de0bf9e | [
"BSD-3-Clause-No-Nuclear-License-2014",
"BSD-3-Clause"
] | null | null | null | ietf/secr/meetings/urls.py | MatheusProla/Codestand | f9f13f2b6e8f9a1500f93ab54da977bb7de0bf9e | [
"BSD-3-Clause-No-Nuclear-License-2014",
"BSD-3-Clause"
] | null | null | null |
from ietf.secr.meetings import views
from ietf.utils.urls import url
urlpatterns = [
url(r'^$', views.main),
url(r'^add/$', views.add),
url(r'^ajax/get-times/(?P<meeting_id>\d{1,6})/(?P<day>\d)/$', views.ajax_get_times),
url(r'^blue_sheet/$', views.blue_sheet_redirect),
url(r'^(?P<meeting_id>\d{1,6})/$', views.view),
url(r'^(?P<meeting_id>\d{1,6})/blue_sheet/$', views.blue_sheet),
url(r'^(?P<meeting_id>\d{1,6})/blue_sheet/generate/$', views.blue_sheet_generate),
url(r'^(?P<meeting_id>\d{1,6})/edit/$', views.edit_meeting),
url(r'^(?P<meeting_id>\d{1,6})/notifications/$', views.notifications),
url(r'^(?P<meeting_id>\d{1,6})/(?P<schedule_name>[A-Za-z0-9_\-]+)/$', views.select),
url(r'^(?P<meeting_id>\d{1,6})/(?P<schedule_name>[A-Za-z0-9_\-]+)/non_session/$', views.non_session),
url(r'^(?P<meeting_id>\d{1,6})/(?P<schedule_name>[A-Za-z0-9_\-]+)/non_session/edit/(?P<slot_id>\d{1,6})/$', views.non_session_edit),
url(r'^(?P<meeting_id>\d{1,6})/(?P<schedule_name>[A-Za-z0-9_\-]+)/non_session/delete/(?P<slot_id>\d{1,6})/$', views.non_session_delete),
url(r'^(?P<meeting_id>\d{1,6})/(?P<schedule_name>[A-Za-z0-9_\-]+)/rooms/$', views.rooms),
url(r'^(?P<meeting_id>\d{1,6})/(?P<schedule_name>[A-Za-z0-9_\-]+)/select/$', views.select_group),
url(r'^(?P<meeting_id>\d{1,6})/(?P<schedule_name>[A-Za-z0-9_\-]+)/times/$', views.times),
url(r'^(?P<meeting_id>\d{1,6})/(?P<schedule_name>[A-Za-z0-9_\-]+)/times/delete/(?P<time>[0-9\:]+)/$', views.times_delete),
url(r'^(?P<meeting_id>\d{1,6})/(?P<schedule_name>[A-Za-z0-9_\-]+)/times/edit/(?P<time>[0-9\:]+)/$', views.times_edit),
url(r'^(?P<meeting_id>\d{1,6})/(?P<schedule_name>[A-Za-z0-9_\-]+)/unschedule/(?P<session_id>\d{1,6})/$', views.unschedule),
url(r'^(?P<meeting_id>\d{1,6})/(?P<schedule_name>[A-Za-z0-9_\-]+)/(?P<acronym>[-a-z0-9]+)/schedule/$', views.schedule),
url(r'^(?P<meeting_id>\d{1,6})/(?P<acronym>[-a-z0-9]+)/remove/$', views.remove_session),
]
| 71.321429 | 140 | 0.609414 | 369 | 1,997 | 3.119241 | 0.130081 | 0.07298 | 0.07298 | 0.091225 | 0.655951 | 0.590791 | 0.561251 | 0.549088 | 0.504778 | 0.445699 | 0 | 0.038772 | 0.070105 | 1,997 | 27 | 141 | 73.962963 | 0.581045 | 0 | 0 | 0 | 0 | 0.52 | 0.611723 | 0.601202 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | false | 0 | 0.08 | 0 | 0.08 | 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 | 1 | 1 | 1 | null | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 3 |
db3f7fab2a53d9b3e854033c3f360eb5e8b3020e | 8,567 | py | Python | lib/django/tests/regressiontests/defaultfilters/tests.py | vin/gerbilcount | fdffe648c3e9ad2667a6edfe0e19d4446c522395 | [
"Apache-2.0"
] | 2 | 2016-05-08T08:57:01.000Z | 2020-02-08T07:39:48.000Z | lib/django/tests/regressiontests/defaultfilters/tests.py | Arachnid/google_appengine | 2e950619f5027f414131fafc3cc253af4875a0fe | [
"Apache-2.0"
] | null | null | null | lib/django/tests/regressiontests/defaultfilters/tests.py | Arachnid/google_appengine | 2e950619f5027f414131fafc3cc253af4875a0fe | [
"Apache-2.0"
] | null | null | null | r"""
>>> floatformat(7.7)
'7.7'
>>> floatformat(7.0)
'7'
>>> floatformat(0.7)
'0.7'
>>> floatformat(0.07)
'0.1'
>>> floatformat(0.007)
'0.0'
>>> floatformat(0.0)
'0'
>>> floatformat(7.7,3)
'7.700'
>>> floatformat(6.000000,3)
'6.000'
>>> floatformat(13.1031,-3)
'13.103'
>>> floatformat(11.1197, -2)
'11.12'
>>> floatformat(11.0000, -2)
'11'
>>> floatformat(11.000001, -2)
'11.00'
>>> floatformat(8.2798, 3)
'8.280'
>>> floatformat('foo')
''
>>> floatformat(13.1031, 'bar')
'13.1031'
>>> floatformat('foo', 'bar')
''
>>> addslashes('"double quotes" and \'single quotes\'')
'\\"double quotes\\" and \\\'single quotes\\\''
>>> addslashes(r'\ : backslashes, too')
'\\\\ : backslashes, too'
>>> capfirst('hello world')
'Hello world'
>>> fix_ampersands('Jack & Jill & Jeroboam')
'Jack & Jill & Jeroboam'
>>> linenumbers('line 1\nline 2')
'1. line 1\n2. line 2'
>>> linenumbers('\n'.join(['x'] * 10))
'01. x\n02. x\n03. x\n04. x\n05. x\n06. x\n07. x\n08. x\n09. x\n10. x'
>>> lower('TEST')
'test'
>>> lower(u'\xcb') # uppercase E umlaut
u'\xeb'
>>> make_list('abc')
['a', 'b', 'c']
>>> make_list(1234)
['1', '2', '3', '4']
>>> slugify(' Jack & Jill like numbers 1,2,3 and 4 and silly characters ?%.$!/')
'jack-jill-like-numbers-123-and-4-and-silly-characters'
>>> stringformat(1, '03d')
'001'
>>> stringformat(1, 'z')
''
>>> title('a nice title, isn\'t it?')
"A Nice Title, Isn't It?"
>>> truncatewords('A sentence with a few words in it', 1)
'A ...'
>>> truncatewords('A sentence with a few words in it', 5)
'A sentence with a few ...'
>>> truncatewords('A sentence with a few words in it', 100)
'A sentence with a few words in it'
>>> truncatewords('A sentence with a few words in it', 'not a number')
'A sentence with a few words in it'
>>> truncatewords_html('<p>one <a href="#">two - three <br>four</a> five</p>', 0)
''
>>> truncatewords_html('<p>one <a href="#">two - three <br>four</a> five</p>', 2)
'<p>one <a href="#">two ...</a></p>'
>>> truncatewords_html('<p>one <a href="#">two - three <br>four</a> five</p>', 4)
'<p>one <a href="#">two - three <br>four ...</a></p>'
>>> truncatewords_html('<p>one <a href="#">two - three <br>four</a> five</p>', 5)
'<p>one <a href="#">two - three <br>four</a> five</p>'
>>> truncatewords_html('<p>one <a href="#">two - three <br>four</a> five</p>', 100)
'<p>one <a href="#">two - three <br>four</a> five</p>'
>>> upper('Mixed case input')
'MIXED CASE INPUT'
>>> upper(u'\xeb') # lowercase e umlaut
u'\xcb'
>>> urlencode('jack & jill')
'jack%20%26%20jill'
>>> urlencode(1)
'1'
>>> urlizetrunc('http://short.com/', 20)
'<a href="http://short.com/" rel="nofollow">http://short.com/</a>'
>>> urlizetrunc('http://www.google.co.uk/search?hl=en&q=some+long+url&btnG=Search&meta=', 20)
'<a href="http://www.google.co.uk/search?hl=en&q=some+long+url&btnG=Search&meta=" rel="nofollow">http://www.google.co...</a>'
>>> wordcount('')
0
>>> wordcount('oneword')
1
>>> wordcount('lots of words')
3
>>> wordwrap('this is a long paragraph of text that really needs to be wrapped I\'m afraid', 14)
"this is a long\nparagraph of\ntext that\nreally needs\nto be wrapped\nI'm afraid"
>>> wordwrap('this is a short paragraph of text.\n But this line should be indented',14)
'this is a\nshort\nparagraph of\ntext.\n But this\nline should be\nindented'
>>> wordwrap('this is a short paragraph of text.\n But this line should be indented',15)
'this is a short\nparagraph of\ntext.\n But this line\nshould be\nindented'
>>> ljust('test', 10)
'test '
>>> ljust('test', 3)
'test'
>>> rjust('test', 10)
' test'
>>> rjust('test', 3)
'test'
>>> center('test', 6)
' test '
>>> cut('a string to be mangled', 'a')
' string to be mngled'
>>> cut('a string to be mangled', 'ng')
'a stri to be maled'
>>> cut('a string to be mangled', 'strings')
'a string to be mangled'
>>> escape('<some html & special characters > here')
'<some html & special characters > here'
>>> linebreaks('line 1')
'<p>line 1</p>'
>>> linebreaks('line 1\nline 2')
'<p>line 1<br />line 2</p>'
>>> removetags('some <b>html</b> with <script>alert("You smell")</script> disallowed <img /> tags', 'script img')
'some <b>html</b> with alert("You smell") disallowed tags'
>>> striptags('some <b>html</b> with <script>alert("You smell")</script> disallowed <img /> tags')
'some html with alert("You smell") disallowed tags'
>>> dictsort([{'age': 23, 'name': 'Barbara-Ann'},
... {'age': 63, 'name': 'Ra Ra Rasputin'},
... {'name': 'Jonny B Goode', 'age': 18}], 'age')
[{'age': 18, 'name': 'Jonny B Goode'}, {'age': 23, 'name': 'Barbara-Ann'}, {'age': 63, 'name': 'Ra Ra Rasputin'}]
>>> dictsortreversed([{'age': 23, 'name': 'Barbara-Ann'},
... {'age': 63, 'name': 'Ra Ra Rasputin'},
... {'name': 'Jonny B Goode', 'age': 18}], 'age')
[{'age': 63, 'name': 'Ra Ra Rasputin'}, {'age': 23, 'name': 'Barbara-Ann'}, {'age': 18, 'name': 'Jonny B Goode'}]
>>> first([0,1,2])
0
>>> first('')
''
>>> first('test')
't'
>>> join([0,1,2], 'glue')
'0glue1glue2'
>>> length('1234')
4
>>> length([1,2,3,4])
4
>>> length_is([], 0)
True
>>> length_is([], 1)
False
>>> length_is('a', 1)
True
>>> length_is('a', 10)
False
>>> slice_('abcdefg', '0')
''
>>> slice_('abcdefg', '1')
'a'
>>> slice_('abcdefg', '-1')
'abcdef'
>>> slice_('abcdefg', '1:2')
'b'
>>> slice_('abcdefg', '1:3')
'bc'
>>> slice_('abcdefg', '0::2')
'aceg'
>>> unordered_list(['item 1', []])
'\t<li>item 1</li>'
>>> unordered_list(['item 1', [['item 1.1', []]]])
'\t<li>item 1\n\t<ul>\n\t\t<li>item 1.1</li>\n\t</ul>\n\t</li>'
>>> unordered_list(['item 1', [['item 1.1', []], ['item 1.2', []]]])
'\t<li>item 1\n\t<ul>\n\t\t<li>item 1.1</li>\n\t\t<li>item 1.2</li>\n\t</ul>\n\t</li>'
>>> add('1', '2')
3
>>> get_digit(123, 1)
3
>>> get_digit(123, 2)
2
>>> get_digit(123, 3)
1
>>> get_digit(123, 4)
0
>>> get_digit(123, 0)
123
>>> get_digit('xyz', 0)
'xyz'
# real testing of date() is in dateformat.py
>>> date(datetime.datetime(2005, 12, 29), "d F Y")
'29 December 2005'
>>> date(datetime.datetime(2005, 12, 29), r'jS o\f F')
'29th of December'
# real testing of time() is done in dateformat.py
>>> time(datetime.time(13), "h")
'01'
>>> time(datetime.time(0), "h")
'12'
# real testing is done in timesince.py, where we can provide our own 'now'
>>> timesince(datetime.datetime.now() - datetime.timedelta(1))
'1 day'
>>> default("val", "default")
'val'
>>> default(None, "default")
'default'
>>> default('', "default")
'default'
>>> default_if_none("val", "default")
'val'
>>> default_if_none(None, "default")
'default'
>>> default_if_none('', "default")
''
>>> divisibleby(4, 2)
True
>>> divisibleby(4, 3)
False
>>> yesno(True)
'yes'
>>> yesno(False)
'no'
>>> yesno(None)
'maybe'
>>> yesno(True, 'certainly,get out of town,perhaps')
'certainly'
>>> yesno(False, 'certainly,get out of town,perhaps')
'get out of town'
>>> yesno(None, 'certainly,get out of town,perhaps')
'perhaps'
>>> yesno(None, 'certainly,get out of town')
'get out of town'
>>> filesizeformat(1023)
'1023 bytes'
>>> filesizeformat(1024)
'1.0 KB'
>>> filesizeformat(10*1024)
'10.0 KB'
>>> filesizeformat(1024*1024-1)
'1024.0 KB'
>>> filesizeformat(1024*1024)
'1.0 MB'
>>> filesizeformat(1024*1024*50)
'50.0 MB'
>>> filesizeformat(1024*1024*1024-1)
'1024.0 MB'
>>> filesizeformat(1024*1024*1024)
'1.0 GB'
>>> pluralize(1)
''
>>> pluralize(0)
's'
>>> pluralize(2)
's'
>>> pluralize([1])
''
>>> pluralize([])
's'
>>> pluralize([1,2,3])
's'
>>> pluralize(1,'es')
''
>>> pluralize(0,'es')
'es'
>>> pluralize(2,'es')
'es'
>>> pluralize(1,'y,ies')
'y'
>>> pluralize(0,'y,ies')
'ies'
>>> pluralize(2,'y,ies')
'ies'
>>> pluralize(0,'y,ies,error')
''
>>> phone2numeric('0800 flowers')
'0800 3569377'
# Filters shouldn't break if passed non-strings
>>> addslashes(123)
'123'
>>> linenumbers(123)
'1. 123'
>>> lower(123)
'123'
>>> make_list(123)
['1', '2', '3']
>>> slugify(123)
'123'
>>> title(123)
'123'
>>> truncatewords(123, 2)
'123'
>>> upper(123)
'123'
>>> urlencode(123)
'123'
>>> urlize(123)
'123'
>>> urlizetrunc(123, 1)
'123'
>>> wordcount(123)
1
>>> wordwrap(123, 2)
'123'
>>> ljust('123', 4)
'123 '
>>> rjust('123', 4)
' 123'
>>> center('123', 5)
' 123 '
>>> center('123', 6)
' 123 '
>>> cut(123, '2')
'13'
>>> escape(123)
'123'
>>> linebreaks(123)
'<p>123</p>'
>>> linebreaksbr(123)
'123'
>>> removetags(123, 'a')
'123'
>>> striptags(123)
'123'
"""
from django.template.defaultfilters import *
import datetime
if __name__ == '__main__':
import doctest
doctest.testmod()
| 18.9117 | 125 | 0.590055 | 1,333 | 8,567 | 3.76069 | 0.225806 | 0.011969 | 0.008977 | 0.016158 | 0.407141 | 0.346898 | 0.255536 | 0.228805 | 0.218432 | 0.18831 | 0 | 0.084507 | 0.146376 | 8,567 | 452 | 126 | 18.95354 | 0.600985 | 0.983425 | 0 | 0 | 0 | 0 | 0.06015 | 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 |
db4f59e0e65732a795c3a3e6b5dcaaa4be394a50 | 235 | py | Python | test_generators/operations/keys.py | ssteiger/eth2.0-specs | 23b1cb225d4aab476bbeba06ab1d17755ccfd104 | [
"CC0-1.0"
] | 1 | 2021-05-22T16:06:27.000Z | 2021-05-22T16:06:27.000Z | test_generators/operations/keys.py | ssteiger/eth2.0-specs | 23b1cb225d4aab476bbeba06ab1d17755ccfd104 | [
"CC0-1.0"
] | null | null | null | test_generators/operations/keys.py | ssteiger/eth2.0-specs | 23b1cb225d4aab476bbeba06ab1d17755ccfd104 | [
"CC0-1.0"
] | null | null | null | from py_ecc import bls
from eth2spec.phase0.spec import hash
privkeys = list(range(1, 101))
pubkeys = [bls.privtopub(k) for k in privkeys]
# Insecure, but easier to follow
withdrawal_creds = [hash(bls.privtopub(k)) for k in privkeys]
| 29.375 | 61 | 0.757447 | 39 | 235 | 4.512821 | 0.666667 | 0.136364 | 0.147727 | 0.181818 | 0.306818 | 0.306818 | 0.306818 | 0 | 0 | 0 | 0 | 0.029703 | 0.140426 | 235 | 7 | 62 | 33.571429 | 0.841584 | 0.12766 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | false | 0 | 0.4 | 0 | 0.4 | 0 | 0 | 0 | 0 | null | 0 | 0 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 0 | 0 | 3 |
db55d9121f440fe7dd70ef48bbae93a5d207a49e | 92 | py | Python | section4/test_FloatingPoint.py | skbansal5642/UnitTestingAndTestDrivenDevelopmentInPythonMaster | ed4fb4eecc0964b5d2b59ac5f7d683d46fb59016 | [
"Apache-2.0"
] | null | null | null | section4/test_FloatingPoint.py | skbansal5642/UnitTestingAndTestDrivenDevelopmentInPythonMaster | ed4fb4eecc0964b5d2b59ac5f7d683d46fb59016 | [
"Apache-2.0"
] | null | null | null | section4/test_FloatingPoint.py | skbansal5642/UnitTestingAndTestDrivenDevelopmentInPythonMaster | ed4fb4eecc0964b5d2b59ac5f7d683d46fb59016 | [
"Apache-2.0"
] | null | null | null | import pytest
def test_approx():
val = 0.1 + 0.2
assert val == pytest.approx(0.3)
| 13.142857 | 36 | 0.608696 | 16 | 92 | 3.4375 | 0.6875 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0.086957 | 0.25 | 92 | 6 | 37 | 15.333333 | 0.710145 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0.25 | 1 | 0.25 | false | 0 | 0.25 | 0 | 0.5 | 0 | 1 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 3 |
db5ac50c5c4ccca8a29c830db5322d06c654ed83 | 1,358 | py | Python | test/descr.py | dramatis/dramatis | 1a43a6be1d7e7e9fd2cde052430d6e84700dc822 | [
"MIT"
] | 5 | 2015-11-05T01:51:29.000Z | 2019-04-16T09:09:19.000Z | test/descr.py | halorgium/dramatis | 50b35c4e79c33e438cb9f5eeab51ab73119bd75d | [
"MIT"
] | null | null | null | test/descr.py | halorgium/dramatis | 50b35c4e79c33e438cb9f5eeab51ab73119bd75d | [
"MIT"
] | 1 | 2022-03-03T19:51:04.000Z | 2022-03-03T19:51:04.000Z | #!/usr/bin/env python
class Real(object):
def method(self):
return "method"
@property
def prop(self):
# print "prop called"
return "prop"
class PropertyProxy(object):
def __init__( self, object, name ):
self._object = object
self._name = name
def __get__(self,obj,type):
# print self, "__get__", obj, type
return obj.__getattribute__(self._name)
class FunctionProxy(object):
def __init__( self, object, name ):
self._object = object
self._name = name
def __call__( self, *args, **kwds ):
return self._object.__getattribute__( self._name ).__call__( *args, **kwds )
def _func(): pass
_func = type(_func)
class Proxy(object):
def __init__( self, object ):
self.__object = object
def __getattribute__( self, name ):
o = super(Proxy,self).__getattribute__( "_Proxy__object" )
if name == "_Proxy__object":
return o
t = type( type(o).__dict__[ name ] )
if t == property:
return PropertyProxy( self.__object, name ).__get__(o,type(o))
elif t == _func:
return FunctionProxy( self.__object, name )
else: raise "hell"
r = Real()
p = Proxy( r )
m = p.method
# print m
# print m()
assert m() == "method"
prop = p.prop
# print prop
assert prop == "prop"
| 24.690909 | 84 | 0.597938 | 163 | 1,358 | 4.521472 | 0.257669 | 0.122117 | 0.075984 | 0.069199 | 0.188602 | 0.157395 | 0.157395 | 0.157395 | 0.157395 | 0.157395 | 0 | 0 | 0.276878 | 1,358 | 54 | 85 | 25.148148 | 0.750509 | 0.07511 | 0 | 0.153846 | 0 | 0 | 0.0416 | 0 | 0 | 0 | 0 | 0 | 0.051282 | 1 | 0.230769 | false | 0.025641 | 0 | 0.102564 | 0.512821 | 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 |
db66a0a4a61e856f9d7fa82343527f1ecda85063 | 21,362 | py | Python | game/game.py | grochavieira/py-arkanoid | 430e55b20fa43abbcb8becfd6b58938f8690fe12 | [
"MIT"
] | null | null | null | game/game.py | grochavieira/py-arkanoid | 430e55b20fa43abbcb8becfd6b58938f8690fe12 | [
"MIT"
] | null | null | null | game/game.py | grochavieira/py-arkanoid | 430e55b20fa43abbcb8becfd6b58938f8690fe12 | [
"MIT"
] | null | null | null | import pygame
import sys
import random
import settings
import engine
class GameState():
def __init__(self):
self.state = "menu"
self.is_running = True
self.paddle_group = pygame.sprite.GroupSingle()
self.block_group = pygame.sprite.Group()
self.powerup_group = pygame.sprite.Group()
self.ball_group = pygame.sprite.GroupSingle()
self.laser_group = pygame.sprite.Group()
self.game_manager = engine.GameManager(self.ball_group, self.paddle_group, self.block_group, self.powerup_group, self.laser_group)
self.player = engine.Player(
"images/paddle_normal.png", settings.screen_width/2, settings.screen_height - 20, 7)
self.paddle_group.add(self.player)
self.ball = engine.Ball("images/balls/ball_night.png", self.player.rect.x + 25,
settings.screen_height/2, 4, 4, self.paddle_group, self.block_group)
self.ball_group.add(self.ball)
def game_events(self, next_stage):
if not self.game_manager.is_winning:
self.state = "lost_level"
self.game_manager.reset_game()
self.is_running = False
if(self.game_manager.has_finished_level):
self.game_manager.soft_reset()
self.state = next_stage
self.is_running = False
for event in pygame.event.get():
# se clicou no X da tela
if event.type == pygame.QUIT:
# sai do jogo
pygame.quit()
sys.exit()
# se apertou alguma tecla
if event.type == pygame.KEYDOWN:
# apertou a tecla para cima
if event.key == pygame.K_LEFT:
# move o jogador para cima
self.player.movement -= self.player.speed
# apertou a tecla para baixo
if event.key == pygame.K_RIGHT:
# move o jogador para baixo
self.player.movement += self.player.speed
if event.key == pygame.K_ESCAPE:
self.state = "menu"
self.game_manager.reset_game()
self.is_running = False
if event.key == pygame.K_SPACE:
if(self.player.can_shoot and self.player.ammunition > 0):
pygame.mixer.Sound.play(settings.laser_sound)
new_laser1 = engine.Laser(
"images/Laser.png", self.player.rect.left + 10, self.player.rect.top, self.block_group)
new_laser2 = engine.Laser(
"images/Laser.png", self.player.rect.right - 10, self.player.rect.top, self.block_group)
self.laser_group.add(new_laser1)
self.laser_group.add(new_laser2)
self.player.shoot_laser()
# se soltou alguma tecla
if event.type == pygame.KEYUP:
if event.key == pygame.K_LEFT:
# reseta o movimento do jogador para 0
self.player.movement += self.player.speed
if event.key == pygame.K_RIGHT:
# reseta o movimento do jogador para 0
self.player.movement -= self.player.speed
def menu(self):
settings.score = 0
self.is_running = True
pygame.mixer.Sound.play(settings.main_theme) # toca fireflies
start_button_text = settings.bigger_basic_font.render(
"START GAME", True, settings.accent_color)
start_button_text_rect = start_button_text.get_rect(
center=(settings.screen_width/2, 395))
start_button = engine.Button(
"images/btn_start/start_game", 9, settings.screen_width/2, 400)
randomizer_button_text = settings.bigger_basic_font.render(
"RANDOMIZER", True, settings.accent_color)
randomizer_button_text_rect = randomizer_button_text.get_rect(
center=(settings.screen_width/2, 595))
randomizer_button = engine.Button(
"images/btn_start/start_game", 9, settings.screen_width/2, 600)
# botão para iniciar o jogo
button_group = pygame.sprite.Group()
button_group.add(start_button)
button_group.add(randomizer_button)
# titulo e texto de informação do jogo
title = engine.Text("images/title/arkanoid_title", 9, 0.07,
settings.screen_width/2, 100)
text_group = pygame.sprite.Group()
text_group.add(title)
# mouse element
mouse = engine.Mouse()
mouse_group = pygame.sprite.Group()
mouse_group.add(mouse)
while self.is_running:
settings.screen.fill(settings.bg_color)
for event in pygame.event.get():
if event.type == pygame.QUIT:
pygame.quit()
sys.exit()
if event.type == pygame.MOUSEBUTTONDOWN:
if pygame.sprite.spritecollide(mouse, button_group, False):
collision_button = pygame.sprite.spritecollide(
mouse, button_group, False)[0].rect
print(collision_button.bottom)
if collision_button.bottom <= 600:
settings.button_sound.play()
self.state = "level_1"
self.is_running = False
elif collision_button.bottom <= 800:
settings.button_sound.play()
self.state = "randomizer"
self.is_running = False
bg_image = pygame.image.load('images/background.jpg')
bg_scaled = pygame.transform.scale(
bg_image, (settings.screen_width, settings.screen_height))
settings.screen.blit(bg_scaled, (0, 0))
button_group.draw(settings.screen)
mouse_group.draw(settings.screen)
text_group.draw(settings.screen)
button_group.update()
settings.screen.blit(start_button_text, start_button_text_rect)
settings.screen.blit(randomizer_button_text,
randomizer_button_text_rect)
mouse_group.update()
text_group.update()
pygame.display.update()
settings.clock.tick(120)
def passed_level(self):
self.is_running = True
passed_level_text = settings.bigger_basic_font.render(
"You passed level " + str(self.game_manager.current_stage), True, settings.accent_color)
passed_level_text_rect = passed_level_text.get_rect(
center=(settings.screen_width/2, settings.screen_height/2 - 50))
press_space_text = settings.basic_font.render(
"Press space to proceed no next level", True, settings.accent_color)
press_space_text_rect = press_space_text.get_rect(
center=(settings.screen_width/2, settings.screen_height/2 + 50))
while self.is_running:
settings.screen.fill(settings.bg_color)
for event in pygame.event.get():
if event.type == pygame.QUIT:
pygame.quit()
sys.exit()
if event.type == pygame.KEYDOWN:
if event.key == pygame.K_SPACE:
self.state = "level_" + \
str(self.game_manager.current_stage + 1)
self.is_running = False
settings.screen.fill(settings.bg_color)
settings.screen.blit(passed_level_text, passed_level_text_rect)
settings.screen.blit(press_space_text, press_space_text_rect)
pygame.display.update()
settings.clock.tick(120)
def lost_level(self):
self.is_running = True
lost_level_text = settings.bigger_basic_font.render(
"Your total score is " + str(settings.score), True, settings.accent_color)
lost_level_text_rect = lost_level_text.get_rect(
center=(settings.screen_width/2, settings.screen_height/2 - 50))
press_space_text = settings.basic_font.render(
"Press space to return to the menu", True, settings.accent_color)
press_space_text_rect = press_space_text.get_rect(
center=(settings.screen_width/2, settings.screen_height/2 + 50))
while self.is_running:
settings.screen.fill(settings.bg_color)
for event in pygame.event.get():
if event.type == pygame.QUIT:
pygame.quit()
sys.exit()
if event.type == pygame.KEYDOWN:
if event.key == pygame.K_SPACE:
self.state = "menu"
self.is_running = False
settings.screen.fill(settings.bg_color)
settings.screen.blit(lost_level_text, lost_level_text_rect)
settings.screen.blit(press_space_text, press_space_text_rect)
pygame.display.update()
settings.clock.tick(120)
def win_game(self):
self.is_running = True
win_text = settings.bigger_basic_font.render(
"You WIN ", True, settings.accent_color)
win_text_rect = win_text.get_rect(
center=(settings.screen_width/2, settings.screen_height/2 - 150))
score_text = settings.bigger_basic_font.render(
"Your total score is " + str(settings.score), True, settings.accent_color)
score_text_rect = score_text.get_rect(
center=(settings.screen_width/2, settings.screen_height/2 - 50))
press_space_text = settings.basic_font.render(
"Press space to return to the menu", True, settings.accent_color)
press_space_text_rect = press_space_text.get_rect(
center=(settings.screen_width/2, settings.screen_height/2 + 50))
while self.is_running:
settings.screen.fill(settings.bg_color)
for event in pygame.event.get():
if event.type == pygame.QUIT:
pygame.quit()
sys.exit()
if event.type == pygame.KEYDOWN:
if event.key == pygame.K_SPACE:
self.state = "menu"
self.is_running = False
settings.screen.fill(settings.bg_color)
settings.screen.blit(win_text, win_text_rect)
settings.screen.blit(score_text, score_text_rect)
settings.screen.blit(press_space_text, press_space_text_rect)
pygame.display.update()
settings.clock.tick(120)
def randomizer(self):
pygame.mixer.Sound.stop(settings.main_theme)
self.is_running = True
self.game_manager.current_stage = 0
self.game_manager.has_finished_level = False
for i in range(11):
for j in range(10):
if random.randint(1, 100) <= 50:
new_powerup = engine.PowerUp(
"images/powerups/invisible.png", settings.left_boundary + i * 51 + 60, 50 + j * 26, self.paddle_group, self.ball_group)
new_breakable_block = engine.BreakableBlock(
"images/blocks/Block1.png", settings.left_boundary + i * 51 + 60, 50 + j * 26, random.randint(1, 7), new_powerup)
self.block_group.add(new_breakable_block)
self.powerup_group.add(new_powerup)
self.ball.reset_ball(True)
game_start_time = pygame.time.get_ticks()
previous_player_score = 0
while self.is_running:
self.game_events("randomizer")
settings.screen.fill(settings.bg_color)
bg_image = pygame.image.load('images/levels/night.png')
bg_scaled = pygame.transform.scale(bg_image, (640, 720))
settings.screen.blit(bg_scaled, (320, 0))
pygame.draw.rect(settings.screen, settings.accent_color,
settings.left_strip)
pygame.draw.rect(settings.screen, settings.accent_color,
settings.right_strip)
self.block_group.draw(settings.screen)
# Cuida da renderização e alteração dos objetos do jogo
self.game_manager.run_game()
# Atualiza todo o conteúdo da tela
pygame.display.flip()
# define a velocidade do jogo
settings.clock.tick(120)
def level_1(self):
pygame.mixer.Sound.stop(settings.main_theme)
self.is_running = True
self.game_manager.current_stage = 1
self.game_manager.has_finished_level = False
for i in range(11):
for j in range(3):
new_powerup = engine.PowerUp(
"images/powerups/invisible.png", settings.left_boundary + i * 51 + 60, 50 + j * 26, self.paddle_group, self.ball_group)
new_breakable_block = engine.BreakableBlock(
"images/blocks/Block1.png", settings.left_boundary + i * 51 + 60, 50 + j * 26, 1, new_powerup)
self.block_group.add(new_breakable_block)
self.powerup_group.add(new_powerup)
self.ball.reset_ball(True)
game_start_time = pygame.time.get_ticks()
while self.is_running:
self.game_events("passed_level")
settings.screen.fill(settings.bg_color)
bg_image = pygame.image.load('images/levels/city.png')
bg_scaled = pygame.transform.scale(bg_image, (640, 720))
settings.screen.blit(bg_scaled, (320, 0))
pygame.draw.rect(settings.screen, settings.accent_color,
settings.left_strip)
pygame.draw.rect(settings.screen, settings.accent_color,
settings.right_strip)
self.block_group.draw(settings.screen)
self.game_manager.run_game()
pygame.display.flip()
settings.clock.tick(120)
def level_2(self):
self.is_running = True
self.game_manager.current_stage = 2
self.game_manager.has_finished_level = False
powerup_group = pygame.sprite.Group()
for i in range(11):
for j in range(11):
if (i == 0 and j > 1) or (j == 0 and i > 1) or (i == 10 and j < 9) or (j == 10 and i < 9) or i == j+1 or j == i+1:
new_powerup = engine.PowerUp("images/powerups/invisible.png", settings.left_boundary + j * 51 + 60, 50 + i * 26, self.paddle_group, self.ball_group)
new_breakable_block = engine.BreakableBlock("images/blocks/Block1.png", settings.left_boundary + j * 51 + 60, 50 + i * 26, 2, new_powerup)
self.block_group.add(new_breakable_block)
self.powerup_group.add(new_powerup)
self.ball.reset_ball(True)
game_start_time = pygame.time.get_ticks()
while self.is_running:
self.game_events("passed_level")
settings.screen.fill(settings.bg_color)
bg_image = pygame.image.load('images/levels/sky.png')
bg_scaled = pygame.transform.scale(bg_image, (640, 720))
settings.screen.blit(bg_scaled, (320, 0))
pygame.draw.rect(settings.screen, settings.accent_color,
settings.left_strip)
pygame.draw.rect(settings.screen, settings.accent_color,
settings.right_strip)
self.block_group.draw(settings.screen)
self.game_manager.run_game()
pygame.display.flip()
settings.clock.tick(120)
def level_3(self):
self.is_running = True
self.game_manager.current_stage = 3
self.game_manager.has_finished_level = False
powerup_group = pygame.sprite.Group()
for i in range(11):
for j in range(11):
if i == 0 or j == 0 or i == 5 or j == 5 or i == 10 or j == 10:
new_powerup = engine.PowerUp("images/powerups/invisible.png", settings.left_boundary + j * 51 + 60, 50 + i * 26, self.paddle_group, self.ball_group)
new_breakable_block = engine.BreakableBlock("images/blocks/Block1.png", settings.left_boundary + j * 51 + 60, 50 + i * 26, 3, new_powerup)
self.block_group.add(new_breakable_block)
self.powerup_group.add(new_powerup)
self.ball.reset_ball(True)
game_start_time = pygame.time.get_ticks()
while self.is_running:
self.game_events("passed_level")
settings.screen.fill(settings.bg_color)
bg_image = pygame.image.load('images/levels/spooky.png')
bg_scaled = pygame.transform.scale(bg_image, (640, 720))
settings.screen.blit(bg_scaled, (320, 0))
pygame.draw.rect(settings.screen, settings.accent_color,
settings.left_strip)
pygame.draw.rect(settings.screen, settings.accent_color,
settings.right_strip)
self.block_group.draw(settings.screen)
self.game_manager.run_game()
pygame.display.flip()
settings.clock.tick(120)
def level_4(self):
self.is_running = True
self.game_manager.current_stage = 4
self.game_manager.has_finished_level = False
powerup_group = pygame.sprite.Group()
for i in range(11):
for j in range(11):
if (i == 0 and j%5 != 0) or (i == 1 and j%5 == 0) or (i - j == 5) or (i + j == 15) or ((j == 0 or j == 10) and (1 <= i <= 4)):
new_powerup = engine.PowerUp("images/powerups/invisible.png", settings.left_boundary + j * 51 + 60, 50 + i * 26, self.paddle_group, self.ball_group)
new_breakable_block = engine.BreakableBlock("images/blocks/Block1.png", settings.left_boundary + j * 51 + 60, 50 + i * 26, 4, new_powerup)
self.block_group.add(new_breakable_block)
self.powerup_group.add(new_powerup)
self.ball.reset_ball(True)
game_start_time = pygame.time.get_ticks()
while self.is_running:
self.game_events("passed_level")
settings.screen.fill(settings.bg_color)
bg_image = pygame.image.load('images/levels/grass.png')
bg_scaled = pygame.transform.scale(bg_image, (640, 720))
settings.screen.blit(bg_scaled, (320, 0))
pygame.draw.rect(settings.screen, settings.accent_color,
settings.left_strip)
pygame.draw.rect(settings.screen, settings.accent_color,
settings.right_strip)
self.block_group.draw(settings.screen)
self.game_manager.run_game()
pygame.display.flip()
settings.clock.tick(120)
def level_5(self):
self.is_running = True
self.game_manager.current_stage = 1
self.game_manager.has_finished_level = False
powerup_group = pygame.sprite.Group()
for i in range(11):
for j in range(11):
if (j-i)%2 == 0:
new_powerup = engine.PowerUp("images/powerups/invisible.png", settings.left_boundary + j * 51 + 60, 50 + i * 26, self.paddle_group, self.ball_group)
new_breakable_block = engine.BreakableBlock("images/blocks/Block1.png", settings.left_boundary + j * 51 + 60, 50 + i * 26, (i%7)+1, new_powerup)
self.block_group.add(new_breakable_block)
self.powerup_group.add(new_powerup)
self.ball.reset_ball(True)
game_start_time = pygame.time.get_ticks()
while self.is_running:
self.game_events("win_game")
settings.screen.fill(settings.bg_color)
bg_image = pygame.image.load('images/levels/night.png')
bg_scaled = pygame.transform.scale(bg_image, (640, 720))
settings.screen.blit(bg_scaled, (320, 0))
pygame.draw.rect(settings.screen, settings.accent_color,
settings.left_strip)
pygame.draw.rect(settings.screen, settings.accent_color,
settings.right_strip)
self.block_group.draw(settings.screen)
self.game_manager.run_game()
pygame.display.flip()
settings.clock.tick(120)
def state_manager(self):
if self.state == "menu":
self.menu()
if self.state == "passed_level":
self.passed_level()
if self.state == "lost_level":
self.lost_level()
if self.state == "win_game":
self.win_game()
if self.state == "randomizer":
self.randomizer()
if self.state == "level_1":
self.level_1()
if self.state == "level_2":
self.level_2()
if self.state == "level_3":
self.level_3()
if self.state == "level_4":
self.level_4()
if self.state == "level_5":
self.level_5()
| 40.535104 | 168 | 0.581593 | 2,561 | 21,362 | 4.641937 | 0.088247 | 0.087147 | 0.031713 | 0.021871 | 0.786003 | 0.745205 | 0.707773 | 0.66605 | 0.650404 | 0.64317 | 0 | 0.025791 | 0.321178 | 21,362 | 526 | 169 | 40.612167 | 0.794014 | 0.021814 | 0 | 0.604592 | 0 | 0 | 0.048855 | 0.029074 | 0 | 0 | 0 | 0.001901 | 0 | 1 | 0.033163 | false | 0.028061 | 0.012755 | 0 | 0.048469 | 0.002551 | 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 |
db6f54aa1a043a7cd737ec2ac0b0bc71225def4f | 89 | py | Python | Desafios/desafio001.py | sthe-eduarda/Curso-de-python | 524f6cc132a5746bc039921f954f941e63aaede0 | [
"MIT"
] | null | null | null | Desafios/desafio001.py | sthe-eduarda/Curso-de-python | 524f6cc132a5746bc039921f954f941e63aaede0 | [
"MIT"
] | null | null | null | Desafios/desafio001.py | sthe-eduarda/Curso-de-python | 524f6cc132a5746bc039921f954f941e63aaede0 | [
"MIT"
] | null | null | null | nome = input('Qual é o seu nome? ')
print('Olá,{},é um prazer te conhecer'.format(nome))
| 29.666667 | 52 | 0.662921 | 16 | 89 | 3.6875 | 0.8125 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0.146067 | 89 | 2 | 53 | 44.5 | 0.776316 | 0 | 0 | 0 | 0 | 0 | 0.550562 | 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 |
db7c7f3efcf787af4ef9ab0dcf313806d6223dc0 | 220 | py | Python | HackerRank/Superset.py | prajjwalkumar17/DSA_Problems- | 61f09676dd67b90d20b2a60fe4e112897e9e735d | [
"Apache-2.0"
] | null | null | null | HackerRank/Superset.py | prajjwalkumar17/DSA_Problems- | 61f09676dd67b90d20b2a60fe4e112897e9e735d | [
"Apache-2.0"
] | 2 | 2021-10-01T16:40:24.000Z | 2021-10-03T05:24:24.000Z | HackerRank/Superset.py | prajjwalkumar17/DSA_Problems- | 61f09676dd67b90d20b2a60fe4e112897e9e735d | [
"Apache-2.0"
] | 5 | 2021-10-01T16:41:28.000Z | 2021-10-07T04:36:51.000Z | set_A = set(map(int,input().split()))
N = int(input())
for i in range(N):
arr_A = set(input().split())
arr_N = set(input().split())
if not arr_A.issuperset(arr_N):
print(False)
else:
print(True)
| 22 | 38 | 0.586364 | 37 | 220 | 3.351351 | 0.513514 | 0.241935 | 0.209677 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0.213636 | 220 | 9 | 39 | 24.444444 | 0.716763 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | false | 0 | 0 | 0 | 0 | 0.222222 | 0 | 0 | 0 | null | 1 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 3 |
db7fadf60b68341d1601e22601267e5b75133e19 | 1,339 | py | Python | tests/scheduler/__init__.py | warownia1/Slivca | 5491afec63c8cd41d6f1389a5dd0ba9877b888a1 | [
"Apache-2.0"
] | null | null | null | tests/scheduler/__init__.py | warownia1/Slivca | 5491afec63c8cd41d6f1389a5dd0ba9877b888a1 | [
"Apache-2.0"
] | null | null | null | tests/scheduler/__init__.py | warownia1/Slivca | 5491afec63c8cd41d6f1389a5dd0ba9877b888a1 | [
"Apache-2.0"
] | null | null | null | from typing import List
from slivka import JobStatus
from slivka.scheduler import BaseSelector, BaseCommandRunner
from slivka.scheduler.runner import Command, Job
from slivka.scheduler.starter import CommandStarter, RunnerID
class BaseSelectorStub(BaseSelector):
def limit_runner1(self, inputs): return inputs.get('runner') == 1
def limit_runner2(self, inputs): return inputs.get('runner') == 2
def limit_default(self, inputs): return inputs.get('use_default', False)
def limit_foo(self, inputs): return inputs.get('use_foo', False)
def limit_bar(self, inputs): return inputs.get('use_bar', False)
def make_starter(service=None, runner=None, base_command="", args=None,
env=None):
service_id = None
if service and runner:
service_id = RunnerID(service, runner)
return CommandStarter(
service_id, base_command, args or [], env or {}
)
class StubRunner(BaseCommandRunner):
def __init__(self, **kwargs):
self.init_kwargs = kwargs
def start(self, commands: List[Command]) -> List[Job]:
return [Job(f"job{i:02d}", command.cwd)
for i, command in enumerate(commands)]
def status(self, jobs: List[Job]) -> List[JobStatus]:
return [JobStatus.RUNNING for _ in jobs]
def cancel(self, jobs: List[Job]):
pass
| 33.475 | 76 | 0.68932 | 173 | 1,339 | 5.219653 | 0.34104 | 0.044297 | 0.088594 | 0.121816 | 0.161683 | 0.161683 | 0 | 0 | 0 | 0 | 0 | 0.005597 | 0.199403 | 1,339 | 39 | 77 | 34.333333 | 0.836754 | 0 | 0 | 0 | 0 | 0 | 0.035101 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0.344828 | false | 0.034483 | 0.172414 | 0.241379 | 0.689655 | 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 |
db888535a87e457766feb2b770d94cf23c1b23bb | 827 | py | Python | makobot/libs/virustotal.py | swimlane/makobot | 352391628942b2b6942fcb4d3cefda57efcf18c2 | [
"MIT"
] | 24 | 2016-05-17T20:36:42.000Z | 2020-05-29T19:36:23.000Z | makobot/libs/virustotal.py | Swimlane/makobot | 352391628942b2b6942fcb4d3cefda57efcf18c2 | [
"MIT"
] | null | null | null | makobot/libs/virustotal.py | Swimlane/makobot | 352391628942b2b6942fcb4d3cefda57efcf18c2 | [
"MIT"
] | 9 | 2016-05-17T20:36:46.000Z | 2021-05-25T17:33:14.000Z | # -*- coding: utf-8 -*-
from requests import Session
class VirusTotal(object):
def __init__(self, api_key):
self.base_url = 'https://www.virustotal.com/vtapi/v2'
self.session = Session()
self.api_key = api_key
def get(self, *uri, **params):
params.update(apikey=self.api_key)
r = self.session.get('/'.join([self.base_url] + list(uri)),
params=params)
r.raise_for_status()
return r.json()
def host(self, host):
return self.get('domain', 'report', domain=host)
def ip(self, ip):
return self.get('ip-address', 'report', ip=ip)
def md5(self, md5):
return self.get('file', 'report', resource=md5, allinfo=1)
def url(self, url):
return self.get('url', 'report', resource=url, scan=1)
| 27.566667 | 67 | 0.579202 | 111 | 827 | 4.207207 | 0.414414 | 0.051392 | 0.111349 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0.011457 | 0.261185 | 827 | 29 | 68 | 28.517241 | 0.752864 | 0.025393 | 0 | 0 | 0 | 0 | 0.103234 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0.3 | false | 0 | 0.05 | 0.2 | 0.65 | 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 |
db8eb25b9447070a6b7dc537704b426fcdebc5f0 | 5,574 | py | Python | packages/python/plotly/plotly/validators/layout/scene/zaxis/__init__.py | reservoirinvest/plotly.py | 73651942b51587086da1eee53f67995f28d68ee3 | [
"MIT"
] | 76 | 2020-07-06T14:44:05.000Z | 2022-02-14T15:30:21.000Z | packages/python/plotly/plotly/validators/layout/scene/zaxis/__init__.py | reservoirinvest/plotly.py | 73651942b51587086da1eee53f67995f28d68ee3 | [
"MIT"
] | 11 | 2020-08-09T02:30:14.000Z | 2022-03-12T00:50:14.000Z | packages/python/plotly/plotly/validators/layout/scene/zaxis/__init__.py | reservoirinvest/plotly.py | 73651942b51587086da1eee53f67995f28d68ee3 | [
"MIT"
] | 11 | 2020-07-12T16:18:07.000Z | 2022-02-05T16:48:35.000Z | import sys
if sys.version_info < (3, 7):
from ._zerolinewidth import ZerolinewidthValidator
from ._zerolinecolor import ZerolinecolorValidator
from ._zeroline import ZerolineValidator
from ._visible import VisibleValidator
from ._type import TypeValidator
from ._title import TitleValidator
from ._tickwidth import TickwidthValidator
from ._tickvalssrc import TickvalssrcValidator
from ._tickvals import TickvalsValidator
from ._ticktextsrc import TicktextsrcValidator
from ._ticktext import TicktextValidator
from ._ticksuffix import TicksuffixValidator
from ._ticks import TicksValidator
from ._tickprefix import TickprefixValidator
from ._tickmode import TickmodeValidator
from ._ticklen import TicklenValidator
from ._tickformatstopdefaults import TickformatstopdefaultsValidator
from ._tickformatstops import TickformatstopsValidator
from ._tickformat import TickformatValidator
from ._tickfont import TickfontValidator
from ._tickcolor import TickcolorValidator
from ._tickangle import TickangleValidator
from ._tick0 import Tick0Validator
from ._spikethickness import SpikethicknessValidator
from ._spikesides import SpikesidesValidator
from ._spikecolor import SpikecolorValidator
from ._showticksuffix import ShowticksuffixValidator
from ._showtickprefix import ShowtickprefixValidator
from ._showticklabels import ShowticklabelsValidator
from ._showspikes import ShowspikesValidator
from ._showline import ShowlineValidator
from ._showgrid import ShowgridValidator
from ._showexponent import ShowexponentValidator
from ._showbackground import ShowbackgroundValidator
from ._showaxeslabels import ShowaxeslabelsValidator
from ._separatethousands import SeparatethousandsValidator
from ._rangemode import RangemodeValidator
from ._range import RangeValidator
from ._nticks import NticksValidator
from ._mirror import MirrorValidator
from ._minexponent import MinexponentValidator
from ._linewidth import LinewidthValidator
from ._linecolor import LinecolorValidator
from ._hoverformat import HoverformatValidator
from ._gridwidth import GridwidthValidator
from ._gridcolor import GridcolorValidator
from ._exponentformat import ExponentformatValidator
from ._dtick import DtickValidator
from ._color import ColorValidator
from ._categoryorder import CategoryorderValidator
from ._categoryarraysrc import CategoryarraysrcValidator
from ._categoryarray import CategoryarrayValidator
from ._calendar import CalendarValidator
from ._backgroundcolor import BackgroundcolorValidator
from ._autorange import AutorangeValidator
else:
from _plotly_utils.importers import relative_import
__all__, __getattr__, __dir__ = relative_import(
__name__,
[],
[
"._zerolinewidth.ZerolinewidthValidator",
"._zerolinecolor.ZerolinecolorValidator",
"._zeroline.ZerolineValidator",
"._visible.VisibleValidator",
"._type.TypeValidator",
"._title.TitleValidator",
"._tickwidth.TickwidthValidator",
"._tickvalssrc.TickvalssrcValidator",
"._tickvals.TickvalsValidator",
"._ticktextsrc.TicktextsrcValidator",
"._ticktext.TicktextValidator",
"._ticksuffix.TicksuffixValidator",
"._ticks.TicksValidator",
"._tickprefix.TickprefixValidator",
"._tickmode.TickmodeValidator",
"._ticklen.TicklenValidator",
"._tickformatstopdefaults.TickformatstopdefaultsValidator",
"._tickformatstops.TickformatstopsValidator",
"._tickformat.TickformatValidator",
"._tickfont.TickfontValidator",
"._tickcolor.TickcolorValidator",
"._tickangle.TickangleValidator",
"._tick0.Tick0Validator",
"._spikethickness.SpikethicknessValidator",
"._spikesides.SpikesidesValidator",
"._spikecolor.SpikecolorValidator",
"._showticksuffix.ShowticksuffixValidator",
"._showtickprefix.ShowtickprefixValidator",
"._showticklabels.ShowticklabelsValidator",
"._showspikes.ShowspikesValidator",
"._showline.ShowlineValidator",
"._showgrid.ShowgridValidator",
"._showexponent.ShowexponentValidator",
"._showbackground.ShowbackgroundValidator",
"._showaxeslabels.ShowaxeslabelsValidator",
"._separatethousands.SeparatethousandsValidator",
"._rangemode.RangemodeValidator",
"._range.RangeValidator",
"._nticks.NticksValidator",
"._mirror.MirrorValidator",
"._minexponent.MinexponentValidator",
"._linewidth.LinewidthValidator",
"._linecolor.LinecolorValidator",
"._hoverformat.HoverformatValidator",
"._gridwidth.GridwidthValidator",
"._gridcolor.GridcolorValidator",
"._exponentformat.ExponentformatValidator",
"._dtick.DtickValidator",
"._color.ColorValidator",
"._categoryorder.CategoryorderValidator",
"._categoryarraysrc.CategoryarraysrcValidator",
"._categoryarray.CategoryarrayValidator",
"._calendar.CalendarValidator",
"._backgroundcolor.BackgroundcolorValidator",
"._autorange.AutorangeValidator",
],
)
| 45.317073 | 72 | 0.717797 | 352 | 5,574 | 10.994318 | 0.360795 | 0.007235 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0.001379 | 0.219412 | 5,574 | 122 | 73 | 45.688525 | 0.888072 | 0 | 0 | 0 | 0 | 0 | 0.317905 | 0.314316 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | true | 0 | 0.483333 | 0 | 0.483333 | 0 | 0 | 0 | 1 | null | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 1 | 0 | 0 | 0 | 0 | 3 |
dba0013b598565ea33939f62e80c7d596e9ac3bd | 764 | py | Python | ee/clickhouse/migrations/0020_session_recording_events_window_id.py | ld-rale/posthog | 0fa5b18b2e940cf5cdbe8afc733eb7e3cd4ae810 | [
"MIT"
] | null | null | null | ee/clickhouse/migrations/0020_session_recording_events_window_id.py | ld-rale/posthog | 0fa5b18b2e940cf5cdbe8afc733eb7e3cd4ae810 | [
"MIT"
] | null | null | null | ee/clickhouse/migrations/0020_session_recording_events_window_id.py | ld-rale/posthog | 0fa5b18b2e940cf5cdbe8afc733eb7e3cd4ae810 | [
"MIT"
] | null | null | null | from infi.clickhouse_orm import migrations
from ee.clickhouse.sql.session_recording_events import (
KAFKA_SESSION_RECORDING_EVENTS_TABLE_SQL,
SESSION_RECORDING_EVENTS_TABLE_MV_SQL,
)
from posthog.settings import CLICKHOUSE_CLUSTER
operations = [
migrations.RunSQL(f"DROP TABLE session_recording_events_mv ON CLUSTER '{CLICKHOUSE_CLUSTER}'"),
migrations.RunSQL(f"DROP TABLE kafka_session_recording_events ON CLUSTER '{CLICKHOUSE_CLUSTER}'"),
migrations.RunSQL(
f"ALTER TABLE session_recording_events ON CLUSTER '{CLICKHOUSE_CLUSTER}' ADD COLUMN IF NOT EXISTS window_id VARCHAR AFTER session_id"
),
migrations.RunSQL(KAFKA_SESSION_RECORDING_EVENTS_TABLE_SQL()),
migrations.RunSQL(SESSION_RECORDING_EVENTS_TABLE_MV_SQL()),
]
| 42.444444 | 141 | 0.808901 | 98 | 764 | 5.928571 | 0.326531 | 0.22031 | 0.302926 | 0.185886 | 0.55938 | 0.499139 | 0.268503 | 0 | 0 | 0 | 0 | 0 | 0.120419 | 764 | 17 | 142 | 44.941176 | 0.864583 | 0 | 0 | 0 | 0 | 0 | 0.362565 | 0.192408 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | false | 0 | 0.2 | 0 | 0.2 | 0 | 0 | 0 | 0 | null | 1 | 1 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 3 |
dbb668a13b7b05607d5c22b67507cfb624c69cec | 2,439 | py | Python | icevision/imports.py | adamfarquhar/icevision | f6e9f54773ba877be0f363769d512c04ce7e5a10 | [
"Apache-2.0"
] | null | null | null | icevision/imports.py | adamfarquhar/icevision | f6e9f54773ba877be0f363769d512c04ce7e5a10 | [
"Apache-2.0"
] | null | null | null | icevision/imports.py | adamfarquhar/icevision | f6e9f54773ba877be0f363769d512c04ce7e5a10 | [
"Apache-2.0"
] | null | null | null | import sys, os, re, shutil, typing, itertools, operator, math, warnings, json, random
import functools, io, cv2, mimetypes, torch, torchvision, dataclasses, zipfile, pickle
from copy import copy, deepcopy
from pdb import set_trace
from dataclasses import dataclass
from fastcore.foundation import *
from fastcore.basics import *
import numpy as np
import torch.nn as nn
import torch.optim.lr_scheduler as lr_scheduler
import matplotlib.pyplot as plt
from types import (
BuiltinFunctionType,
BuiltinMethodType,
MethodType,
FunctionType,
SimpleNamespace,
)
from abc import (
ABC,
abstractmethod,
abstractproperty,
abstractclassmethod,
abstractstaticmethod,
)
from pathlib import Path
from collections import defaultdict, OrderedDict, namedtuple
from enum import Enum
from tqdm.auto import tqdm
from pycocotools import mask as mask_utils
from contextlib import contextmanager
from typing import *
from operator import itemgetter, attrgetter
from functools import partial, reduce
from torch import tensor, Tensor
from torch.utils.data import DataLoader
from torch.optim import SGD, Adam, AdamW, Adagrad, Adadelta, RMSprop
from torch.optim.lr_scheduler import (
LambdaLR,
StepLR,
MultiStepLR,
MultiplicativeLR,
OneCycleLR,
CosineAnnealingLR,
CosineAnnealingWarmRestarts,
)
from torchvision.transforms.functional import to_tensor as im2tensor
from loguru import logger
# Soft imports
from icevision.soft_dependencies import SoftDependencies
if SoftDependencies.fastai:
import fastai.vision.all as fastai
if SoftDependencies.pytorch_lightning:
import pytorch_lightning as pl
from pytorch_lightning import loggers as pl_loggers
if SoftDependencies.wandb:
import wandb
if SoftDependencies.sklearn:
import sklearn
# TODO: Stop importing partial from fastcore and move this to utils
class partial:
"""Wraps functools.partial, same functionality.
Modifies the original partial `__repr__` and `__str__` in other to fix #270
"""
def __init__(self, func, *args, **kwargs):
self._partial = functools.partial(func, *args, **kwargs)
def __call__(self, *args, **kwargs):
return self._partial(*args, **kwargs)
def __str__(self):
name = self._partial.func.__name__
partial_str = str(self._partial)
return re.sub(r"<.+>", name, partial_str)
def __repr__(self):
return str(self)
| 25.946809 | 86 | 0.753998 | 295 | 2,439 | 6.081356 | 0.464407 | 0.020067 | 0.013378 | 0.023411 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0.002503 | 0.180812 | 2,439 | 93 | 87 | 26.225806 | 0.895395 | 0.082411 | 0 | 0 | 0 | 0 | 0.0018 | 0 | 0 | 0 | 0 | 0.010753 | 0 | 1 | 0.057971 | false | 0 | 0.492754 | 0.028986 | 0.608696 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | null | 0 | 0 | 1 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 1 | 0 | 0 | 3 |
dbd10b530e1efbdd7bfcde5fecee46c89eefe1da | 276 | py | Python | test/test_astrofunc.py | LBJ-Wade/astrofunc_lensing_profile | d2223705bc44d07575a5e93291375ab8e69ebfa8 | [
"MIT"
] | null | null | null | test/test_astrofunc.py | LBJ-Wade/astrofunc_lensing_profile | d2223705bc44d07575a5e93291375ab8e69ebfa8 | [
"MIT"
] | null | null | null | test/test_astrofunc.py | LBJ-Wade/astrofunc_lensing_profile | d2223705bc44d07575a5e93291375ab8e69ebfa8 | [
"MIT"
] | null | null | null | """
Tests for `astrofunc` module.
"""
import pytest
from astrofunc import astrofunc
class TestAstrofunc(object):
@classmethod
def setup_class(cls):
pass
def test_something(self):
pass
@classmethod
def teardown_class(cls):
pass
| 13.8 | 31 | 0.648551 | 30 | 276 | 5.866667 | 0.633333 | 0.159091 | 0.136364 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0.268116 | 276 | 19 | 32 | 14.526316 | 0.871287 | 0.105072 | 0 | 0.454545 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0.272727 | false | 0.272727 | 0.181818 | 0 | 0.545455 | 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 |
dbd5f55e9fcbdc7e7a7c822dc2677d86a228591e | 2,521 | py | Python | sdk/python/pulumi_aws/cloudfront/__init__.py | sibuthomasmathew/pulumi-aws | 6351f2182eb6f693d4e09e4136c385adfa0ab674 | [
"ECL-2.0",
"Apache-2.0"
] | null | null | null | sdk/python/pulumi_aws/cloudfront/__init__.py | sibuthomasmathew/pulumi-aws | 6351f2182eb6f693d4e09e4136c385adfa0ab674 | [
"ECL-2.0",
"Apache-2.0"
] | null | null | null | sdk/python/pulumi_aws/cloudfront/__init__.py | sibuthomasmathew/pulumi-aws | 6351f2182eb6f693d4e09e4136c385adfa0ab674 | [
"ECL-2.0",
"Apache-2.0"
] | null | null | null | # coding=utf-8
# *** WARNING: this file was generated by the Pulumi Terraform Bridge (tfgen) Tool. ***
# *** Do not edit by hand unless you're certain you know what you are doing! ***
# Export this package's modules as members:
from .cache_policy import *
from .distribution import *
from .get_cache_policy import *
from .get_distribution import *
from .get_origin_request_policy import *
from .origin_access_identity import *
from .origin_request_policy import *
from .public_key import *
from .realtime_log_config import *
from ._inputs import *
from . import outputs
def _register_module():
import pulumi
from .. import _utilities
class Module(pulumi.runtime.ResourceModule):
_version = _utilities.get_semver_version()
def version(self):
return Module._version
def construct(self, name: str, typ: str, urn: str) -> pulumi.Resource:
if typ == "aws:cloudfront/cachePolicy:CachePolicy":
return CachePolicy(name, pulumi.ResourceOptions(urn=urn))
elif typ == "aws:cloudfront/distribution:Distribution":
return Distribution(name, pulumi.ResourceOptions(urn=urn))
elif typ == "aws:cloudfront/originAccessIdentity:OriginAccessIdentity":
return OriginAccessIdentity(name, pulumi.ResourceOptions(urn=urn))
elif typ == "aws:cloudfront/originRequestPolicy:OriginRequestPolicy":
return OriginRequestPolicy(name, pulumi.ResourceOptions(urn=urn))
elif typ == "aws:cloudfront/publicKey:PublicKey":
return PublicKey(name, pulumi.ResourceOptions(urn=urn))
elif typ == "aws:cloudfront/realtimeLogConfig:RealtimeLogConfig":
return RealtimeLogConfig(name, pulumi.ResourceOptions(urn=urn))
else:
raise Exception(f"unknown resource type {typ}")
_module_instance = Module()
pulumi.runtime.register_resource_module("aws", "cloudfront/cachePolicy", _module_instance)
pulumi.runtime.register_resource_module("aws", "cloudfront/distribution", _module_instance)
pulumi.runtime.register_resource_module("aws", "cloudfront/originAccessIdentity", _module_instance)
pulumi.runtime.register_resource_module("aws", "cloudfront/originRequestPolicy", _module_instance)
pulumi.runtime.register_resource_module("aws", "cloudfront/publicKey", _module_instance)
pulumi.runtime.register_resource_module("aws", "cloudfront/realtimeLogConfig", _module_instance)
_register_module()
| 45.836364 | 103 | 0.719159 | 270 | 2,521 | 6.525926 | 0.311111 | 0.088536 | 0.054484 | 0.095346 | 0.398411 | 0.3479 | 0.3479 | 0.320658 | 0.320658 | 0 | 0 | 0.000486 | 0.183657 | 2,521 | 54 | 104 | 46.685185 | 0.855685 | 0.08687 | 0 | 0 | 1 | 0 | 0.20505 | 0.176752 | 0 | 0 | 0 | 0 | 0 | 1 | 0.073171 | false | 0 | 0.317073 | 0.02439 | 0.609756 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 1 | 0 | 0 | 3 |
917522b35be48c41bceb432d25d0e6f64dabba04 | 175 | py | Python | services/heartbeat/urls.py | Bellboy-Capstone/Services | 36888d90fe7ba4b2afc2ea8ad4839a8e13c7f98b | [
"MIT"
] | null | null | null | services/heartbeat/urls.py | Bellboy-Capstone/Services | 36888d90fe7ba4b2afc2ea8ad4839a8e13c7f98b | [
"MIT"
] | 5 | 2020-10-07T16:31:54.000Z | 2022-03-01T22:16:54.000Z | services/heartbeat/urls.py | Bellboy-Capstone/Services | 36888d90fe7ba4b2afc2ea8ad4839a8e13c7f98b | [
"MIT"
] | 2 | 2020-10-04T23:57:00.000Z | 2020-10-10T03:14:18.000Z | from django.urls import path
from services.heartbeat.views import HeartbeatView
app_name = "heartbeat"
urlpatterns = [path("", view=HeartbeatView.as_view(), name="update")]
| 25 | 69 | 0.771429 | 22 | 175 | 6.045455 | 0.681818 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0.102857 | 175 | 6 | 70 | 29.166667 | 0.847134 | 0 | 0 | 0 | 0 | 0 | 0.085714 | 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 |
9191dc582d64fa722fbc239b20ad294871203ce6 | 78 | py | Python | couchbase_tests/__init__.py | couchbase/couchbase-python-client | 99ec055835f5aef0cd07905497b3ab4bb3cbbc32 | [
"Apache-2.0"
] | 189 | 2015-01-07T18:34:31.000Z | 2022-03-21T17:41:56.000Z | couchbase_tests/__init__.py | couchbase/couchbase-python-client | 99ec055835f5aef0cd07905497b3ab4bb3cbbc32 | [
"Apache-2.0"
] | 24 | 2015-05-19T14:00:16.000Z | 2022-03-16T22:01:30.000Z | couchbase_tests/__init__.py | couchbase/couchbase-python-client | 99ec055835f5aef0cd07905497b3ab4bb3cbbc32 | [
"Apache-2.0"
] | 60 | 2015-03-10T22:12:50.000Z | 2022-03-07T21:57:40.000Z | caseslist = []
try:
import couchbase.tests
except BaseException:
pass
| 13 | 26 | 0.705128 | 8 | 78 | 6.875 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0.217949 | 78 | 5 | 27 | 15.6 | 0.901639 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | false | 0.2 | 0.2 | 0 | 0.2 | 0 | 1 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 0 | 0 | 0 | 3 |
91ac885eab69828adea6ebbbfbe91408ea215d04 | 66 | py | Python | schema.py | rpinaa/python-flask-microservice | 3e479bd1653f8e846ae0b84ffb4f20481dfc7c5d | [
"MIT"
] | 1 | 2019-09-23T20:00:52.000Z | 2019-09-23T20:00:52.000Z | schema.py | rpinaa/python-flask-microservice | 3e479bd1653f8e846ae0b84ffb4f20481dfc7c5d | [
"MIT"
] | null | null | null | schema.py | rpinaa/python-flask-microservice | 3e479bd1653f8e846ae0b84ffb4f20481dfc7c5d | [
"MIT"
] | null | null | null | from flask_marshmallow import Marshmallow
schema = Marshmallow()
| 16.5 | 41 | 0.833333 | 7 | 66 | 7.714286 | 0.714286 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0.121212 | 66 | 3 | 42 | 22 | 0.931034 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | false | 0 | 0.5 | 0 | 0.5 | 0 | 1 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 0 | 0 | 3 |
91c0806fd7566a9a17f46bf8b5cb6996e1f85271 | 29,159 | py | Python | python/pygimli/physics/em/hemmodelling.py | mjziebarth/gimli | 196ac4d6dd67e0326cccc44a87b367f64051e490 | [
"Apache-2.0"
] | 3 | 2021-07-10T00:56:59.000Z | 2022-02-17T12:43:38.000Z | python/pygimli/physics/em/hemmodelling.py | ivek1312/gimli | 5fafebb7c96dd0e04e2616df402fa27a01609d63 | [
"Apache-2.0"
] | null | null | null | python/pygimli/physics/em/hemmodelling.py | ivek1312/gimli | 5fafebb7c96dd0e04e2616df402fa27a01609d63 | [
"Apache-2.0"
] | 1 | 2022-03-29T04:28:40.000Z | 2022-03-29T04:28:40.000Z | #!/usr/bin/env python
# coding: utf-8
"""Classes for modelling helicopter electromagnetics (HEM) using VMD solvers"""
import numpy as np
import pygimli as pg
from math import sqrt, pi
from matplotlib.colors import LinearSegmentedColormap
from matplotlib.cm import register_cmap
def registerDAEROcmap():
"""Standardized colormap from A-AERO projects (purple=0.3 to red=500)."""
CMY = np.array([
[127, 255, 31], [111, 255, 47], [95, 255, 63], [79, 255, 79],
[63, 255, 95], [47, 255, 111], [31, 255, 127], [16, 255, 159],
[0, 223, 159], [0, 191, 159], [0, 159, 207], [0, 127, 175],
[0, 95, 175], [0, 63, 175], [0, 47, 175], [0, 31, 191], [0, 0, 255],
[0, 0, 159], [15, 0, 127], [47, 0, 143], [79, 0, 143], [111, 0, 143],
[143, 0, 127], [159, 31, 63], [175, 47, 31], [207, 63, 0],
[223, 111, 0], [231, 135, 0], [239, 159, 0], [255, 191, 47],
[239, 199, 63], [223, 207, 79], [207, 239, 111]], dtype=float)
RGB = 1.0 - CMY/255
daero = LinearSegmentedColormap.from_list('D-AERO', RGB)
register_cmap(name='daero', cmap=daero)
return daero
class HEMmodelling(pg.ModellingBase):
"""HEM Airborne modelling class based on the BGR RESOLVE system."""
# Constants, should rather use pygiml/physics/constants
ep0 = 8.8542e-12
mu0 = 4e-7 * np.pi
c0 = sqrt(1. / ep0 / mu0)
fdefault = np.array([387.0, 1821.0, 8388.0, 41460.0, 133300.0], np.float)
rdefault = np.array([7.94, 7.93, 7.93, 7.91, 7.92], np.float)
scaling = 1e6
def __init__(self, nlay, height, f=None, r=None, **kwargs):
"""Initialize class with geometry
Parameters
----------
nlay : int
number of layers
height : float
helicopter
f : array [BGR RESOLVE system 387Hz-133kHz]
frequency vector
r : array [BGR RESOLVE system 7.91-7.94]
distance vector
scaling : float
scaling factor or string (ppm=1e6, percent=1e2)
"""
# Attribute
self.nlay = nlay
self.height = height
self.f = np.asarray(f)
if r is None:
raise Exception("Specify separation value or vector!")
if 'scaling' in kwargs:
if kwargs['scaling'] == 'ppm':
self.scaling = 1e6
elif kwargs['scaling'] in ['percent', '%']:
self.scaling = 1e2
else:
self.scaling = kwargs['scaling']
if self.f is None:
self.f = self.fdefault
if isinstance(r, float) or isinstance(r, int):
self.r = np.ones_like(f, dtype=np.float) * r
else:
if len(r) == len(self.f):
self.r = r
else:
raise Exception('Length vector have to be matching!')
if self.r is None:
self.r = self.rdefault
self.wem = (2.0 * pi * self.f) ** 2 * self.ep0 * self.mu0
self.iwm = np.complex(0, 1) * 2.0 * pi * self.f * self.mu0
mesh = pg.createMesh1DBlock(nlay)
pg.ModellingBase.__init__(self, mesh)
def response(self, par):
"""Compute response vector by pasting in-phase and out-phase data."""
ip, op = self.vmd_hem(self.height,
np.asarray(par)[self.nlay-1:self.nlay*2-1],
np.asarray(par)[:self.nlay-1])
# ip, op = self.vmd_hem(self.height,
# np.asarray(par(self.nlay-1, self.nlay*2-1)),
# np.asarray(par(0, self.nlay-1)))
return pg.cat(ip, op)
# Methoden
def calc_forward(self, x, h, rho, d, epr, mur, quasistatic=False):
"""Calculate forward response."""
field = np.zeros((self.f.size, x.size), np.complex)
# Forward calculation for background model
if d.size:
for m in range(x.size):
field[:, m] = self.vmd_hem(np.array([h[m]], np.float),
rho[:, m], d[:, m], epr[:, m],
mur[:, m], quasistatic).T[:, 0]
# für jede Frequenz
else:
for n in range(self.f.size):
for m in range(x.size):
field[n, m] = self.vmd_hem(np.array([h[n, m]], np.float),
np.array([rho[n, m]], np.float),
d,
np.array([epr[n, m]], np.float),
np.array([mur[n, m]], np.float),
quasistatic).T[n, 0]
return field
def downward(self, rho, d, z, epr, mur, lam):
"""Downward continuation of fields."""
# Anzahl der Schichten
nl = rho.size
# arrays anlegen
alpha = np.zeros((nl, lam.shape[1], self.f.size), np.complex)
b = np.zeros((nl, lam.shape[1], self.f.size), np.complex)
aa = np.zeros((nl, lam.shape[1], self.f.size), np.complex)
aap = np.zeros((nl, lam.shape[1], self.f.size), np.complex)
rho = rho[:, np.newaxis, np.newaxis] * np.ones(
(rho.size, lam.shape[1], self.f.size), np.float)
d = d[:, np.newaxis, np.newaxis] * np.ones(
(d.size, lam.shape[1], self.f.size), np.float)
h = np.insert(np.cumsum(d[:, 0, 0]), 0, 0)
epr = epr[:, np.newaxis, np.newaxis] * np.ones(
(epr.size, lam.shape[1], self.f.size), np.float)
mur = mur[:, np.newaxis, np.newaxis] * np.ones(
(mur.size, lam.shape[1], self.f.size), np.float)
lam = np.tile(lam, (nl, 1, 1))
# Ausbreitungskonstante
alpha = np.sqrt(lam ** 2 - np.tile(self.wem, (nl, lam.shape[1], 1)) *
epr * mur + np.tile(self.iwm, (nl, lam.shape[1], 1)) *
mur / rho)
if nl == 1: # homogenous halfspace
b1 = alpha.copy() # (1, 100, nfreq)
a = np.exp(-alpha * z)
ap = a.copy()
return b1, a, ap
elif nl > 1: # multi-layer case
# tanh num instabil tanh(x)=(exp(x)-exp(-x))/(exp(x)+exp(-x))
ealphad = np.exp(-2.0 * alpha[0:-1, :, :] * d)
talphad = (1.0 - ealphad) / (1.0 + ealphad)
b[-1, :, :] = np.copy(alpha[-1, :, :])
# rekursive Berechnung der Admittanzen an der Oberkante der Schicht
# von unten nach oben, für nl-1 Schichten
for n in range(nl-2, -1, -1):
b[n, :, :] = alpha[n, :, :] * \
(b[n+1, :, :] + alpha[n, :, :] * talphad[n, :, :]) / \
(alpha[n, :, :] + b[n+1, :, :] * talphad[n, :, :])
# Impedance
c = 1.0 / b
# b1 == 1. row in b (nl, 100, nfreq)
b1 = np.copy(b[0, :, :][np.newaxis, :, :]) # (1, 100, nfreq)
# Variation from one layer boundary to the other
for n in range(0, nl-1):
aa[n, :, :] = (b[n, :, :] + alpha[n, :, :]) / (
b[n+1, :, :] + alpha[n, :, :]) * \
np.exp(-alpha[n, :, :] * d[n, :, :])
aap[n, :, :] = (1.0 + alpha[n, :, :] * c[n, :, :]) / (
1.0 + alpha[n, :, :] * c[n+1, :, :]) * \
np.exp(-alpha[n, :, :] * d[n, :, :])
# Determin layer Index where z is
for n in range(0, nl-1):
if np.logical_and(z >= h[n], z < h[n+1]):
ind = n
try:
ind
except NameError:
ind = nl - 1
if (ind + 1) < nl:
a = np.prod(aa[:ind, :, :], 0) * 0.5 * \
(1.0 + b[ind, :, :] / alpha[ind, :, :]) * \
(np.exp(-alpha[ind, :, :] * (z - h[ind])) -
(b[ind+1, :, :] - alpha[ind, :, :]) /
(b[ind+1, :, :] + alpha[ind, :, :]) *
np.exp(-alpha[ind, :, :] *
(d[ind, :, :] + h[ind+1] - z)))
ap = np.prod(aap[:ind, :, :], 0) * 0.5 * \
(1.0 + alpha[ind, :, :] * c[ind, :, :]) * \
(np.exp(-alpha[ind, :, :] * (z - h[ind])) +
(1.0 - alpha[ind, :, :] * c[ind+1, :, :]) /
(1.0 + alpha[ind, :, :] * c[ind+1, :, :]) *
np.exp(-alpha[ind, :, :] *
(d[ind, :, :] + h[ind+1] - z)))
else:
a = np.prod(aa, 0) * np.exp(-alpha[ind, :, :] * (z - h[ind]))
ap = np.prod(aap, 0) * np.exp(-alpha[ind, :, :] * (z - h[ind]))
a = a[np.newaxis, :, :] # (1, 100, nfreq)
ap = ap[np.newaxis, :, :] # (1, 100, nfreq)
return b1, a, ap
def vmd_hem(self, h, rho, d, epr=1., mur=1., quasistatic=False):
"""Vertical magnetic dipole (VMD) response.
Parameters
----------
h : float
flight height
rho : array
resistivity vector
d : array
thickness vector
"""
# Filterkoeffizienten
if isinstance(epr, float):
epr = np.ones((len(rho),), np.float)*epr
if isinstance(mur, float):
mur = np.ones((len(rho),), np.float)*mur
fc0, nc, nc0 = hankelfc(3)
fc1, nc, nc0 = hankelfc(4)
# arrays anlegen
nf = len(self.f)
lam = np.zeros((1, nc, nf), np.float)
alpha0 = np.zeros((1, nc, nf), np.complex)
delta0 = np.zeros((1, nc, nf), np.complex)
delta1 = np.zeros((1, nc, nf), np.complex)
delta2 = np.zeros((1, nc, nf), np.complex)
delta3 = np.zeros((1, nc, nf), np.complex)
aux0 = np.zeros((1, nf), np.complex)
aux1 = np.zeros((1, nf), np.complex)
aux2 = np.zeros((1, nf), np.complex)
aux3 = np.zeros((1, nf), np.complex)
Z = np.zeros(nf, np.complex)
# r0
r0 = np.copy(self.r)
# determine optimum r0 (shift nodes) for f > 1e4 and h > 100
if quasistatic:
index = np.zeros(self.f.shape, np.bool)
else:
index = np.logical_and(self.f >= 1e4, h >= 100.0)
if np.any(index):
opt = np.floor(10.0 * np.log10(
self.r[index] * 2.0 * np.pi * self.f[index] / self.c0) + nc0)
r0[index] = self.c0 / (2.0 * np.pi * self.f[index]) * 10.0 ** (
(opt + 0.5 - nc0) / 10.0)
# Bereitstellung der Wellenzahlen
n = np.arange(nc0 - nc, nc0, 1, np.float)
q = 0.1 * np.log(10)
lam = np.reshape(np.exp(-n[np.newaxis, :, np.newaxis] * q) /
r0[np.newaxis, np.newaxis, :], (-1, nc, r0.size))
# (1, 100, nfreq)
# Wellenzahl in Luft, quasistationäre Näherung
alpha0 = np.copy(lam) * np.complex(1, 0) # (1, 100, nfreq)
# Wellenzahl in Luft, vollständige Lösung für f > 1e4
if quasistatic:
index = np.zeros(self.f.shape, np.bool)
else:
index = self.f >= 1e4
if np.any(index):
alpha0[:, :, index] = np.sqrt(
lam[:, :, index]**2 - np.tile(self.wem[index], (1, nc, 1)) +
np.tile(self.iwm[index], (1, nc, 1)) / 1e9) # (1, 100 , nfreq)
# Admittanzen an der Oberfläche eines geschichteten Halbraums
b1, _, aap = self.downward(rho, d, 0.0, epr, mur, lam)
# Kernel functions
e = np.exp(-2.0 * h * alpha0) # (1, 100, nfreq)
delta0 = (b1 - alpha0 * mur[0]) / (b1 + alpha0 * mur[0]) * e
delta1 = (2 * mur[0]) / (b1 + alpha0 * mur[0]) * e # (1, 100, nfreq)
delta2 = 1 / h * e # (1, 100, nfreq)
delta3 = 1 / (2 * h) * e # (1, 100, nfreq)
# Faltung
# quasistationäre Näherung
aux0 = np.sum(delta0 * lam ** 3 / alpha0 *
np.tile(fc0[::-1].T[:, :, np.newaxis],
(1, 1, self.f.size)), 1, np.complex) / r0
# vollständige Lösung, partielle Integration
if np.any(index):
aux1 = np.sum(delta1 * lam ** 3 *
np.tile(fc0[::-1].T[:, :, np.newaxis],
(1, 1, self.f.size)), 1, np.complex) / r0
aux2 = np.sum(
delta2 * lam * np.tile(fc0[::-1].T[:, :, np.newaxis],
(1, 1, self.f.size)), 1, np.complex)/r0
aux3 = np.sum(delta3 * lam ** 2 *
np.tile(fc1[::-1].T[:, :, np.newaxis],
(1, 1, self.f.size)), 1, np.complex) / r0
# normiertes Sekundärfeld
# quasistationäre Näherung
Z = self.r ** 3 * aux0 * self.scaling
# vollständige Lösung
if np.any(index):
Z[:, index] = (-self.r[index]**3 * aux1[:, index] +
self.r[index]**3 * aux2[:, index] -
self.r[index]**4 * aux3[:, index]) * self.scaling
return np.real(Z[0]), np.imag(Z[0])
def vmd_total_Ef(self, h, z, rho, d, epr, mur, tm):
"""VMD E-phi field (not used actively)."""
# nur im HR
# Filterkoeffizienten
fc1, nc, nc0 = hankelfc(4)
# arrays anlegen
lam = np.zeros((1, nc, self.f.size), np.float)
alpha0 = np.zeros((1, nc, self.f.size), np.complex)
delta = np.zeros((1, nc, self.f.size), np.complex)
aux = np.zeros((1, self.f.size), np.complex)
Ef = np.zeros(self.f.size, np.complex)
# r0
r0 = np.copy(self.r)
# Bereitstellung der Wellenzahlen
n = np.arange(nc0 - nc, nc0, 1, np.float)
q = 0.1 * np.log(10)
lam = np.reshape(np.exp(-n[np.newaxis, :, np.newaxis] * q) /
r0[np.newaxis, np.newaxis, :], (-1, nc, r0.size))
# Wellenzahl in Luft, vollständige Lösung
alpha0 = np.sqrt(lam ** 2 - np.tile(self.wem, (1, nc, 1)) +
np.tile(self.iwm, (1, nc, 1)) / 1e9)
# Admittanzen an der Oberfläche eines geschichteten Halbraums
b1, aa, _ = self.downward(rho, d, z, epr, mur, lam)
# Kernfunktionen
e = np.exp(-h * alpha0) # (1, 100, nfreq)
delta = 2.0 / (alpha0 + b1) * e # (1, 100, nfreq)
# Faltung
# vollständige Lösung
aux = np.sum(delta*lam**2*aa*np.tile(fc1[::-1].T[:, :, np.newaxis],
(1, 1, self.f.size)), 1,
np.complex) / r0 # (1, nfreq)
# absolute Feldwerte
# vollständige Lösung
Ef = -tm * self.iwm / (4.0 * np.pi) * aux
return Ef
def hankelfc(order):
"""Filter coefficients for Hankel transformation."""
if order == 1: # sin
fc = np.array([
2.59526236e-7, 3.66544843e-7, 5.17830795e-7, 7.31340622e-7,
1.03322805e-6, 1.45918500e-6, 2.06161065e-6, 2.91137793e-6,
4.11357863e-6, 5.80876420e-6, 8.20798075e-6, 1.15895083e-5,
1.63778560e-5, 2.31228459e-5, 3.26800649e-5, 4.61329334e-5,
6.52101085e-5, 9.20390575e-5, 1.30122935e-4, 1.83620431e-4,
2.59656626e-4, 3.66311982e-4, 5.18141184e-4, 7.30717340e-4,
1.03392184e-3, 1.45742714e-3, 2.06292302e-3, 2.90599911e-3,
4.11471902e-3, 5.79042763e-3, 8.20004722e-3, 1.15192930e-2,
1.63039133e-2, 2.28257757e-2, 3.22249222e-2, 4.47864328e-2,
6.27329625e-2, 8.57059100e-2, 1.17418314e-1, 1.53632655e-1,
1.97717964e-1, 2.28849849e-1, 2.40311038e-1, 1.65409220e-1,
2.84701476e-3, -2.88016057e-1, -3.69097406e-1, -2.50107514e-2,
5.71811256e-1, -3.92261572e-1, 7.63280044e-2, 5.16233994e-2,
-6.48012082e-2, 4.89047141e-2, -3.26936331e-2, 2.10539842e-2,
-1.33862549e-2, 8.47124695e-3, -5.35123972e-3, 3.37796651e-3,
-2.13174466e-3, 1.34513833e-3, -8.48749612e-4, 5.35531006e-4,
-3.37898780e-4, 2.13200109e-4, -1.34520273e-4, 8.48765787e-5,
-5.35535069e-5, 3.37899801e-5, -2.13200365e-5, 1.34520337e-5,
-8.48765949e-6, 5.35535110e-6, -3.37899811e-6, 2.13200368e-6,
-1.34520338e-6, 8.48765951e-7, -5.35535110e-7, 3.37899811e-7],
np.float)
nc = np.int(80)
nc0 = np.int(40)
elif order == 2: # cos
fc = np.array([
1.63740363e-7, 1.83719709e-7, 2.06136904e-7, 2.31289411e-7,
2.59510987e-7, 2.91176117e-7, 3.26704977e-7, 3.66569013e-7,
4.11297197e-7, 4.61483045e-7, 5.17792493e-7, 5.80972733e-7,
6.51862128e-7, 7.31401337e-7, 8.20645798e-7, 9.20779729e-7,
1.03313185e-6, 1.15919300e-6, 1.30063594e-6, 1.45933752e-6,
1.63740363e-6, 1.83719709e-6, 2.06136904e-6, 2.31289411e-6,
2.59510987e-6, 2.91176117e-6, 3.26704977e-6, 3.66569013e-6,
4.11297197e-6, 4.61483045e-6, 5.17792493e-6, 5.80972733e-6,
6.51862128e-6, 7.31401337e-6, 8.20645798e-6, 9.20779729e-6,
1.03313185e-5, 1.15919300e-5, 1.30063594e-5, 1.45933752e-5,
1.63740363e-5, 1.83719709e-5, 2.06136904e-5, 2.31289411e-5,
2.59510987e-5, 2.91176117e-5, 3.26704977e-5, 3.66569013e-5,
4.11297197e-5, 4.61483045e-5, 5.17792493e-5, 5.80972733e-5,
6.51862128e-5, 7.31401337e-5, 8.20645798e-5, 9.20779729e-5,
1.03313185e-4, 1.15919300e-4, 1.30063594e-4, 1.45933752e-4,
1.63740363e-4, 1.83719709e-4, 2.06136904e-4, 2.31289411e-4,
2.59510987e-4, 2.91176117e-4, 3.26704976e-4, 3.66569013e-4,
4.11297197e-4, 4.61483045e-4, 5.17792493e-4, 5.80972733e-4,
6.51862127e-4, 7.31401337e-4, 8.20645797e-4, 9.20779730e-4,
1.03313185e-3, 1.15919300e-3, 1.30063593e-3, 1.45933753e-3,
1.63740362e-3, 1.83719710e-3, 2.06136901e-3, 2.31289411e-3,
2.59510977e-3, 2.91176115e-3, 3.26704948e-3, 3.66569003e-3,
4.11297114e-3, 4.61483003e-3, 5.17792252e-3, 5.80972566e-3,
6.51861416e-3, 7.31400728e-3, 8.20643673e-3, 9.20777603e-3,
1.03312545e-2, 1.15918577e-2, 1.30061650e-2, 1.45931339e-2,
1.63734419e-2, 1.83711757e-2, 2.06118614e-2, 2.31263461e-2,
2.59454421e-2, 2.91092045e-2, 3.26529302e-2, 3.66298115e-2,
4.10749753e-2, 4.60613861e-2, 5.16081994e-2, 5.78193646e-2,
6.46507780e-2, 7.22544422e-2, 8.03873578e-2, 8.92661837e-2,
9.80670729e-2, 1.07049506e-1, 1.13757572e-1, 1.18327217e-1,
1.13965041e-1, 1.00497783e-1, 6.12958082e-2, -1.61234222e-4,
-1.11788551e-1, -2.27536948e-1, -3.39004453e-1, -2.25128800e-1,
8.98279919e-2, 5.12510388e-1, -1.31991937e-1, -3.35136479e-1,
3.64868100e-1, -2.34039961e-1, 1.32085237e-1, -7.56739672e-2,
4.52296662e-2, -2.78297002e-2, 1.73727753e-2, -1.09136894e-2,
6.87397283e-3, -4.33413470e-3, 2.73388730e-3, -1.72477355e-3,
1.08821012e-3, -6.86602007e-4, 4.33213523e-4, -2.73338487e-4,
1.72464733e-4, -1.08817842e-4, 6.86594042e-5, -4.33211523e-5,
2.73337984e-5, -1.72464607e-5, 1.08817810e-5, -6.86593962e-6,
4.33211503e-6, -2.73337979e-6, 1.72464606e-6, -1.08817810e-6,
6.86593961e-7, -4.33211503e-7, 2.73337979e-7, -1.72464606e-7],
np.float)
nc = np.int(164)
nc0 = np.int(122)
elif order == 3: # J0
fc = np.array([
2.89878288e-7, 3.64935144e-7, 4.59426126e-7, 5.78383226e-7,
7.28141338e-7, 9.16675639e-7, 1.15402625e-6, 1.45283298e-6,
1.82900834e-6, 2.30258511e-6, 2.89878286e-6, 3.64935148e-6,
4.59426119e-6, 5.78383236e-6, 7.28141322e-6, 9.16675664e-6,
1.15402621e-5, 1.45283305e-5, 1.82900824e-5, 2.30258527e-5,
2.89878259e-5, 3.64935186e-5, 4.59426051e-5, 5.78383329e-5,
7.28141144e-5, 9.16675882e-5, 1.15402573e-4, 1.45283354e-4,
1.82900694e-4, 2.30258630e-4, 2.89877891e-4, 3.64935362e-4,
4.59424960e-4, 5.78383437e-4, 7.28137738e-4, 9.16674828e-4,
1.15401453e-3, 1.45282561e-3, 1.82896826e-3, 2.30254535e-3,
2.89863979e-3, 3.64916703e-3, 4.59373308e-3, 5.78303238e-3,
7.27941497e-3, 9.16340705e-3, 1.15325691e-2, 1.45145832e-2,
1.82601199e-2, 2.29701042e-2, 2.88702619e-2, 3.62691810e-2,
4.54794031e-2, 5.69408192e-2, 7.09873072e-2, 8.80995426e-2,
1.08223889e-1, 1.31250483e-1, 1.55055715e-1, 1.76371506e-1,
1.85627738e-1, 1.69778044e-1, 1.03405245e-1, -3.02583233e-2,
-2.27574393e-1, -3.62173217e-1, -2.05500446e-1, 3.37394873e-1,
3.17689897e-1, -5.13762160e-1, 3.09130264e-1, -1.26757592e-1,
4.61967890e-2, -1.80968674e-2, 8.35426050e-3, -4.47368304e-3,
2.61974783e-3, -1.60171357e-3, 9.97717882e-4, -6.26275815e-4,
3.94338818e-4, -2.48606354e-4, 1.56808604e-4, -9.89266288e-5,
6.24152398e-5, -3.93805393e-5, 2.48472358e-5, -1.56774945e-5,
9.89181741e-6, -6.24131160e-6, 3.93800058e-6, -2.48471018e-6,
1.56774609e-6, -9.89180896e-7, 6.24130948e-7, -3.93800005e-7,
2.48471005e-7, -1.56774605e-7, 9.89180888e-8, -6.24130946e-8],
np.float)
nc = np.int(100)
nc0 = np.int(60)
elif order == 4: # J1
fc = np.array([
1.84909557e-13, 2.85321327e-13, 4.64471808e-13, 7.16694771e-13,
1.16670043e-12, 1.80025587e-12, 2.93061898e-12, 4.52203829e-12,
7.36138206e-12, 1.13588466e-11, 1.84909557e-11, 2.85321327e-11,
4.64471808e-11, 7.16694771e-11, 1.16670043e-10, 1.80025587e-10,
2.93061898e-10, 4.52203829e-10, 7.36138206e-10, 1.13588466e-9,
1.84909557e-9, 2.85321326e-9, 4.64471806e-9, 7.16694765e-9,
1.16670042e-8, 1.80025583e-8, 2.93061889e-8, 4.52203807e-8,
7.36138149e-8, 1.13588452e-7, 1.84909521e-7, 2.85321237e-7,
4.64471580e-7, 7.16694198e-7, 1.16669899e-6, 1.80025226e-6,
2.93060990e-6, 4.52201549e-6, 7.36132477e-6, 1.13587027e-5,
1.84905942e-5, 2.85312247e-5, 4.64449000e-5, 7.16637480e-5,
1.16655653e-4, 1.79989440e-4, 2.92971106e-4, 4.51975783e-4,
7.35565435e-4, 1.13444615e-3, 1.84548306e-3, 2.84414257e-3,
4.62194743e-3, 7.10980590e-3, 1.15236911e-2, 1.76434485e-2,
2.84076233e-2, 4.29770596e-2, 6.80332569e-2, 9.97845929e-2,
1.51070544e-1, 2.03540581e-1, 2.71235377e-1, 2.76073871e-1,
2.16691977e-1, -7.83723737e-2, -3.40675627e-1, -3.60693673e-1,
5.13024526e-1, -5.94724729e-2, -1.95117123e-1, 1.99235600e-1,
-1.38521553e-1, 8.79320859e-2, -5.50697146e-2, 3.45637848e-2,
-2.17527180e-2, 1.37100291e-2, -8.64656417e-3, 5.45462758e-3,
-3.44138864e-3, 2.17130686e-3, -1.36998628e-3, 8.64398952e-4,
-5.45397874e-4, 3.44122545e-4, -2.17126585e-4, 1.36997597e-4,
-8.64396364e-5, 5.45397224e-5, -3.44122382e-5, 2.17126544e-5,
-1.36997587e-5, 8.64396338e-6, -5.45397218e-6, 3.44122380e-6,
-2.17126543e-6, 1.36997587e-6, -8.64396337e-7, 5.45397218e-7],
np.float)
nc = np.int(100)
nc0 = np.int(60)
return (np.reshape(fc, (-1, 1)), nc, nc0) # (100,) -> (100, 1)
class HEMRhoModelling(HEMmodelling):
"""Airborne EM (HEM) Forward modelling class for Occam inversion."""
def __init__(self, dvec, height=1., **kwargs):
"""Init class by specifying frequencies and distances (s. HEMMod)."""
nlay = len(dvec) + 1
self.dvec = np.asarray(dvec)
self.zvec = np.hstack((0, np.cumsum(dvec)))
HEMmodelling.__init__(self, nlay, height, **kwargs)
self.mymesh = pg.createMesh1D(nlay)
self.setMesh(self.mymesh) # only for inversion
def response(self, res):
"""Forward response as combined in-phase and out-of-phase."""
ip, op = self.vmd_hem(self.height, rho=np.asarray(res), d=self.dvec)
return pg.cat(ip, op)
class FDEMResSusModelling(HEMmodelling):
"""FDEM block modelling class using both conductivity & permittivity."""
def __init__(self, nlay, height=1, **kwargs):
"""Init class (see HEMmodelling)."""
HEMmodelling.__init__(self, nlay, height, **kwargs)
self.scaling = 1e2
self.mymesh = pg.createMesh1DBlock(nlay, nProperties=2)
self.setMesh(self.mymesh) # only for inversion
# pg.ModellingBase.__init__(self, self.mymesh)
def response(self, par):
"""Response vector as combined in-phase and out-phase data."""
thk = np.asarray(par[:self.nlay-1], dtype=np.float)
res = np.asarray(par[self.nlay-1:2*self.nlay-1], dtype=np.float)
mur = np.asarray(par[2*self.nlay-1:3*self.nlay-1], dtype=np.float) + 1
ip, op = self.vmd_hem(self.height, rho=res, d=thk, mur=mur)
return pg.cat(ip, op)
class HEMRhoSusModelling(HEMmodelling):
"""Airborne EM (HEM) Forward modelling class for Occam inversion."""
def __init__(self, dvec, *args, **kwargs):
""" not yet working! """
self.nlay = len(dvec) + 1
self.dvec = np.asarray(dvec)
self.zvec = np.hstack((0, np.cumsum(dvec)))
HEMmodelling.__init__(self, self.nlay, *args, **kwargs)
self.mymesh = pg.createMesh1D(self.nlay, nProperties=2)
self.setMesh(self.mymesh) # only for inversion
def response(self, model):
"""Response vector as combined in-phase and out-phase data."""
res = np.asarray(model[:self.nlay])
mur = np.asarray(model[self.nlay:]) + 1
ip, op = self.vmd_hem(self.height, rho=res, d=self.dvec, mur=mur)
return pg.cat(ip, op)
class FDEMLCIFOP(pg.ModellingBase):
"""FDEM 2d-LCI modelling class based on Block matrices."""
def __init__(self, data, nlay=2, verbose=False, f=None, r=None):
"""Parameters: FDEM data class and number of layers."""
super(FDEMLCIFOP, self).__init__(verbose)
self.nlay = nlay
self.FOP = data.FOP(nlay)
self.nx = len(data.x)
self.nf = len(data.freq())
self.np = 2 * nlay - 1
self.mesh2d = pg.createMesh2D(self.np, self.nx)
self.mesh2d.rotate(pg.RVector3(0, 0, -np.pi/2))
self.setMesh(self.mesh2d)
self.J = pg.RBlockMatrix()
self.FOP1d = []
for i in range(self.nx):
self.FOP1d.append(HEMmodelling(nlay, data.z[i], f, r))
n = self.J.addMatrix(self.FOP1d[-1].jacobian())
self.J.addMatrixEntry(n, self.nf*2*i, self.np*i)
self.setJacobian(self.J)
def response(self, model):
"""Cut together forward responses of all soundings."""
modA = np.reshape(model, (self.nx, self.np))
resp = pg.RVector(0)
for i, modi in enumerate(modA):
resp = pg.cat(resp, self.FOP1d[i].response(modi))
return resp
def createJacobian(self, model):
"""Fill the individual blocks of the Block-Jacobi matrix."""
modA = np.reshape(model, (self.nx, self.np))
for i, modi in enumerate(modA):
self.FOP1d[i].createJacobian(modi)
class FDEM2dFOP(pg.ModellingBase):
"""FDEM 2d-LCI modelling class based on BlockMatrices."""
def __init__(self, data, nlay=2, verbose=False):
"""Parameters: FDEM data class and number of layers."""
super(FDEM2dFOP, self).__init__(verbose)
self.nlay = nlay
self.FOP = data.FOP(nlay)
self.nx = len(data.x)
self.nf = len(data.freq())
npar = 2 * nlay - 1
self.mesh2d = pg.Mesh()
self.mesh2d.create2DGrid(range(npar+1), range(self.nx+1))
self.setMesh(self.mesh2d)
self.J = pg.RBlockMatrix()
self.FOP1d = []
for i in range(self.nx):
self.FOP1d.append(HEMmodelling(nlay, data.z[i]))
n = self.J.addMatrix(self.FOP1d[-1].jacobian())
self.J.addMatrixEntry(n, self.nf*2*i, npar*i)
self.J.recalcMatrixSize()
print(self.J.rows(), self.J.cols())
self.setJacobian(self.J)
def response(self, model):
"""Response as pasted forward responses from all soundings."""
modA = np.reshape(model, (self.nx, self.nlay*2-1))
resp = pg.RVector(0)
for i, modi in enumerate(modA):
resp = pg.cat(resp, self.FOP1d[i].response(modi))
return resp
def createJacobian(self, model):
"""Fill Jacobian (block) matrix by computing each block."""
modA = np.reshape(model, (self.nx, self.nlay*2-1))
for i in range(self.nx):
self.FOP1d[i].createJacobian(modA[i])
if __name__ == '__main__':
numlay = 3
height = np.float(30.0)
resistivity = np.array([1000.0, 100.0, 1000.0], np.float)
thickness = np.array([22.0, 29.0], np.float)
f = HEMmodelling(numlay, height, r=10) # frequency, separation)
IP, OP = f.vmd_hem(height, resistivity, thickness)
print(IP, OP)
| 47.490228 | 79 | 0.526321 | 4,137 | 29,159 | 3.690597 | 0.19797 | 0.010807 | 0.011789 | 0.00917 | 0.337241 | 0.304231 | 0.258777 | 0.228386 | 0.185289 | 0.156602 | 0 | 0.260373 | 0.305738 | 29,159 | 613 | 80 | 47.5677 | 0.493776 | 0.062348 | 0 | 0.24307 | 0 | 0 | 0.005044 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | null | null | 0 | 0.010661 | null | null | 0.004264 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 3 |
91c62dfa43c182285e116d3662ecc53000a59b88 | 188 | py | Python | test_matrix.py | missKatiaPunter/numpy-starter | 0110057852b53cc9bec8f96cc599a9cc4f32fe7f | [
"MIT"
] | null | null | null | test_matrix.py | missKatiaPunter/numpy-starter | 0110057852b53cc9bec8f96cc599a9cc4f32fe7f | [
"MIT"
] | null | null | null | test_matrix.py | missKatiaPunter/numpy-starter | 0110057852b53cc9bec8f96cc599a9cc4f32fe7f | [
"MIT"
] | 1 | 2021-08-18T10:49:06.000Z | 2021-08-18T10:49:06.000Z | import pytest
import numpy as np
from matrix import mat_subset
a=np.arange(16).reshape(4,4)
def test_smoke():
assert 1+1==2
def test_mat_subset():
assert mat_subset([a]) == 9
| 13.428571 | 31 | 0.696809 | 34 | 188 | 3.705882 | 0.617647 | 0.214286 | 0.15873 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0.051948 | 0.180851 | 188 | 13 | 32 | 14.461538 | 0.766234 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0.25 | 1 | 0.25 | false | 0 | 0.375 | 0 | 0.625 | 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 | 1 | 0 | 0 | 0 | 0 | 3 |
91dd2e735069e8ad0bdabdb317835f94af79727d | 651 | py | Python | simple_calc.py | ka-suvorov/calcs | 7c740f86202c1092fe8be2123609c4e463dcd801 | [
"MIT"
] | null | null | null | simple_calc.py | ka-suvorov/calcs | 7c740f86202c1092fe8be2123609c4e463dcd801 | [
"MIT"
] | null | null | null | simple_calc.py | ka-suvorov/calcs | 7c740f86202c1092fe8be2123609c4e463dcd801 | [
"MIT"
] | null | null | null | #Simple calc
operations_math = ['+', '-', '*', '/']
print('This is simle calc')
try:
a = float(input('a = '))
b = float(input('b = '))
choice = input('Please input math operations: +, -, *, / and get result for you')
if choice == operations_math[0]:
print(a+b)
elif choice == operations_math[1]:
print(a-b)
print(b-a)
elif choice == operations_math[2]:
print(a*b)
elif choice == operations_math[3]:
print(a/b)
print(b/a)
else:
print('Incorrect input')
except ValueError:
print('Next time, please insert correct integer numbers!')
except ZeroDivisionError:
print('On zero share cannot be!')
| 24.111111 | 85 | 0.617512 | 89 | 651 | 4.460674 | 0.47191 | 0.176322 | 0.201511 | 0.18136 | 0.2267 | 0.2267 | 0.156171 | 0 | 0 | 0 | 0 | 0.007828 | 0.215054 | 651 | 26 | 86 | 25.038462 | 0.76908 | 0.016897 | 0 | 0 | 0 | 0 | 0.2969 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | false | 0 | 0 | 0 | 0 | 0.454545 | 0 | 0 | 0 | null | 0 | 1 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 3 |
37eea5753a8da582a5c1230237ffcf172d50db45 | 1,442 | py | Python | tests/charts/retrieveChartTest.py | nathanielwarner/seatsio-python | e731ed0c37f2496c620b40e38527a58bf3b9a9b2 | [
"MIT"
] | 2 | 2018-03-29T18:21:01.000Z | 2022-02-08T10:49:47.000Z | tests/charts/retrieveChartTest.py | nathanielwarner/seatsio-python | e731ed0c37f2496c620b40e38527a58bf3b9a9b2 | [
"MIT"
] | 7 | 2018-09-03T12:31:52.000Z | 2022-02-01T08:25:09.000Z | tests/charts/retrieveChartTest.py | nathanielwarner/seatsio-python | e731ed0c37f2496c620b40e38527a58bf3b9a9b2 | [
"MIT"
] | 2 | 2020-12-22T09:51:07.000Z | 2021-12-13T15:37:14.000Z | from seatsio.domain import Chart
from tests.seatsioClientTest import SeatsioClientTest
from tests.util.asserts import assert_that
class RetrieveChartTest(SeatsioClientTest):
def test(self):
chart = self.client.charts.create()
self.client.charts.add_tag(chart.key, "tag1")
self.client.charts.add_tag(chart.key, "tag2")
retrieved_chart = self.client.charts.retrieve(chart.key)
assert_that(retrieved_chart).is_instance(Chart)
assert_that(retrieved_chart.id).is_not_zero()
assert_that(retrieved_chart.key).is_not_blank()
assert_that(retrieved_chart.status).is_equal_to("NOT_USED")
assert_that(retrieved_chart.name).is_equal_to("Untitled chart")
assert_that(retrieved_chart.published_version_thumbnail_url).is_not_blank()
assert_that(retrieved_chart.draft_version_thumbnail_url).is_none()
assert_that(retrieved_chart.events).is_none()
assert_that(retrieved_chart.tags).contains_exactly_in_any_order("tag1", "tag2")
assert_that(retrieved_chart.archived).is_false()
def testWithEvents(self):
chart = self.client.charts.create()
event1 = self.client.events.create(chart.key)
event2 = self.client.events.create(chart.key)
retrieved_chart = self.client.charts.retrieve_with_events(chart.key)
assert_that(retrieved_chart.events).extracting("id").contains_exactly(event2.id, event1.id)
| 42.411765 | 99 | 0.739945 | 187 | 1,442 | 5.411765 | 0.31016 | 0.179842 | 0.206522 | 0.26087 | 0.513834 | 0.444664 | 0.126482 | 0 | 0 | 0 | 0 | 0.006557 | 0.153953 | 1,442 | 33 | 100 | 43.69697 | 0.822951 | 0 | 0 | 0.08 | 0 | 0 | 0.027739 | 0 | 0 | 0 | 0 | 0 | 0.48 | 1 | 0.08 | false | 0 | 0.12 | 0 | 0.24 | 0 | 0 | 0 | 0 | null | 0 | 1 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 3 |
37fd0322847c083a3eb19f16486f5323691d93fb | 1,266 | py | Python | containers/base/python/worker/worker_base.py | m4rc1e/fontbakery-dashboard | 843efafc8c51b0d3905e552638b570bc22a4a5ad | [
"Apache-2.0"
] | 26 | 2017-05-10T12:45:51.000Z | 2021-04-30T18:39:04.000Z | containers/base/python/worker/worker_base.py | m4rc1e/fontbakery-dashboard | 843efafc8c51b0d3905e552638b570bc22a4a5ad | [
"Apache-2.0"
] | 157 | 2017-05-09T20:23:54.000Z | 2021-04-30T18:37:33.000Z | containers/base/python/worker/worker_base.py | m4rc1e/fontbakery-dashboard | 843efafc8c51b0d3905e552638b570bc22a4a5ad | [
"Apache-2.0"
] | 8 | 2017-05-26T00:21:29.000Z | 2020-06-26T09:43:58.000Z | #!/usr/bin/env python
from __future__ import print_function, division, unicode_literals
class WorkerError(Exception):
pass
class PreparationError(WorkerError):
pass
class WorkerBase:
"""In a sub-class define `__init__`, it's properties names are used
for dependency injection. Have a look into worker-launcher to see how
this is done.
"""
def JobType():
"""JobType is expected to be a protocol buffers message constructor"""
raise NotImplementedError('`JobType` method must be set as class '
'property by sub-class.');
def run(self):
"""Run the job, exceptions will be caught and passed to`finalize`."""
raise NotImplementedError('`run` method must be implemented by sub-class.');
def finalize(self, tb_str, *exc):
"""If `run` failed and raised `tb_str` is a string of the traceback.
If run finished regularly `tb_str` is None and there was no exception.
return: If there was no exception, this is irrelevant.
return: If there was an exception, return `Frue` if it has been dealt
with in this method, otherwise return `False` to escalate the exception
to the next level.
"""
raise NotImplementedError('`finalize` method must be implemented by sub-class.');
| 30.878049 | 85 | 0.701422 | 177 | 1,266 | 4.943503 | 0.553672 | 0.036571 | 0.041143 | 0.029714 | 0.075429 | 0.075429 | 0.075429 | 0 | 0 | 0 | 0 | 0 | 0.21169 | 1,266 | 40 | 86 | 31.65 | 0.876754 | 0.515798 | 0 | 0.153846 | 0 | 0 | 0.280357 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0.230769 | false | 0.153846 | 0.076923 | 0 | 0.538462 | 0.076923 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 1 | 0 | 0 | 1 | 0 | 0 | 3 |
531968c365ee0c4302d1b3a27a0995edd0eff29d | 8,917 | py | Python | scamp_python_module/coopeliaAPI/sendMovementSequence-pts.py | yananliusdu/scamp5d_interface | c922f72a63d9dae1fecfa90a5051e08ce1f6facf | [
"MIT"
] | 2 | 2022-03-14T16:01:53.000Z | 2022-03-25T09:14:21.000Z | scamp_python_module/coopeliaAPI/sendMovementSequence-pts.py | yananliusdu/scamp5d_interface | c922f72a63d9dae1fecfa90a5051e08ce1f6facf | [
"MIT"
] | null | null | null | scamp_python_module/coopeliaAPI/sendMovementSequence-pts.py | yananliusdu/scamp5d_interface | c922f72a63d9dae1fecfa90a5051e08ce1f6facf | [
"MIT"
] | 1 | 2022-03-25T07:16:57.000Z | 2022-03-25T07:16:57.000Z | import b0RemoteApi
import time
import math
with b0RemoteApi.RemoteApiClient('b0RemoteApi_pythonClient','b0RemoteApi',60) as client:
client.executedMovId='notReady'
targetArm='threadedBlueArm'
#targetArm='nonThreadedRedArm'
stringSignalName=targetArm+'_executedMovId'
def waitForMovementExecuted(id):
while client.executedMovId!=id:
client.simxSpinOnce()
def executedMovId_callback(msg):
if type(msg[1])==bytes:
msg[1]=msg[1].decode('ascii') # python2/python3 differences
client.executedMovId=msg[1]
# Subscribe to stringSignalName string signal:
client.simxGetStringSignal(stringSignalName,client.simxDefaultSubscriber(executedMovId_callback));
# Set-up some movement variables:
times=[0.000,0.050,0.100,0.150,0.200,0.250,0.300,0.350,0.400,0.450,0.500,0.550,0.600,0.650,0.700,0.750,0.800,0.850,0.900,0.950,1.000,1.050,1.100,1.150,1.200,1.250,1.300,1.350,1.400,1.450,1.500,1.550,1.600,1.650,1.700,1.750,1.800,1.850]
j1=[0.000,0.000,0.002,0.009,0.022,0.042,0.068,0.100,0.139,0.185,0.237,0.296,0.360,0.431,0.506,0.587,0.669,0.753,0.838,0.923,1.008,1.091,1.170,1.243,1.308,1.365,1.414,1.455,1.491,1.519,1.541,1.557,1.566,1.569,1.570,1.571,1.571,1.571]
j2=[0.000,0.000,0.002,0.009,0.022,0.042,0.068,0.100,0.140,0.185,0.237,0.296,0.361,0.431,0.507,0.587,0.670,0.754,0.838,0.924,1.009,1.092,1.171,1.243,1.308,1.365,1.414,1.455,1.491,1.519,1.541,1.557,1.566,1.569,1.570,1.571,1.571,1.571]
j3=[0.000,0.000,-0.002,-0.009,-0.022,-0.042,-0.068,-0.100,-0.139,-0.185,-0.237,-0.296,-0.361,-0.433,-0.511,-0.595,-0.681,-0.767,-0.854,-0.942,-1.027,-1.107,-1.182,-1.249,-1.311,-1.365,-1.414,-1.455,-1.491,-1.519,-1.541,-1.557,-1.566,-1.569,-1.570,-1.571,-1.571,-1.571]
j4=[0.000,0.000,0.002,0.009,0.022,0.042,0.068,0.100,0.139,0.185,0.237,0.296,0.361,0.433,0.511,0.595,0.681,0.768,0.855,0.942,1.027,1.107,1.181,1.249,1.310,1.365,1.413,1.455,1.490,1.519,1.541,1.556,1.565,1.569,1.570,1.570,1.570,1.571]
j5=[0.000,0.000,0.002,0.009,0.022,0.042,0.068,0.100,0.139,0.185,0.237,0.296,0.361,0.433,0.511,0.595,0.681,0.768,0.855,0.942,1.028,1.108,1.182,1.250,1.311,1.366,1.414,1.455,1.491,1.519,1.541,1.557,1.566,1.569,1.570,1.571,1.571,1.571]
j6=[0.000,0.000,0.002,0.009,0.022,0.042,0.068,0.100,0.139,0.185,0.237,0.296,0.361,0.433,0.511,0.595,0.681,0.768,0.855,0.942,1.027,1.108,1.182,1.249,1.311,1.365,1.414,1.455,1.491,1.519,1.541,1.557,1.566,1.569,1.570,1.571,1.571,1.571]
times=[0.000,0.050,0.100,0.150,0.200,0.250,0.300,0.350,0.400,0.450,0.500,0.550,0.600,0.650,0.700,0.750,0.800,0.850,0.900,0.950,1.000,1.050,1.100,1.150,1.200,1.250,1.300,1.350,1.400,1.450,1.500,1.550,1.600,1.650,1.700,1.750,1.800,1.850,1.900,1.950,2.000,2.050,2.100,2.150,2.200,2.250,2.300,2.350,2.400,2.450,2.500,2.550,2.600,2.650,2.700,2.750,2.800,2.850,2.900,2.950,3.000,3.050,3.100,3.150,3.200,3.250,3.300,3.350,3.400,3.450,3.500,3.550,3.600,3.650,3.700,3.750,3.800,3.850,3.900,3.950,4.000,4.050,4.100,4.150,4.200,4.250,4.300,4.350,4.400,4.450,4.500,4.550,4.600,4.650,4.700,4.750,4.800,4.850,4.900,4.950,5.000,5.050,5.100,5.150,5.200,5.250,5.300,5.350,5.400,5.450,5.500,5.550,5.600,5.650,5.700,5.750,5.800,5.850,5.900,5.950,6.000,6.050,6.100,6.150,6.200,6.250,6.300,6.350]
j1=[0.000,0.000,0.002,0.009,0.022,0.042,0.068,0.100,0.139,0.185,0.237,0.296,0.360,0.431,0.506,0.587,0.669,0.753,0.838,0.923,1.008,1.091,1.170,1.243,1.308,1.365,1.414,1.455,1.491,1.519,1.541,1.557,1.566,1.564,1.556,1.543,1.524,1.498,1.465,1.426,1.380,1.328,1.270,1.205,1.136,1.065,0.994,0.922,0.849,0.777,0.705,0.632,0.560,0.487,0.415,0.342,0.270,0.197,0.125,0.053,-0.020,-0.092,-0.165,-0.237,-0.309,-0.382,-0.454,-0.527,-0.599,-0.671,-0.744,-0.816,-0.888,-0.961,-1.033,-1.106,-1.178,-1.250,-1.323,-1.394,-1.462,-1.523,-1.556,-1.595,-1.632,-1.664,-1.690,-1.709,-1.723,-1.729,-1.730,-1.723,-1.710,-1.691,-1.665,-1.632,-1.593,-1.548,-1.495,-1.437,-1.372,-1.302,-1.226,-1.146,-1.064,-0.980,-0.895,-0.810,-0.724,-0.638,-0.552,-0.469,-0.390,-0.318,-0.254,-0.199,-0.151,-0.110,-0.076,-0.048,-0.027,-0.012,-0.004,-0.001,-0.001,-0.000,-0.000,-0.000]
j2=[0.000,0.000,0.002,0.009,0.022,0.042,0.068,0.100,0.140,0.185,0.237,0.296,0.361,0.431,0.507,0.587,0.670,0.754,0.838,0.924,1.009,1.092,1.171,1.243,1.308,1.365,1.414,1.455,1.491,1.519,1.541,1.557,1.566,1.564,1.557,1.544,1.529,1.513,1.497,1.481,1.465,1.449,1.432,1.416,1.400,1.384,1.367,1.351,1.335,1.319,1.303,1.286,1.270,1.254,1.238,1.221,1.205,1.189,1.173,1.157,1.140,1.124,1.108,1.092,1.075,1.059,1.043,1.027,1.010,0.994,0.978,0.961,0.945,0.929,0.913,0.896,0.880,0.864,0.848,0.831,0.815,0.799,0.786,0.769,0.749,0.730,0.710,0.689,0.669,0.649,0.629,0.609,0.589,0.569,0.548,0.528,0.508,0.488,0.468,0.448,0.427,0.407,0.387,0.367,0.347,0.327,0.306,0.286,0.266,0.246,0.226,0.206,0.186,0.166,0.146,0.125,0.105,0.084,0.064,0.044,0.025,0.012,0.004,0.001,0.000,0.000,0.000,0.000]
j3=[0.000,0.000,-0.002,-0.009,-0.022,-0.042,-0.068,-0.100,-0.139,-0.185,-0.237,-0.296,-0.361,-0.433,-0.511,-0.595,-0.681,-0.767,-0.854,-0.942,-1.027,-1.107,-1.182,-1.249,-1.311,-1.365,-1.414,-1.455,-1.491,-1.519,-1.541,-1.557,-1.566,-1.564,-1.556,-1.543,-1.524,-1.498,-1.465,-1.426,-1.381,-1.328,-1.270,-1.205,-1.133,-1.055,-0.971,-0.885,-0.798,-0.711,-0.624,-0.537,-0.450,-0.362,-0.275,-0.188,-0.101,-0.013,0.074,0.161,0.249,0.336,0.423,0.510,0.598,0.685,0.772,0.859,0.947,1.032,1.112,1.186,1.253,1.314,1.369,1.416,1.458,1.492,1.521,1.542,1.557,1.566,1.564,1.557,1.544,1.524,1.498,1.466,1.427,1.383,1.338,1.293,1.247,1.201,1.155,1.110,1.064,1.018,0.972,0.926,0.881,0.835,0.789,0.743,0.697,0.652,0.606,0.560,0.514,0.468,0.423,0.377,0.331,0.285,0.239,0.194,0.149,0.109,0.076,0.048,0.027,0.012,0.004,0.002,0.001,0.000,0.000,0.000]
j4=[0.000,0.000,0.002,0.009,0.022,0.042,0.068,0.100,0.139,0.185,0.237,0.296,0.361,0.433,0.511,0.595,0.681,0.768,0.855,0.942,1.027,1.107,1.181,1.249,1.310,1.365,1.413,1.455,1.490,1.519,1.541,1.556,1.565,1.567,1.574,1.587,1.603,1.619,1.636,1.653,1.670,1.686,1.703,1.720,1.737,1.754,1.771,1.788,1.805,1.822,1.839,1.856,1.873,1.890,1.907,1.923,1.940,1.957,1.974,1.991,2.008,2.025,2.042,2.059,2.076,2.093,2.110,2.127,2.144,2.161,2.178,2.195,2.212,2.229,2.246,2.263,2.280,2.297,2.314,2.331,2.344,2.352,2.350,2.343,2.330,2.310,2.284,2.252,2.212,2.167,2.115,2.056,1.991,1.919,1.841,1.760,1.679,1.597,1.515,1.433,1.350,1.268,1.186,1.104,1.022,0.940,0.858,0.776,0.694,0.612,0.530,0.452,0.379,0.312,0.252,0.198,0.151,0.110,0.076,0.048,0.027,0.012,0.004,0.002,0.001,0.000,0.000,0.000]
j5=[0.000,0.000,0.002,0.009,0.022,0.042,0.068,0.100,0.139,0.185,0.237,0.296,0.361,0.433,0.511,0.595,0.681,0.768,0.855,0.942,1.028,1.108,1.182,1.250,1.311,1.366,1.414,1.455,1.491,1.519,1.541,1.557,1.566,1.566,1.566,1.566,1.566,1.566,1.566,1.566,1.566,1.567,1.567,1.567,1.567,1.567,1.567,1.567,1.567,1.567,1.568,1.568,1.568,1.568,1.568,1.568,1.568,1.568,1.568,1.568,1.568,1.569,1.569,1.569,1.569,1.569,1.569,1.569,1.569,1.569,1.569,1.570,1.570,1.570,1.570,1.570,1.570,1.570,1.570,1.570,1.571,1.571,1.568,1.561,1.548,1.529,1.503,1.470,1.431,1.388,1.342,1.297,1.251,1.205,1.159,1.113,1.067,1.021,0.975,0.929,0.883,0.837,0.791,0.745,0.699,0.653,0.607,0.561,0.516,0.470,0.424,0.378,0.332,0.286,0.240,0.194,0.149,0.109,0.076,0.048,0.027,0.012,0.004,0.002,0.001,0.000,0.000,0.000]
j6=[0.000,0.000,0.002,0.009,0.022,0.042,0.068,0.100,0.139,0.185,0.237,0.296,0.361,0.433,0.511,0.595,0.681,0.768,0.855,0.942,1.027,1.108,1.182,1.249,1.311,1.365,1.414,1.455,1.491,1.519,1.541,1.557,1.566,1.566,1.566,1.566,1.566,1.566,1.566,1.566,1.566,1.567,1.567,1.567,1.567,1.567,1.567,1.567,1.567,1.567,1.567,1.568,1.568,1.568,1.568,1.568,1.568,1.568,1.568,1.568,1.569,1.569,1.569,1.569,1.569,1.569,1.569,1.569,1.569,1.569,1.570,1.570,1.570,1.570,1.570,1.570,1.570,1.570,1.570,1.571,1.571,1.571,1.569,1.561,1.548,1.529,1.503,1.470,1.431,1.388,1.343,1.297,1.251,1.205,1.159,1.113,1.067,1.021,0.975,0.929,0.883,0.837,0.791,0.745,0.699,0.653,0.607,0.561,0.515,0.470,0.424,0.378,0.332,0.286,0.240,0.194,0.149,0.109,0.076,0.048,0.027,0.012,0.004,0.002,0.001,0.000,0.000,0.000]
# Start simulation:
client.simxStartSimulation(client.simxServiceCall())
# Wait until ready:
waitForMovementExecuted('ready')
# Send the movement sequence:
targetConfig=[90*math.pi/180,90*math.pi/180,-90*math.pi/180,90*math.pi/180,90*math.pi/180,90*math.pi/180]
movementData={"id":"movSeq1","type":"pts","times":times,"j1":j1,"j2":j2,"j3":j3,"j4":j4,"j5":j5,"j6":j6}
client.simxCallScriptFunction('movementDataFunction@'+targetArm,'sim.scripttype_childscript',movementData,client.simxDefaultPublisher())
# Execute movement sequence:
client.simxCallScriptFunction('executeMovement@'+targetArm,'sim.scripttype_childscript','movSeq1',client.simxDefaultPublisher())
# Wait until above movement sequence finished executing:
waitForMovementExecuted('movSeq1')
client.simxStopSimulation(client.simxServiceCall())
| 148.616667 | 844 | 0.660312 | 2,506 | 8,917 | 2.347167 | 0.179968 | 0.030602 | 0.033152 | 0.034002 | 0.536042 | 0.534512 | 0.533832 | 0.527542 | 0.521081 | 0.518361 | 0 | 0.548042 | 0.034765 | 8,917 | 59 | 845 | 151.135593 | 0.135355 | 0.031401 | 0 | 0 | 0 | 0 | 0.025267 | 0.011242 | 0 | 0 | 0 | 0 | 0 | 1 | 0.054054 | false | 0 | 0.081081 | 0 | 0.135135 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 0 | 0 | 1 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 3 |
531ff2c18ffde8b8c449c40afe94c6fcbb34972b | 1,100 | py | Python | web/transiq/supplier/migrations/0010_auto_20180425_2017.py | manibhushan05/transiq | 763fafb271ce07d13ac8ce575f2fee653cf39343 | [
"Apache-2.0"
] | null | null | null | web/transiq/supplier/migrations/0010_auto_20180425_2017.py | manibhushan05/transiq | 763fafb271ce07d13ac8ce575f2fee653cf39343 | [
"Apache-2.0"
] | 14 | 2020-06-05T23:06:45.000Z | 2022-03-12T00:00:18.000Z | web/transiq/supplier/migrations/0010_auto_20180425_2017.py | manibhushan05/transiq | 763fafb271ce07d13ac8ce575f2fee653cf39343 | [
"Apache-2.0"
] | null | null | null | # -*- coding: utf-8 -*-
# Generated by Django 1.11.4 on 2018-04-25 20:17
from __future__ import unicode_literals
from django.db import migrations
class Migration(migrations.Migration):
dependencies = [
('supplier', '0009_auto_20180425_1754'),
]
operations = [
migrations.RemoveField(
model_name='contactpersonphone',
name='changed_by',
),
migrations.RemoveField(
model_name='contactpersonphone',
name='contact_person',
),
migrations.RemoveField(
model_name='historicalcontactpersonphone',
name='changed_by',
),
migrations.RemoveField(
model_name='historicalcontactpersonphone',
name='contact_person',
),
migrations.RemoveField(
model_name='historicalcontactpersonphone',
name='history_user',
),
migrations.DeleteModel(
name='ContactPersonPhone',
),
migrations.DeleteModel(
name='HistoricalContactPersonPhone',
),
]
| 26.190476 | 54 | 0.587273 | 84 | 1,100 | 7.47619 | 0.5 | 0.167197 | 0.207006 | 0.238854 | 0.531847 | 0.531847 | 0.382166 | 0.251592 | 0.251592 | 0 | 0 | 0.043651 | 0.312727 | 1,100 | 41 | 55 | 26.829268 | 0.787037 | 0.061818 | 0 | 0.676471 | 1 | 0 | 0.249757 | 0.131195 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | false | 0 | 0.058824 | 0 | 0.147059 | 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 |
5327706d846766fca19a09d1f37dc05a941fdbcf | 307 | py | Python | srfnef/postprocess/imgq/index_recon/__init__.py | twj2417/srf | 63365cfd75199d70eea2273214a4fa580a9fdf2a | [
"Apache-2.0"
] | null | null | null | srfnef/postprocess/imgq/index_recon/__init__.py | twj2417/srf | 63365cfd75199d70eea2273214a4fa580a9fdf2a | [
"Apache-2.0"
] | null | null | null | srfnef/postprocess/imgq/index_recon/__init__.py | twj2417/srf | 63365cfd75199d70eea2273214a4fa580a9fdf2a | [
"Apache-2.0"
] | null | null | null | from .background_variability import sd, bv, snr2, noise1, noise2
from .contrast import contrast_hot, contrast_cold, crc1, crc2, cnr1, cnr2, snr1, se, nsd, ai
from .spatial_resolution import fwhm_x, fwtm_x, fwhm_y, fwtm_y, fwhm_z, fwtm_z, sd_rc
from .uniformity import positive_deviation, negative_deviation
| 61.4 | 92 | 0.80456 | 49 | 307 | 4.77551 | 0.653061 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0.02952 | 0.117264 | 307 | 4 | 93 | 76.75 | 0.833948 | 0 | 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 | 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 |
533226d029b616c0db765d2046a147b8baabdb1e | 259 | py | Python | src/masonite/inertia/helpers.py | josephmancuso/masonite-inertia | 24de317c727bd058a2f6e5537209ca66efb681bb | [
"MIT"
] | 15 | 2020-09-27T18:51:35.000Z | 2022-02-13T11:12:42.000Z | src/masonite/inertia/helpers.py | josephmancuso/masonite-inertia | 24de317c727bd058a2f6e5537209ca66efb681bb | [
"MIT"
] | 90 | 2020-09-27T18:28:27.000Z | 2022-03-21T12:25:26.000Z | src/masonite/inertia/helpers.py | josephmancuso/masonite-inertia | 24de317c727bd058a2f6e5537209ca66efb681bb | [
"MIT"
] | 2 | 2020-12-31T02:31:29.000Z | 2021-04-22T17:13:20.000Z | from jinja2 import Markup
def inertia(page_data, app_id="app"):
"""Inertia view helper to render a div with page data required by client-side
Inertia.js adapter."""
return Markup("<div id='{0}' data-page='{1}'></div>".format(app_id, page_data))
| 32.375 | 83 | 0.687259 | 42 | 259 | 4.142857 | 0.642857 | 0.137931 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0.013761 | 0.158301 | 259 | 7 | 84 | 37 | 0.784404 | 0.362934 | 0 | 0 | 0 | 0 | 0.251613 | 0.141935 | 0 | 0 | 0 | 0 | 0 | 1 | 0.333333 | false | 0 | 0.333333 | 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 | 1 | 0 | 0 | 0 | 0 | 3 |
53349ecb45e60765f728d6ac9c16eab7f819cc77 | 285 | py | Python | ddtrace/contrib/tornado/compat.py | sharov/dd-trace-py | d0995b49cf7147ab463d0a67a38779fad3f539b4 | [
"BSD-3-Clause"
] | null | null | null | ddtrace/contrib/tornado/compat.py | sharov/dd-trace-py | d0995b49cf7147ab463d0a67a38779fad3f539b4 | [
"BSD-3-Clause"
] | null | null | null | ddtrace/contrib/tornado/compat.py | sharov/dd-trace-py | d0995b49cf7147ab463d0a67a38779fad3f539b4 | [
"BSD-3-Clause"
] | null | null | null | from ..util import require_modules
optional_modules = ['concurrent.futures']
with require_modules(optional_modules) as missing_modules:
# detect if concurrent.futures is available as a Python
# stdlib or Python 2.7 backport
futures_available = len(missing_modules) == 0
| 28.5 | 59 | 0.768421 | 38 | 285 | 5.578947 | 0.631579 | 0.132075 | 0.207547 | 0.273585 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0.012552 | 0.161404 | 285 | 9 | 60 | 31.666667 | 0.874477 | 0.291228 | 0 | 0 | 0 | 0 | 0.090452 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | false | 0 | 0.25 | 0 | 0.25 | 0 | 0 | 0 | 0 | null | 0 | 1 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 3 |
534564f57055ecab7a48438bb79dd0eb62d61ba2 | 104 | py | Python | custom_components/airos/airos_api/apis/enums/endpoints.py | kmstumpff/hass-airos | a04573da740678b2c86ff61ed748e3dfdb005a3c | [
"Apache-2.0"
] | null | null | null | custom_components/airos/airos_api/apis/enums/endpoints.py | kmstumpff/hass-airos | a04573da740678b2c86ff61ed748e3dfdb005a3c | [
"Apache-2.0"
] | null | null | null | custom_components/airos/airos_api/apis/enums/endpoints.py | kmstumpff/hass-airos | a04573da740678b2c86ff61ed748e3dfdb005a3c | [
"Apache-2.0"
] | null | null | null | from enum import Enum
class Endpoints(str, Enum):
AUTH = "/api/auth"
STATUS = "/status.cgi"
| 13 | 27 | 0.625 | 14 | 104 | 4.642857 | 0.714286 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0.240385 | 104 | 8 | 28 | 13 | 0.822785 | 0 | 0 | 0 | 0 | 0 | 0.190476 | 0 | 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 |
5349eee01ecb46c5626e62f3cbb837001b2cfcd7 | 573 | py | Python | propagate_go.py | gozsari/Go_Propagation | 7cbb0c63a22d20a78a923da03cf9a9115febc5d0 | [
"MIT"
] | 3 | 2021-04-24T15:13:05.000Z | 2021-10-04T02:53:32.000Z | propagate_go.py | gozsari/Go_Propagation | 7cbb0c63a22d20a78a923da03cf9a9115febc5d0 | [
"MIT"
] | null | null | null | propagate_go.py | gozsari/Go_Propagation | 7cbb0c63a22d20a78a923da03cf9a9115febc5d0 | [
"MIT"
] | null | null | null | def propagate_go(go_id, parent_set, go_term_dict):
if len(go_term_dict[go_id]) == 0:
return parent_set
for parent in go_term_dict[go_id]:
parent_set.add(parent)
for parent in go_term_dict[go_id]:
propagate_go(parent, parent_set, go_term_dict)
return parent_set
def form_all_go_parents_dict(go_term_dict):
go_parents_dict = dict()
for go_id in go_term_dict:
parent_set = set()
parent_set = propagate_go(go_id, parent_set, go_term_dict)
go_parents_dict[go_id] = parent_set
return go_parents_dict
| 30.157895 | 66 | 0.706806 | 97 | 573 | 3.71134 | 0.185567 | 0.225 | 0.222222 | 0.166667 | 0.580556 | 0.427778 | 0.327778 | 0.327778 | 0.188889 | 0 | 0 | 0.002232 | 0.21815 | 573 | 18 | 67 | 31.833333 | 0.801339 | 0 | 0 | 0.266667 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0.133333 | false | 0 | 0 | 0 | 0.333333 | 0 | 0 | 0 | 0 | null | 1 | 1 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 3 |
534a4ddf499740ba6a365bedef39422ddf7cc8a0 | 157 | py | Python | Codes/Day-094/Space-Invaders/utils.py | MdGhulamAzadAnsari/100-Days-of-Code | 8ff993b2e3f7aecefde28cb443355e5fb4d6fbc6 | [
"MIT"
] | 3 | 2021-01-15T15:49:20.000Z | 2021-03-17T03:17:41.000Z | codes/Day-093/Space-Invaders/utils.py | GhulamAzad/100-Days-of-Code | 9533d80a6bc6ce70123126615f0671f979573a67 | [
"MIT"
] | 2 | 2022-01-16T07:00:38.000Z | 2022-01-16T07:16:57.000Z | codes/Day-093/Space-Invaders/utils.py | GhulamAzad/100-Days-of-Code | 9533d80a6bc6ce70123126615f0671f979573a67 | [
"MIT"
] | null | null | null | def collide(obj1, obj2):
offset_x = obj2.x - obj1.x
offset_y = obj2.y - obj1.y
return obj1.mask.overlap(obj2.mask, (offset_x, offset_y)) != None
| 31.4 | 69 | 0.656051 | 27 | 157 | 3.666667 | 0.407407 | 0.141414 | 0.161616 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0.063492 | 0.197452 | 157 | 4 | 70 | 39.25 | 0.722222 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0.25 | false | 0 | 0 | 0 | 0.5 | 0 | 1 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 3 |
726094a46ff8b8323f6f91881e06552060e96bf6 | 236 | py | Python | src/common/json.py | Matej-Chmel/any-project-setup | 42af18893441de89879fe2cd769d9c645bcfd7f2 | [
"CC0-1.0"
] | null | null | null | src/common/json.py | Matej-Chmel/any-project-setup | 42af18893441de89879fe2cd769d9c645bcfd7f2 | [
"CC0-1.0"
] | null | null | null | src/common/json.py | Matej-Chmel/any-project-setup | 42af18893441de89879fe2cd769d9c645bcfd7f2 | [
"CC0-1.0"
] | null | null | null | from json import load
from pathlib import Path
def dictFromJSON(p: Path) -> dict:
return JSON(p)
def JSON(p: Path):
with Path(p).open("r", encoding="utf-8") as f:
return load(f)
def listFromJSON(p: Path) -> list:
return JSON(p)
| 18.153846 | 47 | 0.682203 | 41 | 236 | 3.926829 | 0.512195 | 0.093168 | 0.136646 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0.005102 | 0.169492 | 236 | 12 | 48 | 19.666667 | 0.816327 | 0 | 0 | 0.222222 | 0 | 0 | 0.025424 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0.333333 | false | 0 | 0.222222 | 0.222222 | 0.888889 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 0 | 1 | 1 | 0 | 0 | 3 |
72891e808016647ddff779b2d494875a4a4c73d4 | 32,447 | py | Python | third_party/infra_libs/buildbucket/proto/project_config_pb2.py | khromiumos/chromiumos-chromite | a42a85481cdd9d635dc40a04585e427f89f3bb3f | [
"BSD-3-Clause"
] | null | null | null | third_party/infra_libs/buildbucket/proto/project_config_pb2.py | khromiumos/chromiumos-chromite | a42a85481cdd9d635dc40a04585e427f89f3bb3f | [
"BSD-3-Clause"
] | 2 | 2021-03-26T00:29:32.000Z | 2021-04-30T21:29:33.000Z | third_party/infra_libs/buildbucket/proto/project_config_pb2.py | khromiumos/chromiumos-chromite | a42a85481cdd9d635dc40a04585e427f89f3bb3f | [
"BSD-3-Clause"
] | null | null | null | # Generated by the protocol buffer compiler. DO NOT EDIT!
# source: project_config.proto
import sys
_b = sys.version_info[0] < 3 and (lambda x: x) or (lambda x: x.encode('latin1'))
from google.protobuf.internal import enum_type_wrapper
from google.protobuf import descriptor as _descriptor
from google.protobuf import message as _message
from google.protobuf import reflection as _reflection
from google.protobuf import symbol_database as _symbol_database
from google.protobuf import descriptor_pb2
# @@protoc_insertion_point(imports)
_sym_db = _symbol_database.Default()
from google.protobuf import wrappers_pb2 as google_dot_protobuf_dot_wrappers__pb2
DESCRIPTOR = _descriptor.FileDescriptor(
name='project_config.proto',
package='buildbucket',
syntax='proto3',
serialized_pb=_b(
'\n\x14project_config.proto\x12\x0b\x62uildbucket\x1a\x1egoogle/protobuf/wrappers.proto\"z\n\x03\x41\x63l\x12#\n\x04role\x18\x01 \x01(\x0e\x32\x15.buildbucket.Acl.Role\x12\r\n\x05group\x18\x02 \x01(\t\x12\x10\n\x08identity\x18\x03 \x01(\t\"-\n\x04Role\x12\n\n\x06READER\x10\x00\x12\r\n\tSCHEDULER\x10\x01\x12\n\n\x06WRITER\x10\x02\"6\n\x06\x41\x63lSet\x12\x0c\n\x04name\x18\x01 \x01(\t\x12\x1e\n\x04\x61\x63ls\x18\x02 \x03(\x0b\x32\x10.buildbucket.Acl\"\x94\x05\n\x07\x42uilder\x12\x0c\n\x04name\x18\x01 \x01(\t\x12\x0e\n\x06mixins\x18\n \x03(\t\x12\x10\n\x08\x63\x61tegory\x18\x06 \x01(\t\x12\x15\n\rswarming_tags\x18\x02 \x03(\t\x12\x12\n\ndimensions\x18\x03 \x03(\t\x12+\n\x06recipe\x18\x04 \x01(\x0b\x32\x1b.buildbucket.Builder.Recipe\x12\x10\n\x08priority\x18\x05 \x01(\r\x12\x1e\n\x16\x65xecution_timeout_secs\x18\x07 \x01(\r\x12\x17\n\x0f\x65xpiration_secs\x18\x14 \x01(\r\x12/\n\x06\x63\x61\x63hes\x18\t \x03(\x0b\x32\x1f.buildbucket.Builder.CacheEntry\x12*\n\rbuild_numbers\x18\x10 \x01(\x0e\x32\x13.buildbucket.Toggle\x12\x17\n\x0fservice_account\x18\x0c \x01(\t\x12\x33\n\x16\x61uto_builder_dimension\x18\x11 \x01(\x0e\x32\x13.buildbucket.Toggle\x12)\n\x0c\x65xperimental\x18\x12 \x01(\x0e\x32\x13.buildbucket.Toggle\x12\x1b\n\x13luci_migration_host\x18\x13 \x01(\t\x1a(\n\nCacheEntry\x12\x0c\n\x04name\x18\x01 \x01(\t\x12\x0c\n\x04path\x18\x02 \x01(\t\x1a\x80\x01\n\x06Recipe\x12\x12\n\nrepository\x18\x01 \x01(\t\x12\x0c\n\x04name\x18\x02 \x01(\t\x12\x14\n\x0c\x63ipd_package\x18\x06 \x01(\t\x12\x14\n\x0c\x63ipd_version\x18\x05 \x01(\t\x12\x12\n\nproperties\x18\x03 \x03(\t\x12\x14\n\x0cproperties_j\x18\x04 \x03(\tJ\x04\x08\x08\x10\tJ\x04\x08\x0b\x10\x0cJ\x04\x08\r\x10\x0eJ\x04\x08\x0f\x10\x10\"\xcf\x01\n\x08Swarming\x12\x10\n\x08hostname\x18\x01 \x01(\t\x12\x12\n\nurl_format\x18\x02 \x01(\t\x12.\n\x10\x62uilder_defaults\x18\x03 \x01(\x0b\x32\x14.buildbucket.Builder\x12&\n\x08\x62uilders\x18\x04 \x03(\x0b\x32\x14.buildbucket.Builder\x12\x45\n\x1ftask_template_canary_percentage\x18\x05 \x01(\x0b\x32\x1c.google.protobuf.UInt32Value\"q\n\x06\x42ucket\x12\x0c\n\x04name\x18\x01 \x01(\t\x12\x1e\n\x04\x61\x63ls\x18\x02 \x03(\x0b\x32\x10.buildbucket.Acl\x12\x10\n\x08\x61\x63l_sets\x18\x04 \x03(\t\x12\'\n\x08swarming\x18\x03 \x01(\x0b\x32\x15.buildbucket.Swarming\"\x8b\x01\n\x0e\x42uildbucketCfg\x12$\n\x07\x62uckets\x18\x01 \x03(\x0b\x32\x13.buildbucket.Bucket\x12%\n\x08\x61\x63l_sets\x18\x02 \x03(\x0b\x32\x13.buildbucket.AclSet\x12,\n\x0e\x62uilder_mixins\x18\x03 \x03(\x0b\x32\x14.buildbucket.Builder*$\n\x06Toggle\x12\t\n\x05UNSET\x10\x00\x12\x07\n\x03YES\x10\x01\x12\x06\n\x02NO\x10\x02\x62\x06proto3'
),
dependencies=[
google_dot_protobuf_dot_wrappers__pb2.DESCRIPTOR,
]
)
_sym_db.RegisterFileDescriptor(DESCRIPTOR)
_TOGGLE = _descriptor.EnumDescriptor(
name='Toggle',
full_name='buildbucket.Toggle',
filename=None,
file=DESCRIPTOR,
values=[
_descriptor.EnumValueDescriptor(
name='UNSET', index=0, number=0, options=None, type=None
),
_descriptor.EnumValueDescriptor(
name='YES', index=1, number=1, options=None, type=None
),
_descriptor.EnumValueDescriptor(
name='NO', index=2, number=2, options=None, type=None
),
],
containing_type=None,
options=None,
serialized_start=1379,
serialized_end=1415,
)
_sym_db.RegisterEnumDescriptor(_TOGGLE)
Toggle = enum_type_wrapper.EnumTypeWrapper(_TOGGLE)
UNSET = 0
YES = 1
NO = 2
_ACL_ROLE = _descriptor.EnumDescriptor(
name='Role',
full_name='buildbucket.Acl.Role',
filename=None,
file=DESCRIPTOR,
values=[
_descriptor.EnumValueDescriptor(
name='READER', index=0, number=0, options=None, type=None
),
_descriptor.EnumValueDescriptor(
name='SCHEDULER', index=1, number=1, options=None, type=None
),
_descriptor.EnumValueDescriptor(
name='WRITER', index=2, number=2, options=None, type=None
),
],
containing_type=None,
options=None,
serialized_start=146,
serialized_end=191,
)
_sym_db.RegisterEnumDescriptor(_ACL_ROLE)
_ACL = _descriptor.Descriptor(
name='Acl',
full_name='buildbucket.Acl',
filename=None,
file=DESCRIPTOR,
containing_type=None,
fields=[
_descriptor.FieldDescriptor(
name='role',
full_name='buildbucket.Acl.role',
index=0,
number=1,
type=14,
cpp_type=8,
label=1,
has_default_value=False,
default_value=0,
message_type=None,
enum_type=None,
containing_type=None,
is_extension=False,
extension_scope=None,
options=None
),
_descriptor.FieldDescriptor(
name='group',
full_name='buildbucket.Acl.group',
index=1,
number=2,
type=9,
cpp_type=9,
label=1,
has_default_value=False,
default_value=_b("").decode('utf-8'),
message_type=None,
enum_type=None,
containing_type=None,
is_extension=False,
extension_scope=None,
options=None
),
_descriptor.FieldDescriptor(
name='identity',
full_name='buildbucket.Acl.identity',
index=2,
number=3,
type=9,
cpp_type=9,
label=1,
has_default_value=False,
default_value=_b("").decode('utf-8'),
message_type=None,
enum_type=None,
containing_type=None,
is_extension=False,
extension_scope=None,
options=None
),
],
extensions=[],
nested_types=[],
enum_types=[
_ACL_ROLE,
],
options=None,
is_extendable=False,
syntax='proto3',
extension_ranges=[],
oneofs=[],
serialized_start=69,
serialized_end=191,
)
_ACLSET = _descriptor.Descriptor(
name='AclSet',
full_name='buildbucket.AclSet',
filename=None,
file=DESCRIPTOR,
containing_type=None,
fields=[
_descriptor.FieldDescriptor(
name='name',
full_name='buildbucket.AclSet.name',
index=0,
number=1,
type=9,
cpp_type=9,
label=1,
has_default_value=False,
default_value=_b("").decode('utf-8'),
message_type=None,
enum_type=None,
containing_type=None,
is_extension=False,
extension_scope=None,
options=None
),
_descriptor.FieldDescriptor(
name='acls',
full_name='buildbucket.AclSet.acls',
index=1,
number=2,
type=11,
cpp_type=10,
label=3,
has_default_value=False,
default_value=[],
message_type=None,
enum_type=None,
containing_type=None,
is_extension=False,
extension_scope=None,
options=None
),
],
extensions=[],
nested_types=[],
enum_types=[],
options=None,
is_extendable=False,
syntax='proto3',
extension_ranges=[],
oneofs=[],
serialized_start=193,
serialized_end=247,
)
_BUILDER_CACHEENTRY = _descriptor.Descriptor(
name='CacheEntry',
full_name='buildbucket.Builder.CacheEntry',
filename=None,
file=DESCRIPTOR,
containing_type=None,
fields=[
_descriptor.FieldDescriptor(
name='name',
full_name='buildbucket.Builder.CacheEntry.name',
index=0,
number=1,
type=9,
cpp_type=9,
label=1,
has_default_value=False,
default_value=_b("").decode('utf-8'),
message_type=None,
enum_type=None,
containing_type=None,
is_extension=False,
extension_scope=None,
options=None
),
_descriptor.FieldDescriptor(
name='path',
full_name='buildbucket.Builder.CacheEntry.path',
index=1,
number=2,
type=9,
cpp_type=9,
label=1,
has_default_value=False,
default_value=_b("").decode('utf-8'),
message_type=None,
enum_type=None,
containing_type=None,
is_extension=False,
extension_scope=None,
options=None
),
],
extensions=[],
nested_types=[],
enum_types=[],
options=None,
is_extendable=False,
syntax='proto3',
extension_ranges=[],
oneofs=[],
serialized_start=715,
serialized_end=755,
)
_BUILDER_RECIPE = _descriptor.Descriptor(
name='Recipe',
full_name='buildbucket.Builder.Recipe',
filename=None,
file=DESCRIPTOR,
containing_type=None,
fields=[
_descriptor.FieldDescriptor(
name='repository',
full_name='buildbucket.Builder.Recipe.repository',
index=0,
number=1,
type=9,
cpp_type=9,
label=1,
has_default_value=False,
default_value=_b("").decode('utf-8'),
message_type=None,
enum_type=None,
containing_type=None,
is_extension=False,
extension_scope=None,
options=None
),
_descriptor.FieldDescriptor(
name='name',
full_name='buildbucket.Builder.Recipe.name',
index=1,
number=2,
type=9,
cpp_type=9,
label=1,
has_default_value=False,
default_value=_b("").decode('utf-8'),
message_type=None,
enum_type=None,
containing_type=None,
is_extension=False,
extension_scope=None,
options=None
),
_descriptor.FieldDescriptor(
name='cipd_package',
full_name='buildbucket.Builder.Recipe.cipd_package',
index=2,
number=6,
type=9,
cpp_type=9,
label=1,
has_default_value=False,
default_value=_b("").decode('utf-8'),
message_type=None,
enum_type=None,
containing_type=None,
is_extension=False,
extension_scope=None,
options=None
),
_descriptor.FieldDescriptor(
name='cipd_version',
full_name='buildbucket.Builder.Recipe.cipd_version',
index=3,
number=5,
type=9,
cpp_type=9,
label=1,
has_default_value=False,
default_value=_b("").decode('utf-8'),
message_type=None,
enum_type=None,
containing_type=None,
is_extension=False,
extension_scope=None,
options=None
),
_descriptor.FieldDescriptor(
name='properties',
full_name='buildbucket.Builder.Recipe.properties',
index=4,
number=3,
type=9,
cpp_type=9,
label=3,
has_default_value=False,
default_value=[],
message_type=None,
enum_type=None,
containing_type=None,
is_extension=False,
extension_scope=None,
options=None
),
_descriptor.FieldDescriptor(
name='properties_j',
full_name='buildbucket.Builder.Recipe.properties_j',
index=5,
number=4,
type=9,
cpp_type=9,
label=3,
has_default_value=False,
default_value=[],
message_type=None,
enum_type=None,
containing_type=None,
is_extension=False,
extension_scope=None,
options=None
),
],
extensions=[],
nested_types=[],
enum_types=[],
options=None,
is_extendable=False,
syntax='proto3',
extension_ranges=[],
oneofs=[],
serialized_start=758,
serialized_end=886,
)
_BUILDER = _descriptor.Descriptor(
name='Builder',
full_name='buildbucket.Builder',
filename=None,
file=DESCRIPTOR,
containing_type=None,
fields=[
_descriptor.FieldDescriptor(
name='name',
full_name='buildbucket.Builder.name',
index=0,
number=1,
type=9,
cpp_type=9,
label=1,
has_default_value=False,
default_value=_b("").decode('utf-8'),
message_type=None,
enum_type=None,
containing_type=None,
is_extension=False,
extension_scope=None,
options=None
),
_descriptor.FieldDescriptor(
name='mixins',
full_name='buildbucket.Builder.mixins',
index=1,
number=10,
type=9,
cpp_type=9,
label=3,
has_default_value=False,
default_value=[],
message_type=None,
enum_type=None,
containing_type=None,
is_extension=False,
extension_scope=None,
options=None
),
_descriptor.FieldDescriptor(
name='category',
full_name='buildbucket.Builder.category',
index=2,
number=6,
type=9,
cpp_type=9,
label=1,
has_default_value=False,
default_value=_b("").decode('utf-8'),
message_type=None,
enum_type=None,
containing_type=None,
is_extension=False,
extension_scope=None,
options=None
),
_descriptor.FieldDescriptor(
name='swarming_tags',
full_name='buildbucket.Builder.swarming_tags',
index=3,
number=2,
type=9,
cpp_type=9,
label=3,
has_default_value=False,
default_value=[],
message_type=None,
enum_type=None,
containing_type=None,
is_extension=False,
extension_scope=None,
options=None
),
_descriptor.FieldDescriptor(
name='dimensions',
full_name='buildbucket.Builder.dimensions',
index=4,
number=3,
type=9,
cpp_type=9,
label=3,
has_default_value=False,
default_value=[],
message_type=None,
enum_type=None,
containing_type=None,
is_extension=False,
extension_scope=None,
options=None
),
_descriptor.FieldDescriptor(
name='recipe',
full_name='buildbucket.Builder.recipe',
index=5,
number=4,
type=11,
cpp_type=10,
label=1,
has_default_value=False,
default_value=None,
message_type=None,
enum_type=None,
containing_type=None,
is_extension=False,
extension_scope=None,
options=None
),
_descriptor.FieldDescriptor(
name='priority',
full_name='buildbucket.Builder.priority',
index=6,
number=5,
type=13,
cpp_type=3,
label=1,
has_default_value=False,
default_value=0,
message_type=None,
enum_type=None,
containing_type=None,
is_extension=False,
extension_scope=None,
options=None
),
_descriptor.FieldDescriptor(
name='execution_timeout_secs',
full_name='buildbucket.Builder.execution_timeout_secs',
index=7,
number=7,
type=13,
cpp_type=3,
label=1,
has_default_value=False,
default_value=0,
message_type=None,
enum_type=None,
containing_type=None,
is_extension=False,
extension_scope=None,
options=None
),
_descriptor.FieldDescriptor(
name='expiration_secs',
full_name='buildbucket.Builder.expiration_secs',
index=8,
number=20,
type=13,
cpp_type=3,
label=1,
has_default_value=False,
default_value=0,
message_type=None,
enum_type=None,
containing_type=None,
is_extension=False,
extension_scope=None,
options=None
),
_descriptor.FieldDescriptor(
name='caches',
full_name='buildbucket.Builder.caches',
index=9,
number=9,
type=11,
cpp_type=10,
label=3,
has_default_value=False,
default_value=[],
message_type=None,
enum_type=None,
containing_type=None,
is_extension=False,
extension_scope=None,
options=None
),
_descriptor.FieldDescriptor(
name='build_numbers',
full_name='buildbucket.Builder.build_numbers',
index=10,
number=16,
type=14,
cpp_type=8,
label=1,
has_default_value=False,
default_value=0,
message_type=None,
enum_type=None,
containing_type=None,
is_extension=False,
extension_scope=None,
options=None
),
_descriptor.FieldDescriptor(
name='service_account',
full_name='buildbucket.Builder.service_account',
index=11,
number=12,
type=9,
cpp_type=9,
label=1,
has_default_value=False,
default_value=_b("").decode('utf-8'),
message_type=None,
enum_type=None,
containing_type=None,
is_extension=False,
extension_scope=None,
options=None
),
_descriptor.FieldDescriptor(
name='auto_builder_dimension',
full_name='buildbucket.Builder.auto_builder_dimension',
index=12,
number=17,
type=14,
cpp_type=8,
label=1,
has_default_value=False,
default_value=0,
message_type=None,
enum_type=None,
containing_type=None,
is_extension=False,
extension_scope=None,
options=None
),
_descriptor.FieldDescriptor(
name='experimental',
full_name='buildbucket.Builder.experimental',
index=13,
number=18,
type=14,
cpp_type=8,
label=1,
has_default_value=False,
default_value=0,
message_type=None,
enum_type=None,
containing_type=None,
is_extension=False,
extension_scope=None,
options=None
),
_descriptor.FieldDescriptor(
name='luci_migration_host',
full_name='buildbucket.Builder.luci_migration_host',
index=14,
number=19,
type=9,
cpp_type=9,
label=1,
has_default_value=False,
default_value=_b("").decode('utf-8'),
message_type=None,
enum_type=None,
containing_type=None,
is_extension=False,
extension_scope=None,
options=None
),
],
extensions=[],
nested_types=[
_BUILDER_CACHEENTRY,
_BUILDER_RECIPE,
],
enum_types=[],
options=None,
is_extendable=False,
syntax='proto3',
extension_ranges=[],
oneofs=[],
serialized_start=250,
serialized_end=910,
)
_SWARMING = _descriptor.Descriptor(
name='Swarming',
full_name='buildbucket.Swarming',
filename=None,
file=DESCRIPTOR,
containing_type=None,
fields=[
_descriptor.FieldDescriptor(
name='hostname',
full_name='buildbucket.Swarming.hostname',
index=0,
number=1,
type=9,
cpp_type=9,
label=1,
has_default_value=False,
default_value=_b("").decode('utf-8'),
message_type=None,
enum_type=None,
containing_type=None,
is_extension=False,
extension_scope=None,
options=None
),
_descriptor.FieldDescriptor(
name='url_format',
full_name='buildbucket.Swarming.url_format',
index=1,
number=2,
type=9,
cpp_type=9,
label=1,
has_default_value=False,
default_value=_b("").decode('utf-8'),
message_type=None,
enum_type=None,
containing_type=None,
is_extension=False,
extension_scope=None,
options=None
),
_descriptor.FieldDescriptor(
name='builder_defaults',
full_name='buildbucket.Swarming.builder_defaults',
index=2,
number=3,
type=11,
cpp_type=10,
label=1,
has_default_value=False,
default_value=None,
message_type=None,
enum_type=None,
containing_type=None,
is_extension=False,
extension_scope=None,
options=None
),
_descriptor.FieldDescriptor(
name='builders',
full_name='buildbucket.Swarming.builders',
index=3,
number=4,
type=11,
cpp_type=10,
label=3,
has_default_value=False,
default_value=[],
message_type=None,
enum_type=None,
containing_type=None,
is_extension=False,
extension_scope=None,
options=None
),
_descriptor.FieldDescriptor(
name='task_template_canary_percentage',
full_name='buildbucket.Swarming.task_template_canary_percentage',
index=4,
number=5,
type=11,
cpp_type=10,
label=1,
has_default_value=False,
default_value=None,
message_type=None,
enum_type=None,
containing_type=None,
is_extension=False,
extension_scope=None,
options=None
),
],
extensions=[],
nested_types=[],
enum_types=[],
options=None,
is_extendable=False,
syntax='proto3',
extension_ranges=[],
oneofs=[],
serialized_start=913,
serialized_end=1120,
)
_BUCKET = _descriptor.Descriptor(
name='Bucket',
full_name='buildbucket.Bucket',
filename=None,
file=DESCRIPTOR,
containing_type=None,
fields=[
_descriptor.FieldDescriptor(
name='name',
full_name='buildbucket.Bucket.name',
index=0,
number=1,
type=9,
cpp_type=9,
label=1,
has_default_value=False,
default_value=_b("").decode('utf-8'),
message_type=None,
enum_type=None,
containing_type=None,
is_extension=False,
extension_scope=None,
options=None
),
_descriptor.FieldDescriptor(
name='acls',
full_name='buildbucket.Bucket.acls',
index=1,
number=2,
type=11,
cpp_type=10,
label=3,
has_default_value=False,
default_value=[],
message_type=None,
enum_type=None,
containing_type=None,
is_extension=False,
extension_scope=None,
options=None
),
_descriptor.FieldDescriptor(
name='acl_sets',
full_name='buildbucket.Bucket.acl_sets',
index=2,
number=4,
type=9,
cpp_type=9,
label=3,
has_default_value=False,
default_value=[],
message_type=None,
enum_type=None,
containing_type=None,
is_extension=False,
extension_scope=None,
options=None
),
_descriptor.FieldDescriptor(
name='swarming',
full_name='buildbucket.Bucket.swarming',
index=3,
number=3,
type=11,
cpp_type=10,
label=1,
has_default_value=False,
default_value=None,
message_type=None,
enum_type=None,
containing_type=None,
is_extension=False,
extension_scope=None,
options=None
),
],
extensions=[],
nested_types=[],
enum_types=[],
options=None,
is_extendable=False,
syntax='proto3',
extension_ranges=[],
oneofs=[],
serialized_start=1122,
serialized_end=1235,
)
_BUILDBUCKETCFG = _descriptor.Descriptor(
name='BuildbucketCfg',
full_name='buildbucket.BuildbucketCfg',
filename=None,
file=DESCRIPTOR,
containing_type=None,
fields=[
_descriptor.FieldDescriptor(
name='buckets',
full_name='buildbucket.BuildbucketCfg.buckets',
index=0,
number=1,
type=11,
cpp_type=10,
label=3,
has_default_value=False,
default_value=[],
message_type=None,
enum_type=None,
containing_type=None,
is_extension=False,
extension_scope=None,
options=None
),
_descriptor.FieldDescriptor(
name='acl_sets',
full_name='buildbucket.BuildbucketCfg.acl_sets',
index=1,
number=2,
type=11,
cpp_type=10,
label=3,
has_default_value=False,
default_value=[],
message_type=None,
enum_type=None,
containing_type=None,
is_extension=False,
extension_scope=None,
options=None
),
_descriptor.FieldDescriptor(
name='builder_mixins',
full_name='buildbucket.BuildbucketCfg.builder_mixins',
index=2,
number=3,
type=11,
cpp_type=10,
label=3,
has_default_value=False,
default_value=[],
message_type=None,
enum_type=None,
containing_type=None,
is_extension=False,
extension_scope=None,
options=None
),
],
extensions=[],
nested_types=[],
enum_types=[],
options=None,
is_extendable=False,
syntax='proto3',
extension_ranges=[],
oneofs=[],
serialized_start=1238,
serialized_end=1377,
)
_ACL.fields_by_name['role'].enum_type = _ACL_ROLE
_ACL_ROLE.containing_type = _ACL
_ACLSET.fields_by_name['acls'].message_type = _ACL
_BUILDER_CACHEENTRY.containing_type = _BUILDER
_BUILDER_RECIPE.containing_type = _BUILDER
_BUILDER.fields_by_name['recipe'].message_type = _BUILDER_RECIPE
_BUILDER.fields_by_name['caches'].message_type = _BUILDER_CACHEENTRY
_BUILDER.fields_by_name['build_numbers'].enum_type = _TOGGLE
_BUILDER.fields_by_name['auto_builder_dimension'].enum_type = _TOGGLE
_BUILDER.fields_by_name['experimental'].enum_type = _TOGGLE
_SWARMING.fields_by_name['builder_defaults'].message_type = _BUILDER
_SWARMING.fields_by_name['builders'].message_type = _BUILDER
_SWARMING.fields_by_name[
'task_template_canary_percentage'
].message_type = google_dot_protobuf_dot_wrappers__pb2._UINT32VALUE
_BUCKET.fields_by_name['acls'].message_type = _ACL
_BUCKET.fields_by_name['swarming'].message_type = _SWARMING
_BUILDBUCKETCFG.fields_by_name['buckets'].message_type = _BUCKET
_BUILDBUCKETCFG.fields_by_name['acl_sets'].message_type = _ACLSET
_BUILDBUCKETCFG.fields_by_name['builder_mixins'].message_type = _BUILDER
DESCRIPTOR.message_types_by_name['Acl'] = _ACL
DESCRIPTOR.message_types_by_name['AclSet'] = _ACLSET
DESCRIPTOR.message_types_by_name['Builder'] = _BUILDER
DESCRIPTOR.message_types_by_name['Swarming'] = _SWARMING
DESCRIPTOR.message_types_by_name['Bucket'] = _BUCKET
DESCRIPTOR.message_types_by_name['BuildbucketCfg'] = _BUILDBUCKETCFG
DESCRIPTOR.enum_types_by_name['Toggle'] = _TOGGLE
Acl = _reflection.GeneratedProtocolMessageType(
'Acl',
(_message.Message,),
dict(
DESCRIPTOR=_ACL,
__module__='project_config_pb2'
# @@protoc_insertion_point(class_scope:buildbucket.Acl)
)
)
_sym_db.RegisterMessage(Acl)
AclSet = _reflection.GeneratedProtocolMessageType(
'AclSet',
(_message.Message,),
dict(
DESCRIPTOR=_ACLSET,
__module__='project_config_pb2'
# @@protoc_insertion_point(class_scope:buildbucket.AclSet)
)
)
_sym_db.RegisterMessage(AclSet)
Builder = _reflection.GeneratedProtocolMessageType(
'Builder',
(_message.Message,),
dict(
CacheEntry=_reflection.GeneratedProtocolMessageType(
'CacheEntry',
(_message.Message,),
dict(
DESCRIPTOR=_BUILDER_CACHEENTRY,
__module__='project_config_pb2'
# @@protoc_insertion_point(class_scope:buildbucket.Builder.CacheEntry)
)
),
Recipe=_reflection.GeneratedProtocolMessageType(
'Recipe',
(_message.Message,),
dict(
DESCRIPTOR=_BUILDER_RECIPE,
__module__='project_config_pb2'
# @@protoc_insertion_point(class_scope:buildbucket.Builder.Recipe)
)
),
DESCRIPTOR=_BUILDER,
__module__='project_config_pb2'
# @@protoc_insertion_point(class_scope:buildbucket.Builder)
)
)
_sym_db.RegisterMessage(Builder)
_sym_db.RegisterMessage(Builder.CacheEntry)
_sym_db.RegisterMessage(Builder.Recipe)
Swarming = _reflection.GeneratedProtocolMessageType(
'Swarming',
(_message.Message,),
dict(
DESCRIPTOR=_SWARMING,
__module__='project_config_pb2'
# @@protoc_insertion_point(class_scope:buildbucket.Swarming)
)
)
_sym_db.RegisterMessage(Swarming)
Bucket = _reflection.GeneratedProtocolMessageType(
'Bucket',
(_message.Message,),
dict(
DESCRIPTOR=_BUCKET,
__module__='project_config_pb2'
# @@protoc_insertion_point(class_scope:buildbucket.Bucket)
)
)
_sym_db.RegisterMessage(Bucket)
BuildbucketCfg = _reflection.GeneratedProtocolMessageType(
'BuildbucketCfg',
(_message.Message,),
dict(
DESCRIPTOR=_BUILDBUCKETCFG,
__module__='project_config_pb2'
# @@protoc_insertion_point(class_scope:buildbucket.BuildbucketCfg)
)
)
_sym_db.RegisterMessage(BuildbucketCfg)
# @@protoc_insertion_point(module_scope)
| 31.139155 | 2,635 | 0.573427 | 3,359 | 32,447 | 5.264067 | 0.084549 | 0.061532 | 0.053727 | 0.052257 | 0.675659 | 0.629341 | 0.60751 | 0.574426 | 0.563794 | 0.56074 | 0 | 0.047941 | 0.321786 | 32,447 | 1,041 | 2,636 | 31.169068 | 0.755567 | 0.019786 | 0 | 0.744533 | 1 | 0.001988 | 0.15051 | 0.11418 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | false | 0 | 0.007952 | 0 | 0.007952 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 0 | 0 | 1 | 1 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 3 |
72a152f748d8bc14e7834b2a00919061771a79e2 | 3,245 | py | Python | tests/test_objects.py | jjmontesl/godot_parser | 3b61e83efc67258f1320acf63e7369e8baf4c57b | [
"MIT"
] | null | null | null | tests/test_objects.py | jjmontesl/godot_parser | 3b61e83efc67258f1320acf63e7369e8baf4c57b | [
"MIT"
] | null | null | null | tests/test_objects.py | jjmontesl/godot_parser | 3b61e83efc67258f1320acf63e7369e8baf4c57b | [
"MIT"
] | null | null | null | import unittest
from godot_parser import Color, ExtResource, NodePath, SubResource, Vector2, Vector3
class TestGDObjects(unittest.TestCase):
""" Tests for GD object wrappers """
def test_vector2(self):
""" Test for Vector2 """
v = Vector2(1, 2)
self.assertEqual(v[0], 1)
self.assertEqual(v[1], 2)
self.assertEqual(v.x, 1)
self.assertEqual(v.y, 2)
self.assertEqual(str(v), "Vector2( 1, 2 )")
v.x = 2
v.y = 3
self.assertEqual(v.x, 2)
self.assertEqual(v.y, 3)
v[0] = 3
v[1] = 4
self.assertEqual(v[0], 3)
self.assertEqual(v[1], 4)
def test_vector3(self):
""" Test for Vector3 """
v = Vector3(1, 2, 3)
self.assertEqual(v[0], 1)
self.assertEqual(v[1], 2)
self.assertEqual(v[2], 3)
self.assertEqual(v.x, 1)
self.assertEqual(v.y, 2)
self.assertEqual(v.z, 3)
self.assertEqual(str(v), "Vector3( 1, 2, 3 )")
v.x = 2
v.y = 3
v.z = 4
self.assertEqual(v.x, 2)
self.assertEqual(v.y, 3)
self.assertEqual(v.z, 4)
v[0] = 3
v[1] = 4
v[2] = 5
self.assertEqual(v[0], 3)
self.assertEqual(v[1], 4)
self.assertEqual(v[2], 5)
def test_color(self):
""" Test for Color """
c = Color(0.1, 0.2, 0.3, 0.4)
self.assertEqual(c[0], 0.1)
self.assertEqual(c[1], 0.2)
self.assertEqual(c[2], 0.3)
self.assertEqual(c[3], 0.4)
self.assertEqual(c.r, 0.1)
self.assertEqual(c.g, 0.2)
self.assertEqual(c.b, 0.3)
self.assertEqual(c.a, 0.4)
self.assertEqual(str(c), "Color( 0.1, 0.2, 0.3, 0.4 )")
c.r = 0.2
c.g = 0.3
c.b = 0.4
c.a = 0.5
self.assertEqual(c.r, 0.2)
self.assertEqual(c.g, 0.3)
self.assertEqual(c.b, 0.4)
self.assertEqual(c.a, 0.5)
c[0] = 0.3
c[1] = 0.4
c[2] = 0.5
c[3] = 0.6
self.assertEqual(c[0], 0.3)
self.assertEqual(c[1], 0.4)
self.assertEqual(c[2], 0.5)
self.assertEqual(c[3], 0.6)
def test_node_path(self):
""" Test for NodePath """
n = NodePath("../Sibling")
self.assertEqual(n.path, "../Sibling")
n.path = "../Other"
self.assertEqual(n.path, "../Other")
self.assertEqual(str(n), 'NodePath("../Other")')
def test_ext_resource(self):
""" Test for ExtResource """
r = ExtResource(1)
self.assertEqual(r.id, 1)
r.id = 2
self.assertEqual(r.id, 2)
self.assertEqual(str(r), "ExtResource( 2 )")
def test_sub_resource(self):
""" Test for SubResource """
r = SubResource(1)
self.assertEqual(r.id, 1)
r.id = 2
self.assertEqual(r.id, 2)
self.assertEqual(str(r), "SubResource( 2 )")
def test_dunder(self):
""" Test the __magic__ methods on GDObject """
v = Vector2(1, 2)
self.assertEqual(repr(v), "Vector2( 1, 2 )")
v2 = Vector2(1, 2)
self.assertEqual(v, v2)
v2.x = 10
self.assertNotEqual(v, v2)
self.assertNotEqual(v, (1, 2))
| 28.973214 | 84 | 0.510324 | 478 | 3,245 | 3.433054 | 0.123431 | 0.457038 | 0.204753 | 0.072517 | 0.596587 | 0.388178 | 0.296161 | 0.296161 | 0.296161 | 0.296161 | 0 | 0.076503 | 0.323267 | 3,245 | 111 | 85 | 29.234234 | 0.670765 | 0.056394 | 0 | 0.347826 | 0 | 0 | 0.054117 | 0 | 0 | 0 | 0 | 0 | 0.565217 | 1 | 0.076087 | false | 0 | 0.021739 | 0 | 0.108696 | 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 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 3 |
72a93f5b22fb7cf254a45591dc3bd126b5ef48eb | 301 | py | Python | jira_analysis/throughput/chart/exceptions.py | m1lt0n/jira-analysis | 743bbfde64f0820334f974508e37864cf0b0fa2c | [
"MIT"
] | 10 | 2020-06-12T13:33:20.000Z | 2022-01-14T15:33:12.000Z | jira_analysis/throughput/chart/exceptions.py | m1lt0n/jira-analysis | 743bbfde64f0820334f974508e37864cf0b0fa2c | [
"MIT"
] | 6 | 2020-06-03T06:58:15.000Z | 2022-02-10T15:02:30.000Z | jira_analysis/throughput/chart/exceptions.py | m1lt0n/jira-analysis | 743bbfde64f0820334f974508e37864cf0b0fa2c | [
"MIT"
] | 6 | 2020-06-02T15:20:13.000Z | 2021-11-04T08:46:17.000Z | class ChartError(Exception):
"""Raised whenever we have a generic error trying to draw the chart."""
class NoTicketsProvided(ChartError):
"""Raised if we provide no tickets to the chart."""
def __init__(self) -> None:
super().__init__("No tickets provided. Check your config.")
| 30.1 | 75 | 0.694352 | 39 | 301 | 5.153846 | 0.74359 | 0.079602 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0.192691 | 301 | 9 | 76 | 33.444444 | 0.82716 | 0.368771 | 0 | 0 | 0 | 0 | 0.217877 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0.25 | false | 0 | 0 | 0 | 0.75 | 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 |
72e59ecc61ec12165a4ed8d88011c94192e7bb8b | 1,507 | py | Python | jesseData/binance_crypto/strategies/STimingStrategy/__init__.py | Sebastiencreoff/jesse-stack-docker | baf36d8f2d97fc2f02448dfae618fbbb829f4efb | [
"MIT"
] | 1 | 2021-12-17T10:20:58.000Z | 2021-12-17T10:20:58.000Z | jesseData/binance_crypto/strategies/STimingStrategy/__init__.py | Sebastiencreoff/jesse-stack-docker | baf36d8f2d97fc2f02448dfae618fbbb829f4efb | [
"MIT"
] | null | null | null | jesseData/binance_crypto/strategies/STimingStrategy/__init__.py | Sebastiencreoff/jesse-stack-docker | baf36d8f2d97fc2f02448dfae618fbbb829f4efb | [
"MIT"
] | 2 | 2021-12-17T10:52:59.000Z | 2022-01-21T11:19:32.000Z | import jesse.indicators as ta
from jesse import utils
from jesse.strategies import Strategy, cached
STOP_LOSS_PERCENT = 0.05
CAPITAL_PERCENT = 0.1
PIKE_PERCENT = 5
def calculate_percent(value: float, reference: float) -> float:
return (abs(value - reference) / reference) * 100
class STimingStrategy(Strategy):
def __init__(self):
super().__init__()
self.current_pyramiding_levels = 0
def should_short(self) -> bool:
# Detect small pike
return calculate_percent(self.close, self.long_ema) > PIKE_PERCENT
def should_cancel(self) -> bool:
return True
def go_short(self):
qty = utils.size_to_qty(
self.capital * CAPITAL_PERCENT, self.price, fee_rate=self.fee_rate
)
self.take_profit = qty, self.long_ema
self.sell = qty, self.price
self.stop_loss = qty, self.price + (self.price * STOP_LOSS_PERCENT)
self.current_pyramiding_levels = self.price
def go_long(self):
pass
def update_position(self):
if self.is_short:
# Follow the price if the price raised.
if self.close < self.current_pyramiding_levels * 1.02:
self.current_pyramiding_levels = self.current_pyramiding_levels - (
self.current_pyramiding_levels * 0.01
)
self.stop_loss = self.position.qty, self.current_pyramiding_levels
@property
def long_ema(self):
return ta.ema(self.candles, 60)
| 28.980769 | 83 | 0.650962 | 192 | 1,507 | 4.859375 | 0.354167 | 0.082529 | 0.157556 | 0.202572 | 0.151125 | 0.086817 | 0.086817 | 0.086817 | 0 | 0 | 0 | 0.016245 | 0.264764 | 1,507 | 51 | 84 | 29.54902 | 0.825812 | 0.036496 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0.222222 | false | 0.027778 | 0.083333 | 0.111111 | 0.444444 | 0 | 0 | 0 | 0 | null | 0 | 0 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 0 | 1 | 0 | 0 | 0 | 3 |
72fbc10b209cc60b2315d901da466e55f4859ba3 | 2,767 | py | Python | corehq/apps/userreports/data_source_providers.py | akashkj/commcare-hq | b00a62336ec26cea1477dfb8c048c548cc462831 | [
"BSD-3-Clause"
] | 471 | 2015-01-10T02:55:01.000Z | 2022-03-29T18:07:18.000Z | corehq/apps/userreports/data_source_providers.py | akashkj/commcare-hq | b00a62336ec26cea1477dfb8c048c548cc462831 | [
"BSD-3-Clause"
] | 14,354 | 2015-01-01T07:38:23.000Z | 2022-03-31T20:55:14.000Z | corehq/apps/userreports/data_source_providers.py | akashkj/commcare-hq | b00a62336ec26cea1477dfb8c048c548cc462831 | [
"BSD-3-Clause"
] | 175 | 2015-01-06T07:16:47.000Z | 2022-03-29T13:27:01.000Z | from abc import ABCMeta, abstractmethod
from corehq.apps.userreports.dbaccessors import get_all_registry_data_source_ids, \
get_registry_data_sources_modified_since
from corehq.apps.userreports.models import (
DataSourceConfiguration,
StaticDataSourceConfiguration, RegistryDataSourceConfiguration,
)
from dimagi.utils.couch.database import iter_docs
class DataSourceProvider(metaclass=ABCMeta):
def __init__(self, referenced_doc_type=None):
self.referenced_doc_type = referenced_doc_type
@abstractmethod
def get_all_data_sources(self):
"""Return a list of active data sources"""
pass
@abstractmethod
def get_data_sources_modified_since(self, timestamp):
"""Return a list of active data sources modified since the given timestamp"""
pass
def get_data_sources(self):
sources = self.get_all_data_sources()
if self.referenced_doc_type:
return [source for source in sources if source.referenced_doc_type == self.referenced_doc_type]
else:
return sources
class DynamicDataSourceProvider(DataSourceProvider):
def get_all_data_sources(self):
return DataSourceConfiguration.view(
'userreports/active_data_sources', reduce=False, include_docs=True).all()
def get_data_sources_modified_since(self, timestamp):
return DataSourceConfiguration.view(
'userreports/data_sources_by_last_modified',
startkey=[timestamp.isoformat()],
endkey=[{}],
reduce=False,
include_docs=True
).all()
class RegistryDataSourceProvider(DataSourceProvider):
def get_all_data_sources(self):
active_ids = get_all_registry_data_source_ids(is_active=True)
for result in iter_docs(RegistryDataSourceConfiguration.get_db(), active_ids):
yield RegistryDataSourceConfiguration.wrap(result)
def get_data_sources_modified_since(self, timestamp):
return get_registry_data_sources_modified_since(timestamp)
class StaticDataSourceProvider(DataSourceProvider):
def get_all_data_sources(self):
return StaticDataSourceConfiguration.all()
def get_data_sources_modified_since(self, timestamp):
return []
class MockDataSourceProvider(DataSourceProvider):
# for testing only
def __init__(self, data_sources_by_domain=None, referenced_doc_type=None):
self.referenced_doc_type = referenced_doc_type
self.data_sources_by_domain = data_sources_by_domain or {}
def get_all_data_sources(self):
return [ds for domain, domain_sources in self.data_sources_by_domain.items() for ds in domain_sources]
def get_data_sources_modified_since(self, timestamp):
return []
| 33.743902 | 110 | 0.73979 | 317 | 2,767 | 6.097792 | 0.239748 | 0.125194 | 0.079152 | 0.099327 | 0.446456 | 0.41076 | 0.318158 | 0.240559 | 0.190895 | 0.114847 | 0 | 0 | 0.192266 | 2,767 | 81 | 111 | 34.160494 | 0.864877 | 0.045537 | 0 | 0.363636 | 0 | 0 | 0.027376 | 0.027376 | 0 | 0 | 0 | 0 | 0 | 1 | 0.236364 | false | 0.036364 | 0.072727 | 0.127273 | 0.563636 | 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 |
f41873d165f3e594a57f8d67762a7c2011f0d2a3 | 1,647 | py | Python | 03_Strings/11_AlphabetRangoli.py | vibhorsingh11/hackerrank-python | e00c1198c527f503f6146ab7477a54b0572d3f91 | [
"MIT"
] | null | null | null | 03_Strings/11_AlphabetRangoli.py | vibhorsingh11/hackerrank-python | e00c1198c527f503f6146ab7477a54b0572d3f91 | [
"MIT"
] | null | null | null | 03_Strings/11_AlphabetRangoli.py | vibhorsingh11/hackerrank-python | e00c1198c527f503f6146ab7477a54b0572d3f91 | [
"MIT"
] | null | null | null | """
You are given an integer, N. Your task is to print an alphabet rangoli of size N. (Rangoli is a form of Indian folk art based on creation
of patterns.)
Different sizes of alphabet rangoli are shown below:
#size 3
----c----
--c-b-c--
c-b-a-b-c
--c-b-c--
----c----
#size 5
--------e--------
------e-d-e------
----e-d-c-d-e----
--e-d-c-b-c-d-e--
e-d-c-b-a-b-c-d-e
--e-d-c-b-c-d-e--
----e-d-c-d-e----
------e-d-e------
--------e--------
#size 10
------------------j------------------
----------------j-i-j----------------
--------------j-i-h-i-j--------------
------------j-i-h-g-h-i-j------------
----------j-i-h-g-f-g-h-i-j----------
--------j-i-h-g-f-e-f-g-h-i-j--------
------j-i-h-g-f-e-d-e-f-g-h-i-j------
----j-i-h-g-f-e-d-c-d-e-f-g-h-i-j----
--j-i-h-g-f-e-d-c-b-c-d-e-f-g-h-i-j--
j-i-h-g-f-e-d-c-b-a-b-c-d-e-f-g-h-i-j
--j-i-h-g-f-e-d-c-b-c-d-e-f-g-h-i-j--
----j-i-h-g-f-e-d-c-d-e-f-g-h-i-j----
------j-i-h-g-f-e-d-e-f-g-h-i-j------
--------j-i-h-g-f-e-f-g-h-i-j--------
----------j-i-h-g-f-g-h-i-j----------
------------j-i-h-g-h-i-j------------
--------------j-i-h-i-j--------------
----------------j-i-j----------------
------------------j------------------
The center of the rangoli has the first alphabet letter a, and the boundary has the Nth alphabet letter (in alphabetical order).
"""
import string
def print_rangoli(size):
# your code goes here
alpha = string.ascii_lowercase
L = []
for i in range(size):
s = "-".join(alpha[i:n])
L.append((s[::-1] + s[1:]).center(4 * n - 3, "-"))
print('\n'.join(L[:0:-1] + L))
if __name__ == '__main__':
n = int(input())
print_rangoli(n)
| 24.58209 | 138 | 0.419551 | 352 | 1,647 | 1.931818 | 0.210227 | 0.052941 | 0.075 | 0.094118 | 0.345588 | 0.314706 | 0.314706 | 0.314706 | 0.314706 | 0.285294 | 0 | 0.006906 | 0.120826 | 1,647 | 66 | 139 | 24.954545 | 0.462707 | 0.802064 | 0 | 0 | 0 | 0 | 0.037736 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0.090909 | false | 0 | 0.090909 | 0 | 0.181818 | 0.272727 | 0 | 0 | 1 | null | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 3 |
f41aa957c5878917ade8849ed33aa5df54869e6c | 1,341 | py | Python | core/models.py | uadson/django-api-user-register | d09415c84e5a563566e83c544dd9edf47d991280 | [
"MIT"
] | 1 | 2021-11-17T02:41:45.000Z | 2021-11-17T02:41:45.000Z | core/models.py | uadson/django-api-user-register | d09415c84e5a563566e83c544dd9edf47d991280 | [
"MIT"
] | 2 | 2021-11-16T15:37:39.000Z | 2021-11-16T15:37:51.000Z | core/models.py | uadson/django-api-user-register | d09415c84e5a563566e83c544dd9edf47d991280 | [
"MIT"
] | null | null | null | # Custom User
from django.contrib.auth.models import AbstractUser
# App Models
from django.db import models
# Timezone
from django.utils import timezone
# Module for generate password
import uuid
class User(AbstractUser):
pass
class Base(models.Model):
"""Model Base that repeat in all models"""
created = models.DateTimeField(auto_now_add=True)
updated = models.DateTimeField(auto_now=True)
class Client(Base):
"""Model Client
user, email, birth date and password
* password is not mandatory but when no value is entered, a random password will be generated.
"""
email = models.EmailField(max_length=150, verbose_name="Email")
birth_date = models.DateField(default=timezone.now)
password = models.CharField(max_length=36, verbose_name="Senha", blank=True)
class Meta:
ordering = ('-email',)
verbose_name = 'Client'
verbose_name_plural = 'Clients'
def __str__(self):
return self.email
def save(self, *args, **kwargs):
if self.password == '':
self.password = str(uuid.uuid1())
super().save(*args, **kwargs)
def to_dict_json(self):
return {
'pk': self.pk,
'email': self.email,
'birth_date': self.birth_date,
'password': self.password,
}
| 24.833333 | 102 | 0.644295 | 164 | 1,341 | 5.152439 | 0.493902 | 0.042604 | 0.049704 | 0.061538 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0.005946 | 0.247576 | 1,341 | 53 | 103 | 25.301887 | 0.831516 | 0.181954 | 0 | 0 | 1 | 0 | 0.050847 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0.1 | false | 0.166667 | 0.133333 | 0.066667 | 0.6 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 1 | 0 | 0 | 3 |
f41b26bae0c7373bdef7528103e8357362ea4a91 | 247 | py | Python | cracking_the_coding_interview_qs/8.12/print_8_queens_test.py | angelusualle/algorithms | 86286a49db2a755bc57330cb455bcbd8241ea6be | [
"Apache-2.0"
] | null | null | null | cracking_the_coding_interview_qs/8.12/print_8_queens_test.py | angelusualle/algorithms | 86286a49db2a755bc57330cb455bcbd8241ea6be | [
"Apache-2.0"
] | null | null | null | cracking_the_coding_interview_qs/8.12/print_8_queens_test.py | angelusualle/algorithms | 86286a49db2a755bc57330cb455bcbd8241ea6be | [
"Apache-2.0"
] | null | null | null | import unittest
from print_8_queens import print_8_queens
class Test_Case_print_8_queens(unittest.TestCase):
def test_print_8_queens(self):
num_ans = [0]
print_8_queens(num_ans=num_ans)
self.assertEqual(num_ans[0], 92) | 30.875 | 50 | 0.744939 | 40 | 247 | 4.175 | 0.425 | 0.179641 | 0.359281 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0.044335 | 0.178138 | 247 | 8 | 51 | 30.875 | 0.778325 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0.142857 | 1 | 0.142857 | false | 0 | 0.285714 | 0 | 0.571429 | 0.571429 | 0 | 0 | 0 | null | 0 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 3 |
f4223bf48a2959bd0eb48d8d71001e4b1e66b00b | 4,716 | py | Python | GPy/kern/_src/static.py | strongh/GPy | 775ce9e64c1e8f472083b8f2430134047d97b2fa | [
"BSD-3-Clause"
] | 1 | 2015-08-06T13:47:10.000Z | 2015-08-06T13:47:10.000Z | GPy/kern/_src/static.py | strongh/GPy | 775ce9e64c1e8f472083b8f2430134047d97b2fa | [
"BSD-3-Clause"
] | null | null | null | GPy/kern/_src/static.py | strongh/GPy | 775ce9e64c1e8f472083b8f2430134047d97b2fa | [
"BSD-3-Clause"
] | 1 | 2021-12-09T01:31:17.000Z | 2021-12-09T01:31:17.000Z | # Copyright (c) 2012, GPy authors (see AUTHORS.txt).
# Licensed under the BSD 3-clause license (see LICENSE.txt)
from kern import Kern
import numpy as np
from ...core.parameterization import Param
from ...core.parameterization.transformations import Logexp
class Static(Kern):
def __init__(self, input_dim, variance, active_dims, name):
super(Static, self).__init__(input_dim, active_dims, name)
self.variance = Param('variance', variance, Logexp())
self.link_parameters(self.variance)
def Kdiag(self, X):
ret = np.empty((X.shape[0],), dtype=np.float64)
ret[:] = self.variance
return ret
def gradients_X(self, dL_dK, X, X2=None):
return np.zeros(X.shape)
def gradients_X_diag(self, dL_dKdiag, X):
return np.zeros(X.shape)
def gradients_Z_expectations(self, dL_dpsi0, dL_dpsi1, dL_dpsi2, Z, variational_posterior):
return np.zeros(Z.shape)
def gradients_qX_expectations(self, dL_dpsi0, dL_dpsi1, dL_dpsi2, Z, variational_posterior):
return np.zeros(variational_posterior.shape), np.zeros(variational_posterior.shape)
def psi0(self, Z, variational_posterior):
return self.Kdiag(variational_posterior.mean)
def psi1(self, Z, variational_posterior):
return self.K(variational_posterior.mean, Z)
def psi2(self, Z, variational_posterior):
K = self.K(variational_posterior.mean, Z)
return np.einsum('ij,ik->jk',K,K) #K[:,:,None]*K[:,None,:] # NB. more efficient implementations on inherriting classes
def input_sensitivity(self, summarize=True):
if summarize:
return super(Static, self).input_sensitivity(summarize=summarize)
else:
return np.ones(self.input_dim) * self.variance
class White(Static):
def __init__(self, input_dim, variance=1., active_dims=None, name='white'):
super(White, self).__init__(input_dim, variance, active_dims, name)
def K(self, X, X2=None):
if X2 is None:
return np.eye(X.shape[0])*self.variance
else:
return np.zeros((X.shape[0], X2.shape[0]))
def psi2(self, Z, variational_posterior):
return np.zeros((Z.shape[0], Z.shape[0]), dtype=np.float64)
def update_gradients_full(self, dL_dK, X, X2=None):
self.variance.gradient = np.trace(dL_dK)
def update_gradients_diag(self, dL_dKdiag, X):
self.variance.gradient = dL_dKdiag.sum()
def update_gradients_expectations(self, dL_dpsi0, dL_dpsi1, dL_dpsi2, Z, variational_posterior):
self.variance.gradient = dL_dpsi0.sum()
class Bias(Static):
def __init__(self, input_dim, variance=1., active_dims=None, name='bias'):
super(Bias, self).__init__(input_dim, variance, active_dims, name)
def K(self, X, X2=None):
shape = (X.shape[0], X.shape[0] if X2 is None else X2.shape[0])
ret = np.empty(shape, dtype=np.float64)
ret[:] = self.variance
return ret
def update_gradients_full(self, dL_dK, X, X2=None):
self.variance.gradient = dL_dK.sum()
def update_gradients_diag(self, dL_dKdiag, X):
self.variance.gradient = dL_dKdiag.sum()
def psi2(self, Z, variational_posterior):
ret = np.empty((Z.shape[0], Z.shape[0]), dtype=np.float64)
ret[:] = self.variance*self.variance*variational_posterior.shape[0]
return ret
def update_gradients_expectations(self, dL_dpsi0, dL_dpsi1, dL_dpsi2, Z, variational_posterior):
self.variance.gradient = dL_dpsi0.sum() + dL_dpsi1.sum() + 2.*self.variance*dL_dpsi2.sum()*variational_posterior.shape[0]
class Fixed(Static):
def __init__(self, input_dim, covariance_matrix, variance=1., active_dims=None, name='fixed'):
"""
:param input_dim: the number of input dimensions
:type input_dim: int
:param variance: the variance of the kernel
:type variance: float
"""
super(Fixed, self).__init__(input_dim, variance, active_dims, name)
self.fixed_K = covariance_matrix
def K(self, X, X2):
return self.variance * self.fixed_K
def Kdiag(self, X):
return self.variance * self.fixed_K.diag()
def update_gradients_full(self, dL_dK, X, X2=None):
self.variance.gradient = np.einsum('ij,ij', dL_dK, self.fixed_K)
def update_gradients_diag(self, dL_dKdiag, X):
self.variance.gradient = np.einsum('i,i', dL_dKdiag, self.fixed_K)
def psi2(self, Z, variational_posterior):
return np.zeros((Z.shape[0], Z.shape[0]), dtype=np.float64)
def update_gradients_expectations(self, dL_dpsi0, dL_dpsi1, dL_dpsi2, Z, variational_posterior):
self.variance.gradient = dL_dpsi0.sum()
| 38.341463 | 129 | 0.674936 | 668 | 4,716 | 4.558383 | 0.161677 | 0.078818 | 0.075862 | 0.053202 | 0.621675 | 0.579967 | 0.464696 | 0.444335 | 0.422989 | 0.387849 | 0 | 0.018848 | 0.20123 | 4,716 | 122 | 130 | 38.655738 | 0.789488 | 0.069338 | 0 | 0.385542 | 0 | 0 | 0.008992 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0.349398 | false | 0 | 0.048193 | 0.120482 | 0.662651 | 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 |
f423dec36afb9d4525209df0cb8ddbe74870700a | 1,371 | py | Python | tests/test_platforms.py | pmuller/ipkg | 9e3df803e0f16035a7552f63bbf54886244827d8 | [
"MIT"
] | 3 | 2016-04-20T21:24:59.000Z | 2021-11-17T10:58:49.000Z | tests/test_platforms.py | pmuller/ipkg | 9e3df803e0f16035a7552f63bbf54886244827d8 | [
"MIT"
] | null | null | null | tests/test_platforms.py | pmuller/ipkg | 9e3df803e0f16035a7552f63bbf54886244827d8 | [
"MIT"
] | null | null | null | from unittest import TestCase
import platform
from ipkg.platforms import Platform, InvalidPlatform
class TestPlatform(TestCase):
def test_str(self):
p = Platform('a', 'b', 'c')
self.assertEqual(str(p), 'a-b-c')
def test_eq(self):
p = Platform('a', 'b', 'c')
self.assertEqual('a-b-c', p)
self.assertEqual(p, 'a-b-c')
self.assertEqual('any', p)
self.assertEqual(p, 'any')
self.assertEqual('any-any-any', p)
self.assertEqual(p, 'any-any-any')
self.assertFalse(p == 'a-b')
def test_ne(self):
self.assertTrue(Platform('osx','10.9','x86_64') != 'osx-10.8-x86_64')
def test_parse_any(self):
p = Platform.parse('ANY')
self.assertEqual(p.os_name, 'any')
self.assertEqual(p.os_release, 'any')
self.assertEqual(p.architecture, 'any')
def test_parse(self):
p = Platform.parse('a-b-c')
self.assertEqual(p.os_name, 'a')
self.assertEqual(p.os_release, 'b')
self.assertEqual(p.architecture, 'c')
def test_parse_invalid(self):
self.assertRaises(InvalidPlatform, Platform.parse, 'a-b')
def test_current(self):
p = Platform.current()
if platform.system() == 'Darwin':
self.assertEqual(p.os_name, 'osx')
self.assertEqual(p.architecture, platform.machine())
| 29.804348 | 77 | 0.601751 | 182 | 1,371 | 4.445055 | 0.230769 | 0.278121 | 0.217553 | 0.111248 | 0.31026 | 0.133498 | 0.076638 | 0.076638 | 0 | 0 | 0 | 0.013359 | 0.235594 | 1,371 | 45 | 78 | 30.466667 | 0.758588 | 0 | 0 | 0.057143 | 0 | 0 | 0.081692 | 0 | 0 | 0 | 0 | 0 | 0.514286 | 1 | 0.2 | false | 0 | 0.085714 | 0 | 0.314286 | 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 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 3 |
f427db70bd25b8214dfb5543732c22edd000bd95 | 15,191 | py | Python | gewittergefahr/deep_learning/backwards_optimization_test.py | dopplerchase/GewitterGefahr | 4415b08dd64f37eba5b1b9e8cc5aa9af24f96593 | [
"MIT"
] | 26 | 2018-10-04T01:07:35.000Z | 2022-01-29T08:49:32.000Z | gewittergefahr/deep_learning/backwards_optimization_test.py | liuximarcus/GewitterGefahr | d819874d616f98a25187bfd3091073a2e6d5279e | [
"MIT"
] | 4 | 2017-12-25T02:01:08.000Z | 2018-12-19T01:54:21.000Z | gewittergefahr/deep_learning/backwards_optimization_test.py | liuximarcus/GewitterGefahr | d819874d616f98a25187bfd3091073a2e6d5279e | [
"MIT"
] | 11 | 2017-12-10T23:05:29.000Z | 2022-01-29T08:49:33.000Z | """Unit tests for backwards_optimization.py."""
import unittest
import numpy
import pandas
from gewittergefahr.gg_utils import radar_utils
from gewittergefahr.gg_utils import soundings
from gewittergefahr.deep_learning import cnn
from gewittergefahr.deep_learning import backwards_optimization as backwards_opt
from gewittergefahr.deep_learning import deep_learning_utils as dl_utils
from gewittergefahr.deep_learning import training_validation_io as trainval_io
TOLERANCE = 1e-6
ARRAY_DIMENSIONS_2D = numpy.array([1, 2], dtype=int)
ARRAY_DIMENSIONS_3D = numpy.array([1, 37, 6], dtype=int)
ARRAY_DIMENSIONS_4D = numpy.array([1, 32, 32, 12], dtype=int)
ARRAY_DIMENSIONS_5D = numpy.array([1, 16, 16, 12, 4], dtype=int)
# The following constants are used to test create_gaussian_initializer.
GAUSSIAN_MEAN = 0.
GAUSSIAN_STANDARD_DEVIATION = 0.
GAUSSIAN_MATRIX_3D = numpy.full(ARRAY_DIMENSIONS_3D, 0.)
GAUSSIAN_MATRIX_4D = numpy.full(ARRAY_DIMENSIONS_4D, 0.)
GAUSSIAN_MATRIX_5D = numpy.full(ARRAY_DIMENSIONS_5D, 0.)
# The following constants are used to test create_uniform_random_initializer.
MIN_UNIFORM_VALUE = 1.
MAX_UNIFORM_VALUE = 1.
UNIFORM_MATRIX_3D = numpy.full(ARRAY_DIMENSIONS_3D, 1.)
UNIFORM_MATRIX_4D = numpy.full(ARRAY_DIMENSIONS_4D, 1.)
UNIFORM_MATRIX_5D = numpy.full(ARRAY_DIMENSIONS_5D, 1.)
# The following constants are used to test create_constant_initializer.
CONSTANT_VALUE = 2.
CONSTANT_MATRIX_3D = numpy.full(ARRAY_DIMENSIONS_3D, 2.)
CONSTANT_MATRIX_4D = numpy.full(ARRAY_DIMENSIONS_4D, 2.)
CONSTANT_MATRIX_5D = numpy.full(ARRAY_DIMENSIONS_5D, 2.)
# The following constants are used to test create_climo_initializer.
SOUNDING_FIELD_NAMES = [
soundings.TEMPERATURE_NAME, soundings.VIRTUAL_POTENTIAL_TEMPERATURE_NAME
]
SOUNDING_HEIGHTS_M_AGL = numpy.array([0, 500, 1000, 1500], dtype=int)
THESE_FIELD_NAMES = [radar_utils.REFL_NAME, radar_utils.SPECTRUM_WIDTH_NAME]
THESE_HEIGHTS_M_AGL = numpy.array([1000, 2000, 3000], dtype=int)
TRAINING_OPTION_DICT_3D = {
trainval_io.RADAR_FIELDS_KEY: THESE_FIELD_NAMES,
trainval_io.RADAR_HEIGHTS_KEY: THESE_HEIGHTS_M_AGL,
trainval_io.SOUNDING_FIELDS_KEY: SOUNDING_FIELD_NAMES,
trainval_io.SOUNDING_HEIGHTS_KEY: SOUNDING_HEIGHTS_M_AGL,
trainval_io.NORMALIZATION_TYPE_KEY:
dl_utils.MINMAX_NORMALIZATION_TYPE_STRING,
trainval_io.MIN_NORMALIZED_VALUE_KEY: 0.,
trainval_io.MAX_NORMALIZED_VALUE_KEY: 1.,
trainval_io.NORMALIZATION_FILE_KEY: 'foo'
}
THESE_FIELD_NAMES = [
radar_utils.REFL_NAME, radar_utils.REFL_NAME, radar_utils.REFL_NAME,
radar_utils.REFL_COLUMN_MAX_NAME
]
THESE_HEIGHTS_M_AGL = numpy.array([1000, 2000, 3000, 250], dtype=int)
TRAINING_OPTION_DICT_2D = {
trainval_io.RADAR_FIELDS_KEY: THESE_FIELD_NAMES,
trainval_io.RADAR_HEIGHTS_KEY: THESE_HEIGHTS_M_AGL,
trainval_io.SOUNDING_FIELDS_KEY: SOUNDING_FIELD_NAMES,
trainval_io.SOUNDING_HEIGHTS_KEY: SOUNDING_HEIGHTS_M_AGL,
trainval_io.NORMALIZATION_TYPE_KEY:
dl_utils.MINMAX_NORMALIZATION_TYPE_STRING,
trainval_io.MIN_NORMALIZED_VALUE_KEY: 0.,
trainval_io.MAX_NORMALIZED_VALUE_KEY: 1.,
trainval_io.NORMALIZATION_FILE_KEY: 'foo'
}
RADAR_NORMALIZATION_DICT = {
(radar_utils.REFL_NAME, 1000): numpy.array([8.65, 1, 0, 0]),
(radar_utils.REFL_NAME, 2000): numpy.array([15.5, 1, 0, 0]),
(radar_utils.REFL_NAME, 3000): numpy.array([18.3, 1, 0, 0]),
(radar_utils.SPECTRUM_WIDTH_NAME, 1000): numpy.array([0.169, 1, 0, 0]),
(radar_utils.SPECTRUM_WIDTH_NAME, 2000): numpy.array([0.423, 1, 0, 0]),
(radar_utils.SPECTRUM_WIDTH_NAME, 3000): numpy.array([0.81, 1, 0, 0]),
(radar_utils.REFL_COLUMN_MAX_NAME, 250): numpy.array([20.7, 1, 0, 0]),
radar_utils.REFL_NAME: numpy.array([0., 0, 0, 20]),
radar_utils.SPECTRUM_WIDTH_NAME: numpy.array([0, 0, 0.1, 1.1]),
radar_utils.REFL_COLUMN_MAX_NAME: numpy.array([0., 0, 0, 50])
}
RADAR_NORMALIZATION_TABLE = pandas.DataFrame.from_dict(
RADAR_NORMALIZATION_DICT, orient='index')
COLUMN_DICT_OLD_TO_NEW = {
0: dl_utils.MEAN_VALUE_COLUMN,
1: dl_utils.STANDARD_DEVIATION_COLUMN,
2: dl_utils.MIN_VALUE_COLUMN,
3: dl_utils.MAX_VALUE_COLUMN
}
RADAR_NORMALIZATION_TABLE.rename(columns=COLUMN_DICT_OLD_TO_NEW, inplace=True)
SOUNDING_NORMALIZATION_DICT = {
(soundings.TEMPERATURE_NAME, 0): numpy.array([262., 1, 0, 0]),
(soundings.TEMPERATURE_NAME, 500): numpy.array([280., 1, 0, 0]),
(soundings.TEMPERATURE_NAME, 1000): numpy.array([289., 1, 0, 0]),
(soundings.TEMPERATURE_NAME, 1500): numpy.array([297., 1, 0, 0]),
(soundings.VIRTUAL_POTENTIAL_TEMPERATURE_NAME, 0):
numpy.array([319., 1, 0, 0]),
(soundings.VIRTUAL_POTENTIAL_TEMPERATURE_NAME, 500):
numpy.array([311., 1, 0, 0]),
(soundings.VIRTUAL_POTENTIAL_TEMPERATURE_NAME, 1000):
numpy.array([305., 1, 0, 0]),
(soundings.VIRTUAL_POTENTIAL_TEMPERATURE_NAME, 1500):
numpy.array([299., 1, 0, 0]),
soundings.TEMPERATURE_NAME: numpy.array([0., 0, 210, 310]),
soundings.VIRTUAL_POTENTIAL_TEMPERATURE_NAME: numpy.array([0., 0, 280, 380])
}
SOUNDING_NORMALIZATION_TABLE = pandas.DataFrame.from_dict(
SOUNDING_NORMALIZATION_DICT, orient='index')
SOUNDING_NORMALIZATION_TABLE.rename(
columns=COLUMN_DICT_OLD_TO_NEW, inplace=True)
SOUNDING_DIMENSIONS = numpy.array([1, 4, 2], dtype=int)
RADAR_DIMENSIONS_4D = numpy.array([1, 16, 32, 4], dtype=int)
RADAR_DIMENSIONS_5D = numpy.array([1, 16, 32, 3, 2], dtype=int)
INIT_SOUNDING_MATRIX = numpy.array([
[262, 319],
[280, 311],
[289, 305],
[297, 299]
], dtype=float)
INIT_SOUNDING_MATRIX[:, 0] = (INIT_SOUNDING_MATRIX[:, 0] - 210) / 100
INIT_SOUNDING_MATRIX[:, 1] = (INIT_SOUNDING_MATRIX[:, 1] - 280) / 100
INIT_SOUNDING_MATRIX = numpy.expand_dims(INIT_SOUNDING_MATRIX, axis=0)
THIS_MATRIX_FIELD1 = numpy.full(
(RADAR_DIMENSIONS_4D[1], RADAR_DIMENSIONS_4D[2]), 8.65 / 20
)
THIS_MATRIX_FIELD2 = numpy.full(
(RADAR_DIMENSIONS_4D[1], RADAR_DIMENSIONS_4D[2]), 15.5 / 20
)
THIS_MATRIX_FIELD3 = numpy.full(
(RADAR_DIMENSIONS_4D[1], RADAR_DIMENSIONS_4D[2]), 18.3 / 20
)
THIS_MATRIX_FIELD4 = numpy.full(
(RADAR_DIMENSIONS_4D[1], RADAR_DIMENSIONS_4D[2]), 20.7 / 50
)
INIT_RADAR_MATRIX_4D = numpy.stack((
THIS_MATRIX_FIELD1, THIS_MATRIX_FIELD2, THIS_MATRIX_FIELD3,
THIS_MATRIX_FIELD4
), axis=-1)
INIT_RADAR_MATRIX_4D = numpy.expand_dims(INIT_RADAR_MATRIX_4D, axis=0)
THIS_MATRIX_FIELD1_HEIGHT1 = numpy.full(
(RADAR_DIMENSIONS_5D[1], RADAR_DIMENSIONS_5D[2]), 8.65 / 20
)
THIS_MATRIX_FIELD1_HEIGHT2 = numpy.full(
(RADAR_DIMENSIONS_5D[1], RADAR_DIMENSIONS_5D[2]), 15.5 / 20
)
THIS_MATRIX_FIELD1_HEIGHT3 = numpy.full(
(RADAR_DIMENSIONS_5D[1], RADAR_DIMENSIONS_5D[2]), 18.3 / 20
)
THIS_MATRIX_FIELD1 = numpy.stack((
THIS_MATRIX_FIELD1_HEIGHT1, THIS_MATRIX_FIELD1_HEIGHT2,
THIS_MATRIX_FIELD1_HEIGHT3
), axis=-1)
THIS_MATRIX_FIELD2_HEIGHT1 = numpy.full(
(RADAR_DIMENSIONS_5D[1], RADAR_DIMENSIONS_5D[2]), 0.169 - 0.1
)
THIS_MATRIX_FIELD2_HEIGHT2 = numpy.full(
(RADAR_DIMENSIONS_5D[1], RADAR_DIMENSIONS_5D[2]), 0.423 - 0.1
)
THIS_MATRIX_FIELD2_HEIGHT3 = numpy.full(
(RADAR_DIMENSIONS_5D[1], RADAR_DIMENSIONS_5D[2]), 0.81 - 0.1
)
THIS_MATRIX_FIELD2 = numpy.stack((
THIS_MATRIX_FIELD2_HEIGHT1, THIS_MATRIX_FIELD2_HEIGHT2,
THIS_MATRIX_FIELD2_HEIGHT3
), axis=-1)
INIT_RADAR_MATRIX_5D = numpy.stack(
(THIS_MATRIX_FIELD1, THIS_MATRIX_FIELD2), axis=-1
)
INIT_RADAR_MATRIX_5D = numpy.expand_dims(INIT_RADAR_MATRIX_5D, axis=0)
class FeatureOptimizationTests(unittest.TestCase):
"""Each method is a unit test for backwards_optimization.py."""
def test_create_gaussian_initializer_3d(self):
"""Ensures correct output from create_gaussian_initializer.
In this case, the desired matrix is 3-D.
"""
this_init_function = backwards_opt.create_gaussian_initializer(
mean=GAUSSIAN_MEAN, standard_deviation=GAUSSIAN_STANDARD_DEVIATION)
this_matrix = this_init_function(ARRAY_DIMENSIONS_3D)
self.assertTrue(numpy.allclose(
this_matrix, GAUSSIAN_MATRIX_3D, atol=TOLERANCE
))
def test_create_gaussian_initializer_4d(self):
"""Ensures correct output from create_gaussian_initializer.
In this case, the desired matrix is 4-D.
"""
this_init_function = backwards_opt.create_gaussian_initializer(
mean=GAUSSIAN_MEAN, standard_deviation=GAUSSIAN_STANDARD_DEVIATION)
this_matrix = this_init_function(ARRAY_DIMENSIONS_4D)
self.assertTrue(numpy.allclose(
this_matrix, GAUSSIAN_MATRIX_4D, atol=TOLERANCE
))
def test_create_gaussian_initializer_5d(self):
"""Ensures correct output from create_gaussian_initializer.
In this case, the desired matrix is 5-D.
"""
this_init_function = backwards_opt.create_gaussian_initializer(
mean=GAUSSIAN_MEAN, standard_deviation=GAUSSIAN_STANDARD_DEVIATION)
this_matrix = this_init_function(ARRAY_DIMENSIONS_5D)
self.assertTrue(numpy.allclose(
this_matrix, GAUSSIAN_MATRIX_5D, atol=TOLERANCE
))
def test_create_uniform_random_initializer_3d(self):
"""Ensures correct output from create_uniform_random_initializer.
In this case, the desired matrix is 3-D.
"""
this_init_function = backwards_opt.create_uniform_random_initializer(
min_value=MIN_UNIFORM_VALUE, max_value=MAX_UNIFORM_VALUE)
this_matrix = this_init_function(ARRAY_DIMENSIONS_3D)
self.assertTrue(numpy.allclose(
this_matrix, UNIFORM_MATRIX_3D, atol=TOLERANCE
))
def test_create_uniform_random_initializer_4d(self):
"""Ensures correct output from create_uniform_random_initializer.
In this case, the desired matrix is 4-D.
"""
this_init_function = backwards_opt.create_uniform_random_initializer(
min_value=MIN_UNIFORM_VALUE, max_value=MAX_UNIFORM_VALUE)
this_matrix = this_init_function(ARRAY_DIMENSIONS_4D)
self.assertTrue(numpy.allclose(
this_matrix, UNIFORM_MATRIX_4D, atol=TOLERANCE
))
def test_create_uniform_random_initializer_5d(self):
"""Ensures correct output from create_uniform_random_initializer.
In this case, the desired matrix is 5-D.
"""
this_init_function = backwards_opt.create_uniform_random_initializer(
min_value=MIN_UNIFORM_VALUE, max_value=MAX_UNIFORM_VALUE)
this_matrix = this_init_function(ARRAY_DIMENSIONS_5D)
self.assertTrue(numpy.allclose(
this_matrix, UNIFORM_MATRIX_5D, atol=TOLERANCE
))
def test_create_constant_initializer_3d(self):
"""Ensures correct output from create_constant_initializer.
In this case, the desired matrix is 3-D.
"""
this_init_function = backwards_opt.create_constant_initializer(
constant_value=CONSTANT_VALUE)
this_matrix = this_init_function(ARRAY_DIMENSIONS_3D)
self.assertTrue(numpy.allclose(
this_matrix, CONSTANT_MATRIX_3D, atol=TOLERANCE
))
def test_create_constant_initializer_4d(self):
"""Ensures correct output from create_constant_initializer.
In this case, the desired matrix is 4-D.
"""
this_init_function = backwards_opt.create_constant_initializer(
constant_value=CONSTANT_VALUE)
this_matrix = this_init_function(ARRAY_DIMENSIONS_4D)
self.assertTrue(numpy.allclose(
this_matrix, CONSTANT_MATRIX_4D, atol=TOLERANCE
))
def test_create_constant_initializer_5d(self):
"""Ensures correct output from create_constant_initializer.
In this case, the desired matrix is 5-D.
"""
this_init_function = backwards_opt.create_constant_initializer(
constant_value=CONSTANT_VALUE)
this_matrix = this_init_function(ARRAY_DIMENSIONS_5D)
self.assertTrue(numpy.allclose(
this_matrix, CONSTANT_MATRIX_5D, atol=TOLERANCE
))
def test_create_climo_initializer_3d(self):
"""Ensures correct output from create_climo_initializer.
In this case, the desired matrix is 3-D.
"""
this_metadata_dict = {
cnn.TRAINING_OPTION_DICT_KEY: TRAINING_OPTION_DICT_3D,
cnn.CONV_2D3D_KEY: False
}
this_init_function = backwards_opt.create_climo_initializer(
model_metadata_dict=this_metadata_dict, test_mode=True,
radar_normalization_table=RADAR_NORMALIZATION_TABLE,
sounding_normalization_table=SOUNDING_NORMALIZATION_TABLE)
this_matrix = this_init_function(SOUNDING_DIMENSIONS)
self.assertTrue(numpy.allclose(
this_matrix, INIT_SOUNDING_MATRIX, atol=TOLERANCE
))
def test_create_climo_initializer_4d(self):
"""Ensures correct output from create_climo_initializer.
In this case, the desired matrix is 4-D.
"""
this_metadata_dict = {
cnn.TRAINING_OPTION_DICT_KEY: TRAINING_OPTION_DICT_2D,
cnn.CONV_2D3D_KEY: False,
cnn.LAYER_OPERATIONS_KEY: None
}
this_init_function = backwards_opt.create_climo_initializer(
model_metadata_dict=this_metadata_dict, test_mode=True,
radar_normalization_table=RADAR_NORMALIZATION_TABLE,
sounding_normalization_table=SOUNDING_NORMALIZATION_TABLE)
this_matrix = this_init_function(RADAR_DIMENSIONS_4D)
self.assertTrue(numpy.allclose(
this_matrix, INIT_RADAR_MATRIX_4D, atol=TOLERANCE
))
def test_create_climo_initializer_5d(self):
"""Ensures correct output from create_climo_initializer.
In this case, the desired matrix is 5-D.
"""
this_metadata_dict = {
cnn.TRAINING_OPTION_DICT_KEY: TRAINING_OPTION_DICT_3D,
cnn.CONV_2D3D_KEY: False
}
this_init_function = backwards_opt.create_climo_initializer(
model_metadata_dict=this_metadata_dict, test_mode=True,
radar_normalization_table=RADAR_NORMALIZATION_TABLE,
sounding_normalization_table=SOUNDING_NORMALIZATION_TABLE)
this_matrix = this_init_function(RADAR_DIMENSIONS_5D)
self.assertTrue(numpy.allclose(
this_matrix, INIT_RADAR_MATRIX_5D, atol=TOLERANCE
))
def test_create_climo_initializer_2d(self):
"""Ensures correct output from create_climo_initializer.
In this case, the desired matrix is 2-D (invalid).
"""
this_metadata_dict = {
cnn.TRAINING_OPTION_DICT_KEY: TRAINING_OPTION_DICT_3D,
cnn.CONV_2D3D_KEY: False
}
this_init_function = backwards_opt.create_climo_initializer(
model_metadata_dict=this_metadata_dict, test_mode=True,
radar_normalization_table=RADAR_NORMALIZATION_TABLE,
sounding_normalization_table=SOUNDING_NORMALIZATION_TABLE)
this_matrix = this_init_function(ARRAY_DIMENSIONS_2D)
self.assertTrue(this_matrix is None)
if __name__ == '__main__':
unittest.main()
| 37.416256 | 80 | 0.730762 | 2,023 | 15,191 | 5.081562 | 0.088482 | 0.048638 | 0.040467 | 0.03035 | 0.833366 | 0.752724 | 0.700875 | 0.630447 | 0.543969 | 0.519066 | 0 | 0.043632 | 0.180765 | 15,191 | 405 | 81 | 37.508642 | 0.782403 | 0.110987 | 0 | 0.352518 | 0 | 0 | 0.001817 | 0 | 0 | 0 | 0 | 0 | 0.046763 | 1 | 0.046763 | false | 0 | 0.032374 | 0 | 0.082734 | 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 |
f42efde6221a520e0c9e72accadf7e9b0ee16bef | 147 | py | Python | core/recc/packet/plugin.py | bogonets/answer | 57f892a9841980bcbc35fa1e27521b34cd94bc25 | [
"MIT"
] | 3 | 2021-06-20T02:24:10.000Z | 2022-01-26T23:55:33.000Z | core/recc/packet/plugin.py | bogonets/answer | 57f892a9841980bcbc35fa1e27521b34cd94bc25 | [
"MIT"
] | null | null | null | core/recc/packet/plugin.py | bogonets/answer | 57f892a9841980bcbc35fa1e27521b34cd94bc25 | [
"MIT"
] | null | null | null | # -*- coding: utf-8 -*-
from dataclasses import dataclass
@dataclass
class PluginA:
name: str
@dataclass
class PluginNameA:
name: str
| 10.5 | 33 | 0.680272 | 17 | 147 | 5.882353 | 0.705882 | 0.28 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0.008696 | 0.217687 | 147 | 13 | 34 | 11.307692 | 0.86087 | 0.142857 | 0 | 0.571429 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | true | 0 | 0.142857 | 0 | 0.714286 | 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 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 3 |
f4511376e4bcc8ef6bd9594917d59341cf050367 | 177 | py | Python | main.py | zquaa/league-refresher | 1115291ee1b8b5b2fb80dac83e05686adc492189 | [
"MIT"
] | null | null | null | main.py | zquaa/league-refresher | 1115291ee1b8b5b2fb80dac83e05686adc492189 | [
"MIT"
] | null | null | null | main.py | zquaa/league-refresher | 1115291ee1b8b5b2fb80dac83e05686adc492189 | [
"MIT"
] | null | null | null | import psutil
for process in psutil.process_iter():
try:
if process.name() == "LeagueClientUxRender.exe":
process.kill()
except:
pass | 22.125 | 57 | 0.576271 | 18 | 177 | 5.611111 | 0.777778 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0.322034 | 177 | 8 | 58 | 22.125 | 0.841667 | 0 | 0 | 0 | 0 | 0 | 0.140351 | 0.140351 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | false | 0.142857 | 0.142857 | 0 | 0.142857 | 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 |
f464120518f272ae69a5358ddf7206f67aa60e5e | 716 | py | Python | utils/var_dim.py | Dai-z/pytorch-superpoint | 90e71045238fdcce13f9f0d02bdd0e1126145a10 | [
"MIT"
] | 390 | 2019-12-16T07:36:02.000Z | 2022-03-29T07:27:32.000Z | utils/var_dim.py | Dai-z/pytorch-superpoint | 90e71045238fdcce13f9f0d02bdd0e1126145a10 | [
"MIT"
] | 69 | 2019-12-14T20:38:44.000Z | 2022-03-25T12:53:21.000Z | utils/var_dim.py | Dai-z/pytorch-superpoint | 90e71045238fdcce13f9f0d02bdd0e1126145a10 | [
"MIT"
] | 98 | 2020-01-07T04:29:17.000Z | 2022-03-30T16:09:31.000Z | """change the dimension of tensor/ numpy array
"""
import numpy as np
import torch
# from utils.var_dim import to3dim
def to3dim(img):
if img.ndim == 2:
img = img[:, :, np.newaxis]
return img
# torch
# from utils.var_dim import tensorto4d
def tensorto4d(inp):
if len(inp.shape) == 2:
inp = inp.view(1, 1, inp.shape[0], inp.shape[1])
elif len(inp.shape) == 3:
inp = inp.view(1, inp.shape[0], inp.shape[1], inp.shape[2])
return inp
# torch
# from utils.var_dim import squeezeToNumpy
def squeezeToNumpy(tensor_arr):
return tensor_arr.detach().cpu().numpy().squeeze()
# from utils.var_dim import toNumpy
def toNumpy(tensor):
return tensor.detach().cpu().numpy() | 23.096774 | 67 | 0.659218 | 110 | 716 | 4.236364 | 0.345455 | 0.120172 | 0.103004 | 0.128755 | 0.293991 | 0.248927 | 0.081545 | 0 | 0 | 0 | 0 | 0.026087 | 0.196927 | 716 | 31 | 68 | 23.096774 | 0.784348 | 0.280726 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0.25 | false | 0 | 0.125 | 0.125 | 0.625 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 0 | 1 | 1 | 0 | 0 | 3 |
f46b2ee099757dabe1b8b2f33cf1065ac41fb779 | 135 | py | Python | Matt/OldScripts/cat.py | chrisburch96/LearningLAMOST | 082f1be6841828d6b62982cc11a043005d877668 | [
"MIT"
] | 1 | 2019-01-04T14:55:48.000Z | 2019-01-04T14:55:48.000Z | Matt/OldScripts/cat.py | chrisburch96/LearningLAMOST | 082f1be6841828d6b62982cc11a043005d877668 | [
"MIT"
] | null | null | null | Matt/OldScripts/cat.py | chrisburch96/LearningLAMOST | 082f1be6841828d6b62982cc11a043005d877668 | [
"MIT"
] | 1 | 2018-10-09T15:46:43.000Z | 2018-10-09T15:46:43.000Z | import pandas as pd
import glob
df = pd.concat([pd.read_csv(x, sep = ',') for x in glob.glob('*.csv')])
df.to_csv('../spectra.csv')
| 16.875 | 71 | 0.62963 | 25 | 135 | 3.32 | 0.6 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0.148148 | 135 | 7 | 72 | 19.285714 | 0.721739 | 0 | 0 | 0 | 0 | 0 | 0.149254 | 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 |
f46da8139cf6b4e3556d72ba98168c1400ba1e4f | 395 | py | Python | thinker/core/questionscreator/creatorgoodregularquestion.py | julianandres-eb/guess-number | 8807674858d76b0ed28c2279eb387a1ea979ffe2 | [
"MIT"
] | null | null | null | thinker/core/questionscreator/creatorgoodregularquestion.py | julianandres-eb/guess-number | 8807674858d76b0ed28c2279eb387a1ea979ffe2 | [
"MIT"
] | null | null | null | thinker/core/questionscreator/creatorgoodregularquestion.py | julianandres-eb/guess-number | 8807674858d76b0ed28c2279eb387a1ea979ffe2 | [
"MIT"
] | 1 | 2019-11-22T19:11:43.000Z | 2019-11-22T19:11:43.000Z | from thinker.model.question.questiongoodregular import QuestionGoodregular
from .questioncreator import QuestionCreator
class CreatorGoodregularQuestion(QuestionCreator):
# Override the factory method to return an instance of a
# QuestionGoodRegular.
def _createQuestion(self, values):
return QuestionGoodregular(values['value'], [], values['key'], values['reiterable'])
| 32.916667 | 92 | 0.777215 | 37 | 395 | 8.27027 | 0.702703 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0.139241 | 395 | 11 | 93 | 35.909091 | 0.9 | 0.189873 | 0 | 0 | 0 | 0 | 0.056782 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0.2 | false | 0 | 0.4 | 0.2 | 1 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 1 | 1 | 0 | 0 | 3 |
f475cb0891a2a9a15796327d9ff6f4fe072aa572 | 24,262 | py | Python | is_core/main.py | zamazaljiri/django-is-core | 1f0b2c5fe50d93e20aff4b5d41a7727259b421fd | [
"BSD-3-Clause"
] | null | null | null | is_core/main.py | zamazaljiri/django-is-core | 1f0b2c5fe50d93e20aff4b5d41a7727259b421fd | [
"BSD-3-Clause"
] | null | null | null | is_core/main.py | zamazaljiri/django-is-core | 1f0b2c5fe50d93e20aff4b5d41a7727259b421fd | [
"BSD-3-Clause"
] | null | null | null | """
Core of django-is-core.
Contains controller added between model and UI/REST.
"""
import sys
from collections import OrderedDict
from django.shortcuts import get_object_or_404
from django.utils.translation import ugettext_lazy as _
from django.http.response import Http404
from django.core.exceptions import ValidationError
from django.forms.models import _get_foreign_key
from django.utils.functional import cached_property
from is_core.config import settings
from is_core.actions import WebAction, ConfirmRESTAction
from is_core.generic_views.form_views import AddModelFormView, EditModelFormView, BulkChangeFormView
from is_core.generic_views.table_views import TableView
from is_core.rest.resource import RESTModelResource, UIRESTModelResource
from is_core.auth.main import PermissionsMixin, PermissionsUIMixin, PermissionsRESTMixin
from is_core.patterns import UIPattern, RESTPattern, DoubleRESTPattern, HiddenRESTPattern
from is_core.utils import flatten_fieldsets, str_to_class
from is_core.utils.compatibility import urls_wrapper, get_model_name, reverse
from is_core.menu import LinkMenuItem
from is_core.loading import register_core
from is_core.rest.factory import modelrest_factory
from is_core.forms.models import SmartModelForm
class ISCoreBase(type):
"""Metaclass for IS core classes. Its main purpose is automatic registration cores to your application."""
def __new__(cls, *args, **kwargs):
name, _, attrs = args
abstract = attrs.pop('abstract', False)
super_new = super(ISCoreBase, cls).__new__
new_class = super_new(cls, *args, **kwargs)
model_module = sys.modules[new_class.__module__]
app_label = model_module.__name__.split('.')[-2]
if name != 'NewBase' and not abstract and new_class.register:
register_core(app_label, new_class)
return new_class
class ISCore(PermissionsMixin, metaclass=ISCoreBase):
"""
Parent of all IS cores. Contains common methods for all cores.
This class is abstract.
"""
abstract = True
register = True
verbose_name = None
verbose_name_plural = None
menu_group = None
def __init__(self, site_name, menu_parent_groups):
self.site_name = site_name
self.menu_parent_groups = menu_parent_groups
def init_request(self, request):
pass
def get_urlpatterns(self, patterns):
urls = []
for pattern in patterns.values():
url = pattern.get_url()
if url:
urls.append(url)
return urls_wrapper(*urls)
def get_urls(self):
return ()
def get_views(self):
return {}
def get_menu_groups(self):
menu_groups = list(self.menu_parent_groups)
if self.menu_group:
menu_groups += (self.menu_group,)
return menu_groups
def get_url_prefix(self):
return '/'.join(self.get_menu_groups())
def get_menu_group_pattern_name(self):
return '-'.join(self.get_menu_groups())
class ModelISCore(ISCore):
"""
Parent of REST and UI cores that works as controller to specific model.
This class is abstract.
"""
abstract = True
list_actions = ()
# form params
form_fields = None
form_exclude = ()
form_class = SmartModelForm
form_edit_class = None
form_add_class = None
default_ordering = None
field_labels = {}
def get_form_class(self, request, obj=None):
return self.form_class
def get_form_edit_class(self, request, obj=None):
return self.form_edit_class or self.get_form_class(request, obj)
def get_form_add_class(self, request, obj=None):
return self.form_add_class or self.get_form_class(request, obj)
def get_form_fields(self, request, obj=None):
return self.form_fields
def get_form_exclude(self, request, obj=None):
return self.form_exclude
def get_field_labels(self, request):
return self.field_labels
def pre_save_model(self, request, obj, form, change):
pass
def save_model(self, request, obj, form, change):
obj.save()
def post_save_model(self, request, obj, form, change):
pass
def pre_delete_model(self, request, obj):
pass
def delete_model(self, request, obj):
obj.delete()
def post_delete_model(self, request, obj):
pass
@property
def verbose_name(self):
return self.model._meta.verbose_name
@property
def verbose_name_plural(self):
return self.model._meta.verbose_name_plural
@property
def menu_group(self):
return get_model_name(self.model)
# TODO: remove this function
def get_obj(self, request, **filters):
try:
return get_object_or_404(self.get_queryset(request), **filters)
except (ValidationError, ValueError):
raise Http404
def get_default_ordering(self):
return self.default_ordering if self.default_ordering is not None else (self.model._meta.ordering or ('pk',))
def get_queryset(self, request):
return self.model._default_manager.get_queryset().order_by(*self.get_default_ordering())
def preload_queryset(self, request, qs):
return qs
def get_list_actions(self, request, obj):
return list(self.list_actions)
def get_default_action(self, request, obj):
return None
class UIISCore(PermissionsUIMixin, ISCore):
"""Main core for UI views."""
abstract = True
show_in_menu = True
menu_url_name = None
view_classes = ()
default_ui_pattern_class = UIPattern
def init_ui_request(self, request):
self.init_request(request)
def get_view_classes(self):
return list(self.view_classes)
@cached_property
def ui_patterns(self):
return self.get_ui_patterns()
def get_ui_patterns(self):
ui_patterns = OrderedDict()
for view_class_definition in self.get_view_classes():
name, view_vals = (view_class_definition[0], view_class_definition[1:])
if name not in ui_patterns:
if len(view_vals) == 3:
pattern, view, ViewPatternClass = view_vals
else:
pattern, view = view_vals
ViewPatternClass = self.default_ui_pattern_class
if isinstance(view, str):
view = getattr(self, view)()
pattern_names = [name]
group_pattern_name = self.get_menu_group_pattern_name()
if group_pattern_name:
pattern_names += [self.get_menu_group_pattern_name()]
ui_patterns[name] = ViewPatternClass('-'.join(pattern_names), self.site_name, pattern, view, self)
return ui_patterns
def get_urls(self):
return self.get_urlpatterns(self.ui_patterns)
def get_show_in_menu(self, request):
return (self.show_in_menu and self.menu_url_name and self.menu_url_name in self.ui_patterns and
self.ui_patterns.get(self.menu_url_name).can_call_get(request))
def is_active_menu_item(self, request, active_group):
return active_group == self.menu_group
def get_menu_item(self, request, active_group, item_class=LinkMenuItem):
if self.get_show_in_menu(request):
return item_class(self.verbose_name_plural, self.menu_url(request),
self.menu_group, self.is_active_menu_item(request, active_group))
def menu_url(self, request):
return self.ui_patterns.get(self.menu_url_name).get_url_string(request)
class RESTISCore(PermissionsRESTMixin, ISCore):
"""Main core for REST views."""
rest_classes = ()
default_rest_pattern_class = RESTPattern
abstract = True
def init_rest_request(self, request):
self.init_request(request)
def get_rest_classes(self):
return list(self.rest_classes)
@cached_property
def rest_patterns(self):
return self.get_rest_patterns()
def get_rest_patterns(self):
rest_patterns = OrderedDict()
for rest_class_definition in self.get_rest_classes():
name, rest_vals = (rest_class_definition[0], rest_class_definition[1:])
if name not in rest_patterns:
if len(rest_vals) == 3:
pattern, rest, RESTPatternClass = rest_vals
else:
pattern, rest = rest_vals
RESTPatternClass = self.default_rest_pattern_class
if isinstance(rest, str):
rest = getattr(self, rest)()
pattern_names = [name]
group_pattern_name = self.get_menu_group_pattern_name()
if group_pattern_name:
pattern_names += [self.get_menu_group_pattern_name()]
rest_patterns[name] = RESTPatternClass('-'.join(pattern_names), self.site_name, pattern, rest, self)
return rest_patterns
def get_urls(self):
return self.get_urlpatterns(self.rest_patterns)
class UIRESTISCoreMixin:
"""Helper that joins urls generated wit REST core and UI core."""
def get_urls(self):
return self.get_urlpatterns(self.rest_patterns) + self.get_urlpatterns(self.ui_patterns)
class UIRESTISCore(UIRESTISCoreMixin, UIISCore, RESTISCore):
"""UI REST Core, its main purpose is create custom REST resources and UI views."""
abstract = True
class HomeUIISCore(UIISCore):
menu_url_name = 'index'
verbose_name_plural = _('Home')
menu_group = 'home'
abstract = settings.HOME_CORE != 'is_core.main.HomeUIISCore'
def get_view_classes(self):
view_classes = super(HomeUIISCore, self).get_view_classes()
view_classes.append(('index', r'', str_to_class(settings.HOME_VIEW)))
return view_classes
def menu_url(self, request):
return '/'
def get_url_prefix(self):
return ''
class UIModelISCore(ModelISCore, UIISCore):
"""Main core controller for specific model that provides UI views for model management (add, edit, list)."""
abstract = True
menu_url_name = 'list'
api_url_name = None
# list view params
list_per_page = None
detail_export_types = settings.EXPORT_TYPES
default_list_filter = {}
# add/edit view params
form_fieldsets = None
form_readonly_fields = ()
form_inline_views = None
ui_form_add_class = None
ui_form_edit_class = None
ui_form_field_labels = None
ui_list_field_labels = None
ui_list_fields = ('_obj_name',)
ui_export_fields = ()
ui_list_export_fields = None
ui_detail_export_fields = None
ui_export_types = settings.EXPORT_TYPES
ui_list_export_types = None
ui_detail_export_types = None
ui_add_view = AddModelFormView
ui_edit_view = EditModelFormView
ui_list_view = TableView
default_model_view_classes = (
('add', r'add/', 'get_ui_add_view'),
('edit', r'(?P<pk>[-\w]+)/', 'get_ui_edit_view'),
('list', r'', 'get_ui_list_view'),
)
bulk_change_url_name = None
def get_view_classes(self):
view_classes = super(UIModelISCore, self).get_view_classes() + list(self.default_model_view_classes)
if self.is_bulk_change_enabled():
view_classes.append((self.get_bulk_change_url_name(), r'bulk-change/?', BulkChangeFormView))
return view_classes + list(self.default_model_view_classes)
def get_ui_add_view(self):
return self.ui_add_view
def get_ui_edit_view(self):
return self.ui_edit_view
def get_ui_list_view(self):
return self.ui_list_view
def get_ui_form_add_class(self, request, obj=None):
return self.ui_form_add_class or self.get_form_add_class(request, obj)
def get_ui_form_edit_class(self, request, obj=None):
return self.ui_form_edit_class or self.get_form_edit_class(request, obj)
def get_form_fieldsets(self, request, obj=None):
return self.form_fieldsets
def get_form_readonly_fields(self, request, obj=None):
return self.form_readonly_fields
def get_ui_form_fields(self, request, obj=None):
return self.get_form_fields(request, obj)
def get_ui_form_exclude(self, request, obj=None):
return self.get_form_exclude(request, obj)
def is_bulk_change_enabled(self):
return self.get_bulk_change_url_name() is not None
def get_bulk_change_url_name(self):
return self.bulk_change_url_name
def get_bulk_change_fields(self, request):
return getattr(self, 'bulk_change_fields', ())
def get_urls(self):
return self.get_urlpatterns(self.ui_patterns)
def get_show_in_menu(self, request):
return self.menu_url_name in self.ui_patterns and self.show_in_menu and self.has_ui_read_permission(request)
def get_form_inline_views(self, request, obj=None):
return self.form_inline_views
def get_default_list_filter(self, request):
return self.default_list_filter.copy()
def get_ui_list_fields(self, request):
return list(self.ui_list_fields)
def get_ui_export_fields(self, request):
return list(self.ui_export_fields)
def get_ui_list_export_fields(self, request):
return (
list(self.ui_list_export_fields) if self.ui_list_export_fields is not None
else self.get_ui_export_fields(request)
)
def get_ui_detail_export_fields(self, request, obj=None):
return (
list(self.ui_detail_export_fields) if self.ui_detail_export_fields is not None
else self.get_ui_export_fields(request)
)
def get_ui_export_types(self, request):
return list(self.ui_export_types or ())
def get_ui_list_export_types(self, request):
return (
list(self.ui_list_export_types) if self.ui_list_export_types is not None
else self.get_ui_export_types(request)
)
def get_ui_detail_export_types(self, request):
return (
list(self.ui_detail_export_fields) if self.ui_detail_export_fields is not None
else self.get_ui_export_types(request)
)
def get_list_per_page(self, request):
return self.list_per_page
def get_api_url_name(self):
return self.api_url_name
def get_add_url(self, request):
if 'add' in self.ui_patterns:
return self.ui_patterns.get('add').get_url_string(request)
def get_api_url(self, request):
return reverse(self.get_api_url_name())
def get_ui_form_field_labels(self, request):
return self.ui_form_field_labels if self.ui_form_field_labels is not None else self.get_field_labels(request)
def get_ui_list_field_labels(self, request):
return self.ui_list_field_labels if self.ui_list_field_labels is not None else self.get_field_labels(request)
def get_detail_export_types(self):
return self.detail_export_types
class RESTModelISCore(RESTISCore, ModelISCore):
"""
Main core controller for specific model that provides REST resources for model management.
CRUD (POST, GET, PUT, DELETE).
"""
abstract = True
# Allowed rest fields
rest_fields = None
rest_extra_fields = None
rest_detailed_fields = None
rest_general_fields = None
rest_guest_fields = None
rest_default_fields = None
rest_filter_fields = None
rest_extra_filter_fields = None
rest_order_fields = None
rest_extra_order_fields = None
rest_default_fields_extension = settings.REST_DEFAULT_FIELDS_EXTENSION
rest_form_edit_class = None
rest_form_add_class = None
rest_resource_class = RESTModelResource
rest_form_field_labels = None
rest_allowed_methods = ('get', 'put', 'post', 'delete', 'head', 'options')
def get_rest_form_field_labels(self, request):
return (
self.rest_form_field_labels if self.rest_form_field_labels is not None
else self.get_field_labels(request)
)
def get_rest_form_add_class(self, request, obj=None):
return self.rest_form_add_class or self.get_form_add_class(request, obj)
def get_rest_form_edit_class(self, request, obj=None):
return self.rest_form_edit_class or self.get_form_edit_class(request, obj)
def get_rest_form_fields(self, request, obj=None):
return self.get_form_fields(request, obj)
def get_rest_form_exclude(self, request, obj=None):
return self.get_form_exclude(request, obj)
def get_rest_default_fields_extension(self, request, obj=None):
return list(self.rest_default_fields_extension)
def get_rest_extra_fields(self, request, obj=None):
return list(
self.model._rest_meta.extra_fields if self.rest_extra_fields is None
else self.rest_extra_fields
)
def get_rest_default_fields(self, request, obj=None):
return list(
self.model._rest_meta.default_fields if self.rest_default_fields is None
else self.rest_default_fields
)
def get_rest_fields(self, request, obj=None):
return self.rest_fields
def get_rest_general_fields(self, request, obj=None):
return list(
self.model._rest_meta.general_fields if self.rest_general_fields is None
else self.rest_general_fields
)
def get_rest_detailed_fields(self, request, obj=None):
return list(
self.model._rest_meta.detailed_fields if self.rest_detailed_fields is None
else self.rest_detailed_fields
)
def get_rest_guest_fields(self, request, obj=None):
return list(
self.model._rest_meta.guest_fields if self.rest_guest_fields is None
else self.rest_guest_fields
)
def get_rest_extra_filter_fields(self, request):
return (
self.model._rest_meta.extra_filter_fields if self.rest_extra_filter_fields is None
else self.rest_extra_filter_fields
)
def get_rest_filter_fields(self, request):
return (
self.model._rest_meta.filter_fields if self.rest_filter_fields is None
else self.rest_filter_fields
)
def get_rest_extra_order_fields(self, request):
return (
self.model._rest_meta.extra_order_fields if self.rest_extra_order_fields is None
else self.rest_extra_order_fields
)
def get_rest_order_fields(self, request):
return (
self.model._rest_meta.order_fields if self.rest_order_fields is None
else self.rest_order_fields
)
def get_rest_class(self):
return modelrest_factory(self.model, self.rest_resource_class)
def get_rest_patterns(self):
rest_patterns = super(RESTModelISCore, self).get_rest_patterns()
rest_patterns.update(DoubleRESTPattern(self.get_rest_class(), self.default_rest_pattern_class, self,
self.rest_allowed_methods).patterns)
return rest_patterns
def get_list_actions(self, request, obj):
list_actions = super(RESTModelISCore, self).get_list_actions(request, obj)
if self.has_delete_permission(request, obj):
confirm_dialog = ConfirmRESTAction.ConfirmDialog(_('Do you really want to delete "%s"') % obj)
list_actions.append(ConfirmRESTAction('api-resource-%s' % self.get_menu_group_pattern_name(),
_('Delete'), 'DELETE', confirm_dialog=confirm_dialog,
class_name='delete', success_text=_('Record "%s" was deleted') % obj))
return list_actions
class UIRESTModelISCore(UIRESTISCoreMixin, RESTModelISCore, UIModelISCore):
"""
Combination of UI views and REST resources. UI views uses REST resources for printing model data, filtering,
paging and so on.
"""
abstract = True
ui_rest_extra_fields = ('_web_links', '_rest_links', '_default_action', '_actions', '_class_names', '_obj_name')
rest_resource_class = UIRESTModelResource
rest_obj_class_names = ()
def get_rest_extra_fields(self, request, obj=None):
return (
super(UIRESTModelISCore, self).get_rest_extra_fields(request, obj) +
list(self.get_ui_list_fields(request)) +
list(self.get_ui_list_export_fields(request)) +
list(self.get_ui_detail_export_fields(request)) +
list(self.ui_rest_extra_fields)
)
def get_api_url_name(self):
return self.api_url_name or '%s:api-%s' % (self.site_name, self.get_menu_group_pattern_name())
def get_api_detail_url_name(self):
return self.api_url_name or '%s:api-resource-%s' % (self.site_name, self.get_menu_group_pattern_name())
def get_api_detail_url(self, request, obj):
return reverse(self.get_api_detail_url_name(), kwargs={'pk': obj.pk})
def get_rest_form_fields(self, request, obj=None):
return flatten_fieldsets(self.get_form_fieldsets(request, obj) or ()) or self.get_form_fields(request, obj)
def get_rest_form_exclude(self, request, obj=None):
return self.get_form_readonly_fields(request, obj) + self.get_form_exclude(request, obj)
def get_list_actions(self, request, obj):
list_actions = super(UIRESTModelISCore, self).get_list_actions(request, obj)
edit_pattern = self.ui_patterns.get('edit')
if edit_pattern and edit_pattern.can_call_get(request, obj=obj):
return [WebAction('edit-%s' % self.get_menu_group_pattern_name(), _('Edit'), 'edit')] + list(list_actions)
else:
return list_actions
def get_default_action(self, request, obj):
return 'edit-%s' % self.get_menu_group_pattern_name()
def web_link_patterns(self, request):
return self.ui_patterns.values()
def get_rest_obj_class_names(self, request, obj):
return list(self.rest_obj_class_names)
class ViaRESTModelISCore(RESTModelISCore):
"""
Special REST controller. All REST resources must be updated via another model object.
"""
via_model = None
fk_name = None
abstract = True
default_rest_pattern_class = HiddenRESTPattern
rest_default_fields_extension = ()
def get_form_exclude(self, request, obj=None):
exclude = super(ViaRESTModelISCore, self).get_form_exclude(request, obj)
if obj:
fk = _get_foreign_key(self.via_model, self.model, fk_name=self.fk_name).name
exclude = list(exclude)
exclude.append(fk)
return exclude
def has_rest_via_permission(self, via):
return via and getattr(via[-1], 'model', None) == self.via_model
def has_rest_read_via_permission(self, via):
return self.has_rest_via_permission(via)
def has_rest_create_via_permission(self, via):
return self.has_rest_via_permission(via)
def has_rest_update_via_permission(self, via):
return self.has_rest_via_permission(via)
def has_rest_delete_via_permission(self, via):
return self.has_rest_via_permission(via)
def has_rest_read_permission(self, request, obj=None, via=None):
return (
self.has_rest_read_via_permission(via) and
super(ViaRESTModelISCore, self).has_rest_read_permission(request, obj, via)
)
def has_rest_create_permission(self, request, obj=None, via=None):
return (
self.has_rest_create_via_permission(via) and
super(ViaRESTModelISCore, self).has_rest_create_permission(request, obj, via)
)
def has_rest_update_permission(self, request, obj=None, via=None):
return (
self.has_rest_update_via_permission(via) and
super(ViaRESTModelISCore, self).has_rest_update_permission(request, obj, via)
)
def has_rest_delete_permission(self, request, obj=None, via=None):
return (
self.has_rest_delete_via_permission(via) and
super(ViaRESTModelISCore, self).has_rest_delete_permission(request, obj, via)
)
def get_urls(self):
self.rest_patterns
return None | 33.932867 | 120 | 0.687412 | 3,227 | 24,262 | 4.824915 | 0.085218 | 0.033911 | 0.040462 | 0.036994 | 0.501156 | 0.412974 | 0.361272 | 0.300771 | 0.245344 | 0.192229 | 0 | 0.001072 | 0.230896 | 24,262 | 715 | 121 | 33.932867 | 0.833333 | 0.044638 | 0 | 0.210421 | 0 | 0 | 0.018831 | 0.001085 | 0 | 0 | 0 | 0.001399 | 0 | 1 | 0.238477 | false | 0.01002 | 0.042084 | 0.188377 | 0.681363 | 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 |
f4882b59edca5c4e1e4340a06252f21a68754e37 | 1,354 | py | Python | eternal-storage/tests/test_social_site_v2.py | AgentFUD/evm-smart-contract-upgrade-techniques | d1d01ac25b9b1e98971dc194532aa028525242db | [
"MIT"
] | 1 | 2021-11-25T04:53:13.000Z | 2021-11-25T04:53:13.000Z | eternal-storage/tests/test_social_site_v2.py | AgentFUD/evm-smart-contract-upgrade-techniques | d1d01ac25b9b1e98971dc194532aa028525242db | [
"MIT"
] | null | null | null | eternal-storage/tests/test_social_site_v2.py | AgentFUD/evm-smart-contract-upgrade-techniques | d1d01ac25b9b1e98971dc194532aa028525242db | [
"MIT"
] | null | null | null | import brownie
def test_storage_keeps_values_if_switched_to_v2(social_site_contract_v2):
orig = social_site_contract_v2[0]
updated = social_site_contract_v2[1]
orig.like("https://orno.io/article")
orig.disLike("https://myblog.io/article")
assert orig.getLikes("https://orno.io/article") == 1
assert updated.getLikes("https://orno.io/article") == 1
assert orig.getDisLikes("https://myblog.io/article") == 1
assert updated.getDisLikes("https://myblog.io/article") == 1
def test_v2_only_allows_like_once(social_site_contract_v2):
orig = social_site_contract_v2[0]
updated = social_site_contract_v2[1]
updated.like("https://orno.io/article")
assert orig.getLikes("https://orno.io/article") == 2
assert updated.getLikes("https://orno.io/article") == 2
with brownie.reverts("ERROR: User has already liked"):
updated.like("https://orno.io/article")
def test_v2_only_allows_dislike_once(social_site_contract_v2):
orig = social_site_contract_v2[0]
updated = social_site_contract_v2[1]
assert orig.getDisLikes("https://myblog.io/article") == 1
assert updated.getDisLikes("https://myblog.io/article") == 1
updated.disLike("https://myblog.io/article")
with brownie.reverts("ERROR: User has already disliked"):
updated.disLike("https://myblog.io/article")
| 32.238095 | 73 | 0.716396 | 189 | 1,354 | 4.899471 | 0.21164 | 0.136069 | 0.174946 | 0.194384 | 0.909287 | 0.825054 | 0.696544 | 0.531317 | 0.531317 | 0.434125 | 0 | 0.022279 | 0.138109 | 1,354 | 41 | 74 | 33.02439 | 0.771208 | 0 | 0 | 0.538462 | 0 | 0 | 0.293205 | 0 | 0 | 0 | 0 | 0 | 0.307692 | 1 | 0.115385 | false | 0 | 0.038462 | 0 | 0.153846 | 0 | 0 | 0 | 0 | null | 0 | 0 | 1 | 1 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 3 |
be569e1051f3ab040cd49bfbc502d819a221fcee | 124 | py | Python | python/test-data/testTypesCollections1.py | Panteon32Om/write-your-python-program | 615b73113466c1c8f901fad0a076b480f62ad437 | [
"BSD-3-Clause"
] | 1 | 2021-09-30T10:17:57.000Z | 2021-09-30T10:17:57.000Z | python/test-data/testTypesCollections1.py | Panteon32Om/write-your-python-program | 615b73113466c1c8f901fad0a076b480f62ad437 | [
"BSD-3-Clause"
] | 47 | 2020-11-16T14:02:52.000Z | 2022-03-18T12:44:38.000Z | python/test-data/testTypesCollections1.py | Panteon32Om/write-your-python-program | 615b73113466c1c8f901fad0a076b480f62ad437 | [
"BSD-3-Clause"
] | 4 | 2020-10-28T13:54:44.000Z | 2022-01-20T17:36:24.000Z | from wypp import *
def appendSomething(l: list[int]) -> None:
l.append("foo")
l = [1,2,3]
appendSomething(l)
print(l)
| 13.777778 | 42 | 0.645161 | 20 | 124 | 4 | 0.75 | 0.4 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0.029126 | 0.169355 | 124 | 8 | 43 | 15.5 | 0.747573 | 0 | 0 | 0 | 0 | 0 | 0.024194 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0.166667 | false | 0 | 0.166667 | 0 | 0.333333 | 0.166667 | 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 |
be56bd47b26ec80fa1036fe9edcb48fdfd636094 | 260 | py | Python | Python/Mundo 1/ex031.py | henrique-tavares/Coisas | f740518b1bedec5b0ea8c12ae07a2cac21eb51ae | [
"MIT"
] | 1 | 2020-02-07T20:39:26.000Z | 2020-02-07T20:39:26.000Z | Python/Mundo 1/ex031.py | neptune076/Coisas | 85c064cc0e134465aaf6ef41acf747d47f108fc9 | [
"MIT"
] | null | null | null | Python/Mundo 1/ex031.py | neptune076/Coisas | 85c064cc0e134465aaf6ef41acf747d47f108fc9 | [
"MIT"
] | null | null | null | dist = float(input("\nQual a distancia da viagem em km? "))
if (dist > 200):
print("\nO preço da sua passagem será de R${:.2f}".format(dist*0.45), end="\n\n")
else:
print("\nO preço da sua passagem será de R${:.2f}".format(dist*0.5), end="\n\n")
| 32.5 | 85 | 0.603846 | 48 | 260 | 3.270833 | 0.583333 | 0.089172 | 0.152866 | 0.178344 | 0.573248 | 0.573248 | 0.573248 | 0.573248 | 0.573248 | 0.573248 | 0 | 0.046948 | 0.180769 | 260 | 7 | 86 | 37.142857 | 0.690141 | 0 | 0 | 0 | 0 | 0 | 0.492308 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | false | 0.4 | 0 | 0 | 0 | 0.4 | 0 | 0 | 0 | null | 0 | 0 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 0 | 0 | 0 | 3 |
be5b298fabdaaef84d72b16547a6a531ede31729 | 4,002 | py | Python | tsplib95/tests/test_models.py | michael-ritter/assignments-ma4502-S2019 | dd40371d72a2cc8c8c3b505d073e02dbe1bbec49 | [
"Apache-2.0"
] | null | null | null | tsplib95/tests/test_models.py | michael-ritter/assignments-ma4502-S2019 | dd40371d72a2cc8c8c3b505d073e02dbe1bbec49 | [
"Apache-2.0"
] | null | null | null | tsplib95/tests/test_models.py | michael-ritter/assignments-ma4502-S2019 | dd40371d72a2cc8c8c3b505d073e02dbe1bbec49 | [
"Apache-2.0"
] | null | null | null | # -*- coding: utf-8 -*-
from unittest import mock
import pytest
from tsplib95 import models
def create_problem(**kwargs):
p = models.Problem()
# set attributes after creation intentionally
for k, v in kwargs.items():
setattr(p, k, v)
return p
@pytest.mark.parametrize('problem,correct', [
(create_problem(edge_weight_type='EXPLICIT'), True),
(create_problem(edge_weight_type='FUNCTION'), False),
(create_problem(edge_weight_type=None), False),
(create_problem(), False)
])
def test_is_explicit(problem, correct):
assert problem.is_explicit() is correct
@pytest.mark.parametrize('problem,correct', [
(create_problem(edge_weight_format='FULL_MATRIX'), True),
(create_problem(edge_weight_format='UPPER_ROW'), False),
(create_problem(edge_weight_format=None), False),
(create_problem(), False)
])
def test_is_full_matrix(problem, correct):
assert problem.is_full_matrix() is correct
@pytest.mark.parametrize('problem,correct', [
(create_problem(edge_weight_format='FULL_MATRIX', edge_weight_type='EXPLICIT'), True),
(create_problem(edge_weight_format='FULL_MATRIX'), True),
(create_problem(edge_weight_type='EXPLICIT'), True),
(create_problem(), False)
])
def test_is_weighted(problem, correct):
assert problem.is_weighted() is correct
@pytest.mark.parametrize('problem,correct', [
(create_problem(edge_weight_type='SPECIAL'), True),
(create_problem(edge_weight_type='GEO'), False),
(create_problem(edge_weight_type=None), False),
(create_problem(), False)
])
def test_is_special(problem, correct):
assert problem.is_special() is correct
@pytest.mark.parametrize('problem,correct', [
(create_problem(edge_data_format='EDGE_LIST'), False),
(create_problem(edge_data_format='ADJ_LIST'), False),
(create_problem(edge_data_format=None), True),
(create_problem(), True)
])
def test_is_complete(problem, correct):
assert problem.is_complete() is correct
@pytest.mark.parametrize('problem,correct', [
(create_problem(edge_weight_format='FULL_MATRIX', edge_weight_type='SPECIAL'), False),
(create_problem(edge_weight_format='UPPER_ROW', edge_weight_type='SPECIAL'), False),
(create_problem(edge_weight_format='FULL_MATRIX', edge_weight_type='GEO'), False),
(create_problem(edge_weight_format='UPPER_ROW', edge_weight_type='GEO'), True),
(create_problem(), True)
])
def test_is_symmetric(problem, correct):
assert problem.is_symmetric() is correct
@pytest.mark.parametrize('problem,correct', [
(create_problem(display_data=None, display_data_type=None, node_coords=True), True),
(create_problem(display_data=None, display_data_type=None, node_coords=None), False),
(create_problem(display_data=None, display_data_type='NO_DISPLAY', node_coords=True), False),
(create_problem(display_data=None, display_data_type='NO_DISPLAY', node_coords=None), False),
(create_problem(display_data=True, display_data_type=None, node_coords=True), True),
(create_problem(display_data=True, display_data_type=None, node_coords=None), True),
(create_problem(display_data=True, display_data_type='NO_DISPLAY', node_coords=True), True),
(create_problem(display_data=True, display_data_type='NO_DISPLAY', node_coords=None), True),
(create_problem(), False)
])
def test_is_depictable(problem, correct):
assert problem.is_depictable() is correct
@pytest.mark.parametrize('problem,correct', [
(create_problem(is_depictable=mock.Mock(return_value=True), display_data=['foo']), 'foo'),
(create_problem(is_depictable=mock.Mock(return_value=True), node_coords=['bar']), 'bar'),
(create_problem(is_depictable=mock.Mock(return_value=True), display_data=['foo'], node_coords=['bar']), 'foo'),
(create_problem(is_depictable=mock.Mock(return_value=False), display_data=['foo'], node_coords=['bar']), None),
(create_problem(), None),
])
def test_get_display(problem, correct):
assert problem.get_display(0) is correct
| 39.235294 | 115 | 0.742379 | 529 | 4,002 | 5.287335 | 0.120983 | 0.185913 | 0.115481 | 0.13157 | 0.845191 | 0.769038 | 0.735073 | 0.665356 | 0.644977 | 0.544154 | 0 | 0.001127 | 0.113193 | 4,002 | 101 | 116 | 39.623762 | 0.786982 | 0.016242 | 0 | 0.367089 | 0 | 0 | 0.08846 | 0 | 0 | 0 | 0 | 0 | 0.101266 | 1 | 0.113924 | false | 0 | 0.037975 | 0 | 0.164557 | 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 |
be5b623be49cca0331b25087894eb5f55281a6c2 | 251 | py | Python | chunkflow/plugins/median_filter.py | julesberman/chunkflow | c6af0d036bc2f308c64c591d49c94c414c569241 | [
"Apache-2.0"
] | 36 | 2019-03-20T21:58:15.000Z | 2022-03-28T08:40:59.000Z | chunkflow/plugins/median_filter.py | julesberman/chunkflow | c6af0d036bc2f308c64c591d49c94c414c569241 | [
"Apache-2.0"
] | 96 | 2019-01-23T14:49:18.000Z | 2022-03-21T19:54:20.000Z | chunkflow/plugins/median_filter.py | julesberman/chunkflow | c6af0d036bc2f308c64c591d49c94c414c569241 | [
"Apache-2.0"
] | 7 | 2019-03-25T19:32:19.000Z | 2021-07-20T19:39:03.000Z |
import numpy as np
from scipy.ndimage import median_filter
def execute(chunk: np.ndarray, size: tuple=(3,1,1), mode: str='reflect'):
print('median filtering of chunk...')
chunk = median_filter(chunk, size=size, mode=mode)
return [chunk]
| 27.888889 | 73 | 0.705179 | 38 | 251 | 4.605263 | 0.631579 | 0.137143 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0.014218 | 0.159363 | 251 | 8 | 74 | 31.375 | 0.815166 | 0 | 0 | 0 | 0 | 0 | 0.14 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0.166667 | false | 0 | 0.333333 | 0 | 0.666667 | 0.166667 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 1 | 0 | 0 | 3 |
be98fdfceb8509a2e57c592bf8ee4aa035d959ce | 202 | py | Python | setup.py | neurospin/neurospin_to_bids | 629e434ac2d1cf2c0722c8f281588efbcf28572e | [
"CECILL-B"
] | null | null | null | setup.py | neurospin/neurospin_to_bids | 629e434ac2d1cf2c0722c8f281588efbcf28572e | [
"CECILL-B"
] | 13 | 2021-02-23T13:31:03.000Z | 2022-02-14T16:46:40.000Z | setup.py | neurospin/neurospin_to_bids | 629e434ac2d1cf2c0722c8f281588efbcf28572e | [
"CECILL-B"
] | null | null | null | # All build configuration is contained in setup.cfg.
#
# This file is present for compatibility with legacy builds (i.e. those not
# using the PEP 517 build API).
import setuptools
setuptools.setup()
| 22.444444 | 75 | 0.762376 | 31 | 202 | 4.967742 | 0.870968 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0.017857 | 0.168317 | 202 | 8 | 76 | 25.25 | 0.89881 | 0.762376 | 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 | 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 |
bebeb021d4ce065302bd168b93a55034c040533c | 894 | py | Python | col/generators.py | iehoshia/discipulado | dade1f7ceca4ff07f7e09529605bfac385e22f9e | [
"Apache-2.0"
] | null | null | null | col/generators.py | iehoshia/discipulado | dade1f7ceca4ff07f7e09529605bfac385e22f9e | [
"Apache-2.0"
] | null | null | null | col/generators.py | iehoshia/discipulado | dade1f7ceca4ff07f7e09529605bfac385e22f9e | [
"Apache-2.0"
] | null | null | null | #
# Copyright (c) Elliot Peele <elliot@bentlogic.net>
#
# This program is distributed under the terms of the MIT License as found
# in a file called LICENSE. If it is not present, the license
# is always available at http://www.opensource.org/licenses/mit-license.php.
#
# This program is distributed in the hope that it will be useful, but
# without any warrenty; without even the implied warranty of merchantability
# or fitness for a particular purpose. See the MIT License for full details.
#
import time
import random
import hashlib
def _get_hash():
sha = hashlib.sha256()
sha.update(str(random.random()))
sha.update(str(time.time()))
return sha
def gen_client_id():
return _get_hash().hexdigest()
def gen_client_secret():
return _get_hash().hexdigest()
def gen_token(client):
sha = _get_hash()
sha.update(client.client_id)
return sha.hexdigest()
| 26.294118 | 76 | 0.731544 | 135 | 894 | 4.740741 | 0.548148 | 0.04375 | 0.040625 | 0.075 | 0.0875 | 0.0875 | 0 | 0 | 0 | 0 | 0 | 0.00406 | 0.173378 | 894 | 33 | 77 | 27.090909 | 0.861976 | 0.530201 | 0 | 0.125 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0.25 | false | 0 | 0.1875 | 0.125 | 0.6875 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 0 | 1 | 1 | 0 | 0 | 3 |
bec4df9e994286e128357f7607604ca7f84a25a8 | 212 | py | Python | dashboards/superuser/urls.py | Apubra/django-boilerplate | 1936a866a3b8a4cf93fbc631bd15635beef9d62d | [
"MIT"
] | null | null | null | dashboards/superuser/urls.py | Apubra/django-boilerplate | 1936a866a3b8a4cf93fbc631bd15635beef9d62d | [
"MIT"
] | null | null | null | dashboards/superuser/urls.py | Apubra/django-boilerplate | 1936a866a3b8a4cf93fbc631bd15635beef9d62d | [
"MIT"
] | null | null | null | from django.contrib import admin
from django.urls import path
from . import views
urlpatterns = [
# path('admin/', admin.site.urls),
path('superuser/', views.SuperUserView.as_view(), name='superuser'),
] | 26.5 | 72 | 0.712264 | 27 | 212 | 5.555556 | 0.555556 | 0.133333 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0.141509 | 212 | 8 | 73 | 26.5 | 0.824176 | 0.150943 | 0 | 0 | 0 | 0 | 0.106145 | 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 |
bec884d37755c0e066f49c103f7485f934d97ae7 | 117 | py | Python | exerc016.py | LucasBischof/Praticando_Python | ab14e347228e19ec4ef1ad743e3a469979619f74 | [
"MIT"
] | null | null | null | exerc016.py | LucasBischof/Praticando_Python | ab14e347228e19ec4ef1ad743e3a469979619f74 | [
"MIT"
] | null | null | null | exerc016.py | LucasBischof/Praticando_Python | ab14e347228e19ec4ef1ad743e3a469979619f74 | [
"MIT"
] | null | null | null | import math
num = float(input('digite um valor quebrado: '))
print('O valor inteiro é {} '.format(math.floor(num)))
| 23.4 | 54 | 0.692308 | 18 | 117 | 4.5 | 0.833333 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0.136752 | 117 | 4 | 55 | 29.25 | 0.80198 | 0 | 0 | 0 | 0 | 0 | 0.405172 | 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 |
fe372f1eb6d16b5377f80a9b1cceca23ec8c4a9c | 17 | py | Python | coffeesix/__init__.py | Panurakumara/kuma-vc | e77a2a4231104d712961a649cd647bec8c2549c9 | [
"MIT"
] | 2 | 2021-09-14T12:06:35.000Z | 2021-09-14T12:06:43.000Z | coffeesix/__init__.py | Panurakumara/kuma-vc | e77a2a4231104d712961a649cd647bec8c2549c9 | [
"MIT"
] | null | null | null | coffeesix/__init__.py | Panurakumara/kuma-vc | e77a2a4231104d712961a649cd647bec8c2549c9 | [
"MIT"
] | 2 | 2021-11-27T16:30:29.000Z | 2022-01-30T23:57:46.000Z | bot_username = "" | 17 | 17 | 0.705882 | 2 | 17 | 5.5 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0.117647 | 17 | 1 | 17 | 17 | 0.733333 | 0 | 0 | 0 | 0 | 0 | 0 | 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 |
fe4749b29ceee3487b767b86cecf01ae6c59a126 | 700 | py | Python | src/main/python/vyu/image.py | fruendlab/vyu | a725ca1c694c06c71b686294719349585a3a9bce | [
"MIT"
] | null | null | null | src/main/python/vyu/image.py | fruendlab/vyu | a725ca1c694c06c71b686294719349585a3a9bce | [
"MIT"
] | 1 | 2018-08-21T16:57:25.000Z | 2018-08-21T16:57:25.000Z | src/main/python/vyu/image.py | fruendlab/vyu | a725ca1c694c06c71b686294719349585a3a9bce | [
"MIT"
] | null | null | null | import numpy as np
from scipy.ndimage import label
from skimage.color import rgb2gray
def image2position(img, thres=0.5):
grayscale_img = rgb2gray(img)
x, y = get_brightest_point(grayscale_img)
thresholded = threshold_image(grayscale_img, thres)
connected_clusters, _ = label(thresholded)
centroid = get_centroid(connected_clusters == connected_clusters[x, y])
return centroid
def get_brightest_point(grayscale_img):
return np.unravel_index(np.argmax(grayscale_img), grayscale_img.shape)
def threshold_image(grayscale_img, thres):
return grayscale_img > thres
def get_centroid(region):
xvals, yvals = np.where(region)
return xvals.mean(), yvals.mean()
| 26.923077 | 75 | 0.758571 | 93 | 700 | 5.483871 | 0.419355 | 0.188235 | 0.1 | 0.101961 | 0.235294 | 0 | 0 | 0 | 0 | 0 | 0 | 0.008432 | 0.152857 | 700 | 25 | 76 | 28 | 0.851602 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0.235294 | false | 0 | 0.176471 | 0.117647 | 0.647059 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 0 | 1 | 1 | 0 | 0 | 3 |
fe4bbc6ff692115df8d8256c9f98d37f3a190103 | 266 | py | Python | pdf.py | khalednakhleh/hydrogen | 34ea5572764a843b312b4bc4e72df9cb0aed913d | [
"MIT"
] | null | null | null | pdf.py | khalednakhleh/hydrogen | 34ea5572764a843b312b4bc4e72df9cb0aed913d | [
"MIT"
] | null | null | null | pdf.py | khalednakhleh/hydrogen | 34ea5572764a843b312b4bc4e72df9cb0aed913d | [
"MIT"
] | null | null | null | #!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
Created on Tue Mar 13 13:00:03 2018
@author: Khaled Nakhleh
"""
if __name__ == "__main__":
print("\n\tThis file only contains internal functions. Please use main.py to run the program.\n")
exit | 11.565217 | 101 | 0.635338 | 40 | 266 | 4.025 | 0.925 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0.067308 | 0.218045 | 266 | 23 | 102 | 11.565217 | 0.706731 | 0.390977 | 0 | 0 | 0 | 0.333333 | 0.623377 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | true | 0 | 0 | 0 | 0 | 0.333333 | 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 | 1 | 1 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 3 |
fe6136f163423b66448620397731ae06e0341c9d | 234 | py | Python | tweedle/entry.py | sourcery-ai-bot/tweedle | b3b3262a6ac850658282784354a729559d041e63 | [
"MIT"
] | 2 | 2020-02-24T05:47:03.000Z | 2021-03-30T06:58:10.000Z | tweedle/entry.py | sourcery-ai-bot/tweedle | b3b3262a6ac850658282784354a729559d041e63 | [
"MIT"
] | 13 | 2020-02-22T03:36:22.000Z | 2020-04-05T04:39:42.000Z | tweedle/entry.py | StrayDragon/dragon | 796f9ab4f15f9d8f2164621c3b36a478b7a7047d | [
"MIT"
] | 1 | 2021-03-30T06:58:11.000Z | 2021-03-30T06:58:11.000Z | from munch import Munch
from tweedle import PROJECT_NAME
from tweedle.core import cli
def main():
cli(auto_envvar_prefix=PROJECT_NAME, obj=Munch())
if __name__ == "__main__":
# Enable debug by using vimspector
main()
| 16.714286 | 53 | 0.730769 | 33 | 234 | 4.818182 | 0.606061 | 0.138365 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0.188034 | 234 | 13 | 54 | 18 | 0.836842 | 0.136752 | 0 | 0 | 0 | 0 | 0.04 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0.142857 | true | 0 | 0.428571 | 0 | 0.571429 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 1 | 0 | 1 | 0 | 0 | 3 |
fe6ddbcb4188df22079340e5f10dc6c5f98e7310 | 4,087 | py | Python | DFT and Filters/DFT/DFT.py | mehulcparikh/ComputerVision | a5928eb00dd7bbec0f31c22b087af5d3c2a5e1dd | [
"MIT"
] | null | null | null | DFT and Filters/DFT/DFT.py | mehulcparikh/ComputerVision | a5928eb00dd7bbec0f31c22b087af5d3c2a5e1dd | [
"MIT"
] | null | null | null | DFT and Filters/DFT/DFT.py | mehulcparikh/ComputerVision | a5928eb00dd7bbec0f31c22b087af5d3c2a5e1dd | [
"MIT"
] | 1 | 2021-07-16T05:42:26.000Z | 2021-07-16T05:42:26.000Z | # For this part of the assignment, please implement your own code for all computations,
# Do not use inbuilt functions like fft from either numpy, opencv or other libraries
import math
import numpy as np
class DFT:
def forward_transform(self, matrix):
"""Computes the forward Fourier transform of the input matrix
takes as input:
matrix: a 2d matrix
returns a complex matrix representing fourier transform"""
# Using direct function
# matrix1 = np.fft.fft2(matrix)
# Without using direct function
rows, columns = np.shape(matrix)
matrix1 = np.zeros((rows, columns), dtype=complex)
for u in range(rows):
for v in range(columns):
a = []
for i in range(rows):
for j in range(columns):
omega = np.exp(-2 * math.pi * 1J * (((u * i) / rows) + ((v * j) / columns)))
a.append(matrix[i, j] * omega)
matrix1[u, v] = sum(a)
return matrix1
def inverse_transform(self, matrix):
"""Computes the inverse Fourier transform of the input matrix
matrix: a 2d matrix (DFT) usually complex
takes as input:
returns a complex matrix representing the inverse fourier transform"""
# Using direct function
# matrix1 = np.fft.ifft2(matrix)
# Without using direct function
rows, columns = np.shape(matrix)
matrix1 = np.zeros((rows, columns), dtype=complex)
for u in range(rows):
for v in range(columns):
a = []
for i in range(rows):
for j in range(columns):
omega = np.exp(2 * math.pi * 1J * (((u * i) / rows) + ((v * j) / columns)))
a.append(matrix[i, j] * omega)
matrix1[u, v] = sum(a)
# Normalized value of inverse dft
# matrix1[u, v] = (1 / (rows * columns)) * sum(a)
return matrix1
def discrete_cosine_tranform(self, matrix):
"""Computes the discrete cosine transform of the input matrix
takes as input:
matrix: a 2d matrix
returns a matrix representing discrete cosine transform"""
rows, columns = np.shape(matrix)
matrix1 = np.zeros((rows, columns), dtype=float)
for u in range(rows):
for v in range(columns):
a = []
for i in range(rows):
for j in range(columns):
temp = math.cos(2 * math.pi * (((u * i) / rows) + ((v * j) / columns)))
a.append(matrix[i, j] * temp)
matrix1[u, v] = sum(a)
return matrix1
def discrete_sine_tranform(self, matrix):
"""Computes the discrete cosine transform of the input matrix
takes as input:
matrix: a 2d matrix
returns a matrix representing discrete cosine transform"""
rows, columns = np.shape(matrix)
matrix1 = np.zeros((rows, columns), dtype=float)
for u in range(rows):
for v in range(columns):
a = []
for i in range(rows):
for j in range(columns):
temp = math.sin(2 * math.pi * (((u * i) / rows) + ((v * j) / columns)))
a.append(matrix[i, j] * temp)
matrix1[u, v] = sum(a)
return matrix1
def magnitude(self, matrix):
"""Computes the magnitude of the DFT
takes as input:
matrix: a 2d matrix
returns a matrix representing magnitude of the dft"""
# method 1
# matrix1 = np.abs(matrix)
# method 2
rows, columns = np.shape(matrix)
matrix1 = np.zeros((rows, columns), dtype=float)
for i in range(rows):
for j in range(columns):
# matrix1[i, j] = abs(matrix[i, j])
matrix1[i, j] = math.sqrt(matrix[i, j].real ** 2 + matrix[i, j].imag ** 2)
return matrix1
| 35.53913 | 100 | 0.529728 | 505 | 4,087 | 4.275248 | 0.182178 | 0.05836 | 0.045855 | 0.05836 | 0.767948 | 0.713293 | 0.678555 | 0.678555 | 0.627605 | 0.627605 | 0 | 0.014729 | 0.36873 | 4,087 | 114 | 101 | 35.850877 | 0.822093 | 0.305848 | 0 | 0.775862 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0.086207 | false | 0 | 0.034483 | 0 | 0.224138 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 0 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 3 |
fe76114b316bedd0cf94d55c61d353fd6219ee1d | 1,645 | py | Python | python_scripts/01_tabular_data_exploration_ex_01.py | miwojc/scikit-learn-mooc | 1dd1e6110ee037c2ce9b9597d769de5eb25fcffb | [
"CC-BY-4.0"
] | 1 | 2021-05-18T10:03:27.000Z | 2021-05-18T10:03:27.000Z | python_scripts/01_tabular_data_exploration_ex_01.py | datagistips/scikit-learn-mooc | 9eb67c53173218b5cd3061712c827c6a663e425a | [
"CC-BY-4.0"
] | null | null | null | python_scripts/01_tabular_data_exploration_ex_01.py | datagistips/scikit-learn-mooc | 9eb67c53173218b5cd3061712c827c6a663e425a | [
"CC-BY-4.0"
] | 1 | 2021-06-16T16:54:59.000Z | 2021-06-16T16:54:59.000Z | # ---
# jupyter:
# jupytext:
# text_representation:
# extension: .py
# format_name: percent
# format_version: '1.3'
# jupytext_version: 1.6.0
# kernelspec:
# display_name: Python 3
# language: python
# name: python3
# ---
# %% [markdown]
# # 📝 Exercise M1.01
# %% [markdown]
# Imagine we are interested in predicting penguins species based on two of
# their body measurements: culmen length and culmen depth. First we want to do
# some data exploration to get a feel for the data.
#
# What are the features? What is the target?
# %% [markdown]
# The data is located in `../datasets/penguins_classification.csv`, load it
# with `pandas` into a `DataFrame`.
# %%
# Write your code here.
# %% [markdown]
# Show a few samples of the data
#
# How many features are numerical? How many features are categorical?
# %%
# Write your code here.
# %% [markdown]
# What are the different penguins species available in the dataset and how many
# samples of each species are there? Hint: select the right column and use
# the [`value_counts`](https://pandas.pydata.org/pandas-docs/stable/reference/api/pandas.Series.value_counts.html) method.
# %%
# Write your code here.
# %% [markdown]
# Plot histograms for the numerical features
# %%
# Write your code here.
# %% [markdown]
# Show features distribution for each class. Hint: use
# [`seaborn.pairplot`](https://seaborn.pydata.org/generated/seaborn.pairplot.html)
# %%
# Write your code here.
# %% [markdown]
# Looking at these distributions, how hard do you think it will be to classify
# the penguins only using "culmen depth" and "culmen length"?
| 25.703125 | 122 | 0.694225 | 226 | 1,645 | 5.022124 | 0.535398 | 0.039648 | 0.057269 | 0.07489 | 0.117181 | 0.051101 | 0 | 0 | 0 | 0 | 0 | 0.007508 | 0.190274 | 1,645 | 63 | 123 | 26.111111 | 0.843844 | 0.930091 | 0 | null | 0 | null | 0 | 0 | null | 0 | 0 | 0.015873 | 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 |
fe76f64a62469c4a6ce03ba18bcc8d92d786ec1c | 68 | py | Python | javascript-es6-essencial-master/1-introducao-ao-ES6/1-conceitos/1-tipagem-fraca/tipagem-fraca.py | kevinfigueira/Dio-desafio-github-primeiro-repositorio | f729bc9d54b4622b61e08333dfa04a43b323a2a1 | [
"MIT"
] | null | null | null | javascript-es6-essencial-master/1-introducao-ao-ES6/1-conceitos/1-tipagem-fraca/tipagem-fraca.py | kevinfigueira/Dio-desafio-github-primeiro-repositorio | f729bc9d54b4622b61e08333dfa04a43b323a2a1 | [
"MIT"
] | null | null | null | javascript-es6-essencial-master/1-introducao-ao-ES6/1-conceitos/1-tipagem-fraca/tipagem-fraca.py | kevinfigueira/Dio-desafio-github-primeiro-repositorio | f729bc9d54b4622b61e08333dfa04a43b323a2a1 | [
"MIT"
] | null | null | null | meu_numero = 30
meu_texto = 'Exemplo'
print(meu_numero + meu_texto) | 17 | 29 | 0.764706 | 11 | 68 | 4.363636 | 0.545455 | 0.375 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0.033898 | 0.132353 | 68 | 4 | 29 | 17 | 0.779661 | 0 | 0 | 0 | 0 | 0 | 0.101449 | 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 |
fe7d655089191af7d5c01c2982a42d6398f05b72 | 1,993 | py | Python | src/yandex_checkout_payout/domain/models/organization.py | tonchik-tm/yandex-checkout-payout-sdk-python | 84c4ecf7eec822c82928c33cecce7860f5f1b326 | [
"MIT"
] | null | null | null | src/yandex_checkout_payout/domain/models/organization.py | tonchik-tm/yandex-checkout-payout-sdk-python | 84c4ecf7eec822c82928c33cecce7860f5f1b326 | [
"MIT"
] | null | null | null | src/yandex_checkout_payout/domain/models/organization.py | tonchik-tm/yandex-checkout-payout-sdk-python | 84c4ecf7eec822c82928c33cecce7860f5f1b326 | [
"MIT"
] | null | null | null | # -*- coding: utf-8 -*-
"""
"""
import re
from yandex_checkout_payout.domain.common.base_object import BaseObject
class Organization(BaseObject):
__country_name = None
__state = None
__locality = None
__org_name = None
__org_unit_name = None
__common_name = None
__email = None
@property
def country_name(self):
return self.__country_name
@country_name.setter
def country_name(self, value):
self.__country_name = value
@property
def state(self):
return self.__state
@state.setter
def state(self, value):
self.__state = value
@property
def locality(self):
return self.__locality
@locality.setter
def locality(self, value):
self.__locality = value
@property
def org_name(self):
return self.__org_name
@org_name.setter
def org_name(self, value):
self.__org_name = value
@property
def org_unit_name(self):
return self.__org_unit_name
@org_unit_name.setter
def org_unit_name(self, value):
self.__org_unit_name = value
@property
def common_name(self):
return self.__common_name
@common_name.setter
def common_name(self, value):
cast_value = str(value).replace('/business/', '')
if re.match(r"^[a-z]+$", cast_value):
self.__common_name = '/business/' + value
else:
raise ValueError('Invalid common_name value')
@property
def email(self):
return self.__email
@email.setter
def email(self, value):
cast_value = str(value)
if re.match(r"^[^@]+@[^@]+\.[^@]+$", cast_value):
self.__email = cast_value
else:
raise ValueError('Invalid email value type')
def verify(self):
if not self.common_name or not self.email or not self.org_name or not self.country_name or not self.state:
return False
else:
return True
| 22.144444 | 114 | 0.616157 | 245 | 1,993 | 4.669388 | 0.2 | 0.06993 | 0.085664 | 0.062937 | 0.188811 | 0.045455 | 0 | 0 | 0 | 0 | 0 | 0.0007 | 0.283492 | 1,993 | 89 | 115 | 22.393258 | 0.80042 | 0.010537 | 0 | 0.153846 | 0 | 0 | 0.049439 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0.230769 | false | 0 | 0.030769 | 0.107692 | 0.523077 | 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 |
fe96acb4471d940ee9c8dcc4ff1e9fa17f61e16d | 15 | py | Python | testdata/repos/network/MetadataUrlCheck/DeadUrl-missingfile/responses.py | floppym/pkgcheck | 07215eac255a88b3a0c351f35626a1c79d9f2632 | [
"BSD-3-Clause"
] | 18 | 2015-04-24T23:15:30.000Z | 2022-02-14T04:14:56.000Z | testdata/repos/network/MetadataUrlCheck/DeadUrl-missingfile/responses.py | floppym/pkgcheck | 07215eac255a88b3a0c351f35626a1c79d9f2632 | [
"BSD-3-Clause"
] | 351 | 2015-03-08T07:07:47.000Z | 2022-03-21T11:57:58.000Z | testdata/repos/network/MetadataUrlCheck/DeadUrl-missingfile/responses.py | floppym/pkgcheck | 07215eac255a88b3a0c351f35626a1c79d9f2632 | [
"BSD-3-Clause"
] | 19 | 2015-03-08T01:16:10.000Z | 2022-03-17T10:37:26.000Z | responses = []
| 7.5 | 14 | 0.6 | 1 | 15 | 9 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0.2 | 15 | 1 | 15 | 15 | 0.75 | 0 | 0 | 0 | 0 | 0 | 0 | 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 |
feac6b58847e584a5f53f6382838bb3917337545 | 560 | py | Python | tests/query_test/test_union.py | Altiscale/Impala | 1a57d938ff616669a3111256c548807b10e0bff6 | [
"Apache-2.0"
] | 2 | 2015-11-17T16:58:47.000Z | 2017-01-10T04:15:05.000Z | tests/query_test/test_union.py | Altiscale/Impala | 1a57d938ff616669a3111256c548807b10e0bff6 | [
"Apache-2.0"
] | 1 | 2016-03-10T16:34:10.000Z | 2016-03-10T16:34:10.000Z | tests/query_test/test_union.py | Altiscale/Impala | 1a57d938ff616669a3111256c548807b10e0bff6 | [
"Apache-2.0"
] | 6 | 2015-12-22T14:52:38.000Z | 2019-07-06T08:34:23.000Z | #!/usr/bin/env python
# Copyright (c) 2012 Cloudera, Inc. All rights reserved.
# Tests for Union
#
import logging
import pytest
from tests.common.test_dimensions import create_exec_option_dimension
from tests.common.impala_test_suite import ImpalaTestSuite, SINGLE_NODE_ONLY
class TestUnion(ImpalaTestSuite):
@classmethod
def get_workload(self):
return 'functional-query'
@classmethod
def add_test_dimensions(cls):
super(TestUnion, cls).add_test_dimensions()
def test_union(self, vector):
self.run_test_case('QueryTest/union', vector)
| 26.666667 | 76 | 0.785714 | 75 | 560 | 5.653333 | 0.653333 | 0.099057 | 0.070755 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0.00818 | 0.126786 | 560 | 20 | 77 | 28 | 0.858896 | 0.1625 | 0 | 0.153846 | 0 | 0 | 0.066667 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0.230769 | false | 0 | 0.307692 | 0.076923 | 0.692308 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 1 | 0 | 1 | 0 | 0 | 3 |
22825debd5e4649100a36f42fd2b9388675ef70a | 462 | py | Python | monster_rx/routes.py | YosaiProject/monster_rx | a59015635209cac720ec0a1bb89f017d30f058c1 | [
"Apache-2.0"
] | 4 | 2017-02-07T22:32:22.000Z | 2019-01-30T10:17:59.000Z | monster_rx/routes.py | YosaiProject/monster_rx | a59015635209cac720ec0a1bb89f017d30f058c1 | [
"Apache-2.0"
] | 1 | 2017-10-25T13:09:26.000Z | 2020-09-13T18:17:05.000Z | monster_rx/routes.py | YosaiProject/monster_rx | a59015635209cac720ec0a1bb89f017d30f058c1 | [
"Apache-2.0"
] | null | null | null | def includeme(config):
config.add_static_view('static', 'static', cache_max_age=3600)
config.add_route('home', '/')
config.add_route('login', '/login')
config.add_route('launchpad', '/launchpad')
config.add_route('request_rx', '/request_rx')
config.add_route('rx_portal', '/rx_portal')
config.add_route('pending_rx', '/pending_rx')
config.add_route('write_rx', '/write_rx')
config.add_route('write_rx_form', '/write_rx_form')
| 42 | 66 | 0.692641 | 64 | 462 | 4.625 | 0.3125 | 0.273649 | 0.378378 | 0.162162 | 0.155405 | 0.155405 | 0 | 0 | 0 | 0 | 0 | 0.009877 | 0.123377 | 462 | 10 | 67 | 46.2 | 0.720988 | 0 | 0 | 0 | 0 | 0 | 0.329004 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0.1 | false | 0 | 0 | 0 | 0.1 | 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 |
228625a463541ca167829eb7e138a8923805e149 | 2,975 | py | Python | bluesky_autonomic/_opa_device.py | wright-group/bluesky-autonomic | ba7a3936c0e1739aeecabe636e58ccdd16f83c3e | [
"MIT"
] | null | null | null | bluesky_autonomic/_opa_device.py | wright-group/bluesky-autonomic | ba7a3936c0e1739aeecabe636e58ccdd16f83c3e | [
"MIT"
] | 10 | 2021-03-15T15:27:37.000Z | 2021-09-22T21:06:25.000Z | bluesky_autonomic/_opa_device.py | wright-group/bluesky-autonomic | ba7a3936c0e1739aeecabe636e58ccdd16f83c3e | [
"MIT"
] | 1 | 2021-03-15T13:13:07.000Z | 2021-03-15T13:13:07.000Z | __all__ = ["OPADevice"]
import time
from typing import Dict
import yaqc_bluesky
from ._sdc_manager import sdc_manager
from ._status import Status
class OPADevice:
def __init__(self, host, *, port=None, name=None):
self.parent = yaqc_bluesky.Device(port=port, host=host, name=name)
sdc_manager.register_opa(self)
yaqclient = self.parent.yaq_client
for mot in yaqclient.get_setable_names():
setattr(self, mot, OPAMotor(self, mot))
@property
def arrangement(self) -> str:
return self.parent.yaq_client.get_arrangement()
@property
def instrument(self) -> str:
return self.parent.yaq_client.get_instrument()
def describe(self) -> Dict["str", dict]:
return self.parent.describe()
def describe_configuration(self) -> Dict["str", dict]:
return self.parent.describe_configuration()
def read_configuration(self) -> Dict["str", dict]:
return self.parent.read_configuration()
@property
def name(self):
return self.parent.name
@property
def position(self) -> float:
return self.parent.yaq_client.get_position()
def read(self) -> Dict["str", dict]:
return self.parent.read()
def set(self, position: float, exceptions=None) -> Status:
if exceptions:
self.parent.yaq_client.set_position_except(position, exceptions)
ret = self.parent._wait_until_still()
else:
ret = self.parent.set(position)
sdc_manager.on_opa_set(self.name)
# TODO: join delay status to this status
return ret
@property
def hints(self) -> Dict:
return self.parent.hints
class OPAMotor:
def __init__(self, device: OPADevice, motor: str):
self.parent = device.parent
self._motor = motor
self.parent = None
def describe(self) -> Dict["str", dict]:
return {
self.name: {"source":f"bluesky-autonomic:{self.name}",
"shape":(),
"dtype": "number",
}
}
def describe_configuration(self) -> Dict["str", dict]:
return {}
def read_configuration(self) -> Dict["str", dict]:
return {}
@property
def name(self):
return self._motor
@property
def position(self) -> float:
return self.parent.yaq_client.get_setable_positions()[self._motor]
def read(self) -> Dict["str", dict]:
return {self.name: {"value": self.position, "timestamp": time.time()}}
def set(self, position: float) -> Status:
self.parent.yaq_client.set_setable_positions({self._motor:position})
return self.parent._wait_until_still()
@property
def hints(self) -> Dict:
out: Dict = {}
out["fields"] = [self.name]
return out
def trigger(self) -> Status:
return self.parent.trigger()
| 27.293578 | 78 | 0.603361 | 342 | 2,975 | 5.081871 | 0.216374 | 0.115075 | 0.110472 | 0.069045 | 0.459148 | 0.352129 | 0.318757 | 0.314154 | 0.064442 | 0.064442 | 0 | 0 | 0.278319 | 2,975 | 108 | 79 | 27.546296 | 0.809502 | 0.012773 | 0 | 0.307692 | 0 | 0 | 0.035434 | 0.009881 | 0 | 0 | 0 | 0.009259 | 0 | 1 | 0.269231 | false | 0 | 0.064103 | 0.205128 | 0.602564 | 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 |
229b2cffb91cf3d18f52bd68ef5a38fd2c617d19 | 1,316 | py | Python | lab/string_.py | GabrielBrasileiro/cereja | 568dac79b578c857081fab12301f9d85c9e27089 | [
"MIT"
] | 10 | 2020-11-09T12:41:27.000Z | 2022-03-30T14:10:29.000Z | lab/string_.py | GabrielBrasileiro/cereja | 568dac79b578c857081fab12301f9d85c9e27089 | [
"MIT"
] | 30 | 2019-09-30T21:26:22.000Z | 2020-11-06T12:00:55.000Z | lab/string_.py | GabrielBrasileiro/cereja | 568dac79b578c857081fab12301f9d85c9e27089 | [
"MIT"
] | 7 | 2019-09-30T15:39:34.000Z | 2020-11-05T22:51:37.000Z | """
Copyright (c) 2019 The Cereja Project
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
"""
import string
import re
from typing import AnyStr, Sequence
def str_gen(pattern: AnyStr) -> Sequence[AnyStr]:
regex = re.compile(pattern)
return regex.findall(string.printable)
if __name__ == '__main__':
print(str_gen('[0-9]'))
| 36.555556 | 78 | 0.781915 | 202 | 1,316 | 5.044554 | 0.574257 | 0.086359 | 0.025515 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0.00545 | 0.163374 | 1,316 | 35 | 79 | 37.6 | 0.920073 | 0.806231 | 0 | 0 | 0 | 0 | 0.052846 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0.125 | false | 0 | 0.375 | 0 | 0.625 | 0.25 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 1 | 0 | 0 | 3 |
22ac908cba8f4d617fec01a20f15096dfc112f99 | 219 | py | Python | restframepy/routers.py | josueischiu12/parcial3 | d992835a6123a2bec25bab3472fc7785610448d7 | [
"bzip2-1.0.6"
] | null | null | null | restframepy/routers.py | josueischiu12/parcial3 | d992835a6123a2bec25bab3472fc7785610448d7 | [
"bzip2-1.0.6"
] | null | null | null | restframepy/routers.py | josueischiu12/parcial3 | d992835a6123a2bec25bab3472fc7785610448d7 | [
"bzip2-1.0.6"
] | null | null | null | from rest_framework import routers
from citein.viewsets import GradoViewSet, EstudianteViewSet
router = routers.DefaultRouter()
router.register(r'grado', GradoViewSet)
router.register(r'estudiante', EstudianteViewSet) | 31.285714 | 59 | 0.840183 | 24 | 219 | 7.625 | 0.625 | 0.153005 | 0.163934 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0.077626 | 219 | 7 | 60 | 31.285714 | 0.905941 | 0 | 0 | 0 | 0 | 0 | 0.068182 | 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 |
22bff5597e8d5d164844414d008d4b415f3e0671 | 573 | py | Python | fooof/tests/utils/test_reports.py | varman-m/eeg_notebooks_doc | 12230719637c8087b020e8d5feeb20520a4da74d | [
"Apache-2.0"
] | 154 | 2018-11-05T16:50:21.000Z | 2022-03-31T12:02:33.000Z | fooof/tests/utils/test_reports.py | Xawwell/fooof | 7a520c4f8ac3a44f4f18dc025b5e5d40049c9f2b | [
"Apache-2.0"
] | 128 | 2018-11-03T16:07:05.000Z | 2022-03-30T22:09:48.000Z | fooof/tests/utils/test_reports.py | Xawwell/fooof | 7a520c4f8ac3a44f4f18dc025b5e5d40049c9f2b | [
"Apache-2.0"
] | 42 | 2019-01-31T17:24:58.000Z | 2022-02-19T00:00:58.000Z | """Test functions for fooof.utils.reports"""
from fooof.utils.reports import *
###################################################################################################
###################################################################################################
def test_methods_report_info(tfm):
# Test with and without passing in a FOOOF object
methods_report_info()
methods_report_info(tfm)
def test_methods_report_text(tfm):
# Test with and without passing in a FOOOF object
methods_report_text()
methods_report_text(tfm)
| 30.157895 | 99 | 0.488656 | 55 | 573 | 4.836364 | 0.381818 | 0.293233 | 0.191729 | 0.150376 | 0.413534 | 0.413534 | 0.413534 | 0.413534 | 0.413534 | 0.413534 | 0 | 0 | 0.118674 | 573 | 18 | 100 | 31.833333 | 0.526733 | 0.235602 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0.285714 | false | 0 | 0.142857 | 0 | 0.428571 | 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 |
22c69fc8083d750e6b6cdac63e2c428178679f30 | 1,374 | py | Python | src/long_read_pipeline/models.py | NTU-CGM/MiDSystem | 0d7dadafe4811ec9d1c0df03e99d7c479e8c7f1d | [
"MIT"
] | null | null | null | src/long_read_pipeline/models.py | NTU-CGM/MiDSystem | 0d7dadafe4811ec9d1c0df03e99d7c479e8c7f1d | [
"MIT"
] | null | null | null | src/long_read_pipeline/models.py | NTU-CGM/MiDSystem | 0d7dadafe4811ec9d1c0df03e99d7c479e8c7f1d | [
"MIT"
] | null | null | null | from django.db import models
# Create your models here.
class long_ip_log(models.Model):
ip=models.CharField(max_length=25)
country=models.CharField(max_length=50,default="NA")
functions=models.CharField(max_length=25,default="NA")
submission_time=models.DateTimeField(auto_now_add=True)
class long_User_Job(models.Model):
user_id=models.CharField(max_length=50)
upload_id=models.CharField(max_length=64)
ip=models.CharField(max_length=25)
mail=models.EmailField(max_length=254)
submission_time=models.DateTimeField(auto_now_add=True)
start_time=models.DateTimeField(auto_now_add=True)
end_time=models.DateTimeField(auto_now_add=True)
total_status=models.CharField(max_length=10,default='WAITING')
data_preparation_status=models.CharField(max_length=10,default='WAITING')
quality_check=models.CharField(max_length=10,default='WAITING')
assembly_status=models.CharField(max_length=10,default='WAITING')
remap_status=models.CharField(max_length=10,default='SKIPPED')
gene_prediction_status=models.CharField(max_length=10,default='WAITING')
go_status=models.CharField(max_length=10,default='WAITING')
tree_status=models.CharField(max_length=10,default='SKIPPED')
parsing_status=models.CharField(max_length=10,default='WAITING')
error_log=models.CharField(max_length=50,default='NA')
| 49.071429 | 77 | 0.787482 | 193 | 1,374 | 5.362694 | 0.290155 | 0.147826 | 0.278261 | 0.371014 | 0.755556 | 0.678261 | 0.624155 | 0.446377 | 0 | 0 | 0 | 0.02809 | 0.093159 | 1,374 | 28 | 78 | 49.071429 | 0.802568 | 0.017467 | 0 | 0.166667 | 0 | 0 | 0.051149 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | false | 0 | 0.041667 | 0 | 1 | 0 | 0 | 0 | 0 | null | 0 | 1 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 3 |
22cc41504093e460a2f09a785ca4b1d2cce6786e | 175 | py | Python | hackerrank/4. sets/13.py | Eurydia/Xian-assignment | 4a7e4bcd3d4999ea7429054fec1792064c96ff30 | [
"MIT"
] | null | null | null | hackerrank/4. sets/13.py | Eurydia/Xian-assignment | 4a7e4bcd3d4999ea7429054fec1792064c96ff30 | [
"MIT"
] | null | null | null | hackerrank/4. sets/13.py | Eurydia/Xian-assignment | 4a7e4bcd3d4999ea7429054fec1792064c96ff30 | [
"MIT"
] | null | null | null | a = set(input().split())
n = int(input())
for _ in range(n):
b = set(input().split())
if not a.issuperset(b):
print(False)
break
else:
print(True)
| 17.5 | 28 | 0.537143 | 26 | 175 | 3.576923 | 0.692308 | 0.172043 | 0.27957 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0.274286 | 175 | 9 | 29 | 19.444444 | 0.732283 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | false | 0 | 0 | 0 | 0 | 0.222222 | 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 |
22eca9beded3be4be447d16fa12473200db56a8a | 253 | py | Python | lib/pavilion/expression_functions/common.py | paulbry/pavilion2 | 3b17ba0354d336e824018455d27f293ff7f9cf97 | [
"BSD-3-Clause"
] | 33 | 2019-08-29T18:02:49.000Z | 2022-02-28T04:44:57.000Z | lib/pavilion/expression_functions/common.py | Paul-Ferrell/pavilion2 | ab41c178e4cc992abd2d856e2b276e0bbcf9d0d6 | [
"BSD-3-Clause"
] | 321 | 2019-08-21T15:58:00.000Z | 2022-03-29T01:38:55.000Z | lib/pavilion/expression_functions/common.py | Paul-Ferrell/pavilion2 | ab41c178e4cc992abd2d856e2b276e0bbcf9d0d6 | [
"BSD-3-Clause"
] | 16 | 2019-11-29T02:19:18.000Z | 2021-07-20T22:20:50.000Z | class FunctionPluginError(RuntimeError):
"""Error raised when there's a problem with a function plugin
itself."""
class FunctionArgError(ValueError):
"""Error raised when a function plugin has a problem with the
function arguments."""
| 28.111111 | 65 | 0.735178 | 31 | 253 | 6 | 0.612903 | 0.11828 | 0.16129 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0.181818 | 253 | 8 | 66 | 31.625 | 0.898551 | 0.573123 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | true | 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 | 0 | 1 | 0 | 0 | 0 | 1 | 0 | 0 | 3 |
22f4a26742edb7f6a78e667af86d06b08986d1ab | 757 | py | Python | user.py | Mugo-Ndungu/PasswordLocker | 7e333060931e041ff9cd9fce2ea635f2a676decd | [
"Unlicense"
] | null | null | null | user.py | Mugo-Ndungu/PasswordLocker | 7e333060931e041ff9cd9fce2ea635f2a676decd | [
"Unlicense"
] | null | null | null | user.py | Mugo-Ndungu/PasswordLocker | 7e333060931e041ff9cd9fce2ea635f2a676decd | [
"Unlicense"
] | null | null | null | class User:
'''
User class for user input
'''
user_list = [] # User Empty list
def __init__(self, username, password):
self.username = username
self.password = password
def save_user(self):
'''
save_usermethod saves user objects into user_list
'''
User.user_list.append(self)
@classmethod
def user_exists(cls, characters):
'''
Method to che if a user exists
args:
character:username to search if it exist
return:
Boolean: true or false depending o the search outcome
'''
for user in cls.user_list:
if user.password == characters:
return True
return False | 21.027778 | 65 | 0.557464 | 85 | 757 | 4.835294 | 0.482353 | 0.077859 | 0.058394 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0.371202 | 757 | 36 | 66 | 21.027778 | 0.863445 | 0.321004 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0.230769 | false | 0.230769 | 0 | 0 | 0.538462 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 1 | 0 | 0 | 1 | 0 | 0 | 3 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.