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 |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
75265d3c33bff0658540430d03bc6356f5564d5b
| 3,450
|
py
|
Python
|
ngsutils/fastq/t/test_split.py
|
bgruening/ngsutils
|
417e90dc1918fb553dd84990f2c54bd8cea8f44d
|
[
"BSD-3-Clause"
] | 57
|
2015-03-09T01:26:45.000Z
|
2022-02-22T07:26:01.000Z
|
ngsutils/fastq/t/test_split.py
|
bgruening/ngsutils
|
417e90dc1918fb553dd84990f2c54bd8cea8f44d
|
[
"BSD-3-Clause"
] | 33
|
2015-02-03T23:24:46.000Z
|
2022-03-16T20:08:10.000Z
|
ngsutils/fastq/t/test_split.py
|
bgruening/ngsutils
|
417e90dc1918fb553dd84990f2c54bd8cea8f44d
|
[
"BSD-3-Clause"
] | 33
|
2015-01-18T16:47:47.000Z
|
2022-02-22T07:28:09.000Z
|
#!/usr/bin/env python
'''
Tests for fastqutils split
'''
import os
import unittest
import ngsutils.fastq.split
from ngsutils.fastq import FASTQ
class SplitTest(unittest.TestCase):
def testSplit(self):
fname = os.path.join(os.path.dirname(__file__), 'test.fastq')
templ = os.path.join(os.path.dirname(__file__), 'test_templ')
ngsutils.fastq.split.fastq_split(fname, templ, 2, quiet=True)
self.assertTrue(os.path.exists('%s.1.fastq' % templ))
self.assertTrue(os.path.exists('%s.2.fastq' % templ))
fq1 = FASTQ('%s.1.fastq' % templ)
fq2 = FASTQ('%s.2.fastq' % templ)
names1 = [x.fullname for x in fq1.fetch(quiet=True)]
self.assertEqual(names1, ['foo /1', 'foo /2', 'baz /1', 'baz /2'])
names2 = [x.fullname for x in fq2.fetch(quiet=True)]
self.assertEqual(names2, ['bar /1', 'bar /2'])
fq1.close()
fq2.close()
os.unlink('%s.1.fastq' % templ)
os.unlink('%s.2.fastq' % templ)
def testSplitGz(self):
fname = os.path.join(os.path.dirname(__file__), 'test.fastq')
templ = os.path.join(os.path.dirname(__file__), 'test_templ')
ngsutils.fastq.split.fastq_split(fname, templ, 2, gz=True, quiet=True)
self.assertTrue(os.path.exists('%s.1.fastq.gz' % templ))
self.assertTrue(os.path.exists('%s.2.fastq.gz' % templ))
os.unlink('%s.1.fastq.gz' % templ)
os.unlink('%s.2.fastq.gz' % templ)
def testSplitUnpaired(self):
fname = os.path.join(os.path.dirname(__file__), 'test.fastq')
templ = os.path.join(os.path.dirname(__file__), 'test_templ')
ngsutils.fastq.split.fastq_split(fname, templ, 2, ignore_pairs=True, quiet=True)
self.assertTrue(os.path.exists('%s.1.fastq' % templ))
self.assertTrue(os.path.exists('%s.2.fastq' % templ))
fq1 = FASTQ('%s.1.fastq' % templ)
fq2 = FASTQ('%s.2.fastq' % templ)
names1 = [x.name for x in fq1.fetch(quiet=True)]
self.assertEqual(names1, ['foo', 'bar', 'baz'])
names2 = [x.name for x in fq2.fetch(quiet=True)]
self.assertEqual(names2, ['foo', 'bar', 'baz'])
fq1.close()
fq2.close()
os.unlink('%s.1.fastq' % templ)
os.unlink('%s.2.fastq' % templ)
def testSplitThree(self):
fname = os.path.join(os.path.dirname(__file__), 'test.fastq')
templ = os.path.join(os.path.dirname(__file__), 'test_templ')
ngsutils.fastq.split.fastq_split(fname, templ, 3, ignore_pairs=True, quiet=True)
self.assertTrue(os.path.exists('%s.1.fastq' % templ))
self.assertTrue(os.path.exists('%s.2.fastq' % templ))
self.assertTrue(os.path.exists('%s.3.fastq' % templ))
fq1 = FASTQ('%s.1.fastq' % templ)
fq2 = FASTQ('%s.2.fastq' % templ)
fq3 = FASTQ('%s.3.fastq' % templ)
names1 = [x.fullname for x in fq1.fetch(quiet=True)]
self.assertEqual(names1, ['foo /1', 'bar /2'])
names2 = [x.fullname for x in fq2.fetch(quiet=True)]
self.assertEqual(names2, ['foo /2', 'baz /1'])
names3 = [x.fullname for x in fq3.fetch(quiet=True)]
self.assertEqual(names3, ['bar /1', 'baz /2'])
fq1.close()
fq2.close()
fq3.close()
os.unlink('%s.1.fastq' % templ)
os.unlink('%s.2.fastq' % templ)
os.unlink('%s.3.fastq' % templ)
if __name__ == '__main__':
unittest.main()
| 32.857143
| 88
| 0.593043
| 486
| 3,450
| 4.106996
| 0.123457
| 0.07515
| 0.071643
| 0.09018
| 0.842184
| 0.797094
| 0.775551
| 0.775551
| 0.762024
| 0.742986
| 0
| 0.028475
| 0.226377
| 3,450
| 104
| 89
| 33.173077
| 0.719371
| 0.013623
| 0
| 0.521739
| 0
| 0
| 0.129602
| 0
| 0
| 0
| 0
| 0
| 0.231884
| 1
| 0.057971
| false
| 0
| 0.057971
| 0
| 0.130435
| 0
| 0
| 0
| 0
| null | 0
| 0
| 0
| 1
| 1
| 1
| 1
| 1
| 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
| 6
|
7538a3d002efb43cd025cbe58a5810a6c76f1aae
| 543
|
py
|
Python
|
python/dsbox/planner/event_handler.py
|
RqS/dsbox-ta2
|
43800d4365a154684fa5b9551c2c1cd21ec7139c
|
[
"MIT"
] | 1
|
2021-11-05T17:42:47.000Z
|
2021-11-05T17:42:47.000Z
|
python/dsbox/planner/event_handler.py
|
RqS/dsbox-ta2
|
43800d4365a154684fa5b9551c2c1cd21ec7139c
|
[
"MIT"
] | null | null | null |
python/dsbox/planner/event_handler.py
|
RqS/dsbox-ta2
|
43800d4365a154684fa5b9551c2c1cd21ec7139c
|
[
"MIT"
] | 2
|
2019-02-21T18:29:51.000Z
|
2019-09-02T21:21:26.000Z
|
class PlannerEventHandler(object):
pass
def ProblemNotImplemented(self):
return False
def StartedPlanning(self):
return True
def SubmittedPipeline(self, pipeline):
return True
def RunningPipeline(self, pipeline):
return True
def CompletedPipeline(self, pipeline, result):
return True
def StartExecutingPipeline(self, pipeline):
return True
def ExecutedPipeline(self, pipeline, result):
return True
def EndedPlanning(self):
return True
| 20.111111
| 50
| 0.661142
| 51
| 543
| 7.039216
| 0.372549
| 0.194986
| 0.21727
| 0.183844
| 0.381616
| 0.172702
| 0
| 0
| 0
| 0
| 0
| 0
| 0.276243
| 543
| 26
| 51
| 20.884615
| 0.913486
| 0
| 0
| 0.388889
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 1
| 0.444444
| false
| 0.055556
| 0
| 0.444444
| 0.944444
| 0
| 0
| 0
| 0
| null | 0
| 1
| 1
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| null | 0
| 0
| 0
| 0
| 0
| 1
| 0
| 1
| 0
| 1
| 1
| 0
|
0
| 6
|
f34f9f0ab2f081177fca334c77c02188ceac8814
| 38
|
py
|
Python
|
utils/__init__.py
|
ari-viitala/RLDonkeyCar
|
7719765e72ddcc4239fa6beb913ff3254fac901d
|
[
"MIT"
] | null | null | null |
utils/__init__.py
|
ari-viitala/RLDonkeyCar
|
7719765e72ddcc4239fa6beb913ff3254fac901d
|
[
"MIT"
] | 6
|
2020-09-26T01:09:20.000Z
|
2022-02-10T01:34:41.000Z
|
utils/__init__.py
|
ari-viitala/RLDonkeyCar
|
7719765e72ddcc4239fa6beb913ff3254fac901d
|
[
"MIT"
] | 1
|
2021-02-21T02:04:24.000Z
|
2021-02-21T02:04:24.000Z
|
from .functions import image_to_ascii
| 19
| 37
| 0.868421
| 6
| 38
| 5.166667
| 1
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0.105263
| 38
| 1
| 38
| 38
| 0.911765
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 1
| 0
| true
| 0
| 1
| 0
| 1
| 0
| 1
| 1
| 0
| null | 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 1
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| null | 0
| 0
| 0
| 0
| 0
| 0
| 1
| 0
| 1
| 0
| 1
| 0
|
0
| 6
|
f3a5fab66ceedfb341431e9840acd30ba94bdbc7
| 38
|
py
|
Python
|
python/testlint/testlint/util.py
|
mpsonntag/snippets
|
fc3cc42ea49b885c1f29c0aef1379055a931a978
|
[
"BSD-3-Clause"
] | null | null | null |
python/testlint/testlint/util.py
|
mpsonntag/snippets
|
fc3cc42ea49b885c1f29c0aef1379055a931a978
|
[
"BSD-3-Clause"
] | null | null | null |
python/testlint/testlint/util.py
|
mpsonntag/snippets
|
fc3cc42ea49b885c1f29c0aef1379055a931a978
|
[
"BSD-3-Clause"
] | null | null | null |
def add_yourself(a):
return a + a
| 12.666667
| 20
| 0.631579
| 7
| 38
| 3.285714
| 0.714286
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0.263158
| 38
| 2
| 21
| 19
| 0.821429
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 1
| 0.5
| false
| 0
| 0
| 0.5
| 1
| 0
| 1
| 1
| 0
| null | 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 1
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| null | 0
| 0
| 0
| 0
| 0
| 1
| 0
| 0
| 0
| 1
| 1
| 0
|
0
| 6
|
45f617d11581a0cf0260e2455d4557f6c5262ffa
| 153
|
py
|
Python
|
tests/error/redefined_name01.py
|
ktok07b6/polyphony
|
657c5c7440520db6b4985970bd50547407693ac4
|
[
"MIT"
] | 83
|
2015-11-30T09:59:13.000Z
|
2021-08-03T09:12:28.000Z
|
tests/error/redefined_name01.py
|
jesseclin/polyphony
|
657c5c7440520db6b4985970bd50547407693ac4
|
[
"MIT"
] | 4
|
2017-02-10T01:43:11.000Z
|
2020-07-14T03:52:25.000Z
|
tests/error/redefined_name01.py
|
jesseclin/polyphony
|
657c5c7440520db6b4985970bd50547407693ac4
|
[
"MIT"
] | 11
|
2016-11-18T14:39:15.000Z
|
2021-02-23T10:05:20.000Z
|
#'func0' has been redefined
from polyphony import testbench
def func0(x):
pass
def func0(x):
pass
@testbench
def test():
pass
test()
| 8.052632
| 31
| 0.647059
| 21
| 153
| 4.714286
| 0.571429
| 0.242424
| 0.181818
| 0.262626
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0.026316
| 0.254902
| 153
| 18
| 32
| 8.5
| 0.842105
| 0.169935
| 0
| 0.555556
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 1
| 0.333333
| false
| 0.333333
| 0.111111
| 0
| 0.444444
| 0
| 1
| 0
| 0
| null | 1
| 1
| 1
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| null | 0
| 0
| 0
| 0
| 0
| 1
| 0
| 1
| 0
| 0
| 0
| 0
|
0
| 6
|
3443175248730b51ad72e72fcbe1751c3abf74e5
| 44,450
|
py
|
Python
|
tests/001_theoretical/test_023_json_blueprint.py
|
vitlabuda/datalidator
|
539063a98990c6be165baeff6c2a74ac2fd7a130
|
[
"BSD-3-Clause"
] | null | null | null |
tests/001_theoretical/test_023_json_blueprint.py
|
vitlabuda/datalidator
|
539063a98990c6be165baeff6c2a74ac2fd7a130
|
[
"BSD-3-Clause"
] | null | null | null |
tests/001_theoretical/test_023_json_blueprint.py
|
vitlabuda/datalidator
|
539063a98990c6be165baeff6c2a74ac2fd7a130
|
[
"BSD-3-Clause"
] | null | null | null |
#!/bin/false
# Copyright (c) 2022 Vít Labuda. All rights reserved.
#
# Redistribution and use in source and binary forms, with or without modification, are permitted provided that the
# following conditions are met:
# 1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following
# disclaimer.
# 2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the
# following disclaimer in the documentation and/or other materials provided with the distribution.
# 3. Neither the name of the copyright holder nor the names of its contributors may be used to endorse or promote
# products derived from this software without specific prior written permission.
#
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,
# INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
# DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
# SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
# WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
import os
import os.path
import sys
if "DATALIDATOR_TESTS_AUTOPATH" in os.environ:
__TESTS_DIR = os.path.dirname(os.path.realpath(__file__))
__MODULE_DIR = os.path.realpath(os.path.join(__TESTS_DIR, "../.."))
if __TESTS_DIR not in sys.path:
sys.path.insert(0, __TESTS_DIR)
if __MODULE_DIR not in sys.path:
sys.path.insert(0, __MODULE_DIR)
from typing import Any, List
import theoretical_testutils
import pytest
from datalidator.blueprints.ParsingMode import ParsingMode
from datalidator.blueprints.specialimpl.JSONBlueprint import JSONBlueprint
from datalidator.blueprints.impl.StringBlueprint import StringBlueprint
from datalidator.blueprints.impl.IntegerBlueprint import IntegerBlueprint
from datalidator.blueprints.impl.BooleanBlueprint import BooleanBlueprint
from datalidator.blueprints.impl.GenericBlueprint import GenericBlueprint
from datalidator.blueprints.impl.ListBlueprint import ListBlueprint
from datalidator.blueprints.impl.ObjectBlueprint import ObjectBlueprint
from datalidator.blueprints.extras.ObjectModel import ObjectModel
from datalidator.blueprints.exc.InvalidInputDataExc import InvalidInputDataExc
from datalidator.blueprints.exc.InputDataTypeNotInAllowlistExc import InputDataTypeNotInAllowlistExc
from datalidator.blueprints.exc.InputDataNotConvertibleExc import InputDataNotConvertibleExc
from datalidator.blueprints.exc.InputDataValueNotAllowedForDataTypeExc import InputDataValueNotAllowedForDataTypeExc
from datalidator.filters.impl.StringStripFilter import StringStripFilter
from datalidator.filters.impl.StringUnicodeNormalizeFilter import StringUnicodeNormalizeFilter
from datalidator.validators.impl.StringMatchesRegexValidator import StringMatchesRegexValidator
from datalidator.validators.impl.NumberMinimumValueValidator import NumberMinimumValueValidator
from datalidator.validators.impl.NumberMaximumValueValidator import NumberMaximumValueValidator
from datalidator.validators.exc.DataValidationFailedExc import DataValidationFailedExc
class JSONTestObjectModel(ObjectModel):
username = StringBlueprint(
filters=(StringStripFilter(), StringUnicodeNormalizeFilter(normal_form="NFKC")),
validators=(StringMatchesRegexValidator(r'^[a-z0-9]{3,15}\Z'),),
parsing_mode=ParsingMode.MODE_STRICT
)
age = IntegerBlueprint(
validators=(NumberMinimumValueValidator(13), NumberMaximumValueValidator(100)),
parsing_mode=ParsingMode.MODE_STRICT
)
__JSON_BLUEPRINT_TEST_SUITE = (
(JSONBlueprint[Any](
wrapped_blueprint=GenericBlueprint()
), (
("", InvalidInputDataExc),
("hello", InvalidInputDataExc),
("hello\x00", InvalidInputDataExc),
("hello world", InvalidInputDataExc),
("hello world\r\n", InvalidInputDataExc),
("hello\r\nworld", InvalidInputDataExc),
("hello\x00world\r\n", InvalidInputDataExc),
("řeřicha", InvalidInputDataExc),
("řeřicha\r\n", InvalidInputDataExc),
("řeř\r\nicha", InvalidInputDataExc),
("řeř\x00icha", InvalidInputDataExc),
("🤍", InvalidInputDataExc),
("🤍\r\n", InvalidInputDataExc),
("🤍\x00", InvalidInputDataExc),
("\x00🤍", InvalidInputDataExc),
("null", None),
("Null", InvalidInputDataExc),
("NULL", InvalidInputDataExc),
("true", True),
("True", InvalidInputDataExc),
("TRUE", InvalidInputDataExc),
("false", False),
("False", InvalidInputDataExc),
("FALSE", InvalidInputDataExc),
("123", 123),
("-123", -123),
("123.0", 123.0),
("-123.0", -123.0),
("Infinity", float("inf")), # This is not portable!
("infinity", InvalidInputDataExc),
("-Infinity", float("-inf")), # This is not portable!
("-infinity", InvalidInputDataExc),
("NaN", lambda output: str(output) == "nan"), # This is not portable!
("nan", InvalidInputDataExc),
('""', ""),
('"abc"', "abc"),
('"hello\\tworld\\r\\n"', "hello\tworld\r\n"),
('"hello\\t\\u0000world\\r\\n"', "hello\t\x00world\r\n"),
('"\\f\\u000b hello\\t\\u0000world\\r\\n"', "\f\v hello\t\x00world\r\n"),
('"\\"\\"\\"\'\'\\"\\"\'\\"\\"\'\\""', '"""\'\'""\'""\'"'),
(
'[1, 2.5, true, "abc", null, "hello\\tworld\\r\\n"]',
[1, 2.5, True, "abc", None, "hello\tworld\r\n"]
),
(
'{"true": false, "some_value": null, "1.5": -123, "float": 123.5, "hello world": "\\u0159e\\u0159icha", "test\\u0000\\t key": "hello \\ud83e\\udd0d!", " ascii\\uffffstring \\t\\n": "value", "": ""}',
{"true": False, "some_value": None, "1.5": -123, "float": 123.5, "hello world": "řeřicha", "test\x00\t key": "hello 🤍!", " ascii\uffffstring \t\n": "value", "": ""}
),
(
'[{}, {"a": 123, "b": true}, null, [1, 2.5], "test"]',
[{}, {"a": 123, "b": True}, None, [1, 2.5], "test"]
),
(
'{"hello": [true, false, "123 "], "value": null, "test\\r\\n": 132.5, "object": {"a": null, "b": "c"}}',
{"hello": [True, False, "123 "], "value": None, "test\r\n": 132.5, "object": {"a": None, "b": "c"}}
),
("\t\r\u2029\x85 \t \x1c ", InvalidInputDataExc),
("\t\r\u2029\x85 \t \x1c hello", InvalidInputDataExc),
("\t\r\u2029\x85 \t \x1c hello\x00", InvalidInputDataExc),
("\t\r\u2029\x85 \t \x1c hello world", InvalidInputDataExc),
("\t\r\u2029\x85 \t \x1c hello world\r\n", InvalidInputDataExc),
("\t\r\u2029\x85 \t \x1c hello\r\nworld", InvalidInputDataExc),
("\t\r\u2029\x85 \t \x1c hello\x00world\r\n", InvalidInputDataExc),
("\t\r\u2029\x85 \t \x1c řeřicha", InvalidInputDataExc),
("\t\r\u2029\x85 \t \x1c řeřicha\r\n", InvalidInputDataExc),
("\t\r\u2029\x85 \t \x1c řeř\r\nicha", InvalidInputDataExc),
("\t\r\u2029\x85 \t \x1c řeř\x00icha", InvalidInputDataExc),
("\t\r\u2029\x85 \t \x1c 🤍", InvalidInputDataExc),
("\t\r\u2029\x85 \t \x1c 🤍\r\n", InvalidInputDataExc),
("\t\r\u2029\x85 \t \x1c 🤍\x00", InvalidInputDataExc),
("\t\r\u2029\x85 \t \x1c \x00🤍", InvalidInputDataExc),
("\t\r\u2029\x85 \t \x1c null", None),
("\t\r\u2029\x85 \t \x1c Null", InvalidInputDataExc),
("\t\r\u2029\x85 \t \x1c NULL", InvalidInputDataExc),
("\t\r\u2029\x85 \t \x1c true", True),
("\t\r\u2029\x85 \t \x1c True", InvalidInputDataExc),
("\t\r\u2029\x85 \t \x1c TRUE", InvalidInputDataExc),
("\t\r\u2029\x85 \t \x1c false", False),
("\t\r\u2029\x85 \t \x1c False", InvalidInputDataExc),
("\t\r\u2029\x85 \t \x1c FALSE", InvalidInputDataExc),
("\t\r\u2029\x85 \t \x1c 123", 123),
("\t\r\u2029\x85 \t \x1c -123", -123),
("\t\r\u2029\x85 \t \x1c 123.0", 123.0),
("\t\r\u2029\x85 \t \x1c -123.0", -123.0),
("\t\r\u2029\x85 \t \x1c Infinity", float("inf")), # This is not portable!
("\t\r\u2029\x85 \t \x1c infinity", InvalidInputDataExc),
("\t\r\u2029\x85 \t \x1c -Infinity", float("-inf")), # This is not portable!
("\t\r\u2029\x85 \t \x1c -infinity", InvalidInputDataExc),
("\t\r\u2029\x85 \t \x1c NaN", lambda output: str(output) == "nan"), # This is not portable!
("\t\r\u2029\x85 \t \x1c nan", InvalidInputDataExc),
('\t\r\u2029\x85 \t \x1c ""', ""),
('\t\r\u2029\x85 \t \x1c "abc"', "abc"),
('\t\r\u2029\x85 \t \x1c "hello\\tworld\\r\\n"', "hello\tworld\r\n"),
('\t\r\u2029\x85 \t \x1c "hello\\t\\u0000world\\r\\n"', "hello\t\x00world\r\n"),
('\t\r\u2029\x85 \t \x1c "\\f\\u000b hello\\t\\u0000world\\r\\n"', "\f\v hello\t\x00world\r\n"),
('\t\r\u2029\x85 \t \x1c "\\"\\"\\"\'\'\\"\\"\'\\"\\"\'\\""', '"""\'\'""\'""\'"'),
(
'\x1c\x1e \t\x85 \u2029\u2028 [1, 2.5, true, "abc", null, "hello\\tworld\\r\\n"]\v\f\f\r\n\r\r\n\n\n ',
[1, 2.5, True, "abc", None, "hello\tworld\r\n"]
),
(
'\x1c\x1e \t\x85 \u2029\u2028 {"true": false, "some_value": null, "1.5": -123, "float": 123.5, "hello world": "\\u0159e\\u0159icha", "test\\u0000\\t key": "hello \\ud83e\\udd0d!", " ascii\\uffffstring \\t\\n": "value", "": ""}\v\f\f\r\n\r\r\n\n\n ',
{"true": False, "some_value": None, "1.5": -123, "float": 123.5, "hello world": "řeřicha", "test\x00\t key": "hello 🤍!", " ascii\uffffstring \t\n": "value", "": ""}
),
(
'\x1c\x1e \t\x85 \u2029\u2028 [{}, {"a": 123, "b": true}, null, [1, 2.5], "test"]\v\f\f\r\n\r\r\n\n\n ',
[{}, {"a": 123, "b": True}, None, [1, 2.5], "test"]
),
(
'\x1c\x1e \t\x85 \u2029\u2028 {"hello": [true, false, "123 "], "value": null, "test\\r\\n": 132.5, "object": {"a": null, "b": "c"}}\v\f\f\r\n\r\r\n\n\n ',
{"hello": [True, False, "123 "], "value": None, "test\r\n": 132.5, "object": {"a": None, "b": "c"}}
),
(None, InputDataTypeNotInAllowlistExc),
(False, InputDataTypeNotInAllowlistExc),
(True, InputDataTypeNotInAllowlistExc),
(1, InputDataTypeNotInAllowlistExc),
(0, InputDataTypeNotInAllowlistExc),
(1.5, InputDataTypeNotInAllowlistExc),
(0.5, InputDataTypeNotInAllowlistExc),
(1+2j, InputDataTypeNotInAllowlistExc),
([], InputDataTypeNotInAllowlistExc),
(["abc"], InputDataTypeNotInAllowlistExc),
({}, InputDataTypeNotInAllowlistExc),
({"abc": "def"}, InputDataTypeNotInAllowlistExc),
(b'', InputDataTypeNotInAllowlistExc),
(b'hello', InputDataTypeNotInAllowlistExc),
(bytearray(b''), InputDataTypeNotInAllowlistExc),
(bytearray(b'hello'), InputDataTypeNotInAllowlistExc),
(str, InputDataTypeNotInAllowlistExc),
(object(), InputDataTypeNotInAllowlistExc),
(theoretical_testutils.EmptyObject(), InputDataTypeNotInAllowlistExc),
)),
(JSONBlueprint[bool](
wrapped_blueprint=BooleanBlueprint(parsing_mode=ParsingMode.MODE_RATIONAL)
), (
("true", True),
("false", False),
("null", InputDataTypeNotInAllowlistExc),
("[]", InputDataTypeNotInAllowlistExc),
("{}", InputDataTypeNotInAllowlistExc),
("1.0", True),
("0.0", False),
("1.5", InputDataValueNotAllowedForDataTypeExc),
("0.5", InputDataValueNotAllowedForDataTypeExc),
("1", True),
("0", False),
("2", InputDataValueNotAllowedForDataTypeExc),
('""', InputDataValueNotAllowedForDataTypeExc),
('"hello"', InputDataValueNotAllowedForDataTypeExc),
('"TRUE"', True),
('"Yes\\r"', True),
('" \\n TRUE \\t"', True),
('" \\t no\\r\\n"', False),
('" \\t oFF\\r\\n"', False),
('" \\t \\u0000oFF\\r\\n"', InputDataValueNotAllowedForDataTypeExc),
('\r\n \t\u2029 "\\t TRUE \\n" \x1d\x1c \x85', True),
("", InvalidInputDataExc),
("hello", InvalidInputDataExc),
("he\x00llo", InvalidInputDataExc),
('"', InvalidInputDataExc),
('"""', InvalidInputDataExc),
(None, InputDataTypeNotInAllowlistExc),
([], InputDataTypeNotInAllowlistExc),
(str, InputDataTypeNotInAllowlistExc),
(object(), InputDataTypeNotInAllowlistExc),
(theoretical_testutils.EmptyObject(), InputDataTypeNotInAllowlistExc),
)),
(JSONBlueprint[List[int]](
wrapped_blueprint=ListBlueprint(
item_blueprint=IntegerBlueprint(parsing_mode=ParsingMode.MODE_RATIONAL),
parsing_mode=ParsingMode.MODE_STRICT
),
), (
("true", InputDataTypeNotInAllowlistExc),
("null", InputDataTypeNotInAllowlistExc),
("{}", InputDataTypeNotInAllowlistExc),
("5", InputDataTypeNotInAllowlistExc),
('""', InputDataTypeNotInAllowlistExc),
('"hello"', InputDataTypeNotInAllowlistExc),
('[true, "\\r 10_000 \\t\\n", "", 2.9, 8, "-789000"]', InputDataNotConvertibleExc),
('[true, "\\r 10_000 \\t\\n", "hello", 2.9, 8, "-789000"]', InputDataNotConvertibleExc),
('[true, "\\r 10_000 \\t\\n", [], 2.9, 8, "-789000"]', InputDataTypeNotInAllowlistExc),
('[true, "\\r 10_000 \\t\\n", {}, 2.9, 8, "-789000"]', InputDataTypeNotInAllowlistExc),
('[true, "\\r 10_000 \\t\\n", null, 2.9, 8, "-789000"]', InputDataTypeNotInAllowlistExc),
('[]', []),
('[1, 2, -3, 4]', [1, 2, -3, 4]),
('[true, "\\r 10_000 \\t\\n", 2.9, 8, "-789000"]', [1, 10000, 2, 8, -789000]),
('\t\f\v\u2028 [] \x1c\x1d ', []),
('\t\f\v\u2028 [1, 2, -3, 4] \x1c\x1d ', [1, 2, -3, 4]),
('\t\f\v\u2028 [true, "\\r 10_000 \\t\\n", 2.9, 8, "-789000"] \x1c\x1d ', [1, 10000, 2, 8, -789000]),
("", InvalidInputDataExc),
("hello", InvalidInputDataExc),
("he\x00llo", InvalidInputDataExc),
('"', InvalidInputDataExc),
('"""', InvalidInputDataExc),
(None, InputDataTypeNotInAllowlistExc),
([], InputDataTypeNotInAllowlistExc),
(str, InputDataTypeNotInAllowlistExc),
(object(), InputDataTypeNotInAllowlistExc),
(theoretical_testutils.EmptyObject(), InputDataTypeNotInAllowlistExc),
)),
(JSONBlueprint[ObjectModel](
wrapped_blueprint=ObjectBlueprint(
object_model=JSONTestObjectModel,
ignore_input_keys_which_are_not_in_model=False
),
), (
("true", InputDataNotConvertibleExc),
("null", InputDataNotConvertibleExc),
("5", InputDataNotConvertibleExc),
("5.8", InputDataNotConvertibleExc),
('""', InvalidInputDataExc),
('"\\uffff"', InvalidInputDataExc),
('"hello"', InputDataNotConvertibleExc),
('[]', InvalidInputDataExc),
('[1]', InputDataNotConvertibleExc),
('[1, 2]', InputDataNotConvertibleExc),
('{"username": "john01", "age": 15}', JSONTestObjectModel(username="john01", age=15)),
('{"username": "\\r\\n\\u2028 john01 \\t \\u2029\\t\\n\\r", "age": 15}', JSONTestObjectModel(username="john01", age=15)),
('{"username": "john01", "age": 15}', JSONTestObjectModel(username="john01", age=15)),
('{"username": "\\uff4a\\uff4f\\uff48\\uff4e\\uff10\\uff11", "age": 15}', JSONTestObjectModel(username="john01", age=15)),
('[["username", "john01"], ["age", 15]]', JSONTestObjectModel(username="john01", age=15)),
('[["username", "\\r\\n\\u2028 john01 \\t \\u2029\\t\\n\\r"], ["age", 15]]', JSONTestObjectModel(username="john01", age=15)),
('[["username", "john01"], ["age", 15]]', JSONTestObjectModel(username="john01", age=15)),
('[["username", "\\uff4a\\uff4f\\uff48\\uff4e\\uff10\\uff11"], ["age", 15]]', JSONTestObjectModel(username="john01", age=15)),
('{"username": "", "age": 15}', DataValidationFailedExc),
('[["username", ""], ["age", 15]]', DataValidationFailedExc),
('{"username": "ab", "age": 15}', DataValidationFailedExc),
('[["username", "ab"], ["age", 15]]', DataValidationFailedExc),
('{"username": "abc", "age": 15}', JSONTestObjectModel(username="abc", age=15)),
('[["username", "abc"], ["age", 15]]', JSONTestObjectModel(username="abc", age=15)),
('{"username": "abcdefghij", "age": 15}', JSONTestObjectModel(username="abcdefghij", age=15)),
('[["username", "abcdefghij"], ["age", 15]]', JSONTestObjectModel(username="abcdefghij", age=15)),
('{"username": "abcdefghijklmno", "age": 15}', JSONTestObjectModel(username="abcdefghijklmno", age=15)),
('[["username", "abcdefghijklmno"], ["age", 15]]', JSONTestObjectModel(username="abcdefghijklmno", age=15)),
('{"username": "abcdefghijklmnop", "age": 15}', DataValidationFailedExc),
('[["username", "abcdefghijklmnop"], ["age", 15]]', DataValidationFailedExc),
('{"username": "abcdefghijklmnop1234567890", "age": 15}', DataValidationFailedExc),
('[["username", "abcdefghijklmnop1234567890"], ["age", 15]]', DataValidationFailedExc),
('{"username": "John01", "age": 15}', DataValidationFailedExc),
('[["username", "John01"], ["age", 15]]', DataValidationFailedExc),
('{"username": "JOHN01", "age": 15}', DataValidationFailedExc),
('[["username", "JOHN01"], ["age", 15]]', DataValidationFailedExc),
('{"username": "johnŠ01", "age": 15}', DataValidationFailedExc),
('[["username", "johnŠ01"], ["age", 15]]', DataValidationFailedExc),
('{"username": "john\\u015901", "age": 15}', DataValidationFailedExc),
('[["username", "john\\u015901"], ["age", 15]]', DataValidationFailedExc),
('{"username": "john🤍01", "age": 15}', DataValidationFailedExc),
('[["username", "john🤍01"], ["age", 15]]', DataValidationFailedExc),
('{"username": "john\\ud83e\\udd0d01", "age": 15}', DataValidationFailedExc),
('[["username", "john\\ud83e\\udd0d01"], ["age", 15]]', DataValidationFailedExc),
('{"username": "john\\n01", "age": 15}', DataValidationFailedExc),
('[["username", "john\\n01"], ["age", 15]]', DataValidationFailedExc),
('{"username": "john\\u000001", "age": 15}', DataValidationFailedExc),
('[["username", "john\\u000001"], ["age", 15]]', DataValidationFailedExc),
('{"username": "john!01", "age": 15}', DataValidationFailedExc),
('[["username", "john!01"], ["age", 15]]', DataValidationFailedExc),
('{"username": "john.01", "age": 15}', DataValidationFailedExc),
('[["username", "john.01"], ["age", 15]]', DataValidationFailedExc),
('{"username": "john 01", "age": 15}', DataValidationFailedExc),
('[["username", "john 01"], ["age", 15]]', DataValidationFailedExc),
('{"username": "john\\t01", "age": 15}', DataValidationFailedExc),
('[["username", "john\\t01"], ["age", 15]]', DataValidationFailedExc),
('{"username": null, "age": 15}', InputDataTypeNotInAllowlistExc),
('[["username", null], ["age", 15]]', InputDataTypeNotInAllowlistExc),
('{"username": true, "age": 15}', InputDataTypeNotInAllowlistExc),
('[["username", true], ["age", 15]]', InputDataTypeNotInAllowlistExc),
('{"username": 7, "age": 15}', InputDataTypeNotInAllowlistExc),
('[["username", 7], ["age", 15]]', InputDataTypeNotInAllowlistExc),
('{"username": 5.5, "age": 15}', InputDataTypeNotInAllowlistExc),
('[["username", 5.5], ["age", 15]]', InputDataTypeNotInAllowlistExc),
('{"username": [], "age": 15}', InputDataTypeNotInAllowlistExc),
('[["username", []], ["age", 15]]', InputDataTypeNotInAllowlistExc),
('{"username": ["test"], "age": 15}', InputDataTypeNotInAllowlistExc),
('[["username", ["test"]], ["age", 15]]', InputDataTypeNotInAllowlistExc),
('{"username": {}, "age": 15}', InputDataTypeNotInAllowlistExc),
('[["username", {}], ["age", 15]]', InputDataTypeNotInAllowlistExc),
('{"username": {"test": "test"}, "age": 15}', InputDataTypeNotInAllowlistExc),
('[["username", {"test": "test"}], ["age", 15]]', InputDataTypeNotInAllowlistExc),
('{"username": "john01", "age": 0}', DataValidationFailedExc),
('[["username", "john01"], ["age", 0]]', DataValidationFailedExc),
('{"username": "john01", "age": 12}', DataValidationFailedExc),
('[["username", "john01"], ["age", 12]]', DataValidationFailedExc),
('{"username": "john01", "age": 13}', JSONTestObjectModel(username="john01", age=13)),
('[["username", "john01"], ["age", 13]]', JSONTestObjectModel(username="john01", age=13)),
('{"username": "john01", "age": 50}', JSONTestObjectModel(username="john01", age=50)),
('[["username", "john01"], ["age", 50]]', JSONTestObjectModel(username="john01", age=50)),
('{"username": "john01", "age": 100}', JSONTestObjectModel(username="john01", age=100)),
('[["username", "john01"], ["age", 100]]', JSONTestObjectModel(username="john01", age=100)),
('{"username": "john01", "age": 101}', DataValidationFailedExc),
('[["username", "john01"], ["age", 101]]', DataValidationFailedExc),
('{"username": "john01", "age": 100000000}', DataValidationFailedExc),
('[["username", "john01"], ["age", 100000000]]', DataValidationFailedExc),
('{"username": "john01", "age": null}', InputDataTypeNotInAllowlistExc),
('[["username", "john01"], ["age", null]]', InputDataTypeNotInAllowlistExc),
('{"username": "john01", "age": true}', DataValidationFailedExc), # For historic reasons, 'bool' is a subclass of 'int'.
('[["username", "john01"], ["age", true]]', DataValidationFailedExc), # For historic reasons, 'bool' is a subclass of 'int'.
('{"username": "john01", "age": 20.0}', InputDataTypeNotInAllowlistExc),
('[["username", "john01"], ["age", 20.0]]', InputDataTypeNotInAllowlistExc),
('{"username": "john01", "age": 20.9}', InputDataTypeNotInAllowlistExc),
('[["username", "john01"], ["age", 20.9]]', InputDataTypeNotInAllowlistExc),
('{"username": "john01", "age": "hello"}', InputDataTypeNotInAllowlistExc),
('[["username", "john01"], ["age", "hello"]]', InputDataTypeNotInAllowlistExc),
('{"username": "john01", "age": "20"}', InputDataTypeNotInAllowlistExc),
('[["username", "john01"], ["age", "20"]]', InputDataTypeNotInAllowlistExc),
('{"username": "john01", "age": []}', InputDataTypeNotInAllowlistExc),
('[["username", "john01"], ["age", []]]', InputDataTypeNotInAllowlistExc),
('{"username": "john01", "age": [20]}', InputDataTypeNotInAllowlistExc),
('[["username", "john01"], ["age", [20]]]', InputDataTypeNotInAllowlistExc),
('{"username": "john01", "age": {}}', InputDataTypeNotInAllowlistExc),
('[["username", "john01"], ["age", {}]]', InputDataTypeNotInAllowlistExc),
('{"username": "john01", "age": {"20": 20}}', InputDataTypeNotInAllowlistExc),
('[["username", "john01"], ["age", {"20": 20}]]', InputDataTypeNotInAllowlistExc),
('{"username": "john01", "age": 15, "extra": "field"}', InvalidInputDataExc),
('[["username", "john01"], ["age", 15], ["extra: "field"]]', InvalidInputDataExc),
('[["username", "john01", "abc"], ["age", 15]]', InputDataNotConvertibleExc),
('[["username", "john01"], ["age", 15, 16]]', InputDataNotConvertibleExc),
('[["username"], ["age", 15]]', InputDataNotConvertibleExc),
('[["username", "john01"], ["age"]]', InputDataNotConvertibleExc),
('[["username", "john01"], [], ["age", 15]]', InputDataNotConvertibleExc),
('[["username", "john01"], ["key"], ["age", 15]]', InputDataNotConvertibleExc),
('[["username", "john01"], ["key", "value"], ["age", 15]]', InvalidInputDataExc),
('[["username", "john01"], ["key", "value", "123"], ["age", 15]]', InputDataNotConvertibleExc),
('{"username": "john01"}', InvalidInputDataExc),
('[["username", "john01"]]', InvalidInputDataExc),
('{"age": 15}', InvalidInputDataExc),
('[["age", 15]]', InvalidInputDataExc),
('{}', InvalidInputDataExc),
('[]', InvalidInputDataExc),
('\n\n\t \x85\x1d\r\n\r \u2029\u2028 {"username": "john01", "age": 15} \x1c\x1e\x85\n\n \t\n \u2029 ', JSONTestObjectModel(username="john01", age=15)),
('\n\n\t \x85\x1d\r\n\r \u2029\u2028 {"username": "\\r\\n\\u2028 john01 \\t \\u2029\\t\\n\\r", "age": 15} \x1c\x1e\x85\n\n \t\n \u2029 ', JSONTestObjectModel(username="john01", age=15)),
('\n\n\t \x85\x1d\r\n\r \u2029\u2028 {"username": "john01", "age": 15} \x1c\x1e\x85\n\n \t\n \u2029 ', JSONTestObjectModel(username="john01", age=15)),
('\n\n\t \x85\x1d\r\n\r \u2029\u2028 {"username": "\\uff4a\\uff4f\\uff48\\uff4e\\uff10\\uff11", "age": 15} \x1c\x1e\x85\n\n \t\n \u2029 ', JSONTestObjectModel(username="john01", age=15)),
('\n\n\t \x85\x1d\r\n\r \u2029\u2028 [["username", "john01"], ["age", 15]] \x1c\x1e\x85\n\n \t\n \u2029 ', JSONTestObjectModel(username="john01", age=15)),
('\n\n\t \x85\x1d\r\n\r \u2029\u2028 [["username", "\\r\\n\\u2028 john01 \\t \\u2029\\t\\n\\r"], ["age", 15]] \x1c\x1e\x85\n\n \t\n \u2029 ', JSONTestObjectModel(username="john01", age=15)),
('\n\n\t \x85\x1d\r\n\r \u2029\u2028 [["username", "john01"], ["age", 15]] \x1c\x1e\x85\n\n \t\n \u2029 ', JSONTestObjectModel(username="john01", age=15)),
('\n\n\t \x85\x1d\r\n\r \u2029\u2028 [["username", "\\uff4a\\uff4f\\uff48\\uff4e\\uff10\\uff11"], ["age", 15]] \x1c\x1e\x85\n\n \t\n \u2029 ', JSONTestObjectModel(username="john01", age=15)),
('\n\n\t \x85\x1d\r\n\r \u2029\u2028 {"username": "", "age": 15} \x1c\x1e\x85\n\n \t\n \u2029 ', DataValidationFailedExc),
('\n\n\t \x85\x1d\r\n\r \u2029\u2028 [["username", ""], ["age", 15]] \x1c\x1e\x85\n\n \t\n \u2029 ', DataValidationFailedExc),
('\n\n\t \x85\x1d\r\n\r \u2029\u2028 {"username": "ab", "age": 15} \x1c\x1e\x85\n\n \t\n \u2029 ', DataValidationFailedExc),
('\n\n\t \x85\x1d\r\n\r \u2029\u2028 [["username", "ab"], ["age", 15]] \x1c\x1e\x85\n\n \t\n \u2029 ', DataValidationFailedExc),
('\n\n\t \x85\x1d\r\n\r \u2029\u2028 {"username": "abc", "age": 15} \x1c\x1e\x85\n\n \t\n \u2029 ', JSONTestObjectModel(username="abc", age=15)),
('\n\n\t \x85\x1d\r\n\r \u2029\u2028 [["username", "abc"], ["age", 15]] \x1c\x1e\x85\n\n \t\n \u2029 ', JSONTestObjectModel(username="abc", age=15)),
('\n\n\t \x85\x1d\r\n\r \u2029\u2028 {"username": "abcdefghij", "age": 15} \x1c\x1e\x85\n\n \t\n \u2029 ', JSONTestObjectModel(username="abcdefghij", age=15)),
('\n\n\t \x85\x1d\r\n\r \u2029\u2028 [["username", "abcdefghij"], ["age", 15]] \x1c\x1e\x85\n\n \t\n \u2029 ', JSONTestObjectModel(username="abcdefghij", age=15)),
('\n\n\t \x85\x1d\r\n\r \u2029\u2028 {"username": "abcdefghijklmno", "age": 15} \x1c\x1e\x85\n\n \t\n \u2029 ', JSONTestObjectModel(username="abcdefghijklmno", age=15)),
('\n\n\t \x85\x1d\r\n\r \u2029\u2028 [["username", "abcdefghijklmno"], ["age", 15]] \x1c\x1e\x85\n\n \t\n \u2029 ', JSONTestObjectModel(username="abcdefghijklmno", age=15)),
('\n\n\t \x85\x1d\r\n\r \u2029\u2028 {"username": "abcdefghijklmnop", "age": 15} \x1c\x1e\x85\n\n \t\n \u2029 ', DataValidationFailedExc),
('\n\n\t \x85\x1d\r\n\r \u2029\u2028 [["username", "abcdefghijklmnop"], ["age", 15]] \x1c\x1e\x85\n\n \t\n \u2029 ', DataValidationFailedExc),
('\n\n\t \x85\x1d\r\n\r \u2029\u2028 {"username": "abcdefghijklmnop1234567890", "age": 15} \x1c\x1e\x85\n\n \t\n \u2029 ', DataValidationFailedExc),
('\n\n\t \x85\x1d\r\n\r \u2029\u2028 [["username", "abcdefghijklmnop1234567890"], ["age", 15]] \x1c\x1e\x85\n\n \t\n \u2029 ', DataValidationFailedExc),
('\n\n\t \x85\x1d\r\n\r \u2029\u2028 {"username": "John01", "age": 15} \x1c\x1e\x85\n\n \t\n \u2029 ', DataValidationFailedExc),
('\n\n\t \x85\x1d\r\n\r \u2029\u2028 [["username", "John01"], ["age", 15]] \x1c\x1e\x85\n\n \t\n \u2029 ', DataValidationFailedExc),
('\n\n\t \x85\x1d\r\n\r \u2029\u2028 {"username": "JOHN01", "age": 15} \x1c\x1e\x85\n\n \t\n \u2029 ', DataValidationFailedExc),
('\n\n\t \x85\x1d\r\n\r \u2029\u2028 [["username", "JOHN01"], ["age", 15]] \x1c\x1e\x85\n\n \t\n \u2029 ', DataValidationFailedExc),
('\n\n\t \x85\x1d\r\n\r \u2029\u2028 {"username": "johnŠ01", "age": 15} \x1c\x1e\x85\n\n \t\n \u2029 ', DataValidationFailedExc),
('\n\n\t \x85\x1d\r\n\r \u2029\u2028 [["username", "johnŠ01"], ["age", 15]] \x1c\x1e\x85\n\n \t\n \u2029 ', DataValidationFailedExc),
('\n\n\t \x85\x1d\r\n\r \u2029\u2028 {"username": "john\\u015901", "age": 15} \x1c\x1e\x85\n\n \t\n \u2029 ', DataValidationFailedExc),
('\n\n\t \x85\x1d\r\n\r \u2029\u2028 [["username", "john\\u015901"], ["age", 15]] \x1c\x1e\x85\n\n \t\n \u2029 ', DataValidationFailedExc),
('\n\n\t \x85\x1d\r\n\r \u2029\u2028 {"username": "john🤍01", "age": 15} \x1c\x1e\x85\n\n \t\n \u2029 ', DataValidationFailedExc),
('\n\n\t \x85\x1d\r\n\r \u2029\u2028 [["username", "john🤍01"], ["age", 15]] \x1c\x1e\x85\n\n \t\n \u2029 ', DataValidationFailedExc),
('\n\n\t \x85\x1d\r\n\r \u2029\u2028 {"username": "john\\ud83e\\udd0d01", "age": 15} \x1c\x1e\x85\n\n \t\n \u2029 ', DataValidationFailedExc),
('\n\n\t \x85\x1d\r\n\r \u2029\u2028 [["username", "john\\ud83e\\udd0d01"], ["age", 15]] \x1c\x1e\x85\n\n \t\n \u2029 ', DataValidationFailedExc),
('\n\n\t \x85\x1d\r\n\r \u2029\u2028 {"username": "john\\n01", "age": 15} \x1c\x1e\x85\n\n \t\n \u2029 ', DataValidationFailedExc),
('\n\n\t \x85\x1d\r\n\r \u2029\u2028 [["username", "john\\n01"], ["age", 15]] \x1c\x1e\x85\n\n \t\n \u2029 ', DataValidationFailedExc),
('\n\n\t \x85\x1d\r\n\r \u2029\u2028 {"username": "john\\u000001", "age": 15} \x1c\x1e\x85\n\n \t\n \u2029 ', DataValidationFailedExc),
('\n\n\t \x85\x1d\r\n\r \u2029\u2028 [["username", "john\\u000001"], ["age", 15]] \x1c\x1e\x85\n\n \t\n \u2029 ', DataValidationFailedExc),
('\n\n\t \x85\x1d\r\n\r \u2029\u2028 {"username": "john!01", "age": 15} \x1c\x1e\x85\n\n \t\n \u2029 ', DataValidationFailedExc),
('\n\n\t \x85\x1d\r\n\r \u2029\u2028 [["username", "john!01"], ["age", 15]] \x1c\x1e\x85\n\n \t\n \u2029 ', DataValidationFailedExc),
('\n\n\t \x85\x1d\r\n\r \u2029\u2028 {"username": "john.01", "age": 15} \x1c\x1e\x85\n\n \t\n \u2029 ', DataValidationFailedExc),
('\n\n\t \x85\x1d\r\n\r \u2029\u2028 [["username", "john.01"], ["age", 15]] \x1c\x1e\x85\n\n \t\n \u2029 ', DataValidationFailedExc),
('\n\n\t \x85\x1d\r\n\r \u2029\u2028 {"username": "john 01", "age": 15} \x1c\x1e\x85\n\n \t\n \u2029 ', DataValidationFailedExc),
('\n\n\t \x85\x1d\r\n\r \u2029\u2028 [["username", "john 01"], ["age", 15]] \x1c\x1e\x85\n\n \t\n \u2029 ', DataValidationFailedExc),
('\n\n\t \x85\x1d\r\n\r \u2029\u2028 {"username": "john\\t01", "age": 15} \x1c\x1e\x85\n\n \t\n \u2029 ', DataValidationFailedExc),
('\n\n\t \x85\x1d\r\n\r \u2029\u2028 [["username", "john\\t01"], ["age", 15]] \x1c\x1e\x85\n\n \t\n \u2029 ', DataValidationFailedExc),
('\n\n\t \x85\x1d\r\n\r \u2029\u2028 {"username": null, "age": 15} \x1c\x1e\x85\n\n \t\n \u2029 ', InputDataTypeNotInAllowlistExc),
('\n\n\t \x85\x1d\r\n\r \u2029\u2028 [["username", null], ["age", 15]] \x1c\x1e\x85\n\n \t\n \u2029 ', InputDataTypeNotInAllowlistExc),
('\n\n\t \x85\x1d\r\n\r \u2029\u2028 {"username": true, "age": 15} \x1c\x1e\x85\n\n \t\n \u2029 ', InputDataTypeNotInAllowlistExc),
('\n\n\t \x85\x1d\r\n\r \u2029\u2028 [["username", true], ["age", 15]] \x1c\x1e\x85\n\n \t\n \u2029 ', InputDataTypeNotInAllowlistExc),
('\n\n\t \x85\x1d\r\n\r \u2029\u2028 {"username": 7, "age": 15} \x1c\x1e\x85\n\n \t\n \u2029 ', InputDataTypeNotInAllowlistExc),
('\n\n\t \x85\x1d\r\n\r \u2029\u2028 [["username", 7], ["age", 15]] \x1c\x1e\x85\n\n \t\n \u2029 ', InputDataTypeNotInAllowlistExc),
('\n\n\t \x85\x1d\r\n\r \u2029\u2028 {"username": 5.5, "age": 15} \x1c\x1e\x85\n\n \t\n \u2029 ', InputDataTypeNotInAllowlistExc),
('\n\n\t \x85\x1d\r\n\r \u2029\u2028 [["username", 5.5], ["age", 15]] \x1c\x1e\x85\n\n \t\n \u2029 ', InputDataTypeNotInAllowlistExc),
('\n\n\t \x85\x1d\r\n\r \u2029\u2028 {"username": [], "age": 15} \x1c\x1e\x85\n\n \t\n \u2029 ', InputDataTypeNotInAllowlistExc),
('\n\n\t \x85\x1d\r\n\r \u2029\u2028 [["username", []], ["age", 15]] \x1c\x1e\x85\n\n \t\n \u2029 ', InputDataTypeNotInAllowlistExc),
('\n\n\t \x85\x1d\r\n\r \u2029\u2028 {"username": ["test"], "age": 15} \x1c\x1e\x85\n\n \t\n \u2029 ', InputDataTypeNotInAllowlistExc),
('\n\n\t \x85\x1d\r\n\r \u2029\u2028 [["username", ["test"]], ["age", 15]] \x1c\x1e\x85\n\n \t\n \u2029 ', InputDataTypeNotInAllowlistExc),
('\n\n\t \x85\x1d\r\n\r \u2029\u2028 {"username": {}, "age": 15} \x1c\x1e\x85\n\n \t\n \u2029 ', InputDataTypeNotInAllowlistExc),
('\n\n\t \x85\x1d\r\n\r \u2029\u2028 [["username", {}], ["age", 15]] \x1c\x1e\x85\n\n \t\n \u2029 ', InputDataTypeNotInAllowlistExc),
('\n\n\t \x85\x1d\r\n\r \u2029\u2028 {"username": {"test": "test"}, "age": 15} \x1c\x1e\x85\n\n \t\n \u2029 ', InputDataTypeNotInAllowlistExc),
('\n\n\t \x85\x1d\r\n\r \u2029\u2028 [["username", {"test": "test"}], ["age", 15]] \x1c\x1e\x85\n\n \t\n \u2029 ', InputDataTypeNotInAllowlistExc),
('\n\n\t \x85\x1d\r\n\r \u2029\u2028 {"username": "john01", "age": 0} \x1c\x1e\x85\n\n \t\n \u2029 ', DataValidationFailedExc),
('\n\n\t \x85\x1d\r\n\r \u2029\u2028 [["username", "john01"], ["age", 0]] \x1c\x1e\x85\n\n \t\n \u2029 ', DataValidationFailedExc),
('\n\n\t \x85\x1d\r\n\r \u2029\u2028 {"username": "john01", "age": 12} \x1c\x1e\x85\n\n \t\n \u2029 ', DataValidationFailedExc),
('\n\n\t \x85\x1d\r\n\r \u2029\u2028 [["username", "john01"], ["age", 12]] \x1c\x1e\x85\n\n \t\n \u2029 ', DataValidationFailedExc),
('\n\n\t \x85\x1d\r\n\r \u2029\u2028 {"username": "john01", "age": 13} \x1c\x1e\x85\n\n \t\n \u2029 ', JSONTestObjectModel(username="john01", age=13)),
('\n\n\t \x85\x1d\r\n\r \u2029\u2028 [["username", "john01"], ["age", 13]] \x1c\x1e\x85\n\n \t\n \u2029 ', JSONTestObjectModel(username="john01", age=13)),
('\n\n\t \x85\x1d\r\n\r \u2029\u2028 {"username": "john01", "age": 50} \x1c\x1e\x85\n\n \t\n \u2029 ', JSONTestObjectModel(username="john01", age=50)),
('\n\n\t \x85\x1d\r\n\r \u2029\u2028 [["username", "john01"], ["age", 50]] \x1c\x1e\x85\n\n \t\n \u2029 ', JSONTestObjectModel(username="john01", age=50)),
('\n\n\t \x85\x1d\r\n\r \u2029\u2028 {"username": "john01", "age": 100} \x1c\x1e\x85\n\n \t\n \u2029 ', JSONTestObjectModel(username="john01", age=100)),
('\n\n\t \x85\x1d\r\n\r \u2029\u2028 [["username", "john01"], ["age", 100]] \x1c\x1e\x85\n\n \t\n \u2029 ', JSONTestObjectModel(username="john01", age=100)),
('\n\n\t \x85\x1d\r\n\r \u2029\u2028 {"username": "john01", "age": 101} \x1c\x1e\x85\n\n \t\n \u2029 ', DataValidationFailedExc),
('\n\n\t \x85\x1d\r\n\r \u2029\u2028 [["username", "john01"], ["age", 101]] \x1c\x1e\x85\n\n \t\n \u2029 ', DataValidationFailedExc),
('\n\n\t \x85\x1d\r\n\r \u2029\u2028 {"username": "john01", "age": 100000000} \x1c\x1e\x85\n\n \t\n \u2029 ', DataValidationFailedExc),
('\n\n\t \x85\x1d\r\n\r \u2029\u2028 [["username", "john01"], ["age", 100000000]] \x1c\x1e\x85\n\n \t\n \u2029 ', DataValidationFailedExc),
('\n\n\t \x85\x1d\r\n\r \u2029\u2028 {"username": "john01", "age": null} \x1c\x1e\x85\n\n \t\n \u2029 ', InputDataTypeNotInAllowlistExc),
('\n\n\t \x85\x1d\r\n\r \u2029\u2028 [["username", "john01"], ["age", null]] \x1c\x1e\x85\n\n \t\n \u2029 ', InputDataTypeNotInAllowlistExc),
('\n\n\t \x85\x1d\r\n\r \u2029\u2028 {"username": "john01", "age": true} \x1c\x1e\x85\n\n \t\n \u2029 ', DataValidationFailedExc), # For historic reasons, 'bool' is a subclass of 'int'.
('\n\n\t \x85\x1d\r\n\r \u2029\u2028 [["username", "john01"], ["age", true]] \x1c\x1e\x85\n\n \t\n \u2029 ', DataValidationFailedExc), # For historic reasons, 'bool' is a subclass of 'int'.
('\n\n\t \x85\x1d\r\n\r \u2029\u2028 {"username": "john01", "age": 20.0} \x1c\x1e\x85\n\n \t\n \u2029 ', InputDataTypeNotInAllowlistExc),
('\n\n\t \x85\x1d\r\n\r \u2029\u2028 [["username", "john01"], ["age", 20.0]] \x1c\x1e\x85\n\n \t\n \u2029 ', InputDataTypeNotInAllowlistExc),
('\n\n\t \x85\x1d\r\n\r \u2029\u2028 {"username": "john01", "age": 20.9} \x1c\x1e\x85\n\n \t\n \u2029 ', InputDataTypeNotInAllowlistExc),
('\n\n\t \x85\x1d\r\n\r \u2029\u2028 [["username", "john01"], ["age", 20.9]] \x1c\x1e\x85\n\n \t\n \u2029 ', InputDataTypeNotInAllowlistExc),
('\n\n\t \x85\x1d\r\n\r \u2029\u2028 {"username": "john01", "age": "hello"} \x1c\x1e\x85\n\n \t\n \u2029 ', InputDataTypeNotInAllowlistExc),
('\n\n\t \x85\x1d\r\n\r \u2029\u2028 [["username", "john01"], ["age", "hello"]] \x1c\x1e\x85\n\n \t\n \u2029 ', InputDataTypeNotInAllowlistExc),
('\n\n\t \x85\x1d\r\n\r \u2029\u2028 {"username": "john01", "age": "20"} \x1c\x1e\x85\n\n \t\n \u2029 ', InputDataTypeNotInAllowlistExc),
('\n\n\t \x85\x1d\r\n\r \u2029\u2028 [["username", "john01"], ["age", "20"]] \x1c\x1e\x85\n\n \t\n \u2029 ', InputDataTypeNotInAllowlistExc),
('\n\n\t \x85\x1d\r\n\r \u2029\u2028 {"username": "john01", "age": []} \x1c\x1e\x85\n\n \t\n \u2029 ', InputDataTypeNotInAllowlistExc),
('\n\n\t \x85\x1d\r\n\r \u2029\u2028 [["username", "john01"], ["age", []]] \x1c\x1e\x85\n\n \t\n \u2029 ', InputDataTypeNotInAllowlistExc),
('\n\n\t \x85\x1d\r\n\r \u2029\u2028 {"username": "john01", "age": [20]} \x1c\x1e\x85\n\n \t\n \u2029 ', InputDataTypeNotInAllowlistExc),
('\n\n\t \x85\x1d\r\n\r \u2029\u2028 [["username", "john01"], ["age", [20]]] \x1c\x1e\x85\n\n \t\n \u2029 ', InputDataTypeNotInAllowlistExc),
('\n\n\t \x85\x1d\r\n\r \u2029\u2028 {"username": "john01", "age": {}} \x1c\x1e\x85\n\n \t\n \u2029 ', InputDataTypeNotInAllowlistExc),
('\n\n\t \x85\x1d\r\n\r \u2029\u2028 [["username", "john01"], ["age", {}]] \x1c\x1e\x85\n\n \t\n \u2029 ', InputDataTypeNotInAllowlistExc),
('\n\n\t \x85\x1d\r\n\r \u2029\u2028 {"username": "john01", "age": {"20": 20}} \x1c\x1e\x85\n\n \t\n \u2029 ', InputDataTypeNotInAllowlistExc),
('\n\n\t \x85\x1d\r\n\r \u2029\u2028 [["username", "john01"], ["age", {"20": 20}]] \x1c\x1e\x85\n\n \t\n \u2029 ', InputDataTypeNotInAllowlistExc),
('\n\n\t \x85\x1d\r\n\r \u2029\u2028 {"username": "john01", "age": 15, "extra": "field"} \x1c\x1e\x85\n\n \t\n \u2029 ', InvalidInputDataExc),
('\n\n\t \x85\x1d\r\n\r \u2029\u2028 [["username", "john01"], ["age", 15], ["extra: "field"]] \x1c\x1e\x85\n\n \t\n \u2029 ', InvalidInputDataExc),
('\n\n\t \x85\x1d\r\n\r \u2029\u2028 [["username", "john01", "abc"], ["age", 15]] \x1c\x1e\x85\n\n \t\n \u2029 ', InputDataNotConvertibleExc),
('\n\n\t \x85\x1d\r\n\r \u2029\u2028 [["username", "john01"], ["age", 15, 16]] \x1c\x1e\x85\n\n \t\n \u2029 ', InputDataNotConvertibleExc),
('\n\n\t \x85\x1d\r\n\r \u2029\u2028 [["username"], ["age", 15]] \x1c\x1e\x85\n\n \t\n \u2029 ', InputDataNotConvertibleExc),
('\n\n\t \x85\x1d\r\n\r \u2029\u2028 [["username", "john01"], ["age"]] \x1c\x1e\x85\n\n \t\n \u2029 ', InputDataNotConvertibleExc),
('\n\n\t \x85\x1d\r\n\r \u2029\u2028 [["username", "john01"], [], ["age", 15]] \x1c\x1e\x85\n\n \t\n \u2029 ', InputDataNotConvertibleExc),
('\n\n\t \x85\x1d\r\n\r \u2029\u2028 [["username", "john01"], ["key"], ["age", 15]] \x1c\x1e\x85\n\n \t\n \u2029 ', InputDataNotConvertibleExc),
('\n\n\t \x85\x1d\r\n\r \u2029\u2028 [["username", "john01"], ["key", "value"], ["age", 15]] \x1c\x1e\x85\n\n \t\n \u2029 ', InvalidInputDataExc),
('\n\n\t \x85\x1d\r\n\r \u2029\u2028 [["username", "john01"], ["key", "value", "123"], ["age", 15]] \x1c\x1e\x85\n\n \t\n \u2029 ', InputDataNotConvertibleExc),
('\n\n\t \x85\x1d\r\n\r \u2029\u2028 {"username": "john01"} \x1c\x1e\x85\n\n \t\n \u2029 ', InvalidInputDataExc),
('\n\n\t \x85\x1d\r\n\r \u2029\u2028 [["username", "john01"]] \x1c\x1e\x85\n\n \t\n \u2029 ', InvalidInputDataExc),
('\n\n\t \x85\x1d\r\n\r \u2029\u2028 {"age": 15} \x1c\x1e\x85\n\n \t\n \u2029 ', InvalidInputDataExc),
('\n\n\t \x85\x1d\r\n\r \u2029\u2028 [["age", 15]] \x1c\x1e\x85\n\n \t\n \u2029 ', InvalidInputDataExc),
('\n\n\t \x85\x1d\r\n\r \u2029\u2028 {} \x1c\x1e\x85\n\n \t\n \u2029 ', InvalidInputDataExc),
('\n\n\t \x85\x1d\r\n\r \u2029\u2028 [] \x1c\x1e\x85\n\n \t\n \u2029 ', InvalidInputDataExc),
("", InvalidInputDataExc),
("hello", InvalidInputDataExc),
("he\x00llo", InvalidInputDataExc),
('"', InvalidInputDataExc),
('"""', InvalidInputDataExc),
(None, InputDataTypeNotInAllowlistExc),
([], InputDataTypeNotInAllowlistExc),
(str, InputDataTypeNotInAllowlistExc),
(object(), InputDataTypeNotInAllowlistExc),
(theoretical_testutils.EmptyObject(), InputDataTypeNotInAllowlistExc),
)),
)
@pytest.mark.parametrize(("blueprint", "input_", "output"), theoretical_testutils.test_function_parameter_generator(__JSON_BLUEPRINT_TEST_SUITE))
def test_json_blueprint(blueprint, input_, output):
theoretical_testutils.perform_test(blueprint, input_, output)
@pytest.mark.parametrize("wrapped_bp", (
StringBlueprint(bytes_encoding="windows-1250", datetime_string_format="%d.%m.%Y %H:%M:%S", parsing_mode=ParsingMode.MODE_RATIONAL),
IntegerBlueprint(parsing_mode=ParsingMode.MODE_STRICT),
BooleanBlueprint(parsing_mode=ParsingMode.MODE_LOOSE),
GenericBlueprint(),
))
def test_json_blueprint_wrapped_blueprint(wrapped_bp):
assert JSONBlueprint(wrapped_blueprint=wrapped_bp).get_wrapped_blueprint() is wrapped_bp
| 82.01107
| 270
| 0.581732
| 5,173
| 44,450
| 4.980476
| 0.06244
| 0.01801
| 0.026083
| 0.026083
| 0.776316
| 0.747632
| 0.73036
| 0.727139
| 0.70354
| 0.649744
| 0
| 0.111463
| 0.19811
| 44,450
| 541
| 271
| 82.162662
| 0.610958
| 0.04153
| 0
| 0.14902
| 0
| 0.262745
| 0.506377
| 0.017733
| 0
| 0
| 0
| 0
| 0.001961
| 1
| 0.003922
| false
| 0
| 0.04902
| 0
| 0.058824
| 0.064706
| 0
| 0
| 0
| null | 0
| 0
| 0
| 0
| 1
| 1
| 1
| 1
| 1
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 1
| 0
| 0
| null | 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
|
0
| 6
|
cadd82e7e0814515f2dd9f7294141195d102f1c8
| 29
|
py
|
Python
|
sentry_logger/__init__.py
|
gurayinan/sentry_logger
|
290e282fd6286b91f2d7bf41eea6c9cce13dc78e
|
[
"MIT"
] | null | null | null |
sentry_logger/__init__.py
|
gurayinan/sentry_logger
|
290e282fd6286b91f2d7bf41eea6c9cce13dc78e
|
[
"MIT"
] | null | null | null |
sentry_logger/__init__.py
|
gurayinan/sentry_logger
|
290e282fd6286b91f2d7bf41eea6c9cce13dc78e
|
[
"MIT"
] | null | null | null |
from .sentry_logger import *
| 14.5
| 28
| 0.793103
| 4
| 29
| 5.5
| 1
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0.137931
| 29
| 1
| 29
| 29
| 0.88
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 1
| 0
| true
| 0
| 1
| 0
| 1
| 0
| 1
| 1
| 0
| null | 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 1
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| null | 0
| 0
| 0
| 0
| 0
| 0
| 1
| 0
| 1
| 0
| 1
| 0
|
0
| 6
|
1b0df61f8db2d162e67c85961219a5e2234e264b
| 52
|
py
|
Python
|
trainer/__init__.py
|
LeiYangJustin/Map-in-a-Cycle
|
52acac7bf31c0d3781c7ee6ecc3accc4d618f8c1
|
[
"MIT"
] | 9
|
2020-09-15T06:36:50.000Z
|
2021-09-08T11:13:06.000Z
|
trainer/__init__.py
|
LeiYangJustin/Map-in-a-Cycle
|
52acac7bf31c0d3781c7ee6ecc3accc4d618f8c1
|
[
"MIT"
] | null | null | null |
trainer/__init__.py
|
LeiYangJustin/Map-in-a-Cycle
|
52acac7bf31c0d3781c7ee6ecc3accc4d618f8c1
|
[
"MIT"
] | 1
|
2021-09-02T22:46:46.000Z
|
2021-09-02T22:46:46.000Z
|
from .pc_trainer import *
from .seg_trainer import *
| 26
| 26
| 0.788462
| 8
| 52
| 4.875
| 0.625
| 0.666667
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0.134615
| 52
| 2
| 26
| 26
| 0.866667
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 1
| 0
| true
| 0
| 1
| 0
| 1
| 0
| 1
| 0
| 0
| null | 1
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 1
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| null | 0
| 0
| 0
| 0
| 0
| 0
| 1
| 0
| 1
| 0
| 1
| 0
|
0
| 6
|
1b3d419a00bc75c2d6fd14b8ff0d9fd0ad59dc79
| 9,462
|
py
|
Python
|
src/main/ht16k33/matrix.py
|
hanmy75/my_robot
|
c99ce98fda5a94a7c64ded6a3a6c347ae7acba16
|
[
"Apache-2.0"
] | null | null | null |
src/main/ht16k33/matrix.py
|
hanmy75/my_robot
|
c99ce98fda5a94a7c64ded6a3a6c347ae7acba16
|
[
"Apache-2.0"
] | null | null | null |
src/main/ht16k33/matrix.py
|
hanmy75/my_robot
|
c99ce98fda5a94a7c64ded6a3a6c347ae7acba16
|
[
"Apache-2.0"
] | null | null | null |
# The MIT License (MIT)
#
# Copyright (c) 2016 Radomir Dopieralski & Tony DiCola for Adafruit Industries
#
# 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.
"""
Matrix Displays
================
"""
from ht16k33.ht16k33 import HT16K33
__version__ = "0.0.0-auto.0"
__repo__ = "https://github.com/adafruit/Adafruit_CircuitPython_HT16K33.git"
# Font table 0x20 ~ 0x7f
FontTable = [
[0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00], #
[0x00, 0x00, 0x00, 0x1d, 0x00, 0x00, 0x00, 0x00], # !
[0x00, 0x00, 0x18, 0x00, 0x18, 0x00, 0x00, 0x00], # "
[0x00, 0x0a, 0x1f, 0x0a, 0x1f, 0x0a, 0x00, 0x00], # #
[0x00, 0x0e, 0x0a, 0x1f, 0x0a, 0x0b, 0x00, 0x00], # $
[0x00, 0x11, 0x02, 0x04, 0x08, 0x11, 0x00, 0x00], # %
[0x00, 0x0a, 0x15, 0x15, 0x02, 0x05, 0x00, 0x00], # &
[0x00, 0x18, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00], # '
[0x00, 0x00, 0x0e, 0x11, 0x00, 0x00, 0x00, 0x00], # (
[0x00, 0x00, 0x11, 0x0e, 0x00, 0x00, 0x00, 0x00], # )
[0x00, 0x00, 0x04, 0x0e, 0x04, 0x00, 0x00, 0x00], # *
[0x00, 0x04, 0x04, 0x1f, 0x04, 0x04, 0x00, 0x00], # +
[0x00, 0x00, 0x01, 0x06, 0x00, 0x00, 0x00, 0x00], # ,
[0x00, 0x04, 0x04, 0x04, 0x04, 0x04, 0x00, 0x00], # -
[0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00], # .
[0x00, 0x00, 0x03, 0x04, 0x18, 0x00, 0x00, 0x00], # /
[0x00, 0x1f, 0x13, 0x15, 0x19, 0x1f, 0x00, 0x00], # 0
[0x00, 0x09, 0x1f, 0x01, 0x00, 0x00, 0x00, 0x00], # 1
[0x00, 0x13, 0x15, 0x15, 0x15, 0x09, 0x00, 0x00], # 2
[0x00, 0x11, 0x15, 0x15, 0x15, 0x1b, 0x00, 0x00], # 3
[0x00, 0x1e, 0x02, 0x07, 0x02, 0x02, 0x00, 0x00], # 4
[0x00, 0x1d, 0x15, 0x15, 0x15, 0x12, 0x00, 0x00], # 5
[0x00, 0x1f, 0x15, 0x15, 0x15, 0x17, 0x00, 0x00], # 6
[0x00, 0x10, 0x10, 0x13, 0x14, 0x18, 0x00, 0x00], # 7
[0x00, 0x1f, 0x15, 0x15, 0x15, 0x1f, 0x00, 0x00], # 8
[0x00, 0x1d, 0x15, 0x15, 0x15, 0x1f, 0x00, 0x00], # 9
[0x00, 0x00, 0x00, 0x1b, 0x00, 0x00, 0x00, 0x00], # :
[0x00, 0x00, 0x00, 0x13, 0x00, 0x00, 0x00, 0x00], # ;
[0x00, 0x00, 0x04, 0x0a, 0x11, 0x00, 0x00, 0x00], # <
[0x00, 0x0a, 0x0a, 0x0a, 0x0a, 0x0a, 0x00, 0x00], # =
[0x00, 0x00, 0x11, 0x0a, 0x04, 0x00, 0x00, 0x00], # >
[0x00, 0x08, 0x10, 0x15, 0x08, 0x00, 0x00, 0x00], # ?
[0x00, 0x1f, 0x11, 0x15, 0x15, 0x1d, 0x00, 0x00], # @
[0x00, 0x1f, 0x12, 0x12, 0x12, 0x1f, 0x00, 0x00], # A
[0x00, 0x1f, 0x15, 0x15, 0x15, 0x1b, 0x00, 0x00], # B
[0x00, 0x1f, 0x11, 0x11, 0x11, 0x11, 0x00, 0x00], # C
[0x00, 0x1f, 0x11, 0x11, 0x11, 0x0e, 0x00, 0x00], # D
[0x00, 0x1f, 0x15, 0x15, 0x15, 0x11, 0x00, 0x00], # E
[0x00, 0x1f, 0x14, 0x14, 0x14, 0x10, 0x00, 0x00], # F
[0x00, 0x1f, 0x11, 0x11, 0x15, 0x17, 0x00, 0x00], # G
[0x00, 0x1f, 0x04, 0x04, 0x04, 0x1f, 0x00, 0x00], # H
[0x00, 0x11, 0x11, 0x1f, 0x11, 0x11, 0x00, 0x00], # I
[0x00, 0x03, 0x01, 0x01, 0x11, 0x1f, 0x00, 0x00], # J
[0x00, 0x1f, 0x04, 0x04, 0x0a, 0x11, 0x00, 0x00], # K
[0x00, 0x1f, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00], # L
[0x00, 0x1f, 0x08, 0x04, 0x08, 0x1f, 0x00, 0x00], # M
[0x00, 0x1f, 0x08, 0x04, 0x02, 0x1f, 0x00, 0x00], # N
[0x00, 0x0e, 0x11, 0x11, 0x11, 0x0e, 0x00, 0x00], # O
[0x00, 0x1f, 0x14, 0x14, 0x14, 0x08, 0x00, 0x00], # P
[0x00, 0x1e, 0x12, 0x13, 0x12, 0x1e, 0x00, 0x00], # Q
[0x00, 0x1f, 0x14, 0x14, 0x14, 0x0b, 0x00, 0x00], # R
[0x00, 0x1d, 0x15, 0x15, 0x15, 0x17, 0x00, 0x00], # S
[0x00, 0x10, 0x10, 0x1f, 0x10, 0x10, 0x00, 0x00], # T
[0x00, 0x1f, 0x01, 0x01, 0x01, 0x1f, 0x00, 0x00], # U
[0x00, 0x18, 0x06, 0x01, 0x06, 0x18, 0x00, 0x00], # V
[0x00, 0x1e, 0x01, 0x06, 0x01, 0x1e, 0x00, 0x00], # W
[0x00, 0x11, 0x0a, 0x04, 0x0a, 0x11, 0x00, 0x00], # X
[0x00, 0x18, 0x04, 0x03, 0x04, 0x18, 0x00, 0x00], # Y
[0x00, 0x11, 0x13, 0x15, 0x19, 0x11, 0x00, 0x00], # Z
[0x00, 0x00, 0x1f, 0x11, 0x11, 0x00, 0x00, 0x00], # [
[0x00, 0x00, 0x18, 0x04, 0x03, 0x00, 0x00, 0x00], # \
[0x00, 0x11, 0x1f, 0x00, 0x00, 0x00, 0x00, 0x00], # ]
[0x00, 0x00, 0x08, 0x10, 0x08, 0x00, 0x00, 0x00], # ^
[0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x00], # _
[0x00, 0x10, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00], # `
[0x00, 0x1f, 0x12, 0x12, 0x12, 0x1f, 0x00, 0x00], # a
[0x00, 0x1f, 0x15, 0x15, 0x15, 0x1b, 0x00, 0x00], # b
[0x00, 0x1f, 0x11, 0x11, 0x11, 0x11, 0x00, 0x00], # c
[0x00, 0x1f, 0x11, 0x11, 0x11, 0x0e, 0x00, 0x00], # d
[0x00, 0x1f, 0x15, 0x15, 0x15, 0x11, 0x00, 0x00], # e
[0x00, 0x1f, 0x14, 0x14, 0x14, 0x10, 0x00, 0x00], # f
[0x00, 0x1f, 0x11, 0x11, 0x15, 0x17, 0x00, 0x00], # g
[0x00, 0x1f, 0x04, 0x04, 0x04, 0x1f, 0x00, 0x00], # h
[0x00, 0x11, 0x11, 0x1f, 0x11, 0x11, 0x00, 0x00], # i
[0x00, 0x03, 0x01, 0x01, 0x11, 0x1f, 0x00, 0x00], # j
[0x00, 0x1f, 0x04, 0x04, 0x0a, 0x11, 0x00, 0x00], # k
[0x00, 0x1f, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00], # l
[0x00, 0x1f, 0x08, 0x04, 0x08, 0x1f, 0x00, 0x00], # m
[0x00, 0x1f, 0x08, 0x04, 0x02, 0x1f, 0x00, 0x00], # n
[0x00, 0x0e, 0x11, 0x11, 0x11, 0x0e, 0x00, 0x00], # o
[0x00, 0x1f, 0x14, 0x14, 0x14, 0x08, 0x00, 0x00], # p
[0x00, 0x1e, 0x12, 0x13, 0x12, 0x1e, 0x00, 0x00], # q
[0x00, 0x1f, 0x14, 0x14, 0x14, 0x0b, 0x00, 0x00], # r
[0x00, 0x1d, 0x15, 0x15, 0x15, 0x17, 0x00, 0x00], # s
[0x00, 0x10, 0x10, 0x1f, 0x10, 0x10, 0x00, 0x00], # t
[0x00, 0x1f, 0x01, 0x01, 0x01, 0x1f, 0x00, 0x00], # u
[0x00, 0x18, 0x06, 0x01, 0x06, 0x18, 0x00, 0x00], # v
[0x00, 0x1e, 0x01, 0x06, 0x01, 0x1e, 0x00, 0x00], # w
[0x00, 0x11, 0x0a, 0x04, 0x0a, 0x11, 0x00, 0x00], # x
[0x00, 0x18, 0x04, 0x03, 0x04, 0x18, 0x00, 0x00], # y
[0x00, 0x11, 0x13, 0x15, 0x19, 0x11, 0x00, 0x00], # z
[0x00, 0x00, 0x04, 0x1f, 0x11, 0x00, 0x00, 0x00], # {
[0x00, 0x00, 0x00, 0x1b, 0x00, 0x00, 0x00, 0x00], # |
[0x00, 0x00, 0x11, 0x1f, 0x04, 0x00, 0x00, 0x00], # }
[0x00, 0x04, 0x08, 0x04, 0x08, 0x00, 0x00, 0x00], # ~
[0x00, 0x00, 0x00, 0x07, 0x00, 0x00, 0x00, 0x00], #
]
def getFontData(char):
value = ord(char)
if not 0x20 <= value <= 0x7f:
return None
return FontTable[value-0x20]
class Matrix16x8(HT16K33):
"""A double matrix or the matrix wing."""
def pixel(self, x, y, color=None):
"""Get or set the color of a given pixel."""
if not 0 <= x <= 15:
return None
if not 0 <= y <= 7:
return None
if x >= 8:
x -= 8
y += 8
return super()._pixel(y, x, color)
def __getitem__(self, key):
x, y = key
return self.pixel(x, y)
def __setitem__(self, key, value):
x, y = key
self.pixel(x, y, value)
def putChar(self, left, right):
total_buff = bytearray(16)
left_buff = getFontData(left)
right_buff = getFontData(right)
for i in range(0, 8):
total_buff[i*2] = right_buff[i]
total_buff[i*2+1] = left_buff[i]
self.set_buffer(total_buff)
class Matrix8x8(HT16K33):
"""A single matrix."""
def pixel(self, x, y, color=None):
"""Get or set the color of a given pixel."""
if not 0 <= x <= 7:
return None
if not 0 <= y <= 7:
return None
x = (x - 1) % 8
return super()._pixel(x, y, color)
def __getitem__(self, key):
x, y = key
return self.pixel(x, y)
def __setitem__(self, key, value):
x, y = key
self.pixel(x, y, value)
class Matrix8x8x2(HT16K33):
"""A bi-color matrix."""
def pixel(self, x, y, color=None):
"""Get or set the color of a given pixel."""
if not 0 <= x <= 7:
return None
if not 0 <= y <= 7:
return None
if color is not None:
super()._pixel(y, x, (color & 0x01))
super()._pixel(y + 8, x, (color >> 1) & 0x01)
else:
return super()._pixel(y, x) | super()._pixel(y + 8, x) << 1
return None
def __getitem__(self, key):
x, y = key
return self.pixel(x, y)
def __setitem__(self, key, value):
x, y = key
self.pixel(x, y, value)
def fill(self, color):
"""Fill the whole display with the given color."""
fill1 = 0xff if color & 0x01 else 0x00
fill2 = 0xff if color & 0x02 else 0x00
for i in range(8):
self._set_buffer(i * 2, fill1)
self._set_buffer(i * 2 + 1, fill2)
if self._auto_write:
self.show()
| 42.241071
| 80
| 0.577891
| 1,388
| 9,462
| 3.899135
| 0.160663
| 0.295639
| 0.223947
| 0.195122
| 0.627125
| 0.565595
| 0.485772
| 0.451774
| 0.445861
| 0.445861
| 0
| 0.331661
| 0.262629
| 9,462
| 223
| 81
| 42.430493
| 0.44403
| 0.168992
| 0
| 0.517647
| 0
| 0
| 0.009609
| 0
| 0
| 0
| 0.404623
| 0
| 0
| 1
| 0.070588
| false
| 0
| 0.005882
| 0
| 0.182353
| 0
| 0
| 0
| 0
| null | 1
| 1
| 1
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 1
| 0
| 0
| 0
| 0
| 0
| 1
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| null | 0
| 1
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
|
0
| 6
|
1b4726b1cca797af918c3eac9e909272a40a3b34
| 23
|
py
|
Python
|
gdn-master/lib/psa/modules/__init__.py
|
ldrunning/segmentation
|
d787ea12a87968c0308c1fb8be6685036b852b5e
|
[
"MIT"
] | 1,137
|
2018-09-06T19:13:07.000Z
|
2022-03-28T09:42:08.000Z
|
lib/psa/modules/__init__.py
|
cj-mclaughlin/semseg
|
b103cf7747114812239b733338121c78ba4aab76
|
[
"MIT"
] | 80
|
2019-06-03T16:37:09.000Z
|
2022-03-29T01:19:36.000Z
|
lib/psa/modules/__init__.py
|
cj-mclaughlin/semseg
|
b103cf7747114812239b733338121c78ba4aab76
|
[
"MIT"
] | 241
|
2019-05-29T13:09:14.000Z
|
2022-03-23T11:40:13.000Z
|
from .psamask import *
| 11.5
| 22
| 0.73913
| 3
| 23
| 5.666667
| 1
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0.173913
| 23
| 1
| 23
| 23
| 0.894737
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 1
| 0
| true
| 0
| 1
| 0
| 1
| 0
| 1
| 1
| 0
| null | 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 1
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| null | 0
| 0
| 0
| 0
| 0
| 0
| 1
| 0
| 1
| 0
| 1
| 0
|
0
| 6
|
1b4bcbab8dcc4e2f48f4a54ce588cf96ac80c761
| 38
|
py
|
Python
|
src/stk/molecular/topology_graphs/topology_graph/topology_graph/__init__.py
|
stevenbennett96/stk
|
6e5af87625b83e0bfc7243bc42d8c7a860cbeb76
|
[
"MIT"
] | 21
|
2018-04-12T16:25:24.000Z
|
2022-02-14T23:05:43.000Z
|
src/stk/molecular/topology_graphs/topology_graph/topology_graph/__init__.py
|
stevenbennett96/stk
|
6e5af87625b83e0bfc7243bc42d8c7a860cbeb76
|
[
"MIT"
] | 8
|
2019-03-19T12:36:36.000Z
|
2020-11-11T12:46:00.000Z
|
src/stk/molecular/topology_graphs/topology_graph/topology_graph/__init__.py
|
stevenbennett96/stk
|
6e5af87625b83e0bfc7243bc42d8c7a860cbeb76
|
[
"MIT"
] | 5
|
2018-08-07T13:00:16.000Z
|
2021-11-01T00:55:10.000Z
|
from .topology_graph import * # noqa
| 19
| 37
| 0.736842
| 5
| 38
| 5.4
| 1
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0.184211
| 38
| 1
| 38
| 38
| 0.870968
| 0.105263
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 1
| 0
| true
| 0
| 1
| 0
| 1
| 0
| 1
| 1
| 0
| null | 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 1
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| null | 0
| 0
| 0
| 0
| 0
| 0
| 1
| 0
| 1
| 0
| 1
| 0
|
0
| 6
|
1b500d64e9dacc60870c0894f83e70b65ce4b078
| 4,567
|
py
|
Python
|
tests/test_types.py
|
comic31/MongoDBQueriesManager
|
34d2a0bd73777dc12ee860bbd8929254bed48791
|
[
"MIT"
] | 2
|
2021-04-29T12:05:36.000Z
|
2021-07-15T08:42:40.000Z
|
tests/test_types.py
|
comic31/MongoDBQueriesManager
|
34d2a0bd73777dc12ee860bbd8929254bed48791
|
[
"MIT"
] | null | null | null |
tests/test_types.py
|
comic31/MongoDBQueriesManager
|
34d2a0bd73777dc12ee860bbd8929254bed48791
|
[
"MIT"
] | null | null | null |
#!/usr/bin/env python3
# coding: utf-8
# Copyright (c) Modos Team, 2020
import re
from datetime import datetime, timezone
from mongo_queries_manager import mqm
class TestTypes:
# Type string tests part
def test_type_string(self):
query_result = mqm(string_query="name=toto")
assert query_result == {'filter': {"name": 'toto'}, 'sort': None,
'skip': 0, 'limit': 0, 'projection': None}
# Type integer tests part
def test_type_integer(self):
query_result = mqm(string_query="price=5")
assert query_result == {'filter': {"price": 5}, 'sort': None,
'skip': 0, 'limit': 0, 'projection': None}
def test_type_negative_integer(self):
query_result = mqm(string_query="price=-5")
assert query_result == {'filter': {"price": -5}, 'sort': None,
'skip': 0, 'limit': 0, 'projection': None}
# Type float tests part
def test_type_float(self):
query_result = mqm(string_query="price=5.5")
assert query_result == {'filter': {"price": 5.5}, 'sort': None,
'skip': 0, 'limit': 0, 'projection': None}
def test_type_negative_float(self):
query_result = mqm(string_query="price=-5.5")
assert query_result == {'filter': {"price": -5.5}, 'sort': None,
'skip': 0, 'limit': 0, 'projection': None}
# Type datetime tests part
def test_type_datetime_format_1(self):
query_result = mqm(string_query="created_at=2016-01-01")
assert query_result == {'filter': {"created_at": datetime(year=2016, month=1, day=1)},
'sort': None, 'skip': 0, 'limit': 0, 'projection': None}
def test_type_datetime_format_2(self):
query_result = mqm(string_query="created_at=2016-01-01T00:00:00.000000+00:00")
assert query_result == {'filter': {"created_at": datetime(year=2016, month=1, day=1, tzinfo=timezone.utc)},
'sort': None, 'skip': 0, 'limit': 0, 'projection': None}
# Type list tests part
def test_type_list(self):
query_result = mqm(string_query="country=US,RU")
assert query_result == {'filter': {"country": {"$in": ['US', 'RU']}}, 'sort': None,
'skip': 0, 'limit': 0, 'projection': None}
# Type regex tests part
def test_type_regex(self):
query_result = mqm(string_query="email=/@gmail\\.com$/i")
assert query_result == {'filter': {"email": re.compile(r'/@gmail\.com$/i')}, 'sort': None,
'skip': 0, 'limit': 0, 'projection': None}
# Type boolean tests part
def test_type_boolean_true(self):
query_result = mqm(string_query="active=true")
assert query_result == {'filter': {"active": True}, 'sort': None, 'skip': 0, 'limit': 0,
'projection': None}
query_result = mqm(string_query="active=True")
assert query_result == {'filter': {"active": True}, 'sort': None, 'skip': 0, 'limit': 0,
'projection': None}
def test_type_boolean_false(self):
query_result = mqm(string_query="active!=false")
assert query_result == {'filter': {"active": {'$ne': False}}, 'sort': None,
'skip': 0, 'limit': 0, 'projection': None}
query_result = mqm(string_query="active!=False")
assert query_result == {'filter': {"active": {'$ne': False}}, 'sort': None,
'skip': 0, 'limit': 0, 'projection': None}
# Type null tests part
def test_type_null(self):
query_result = mqm(string_query="active!=null")
assert query_result == {'filter': {"active": {'$ne': None}}, 'sort': None,
'skip': 0, 'limit': 0, 'projection': None}
query_result = mqm(string_query="active!=Null")
assert query_result == {'filter': {"active": {'$ne': None}}, 'sort': None,
'skip': 0, 'limit': 0, 'projection': None}
query_result = mqm(string_query="active!=none")
assert query_result == {'filter': {"active": {'$ne': None}}, 'sort': None,
'skip': 0, 'limit': 0, 'projection': None}
query_result = mqm(string_query="active!=None")
assert query_result == {'filter': {"active": {'$ne': None}}, 'sort': None,
'skip': 0, 'limit': 0, 'projection': None}
| 42.287037
| 115
| 0.544997
| 532
| 4,567
| 4.511278
| 0.150376
| 0.155833
| 0.099167
| 0.141667
| 0.826667
| 0.748333
| 0.712083
| 0.707083
| 0.707083
| 0.64375
| 0
| 0.030135
| 0.287935
| 4,567
| 107
| 116
| 42.682243
| 0.707872
| 0.054303
| 0
| 0.373134
| 0
| 0
| 0.204039
| 0.019963
| 0
| 0
| 0
| 0
| 0.253731
| 1
| 0.179104
| false
| 0
| 0.044776
| 0
| 0.238806
| 0
| 0
| 0
| 0
| null | 0
| 0
| 0
| 1
| 1
| 1
| 1
| 1
| 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
| 6
|
1b5f2636fdfff520dcc830e083cd7f72333aeeb6
| 39
|
py
|
Python
|
quake/server/__init__.py
|
It4innovations/quake
|
a57f37e5c871e0c7c00b84aef638b925ef96690a
|
[
"MIT"
] | 1
|
2021-03-26T14:23:44.000Z
|
2021-03-26T14:23:44.000Z
|
quake/server/__init__.py
|
It4innovations/quake
|
a57f37e5c871e0c7c00b84aef638b925ef96690a
|
[
"MIT"
] | null | null | null |
quake/server/__init__.py
|
It4innovations/quake
|
a57f37e5c871e0c7c00b84aef638b925ef96690a
|
[
"MIT"
] | null | null | null |
from quake.server.worker import Worker
| 19.5
| 38
| 0.846154
| 6
| 39
| 5.5
| 0.833333
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0.102564
| 39
| 1
| 39
| 39
| 0.942857
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 1
| 0
| true
| 0
| 1
| 0
| 1
| 0
| 1
| 1
| 0
| null | 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 1
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| null | 0
| 0
| 0
| 0
| 0
| 0
| 1
| 0
| 1
| 0
| 1
| 0
|
0
| 6
|
1b9ccc881cad7b718f0df4e260029d1abab109c7
| 61
|
py
|
Python
|
toy_environment/relation_system.py
|
lobachevzky/hsr
|
b8c40b82c0d39fedc8f64cb50734620a0b2d84ab
|
[
"MIT"
] | 1
|
2021-03-29T16:42:01.000Z
|
2021-03-29T16:42:01.000Z
|
toy_environment/relation_system.py
|
ethanabrooks/hsr
|
b8c40b82c0d39fedc8f64cb50734620a0b2d84ab
|
[
"MIT"
] | 2
|
2018-02-02T20:47:03.000Z
|
2018-05-22T21:10:29.000Z
|
toy_environment/relation_system.py
|
lobachevzky/hsr
|
b8c40b82c0d39fedc8f64cb50734620a0b2d84ab
|
[
"MIT"
] | null | null | null |
import numpy as np
class RelationManager(object):
pass
| 10.166667
| 30
| 0.737705
| 8
| 61
| 5.625
| 1
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0.213115
| 61
| 5
| 31
| 12.2
| 0.9375
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 1
| 0
| true
| 0.333333
| 0.333333
| 0
| 0.666667
| 0
| 1
| 0
| 0
| null | 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 1
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| null | 0
| 0
| 0
| 0
| 0
| 0
| 1
| 1
| 1
| 0
| 1
| 0
|
0
| 6
|
1bc6d6fc6e50d20d2664f6d7cb6f3a13389de5c8
| 38
|
py
|
Python
|
nanocamera/__init__.py
|
psomers3/NanoCamera
|
1ee0657a22cad705aa502a6b8c95a63a700d6500
|
[
"MIT"
] | 74
|
2020-06-01T08:03:22.000Z
|
2022-03-23T17:47:31.000Z
|
nanocamera/__init__.py
|
psomers3/NanoCamera
|
1ee0657a22cad705aa502a6b8c95a63a700d6500
|
[
"MIT"
] | 9
|
2020-01-30T06:06:08.000Z
|
2021-09-24T14:25:35.000Z
|
nanocamera/__init__.py
|
psomers3/NanoCamera
|
1ee0657a22cad705aa502a6b8c95a63a700d6500
|
[
"MIT"
] | 15
|
2020-02-25T15:58:58.000Z
|
2022-03-27T15:12:25.000Z
|
from nanocamera.NanoCam import Camera
| 19
| 37
| 0.868421
| 5
| 38
| 6.6
| 1
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0.105263
| 38
| 1
| 38
| 38
| 0.970588
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 1
| 0
| true
| 0
| 1
| 0
| 1
| 0
| 1
| 1
| 0
| null | 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 1
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| null | 0
| 0
| 0
| 0
| 0
| 0
| 1
| 0
| 1
| 0
| 1
| 0
|
0
| 6
|
59fb5879afd513ed60b5482a655d184019f0bb04
| 33
|
py
|
Python
|
oculus_reader/__init__.py
|
rail-berkeley/oculus_reader
|
de73f3d259b3c41c4564f70a64682e24aa3ac31c
|
[
"Apache-2.0"
] | 9
|
2021-02-14T09:06:12.000Z
|
2022-02-19T08:52:11.000Z
|
oculus_reader/__init__.py
|
rail-berkeley/oculus_reader
|
de73f3d259b3c41c4564f70a64682e24aa3ac31c
|
[
"Apache-2.0"
] | null | null | null |
oculus_reader/__init__.py
|
rail-berkeley/oculus_reader
|
de73f3d259b3c41c4564f70a64682e24aa3ac31c
|
[
"Apache-2.0"
] | 1
|
2022-03-13T03:44:04.000Z
|
2022-03-13T03:44:04.000Z
|
from .reader import OculusReader
| 16.5
| 32
| 0.848485
| 4
| 33
| 7
| 1
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0.121212
| 33
| 1
| 33
| 33
| 0.965517
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 1
| 0
| true
| 0
| 1
| 0
| 1
| 0
| 1
| 1
| 0
| null | 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 1
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| null | 0
| 0
| 0
| 0
| 0
| 0
| 1
| 0
| 1
| 0
| 1
| 0
|
0
| 6
|
942b1aafb12681c68c1f71dc2a5f16e24a29e696
| 32
|
py
|
Python
|
backend/flask/app/apis/__init__.py
|
yf-dev/open-dccon-selector
|
56d4f54bc73e9b33cc568f0101da919fd13ed697
|
[
"MIT"
] | 2
|
2021-05-10T07:04:21.000Z
|
2021-05-17T08:53:49.000Z
|
backend/flask/app/apis/__init__.py
|
yf-dev/open-dccon-selector
|
56d4f54bc73e9b33cc568f0101da919fd13ed697
|
[
"MIT"
] | 8
|
2020-05-12T02:17:57.000Z
|
2022-02-17T23:36:18.000Z
|
backend/flask/app/apis/__init__.py
|
yf-dev/open-dccon-selector
|
56d4f54bc73e9b33cc568f0101da919fd13ed697
|
[
"MIT"
] | 1
|
2021-07-01T09:23:17.000Z
|
2021-07-01T09:23:17.000Z
|
from . import exports, channels
| 16
| 31
| 0.78125
| 4
| 32
| 6.25
| 1
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0.15625
| 32
| 1
| 32
| 32
| 0.925926
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 1
| 0
| true
| 0
| 1
| 0
| 1
| 0
| 1
| 1
| 0
| null | 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 1
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| null | 0
| 0
| 0
| 0
| 0
| 0
| 1
| 0
| 1
| 0
| 1
| 0
|
0
| 6
|
942e7abaf82b741179aebefb3799f23be31f936b
| 5,250
|
py
|
Python
|
tests/test_create_token.py
|
jsenecal/async-fastapi-jwt-auth
|
dd825f51a2e93192d4128c85b0d4a73df1a9c418
|
[
"MIT"
] | 4
|
2022-02-04T08:06:32.000Z
|
2022-03-25T23:22:07.000Z
|
tests/test_create_token.py
|
jsenecal/async-fastapi-jwt-auth
|
dd825f51a2e93192d4128c85b0d4a73df1a9c418
|
[
"MIT"
] | null | null | null |
tests/test_create_token.py
|
jsenecal/async-fastapi-jwt-auth
|
dd825f51a2e93192d4128c85b0d4a73df1a9c418
|
[
"MIT"
] | 1
|
2022-02-16T16:26:27.000Z
|
2022-02-16T16:26:27.000Z
|
import pytest, jwt
from async_fastapi_jwt_auth import AuthJWT
from pydantic import BaseSettings
from datetime import timedelta, datetime, timezone
async def test_create_access_token(Authorize):
class Settings(BaseSettings):
AUTHJWT_SECRET_KEY: str = "testing"
AUTHJWT_ACCESS_TOKEN_EXPIRES: int = 2
AUTHJWT_REFRESH_TOKEN_EXPIRES: int = 4
@AuthJWT.load_config
def get_settings():
return Settings()
with pytest.raises(TypeError, match=r"missing 1 required positional argument"):
await Authorize.create_access_token()
with pytest.raises(TypeError, match=r"subject"):
await Authorize.create_access_token(subject=0.123)
with pytest.raises(TypeError, match=r"fresh"):
await Authorize.create_access_token(subject="test", fresh="lol")
with pytest.raises(ValueError, match=r"dictionary update sequence element"):
await Authorize.create_access_token(subject=1, headers="test")
async def test_create_refresh_token(Authorize):
with pytest.raises(TypeError, match=r"missing 1 required positional argument"):
await Authorize.create_refresh_token()
with pytest.raises(TypeError, match=r"subject"):
await Authorize.create_refresh_token(subject=0.123)
with pytest.raises(ValueError, match=r"dictionary update sequence element"):
await Authorize.create_refresh_token(subject=1, headers="test")
async def test_create_dynamic_access_token_expires(Authorize):
expires_time = int(datetime.now(timezone.utc).timestamp()) + 90
token = await Authorize.create_access_token(subject=1, expires_time=90)
assert jwt.decode(token, "testing", algorithms="HS256")['exp'] == expires_time
expires_time = int(datetime.now(timezone.utc).timestamp()) + 86400
token = await Authorize.create_access_token(subject=1, expires_time=timedelta(days=1))
assert jwt.decode(token, "testing", algorithms="HS256")['exp'] == expires_time
expires_time = int(datetime.now(timezone.utc).timestamp()) + 2
token = await Authorize.create_access_token(subject=1, expires_time=True)
assert jwt.decode(token, "testing", algorithms="HS256")['exp'] == expires_time
token = await Authorize.create_access_token(subject=1, expires_time=False)
assert 'exp' not in jwt.decode(token, "testing", algorithms="HS256")
with pytest.raises(TypeError, match=r"expires_time"):
await Authorize.create_access_token(subject=1, expires_time="test")
async def test_create_dynamic_refresh_token_expires(Authorize):
expires_time = int(datetime.now(timezone.utc).timestamp()) + 90
token = await Authorize.create_refresh_token(subject=1, expires_time=90)
assert jwt.decode(token, "testing", algorithms="HS256")['exp'] == expires_time
expires_time = int(datetime.now(timezone.utc).timestamp()) + 86400
token = await Authorize.create_refresh_token(subject=1, expires_time=timedelta(days=1))
assert jwt.decode(token, "testing", algorithms="HS256")['exp'] == expires_time
expires_time = int(datetime.now(timezone.utc).timestamp()) + 4
token = await Authorize.create_refresh_token(subject=1, expires_time=True)
assert jwt.decode(token, "testing", algorithms="HS256")['exp'] == expires_time
token = await Authorize.create_refresh_token(subject=1, expires_time=False)
assert 'exp' not in jwt.decode(token, "testing", algorithms="HS256")
with pytest.raises(TypeError, match=r"expires_time"):
await Authorize.create_refresh_token(subject=1, expires_time="test")
async def test_create_token_invalid_type_data_audience(Authorize):
with pytest.raises(TypeError, match=r"audience"):
await Authorize.create_access_token(subject=1, audience=1)
with pytest.raises(TypeError, match=r"audience"):
await Authorize.create_refresh_token(subject=1, audience=1)
async def test_create_token_invalid_algorithm(Authorize):
with pytest.raises(ValueError, match=r"Algorithm"):
await Authorize.create_access_token(subject=1, algorithm="test")
with pytest.raises(ValueError, match=r"Algorithm"):
await Authorize.create_refresh_token(subject=1, algorithm="test")
async def test_create_token_invalid_type_data_algorithm(Authorize):
with pytest.raises(TypeError, match=r"algorithm"):
await Authorize.create_access_token(subject=1, algorithm=1)
with pytest.raises(TypeError, match=r"algorithm"):
await Authorize.create_refresh_token(subject=1, algorithm=1)
async def test_create_token_invalid_user_claims(Authorize):
with pytest.raises(TypeError, match=r"user_claims"):
await Authorize.create_access_token(subject=1, user_claims="asd")
with pytest.raises(TypeError, match=r"user_claims"):
await Authorize.create_refresh_token(subject=1, user_claims="asd")
async def test_create_valid_user_claims(Authorize):
access_token = await Authorize.create_access_token(subject=1, user_claims={"my_access": "yeah"})
refresh_token = await Authorize.create_refresh_token(subject=1, user_claims={"my_refresh": "hello"})
assert jwt.decode(access_token, "testing", algorithms="HS256")['my_access'] == "yeah"
assert jwt.decode(refresh_token, "testing", algorithms="HS256")['my_refresh'] == "hello"
| 44.491525
| 104
| 0.748952
| 685
| 5,250
| 5.527007
| 0.124088
| 0.099842
| 0.142631
| 0.096144
| 0.862388
| 0.83122
| 0.807448
| 0.754622
| 0.751981
| 0.668251
| 0
| 0.019815
| 0.134857
| 5,250
| 117
| 105
| 44.871795
| 0.813738
| 0
| 0
| 0.35
| 0
| 0
| 0.09619
| 0
| 0
| 0
| 0
| 0
| 0.125
| 1
| 0.0125
| false
| 0
| 0.05
| 0.0125
| 0.125
| 0
| 0
| 0
| 0
| null | 0
| 0
| 0
| 1
| 1
| 1
| 1
| 1
| 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
| 6
|
944f47284e308f79615c9f5e0bdcfdb714cf33ff
| 481
|
py
|
Python
|
core/views.py
|
pauloupgrad/sistema-django
|
f1a7fc9f5602ec6eb1e3a777897ff94ee4b2e1ff
|
[
"MIT"
] | null | null | null |
core/views.py
|
pauloupgrad/sistema-django
|
f1a7fc9f5602ec6eb1e3a777897ff94ee4b2e1ff
|
[
"MIT"
] | null | null | null |
core/views.py
|
pauloupgrad/sistema-django
|
f1a7fc9f5602ec6eb1e3a777897ff94ee4b2e1ff
|
[
"MIT"
] | null | null | null |
from django.shortcuts import render
def login(request):
return render(request,'core/login.html')
def base(request):
return render(request,'core/base.html')
def perfil(request):
return render(request,'core/perfil.html')
def lista_user(request):
return render(request, 'core/lista-usuarios.html')
def cadastrar_user(request):
return render(request, 'core/cadastrar-usuarios.html')
def atualizar_perfil(request):
return render(request, 'core/atualizar-perfil.html')
| 25.315789
| 55
| 0.765073
| 65
| 481
| 5.615385
| 0.276923
| 0.213699
| 0.312329
| 0.427397
| 0.547945
| 0.383562
| 0
| 0
| 0
| 0
| 0
| 0
| 0.101871
| 481
| 19
| 56
| 25.315789
| 0.844907
| 0
| 0
| 0
| 0
| 0
| 0.255187
| 0.161826
| 0
| 0
| 0
| 0
| 0
| 1
| 0.461538
| false
| 0
| 0.076923
| 0.461538
| 1
| 0
| 0
| 0
| 0
| null | 1
| 1
| 1
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| null | 0
| 0
| 0
| 0
| 0
| 1
| 0
| 0
| 0
| 1
| 1
| 0
|
0
| 6
|
947673beaa243974d245474fca5579c69b561ddc
| 22
|
py
|
Python
|
timeular/__init__.py
|
davidbstein/sdk-timeular-tools
|
bce9d536b3a4bec1ab2a31f5b2118d8341b6e9fa
|
[
"MIT"
] | 2
|
2021-07-20T01:24:23.000Z
|
2021-09-20T08:21:34.000Z
|
timeular/__init__.py
|
davidbstein/sdk-timeular-tools
|
bce9d536b3a4bec1ab2a31f5b2118d8341b6e9fa
|
[
"MIT"
] | null | null | null |
timeular/__init__.py
|
davidbstein/sdk-timeular-tools
|
bce9d536b3a4bec1ab2a31f5b2118d8341b6e9fa
|
[
"MIT"
] | 1
|
2022-03-30T09:49:08.000Z
|
2022-03-30T09:49:08.000Z
|
from timeular import *
| 22
| 22
| 0.818182
| 3
| 22
| 6
| 1
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0.136364
| 22
| 1
| 22
| 22
| 0.947368
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 1
| 0
| true
| 0
| 1
| 0
| 1
| 0
| 1
| 1
| 0
| null | 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 1
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| null | 0
| 0
| 0
| 0
| 0
| 0
| 1
| 0
| 1
| 0
| 1
| 0
|
0
| 6
|
8472474443a53b613f483959a6c1f657fb5cfc17
| 28,138
|
py
|
Python
|
UI/EMGGeming.py
|
r33did/SkripsiEmosiRNN
|
0bfdb7d19850bbcd994fc4a8557a52716ae38128
|
[
"MIT"
] | 2
|
2021-09-15T08:25:41.000Z
|
2021-11-12T06:42:31.000Z
|
UI/EMGGeming.py
|
r33did/SkripsiEmosiRNN
|
0bfdb7d19850bbcd994fc4a8557a52716ae38128
|
[
"MIT"
] | null | null | null |
UI/EMGGeming.py
|
r33did/SkripsiEmosiRNN
|
0bfdb7d19850bbcd994fc4a8557a52716ae38128
|
[
"MIT"
] | null | null | null |
# -*- coding: utf-8 -*-
# Form implementation generated from reading ui file 'emg.ui'
#
# Created by: PyQt5 UI code generator 5.15.4
#
# WARNING: Any manual changes made to this file will be lost when pyuic5 is
# run again. Do not edit this file unless you know what you are doing.
from PyQt5 import QtCore, QtGui, QtWidgets
class Ui_MainWindow(object):
def setupUi(self, MainWindow):
MainWindow.setObjectName("MainWindow")
MainWindow.resize(732, 405)
font = QtGui.QFont()
font.setPointSize(12)
MainWindow.setFont(font)
MainWindow.setAutoFillBackground(False)
MainWindow.setStyleSheet("background-color: rgb(52, 52, 52);\n"
"")
self.centralwidget = QtWidgets.QWidget(MainWindow)
self.centralwidget.setObjectName("centralwidget")
self.gridLayout_2 = QtWidgets.QGridLayout(self.centralwidget)
self.gridLayout_2.setObjectName("gridLayout_2")
self.gridLayout = QtWidgets.QGridLayout()
self.gridLayout.setObjectName("gridLayout")
spacerItem = QtWidgets.QSpacerItem(20, 40, QtWidgets.QSizePolicy.Minimum, QtWidgets.QSizePolicy.Expanding)
self.gridLayout.addItem(spacerItem, 2, 0, 1, 1)
self.label_4 = QtWidgets.QLabel(self.centralwidget)
font = QtGui.QFont()
font.setFamily("NewsGoth BT")
font.setPointSize(16)
font.setBold(True)
font.setItalic(False)
font.setWeight(75)
self.label_4.setFont(font)
self.label_4.setStyleSheet("\n"
"color: rgb(255, 255, 255);")
self.label_4.setAlignment(QtCore.Qt.AlignCenter)
self.label_4.setObjectName("label_4")
self.gridLayout.addWidget(self.label_4, 0, 2, 1, 1)
spacerItem1 = QtWidgets.QSpacerItem(378, 17, QtWidgets.QSizePolicy.Expanding, QtWidgets.QSizePolicy.Minimum)
self.gridLayout.addItem(spacerItem1, 3, 2, 1, 1)
self.widget = PlotWidget(self.centralwidget)
self.widget.setStyleSheet("border:1px solid white")
self.widget.setObjectName("widget")
self.gridLayout.addWidget(self.widget, 2, 2, 1, 1)
self.gridLayout_2.addLayout(self.gridLayout, 0, 0, 8, 1)
self.label = QtWidgets.QLabel(self.centralwidget)
font = QtGui.QFont()
font.setFamily("NewsGoth BT")
font.setPointSize(14)
font.setBold(True)
font.setWeight(75)
self.label.setFont(font)
self.label.setStyleSheet("\n"
"color: rgb(255, 255, 255);")
self.label.setAlignment(QtCore.Qt.AlignCenter)
self.label.setObjectName("label")
self.gridLayout_2.addWidget(self.label, 0, 1, 1, 1)
self.lineEdit = QtWidgets.QLineEdit(self.centralwidget)
font = QtGui.QFont()
font.setFamily("NewsGoth BT")
font.setPointSize(10)
font.setBold(True)
font.setWeight(75)
self.lineEdit.setFont(font)
self.lineEdit.setStyleSheet("\n"
"QLineEdit::!pressed\n"
"{background-color:black;\n"
"border : 1px solid white;\n"
"color: white}\n"
"\n"
"QLineEdit::focus\n"
"{border : 1px solid rgb(255, 170, 0);\n"
"color: white}\n"
"\n"
"QLineEdit::hover\n"
"{border : 1px solid rgb(255, 170, 0);\n"
"color: white}\n"
"\n"
"\n"
"")
self.lineEdit.setAlignment(QtCore.Qt.AlignCenter)
self.lineEdit.setObjectName("lineEdit")
self.gridLayout_2.addWidget(self.lineEdit, 1, 1, 1, 1)
self.label_2 = QtWidgets.QLabel(self.centralwidget)
font = QtGui.QFont()
font.setFamily("NewsGoth BT")
font.setPointSize(14)
font.setBold(True)
font.setWeight(75)
self.label_2.setFont(font)
self.label_2.setStyleSheet("\n"
"color: rgb(255, 255, 255);")
self.label_2.setAlignment(QtCore.Qt.AlignCenter)
self.label_2.setObjectName("label_2")
self.gridLayout_2.addWidget(self.label_2, 2, 1, 1, 1)
self.lineEdit_2 = QtWidgets.QLineEdit(self.centralwidget)
palette = QtGui.QPalette()
brush = QtGui.QBrush(QtGui.QColor(255, 255, 255))
brush.setStyle(QtCore.Qt.SolidPattern)
palette.setBrush(QtGui.QPalette.Active, QtGui.QPalette.WindowText, brush)
brush = QtGui.QBrush(QtGui.QColor(0, 0, 0))
brush.setStyle(QtCore.Qt.SolidPattern)
palette.setBrush(QtGui.QPalette.Active, QtGui.QPalette.Button, brush)
brush = QtGui.QBrush(QtGui.QColor(255, 255, 255))
brush.setStyle(QtCore.Qt.SolidPattern)
palette.setBrush(QtGui.QPalette.Active, QtGui.QPalette.Text, brush)
brush = QtGui.QBrush(QtGui.QColor(255, 255, 255))
brush.setStyle(QtCore.Qt.SolidPattern)
palette.setBrush(QtGui.QPalette.Active, QtGui.QPalette.ButtonText, brush)
brush = QtGui.QBrush(QtGui.QColor(0, 0, 0))
brush.setStyle(QtCore.Qt.SolidPattern)
palette.setBrush(QtGui.QPalette.Active, QtGui.QPalette.Base, brush)
brush = QtGui.QBrush(QtGui.QColor(0, 0, 0))
brush.setStyle(QtCore.Qt.SolidPattern)
palette.setBrush(QtGui.QPalette.Active, QtGui.QPalette.Window, brush)
brush = QtGui.QBrush(QtGui.QColor(255, 170, 0))
brush.setStyle(QtCore.Qt.SolidPattern)
palette.setBrush(QtGui.QPalette.Active, QtGui.QPalette.Highlight, brush)
brush = QtGui.QBrush(QtGui.QColor(255, 255, 255))
brush.setStyle(QtCore.Qt.SolidPattern)
palette.setBrush(QtGui.QPalette.Inactive, QtGui.QPalette.WindowText, brush)
brush = QtGui.QBrush(QtGui.QColor(0, 0, 0))
brush.setStyle(QtCore.Qt.SolidPattern)
palette.setBrush(QtGui.QPalette.Inactive, QtGui.QPalette.Button, brush)
brush = QtGui.QBrush(QtGui.QColor(255, 255, 255))
brush.setStyle(QtCore.Qt.SolidPattern)
palette.setBrush(QtGui.QPalette.Inactive, QtGui.QPalette.Text, brush)
brush = QtGui.QBrush(QtGui.QColor(255, 255, 255))
brush.setStyle(QtCore.Qt.SolidPattern)
palette.setBrush(QtGui.QPalette.Inactive, QtGui.QPalette.ButtonText, brush)
brush = QtGui.QBrush(QtGui.QColor(0, 0, 0))
brush.setStyle(QtCore.Qt.SolidPattern)
palette.setBrush(QtGui.QPalette.Inactive, QtGui.QPalette.Base, brush)
brush = QtGui.QBrush(QtGui.QColor(0, 0, 0))
brush.setStyle(QtCore.Qt.SolidPattern)
palette.setBrush(QtGui.QPalette.Inactive, QtGui.QPalette.Window, brush)
brush = QtGui.QBrush(QtGui.QColor(255, 170, 0))
brush.setStyle(QtCore.Qt.SolidPattern)
palette.setBrush(QtGui.QPalette.Inactive, QtGui.QPalette.Highlight, brush)
brush = QtGui.QBrush(QtGui.QColor(255, 255, 255))
brush.setStyle(QtCore.Qt.SolidPattern)
palette.setBrush(QtGui.QPalette.Disabled, QtGui.QPalette.WindowText, brush)
brush = QtGui.QBrush(QtGui.QColor(0, 0, 0))
brush.setStyle(QtCore.Qt.SolidPattern)
palette.setBrush(QtGui.QPalette.Disabled, QtGui.QPalette.Button, brush)
brush = QtGui.QBrush(QtGui.QColor(255, 255, 255))
brush.setStyle(QtCore.Qt.SolidPattern)
palette.setBrush(QtGui.QPalette.Disabled, QtGui.QPalette.Text, brush)
brush = QtGui.QBrush(QtGui.QColor(255, 255, 255))
brush.setStyle(QtCore.Qt.SolidPattern)
palette.setBrush(QtGui.QPalette.Disabled, QtGui.QPalette.ButtonText, brush)
brush = QtGui.QBrush(QtGui.QColor(0, 0, 0))
brush.setStyle(QtCore.Qt.SolidPattern)
palette.setBrush(QtGui.QPalette.Disabled, QtGui.QPalette.Base, brush)
brush = QtGui.QBrush(QtGui.QColor(0, 0, 0))
brush.setStyle(QtCore.Qt.SolidPattern)
palette.setBrush(QtGui.QPalette.Disabled, QtGui.QPalette.Window, brush)
brush = QtGui.QBrush(QtGui.QColor(0, 120, 215))
brush.setStyle(QtCore.Qt.SolidPattern)
palette.setBrush(QtGui.QPalette.Disabled, QtGui.QPalette.Highlight, brush)
self.lineEdit_2.setPalette(palette)
font = QtGui.QFont()
font.setFamily("NewsGoth BT")
font.setPointSize(10)
font.setBold(True)
font.setWeight(75)
self.lineEdit_2.setFont(font)
self.lineEdit_2.setStyleSheet("\n"
"QLineEdit::!pressed\n"
"{background-color:black;\n"
"border : 1px solid white;\n"
"color: white}\n"
"\n"
"QLineEdit::focus\n"
"{border : 1px solid rgb(255, 170, 0);\n"
"color: white}\n"
"\n"
"QLineEdit::hover\n"
"{border : 1px solid rgb(255, 170, 0);\n"
"color: white}")
self.lineEdit_2.setAlignment(QtCore.Qt.AlignCenter)
self.lineEdit_2.setObjectName("lineEdit_2")
self.gridLayout_2.addWidget(self.lineEdit_2, 3, 1, 1, 1)
self.listWidget = QtWidgets.QListWidget(self.centralwidget)
font = QtGui.QFont()
font.setPointSize(6)
font.setItalic(True)
self.listWidget.setFont(font)
self.listWidget.setStyleSheet("background-color: rgb(0, 0, 0);\n"
"gridline-color: rgb(255, 255, 255);\n"
"border: 1px solid white;\n"
"")
self.listWidget.setObjectName("listWidget")
self.gridLayout_2.addWidget(self.listWidget, 4, 1, 1, 1)
self.horizontalLayout_2 = QtWidgets.QHBoxLayout()
self.horizontalLayout_2.setObjectName("horizontalLayout_2")
self.label_3 = QtWidgets.QLabel(self.centralwidget)
font = QtGui.QFont()
font.setFamily("NewsGoth BT")
font.setPointSize(12)
font.setBold(True)
font.setWeight(75)
self.label_3.setFont(font)
self.label_3.setStyleSheet("color: rgb(255, 255, 255);")
self.label_3.setObjectName("label_3")
self.horizontalLayout_2.addWidget(self.label_3)
self.comboBox = QtWidgets.QComboBox(self.centralwidget)
sizePolicy = QtWidgets.QSizePolicy(QtWidgets.QSizePolicy.Preferred, QtWidgets.QSizePolicy.Preferred)
sizePolicy.setHorizontalStretch(0)
sizePolicy.setVerticalStretch(0)
sizePolicy.setHeightForWidth(self.comboBox.sizePolicy().hasHeightForWidth())
self.comboBox.setSizePolicy(sizePolicy)
palette = QtGui.QPalette()
brush = QtGui.QBrush(QtGui.QColor(255, 255, 255))
brush.setStyle(QtCore.Qt.SolidPattern)
palette.setBrush(QtGui.QPalette.Active, QtGui.QPalette.WindowText, brush)
brush = QtGui.QBrush(QtGui.QColor(0, 0, 0))
brush.setStyle(QtCore.Qt.SolidPattern)
palette.setBrush(QtGui.QPalette.Active, QtGui.QPalette.Button, brush)
brush = QtGui.QBrush(QtGui.QColor(255, 255, 255))
brush.setStyle(QtCore.Qt.SolidPattern)
palette.setBrush(QtGui.QPalette.Active, QtGui.QPalette.Text, brush)
brush = QtGui.QBrush(QtGui.QColor(255, 255, 255))
brush.setStyle(QtCore.Qt.SolidPattern)
palette.setBrush(QtGui.QPalette.Active, QtGui.QPalette.ButtonText, brush)
brush = QtGui.QBrush(QtGui.QColor(0, 0, 0))
brush.setStyle(QtCore.Qt.SolidPattern)
palette.setBrush(QtGui.QPalette.Active, QtGui.QPalette.Base, brush)
brush = QtGui.QBrush(QtGui.QColor(0, 0, 0))
brush.setStyle(QtCore.Qt.SolidPattern)
palette.setBrush(QtGui.QPalette.Active, QtGui.QPalette.Window, brush)
brush = QtGui.QBrush(QtGui.QColor(255, 170, 0))
brush.setStyle(QtCore.Qt.SolidPattern)
palette.setBrush(QtGui.QPalette.Active, QtGui.QPalette.Highlight, brush)
brush = QtGui.QBrush(QtGui.QColor(255, 255, 255))
brush.setStyle(QtCore.Qt.SolidPattern)
palette.setBrush(QtGui.QPalette.Inactive, QtGui.QPalette.WindowText, brush)
brush = QtGui.QBrush(QtGui.QColor(0, 0, 0))
brush.setStyle(QtCore.Qt.SolidPattern)
palette.setBrush(QtGui.QPalette.Inactive, QtGui.QPalette.Button, brush)
brush = QtGui.QBrush(QtGui.QColor(255, 255, 255))
brush.setStyle(QtCore.Qt.SolidPattern)
palette.setBrush(QtGui.QPalette.Inactive, QtGui.QPalette.Text, brush)
brush = QtGui.QBrush(QtGui.QColor(255, 255, 255))
brush.setStyle(QtCore.Qt.SolidPattern)
palette.setBrush(QtGui.QPalette.Inactive, QtGui.QPalette.ButtonText, brush)
brush = QtGui.QBrush(QtGui.QColor(0, 0, 0))
brush.setStyle(QtCore.Qt.SolidPattern)
palette.setBrush(QtGui.QPalette.Inactive, QtGui.QPalette.Base, brush)
brush = QtGui.QBrush(QtGui.QColor(0, 0, 0))
brush.setStyle(QtCore.Qt.SolidPattern)
palette.setBrush(QtGui.QPalette.Inactive, QtGui.QPalette.Window, brush)
brush = QtGui.QBrush(QtGui.QColor(255, 170, 0))
brush.setStyle(QtCore.Qt.SolidPattern)
palette.setBrush(QtGui.QPalette.Inactive, QtGui.QPalette.Highlight, brush)
brush = QtGui.QBrush(QtGui.QColor(255, 255, 255))
brush.setStyle(QtCore.Qt.SolidPattern)
palette.setBrush(QtGui.QPalette.Disabled, QtGui.QPalette.WindowText, brush)
brush = QtGui.QBrush(QtGui.QColor(0, 0, 0))
brush.setStyle(QtCore.Qt.SolidPattern)
palette.setBrush(QtGui.QPalette.Disabled, QtGui.QPalette.Button, brush)
brush = QtGui.QBrush(QtGui.QColor(255, 255, 255))
brush.setStyle(QtCore.Qt.SolidPattern)
palette.setBrush(QtGui.QPalette.Disabled, QtGui.QPalette.Text, brush)
brush = QtGui.QBrush(QtGui.QColor(255, 255, 255))
brush.setStyle(QtCore.Qt.SolidPattern)
palette.setBrush(QtGui.QPalette.Disabled, QtGui.QPalette.ButtonText, brush)
brush = QtGui.QBrush(QtGui.QColor(0, 0, 0))
brush.setStyle(QtCore.Qt.SolidPattern)
palette.setBrush(QtGui.QPalette.Disabled, QtGui.QPalette.Base, brush)
brush = QtGui.QBrush(QtGui.QColor(0, 0, 0))
brush.setStyle(QtCore.Qt.SolidPattern)
palette.setBrush(QtGui.QPalette.Disabled, QtGui.QPalette.Window, brush)
brush = QtGui.QBrush(QtGui.QColor(0, 0, 0))
brush.setStyle(QtCore.Qt.SolidPattern)
palette.setBrush(QtGui.QPalette.Disabled, QtGui.QPalette.Highlight, brush)
self.comboBox.setPalette(palette)
font = QtGui.QFont()
font.setFamily("NewsGoth BT")
font.setPointSize(12)
font.setBold(True)
font.setWeight(75)
self.comboBox.setFont(font)
self.comboBox.setMouseTracking(False)
self.comboBox.setStyleSheet("QComboBox {\n"
"background-color:black;\n"
"border : 1px solid white;\n"
"color: white;\n"
"}\n"
"\n"
"QComboBox:hover{\n"
"border : 1px solid rgb(255, 170, 0);\n"
"color: white;\n"
"}\n"
"\n"
"QComboBox QAbstractItemView\n"
"{\n"
"background-color: rgb(255, 255, 255);\n"
"selection-background-color: rgb(170, 170, 255);\n"
"border-radius: 0px;\n"
"color: rgb(0, 0, 0);\n"
"font: 14pt;\n"
"}\n"
"")
self.comboBox.setObjectName("comboBox")
self.comboBox.addItem("")
self.comboBox.addItem("")
self.horizontalLayout_2.addWidget(self.comboBox)
self.gridLayout_2.addLayout(self.horizontalLayout_2, 5, 1, 1, 1)
self.horizontalLayout = QtWidgets.QHBoxLayout()
self.horizontalLayout.setObjectName("horizontalLayout")
self.pushButton_2 = QtWidgets.QPushButton(self.centralwidget)
sizePolicy = QtWidgets.QSizePolicy(QtWidgets.QSizePolicy.Minimum, QtWidgets.QSizePolicy.Preferred)
sizePolicy.setHorizontalStretch(0)
sizePolicy.setVerticalStretch(0)
sizePolicy.setHeightForWidth(self.pushButton_2.sizePolicy().hasHeightForWidth())
self.pushButton_2.setSizePolicy(sizePolicy)
font = QtGui.QFont()
font.setFamily("NewsGoth BT")
font.setPointSize(10)
font.setBold(True)
font.setWeight(75)
self.pushButton_2.setFont(font)
self.pushButton_2.setStyleSheet("QPushButton::hover:!pressed\n"
"{background-color : rgb(255, 170, 0);}\n"
"\n"
"QPushButton::!pressed\n"
"{background-color : rgb(52, 52, 52);\n"
"color:white;\n"
"border: 1px solid white;}\n"
"\n"
"QPushButton::pressed\n"
"{background-color :rgb(238, 159, 0);\n"
"color:white;}\n"
"\n"
"\n"
"")
self.pushButton_2.setObjectName("pushButton_2")
self.horizontalLayout.addWidget(self.pushButton_2)
self.pushButton = QtWidgets.QPushButton(self.centralwidget)
sizePolicy = QtWidgets.QSizePolicy(QtWidgets.QSizePolicy.Minimum, QtWidgets.QSizePolicy.Preferred)
sizePolicy.setHorizontalStretch(0)
sizePolicy.setVerticalStretch(0)
sizePolicy.setHeightForWidth(self.pushButton.sizePolicy().hasHeightForWidth())
self.pushButton.setSizePolicy(sizePolicy)
palette = QtGui.QPalette()
brush = QtGui.QBrush(QtGui.QColor(255, 255, 255))
brush.setStyle(QtCore.Qt.SolidPattern)
palette.setBrush(QtGui.QPalette.Active, QtGui.QPalette.WindowText, brush)
brush = QtGui.QBrush(QtGui.QColor(52, 52, 52))
brush.setStyle(QtCore.Qt.SolidPattern)
palette.setBrush(QtGui.QPalette.Active, QtGui.QPalette.Button, brush)
brush = QtGui.QBrush(QtGui.QColor(255, 255, 255))
brush.setStyle(QtCore.Qt.SolidPattern)
palette.setBrush(QtGui.QPalette.Active, QtGui.QPalette.Text, brush)
brush = QtGui.QBrush(QtGui.QColor(255, 255, 255))
brush.setStyle(QtCore.Qt.SolidPattern)
palette.setBrush(QtGui.QPalette.Active, QtGui.QPalette.ButtonText, brush)
brush = QtGui.QBrush(QtGui.QColor(52, 52, 52))
brush.setStyle(QtCore.Qt.SolidPattern)
palette.setBrush(QtGui.QPalette.Active, QtGui.QPalette.Base, brush)
brush = QtGui.QBrush(QtGui.QColor(52, 52, 52))
brush.setStyle(QtCore.Qt.SolidPattern)
palette.setBrush(QtGui.QPalette.Active, QtGui.QPalette.Window, brush)
brush = QtGui.QBrush(QtGui.QColor(255, 255, 255))
brush.setStyle(QtCore.Qt.SolidPattern)
palette.setBrush(QtGui.QPalette.Inactive, QtGui.QPalette.WindowText, brush)
brush = QtGui.QBrush(QtGui.QColor(52, 52, 52))
brush.setStyle(QtCore.Qt.SolidPattern)
palette.setBrush(QtGui.QPalette.Inactive, QtGui.QPalette.Button, brush)
brush = QtGui.QBrush(QtGui.QColor(255, 255, 255))
brush.setStyle(QtCore.Qt.SolidPattern)
palette.setBrush(QtGui.QPalette.Inactive, QtGui.QPalette.Text, brush)
brush = QtGui.QBrush(QtGui.QColor(255, 255, 255))
brush.setStyle(QtCore.Qt.SolidPattern)
palette.setBrush(QtGui.QPalette.Inactive, QtGui.QPalette.ButtonText, brush)
brush = QtGui.QBrush(QtGui.QColor(52, 52, 52))
brush.setStyle(QtCore.Qt.SolidPattern)
palette.setBrush(QtGui.QPalette.Inactive, QtGui.QPalette.Base, brush)
brush = QtGui.QBrush(QtGui.QColor(52, 52, 52))
brush.setStyle(QtCore.Qt.SolidPattern)
palette.setBrush(QtGui.QPalette.Inactive, QtGui.QPalette.Window, brush)
brush = QtGui.QBrush(QtGui.QColor(255, 255, 255))
brush.setStyle(QtCore.Qt.SolidPattern)
palette.setBrush(QtGui.QPalette.Disabled, QtGui.QPalette.WindowText, brush)
brush = QtGui.QBrush(QtGui.QColor(52, 52, 52))
brush.setStyle(QtCore.Qt.SolidPattern)
palette.setBrush(QtGui.QPalette.Disabled, QtGui.QPalette.Button, brush)
brush = QtGui.QBrush(QtGui.QColor(255, 255, 255))
brush.setStyle(QtCore.Qt.SolidPattern)
palette.setBrush(QtGui.QPalette.Disabled, QtGui.QPalette.Text, brush)
brush = QtGui.QBrush(QtGui.QColor(255, 255, 255))
brush.setStyle(QtCore.Qt.SolidPattern)
palette.setBrush(QtGui.QPalette.Disabled, QtGui.QPalette.ButtonText, brush)
brush = QtGui.QBrush(QtGui.QColor(52, 52, 52))
brush.setStyle(QtCore.Qt.SolidPattern)
palette.setBrush(QtGui.QPalette.Disabled, QtGui.QPalette.Base, brush)
brush = QtGui.QBrush(QtGui.QColor(52, 52, 52))
brush.setStyle(QtCore.Qt.SolidPattern)
palette.setBrush(QtGui.QPalette.Disabled, QtGui.QPalette.Window, brush)
self.pushButton.setPalette(palette)
font = QtGui.QFont()
font.setFamily("NewsGoth BT")
font.setPointSize(10)
font.setBold(True)
font.setWeight(75)
self.pushButton.setFont(font)
self.pushButton.setStyleSheet("QPushButton::hover:!pressed\n"
"{background-color : rgb(255, 170, 0);}\n"
"\n"
"QPushButton::!pressed\n"
"{background-color : rgb(52, 52, 52);\n"
"color:white;\n"
"border: 1px solid white;}\n"
"\n"
"QPushButton::pressed\n"
"{background-color :rgb(238, 159, 0);\n"
"color:white;}\n"
"\n"
"")
self.pushButton.setObjectName("pushButton")
self.horizontalLayout.addWidget(self.pushButton)
self.gridLayout_2.addLayout(self.horizontalLayout, 6, 1, 1, 1)
self.horizontalLayout_3 = QtWidgets.QHBoxLayout()
self.horizontalLayout_3.setObjectName("horizontalLayout_3")
self.statusText = QtWidgets.QLabel(self.centralwidget)
font = QtGui.QFont()
font.setPointSize(9)
font.setBold(True)
font.setWeight(75)
self.statusText.setFont(font)
self.statusText.setStyleSheet("color: rgb(255, 255, 255);")
self.statusText.setAlignment(QtCore.Qt.AlignRight|QtCore.Qt.AlignTrailing|QtCore.Qt.AlignVCenter)
self.statusText.setWordWrap(False)
self.statusText.setObjectName("statusText")
self.horizontalLayout_3.addWidget(self.statusText)
self.statusValue = QtWidgets.QLabel(self.centralwidget)
font = QtGui.QFont()
font.setPointSize(9)
font.setBold(True)
font.setWeight(75)
self.statusValue.setFont(font)
self.statusValue.setStyleSheet("color: rgb(255, 255, 255);")
self.statusValue.setAlignment(QtCore.Qt.AlignCenter)
self.statusValue.setObjectName("statusValue")
self.horizontalLayout_3.addWidget(self.statusValue)
self.gridLayout_2.addLayout(self.horizontalLayout_3, 7, 1, 1, 1)
MainWindow.setCentralWidget(self.centralwidget)
self.menubar = QtWidgets.QMenuBar(MainWindow)
self.menubar.setGeometry(QtCore.QRect(0, 0, 732, 21))
self.menubar.setStyleSheet("QMenuBar{\n"
"background-color:rgb(52, 52, 52);\n"
"color: rgb(255, 255, 255);\n"
"}\n"
"\n"
"QMenuBar::item:selected{\n"
"background-color:rgb(255, 170, 0);\n"
"color: rgb(255, 255, 255);\n"
"}")
self.menubar.setObjectName("menubar")
self.menuFile = QtWidgets.QMenu(self.menubar)
palette = QtGui.QPalette()
brush = QtGui.QBrush(QtGui.QColor(255, 255, 255))
brush.setStyle(QtCore.Qt.SolidPattern)
palette.setBrush(QtGui.QPalette.Active, QtGui.QPalette.WindowText, brush)
brush = QtGui.QBrush(QtGui.QColor(52, 52, 52))
brush.setStyle(QtCore.Qt.SolidPattern)
palette.setBrush(QtGui.QPalette.Active, QtGui.QPalette.Button, brush)
brush = QtGui.QBrush(QtGui.QColor(255, 255, 255))
brush.setStyle(QtCore.Qt.SolidPattern)
palette.setBrush(QtGui.QPalette.Active, QtGui.QPalette.Text, brush)
brush = QtGui.QBrush(QtGui.QColor(255, 255, 255))
brush.setStyle(QtCore.Qt.SolidPattern)
palette.setBrush(QtGui.QPalette.Active, QtGui.QPalette.ButtonText, brush)
brush = QtGui.QBrush(QtGui.QColor(52, 52, 52))
brush.setStyle(QtCore.Qt.SolidPattern)
palette.setBrush(QtGui.QPalette.Active, QtGui.QPalette.Base, brush)
brush = QtGui.QBrush(QtGui.QColor(52, 52, 52))
brush.setStyle(QtCore.Qt.SolidPattern)
palette.setBrush(QtGui.QPalette.Active, QtGui.QPalette.Window, brush)
brush = QtGui.QBrush(QtGui.QColor(255, 170, 0))
brush.setStyle(QtCore.Qt.SolidPattern)
palette.setBrush(QtGui.QPalette.Active, QtGui.QPalette.Highlight, brush)
brush = QtGui.QBrush(QtGui.QColor(255, 255, 255))
brush.setStyle(QtCore.Qt.SolidPattern)
palette.setBrush(QtGui.QPalette.Inactive, QtGui.QPalette.WindowText, brush)
brush = QtGui.QBrush(QtGui.QColor(52, 52, 52))
brush.setStyle(QtCore.Qt.SolidPattern)
palette.setBrush(QtGui.QPalette.Inactive, QtGui.QPalette.Button, brush)
brush = QtGui.QBrush(QtGui.QColor(255, 255, 255))
brush.setStyle(QtCore.Qt.SolidPattern)
palette.setBrush(QtGui.QPalette.Inactive, QtGui.QPalette.Text, brush)
brush = QtGui.QBrush(QtGui.QColor(255, 255, 255))
brush.setStyle(QtCore.Qt.SolidPattern)
palette.setBrush(QtGui.QPalette.Inactive, QtGui.QPalette.ButtonText, brush)
brush = QtGui.QBrush(QtGui.QColor(52, 52, 52))
brush.setStyle(QtCore.Qt.SolidPattern)
palette.setBrush(QtGui.QPalette.Inactive, QtGui.QPalette.Base, brush)
brush = QtGui.QBrush(QtGui.QColor(52, 52, 52))
brush.setStyle(QtCore.Qt.SolidPattern)
palette.setBrush(QtGui.QPalette.Inactive, QtGui.QPalette.Window, brush)
brush = QtGui.QBrush(QtGui.QColor(255, 170, 0))
brush.setStyle(QtCore.Qt.SolidPattern)
palette.setBrush(QtGui.QPalette.Inactive, QtGui.QPalette.Highlight, brush)
brush = QtGui.QBrush(QtGui.QColor(255, 255, 255))
brush.setStyle(QtCore.Qt.SolidPattern)
palette.setBrush(QtGui.QPalette.Disabled, QtGui.QPalette.WindowText, brush)
brush = QtGui.QBrush(QtGui.QColor(52, 52, 52))
brush.setStyle(QtCore.Qt.SolidPattern)
palette.setBrush(QtGui.QPalette.Disabled, QtGui.QPalette.Button, brush)
brush = QtGui.QBrush(QtGui.QColor(255, 255, 255))
brush.setStyle(QtCore.Qt.SolidPattern)
palette.setBrush(QtGui.QPalette.Disabled, QtGui.QPalette.Text, brush)
brush = QtGui.QBrush(QtGui.QColor(255, 255, 255))
brush.setStyle(QtCore.Qt.SolidPattern)
palette.setBrush(QtGui.QPalette.Disabled, QtGui.QPalette.ButtonText, brush)
brush = QtGui.QBrush(QtGui.QColor(52, 52, 52))
brush.setStyle(QtCore.Qt.SolidPattern)
palette.setBrush(QtGui.QPalette.Disabled, QtGui.QPalette.Base, brush)
brush = QtGui.QBrush(QtGui.QColor(52, 52, 52))
brush.setStyle(QtCore.Qt.SolidPattern)
palette.setBrush(QtGui.QPalette.Disabled, QtGui.QPalette.Window, brush)
brush = QtGui.QBrush(QtGui.QColor(255, 170, 0))
brush.setStyle(QtCore.Qt.SolidPattern)
palette.setBrush(QtGui.QPalette.Disabled, QtGui.QPalette.Highlight, brush)
self.menuFile.setPalette(palette)
self.menuFile.setStyleSheet("QMenu{\n"
"background-color: rgb(52, 52, 52);\n"
"color: rgb(255, 255, 255);\n"
"selection-background-color:rgb(255, 170, 0)\n"
"}\n"
"\n"
"QMenu::item:selected\n"
"{background-color : rgb(255, 170, 0)}\n"
"\n"
"QMenu::on\n"
"{background-color : rgb(255, 170, 0)}\n"
"")
self.menuFile.setObjectName("menuFile")
MainWindow.setMenuBar(self.menubar)
self.statusbar = QtWidgets.QStatusBar(MainWindow)
self.statusbar.setObjectName("statusbar")
MainWindow.setStatusBar(self.statusbar)
self.actionExit = QtWidgets.QAction(MainWindow)
self.actionExit.setObjectName("actionExit")
self.menuFile.addAction(self.actionExit)
self.menubar.addAction(self.menuFile.menuAction())
self.retranslateUi(MainWindow)
QtCore.QMetaObject.connectSlotsByName(MainWindow)
def retranslateUi(self, MainWindow):
_translate = QtCore.QCoreApplication.translate
MainWindow.setWindowTitle(_translate("MainWindow", "EMGGraph"))
self.label_4.setText(_translate("MainWindow", "Electromyograph Signal Graph"))
self.label.setText(_translate("MainWindow", "Subject"))
self.label_2.setText(_translate("MainWindow", "Notes"))
self.label_3.setText(_translate("MainWindow", "Port"))
self.comboBox.setItemText(0, _translate("MainWindow", "COM5"))
self.comboBox.setItemText(1, _translate("MainWindow", "COM6"))
self.pushButton_2.setText(_translate("MainWindow", "START"))
self.pushButton.setText(_translate("MainWindow", "STOP"))
self.statusText.setText(_translate("MainWindow", "Status : "))
self.statusValue.setText(_translate("MainWindow", "-"))
self.menuFile.setTitle(_translate("MainWindow", "File"))
self.actionExit.setText(_translate("MainWindow", "Exit"))
from pyqtgraph import PlotWidget
if __name__ == "__main__":
import sys
app = QtWidgets.QApplication(sys.argv)
MainWindow = QtWidgets.QMainWindow()
ui = Ui_MainWindow()
ui.setupUi(MainWindow)
MainWindow.show()
sys.exit(app.exec_())
| 48.181507
| 116
| 0.683773
| 3,301
| 28,138
| 5.801575
| 0.068767
| 0.112683
| 0.067673
| 0.08882
| 0.773432
| 0.746071
| 0.717769
| 0.702992
| 0.700381
| 0.694063
| 0
| 0.043444
| 0.183595
| 28,138
| 583
| 117
| 48.264151
| 0.790223
| 0.009524
| 0
| 0.687831
| 1
| 0
| 0.093784
| 0.01529
| 0
| 0
| 0
| 0
| 0
| 1
| 0.003527
| false
| 0
| 0.005291
| 0
| 0.010582
| 0
| 0
| 0
| 0
| null | 0
| 0
| 0
| 0
| 1
| 1
| 1
| 1
| 1
| 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
| 6
|
847aad3fd187df6ab3daf4b7320f23ea24e6d6bc
| 90
|
py
|
Python
|
cui_p1p.py
|
userElaina/rsa-p2p
|
8d0d5e09581f9df5c2109f21d3acbf5d13599231
|
[
"Apache-2.0",
"MIT"
] | null | null | null |
cui_p1p.py
|
userElaina/rsa-p2p
|
8d0d5e09581f9df5c2109f21d3acbf5d13599231
|
[
"Apache-2.0",
"MIT"
] | null | null | null |
cui_p1p.py
|
userElaina/rsa-p2p
|
8d0d5e09581f9df5c2109f21d3acbf5d13599231
|
[
"Apache-2.0",
"MIT"
] | null | null | null |
from rsap2p import TCPp2p_CUI
TCPp2p_CUI(('0.0.0.0',23305),'user1','127.0.0.1').joins()
| 30
| 57
| 0.677778
| 18
| 90
| 3.277778
| 0.611111
| 0.135593
| 0.101695
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0.228916
| 0.077778
| 90
| 3
| 57
| 30
| 0.481928
| 0
| 0
| 0
| 0
| 0
| 0.235955
| 0
| 0
| 0
| 0
| 0
| 0
| 1
| 0
| true
| 0
| 0.5
| 0
| 0.5
| 0
| 1
| 0
| 0
| null | 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 1
| 0
| 0
| 1
| 0
| 0
| 1
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| null | 0
| 0
| 0
| 0
| 0
| 0
| 1
| 0
| 1
| 0
| 0
| 0
|
0
| 6
|
847de071ffa487a10201978e4666cf613b6fe47a
| 48
|
py
|
Python
|
randomWalk/steps_generating_exception.py
|
jpshankar/random_walk
|
02367c363164ba0207f09a775bbe1f27e4a48ff6
|
[
"MIT"
] | null | null | null |
randomWalk/steps_generating_exception.py
|
jpshankar/random_walk
|
02367c363164ba0207f09a775bbe1f27e4a48ff6
|
[
"MIT"
] | null | null | null |
randomWalk/steps_generating_exception.py
|
jpshankar/random_walk
|
02367c363164ba0207f09a775bbe1f27e4a48ff6
|
[
"MIT"
] | null | null | null |
class StepsGeneratingException(Exception):
pass
| 24
| 42
| 0.875
| 4
| 48
| 10.5
| 1
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0.0625
| 48
| 2
| 43
| 24
| 0.933333
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 1
| 0
| true
| 0.5
| 0
| 0
| 0.5
| 0
| 1
| 1
| 1
| null | 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 1
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| null | 0
| 0
| 0
| 0
| 0
| 0
| 1
| 1
| 0
| 0
| 0
| 0
|
0
| 6
|
84ea21da32f03cd3fe651bb4ef0c06c9b94b138a
| 139
|
py
|
Python
|
models/__init__.py
|
WZzhaoyi/TF-NAS
|
f63e9fd3a5ca0d8c6400891baa19c2168b203513
|
[
"MIT"
] | 62
|
2020-07-05T11:59:47.000Z
|
2022-01-18T08:09:53.000Z
|
models/__init__.py
|
WZzhaoyi/TF-NAS
|
f63e9fd3a5ca0d8c6400891baa19c2168b203513
|
[
"MIT"
] | 4
|
2020-08-17T09:13:47.000Z
|
2021-10-01T03:21:28.000Z
|
models/__init__.py
|
WZzhaoyi/TF-NAS
|
f63e9fd3a5ca0d8c6400891baa19c2168b203513
|
[
"MIT"
] | 11
|
2020-07-23T06:21:28.000Z
|
2021-06-13T20:19:24.000Z
|
from .layers import set_layer_from_config
from .model_search import Network as NetworkSearch
from .model_eval import Network as NetworkEval
| 46.333333
| 50
| 0.870504
| 21
| 139
| 5.52381
| 0.619048
| 0.155172
| 0.258621
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0.107914
| 139
| 3
| 51
| 46.333333
| 0.935484
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 1
| 0
| true
| 0
| 1
| 0
| 1
| 0
| 1
| 0
| 0
| null | 0
| 1
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 1
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| null | 0
| 0
| 0
| 0
| 0
| 0
| 1
| 0
| 1
| 0
| 1
| 0
|
0
| 6
|
ca57f0232f7ba96bda21b5ef105a4de0bb60e22f
| 126
|
py
|
Python
|
SUAVE/SUAVE-2.5.0/trunk/SUAVE/Input_Output/FreeMind/__init__.py
|
Vinicius-Tanigawa/Undergraduate-Research-Project
|
e92372f07882484b127d7affe305eeec2238b8a9
|
[
"MIT"
] | null | null | null |
SUAVE/SUAVE-2.5.0/trunk/SUAVE/Input_Output/FreeMind/__init__.py
|
Vinicius-Tanigawa/Undergraduate-Research-Project
|
e92372f07882484b127d7affe305eeec2238b8a9
|
[
"MIT"
] | null | null | null |
SUAVE/SUAVE-2.5.0/trunk/SUAVE/Input_Output/FreeMind/__init__.py
|
Vinicius-Tanigawa/Undergraduate-Research-Project
|
e92372f07882484b127d7affe305eeec2238b8a9
|
[
"MIT"
] | null | null | null |
## @defgroup Input_Output-FreeMind FreeMind
# Function to save FreeMind output.
# @ingroup Input_Output
from .save import save
| 31.5
| 43
| 0.801587
| 17
| 126
| 5.823529
| 0.588235
| 0.222222
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0.126984
| 126
| 4
| 44
| 31.5
| 0.9
| 0.761905
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 1
| 0
| true
| 0
| 1
| 0
| 1
| 0
| 1
| 0
| 0
| null | 1
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 1
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| null | 0
| 0
| 0
| 0
| 0
| 0
| 1
| 0
| 1
| 0
| 1
| 0
|
0
| 6
|
0488ee3702ec32f1ccce21212ecd5cf5c5445b90
| 27,815
|
py
|
Python
|
tests/test_server.py
|
LandRegistry-Attic/digital-register-api
|
f6093d1d066ab620b8882dfd1bcf3fbfd107e467
|
[
"MIT"
] | null | null | null |
tests/test_server.py
|
LandRegistry-Attic/digital-register-api
|
f6093d1d066ab620b8882dfd1bcf3fbfd107e467
|
[
"MIT"
] | 56
|
2015-02-11T13:31:52.000Z
|
2016-04-20T14:31:30.000Z
|
tests/test_server.py
|
LandRegistry-Attic/digital-register-api
|
f6093d1d066ab620b8882dfd1bcf3fbfd107e467
|
[
"MIT"
] | null | null | null |
import json
import mock
from datetime import datetime
from collections import namedtuple
from elasticsearch_dsl.utils import AttrList
from service import app
from service.server import db_access, es_access, api_client
FakeTitleRegisterData = namedtuple(
'TitleRegisterData',
['title_number', 'register_data', 'geometry_data', 'official_copy_data']
)
FakeUprnMapping = namedtuple(
'UprnMapping',
['uprn', 'lr_uprn'])
FakeElasticsearchAddressHit = namedtuple(
'Hit',
['title_number', 'address_string', 'entry_datetime']
)
FakeElasticsearchPostcodeHit = namedtuple(
'Hit',
['title_number', 'postcode', 'house_number_or_first_number', 'address_string', 'entry_datetime']
)
TEST_EXCEPTION = Exception('Test exception')
ES_RESULT = {
"data": {
"addresses": [
{
"building_name": "1 INGLEWOOD HOUSE",
"building_number": "",
"department_name": "",
"dependent_locality": "",
"dependent_thoroughfare_name": "",
"double_dependent_locality": "",
"entry_datetime": "2014-06-07T09:01:38+00",
"joined_fields": "1 INGLEWOOD HOUSE, SIDWELL STREET, EXETER, EX1 1AA",
"organisation_name": "",
"post_town": "EXETER",
"postcode": "EX1 1AA",
"sub_building_name": "",
"thoroughfare_name": "SIDWELL STREET",
"uprn": "1234",
"x_coordinate": 292772.0,
"y_coordinate": 93294.0
}]
}
}
def _get_page_size():
return app.config['SEARCH_RESULTS_PER_PAGE']
def _get_es_postcode_results(*title_numbers, total=None):
result = AttrList([_get_es_postcode_result(i) for i in title_numbers])
result.total = len(title_numbers) if total is None else total
return result
def _get_empty_es_result(total=None):
result = AttrList([])
result.total = total if total else 0
return result
def _get_empty_api_client():
return {'data': {'addresses': [], 'total': 0, 'page_number': 0, 'page_size': 20}}
def _get_one_result_from_api_client():
return {'data': {'addresses': [
{
"building_name": "1 INGLEWOOD HOUSE",
"building_number": "",
"department_name": "",
"dependent_locality": "",
"dependent_thoroughfare_name": "",
"double_dependent_locality": "",
"entry_datetime": "2014-06-07T09:01:38+00",
"joined_fields": "1 INGLEWOOD HOUSE, SIDWELL STREET, EXETER, EX1 1AA",
"organisation_name": "",
"post_town": "EXETER",
"postcode": "EX1 1AA",
"sub_building_name": "",
"thoroughfare_name": "SIDWELL STREET",
"uprn": "10023117067",
"x_coordinate": 292772.0,
"y_coordinate": 93294.0,
"title_number": "EX100",
"tenure": "freehold",
"register_data": "blah"
}], 'total': 1, 'page_number': 1, 'page_size': 20}}
def _get_two_results_from_api_client():
return {'data': {'addresses': [
{
"building_name": "1 INGLEWOOD HOUSE",
"building_number": "",
"department_name": "",
"dependent_locality": "",
"dependent_thoroughfare_name": "",
"double_dependent_locality": "",
"entry_datetime": "2014-06-07T09:01:38+00",
"joined_fields": "1 INGLEWOOD HOUSE, SIDWELL STREET, EXETER, EX1 1AA",
"organisation_name": "",
"post_town": "EXETER",
"postcode": "EX1 1AA",
"sub_building_name": "",
"thoroughfare_name": "SIDWELL STREET",
"uprn": "10023117067",
"x_coordinate": 292772.0,
"y_coordinate": 93294.0,
"title_number": "EX100",
"tenure": "freehold",
"register_data": "blah"
},
{
"building_name": "2 INGLEWOOD HOUSE",
"building_number": "",
"department_name": "",
"dependent_locality": "",
"dependent_thoroughfare_name": "",
"double_dependent_locality": "",
"entry_datetime": "2014-06-07T09:01:38+00",
"joined_fields": "2 INGLEWOOD HOUSE, SIDWELL STREET, EXETER, EX1 1AA",
"organisation_name": "",
"post_town": "EXETER",
"postcode": "EX1 1AA",
"sub_building_name": "",
"thoroughfare_name": "SIDWELL STREET",
"uprn": "10023117067",
"x_coordinate": 292772.0,
"y_coordinate": 93294.0,
"title_number": "EX101",
"tenure": "freehold",
"register_data": "blah"
}], 'total': 2, 'page_number': 1, 'page_size': 20}}
def _get_api_client_response_when_es_finds_but_no_pg_result():
return {'data': {'addresses': [], 'total': 1, 'page_number': 1, 'page_size': 20}}
def _get_es_address_results(*title_numbers, total=None):
result = AttrList([_get_es_address_result(i) for i in title_numbers])
result.total = len(title_numbers) if total is None else total
return result
def _get_es_postcode_result(number):
return FakeElasticsearchPostcodeHit(
title_number=str(number),
postcode='SW11 2DR',
house_number_or_first_number=number,
address_string='address string {}'.format(number),
entry_datetime=datetime(2015, 8, 12, 12, 34, 56),
)
def _get_es_address_result(number):
return FakeElasticsearchAddressHit(
title_number=str(number),
address_string='address string {}'.format(number),
entry_datetime=datetime(2015, 8, 12, 12, 34, 56),
)
def _get_titles(*title_numbers):
return [_get_sample_title(i) for i in title_numbers]
def _get_sample_title(number):
return FakeTitleRegisterData(
str(number),
{'register': 'data {}'.format(number)},
{'geometry': 'geodata {}'.format(number)},
{'sub_registers': [{'A': 'register A {}'.format(number)}]},
)
def _get_sample_uprn():
return FakeUprnMapping(
uprn='1234',
lr_uprn='1234'
)
class TestHealthCheck:
def setup_method(self, method):
self.app = app.test_client()
@mock.patch.object(db_access, 'get_title_register', return_value=None)
@mock.patch.object(es_access, 'get_info', return_value={'status': 200})
def test_health_check_returns_200_response_when_data_stores_respond_properly(
self, mock_get_info, mock_get_user):
response = self.app.get('/health')
assert response.status_code == 200
assert response.data.decode() == '{"status": "ok"}'
@mock.patch.object(db_access, 'get_title_register', side_effect=Exception('Test PG exception'))
@mock.patch.object(es_access, 'get_info', return_value={'status': 200})
def test_health_check_returns_500_response_when_db_access_fails(self, mock_get_info, mock_get_user):
response = self.app.get('/health')
assert response.status_code == 500
json_response = json.loads(response.data.decode())
assert json_response == {
'status': 'error',
'errors': ['Problem talking to PostgreSQL: Test PG exception'],
}
@mock.patch.object(db_access, 'get_title_register', return_value=None)
@mock.patch.object(es_access, 'get_info', side_effect=Exception('Test ES exception'))
def test_health_check_returns_500_response_when_es_access_fails(self, mock_get_info, mock_get_user):
response = self.app.get('/health')
assert response.status_code == 500
json_response = json.loads(response.data.decode())
assert json_response == {
'status': 'error',
'errors': ['Problem talking to elasticsearch: Test ES exception'],
}
@mock.patch.object(db_access, 'get_title_register', side_effect=Exception('Test PG exception'))
@mock.patch.object(es_access, 'get_info', side_effect=Exception('Test ES exception'))
def test_health_check_returns_500_response_with_multiple_errors_when_both_data_stores_fail(
self, mock_get_info, mock_get_user):
response = self.app.get('/health')
assert response.status_code == 500
json_response = json.loads(response.data.decode())
assert json_response == {
'status': 'error',
'errors': [
'Problem talking to elasticsearch: Test ES exception',
'Problem talking to PostgreSQL: Test PG exception',
],
}
class TestGetTitle:
def setup_method(self, method):
self.app = app.test_client()
@mock.patch.object(db_access, 'get_title_register', return_value=None)
def test_get_title_calls_db_access_to_get_title(self, mock_get_title_register):
title_number = 'title123'
self.app.get('/titles/{}'.format(title_number))
mock_get_title_register.assert_called_once_with(title_number)
@mock.patch.object(db_access, 'get_title_register', return_value=None)
def test_get_title_returns_404_response_when_db_access_returns_none(self, mock_get_title_register):
response = self.app.get('/titles/title123')
assert response.status_code == 404
assert '"error": "Title not found"' in response.data.decode()
@mock.patch.object(db_access, 'get_title_register', side_effect=TEST_EXCEPTION)
def test_get_title_returns_generic_error_response_when_db_access_fails(self, mock_get_title_register):
response = self.app.get('/titles/title123')
assert response.status_code == 500
json_body = json.loads(response.data.decode())
assert json_body == {'error': 'Internal server error'}
def test_get_title_returns_200_response_with_title_from_db_access(self):
title_number = 'title123'
register_data = {'register': 'data'}
geometry_data = {'geometry': 'data'}
sub_registers = {'sub_registers': [{'A': 'register A'}]}
title = FakeTitleRegisterData(title_number, register_data, geometry_data, sub_registers)
with mock.patch('service.server.db_access.get_title_register', return_value=title):
response = self.app.get('/titles/{}'.format(title_number))
assert response.status_code == 200
json_body = json.loads(response.data.decode())
assert json_body == {
'title_number': title_number,
'data': register_data,
'geometry_data': geometry_data,
}
class TestGetOfficialCopy:
def setup_method(self, method):
self.app = app.test_client()
@mock.patch.object(db_access, 'get_official_copy_data', return_value=None)
def test_get_official_copy_calls_db_access_to_get_the_copy(self, mock_get_official_copy_data):
title_number = 'title123'
self.app.get('/titles/{}/official-copy'.format(title_number))
mock_get_official_copy_data.assert_called_once_with(title_number)
@mock.patch.object(db_access, 'get_official_copy_data', return_value=None)
def test_get_official_copy_returns_404_response_when_db_access_returns_none(self, mock_get_official_copy_data):
title_number = 'title123'
response = self.app.get('/titles/{}/official-copy'.format(title_number))
assert response.status_code == 404
json_body = json.loads(response.data.decode())
assert json_body == {'error': 'Title not found'}
@mock.patch.object(db_access, 'get_official_copy_data', side_effect=TEST_EXCEPTION)
def test_get_official_copy_returns_generic_error_response_when_db_access_fails(self, mock_get_official_copy_data):
response = self.app.get('/titles/title123/official-copy')
assert response.status_code == 500
json_body = json.loads(response.data.decode())
assert json_body == {'error': 'Internal server error'}
def test_get_official_copy_returns_200_response_with_copy_from_db_access(self):
title_number = 'title123'
sub_registers = [{'A': 'register A'}, {'B': 'register B'}]
title = FakeTitleRegisterData(
title_number, {'register': 'data'}, {'geometry': 'data'}, {'sub_registers': sub_registers}
)
with mock.patch('service.server.db_access.get_official_copy_data', return_value=title):
response = self.app.get('/titles/{}/official-copy'.format(title_number))
assert response.status_code == 200
json_body = json.loads(response.data.decode())
assert json_body == {
'official_copy_data': {
'sub_registers': sub_registers,
'title_number': title_number,
}
}
class TestGetPropertiesForPostcode:
def setup_method(self, method):
self.app = app.test_client()
@mock.patch.dict(app.config, {'SEARCH_RESULTS_PER_PAGE': 321})
@mock.patch.object(api_client, 'get_titles_by_postcode', return_value=_get_empty_api_client())
def test_get_properties_for_postcode_calls_db_access_with_page_number_and_normalised_postcode(
self, mock_get_properties):
postcode = ' Sw11_ 2dR '
normalised_postcode = 'SW11 2DR'
page_number = 123
self.app.get('/title_search_postcode/{}?page={}'.format(postcode, page_number))
mock_get_properties.assert_called_once_with(normalised_postcode, page_number, 321)
@mock.patch.object(api_client, 'get_titles_by_postcode', return_value=_get_empty_api_client())
def test_get_properties_for_postcode_calls_es_access_with_default_page_number_when_not_provided(
self, mock_get_properties):
postcode = 'SW11 2DR'
self.app.get('/title_search_postcode/{}'.format(postcode))
mock_get_properties.assert_called_once_with(postcode, 0, _get_page_size())
@mock.patch.object(api_client, 'get_titles_by_postcode', side_effect=TEST_EXCEPTION)
def test_get_properties_for_postcode_returns_generic_error_response_when_fails(self, mock_get_properties):
response = self.app.get('/title_search_postcode/SW112DR')
assert response.status_code == 500
json_body = json.loads(response.data.decode())
assert json_body == {'error': 'Internal server error'}
@mock.patch.object(db_access, 'get_mapped_lruprn', return_value=_get_titles(1))
def test_get_properties_for_postcode_calls_db_access_with_uprn_from_elasticsearch(
self, mock_get_registers):
with mock.patch('service.server.api_client.get_titles_by_postcode') as mock_get_properties:
mock_get_properties.return_value = ES_RESULT
self.app.get('/title_search_postcode/SW11 2DR')
mock_get_registers.assert_called_once_with('1234')
@mock.patch.object(api_client, 'get_titles_by_postcode', return_value=_get_one_result_from_api_client())
@mock.patch.object(db_access, 'get_mapped_lruprn', return_value=_get_sample_uprn())
@mock.patch.object(db_access, 'get_title_number_and_register_data', return_value=_get_sample_title(1))
def test_get_properties_for_postcode_returns_response_in_correct_format(
self, mock_get_titles, mock_get_mapped_lruprn, get_title_and_register_data):
response = self.app.get('/title_search_postcode/SW11%202DR')
assert response.status_code == 200
json_body = json.loads(response.data.decode())
assert json_body == {
'number_pages': 1,
'number_results': 1,
'page_number': 0,
'titles': [
{'address': '1 INGLEWOOD HOUSE, SIDWELL STREET, EXETER, EX1 1AA', 'data': {'register': 'data 1'}, 'title_number': '1'}
]
}
@mock.patch.object(api_client, 'get_titles_by_postcode', return_value=_get_two_results_from_api_client())
@mock.patch.object(db_access, 'get_mapped_lruprn', return_value=_get_sample_uprn())
@mock.patch.object(db_access, 'get_title_number_and_register_data', return_value=_get_sample_title(1))
def test_get_properties_for_postcode_returns_titles_in_order_given_by_api_client(
self, mock_get_titles, mock_get_mapped_lruprn, get_title_and_register_data):
response = self.app.get('/title_search_postcode/SW11%202DR')
assert response.status_code == 200
json_body = json.loads(response.data.decode())
assert 'titles' in json_body
assert json_body['titles'] == [
{'address': '1 INGLEWOOD HOUSE, SIDWELL STREET, EXETER, EX1 1AA', 'data': {'register': 'data 1'}, 'title_number': '1'},
{'address': '2 INGLEWOOD HOUSE, SIDWELL STREET, EXETER, EX1 1AA', 'data': {'register': 'data 1'}, 'title_number': '1'}
]
@mock.patch.object(api_client, 'get_titles_by_postcode', return_value=_get_two_results_from_api_client())
@mock.patch.object(db_access, 'get_mapped_lruprn', return_value=_get_sample_uprn())
@mock.patch.object(db_access, 'get_title_number_and_register_data', return_value=_get_sample_title(1))
def test_get_properties_for_postcode_response_contains_requested_page_number_when_present(self,
mock_get_titles,
mock_get_mapped_lruprn,
get_title_and_register_data):
requested_page_number = 12
response = self.app.get('/title_search_postcode/SW11%202DR?page={}'.format(requested_page_number))
assert response.status_code == 200
json_body = json.loads(response.data.decode())
assert 'page_number' in json_body
assert json_body['page_number'] == requested_page_number
@mock.patch.object(api_client, 'get_titles_by_postcode', return_value=_get_api_client_response_when_es_finds_but_no_pg_result())
def test_get_properties_for_postcode_returns_requested_page_number_when_it_does_not_exist(
self, mock_get_titles):
requested_page_number = 3
page_size = 5
with mock.patch.dict(app.config, {'SEARCH_RESULTS_PER_PAGE': page_size}):
response = self.app.get('/title_search_postcode/SW11%202DR?page={}'.format(requested_page_number))
assert response.status_code == 200
json_body = json.loads(response.data.decode())
assert 'page_number' in json_body
assert json_body == {
'number_pages': 1,
'number_results': 1,
'page_number': requested_page_number,
'titles': []
}
@mock.patch.object(api_client, 'get_titles_by_postcode', return_value=_get_empty_api_client())
def test_get_properties_for_postcode_returns_right_response_when_no_results_from_api_client(self, mock_get_properties):
response = self.app.get('/title_search_postcode/SW11%202DR')
assert response.status_code == 200
json_body = json.loads(response.data.decode())
assert json_body == {'number_pages': 0, 'number_results': 0, 'page_number': 0, 'titles': []}
@mock.patch.object(api_client, 'get_titles_by_postcode', return_value=_get_api_client_response_when_es_finds_but_no_pg_result())
@mock.patch.object(db_access, 'get_mapped_lruprn', return_value=None)
def test_get_properties_for_postcode_returns_right_response_when_no_results_from_pg(
self, mock_get_titles, mock_get_mapped_lruprn):
response = self.app.get('/title_search_postcode/SW11%202DR')
assert response.status_code == 200
json_body = json.loads(response.data.decode())
assert json_body == {'number_pages': 1, 'number_results': 1, 'page_number': 0, 'titles': []}
class TestGetPropertiesForAddress:
def setup_method(self, method):
self.app = app.test_client()
@mock.patch.dict(app.config, {'SEARCH_RESULTS_PER_PAGE': 321})
@mock.patch.object(es_access, 'get_properties_for_address', return_value=[])
def test_get_properties_for_address_calls_es_access_with_page_number_and_search_term(self, mock_get_properties):
search_term = 'search term'
page_number = 123
self.app.get('/title_search_address/{}?page={}'.format(search_term, page_number))
mock_get_properties.assert_called_once_with(search_term, 321, page_number)
@mock.patch.object(es_access, 'get_properties_for_address', return_value=[])
def test_get_properties_for_address_calls_es_access_with_default_page_number_when_not_provided(
self, mock_get_properties):
search_term = 'searchterm'
self.app.get('/title_search_address/{}'.format(search_term))
mock_get_properties.assert_called_once_with(search_term, _get_page_size(), 0)
@mock.patch.object(es_access, 'get_properties_for_address', side_effect=TEST_EXCEPTION)
def test_get_properties_for_address_returns_generic_error_response_when_fails(self, mock_get_properties):
response = self.app.get('/title_search_address/searchterm')
assert response.status_code == 500
json_body = json.loads(response.data.decode())
assert json_body == {'error': 'Internal server error'}
@mock.patch.object(db_access, 'get_title_registers', return_value=_get_titles(1))
def test_get_properties_for_address_calls_db_access_with_data_from_elasticsearch(
self, mock_get_registers):
with mock.patch('service.server.es_access.get_properties_for_address') as mock_get_properties:
mock_get_properties.return_value = _get_es_address_results(1, 2, 3, 4)
self.app.get('/title_search_address/searchterm')
mock_get_registers.assert_called_once_with(['1', '2', '3', '4'])
@mock.patch.object(es_access, 'get_properties_for_address', return_value=_get_es_address_results(1, 2))
@mock.patch.object(db_access, 'get_title_registers', return_value=_get_titles(1, 2))
def test_get_properties_for_address_returns_response_in_correct_format(
self, mock_get_registers, mock_get_properties):
response = self.app.get('/title_search_address/searchterm')
assert response.status_code == 200
json_body = json.loads(response.data.decode())
assert json_body == {
'number_pages': 1,
'number_results': 2,
'page_number': 0,
'titles': [
{'data': {'register': 'data 1'}, 'title_number': '1'},
{'data': {'register': 'data 2'}, 'title_number': '2'}
]
}
@mock.patch.object(es_access, 'get_properties_for_address', return_value=_get_es_address_results(3, 1, 2))
@mock.patch.object(db_access, 'get_title_registers', return_value=_get_titles(1, 2, 3))
def test_get_properties_for_address_returns_titles_in_order_given_by_es_access(
self, mock_get_registers, mock_get_properties):
response = self.app.get('/title_search_address/searchterm')
assert response.status_code == 200
json_body = json.loads(response.data.decode())
assert 'titles' in json_body
assert json_body['titles'] == [
{'data': {'register': 'data 3'}, 'title_number': '3'},
{'data': {'register': 'data 1'}, 'title_number': '1'},
{'data': {'register': 'data 2'}, 'title_number': '2'},
]
@mock.patch.object(es_access, 'get_properties_for_address', return_value=_get_es_address_results(1, 2, total=4))
@mock.patch.object(db_access, 'get_title_registers', return_value=_get_titles(1, 2))
def test_get_properties_for_address_response_contains_right_number_of_pages_when_last_page_full(
self, mock_get_registers, mock_get_properties):
page_size = 2
with mock.patch.dict(app.config, {'SEARCH_RESULTS_PER_PAGE': page_size}):
response = self.app.get('/title_search_address/searchterm?page=1')
assert response.status_code == 200
json_body = json.loads(response.data.decode())
assert 'page_number' in json_body
assert json_body['number_pages'] == 2
@mock.patch.object(es_access, 'get_properties_for_address', return_value=_get_es_address_results(1, total=4))
@mock.patch.object(db_access, 'get_title_registers', return_value=_get_titles(1))
def test_get_properties_for_address_response_contains_right_number_of_pages_when_last_page_not_full(
self, mock_get_registers, mock_get_properties):
page_size = 2
with mock.patch.dict(app.config, {'SEARCH_RESULTS_PER_PAGE': page_size}):
response = self.app.get('/title_search_address/searchterm?page=1')
assert response.status_code == 200
json_body = json.loads(response.data.decode())
assert 'page_number' in json_body
assert json_body['number_pages'] == 2
@mock.patch.object(es_access, 'get_properties_for_address', return_value=_get_es_address_results(1, total=200))
@mock.patch.object(db_access, 'get_title_registers', return_value=_get_titles(1))
def test_get_properties_for_address_response_contains_requested_page_number_when_present(
self, mock_get_properties, mock_get_registers):
requested_page_number = 12
response = self.app.get('/title_search_address/searchterm?page={}'.format(requested_page_number))
assert response.status_code == 200
json_body = json.loads(response.data.decode())
assert 'page_number' in json_body
assert json_body['page_number'] == requested_page_number
@mock.patch.object(es_access, 'get_properties_for_address', return_value=_get_es_address_results(total=10))
@mock.patch.object(db_access, 'get_title_registers', return_value=_get_titles(1))
def test_get_properties_for_address_returns_requested_page_number_when_it_does_not_exist(
self, mock_get_registers, mock_get_properties):
requested_page_number = 3
page_size = 5
with mock.patch.dict(app.config, {'SEARCH_RESULTS_PER_PAGE': page_size}):
response = self.app.get('/title_search_address/searchterm?page={}'.format(requested_page_number))
assert response.status_code == 200
json_body = json.loads(response.data.decode())
assert 'page_number' in json_body
assert json_body == {
'number_pages': 2,
'number_results': 10,
'page_number': requested_page_number,
'titles': []
}
@mock.patch.object(es_access, 'get_properties_for_address', return_value=_get_empty_es_result())
def test_get_properties_for_address_returns_right_response_when_no_results_from_es(self, mock_get_properties):
response = self.app.get('/title_search_address/searchterm')
assert response.status_code == 200
json_body = json.loads(response.data.decode())
assert json_body == {'number_pages': 0, 'number_results': 0, 'page_number': 0, 'titles': []}
@mock.patch.object(es_access, 'get_properties_for_address', return_value=_get_es_address_results(1, total=1))
@mock.patch.object(db_access, 'get_title_registers', return_value=[])
def test_get_properties_for_address_returns_right_response_when_no_results_from_pg(
self, mock_get_registers, mock_get_properties):
response = self.app.get('/title_search_address/searchterm')
assert response.status_code == 200
json_body = json.loads(response.data.decode())
assert json_body == {'number_pages': 1, 'number_results': 1, 'page_number': 0, 'titles': []}
| 43.393136
| 135
| 0.667482
| 3,402
| 27,815
| 5.042916
| 0.063492
| 0.031476
| 0.043716
| 0.025764
| 0.894498
| 0.8692
| 0.84297
| 0.802343
| 0.783633
| 0.740208
| 0
| 0.025007
| 0.217904
| 27,815
| 640
| 136
| 43.460938
| 0.76363
| 0
| 0
| 0.578313
| 0
| 0
| 0.218695
| 0.077764
| 0
| 0
| 0
| 0
| 0.136546
| 1
| 0.104418
| false
| 0
| 0.014056
| 0.02008
| 0.154618
| 0
| 0
| 0
| 0
| null | 0
| 0
| 0
| 1
| 1
| 1
| 1
| 1
| 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
| 6
|
04cf01e57ba0b08e9893d0e5f859145e49af7fe2
| 27
|
py
|
Python
|
resources/EasyLogger/__init__.py
|
Eksno/2ITB-GithubOppgave
|
5a212aef69b4c609f67d10a08e62c65b132256a7
|
[
"Apache-2.0"
] | 1
|
2022-02-09T13:06:43.000Z
|
2022-02-09T13:06:43.000Z
|
resources/EasyLogger/__init__.py
|
Eksno/2ITB-GithubOppgave
|
5a212aef69b4c609f67d10a08e62c65b132256a7
|
[
"Apache-2.0"
] | null | null | null |
resources/EasyLogger/__init__.py
|
Eksno/2ITB-GithubOppgave
|
5a212aef69b4c609f67d10a08e62c65b132256a7
|
[
"Apache-2.0"
] | null | null | null |
from .easy_logger import *
| 13.5
| 26
| 0.777778
| 4
| 27
| 5
| 1
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0.148148
| 27
| 1
| 27
| 27
| 0.869565
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 1
| 0
| true
| 0
| 1
| 0
| 1
| 0
| 1
| 1
| 0
| null | 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 1
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| null | 0
| 0
| 0
| 0
| 0
| 0
| 1
| 0
| 1
| 0
| 1
| 0
|
0
| 6
|
b6bd42b2ee4b3c301d5669237294dd1b1371b76f
| 257
|
py
|
Python
|
exercise/__init__.py
|
deepspaceghost/deme
|
324741ee8e6ef30de5116f6018966829302796ed
|
[
"MIT"
] | null | null | null |
exercise/__init__.py
|
deepspaceghost/deme
|
324741ee8e6ef30de5116f6018966829302796ed
|
[
"MIT"
] | 6
|
2021-07-09T16:56:28.000Z
|
2022-03-12T00:58:06.000Z
|
exercise/__init__.py
|
deepspaceghost/demeter.py
|
324741ee8e6ef30de5116f6018966829302796ed
|
[
"MIT"
] | 1
|
2021-06-01T23:49:44.000Z
|
2021-06-01T23:49:44.000Z
|
from .__version__ import __title__, __description__, __url__, __version__, __author__, __author_email__, __license__, __copyright__
from exercise.main import get_exercise, other_exercises, plank_exercises, pushup_exercises, squat_exercises, all_exercises
| 85.666667
| 132
| 0.859922
| 28
| 257
| 6.357143
| 0.678571
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0.085603
| 257
| 2
| 133
| 128.5
| 0.757447
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 1
| 0
| true
| 0
| 1
| 0
| 1
| 0
| 1
| 0
| 0
| null | 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 1
| 0
| 1
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| null | 0
| 0
| 0
| 0
| 0
| 0
| 1
| 0
| 1
| 0
| 1
| 0
|
0
| 6
|
8e0d0205d598c6f53ec13a3c0c54c4d76e99c186
| 16,787
|
py
|
Python
|
modul6.py
|
L200170161/prak_ASD
|
49f94b9b551fec698afe12cf99ebbea469d8aef5
|
[
"MIT"
] | null | null | null |
modul6.py
|
L200170161/prak_ASD
|
49f94b9b551fec698afe12cf99ebbea469d8aef5
|
[
"MIT"
] | null | null | null |
modul6.py
|
L200170161/prak_ASD
|
49f94b9b551fec698afe12cf99ebbea469d8aef5
|
[
"MIT"
] | null | null | null |
#======== no 1=========#
class mhs(object): #membuat class
def __init__(self, nama, nim, kota, us): #metode pemanggil ketikan pemnuatan object terjadi
self.nama = nama
self.nim = nim
self.kota = kota
self.uang = us
def __str__(self): #metode pemanggil ketika string akan di munculkan bersama pemanggilan onject
x='Nama: '
x+= self.nama + ', NIM: '
x+= str(self.nim)+ ', Tempat tinggal: '
x+= self.kota + ', Uang Saku: '
x+= str(self.uang)
return x
def getNim(self): #metode pemanggil nim
return self.nim
a0=mhs('Falah', 10, 'Boyolali', 240000)
a1=mhs('sulu', 51, 'Sragen', 230000)
a2=mhs('sule', 2, 'Surakarta', 250000)
a3=mhs('cocol', 18, 'Surakarta', 235000)
a4=mhs('dodol', 4, 'Boyolali', 240000)
a5=mhs('dims', 31, 'Brebes', 250000)
a6=mhs('Doso', 13, 'Klaten', 245000)
a7=mhs('galowi', 5, 'Wonogiri', 245000)
a8=mhs('Janto', 23, 'Klaten', 245000)
a9= mhs('hiawa', 64, 'Karanganyar', 270000)
a10=mhs('sitik',29,'Purwodadi',265000)
daftar = [a0,a1,a2,a3,a4,a5,a6,a7,a8,a9,a10] #list dari class mhsTIF
def mergesort(A): #untuk menghitung mergeshort
if len(A) > 1:
mid = len(A) // 2 #membelah list
kiri = A[:mid] #membelah ke kiri
kanan = A[mid:] #membelah ke kanan
mergesort(kiri) #memanggil lebih lanjut mergeshort
mergesort(kanan) #untuk separuh kiri dan separuh kanan
i = 0 ; j = 0 ; k = 0
while i < len (kiri) and j < len (kanan): #while lope ini
if kiri[i].getNim() < kanan[j].getNim(): #jika loop ini
A[k] = kiri[i] #menggabungkan kedua list
i = i +1 #separuh kiri dan separuh kanan
else:
A[k] = kanan[j] #a samadengan kanan
j = j +1 #maka kanan di tambah 1
k = k+1 #dua list urut
while i < len(kiri): #ketika i lebih kecil dari len kiri
A[k]= kiri [i] #maka a samadengan kiri
i= i+1 #kiri samadengan ditambah 1
k = k +1 #k otomastis kiri dan di tambah 1
while j < len(kanan): #ketika j lebih kecil dari kanan
A[k]= kanan [j] #a samadengan kanan
j= j+1 #maka kanan di tambah 1
k = k +1 #k otomatis kanan dan di tambah 1
return A
#print 'menggabungkan' , A
def quickSort(a):
quickSortbantu(a, 0, len(a)-1) #memanggil quickshort bantu
def quickSortbantu(a,awal,akhir):
if awal <akhir:
titikBelah = partisi (a, awal, akhir) #atur elemen dan dapatkan titik belah
quickSortbantu(a, awal, titikBelah-1) #ini rekursi untuk belah sisi kiri
quickSortbantu(a, titikBelah+1, akhir) #dan belah sisi kanan
def partisi(a,awal,akhir):
nilaiPivot = a[awal].getNim() #nilai pivot di ambil dari elemen yg paling kiri disertai nim
penandakiri = awal +1 #posisi awal penandakiri
penandakanan = akhir #posisi awal penanda kanan
selesai = False
while not selesai: #loop untuk mengatur ulang posisi semua elemen
while penandakiri <= penandakanan and \
a[penandakiri].getNim() <= nilaiPivot: #sampai ketemu suatu nilai yang
penandakiri = penandakiri +1 #lebih besar dari nilai pivot
while a[penandakanan].getNim() >=nilaiPivot and penandakanan >= penandakiri:
penandakanan = penandakanan -1
if penandakanan < penandakiri: #kalau dua penanda sudah bersilangan
selesai = True #selesai dan lanjut ke penempatan pivot
else:
a[penandakiri],a[penandakanan] = a[penandakanan], a[penandakiri]
a[awal], a[penandakanan] = a[penandakanan], a[awal]
return penandakanan #fungsi mengembalikan titik belah ke pemanggil
print ("merge sort")
mergesort(daftar)
for i in daftar:
print (i) #untuk menampilkan list menggunakan mergesort dari daftar
print ('quick sort')
quickSort(daftar)
for i in daftar:
print (i) #untuk menampilkan list menggunakan quicksort dari daftar
#======== no 2=========#
def mergesort(A): #untuk menghitung mergeshort
if len(A) > 1:
mid = len(A) // 2 #membelah list
kiri = A[:mid] #membelah ke kiri
kanan = A[mid:] #membelah ke kanan
mergesort(kiri) #memanggil lebih lanjut mergeshort
mergesort(kanan) #untuk separuh kiri dan separuh kanan
i = 0 ; j = 0 ; k = 0
while i < len (kiri) and j < len (kanan): #while lope ini
if kiri[i] < kanan[j]: #jika loop ini
A[k] = kiri[i] #menggabungkan kedua list
i = i +1 #separuh kiri dan separuh kanan
else:
A[k] = kanan[j] #a samadengan kanan
j = j +1 #maka kanan di tambah 1
k = k+1 #dua list urut
while i < len(kiri): #ketika i lebih kecil dari len kiri
A[k]= kiri [i] #maka a samadengan kiri
i= i+1 #kiri samadengan ditambah 1
k = k +1 #k otomastis kiri dan di tambah 1
while j < len(kanan): #ketika j lebih kecil dari kanan
A[k]= kanan [j] #a samadengan kanan
j= j+1 #maka kanan di tambah 1
k = k +1 #k otomatis kanan dan di tambah 1
return A
#print 'menggabungkan' , A
#======== no 3=========#
from time import time as detak
from random import shuffle as kocok
k = range(6000)
kocok(k)
u_bub=k[:]
u_sel=k[:]
u_ins=k[:]
u_mrg=k[:]
u_qck=k[:]
aw=detak();bubleSort(u_bub);ak=detak();print('bubble: %g detik' %(ak-aw));
aw=detak();selectionSort(u_sel);ak=detak();print('selection: %g detik' %(ak-aw));
aw=detak();insertionSort(u_ins);ak=detak(); print('insertion: %g detik' %(ak-aw));
aw=detak();MergeSort(u_mrg);ak=detak(); print('merge: %g detik' %(ak-aw));
aw=detak();quickSort(u_qck);ak=detak(); print('quick: %g detik' %(ak-aw));
#======== no 5=========#
import random
def _merge_sort(indices, the_list):
start = indices[0]
end = indices[1]
half_way = (end - start)//2 + start
if start < half_way:
_merge_sort((start, half_way), the_list)
if half_way + 1 <= end and end - start != 1:
_merge_sort((half_way + 1, end), the_list)
sort_sub_list(the_list, indices[0], indices[1])
return the_list
def sort_sub_list(the_list, start, end):
orig_start = start
initial_start_second_list = (end - start)//2 + start + 1
list2_first_index = initial_start_second_list
new_list = []
while start < initial_start_second_list and list2_first_index <= end:
first1 = the_list[start]
first2 = the_list[list2_first_index]
if first1 > first2:
new_list.append(first2)
list2_first_index += 1
else:
new_list.append(first1)
start += 1
while start < initial_start_second_list:
new_list.append(the_list[start])
start += 1
while list2_first_index <= end:
new_list.append(the_list[list2_first_index])
list2_first_index += 1
for i in new_list:
the_list[orig_start] = i
orig_start += 1
return the_list
def merge_sort(the_list):
return _merge_sort((0, len(the_list) - 1), the_list)
print(merge_sort([13,45,12]))
#======== no 6=========#
def quickSort(L, ascending = True):
quicksorthelp(L, 0, len(L), ascending)
def quicksorthelp(L, low, high, ascending = True):
result = 0
if low < high:
pivot_location, result = Partition(L, low, high, ascending)
result += quicksorthelp(L, low, pivot_location, ascending)
result += quicksorthelp(L, pivot_location + 1, high, ascending)
return result
def Partition(L, low, high, ascending = True):
result = 0
pivot, pidx = median_of_three(L, low, high)
L[low], L[pidx] = L[pidx], L[low]
i = low + 1
for j in range(low+1, high, 1):
result += 1
if (ascending and L[j] < pivot) or (not ascending and L[j] > pivot):
L[i], L[j] = L[j], L[i]
i += 1
L[low], L[i-1] = L[i-1], L[low]
return i - 1, result
def median_of_three(L, low, high):
mid = (low+high-1)//2
a = L[low]
b = L[mid]
c = L[high-1]
if a <= b <= c:
return b, mid
if c <= b <= a:
return b, mid
if a <= c <= b:
return c, high-1
if b <= c <= a:
return c, high-1
return a, low
liste1 = list([12,4,15,124,123])
quickSort(liste1, False) # descending order
print('sorted:')
print(liste1)
#======== no 7=========#
from time import time as detak
from random import shuffle as kocok
import time
k = [i for i in range(1,6001)]
kocok(k)
def mergeSort(arr):
if len(arr) >1:
mid = len(arr)//2
L = arr[:mid]
R = arr[mid:]
mergeSort(L)
mergeSort(R)
i = j = k = 0
while i < len(L) and j < len(R):
if L[i] < R[j]:
arr[k] = L[i]
i+=1
else:
arr[k] = R[j]
j+=1
k+=1
while i < len(L):
arr[k] = L[i]
i+=1
k+=1
while j < len(R):
arr[k] = R[j]
j+=1
k+=1
def partition(arr,low,high):
i = ( low-1 )
pivot = arr[high]
for j in range(low , high):
if arr[j] <= pivot:
i = i+1
arr[i],arr[j] = arr[j],arr[i]
arr[i+1],arr[high] = arr[high],arr[i+1]
return ( i+1 )
def quickSort(arr,low,high):
if low < high:
pi = partition(arr,low,high)
quickSort(arr, low, pi-1)
quickSort(arr, pi+1, high)
import random
def _merge_sort(indices, the_list):
start = indices[0]
end = indices[1]
half_way = (end - start)//2 + start
if start < half_way:
_merge_sort((start, half_way), the_list)
if half_way + 1 <= end and end - start != 1:
_merge_sort((half_way + 1, end), the_list)
sort_sub_list(the_list, indices[0], indices[1])
def sort_sub_list(the_list, start, end):
orig_start = start
initial_start_second_list = (end - start)//2 + start + 1
list2_first_index = initial_start_second_list
new_list = []
while start < initial_start_second_list and list2_first_index <= end:
first1 = the_list[start]
first2 = the_list[list2_first_index]
if first1 > first2:
new_list.append(first2)
list2_first_index += 1
else:
new_list.append(first1)
start += 1
while start < initial_start_second_list:
new_list.append(the_list[start])
start += 1
while list2_first_index <= end:
new_list.append(the_list[list2_first_index])
list2_first_index += 1
for i in new_list:
the_list[orig_start] = i
orig_start += 1
def merge_sort(the_list):
return _merge_sort((0, len(the_list) - 1), the_list)
def quickSortMOD(L, ascending = True):
quicksorthelp(L, 0, len(L), ascending)
def quicksorthelp(L, low, high, ascending = True):
result = 0
if low < high:
pivot_location, result = Partition(L, low, high, ascending)
result += quicksorthelp(L, low, pivot_location, ascending)
result += quicksorthelp(L, pivot_location + 1, high, ascending)
return result
def Partition(L, low, high, ascending = True):
result = 0
pivot, pidx = median_of_three(L, low, high)
L[low], L[pidx] = L[pidx], L[low]
i = low + 1
for j in range(low+1, high, 1):
result += 1
if (ascending and L[j] < pivot) or (not ascending and L[j] > pivot):
L[i], L[j] = L[j], L[i]
i += 1
L[low], L[i-1] = L[i-1], L[low]
return i - 1, result
def median_of_three(L, low, high):
mid = (low+high-1)//2
a = L[low]
b = L[mid]
c = L[high-1]
if a <= b <= c:
return b, mid
if c <= b <= a:
return b, mid
if a <= c <= b:
return c, high-1
if b <= c <= a:
return c, high-1
return a, low
mer = k[:]
qui = k[:]
mer2 = k[:]
qui2 = k[:]
aw=detak();mergeSort(mer);ak=detak();print('merge : %g detik' %(ak-aw));
aw=detak();quickSort(qui,0,len(qui)-1);ak=detak();print('quick : %g detik' %(ak-aw));
aw=detak();merge_sort(mer2);print('merge mod : %g detik' %(ak-aw));
aw=detak();quickSortMOD(qui2, False);print('quick mod : %g detik' %(ak-aw));
#======== no 8=========#
from time import time as detak
from random import shuffle as kocok
import time
k = [i for i in range(1,6001)]
kocok(k)
def mergeSort(arr):
if len(arr) >1:
mid = len(arr)//2
L = arr[:mid]
R = arr[mid:]
mergeSort(L)
mergeSort(R)
i = j = k = 0
while i < len(L) and j < len(R):
if L[i] < R[j]:
arr[k] = L[i]
i+=1
else:
arr[k] = R[j]
j+=1
k+=1
while i < len(L):
arr[k] = L[i]
i+=1
k+=1
while j < len(R):
arr[k] = R[j]
j+=1
k+=1
def partition(arr,low,high):
i = ( low-1 )
pivot = arr[high]
for j in range(low , high):
if arr[j] <= pivot:
i = i+1
arr[i],arr[j] = arr[j],arr[i]
arr[i+1],arr[high] = arr[high],arr[i+1]
return ( i+1 )
def quickSort(arr,low,high):
if low < high:
pi = partition(arr,low,high)
quickSort(arr, low, pi-1)
quickSort(arr, pi+1, high)
import random
def _merge_sort(indices, the_list):
start = indices[0]
end = indices[1]
half_way = (end - start)//2 + start
if start < half_way:
_merge_sort((start, half_way), the_list)
if half_way + 1 <= end and end - start != 1:
_merge_sort((half_way + 1, end), the_list)
sort_sub_list(the_list, indices[0], indices[1])
def sort_sub_list(the_list, start, end):
orig_start = start
initial_start_second_list = (end - start)//2 + start + 1
list2_first_index = initial_start_second_list
new_list = []
while start < initial_start_second_list and list2_first_index <= end:
first1 = the_list[start]
first2 = the_list[list2_first_index]
if first1 > first2:
new_list.append(first2)
list2_first_index += 1
else:
new_list.append(first1)
start += 1
while start < initial_start_second_list:
new_list.append(the_list[start])
start += 1
while list2_first_index <= end:
new_list.append(the_list[list2_first_index])
list2_first_index += 1
for i in new_list:
the_list[orig_start] = i
orig_start += 1
def merge_sort(the_list):
return _merge_sort((0, len(the_list) - 1), the_list)
def quickSortMOD(L, ascending = True):
quicksorthelp(L, 0, len(L), ascending)
def quicksorthelp(L, low, high, ascending = True):
result = 0
if low < high:
pivot_location, result = Partition(L, low, high, ascending)
result += quicksorthelp(L, low, pivot_location, ascending)
result += quicksorthelp(L, pivot_location + 1, high, ascending)
return result
def Partition(L, low, high, ascending = True):
result = 0
pivot, pidx = median_of_three(L, low, high)
L[low], L[pidx] = L[pidx], L[low]
i = low + 1
for j in range(low+1, high, 1):
result += 1
if (ascending and L[j] < pivot) or (not ascending and L[j] > pivot):
L[i], L[j] = L[j], L[i]
i += 1
L[low], L[i-1] = L[i-1], L[low]
return i - 1, result
def median_of_three(L, low, high):
mid = (low+high-1)//2
a = L[low]
b = L[mid]
c = L[high-1]
if a <= b <= c:
return b, mid
if c <= b <= a:
return b, mid
if a <= c <= b:
return c, high-1
if b <= c <= a:
return c, high-1
return a, low
mer = k[:]
qui = k[:]
mer2 = k[:]
qui2 = k[:]
aw=detak();mergeSort(mer);ak=detak();print('merge : %g detik' %(ak-aw));
aw=detak();quickSort(qui,0,len(qui)-1);ak=detak();print('quick : %g detik' %(ak-aw));
aw=detak();merge_sort(mer2);print('merge mod : %g detik' %(ak-aw));
aw=detak();quickSortMOD(qui2, False);print('quick mod : %g detik' %(ak-aw));
| 31.733459
| 100
| 0.54703
| 2,406
| 16,787
| 3.716126
| 0.107232
| 0.032099
| 0.035231
| 0.01454
| 0.779331
| 0.769936
| 0.764232
| 0.764232
| 0.761212
| 0.761212
| 0
| 0.033068
| 0.319056
| 16,787
| 528
| 101
| 31.793561
| 0.749103
| 0.115804
| 0
| 0.834842
| 0
| 0
| 0.030697
| 0
| 0
| 0
| 0
| 0
| 0
| 1
| 0.079186
| false
| 0
| 0.024887
| 0.00905
| 0.180995
| 0.045249
| 0
| 0
| 0
| null | 0
| 0
| 0
| 0
| 1
| 1
| 1
| 1
| 1
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 1
| 0
| 0
| 0
| 0
| null | 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
|
0
| 6
|
f3ce7c46d5a9eafc1d38c94a287b281d4144f2b4
| 22,274
|
py
|
Python
|
python/tests/test_tools_misc.py
|
mrkem598/housing-insights
|
05dffebad690bf727cbcbec53128d2fb69166e4c
|
[
"MIT"
] | null | null | null |
python/tests/test_tools_misc.py
|
mrkem598/housing-insights
|
05dffebad690bf727cbcbec53128d2fb69166e4c
|
[
"MIT"
] | null | null | null |
python/tests/test_tools_misc.py
|
mrkem598/housing-insights
|
05dffebad690bf727cbcbec53128d2fb69166e4c
|
[
"MIT"
] | null | null | null |
import unittest
import sys
import os
sys.path.append(os.path.abspath(os.path.join(os.path.dirname(__file__),
os.pardir)))
import housinginsights.tools.misc as misc_tools
class ToolsMiscTestCase(unittest.TestCase):
def test_get_unique_addresses_from_str(self):
# Cases for multiple addresses delimiters #
# case 1: ';' delimiter separated addresses
address_str = '1110 Aspen Street NW; 6650 Georgia Avenue NW; ' \
'6656 Georgia Avenue NW; others'
expected_result = ['1110 Aspen Street NW', '6650 Georgia Avenue NW',
'6656 Georgia Avenue NW', 'others']
result = misc_tools.get_unique_addresses_from_str(address_str)
self.assertTrue(result, 'Failed ";" - returned empty list')
self.assertEqual(len(expected_result), len(result),
'Failed ";" - returned less/more unique '
'addresses {}'.format(result))
for address in result:
self.assertTrue(address in expected_result,
"Failed ';' delimiter case: {}".format(address))
# case 2: 'and' delimiter separated address
address_str = '1110 Aspen Street NW and 6650 Georgia Avenue NW'
expected_result = ['1110 Aspen Street NW', '6650 Georgia Avenue NW']
result = misc_tools.get_unique_addresses_from_str(address_str)
self.assertTrue(result, 'Failed " and " - returned empty list')
self.assertEqual(len(expected_result), len(result),
'Failed " and " - returned less/more unique '
'addresses {}'.format(result))
for address in result:
self.assertTrue(address in expected_result,
'Failed "and" delimiter case: {}'.format(address))
# Cases for address number ranges #
# case 3: '&' delimiter separated address
address_str = '1521 & 1523 16th Street NW'
expected_result = ['1521 16th Street NW', '1523 16th Street NW']
result = misc_tools.get_unique_addresses_from_str(address_str)
self.assertTrue(result, 'Failed "&" - returned empty list')
self.assertEqual(len(expected_result), len(result),
'Failed "&" - returned less/more unique '
'addresses {}'.format(result))
for address in result:
self.assertTrue(address in expected_result,
'Failed "&" delimiter case: {}'.format(address))
"""
Separating into multiple cases for now but it seems best to assume
+2 when given address number ranges. Examples for real data seems to
confirm this.
"""
# case 4a: '-' odd delimiter address number ranges
address_str = '1309-1313 E Street SE'
expected_result = ['1309 E Street SE', '1311 E Street SE',
'1313 E Street SE']
result = misc_tools.get_unique_addresses_from_str(address_str)
self.assertTrue(result, 'Failed odd "-" - returned empty list')
self.assertEqual(len(expected_result), len(result),
'Failed odd "-" - returned less/more unique '
'addresses {}'.format(result))
for address in result:
self.assertTrue(address in expected_result,
'Failed odd "-" delimiter case: {}'.format(address))
# case 4b: '-' even delimiter address number ranges
address_str = '4000-4008 8th Street NE'
expected_result = ['4000 8th Street NE', '4002 8th Street NE',
'4004 8th Street NE', '4006 8th Street NE',
'4008 8th Street NE']
result = misc_tools.get_unique_addresses_from_str(address_str)
self.assertTrue(result, 'Failed even "-" - returned empty list')
self.assertEqual(len(expected_result), len(result),
'Failed even "-" - returned less/more unique '
'addresses {}'.format(result))
for address in result:
self.assertTrue(address in expected_result,
'Failed even "-" delimiter case: {}'.format(
address))
# case 4c: '-' ambiguous delimiter address number ranges
address_str = '4000-4005 8th Street NE'
expected_result = ['4000 8th Street NE', '4002 8th Street NE',
'4004 8th Street NE', '4001 8th Street NE',
'4003 8th Street NE', '4005 8th Street NE']
result = misc_tools.get_unique_addresses_from_str(address_str)
self.assertTrue(result, 'Failed ambiguous "-" - returned empty list')
self.assertEqual(len(expected_result), len(result),
'Failed ambiguous "-" - returned less/more unique '
'addresses {}'.format(result))
for address in result:
self.assertTrue(address in expected_result,
'Failed ambiguous "-" delimiter case: {}'.format(
address))
# Cases for composites #
# case 5: '&' + 'and' delimiter separated addresses
address_str = '1521 & 1523 16th Street NW and 1531 Church Street NW'
expected_result = ['1521 16th Street NW', '1523 16th Street NW',
'1531 Church Street NW']
result = misc_tools.get_unique_addresses_from_str(address_str)
self.assertTrue(result, 'Failed "&" + " and " - returned empty list')
self.assertEqual(len(expected_result), len(result),
'Failed "&" + " and " - returned less/more unique '
'addresses {}'.format(result))
for address in result:
self.assertTrue(address in expected_result,
"Failed '&' + 'and' delimiter "
"composite: {}".format(address))
# case 6: both addresses delimiter and address number ranges
address_str = '1110 Aspen Street NW; 4000-4005 8th Street NE; ' \
'6650 Georgia Avenue NW; 2420-2428 14th Street NE'
expected_result = ['1110 Aspen Street NW', '4000 8th Street NE',
'4002 8th Street NE', '4004 8th Street NE',
'4001 8th Street NE', '4003 8th Street NE',
'4005 8th Street NE', '6650 Georgia Avenue NW',
'2420 14th Street NE', '2422 14th Street NE',
'2424 14th Street NE', '2426 14th Street NE',
'2428 14th Street NE']
result = misc_tools.get_unique_addresses_from_str(address_str)
self.assertTrue(result, 'Failed both number range and multiple '
'addresses delimiter - returned empty list')
self.assertEqual(len(expected_result), len(result),
'Failed both number range and multiple addresses '
'delimiter - returned less/more unique '
'addresses {}'.format(result))
for address in result:
self.assertTrue(address in expected_result,
"Failed both number range and address delimiter"
" cases: {}".format(address))
# case 7: composite of many delimiters
address_str = '4232-4238 4th Street SE and 4281-4285 6th Street SE; ' \
'1521 & 1523 16th Street NW and 1531 Church Street NW'
expected_result = ['4232 4th Street SE', '4234 4th Street SE',
'4236 4th Street SE', '4238 4th Street SE',
'4281 6th Street SE', '4283 6th Street SE',
'4285 6th Street SE', '1523 16th Street NW',
'1521 16th Street NW', '1531 Church Street NW']
result = misc_tools.get_unique_addresses_from_str(address_str)
self.assertTrue(result, 'Failed composite of many delimiter - returned '
'empty list')
self.assertEqual(len(expected_result), len(result),
'Failed composite of many delimiter - returned '
'less/more unique addresses {}'.format(result))
for address in result:
self.assertTrue(address in expected_result,
"Failed composite of many delimiter "
"cases: {}".format(address))
# case 8: single address passed
address_str = '1110 Aspen Street NW'
result = misc_tools.get_unique_addresses_from_str(address_str)
self.assertTrue(result, 'Failed single address - returned empty list')
self.assertEqual(len(result), 1,
'Failed single address - returned less/more unique '
'addresses {}'.format(result))
self.assertEqual(address_str, result[0],
'Failed single address validation: {}'.format(
result[0]))
# Messy cases involving commas #
# case 9a: simple comma delimited address numbers only
address_str = '6616, 6626 GEORGIA AVE NW'
expected_result = ['6616 GEORGIA AVE NW', '6626 GEORGIA AVE NW']
result = misc_tools.get_unique_addresses_from_str(address_str)
self.assertTrue(result, 'Failed single address number range comma '
'delimiter - returned empty list')
self.assertEqual(len(expected_result), len(result),
'Failed single address number range comma delimiter - '
'returned less/more unique addresses {}'.format(result))
for address in result:
self.assertTrue(address in expected_result,
"Failed single address number range comma "
"delimiter case: {}".format(address))
# case 9b: comma delimited address numbers only
address_str = '6606, 6606, 6616, 6626 GEORGIA AVE NW'
expected_result = ['6606 GEORGIA AVE NW', '6606 GEORGIA AVE NW',
'6616 GEORGIA AVE NW', '6626 GEORGIA AVE NW']
result = misc_tools.get_unique_addresses_from_str(address_str)
self.assertTrue(result, 'Failed multiple address number range comma '
'delimiter - returned empty list')
self.assertEqual(len(expected_result), len(result),
'Failed multiple address number range comma '
'delimiter - returned less/more unique '
'addresses {}'.format(result))
for address in result:
self.assertTrue(address in expected_result,
'Failed multiple address number range comma '
'delimiter case: {}'.format(address))
# case 9c: clean up unnecessary comma
address_str = '1864 CENTRAL PLACE, NE'
expected_result = ['1864 CENTRAL PLACE NE']
result = misc_tools.get_unique_addresses_from_str(address_str)
self.assertTrue(result, 'Failed remove extra comma - returned '
'empty list')
self.assertEqual(len(expected_result), len(result),
'Failed remove extra comma - returned less/more '
'unique addresses {}'.format(result))
for address in result:
self.assertTrue(address in expected_result,
'Failed remove extra comma case: {}'.format(
address))
# case 9d: comma delimited address numbers and street
address_str = '1860,1862,1864 CENTRAL PLACE, NE'
expected_result = ['1860 CENTRAL PLACE NE', '1862 CENTRAL PLACE NE',
'1864 CENTRAL PLACE NE']
result = misc_tools.get_unique_addresses_from_str(address_str)
self.assertTrue(result, 'Failed remove extra comma + multiple address'
' number range comma delimiter - returned '
'empty list')
self.assertEqual(len(expected_result), len(result),
'Failed remove extra comma + multiple address number '
'range comma delimiter - returned less/more '
'unique addresses {}'.format(result))
for address in result:
self.assertTrue(address in expected_result,
'Failed remove extra comma + multiple address '
'number range comma delimiter case: {}'.format(
address))
# case 10a: remove extra comma and '-' number range composite case
address_str = '1210-1214 SOUTHERN AVE, S.E.'
expected_result = ['1210 SOUTHERN AVE S.E.',
'1212 SOUTHERN AVE S.E.',
'1214 SOUTHERN AVE S.E.']
result = misc_tools.get_unique_addresses_from_str(address_str)
self.assertTrue(result, 'Failed remove extra comma + "-" - returned '
'empty list')
self.assertEqual(len(expected_result), len(result),
'Failed remove extra comma + "-" - returned less/more '
'unique addresses {}'.format(result))
for address in result:
self.assertTrue(address in expected_result,
'Failed remove extra comma + "-" case: {}'.format(
address))
# case 10b: shorthand '-' delimiter and remove extra comma composite
address_str = '1210-14 SOUTHERN AVE, S.E.'
expected_result = ['1210 SOUTHERN AVE S.E.',
'1212 SOUTHERN AVE S.E.',
'1214 SOUTHERN AVE S.E.']
result = misc_tools.get_unique_addresses_from_str(address_str)
self.assertTrue(result, 'Failed shorthand "-" + remove extra comma '
'composite - returned empty list')
self.assertEqual(len(expected_result), len(result),
'Failed shorthand "-" + remove extra comma - returned '
'less/more unique addresses {}'.format(result))
for address in result:
self.assertTrue(address in expected_result,
'Failed shorthand "-" + remove extra comma '
'composite: {}'.format(address))
# case 11: '&' and comma delimiter composite
address_str = '24, 52, & 230 BATES ST NW'
expected_result = ['230 BATES ST NW', '24 BATES ST NW',
'52 BATES ST NW']
result = misc_tools.get_unique_addresses_from_str(address_str)
self.assertTrue(result, 'Failed "&" + comma composite - returned empty '
'list')
self.assertEqual(len(expected_result), len(result),
'Failed "&" and comma composite - returned less/more '
'unique addresses {}'.format(result))
for address in result:
self.assertTrue(address in expected_result,
'Failed "&" and comma composite: {}'.format(
address))
# case 12: funky '&' case clean up and remove extra comma - invalid
# building address
address_str = 'HAYES STREET &ANACOSTIA AVENUE, NORTH EAST'
expected_result = ['HAYES STREET & ANACOSTIA AVENUE NORTH EAST']
result = misc_tools.get_unique_addresses_from_str(address_str)
self.assertTrue(result, 'Failed funky "&" clean up - returned empty '
'list')
self.assertEqual(len(expected_result), len(result),
'Failed funky "&" clean up - returned less/more '
'unique addresses {}'.format(result))
for address in result:
self.assertTrue(address in expected_result,
'Failed funky "&" clean up case: {}'.format(
address))
# case 13: '-', '&', and comma address number range composite
address_str = '1416-1420,1432,1436 & 1440 R ST NW'
expected_result = ['1440 R ST NW', '1420 R ST NW',
'1432 R ST NW', '1436 R ST NW',
'1416 R ST NW', '1418 R ST NW']
result = misc_tools.get_unique_addresses_from_str(address_str)
self.assertTrue(result, 'Failed "-" + "&" + comma composite - returned '
'empty list')
self.assertEqual(len(result), len(expected_result),
'Failed "-" + "&" + comma composite - returned '
'less/more unique addresses {}'.format(result))
for address in result:
self.assertTrue(address in expected_result,
'Failed "-" + "&" + comma composite '
'case: {}'.format(address))
# 'dirty' cases - return original string
# case 14a: invalid '&' with address number
address_str = '1416-1440 R & 14th ST NW'
expected_result = ['1416-1440 R & 14th ST NW']
result = misc_tools.get_unique_addresses_from_str(address_str)
self.assertTrue(result, 'Failed handling invalid "&" - '
'returned empty list')
self.assertEqual(len(result), len(expected_result),
'Failed handling invalid "&" - returned '
'less/more unique addresses {}'.format(result))
for address in result:
self.assertTrue(address in expected_result,
'Failed handling invalid "&" case: {}'.format(
address))
# case 14b: invalid '&' (intersections)
address_str = 'HAYES STREET &ANACOSTIA AVENUE NORTH EAST'
expected_result = ['HAYES STREET &ANACOSTIA AVENUE NORTH EAST']
result = misc_tools.get_unique_addresses_from_str(address_str)
self.assertTrue(result, 'Failed handling invalid "&" - '
'returned empty list')
self.assertEqual(len(result), len(expected_result),
'Failed handling invalid "&" - returned '
'less/more unique addresses {}'.format(result))
for address in result:
self.assertTrue(address in expected_result,
'Failed handling invalid "&" case: {}'.format(
address))
# case 15a: incomplete dash address number range
address_str = '1416- R ST NW'
expected_result = ['1416- R ST NW']
result = misc_tools.get_unique_addresses_from_str(address_str)
self.assertTrue(result, 'Failed incomplete dash address number - '
'returned empty list')
self.assertEqual(len(result), len(expected_result),
'Failed incomplete dash address number - returned '
'less/more unique addresses {}'.format(result))
for address in result:
self.assertTrue(address in expected_result,
'Failed incomplete dash address number '
'case: {}'.format(address))
# case 15b: incomplete comma address number range
address_str = '1416, R ST NW'
expected_result = ['1416, R ST NW']
result = misc_tools.get_unique_addresses_from_str(address_str)
self.assertTrue(result, 'Failed incomplete comma address number - '
'returned empty list')
self.assertEqual(len(result), len(expected_result),
'Failed incomplete comma address number - returned '
'less/more unique addresses {}'.format(result))
for address in result:
self.assertTrue(address in expected_result,
'Failed incomplete comma address number '
'case: {}'.format(address))
# case 15c: incomplete ampersand address number range
address_str = '1416 & R ST NW'
expected_result = ['1416 & R ST NW']
result = misc_tools.get_unique_addresses_from_str(address_str)
self.assertTrue(result, 'Failed incomplete ampersand address number - '
'returned empty list')
self.assertEqual(len(result), len(expected_result),
'Failed incomplete ampersand address number - '
'returned less/more unique addresses {}'.format(
result))
for address in result:
self.assertTrue(address in expected_result,
'Failed incomplete ampersand address number '
'case: {}'.format(address))
# case 16: multiple contiguous '-', '&', ',': assuming invalid address
address_str = '1416 && 1418 R ST NW; 1416--1418 R ST NW; ' \
'1416,, 1418 R ST NW; 1416 &-, 1418 R ST NW'
expected_result = ['1416 && 1418 R ST NW', '1416--1418 R ST NW',
'1416,, 1418 R ST NW', '1416 &-, 1418 R ST NW']
result = misc_tools.get_unique_addresses_from_str(address_str)
self.assertTrue(result, 'Failed multiple contiguous range delimiter - '
'returned empty list')
self.assertEqual(len(result), len(expected_result),
'Failed multiple contiguous range delimiter - '
'returned less/more unique addresses {}'.format(
result))
for address in result:
self.assertTrue(address in expected_result,
'Failed multiple contiguous range delimiter '
'case: {}'.format(address))
if __name__ == '__main__':
unittest.main()
| 55.40796
| 81
| 0.553201
| 2,286
| 22,274
| 5.273841
| 0.092301
| 0.072661
| 0.051427
| 0.047445
| 0.840909
| 0.809058
| 0.771151
| 0.721384
| 0.720886
| 0.710932
| 0
| 0.048355
| 0.358445
| 22,274
| 401
| 82
| 55.546135
| 0.795311
| 0.063707
| 0
| 0.520958
| 0
| 0
| 0.327419
| 0
| 0
| 0
| 0
| 0
| 0.224551
| 1
| 0.002994
| false
| 0
| 0.011976
| 0
| 0.017964
| 0
| 0
| 0
| 0
| null | 0
| 0
| 0
| 1
| 1
| 1
| 1
| 1
| 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
| 6
|
f3d4ba41ce8f7af69c55d46be1d733b32e65f449
| 5,702
|
py
|
Python
|
dashboard/views.py
|
devqueue/assaydashboard
|
550a5392abb366d7b0cefbe9ce4141538a8ff801
|
[
"MIT"
] | null | null | null |
dashboard/views.py
|
devqueue/assaydashboard
|
550a5392abb366d7b0cefbe9ce4141538a8ff801
|
[
"MIT"
] | null | null | null |
dashboard/views.py
|
devqueue/assaydashboard
|
550a5392abb366d7b0cefbe9ce4141538a8ff801
|
[
"MIT"
] | null | null | null |
from django.shortcuts import render
import pandas as pd
from dashboard.models import Utilization, Samples, Revenue, monthlystats
from dashboard.serializers import UtilizationSerializer, SamplesSerializer, RevenueSerializer, monthlystatsSerializer
from dashboard.viewfuncs import index_context, sample_context, util_context, revenue_context
# Create your views here.
def indexpage(request):
samples_obj = Samples.objects.all()
revenue_obj = Revenue.objects.all()
samples_serializer = SamplesSerializer(samples_obj, many=True)
revenue_serializer = RevenueSerializer(revenue_obj, many=True)
samples_df = pd.DataFrame(samples_serializer.data)
revenue_df = pd.DataFrame(revenue_serializer.data)
if not samples_df.empty:
years = samples_df['Year'].unique()
machines = samples_df['MachineID'].unique()
months = [col for col in samples_df.columns if col not in ('AssayID', 'Assay', 'Year', 'MachineID')]
if request.method == 'POST':
YEAR = request.POST['year']
MONTH = request.POST['month']
MACHINE = request.POST['assay']
context = index_context(YEAR, MONTH, MACHINE, samples_df, revenue_df)
return render(request, 'dashboard/index.html', context)
else:
if samples_df.empty:
return render(request, 'dashboard/index.html', {})
else:
YEAR = years[0]
MONTH = months[0]
MACHINE = machines[0]
context = index_context(YEAR, MONTH, MACHINE, samples_df, revenue_df)
return render(request, 'dashboard/index.html', context)
def sample(request):
samples_obj = Samples.objects.all()
monthlystats_obj = monthlystats.objects.all()
samples_serializer = SamplesSerializer(samples_obj, many=True)
monthlystats_serializer = monthlystatsSerializer(monthlystats_obj, many=True)
samples_df = pd.DataFrame(samples_serializer.data)
monthlystats_df = pd.DataFrame(monthlystats_serializer.data)
if not samples_df.empty:
years = samples_df['Year'].unique()
months = [col for col in samples_df.columns if col not in ('AssayID', 'Assay', 'Year', 'MachineID')]
machines = samples_df['MachineID'].unique()
if request.method == 'POST':
YEAR = request.POST['year']
MONTH = request.POST['month']
YEAR2 = request.POST['year2']
MACHINE = request.POST['assay2']
context = sample_context(YEAR, MONTH, YEAR2, MACHINE, samples_df, monthlystats_df)
return render(request, 'dashboard/sample.html', context)
else:
if samples_df.empty:
return render(request, 'dashboard/sample.html', {})
else:
YEAR = years[0]
MONTH = months[0]
YEAR2 = years[0]
MACHINE = machines[0]
context = sample_context(YEAR, MONTH, YEAR2, MACHINE, samples_df, monthlystats_df)
return render(request, 'dashboard/sample.html', context)
def util(request):
util_obj = Utilization.objects.all()
monthlystats_obj = monthlystats.objects.all()
util_serializer = UtilizationSerializer(util_obj, many=True)
monthlystats_serializer = monthlystatsSerializer(monthlystats_obj, many=True)
util_df = pd.DataFrame(util_serializer.data)
monthlystats_df = pd.DataFrame(monthlystats_serializer.data)
if not util_df.empty:
years = util_df['Year'].unique()
months = [col for col in util_df.columns if col not in ('AssayID', 'Assay', 'Year', 'MachineID')]
machines = util_df['MachineID'].unique()
if request.method == 'POST':
YEAR = request.POST['year']
MONTH = request.POST['month']
YEAR2 = request.POST['year2']
MACHINE = request.POST['assay2']
context = util_context(YEAR, MONTH, YEAR2 , MACHINE, util_df, monthlystats_df)
return render(request, 'dashboard/utilization.html', context)
else:
if util_df.empty:
return render(request, 'dashboard/utilization.html', {})
else:
YEAR = years[0]
MONTH = months[0]
YEAR2 = years[0]
MACHINE = machines[0]
context = util_context(YEAR, MONTH, YEAR2 , MACHINE, util_df, monthlystats_df)
return render(request, 'dashboard/utilization.html', context)
def revenue(request):
revenue_obj = Revenue.objects.all()
monthlystats_obj = monthlystats.objects.all()
revenue_serializer = RevenueSerializer(revenue_obj, many=True)
monthlystats_serializer = monthlystatsSerializer(monthlystats_obj, many=True)
revenue_df = pd.DataFrame(revenue_serializer.data)
monthlystats_df = pd.DataFrame(monthlystats_serializer.data)
if not revenue_df.empty:
years = revenue_df['Year'].unique()
months = [col for col in revenue_df.columns if col not in ('AssayID', 'Assay', 'Year', 'MachineID')]
machines = revenue_df['MachineID'].unique()
if request.method == 'POST':
YEAR = request.POST['year']
MONTH = request.POST['month']
YEAR2 = request.POST['year2']
MACHINE = request.POST['assay2']
context = revenue_context(YEAR, MONTH, YEAR2 , MACHINE, revenue_df, monthlystats_df)
return render(request, 'dashboard/revenue.html', context)
else:
if revenue_df.empty:
return render(request, 'dashboard/revenue.html')
else:
YEAR = years[0]
MONTH = months[0]
YEAR2 = years[0]
MACHINE = machines[0]
context = revenue_context(YEAR, MONTH, YEAR2 , MACHINE, revenue_df, monthlystats_df)
return render(request, 'dashboard/revenue.html', context)
| 36.088608
| 117
| 0.66047
| 640
| 5,702
| 5.746875
| 0.101563
| 0.039152
| 0.06199
| 0.091354
| 0.848559
| 0.825992
| 0.783306
| 0.710712
| 0.686786
| 0.656063
| 0
| 0.007515
| 0.229919
| 5,702
| 157
| 118
| 36.318471
| 0.830107
| 0.004034
| 0
| 0.765217
| 0
| 0
| 0.089707
| 0.036482
| 0
| 0
| 0
| 0
| 0
| 1
| 0.034783
| false
| 0
| 0.043478
| 0
| 0.182609
| 0
| 0
| 0
| 0
| null | 0
| 0
| 0
| 1
| 1
| 1
| 1
| 0
| 1
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 1
| 0
| 0
| 0
| 0
| null | 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
|
0
| 6
|
f3dbe6da8bfa628f6318a86f680cde2f634c87e3
| 293
|
py
|
Python
|
deepdrive_zero/envs/__init__.py
|
farhanhubble/deep-drive-zero-experiments
|
6170986aada389986604053019ee91345d7a972b
|
[
"MIT"
] | 30
|
2020-02-15T09:46:36.000Z
|
2022-03-18T08:16:52.000Z
|
deepdrive_zero/envs/__init__.py
|
farhanhubble/deep-drive-zero-experiments
|
6170986aada389986604053019ee91345d7a972b
|
[
"MIT"
] | 6
|
2020-02-05T05:53:53.000Z
|
2020-02-10T20:17:13.000Z
|
deepdrive_zero/envs/__init__.py
|
deepdrive/deepdrive-2d
|
53796f84a49f29eadc1c43284e77bd4717a1e2d1
|
[
"MIT"
] | 4
|
2020-02-15T19:07:23.000Z
|
2020-04-04T17:48:32.000Z
|
from deepdrive_zero.envs.env import Deepdrive2DEnv
from deepdrive_zero.envs.variants import OneWaypointSteerOnlyEnv, \
OneWaypointEnv, IncentArrivalEnv, StaticObstacleEnv, \
NoGforcePenaltyEnv, SixtyFpsEnv, IntersectionEnv, IntersectionWithGsEnv, \
IntersectionWithGsAllowDecelEnv
| 48.833333
| 78
| 0.843003
| 22
| 293
| 11.136364
| 0.772727
| 0.106122
| 0.138776
| 0.171429
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0.003817
| 0.105802
| 293
| 5
| 79
| 58.6
| 0.931298
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 1
| 0
| true
| 0
| 0.4
| 0
| 0.4
| 0
| 1
| 0
| 1
| null | 0
| 0
| 1
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 1
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| null | 0
| 0
| 0
| 0
| 0
| 0
| 1
| 0
| 1
| 0
| 0
| 0
|
0
| 6
|
f3ef87ad11a0cf1a073a9bfb8b0107a021d28d76
| 211
|
py
|
Python
|
skfda/misc/__init__.py
|
jdtuck/scikit-fda
|
28259dffbc45dfc8dbf3c12839b928f9df200351
|
[
"BSD-3-Clause"
] | null | null | null |
skfda/misc/__init__.py
|
jdtuck/scikit-fda
|
28259dffbc45dfc8dbf3c12839b928f9df200351
|
[
"BSD-3-Clause"
] | null | null | null |
skfda/misc/__init__.py
|
jdtuck/scikit-fda
|
28259dffbc45dfc8dbf3c12839b928f9df200351
|
[
"BSD-3-Clause"
] | null | null | null |
from . import covariances, kernels, metrics
from . import operators
from . import regularization
from ._math import (log, log2, log10, exp, sqrt, cumsum,
inner_product, inner_product_matrix)
| 35.166667
| 56
| 0.71564
| 25
| 211
| 5.88
| 0.68
| 0.204082
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0.018072
| 0.21327
| 211
| 5
| 57
| 42.2
| 0.86747
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 1
| 0
| true
| 0
| 0.8
| 0
| 0.8
| 0
| 1
| 0
| 0
| null | 1
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 1
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| null | 0
| 0
| 0
| 0
| 0
| 0
| 1
| 0
| 1
| 0
| 1
| 0
|
0
| 6
|
6d52fc0c687fb8a840da459bb530687acbb44fb7
| 119
|
py
|
Python
|
test.py
|
irenepal/snakemake-cnvseq
|
a66acbf7286b001f1afbb582854b85b750ffa33e
|
[
"MIT"
] | 4
|
2020-08-12T09:42:50.000Z
|
2022-03-11T03:39:04.000Z
|
test.py
|
irenepal/snakemake-cnvseq
|
a66acbf7286b001f1afbb582854b85b750ffa33e
|
[
"MIT"
] | null | null | null |
test.py
|
irenepal/snakemake-cnvseq
|
a66acbf7286b001f1afbb582854b85b750ffa33e
|
[
"MIT"
] | 3
|
2019-07-26T10:12:16.000Z
|
2022-02-01T19:21:33.000Z
|
import subprocess
def test_pipeline():
subprocess.check_call(["snakemake", "-n", "--configfile", "config.yaml"])
| 19.833333
| 77
| 0.689076
| 13
| 119
| 6.153846
| 0.923077
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0.117647
| 119
| 5
| 78
| 23.8
| 0.761905
| 0
| 0
| 0
| 0
| 0
| 0.285714
| 0
| 0
| 0
| 0
| 0
| 0
| 1
| 0.333333
| true
| 0
| 0.333333
| 0
| 0.666667
| 0
| 1
| 0
| 0
| null | 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 1
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| null | 0
| 0
| 0
| 0
| 0
| 1
| 1
| 0
| 1
| 0
| 1
| 0
|
0
| 6
|
ed8f063b4ee8f16b24a6702c00b6270e004f2410
| 71
|
py
|
Python
|
flask_app/__init__.py
|
shubham192/red-data
|
e641f1cd7f9c9e85d2729b1417a8decde12ff37b
|
[
"Fair"
] | null | null | null |
flask_app/__init__.py
|
shubham192/red-data
|
e641f1cd7f9c9e85d2729b1417a8decde12ff37b
|
[
"Fair"
] | 2
|
2021-02-08T20:18:44.000Z
|
2021-04-30T20:32:42.000Z
|
flask_app/__init__.py
|
shubham192/red-data
|
e641f1cd7f9c9e85d2729b1417a8decde12ff37b
|
[
"Fair"
] | null | null | null |
from flask import Flask
app = Flask(__name__)
import flask_app.views
| 11.833333
| 23
| 0.788732
| 11
| 71
| 4.636364
| 0.545455
| 0.431373
| 0.54902
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0.15493
| 71
| 5
| 24
| 14.2
| 0.85
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 1
| 0
| false
| 0
| 0.666667
| 0
| 0.666667
| 0
| 1
| 0
| 0
| null | 1
| 1
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 1
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| null | 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 1
| 0
| 1
| 0
|
0
| 6
|
ed905bfbba27b0d862492262e3eca37b8bb27de4
| 11,069
|
py
|
Python
|
mayan/apps/linking/tests/test_api.py
|
kyper999/mayan-edms
|
ca7b8301a1f68548e8e718d42a728a500d67286e
|
[
"Apache-2.0"
] | 1
|
2020-07-15T02:56:02.000Z
|
2020-07-15T02:56:02.000Z
|
mayan/apps/linking/tests/test_api.py
|
kyper999/mayan-edms
|
ca7b8301a1f68548e8e718d42a728a500d67286e
|
[
"Apache-2.0"
] | null | null | null |
mayan/apps/linking/tests/test_api.py
|
kyper999/mayan-edms
|
ca7b8301a1f68548e8e718d42a728a500d67286e
|
[
"Apache-2.0"
] | null | null | null |
from __future__ import unicode_literals
from django.contrib.auth import get_user_model
from django.core.urlresolvers import reverse
from django.test import override_settings
from rest_framework.exceptions import ValidationError
from rest_framework.test import APITestCase
from documents.models import DocumentType
from documents.tests.literals import (
TEST_DOCUMENT_TYPE, TEST_SMALL_DOCUMENT_PATH
)
from user_management.tests.literals import (
TEST_ADMIN_EMAIL, TEST_ADMIN_PASSWORD, TEST_ADMIN_USERNAME
)
from ..models import SmartLink, SmartLinkCondition
from .literals import (
TEST_SMART_LINK_CONDITION_FOREIGN_DOCUMENT_DATA,
TEST_SMART_LINK_CONDITION_EXPRESSION,
TEST_SMART_LINK_CONDITION_EXPRESSION_EDITED,
TEST_SMART_LINK_CONDITION_OPERATOR, TEST_SMART_LINK_DYNAMIC_LABEL,
TEST_SMART_LINK_LABEL_EDITED, TEST_SMART_LINK_LABEL
)
@override_settings(OCR_AUTO_OCR=False)
class SmartLinkAPITestCase(APITestCase):
def setUp(self):
self.admin_user = get_user_model().objects.create_superuser(
username=TEST_ADMIN_USERNAME, email=TEST_ADMIN_EMAIL,
password=TEST_ADMIN_PASSWORD
)
self.client.login(
username=TEST_ADMIN_USERNAME, password=TEST_ADMIN_PASSWORD
)
def tearDown(self):
if hasattr(self, 'document_type'):
self.document_type.delete()
def _create_document_type(self):
self.document_type = DocumentType.objects.create(
label=TEST_DOCUMENT_TYPE
)
def _create_document(self):
with open(TEST_SMALL_DOCUMENT_PATH) as file_object:
self.document = self.document_type.new_document(
file_object=file_object
)
def _create_smart_link(self):
return SmartLink.objects.create(
label=TEST_SMART_LINK_LABEL,
dynamic_label=TEST_SMART_LINK_DYNAMIC_LABEL
)
def test_smart_link_create_view(self):
response = self.client.post(
reverse('rest_api:smartlink-list'), {
'label': TEST_SMART_LINK_LABEL
}
)
smart_link = SmartLink.objects.first()
self.assertEqual(response.data['id'], smart_link.pk)
self.assertEqual(response.data['label'], TEST_SMART_LINK_LABEL)
self.assertEqual(SmartLink.objects.count(), 1)
self.assertEqual(smart_link.label, TEST_SMART_LINK_LABEL)
def test_smart_link_create_with_document_types_view(self):
self._create_document_type()
response = self.client.post(
reverse('rest_api:smartlink-list'), data={
'label': TEST_SMART_LINK_LABEL,
'document_types_pk_list': self.document_type.pk
},
)
smart_link = SmartLink.objects.first()
self.assertEqual(response.data['id'], smart_link.pk)
self.assertEqual(response.data['label'], TEST_SMART_LINK_LABEL)
self.assertEqual(SmartLink.objects.count(), 1)
self.assertEqual(smart_link.label, TEST_SMART_LINK_LABEL)
self.assertQuerysetEqual(
smart_link.document_types.all(), (repr(self.document_type),)
)
def test_smart_link_delete_view(self):
smart_link = self._create_smart_link()
self.client.delete(
reverse('rest_api:smartlink-detail', args=(smart_link.pk,))
)
self.assertEqual(SmartLink.objects.count(), 0)
def test_smart_link_detail_view(self):
smart_link = self._create_smart_link()
response = self.client.get(
reverse('rest_api:smartlink-detail', args=(smart_link.pk,))
)
self.assertEqual(
response.data['label'], TEST_SMART_LINK_LABEL
)
def test_smart_link_patch_view(self):
self._create_document_type()
smart_link = self._create_smart_link()
self.client.patch(
reverse('rest_api:smartlink-detail', args=(smart_link.pk,)),
data={
'label': TEST_SMART_LINK_LABEL_EDITED,
'document_types_pk_list': self.document_type.pk
}
)
smart_link.refresh_from_db()
self.assertEqual(smart_link.label, TEST_SMART_LINK_LABEL_EDITED)
self.assertQuerysetEqual(
smart_link.document_types.all(), (repr(self.document_type),)
)
def test_smart_link_put_view(self):
smart_link = self._create_smart_link()
self.client.put(
reverse('rest_api:smartlink-detail', args=(smart_link.pk,)),
data={
'label': TEST_SMART_LINK_LABEL_EDITED,
}
)
smart_link.refresh_from_db()
self.assertEqual(smart_link.label, TEST_SMART_LINK_LABEL_EDITED)
@override_settings(OCR_AUTO_OCR=False)
class SmartLinkConditionAPITestCase(APITestCase):
def setUp(self):
self.admin_user = get_user_model().objects.create_superuser(
username=TEST_ADMIN_USERNAME, email=TEST_ADMIN_EMAIL,
password=TEST_ADMIN_PASSWORD
)
self.client.login(
username=TEST_ADMIN_USERNAME, password=TEST_ADMIN_PASSWORD
)
def tearDown(self):
if hasattr(self, 'document_type'):
self.document_type.delete()
def _create_document_type(self):
self.document_type = DocumentType.objects.create(
label=TEST_DOCUMENT_TYPE
)
def _create_document(self):
with open(TEST_SMALL_DOCUMENT_PATH) as file_object:
self.document = self.document_type.new_document(
file_object=file_object
)
def _create_smart_link(self):
self.smart_link = SmartLink.objects.create(
label=TEST_SMART_LINK_LABEL,
dynamic_label=TEST_SMART_LINK_DYNAMIC_LABEL
)
self.smart_link.document_types.add(self.document_type)
def _create_smart_link_condition(self):
self.smart_link_condition = SmartLinkCondition.objects.create(
smart_link=self.smart_link,
foreign_document_data=TEST_SMART_LINK_CONDITION_FOREIGN_DOCUMENT_DATA,
expression=TEST_SMART_LINK_CONDITION_EXPRESSION,
operator=TEST_SMART_LINK_CONDITION_OPERATOR
)
def test_resolved_smart_link_detail_view(self):
self._create_document_type()
self._create_smart_link()
self._create_smart_link_condition()
self._create_document()
response = self.client.get(
reverse(
'rest_api:resolvedsmartlink-detail',
args=(self.document.pk, self.smart_link.pk)
)
)
self.assertEqual(
response.data['label'], TEST_SMART_LINK_LABEL
)
def test_resolved_smart_link_list_view(self):
self._create_document_type()
self._create_smart_link()
self._create_smart_link_condition()
self._create_document()
response = self.client.get(
reverse(
'rest_api:resolvedsmartlink-list', args=(self.document.pk,)
)
)
self.assertEqual(
response.data['results'][0]['label'], TEST_SMART_LINK_LABEL
)
def test_resolved_smart_link_document_list_view(self):
self._create_document_type()
self._create_smart_link()
self._create_smart_link_condition()
self._create_document()
response = self.client.get(
reverse(
'rest_api:resolvedsmartlinkdocument-list',
args=(self.document.pk, self.smart_link.pk)
)
)
self.assertEqual(
response.data['results'][0]['label'], self.document.label
)
def test_smart_link_condition_create_view(self):
self._create_document_type()
self._create_smart_link()
response = self.client.post(
reverse(
'rest_api:smartlinkcondition-list', args=(self.smart_link.pk,)
), {
'foreign_document_data': TEST_SMART_LINK_CONDITION_FOREIGN_DOCUMENT_DATA,
'expression': TEST_SMART_LINK_CONDITION_EXPRESSION,
'operator': TEST_SMART_LINK_CONDITION_OPERATOR
}
)
smart_link_condition = SmartLinkCondition.objects.first()
self.assertEqual(response.data['id'], smart_link_condition.pk)
self.assertEqual(
response.data['operator'], TEST_SMART_LINK_CONDITION_OPERATOR
)
self.assertEqual(SmartLinkCondition.objects.count(), 1)
self.assertEqual(
smart_link_condition.operator, TEST_SMART_LINK_CONDITION_OPERATOR
)
def test_smart_link_condition_delete_view(self):
self._create_document_type()
self._create_smart_link()
self._create_smart_link_condition()
self.client.delete(
reverse(
'rest_api:smartlinkcondition-detail',
args=(self.smart_link.pk, self.smart_link_condition.pk)
)
)
self.assertEqual(SmartLinkCondition.objects.count(), 0)
def test_smart_link_condition_detail_view(self):
self._create_document_type()
self._create_smart_link()
self._create_smart_link_condition()
response = self.client.get(
reverse(
'rest_api:smartlinkcondition-detail',
args=(self.smart_link.pk, self.smart_link_condition.pk)
)
)
self.assertEqual(
response.data['operator'], TEST_SMART_LINK_CONDITION_OPERATOR
)
def test_smart_link_condition_patch_view(self):
self._create_document_type()
self._create_smart_link()
self._create_smart_link_condition()
self.client.patch(
reverse(
'rest_api:smartlinkcondition-detail',
args=(self.smart_link.pk, self.smart_link_condition.pk)
),
data={
'expression': TEST_SMART_LINK_CONDITION_EXPRESSION_EDITED,
}
)
self.smart_link_condition.refresh_from_db()
self.assertEqual(
self.smart_link_condition.expression,
TEST_SMART_LINK_CONDITION_EXPRESSION_EDITED
)
def test_smart_link_condition_put_view(self):
self._create_document_type()
self._create_smart_link()
self._create_smart_link_condition()
self.client.put(
reverse(
'rest_api:smartlinkcondition-detail',
args=(self.smart_link.pk, self.smart_link_condition.pk)
),
data={
'expression': TEST_SMART_LINK_CONDITION_EXPRESSION_EDITED,
'foreign_document_data': TEST_SMART_LINK_CONDITION_FOREIGN_DOCUMENT_DATA,
'operator': TEST_SMART_LINK_CONDITION_OPERATOR,
}
)
self.smart_link_condition.refresh_from_db()
self.assertEqual(
self.smart_link_condition.expression,
TEST_SMART_LINK_CONDITION_EXPRESSION_EDITED
)
| 32.365497
| 89
| 0.65182
| 1,212
| 11,069
| 5.518977
| 0.081683
| 0.158768
| 0.097174
| 0.078936
| 0.884736
| 0.839438
| 0.814621
| 0.75811
| 0.732247
| 0.707729
| 0
| 0.000861
| 0.265155
| 11,069
| 341
| 90
| 32.460411
| 0.82149
| 0
| 0
| 0.582418
| 0
| 0
| 0.059716
| 0.045442
| 0
| 0
| 0
| 0
| 0.091575
| 1
| 0.091575
| false
| 0.018315
| 0.040293
| 0.003663
| 0.142857
| 0
| 0
| 0
| 0
| null | 0
| 0
| 0
| 1
| 1
| 1
| 1
| 1
| 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
| 6
|
edf4d246b701a9f00b1e3a7e1d34c380f54ba347
| 19,365
|
py
|
Python
|
tests/cli/v2_1_1/test_sda.py
|
AltusConsulting/dnacentercli
|
26ea46fdbd40fc30649ea1d8803158655aa545aa
|
[
"MIT"
] | null | null | null |
tests/cli/v2_1_1/test_sda.py
|
AltusConsulting/dnacentercli
|
26ea46fdbd40fc30649ea1d8803158655aa545aa
|
[
"MIT"
] | null | null | null |
tests/cli/v2_1_1/test_sda.py
|
AltusConsulting/dnacentercli
|
26ea46fdbd40fc30649ea1d8803158655aa545aa
|
[
"MIT"
] | null | null | null |
# -*- coding: utf-8 -*-
"""DNACenterAPI SDA API fixtures and tests.
Copyright (c) 2019 Cisco and/or its affiliates.
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 click
import pytest
from json import loads
from tests.environment import DNA_CENTER_VERSION
pytestmark = pytest.mark.skipif(DNA_CENTER_VERSION != '2.1.1', reason='version does not match')
def is_valid_get_sda_fabric_info(result):
data = result.output.strip()
return True if data else False
@pytest.mark.sda
def test_get_sda_fabric_info(runner, cli, auth_options):
result = runner.invoke(cli, ['-v', '2.1.1', *auth_options,
'sda', 'get-sda-fabric-info',
"""--fabric_name='string'"""])
assert not result.exception
assert is_valid_get_sda_fabric_info(result)
def is_valid_add_ip_pool_in_sda_virtual_network(result):
data = result.output.strip()
return True if data else False
@pytest.mark.sda
def test_add_ip_pool_in_sda_virtual_network(runner, cli, auth_options):
result = runner.invoke(cli, ['-v', '2.1.1', *auth_options,
'sda', 'add-ip-pool-in-sda-virtual-network',
"""--active_validation=True""",
"""--payload='{"virtualNetworkName": "string", "ipPoolName": "string", "trafficType": "string", "authenticationPolicyName": "string", "scalableGroupName": "string", "isL2FloodingEnabled": true, "isThisCriticalPool": true, "poolType": "string"}'"""])
assert not result.exception
assert is_valid_add_ip_pool_in_sda_virtual_network(result)
def is_valid_get_device_info(result):
data = result.output.strip()
return True if data else False
@pytest.mark.sda
def test_get_device_info(runner, cli, auth_options):
result = runner.invoke(cli, ['-v', '2.1.1', *auth_options,
'sda', 'get-device-info',
"""--device_ipaddress='string'"""])
assert not result.exception
assert is_valid_get_device_info(result)
def is_valid_delete_port_assignment_for_access_point(result):
data = result.output.strip()
return True if data else False
@pytest.mark.sda
def test_delete_port_assignment_for_access_point(runner, cli, auth_options):
result = runner.invoke(cli, ['-v', '2.1.1', *auth_options,
'sda', 'delete-port-assignment-for-access-point',
"""--device_ip='string'""",
"""--interface_name='string'"""])
assert not result.exception
assert is_valid_delete_port_assignment_for_access_point(result)
def is_valid_delete_edge_device(result):
data = result.output.strip()
return True if data else False
@pytest.mark.sda
def test_delete_edge_device(runner, cli, auth_options):
result = runner.invoke(cli, ['-v', '2.1.1', *auth_options,
'sda', 'delete-edge-device',
"""--device_ipaddress='string'"""])
assert not result.exception
assert is_valid_delete_edge_device(result)
def is_valid_get_vn(result):
data = result.output.strip()
return True if data else False
@pytest.mark.sda
def test_get_vn(runner, cli, auth_options):
result = runner.invoke(cli, ['-v', '2.1.1', *auth_options,
'sda', 'get-vn',
"""--site_name_hierarchy='string'""",
"""--virtual_network_name='string'"""])
assert not result.exception
assert is_valid_get_vn(result)
def is_valid_delete_site(result):
data = result.output.strip()
return True if data else False
@pytest.mark.sda
def test_delete_site(runner, cli, auth_options):
result = runner.invoke(cli, ['-v', '2.1.1', *auth_options,
'sda', 'delete-site',
"""--site_name_hierarchy='string'"""])
assert not result.exception
assert is_valid_delete_site(result)
def is_valid_delete_default_authentication_profile(result):
data = result.output.strip()
return True if data else False
@pytest.mark.sda
def test_delete_default_authentication_profile(runner, cli, auth_options):
result = runner.invoke(cli, ['-v', '2.1.1', *auth_options,
'sda', 'delete-default-authentication-profile',
"""--site_name_hierarchy='string'"""])
assert not result.exception
assert is_valid_delete_default_authentication_profile(result)
def is_valid_get_port_assignment_for_access_point(result):
data = result.output.strip()
return True if data else False
@pytest.mark.sda
def test_get_port_assignment_for_access_point(runner, cli, auth_options):
result = runner.invoke(cli, ['-v', '2.1.1', *auth_options,
'sda', 'get-port-assignment-for-access-point',
"""--device_ip='string'""",
"""--interface_name='string'"""])
assert not result.exception
assert is_valid_get_port_assignment_for_access_point(result)
def is_valid_delete_ip_pool_from_sda_virtual_network(result):
data = result.output.strip()
return True if data else False
@pytest.mark.sda
def test_delete_ip_pool_from_sda_virtual_network(runner, cli, auth_options):
result = runner.invoke(cli, ['-v', '2.1.1', *auth_options,
'sda', 'delete-ip-pool-from-sda-virtual-network',
"""--ip_pool_name='string'""",
"""--virtual_network_name='string'"""])
assert not result.exception
assert is_valid_delete_ip_pool_from_sda_virtual_network(result)
def is_valid_get_edge_device(result):
data = result.output.strip()
return True if data else False
@pytest.mark.sda
def test_get_edge_device(runner, cli, auth_options):
result = runner.invoke(cli, ['-v', '2.1.1', *auth_options,
'sda', 'get-edge-device',
"""--device_ipaddress='string'"""])
assert not result.exception
assert is_valid_get_edge_device(result)
def is_valid_add_vn(result):
data = result.output.strip()
return True if data else False
@pytest.mark.sda
def test_add_vn(runner, cli, auth_options):
result = runner.invoke(cli, ['-v', '2.1.1', *auth_options,
'sda', 'add-vn',
"""--active_validation=True""",
"""--payload='{"virtualNetworkName": "string", "siteNameHierarchy": "string"}'"""])
assert not result.exception
assert is_valid_add_vn(result)
def is_valid_update_default_authentication_profile(result):
data = result.output.strip()
return True if data else False
@pytest.mark.sda
def test_update_default_authentication_profile(runner, cli, auth_options):
result = runner.invoke(cli, ['-v', '2.1.1', *auth_options,
'sda', 'update-default-authentication-profile',
"""--active_validation=True""",
"""--payload='{"siteNameHierarchy": "string", "authenticateTemplateName": "string"}'"""])
assert not result.exception
assert is_valid_update_default_authentication_profile(result)
def is_valid_add_fabric(result):
data = result.output.strip()
return True if data else False
@pytest.mark.sda
def test_add_fabric(runner, cli, auth_options):
result = runner.invoke(cli, ['-v', '2.1.1', *auth_options,
'sda', 'add-fabric',
"""--active_validation=True""",
"""--payload='{"fabricName": "string"}'"""])
assert not result.exception
assert is_valid_add_fabric(result)
def is_valid_get_site(result):
data = result.output.strip()
return True if data else False
@pytest.mark.sda
def test_get_site(runner, cli, auth_options):
result = runner.invoke(cli, ['-v', '2.1.1', *auth_options,
'sda', 'get-site',
"""--site_name_hierarchy='string'"""])
assert not result.exception
assert is_valid_get_site(result)
def is_valid_add_edge_device(result):
data = result.output.strip()
return True if data else False
@pytest.mark.sda
def test_add_edge_device(runner, cli, auth_options):
result = runner.invoke(cli, ['-v', '2.1.1', *auth_options,
'sda', 'add-edge-device',
"""--active_validation=True""",
"""--payload='{"deviceManagementIpAddress": "string", "siteNameHierarchy": "string"}'"""])
assert not result.exception
assert is_valid_add_edge_device(result)
def is_valid_get_default_authentication_profile(result):
data = result.output.strip()
return True if data else False
@pytest.mark.sda
def test_get_default_authentication_profile(runner, cli, auth_options):
result = runner.invoke(cli, ['-v', '2.1.1', *auth_options,
'sda', 'get-default-authentication-profile',
"""--site_name_hierarchy='string'"""])
assert not result.exception
assert is_valid_get_default_authentication_profile(result)
def is_valid_get_control_plane_device(result):
data = result.output.strip()
return True if data else False
@pytest.mark.sda
def test_get_control_plane_device(runner, cli, auth_options):
result = runner.invoke(cli, ['-v', '2.1.1', *auth_options,
'sda', 'get-control-plane-device',
"""--device_ipaddress='string'"""])
assert not result.exception
assert is_valid_get_control_plane_device(result)
def is_valid_gets_border_device_detail(result):
data = result.output.strip()
return True if data else False
@pytest.mark.sda
def test_gets_border_device_detail(runner, cli, auth_options):
result = runner.invoke(cli, ['-v', '2.1.1', *auth_options,
'sda', 'gets-border-device-detail',
"""--device_ipaddress='string'"""])
assert not result.exception
assert is_valid_gets_border_device_detail(result)
def is_valid_add_port_assignment_for_user_device(result):
data = result.output.strip()
return True if data else False
@pytest.mark.sda
def test_add_port_assignment_for_user_device(runner, cli, auth_options):
result = runner.invoke(cli, ['-v', '2.1.1', *auth_options,
'sda', 'add-port-assignment-for-user-device',
"""--active_validation=True""",
"""--payload='{"siteNameHierarchy": "string", "deviceManagementIpAddress": "string", "interfaceName": "string", "dataIpAddressPoolName": "string", "voiceIpAddressPoolName": "string", "authenticateTemplateName": "string"}'"""])
assert not result.exception
assert is_valid_add_port_assignment_for_user_device(result)
def is_valid_add_default_authentication_profile(result):
data = result.output.strip()
return True if data else False
@pytest.mark.sda
def test_add_default_authentication_profile(runner, cli, auth_options):
result = runner.invoke(cli, ['-v', '2.1.1', *auth_options,
'sda', 'add-default-authentication-profile',
"""--active_validation=True""",
"""--payload='{"siteNameHierarchy": "string", "authenticateTemplateName": "string"}'"""])
assert not result.exception
assert is_valid_add_default_authentication_profile(result)
def is_valid_get_port_assignment_for_user_device(result):
data = result.output.strip()
return True if data else False
@pytest.mark.sda
def test_get_port_assignment_for_user_device(runner, cli, auth_options):
result = runner.invoke(cli, ['-v', '2.1.1', *auth_options,
'sda', 'get-port-assignment-for-user-device',
"""--device_ip='string'""",
"""--interface_name='string'"""])
assert not result.exception
assert is_valid_get_port_assignment_for_user_device(result)
def is_valid_delete_vn(result):
data = result.output.strip()
return True if data else False
@pytest.mark.sda
def test_delete_vn(runner, cli, auth_options):
result = runner.invoke(cli, ['-v', '2.1.1', *auth_options,
'sda', 'delete-vn',
"""--site_name_hierarchy='string'""",
"""--virtual_network_name='string'"""])
assert not result.exception
assert is_valid_delete_vn(result)
def is_valid_add_site(result):
data = result.output.strip()
return True if data else False
@pytest.mark.sda
def test_add_site(runner, cli, auth_options):
result = runner.invoke(cli, ['-v', '2.1.1', *auth_options,
'sda', 'add-site',
"""--active_validation=True""",
"""--payload='{"fabricName": "string", "siteNameHierarchy": "string"}'"""])
assert not result.exception
assert is_valid_add_site(result)
def is_valid_delete_port_assignment_for_user_device(result):
data = result.output.strip()
return True if data else False
@pytest.mark.sda
def test_delete_port_assignment_for_user_device(runner, cli, auth_options):
result = runner.invoke(cli, ['-v', '2.1.1', *auth_options,
'sda', 'delete-port-assignment-for-user-device',
"""--device_ip='string'""",
"""--interface_name='string'"""])
assert not result.exception
assert is_valid_delete_port_assignment_for_user_device(result)
def is_valid_adds_border_device(result):
data = result.output.strip()
return True if data else False
@pytest.mark.sda
def test_adds_border_device(runner, cli, auth_options):
result = runner.invoke(cli, ['-v', '2.1.1', *auth_options,
'sda', 'adds-border-device',
"""--active_validation=True""",
"""--payload='{"deviceManagementIpAddress": "string", "siteNameHierarchy": "string", "externalDomainRoutingProtocolName": "string", "externalConnectivityIpPoolName": "string", "internalAutonomouSystemNumber": "string", "borderSessionType": "string", "connectedToInternet": true, "externalConnectivitySettings": [{"interfaceName": "string", "externalAutonomouSystemNumber": "string", "l3Handoff": [{"virtualNetwork": {"virtualNetworkName": "string"}}]}]}'"""])
assert not result.exception
assert is_valid_adds_border_device(result)
def is_valid_add_port_assignment_for_access_point(result):
data = result.output.strip()
return True if data else False
@pytest.mark.sda
def test_add_port_assignment_for_access_point(runner, cli, auth_options):
result = runner.invoke(cli, ['-v', '2.1.1', *auth_options,
'sda', 'add-port-assignment-for-access-point',
"""--active_validation=True""",
"""--payload='{"siteNameHierarchy": "string", "deviceManagementIpAddress": "string", "interfaceName": "string", "dataIpAddressPoolName": "string", "voiceIpAddressPoolName": "string", "authenticateTemplateName": "string"}'"""])
assert not result.exception
assert is_valid_add_port_assignment_for_access_point(result)
def is_valid_add_control_plane_device(result):
data = result.output.strip()
return True if data else False
@pytest.mark.sda
def test_add_control_plane_device(runner, cli, auth_options):
result = runner.invoke(cli, ['-v', '2.1.1', *auth_options,
'sda', 'add-control-plane-device',
"""--active_validation=True""",
"""--payload='{"deviceManagementIpAddress": "string", "siteNameHierarchy": "string"}'"""])
assert not result.exception
assert is_valid_add_control_plane_device(result)
def is_valid_deletes_border_device(result):
data = result.output.strip()
return True if data else False
@pytest.mark.sda
def test_deletes_border_device(runner, cli, auth_options):
result = runner.invoke(cli, ['-v', '2.1.1', *auth_options,
'sda', 'deletes-border-device',
"""--device_ipaddress='string'"""])
assert not result.exception
assert is_valid_deletes_border_device(result)
def is_valid_delete_sda_fabric(result):
data = result.output.strip()
return True if data else False
@pytest.mark.sda
def test_delete_sda_fabric(runner, cli, auth_options):
result = runner.invoke(cli, ['-v', '2.1.1', *auth_options,
'sda', 'delete-sda-fabric',
"""--fabric_name='string'"""])
assert not result.exception
assert is_valid_delete_sda_fabric(result)
def is_valid_delete_control_plane_device(result):
data = result.output.strip()
return True if data else False
@pytest.mark.sda
def test_delete_control_plane_device(runner, cli, auth_options):
result = runner.invoke(cli, ['-v', '2.1.1', *auth_options,
'sda', 'delete-control-plane-device',
"""--device_ipaddress='string'"""])
assert not result.exception
assert is_valid_delete_control_plane_device(result)
def is_valid_get_ip_pool_from_sda_virtual_network(result):
data = result.output.strip()
return True if data else False
@pytest.mark.sda
def test_get_ip_pool_from_sda_virtual_network(runner, cli, auth_options):
result = runner.invoke(cli, ['-v', '2.1.1', *auth_options,
'sda', 'get-ip-pool-from-sda-virtual-network',
"""--ip_pool_name='string'""",
"""--virtual_network_name='string'"""])
assert not result.exception
assert is_valid_get_ip_pool_from_sda_virtual_network(result)
| 38.807615
| 492
| 0.630571
| 2,298
| 19,365
| 5.06658
| 0.087903
| 0.038478
| 0.008503
| 0.060466
| 0.858284
| 0.849437
| 0.818947
| 0.787769
| 0.774714
| 0.74723
| 0
| 0.007264
| 0.246476
| 19,365
| 498
| 493
| 38.885542
| 0.790639
| 0.058663
| 0
| 0.55814
| 0
| 0
| 0.07295
| 0.038736
| 0
| 0
| 0
| 0
| 0.186047
| 1
| 0.186047
| false
| 0
| 0.011628
| 0
| 0.290698
| 0
| 0
| 0
| 0
| null | 0
| 0
| 0
| 1
| 1
| 1
| 1
| 1
| 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
| 6
|
edf547a1039ff4c30d4e43a80111a53c6045a174
| 2,407
|
py
|
Python
|
src/tests/part2/q529_test_mine_sweeper.py
|
hychrisli/PyAlgorithms
|
71e537180f3b371d0d2cc47b11cb68ec13a8ac68
|
[
"Apache-2.0"
] | null | null | null |
src/tests/part2/q529_test_mine_sweeper.py
|
hychrisli/PyAlgorithms
|
71e537180f3b371d0d2cc47b11cb68ec13a8ac68
|
[
"Apache-2.0"
] | null | null | null |
src/tests/part2/q529_test_mine_sweeper.py
|
hychrisli/PyAlgorithms
|
71e537180f3b371d0d2cc47b11cb68ec13a8ac68
|
[
"Apache-2.0"
] | null | null | null |
from src.base.test_cases import TestCases
class MineSweeperTestCases(TestCases):
def __init__(self):
super(MineSweeperTestCases, self).__init__()
self.__add_test_case__('Test 1',
([['E', 'E', 'E', 'E', 'E'],
['E', 'E', 'M', 'E', 'E'],
['E', 'E', 'E', 'E', 'E'],
['E', 'E', 'E', 'E', 'E']], [3, 0]),
[['B', '1', 'E', '1', 'B'],
['B', '1', 'M', '1', 'B'],
['B', '1', '1', '1', 'B'],
['B', 'B', 'B', 'B', 'B']]
)
self.__add_test_case__('Test 2',
([['B', '1', 'E', '1', 'B'],
['B', '1', 'M', '1', 'B'],
['B', '1', '1', '1', 'B'],
['B', 'B', 'B', 'B', 'B']], [1, 2]),
[['B', '1', 'E', '1', 'B'],
['B', '1', 'X', '1', 'B'],
['B', '1', '1', '1', 'B'],
['B', 'B', 'B', 'B', 'B']]
)
self.__add_test_case__('Test 3',
([['E', 'E', 'E', 'E', 'E'],
['E', 'E', 'M', 'E', 'E'],
['E', 'M', 'E', 'M', 'E'],
['E', 'E', 'E', 'E', 'E']], [0, 2]),
[['E', 'E', '1', 'E', 'E'],
['E', 'E', 'M', 'E', 'E'],
['E', 'M', 'E', 'M', 'E'],
['E', 'E', 'E', 'E', 'E']]
)
self.__add_test_case__('Test 4',
([['E', 'E', 'E', 'E', 'E'],
['E', 'E', 'M', 'E', 'E'],
['E', 'M', 'E', 'M', 'E'],
['E', 'E', 'E', 'E', 'E']], [0, 0]),
[['B', '1', 'E', 'E', 'E'],
['1', '2', 'M', 'E', 'E'],
['E', 'M', 'E', 'M', 'E'],
['E', 'E', 'E', 'E', 'E']]
)
| 44.574074
| 69
| 0.163689
| 209
| 2,407
| 1.727273
| 0.114833
| 0.34903
| 0.398892
| 0.376731
| 0.639889
| 0.529086
| 0.529086
| 0.529086
| 0.504155
| 0.504155
| 0
| 0.036561
| 0.57956
| 2,407
| 53
| 70
| 45.415094
| 0.320158
| 0
| 0
| 0.5
| 0
| 0
| 0.076444
| 0
| 0
| 0
| 0
| 0
| 0
| 1
| 0.022727
| false
| 0
| 0.022727
| 0
| 0.068182
| 0
| 0
| 0
| 1
| null | 1
| 1
| 1
| 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
| 6
|
612c74fa6ed9b99711a964e8a8f541882f44f62b
| 218
|
py
|
Python
|
end2you/data_provider/hdf5/__init__.py
|
VincentKaras/end2you
|
2e49bc825ddf98dd49215ec2317247985de9070e
|
[
"BSD-3-Clause"
] | 85
|
2018-01-18T20:11:25.000Z
|
2022-03-29T19:51:22.000Z
|
end2you/data_provider/hdf5/__init__.py
|
VincentKaras/end2you
|
2e49bc825ddf98dd49215ec2317247985de9070e
|
[
"BSD-3-Clause"
] | 7
|
2018-02-27T22:43:37.000Z
|
2021-11-22T20:57:49.000Z
|
end2you/data_provider/hdf5/__init__.py
|
VincentKaras/end2you
|
2e49bc825ddf98dd49215ec2317247985de9070e
|
[
"BSD-3-Clause"
] | 18
|
2018-02-20T15:05:59.000Z
|
2022-02-25T15:25:57.000Z
|
from .audio_provider import AudioProvider
from .visual_provider import VisualProvider
from .multifile_audiovisual_provider import MultiFile_AVProvider
from .singlefile_audiovisual_provider import SingleFile_AVProvider
| 43.6
| 66
| 0.908257
| 24
| 218
| 7.916667
| 0.458333
| 0.294737
| 0.263158
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0.073395
| 218
| 4
| 67
| 54.5
| 0.940594
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 1
| 0
| true
| 0
| 1
| 0
| 1
| 0
| 1
| 0
| 0
| null | 1
| 1
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 1
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| null | 0
| 0
| 0
| 0
| 0
| 0
| 1
| 0
| 1
| 0
| 0
| 0
|
0
| 6
|
b620d5febabb5a11efb8ae9b0611be633b4f2b8f
| 31
|
py
|
Python
|
Adafruit_MAX31856/__init__.py
|
johnrbnsn/Adafruit_Python_MAX31856
|
785eb2396c65302ca6521ca7264996a8c2c24600
|
[
"MIT"
] | 15
|
2017-01-02T22:22:47.000Z
|
2021-04-20T19:13:54.000Z
|
Adafruit_MAX31856/__init__.py
|
johnrbnsn/Adafruit_Python_MAX31856
|
785eb2396c65302ca6521ca7264996a8c2c24600
|
[
"MIT"
] | 17
|
2016-12-08T16:17:46.000Z
|
2020-04-22T16:32:22.000Z
|
Adafruit_MAX31856/__init__.py
|
johnrbnsn/Adafruit_Python_MAX31856
|
785eb2396c65302ca6521ca7264996a8c2c24600
|
[
"MIT"
] | 14
|
2016-12-08T16:16:52.000Z
|
2019-04-23T03:36:41.000Z
|
from .max31856 import MAX31856
| 15.5
| 30
| 0.83871
| 4
| 31
| 6.5
| 0.75
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0.37037
| 0.129032
| 31
| 1
| 31
| 31
| 0.592593
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 1
| 0
| true
| 0
| 1
| 0
| 1
| 0
| 1
| 1
| 0
| null | 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 1
| 0
| 0
| 1
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| null | 0
| 0
| 0
| 0
| 0
| 0
| 1
| 0
| 1
| 0
| 0
| 0
|
0
| 6
|
b647c8845567d2fc9842b0e30b327c2b17ad1ddd
| 120
|
py
|
Python
|
clubadmin/memadmin/test_logic.py
|
rpmoseley/clubadmin
|
35d0094ea5e97e8478ca021ab8e422cebbc26263
|
[
"MIT"
] | null | null | null |
clubadmin/memadmin/test_logic.py
|
rpmoseley/clubadmin
|
35d0094ea5e97e8478ca021ab8e422cebbc26263
|
[
"MIT"
] | null | null | null |
clubadmin/memadmin/test_logic.py
|
rpmoseley/clubadmin
|
35d0094ea5e97e8478ca021ab8e422cebbc26263
|
[
"MIT"
] | null | null | null |
'''
This module exists purely to check how to import test cases in the test suite
'''
def ex_function():
return True
| 17.142857
| 77
| 0.725
| 20
| 120
| 4.3
| 0.9
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0.2
| 120
| 6
| 78
| 20
| 0.895833
| 0.641667
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 1
| 0.5
| true
| 0
| 0
| 0.5
| 1
| 0
| 1
| 0
| 0
| null | 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 1
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| null | 0
| 0
| 0
| 0
| 0
| 1
| 1
| 0
| 0
| 1
| 1
| 0
|
0
| 6
|
fcbb5fe47a847cdfe9926a75416e0fb5eae2b559
| 17,214
|
py
|
Python
|
qa_tool/tests/test_relevancy_score.py
|
pg-irc/pathways-backend
|
05a8c4e750523d2d081b030a248c5444d1ed7992
|
[
"BSD-3-Clause"
] | 12
|
2017-08-30T18:21:00.000Z
|
2021-12-09T04:04:17.000Z
|
qa_tool/tests/test_relevancy_score.py
|
pg-irc/pathways-backend
|
05a8c4e750523d2d081b030a248c5444d1ed7992
|
[
"BSD-3-Clause"
] | 424
|
2017-08-08T18:32:14.000Z
|
2022-03-30T21:42:51.000Z
|
qa_tool/tests/test_relevancy_score.py
|
pg-irc/pathways-backend
|
05a8c4e750523d2d081b030a248c5444d1ed7992
|
[
"BSD-3-Clause"
] | 7
|
2017-09-29T21:14:37.000Z
|
2019-12-30T21:07:37.000Z
|
import datetime
from test_plus.test import TestCase
from qa_tool.tests.helpers import RelevancyScoreBuilder, AlgorithmBuilder, SearchLocationBuilder
from rest_framework import status
from rest_framework.authtoken.models import Token
from rest_framework.test import APIClient
from human_services.services_at_location.tests.helpers import ServiceAtLocationBuilder
from newcomers_guide.tests.helpers import create_topic
from common.testhelpers.random_test_values import an_integer, a_string
class GETRelevancyScoreTests(TestCase):
def setUp(self):
self.user = self.make_user()
self.token = Token.objects.create(user=self.user)
self.APIClient = APIClient()
self.data = {
'value': an_integer(),
'algorithm': AlgorithmBuilder().create().id,
'search_location': SearchLocationBuilder().create().id,
'service_at_location': ServiceAtLocationBuilder().create().id,
'topic': create_topic(a_string()).id,
}
def test_can_get_one_entity_unauthenticated(self):
score_value = an_integer()
score = RelevancyScoreBuilder(self.user).with_value(score_value).create()
url = '/qa/v1/relevancyscores/{0}/'.format(score.pk)
response = self.APIClient.get(url)
self.assertEqual(response.status_code, status.HTTP_200_OK)
self.assertEqual(response.json()['value'], score_value)
def test_can_get_entities_unauthenticated(self):
RelevancyScoreBuilder(self.user).create()
RelevancyScoreBuilder(self.user).create()
url = '/qa/v1/relevancyscores/'
response = self.APIClient.get(url)
self.assertEqual(response.status_code, status.HTTP_200_OK)
self.assertEqual(len(response.json()), 2)
def test_cannot_get_non_existent_entity_unauthenticated(self):
url = '/qa/v1/relevancyscores/0/'
response = self.APIClient.get(url)
self.assertEqual(response.status_code, status.HTTP_404_NOT_FOUND)
class DELETERelevancyScoreTests(TestCase):
def setUp(self):
self.user = self.make_user()
self.token = Token.objects.create(user=self.user)
self.APIClient = APIClient()
self.data = {
'value': an_integer(),
'algorithm': AlgorithmBuilder().create().id,
'search_location': SearchLocationBuilder().create().id,
'service_at_location': ServiceAtLocationBuilder().create().id,
'topic': create_topic(a_string()).id,
}
def test_can_delete(self):
self.APIClient.credentials(HTTP_AUTHORIZATION='Token ' + self.token.key)
score = RelevancyScoreBuilder(self.user).create()
url = '/qa/v1/relevancyscores/{0}/'.format(score.pk)
response = self.APIClient.delete(url)
self.assertEqual(response.status_code, status.HTTP_204_NO_CONTENT)
def test_cannot_delete_unauthenticated(self):
score = RelevancyScoreBuilder(self.user).create()
url = '/qa/v1/relevancyscores/{0}/'.format(score.pk)
response = self.APIClient.delete(url)
self.assertEqual(response.status_code, status.HTTP_401_UNAUTHORIZED)
def test_cannot_delete_non_existent_entity(self):
self.APIClient.credentials(HTTP_AUTHORIZATION='Token ' + self.token.key)
url = '/qa/v1/relevancyscores/0/'
response = self.APIClient.delete(url)
self.assertEqual(response.status_code, status.HTTP_404_NOT_FOUND)
class PUTRelevancyScoreTests(TestCase):
def setUp(self):
self.user = self.make_user()
self.new_user = self.make_user(username='testuser2')
self.token = Token.objects.create(user=self.user)
self.APIClient = APIClient()
self.sample_score = RelevancyScoreBuilder(self.user).create()
self.data = {
'value': an_integer(),
'algorithm': AlgorithmBuilder().create().id,
'search_location': SearchLocationBuilder().create().id,
'service_at_location': ServiceAtLocationBuilder().create().id,
'topic': create_topic(a_string()).id,
}
def test_can_put_value(self):
self.APIClient.credentials(HTTP_AUTHORIZATION='Token ' + self.token.key)
new_value = an_integer()
self.data['value'] = new_value
url = '/qa/v1/relevancyscores/{0}/'.format(self.sample_score.pk)
response = self.APIClient.put(url, self.data)
self.assertEqual(response.status_code, status.HTTP_200_OK)
self.assertEqual(response.json()['value'], new_value)
def test_can_put_algorithm(self):
self.APIClient.credentials(HTTP_AUTHORIZATION='Token ' + self.token.key)
new_algorithm = AlgorithmBuilder().create()
self.data['algorithm'] = new_algorithm.id
url = '/qa/v1/relevancyscores/{0}/'.format(self.sample_score.pk)
response = self.APIClient.put(url, self.data)
self.assertEqual(response.status_code, status.HTTP_200_OK)
self.assertEqual(response.json()['algorithm'], new_algorithm.id)
def test_can_put_search_location(self):
self.APIClient.credentials(HTTP_AUTHORIZATION='Token ' + self.token.key)
new_search_location = SearchLocationBuilder().create()
self.data['search_location'] = new_search_location.id
url = '/qa/v1/relevancyscores/{0}/'.format(self.sample_score.pk)
response = self.APIClient.put(url, self.data)
self.assertEqual(response.status_code, status.HTTP_200_OK)
self.assertEqual(response.json()['search_location'], new_search_location.id)
def test_can_put_service_at_location(self):
self.APIClient.credentials(HTTP_AUTHORIZATION='Token ' + self.token.key)
new_service_at_location = ServiceAtLocationBuilder().create()
self.data['service_at_location'] = new_service_at_location.id
url = '/qa/v1/relevancyscores/{0}/'.format(self.sample_score.pk)
response = self.APIClient.put(url, self.data)
self.assertEqual(response.status_code, status.HTTP_200_OK)
self.assertEqual(response.json()['service_at_location'], new_service_at_location.id)
def test_can_put_topic(self):
self.APIClient.credentials(HTTP_AUTHORIZATION='Token ' + self.token.key)
new_topic = create_topic(a_string())
self.data['topic'] = new_topic.id
url = '/qa/v1/relevancyscores/{0}/'.format(self.sample_score.pk)
response = self.APIClient.put(url, self.data)
self.assertEqual(response.status_code, status.HTTP_200_OK)
self.assertEqual(response.json()['topic'], new_topic.id)
def test_put_response_has_new_time_stamp(self):
url = '/qa/v1/relevancyscores/{0}/'.format(self.sample_score.pk)
self.APIClient.credentials(HTTP_AUTHORIZATION='Token ' + self.token.key)
response = self.APIClient.put(url, self.data)
self.assertEqual(response.status_code, status.HTTP_200_OK)
recreated_time = datetime.datetime.strptime(response.json()['time_stamp'], '%Y-%m-%dT%H:%M:%S.%fZ')
self.assertLessEqual(recreated_time, datetime.datetime.now())
self.assertGreaterEqual(recreated_time + datetime.timedelta(seconds=1), datetime.datetime.now())
def test_can_put_with_different_credential(self):
new_token = Token.objects.create(user=self.new_user)
self.APIClient.credentials(HTTP_AUTHORIZATION='Token ' + new_token.key)
new_value = an_integer()
self.data['value'] = new_value
url = '/qa/v1/relevancyscores/{0}/'.format(self.sample_score.pk)
response = self.APIClient.put(url, self.data)
self.assertEqual(response.status_code, status.HTTP_200_OK)
self.assertEqual(response.json()['user'], self.new_user.id)
self.assertEqual(response.json()['value'], new_value)
def test_cannot_put_id(self):
self.APIClient.credentials(HTTP_AUTHORIZATION='Token ' + self.token.key)
new_id = an_integer()
self.data['id'] = new_id
url = '/qa/v1/relevancyscores/{0}/'.format(self.sample_score.pk)
response = self.APIClient.put(url, self.data)
self.assertEqual(response.status_code, status.HTTP_400_BAD_REQUEST)
self.assertEqual(response.json(), 'id of relevancyscore is immutable')
def test_cannot_put_user(self):
self.APIClient.credentials(HTTP_AUTHORIZATION='Token ' + self.token.key)
self.data['user'] = self.new_user.id
url = '/qa/v1/relevancyscores/{0}/'.format(self.sample_score.pk)
response = self.APIClient.put(url, self.data)
self.assertEqual(response.status_code, status.HTTP_400_BAD_REQUEST)
self.assertEqual(response.json(), 'user_id of relevancyscore is immutable')
def test_cannot_put_unauthenticated(self):
url = '/qa/v1/relevancyscores/{0}/'.format(self.sample_score.pk)
self.data['value'] = an_integer()
response = self.APIClient.put(url, self.data)
self.assertEqual(response.status_code, status.HTTP_401_UNAUTHORIZED)
def test_cannot_put_non_existent_entity(self):
url = '/qa/v1/relevancyscores/0/'
self.APIClient.credentials(HTTP_AUTHORIZATION='Token ' + self.token.key)
response = self.APIClient.put(url, self.data)
self.assertEqual(response.status_code, status.HTTP_404_NOT_FOUND)
class POSTRelevancyScoreTests(TestCase):
def setUp(self):
self.user = self.make_user()
self.token = Token.objects.create(user=self.user)
self.APIClient = APIClient()
self.score_value = an_integer()
self.data_without_algorithm_in_body = {
'value': self.score_value,
'search_location': SearchLocationBuilder().create().id,
'service_at_location': ServiceAtLocationBuilder().create().id,
'topic': create_topic('test').id,
}
self.data_with_algorithm_in_body = {
'value': self.score_value,
'algorithm': AlgorithmBuilder().create().id,
'search_location': SearchLocationBuilder().create().id,
'service_at_location': ServiceAtLocationBuilder().create().id,
'topic': create_topic(a_string()).id,
}
def test_can_post_with_algorithm_in_body_not_in_url_short_url(self):
self.APIClient.credentials(HTTP_AUTHORIZATION='Token ' + self.token.key)
url = '/qa/v1/relevancyscores/'
response = self.APIClient.post(url, data=self.data_with_algorithm_in_body)
self.assertEqual(response.status_code, status.HTTP_201_CREATED)
self.assertEqual(response.json()['value'], self.score_value)
def test_can_post_with_algorithm_in_url_not_in_body_long_url(self):
self.APIClient.credentials(HTTP_AUTHORIZATION='Token ' + self.token.key)
algorithm = AlgorithmBuilder().create()
url = '/qa/v1/algorithms/{0}/relevancyscores/'.format(algorithm.pk)
response = self.APIClient.post(url, data=self.data_without_algorithm_in_body)
self.assertEqual(response.status_code, status.HTTP_201_CREATED)
self.assertEqual(response.json()['value'], self.score_value)
def test_post_response_has_correct_algorithm(self):
self.APIClient.credentials(HTTP_AUTHORIZATION='Token ' + self.token.key)
url = '/qa/v1/relevancyscores/'
response = self.APIClient.post(url, self.data_with_algorithm_in_body)
self.assertEqual(response.status_code, status.HTTP_201_CREATED)
self.assertEqual(response.json()['algorithm'], self.data_with_algorithm_in_body['algorithm'])
def test_post_response_has_correct_search_location(self):
self.APIClient.credentials(HTTP_AUTHORIZATION='Token ' + self.token.key)
url = '/qa/v1/relevancyscores/'
response = self.APIClient.post(url, self.data_with_algorithm_in_body)
self.assertEqual(response.status_code, status.HTTP_201_CREATED)
self.assertEqual(response.json()['search_location'], self.data_with_algorithm_in_body['search_location'])
def test_post_response_has_correct_service_at_location(self):
self.APIClient.credentials(HTTP_AUTHORIZATION='Token ' + self.token.key)
url = '/qa/v1/relevancyscores/'
response = self.APIClient.post(url, self.data_with_algorithm_in_body)
self.assertEqual(response.status_code, status.HTTP_201_CREATED)
self.assertEqual(response.json()['service_at_location'],
self.data_with_algorithm_in_body['service_at_location'])
def test_post_response_has_correct_topic(self):
self.APIClient.credentials(HTTP_AUTHORIZATION='Token ' + self.token.key)
url = '/qa/v1/relevancyscores/'
response = self.APIClient.post(url, self.data_with_algorithm_in_body)
self.assertEqual(response.status_code, status.HTTP_201_CREATED)
self.assertEqual(response.json()['topic'], self.data_with_algorithm_in_body['topic'])
def test_post_response_has_correct_user(self):
self.APIClient.credentials(HTTP_AUTHORIZATION='Token ' + self.token.key)
url = '/qa/v1/relevancyscores/'
response = self.APIClient.post(url, self.data_with_algorithm_in_body)
self.assertEqual(response.status_code, status.HTTP_201_CREATED)
self.assertEqual(response.json()['user'], self.user.id)
def test_post_response_has_accurate_time_stamp(self):
self.APIClient.credentials(HTTP_AUTHORIZATION='Token ' + self.token.key)
url = '/qa/v1/relevancyscores/'
response = self.APIClient.post(url, self.data_with_algorithm_in_body)
self.assertEqual(response.status_code, status.HTTP_201_CREATED)
recreated_time = datetime.datetime.strptime(response.json()['time_stamp'], '%Y-%m-%dT%H:%M:%S.%fZ')
self.assertLessEqual(recreated_time, datetime.datetime.now())
self.assertGreaterEqual(recreated_time + datetime.timedelta(seconds=1), datetime.datetime.now())
def test_cannot_post_unauthenticated(self):
url = '/qa/v1/relevancyscores/'
response = self.APIClient.post(url, data=self.data_with_algorithm_in_body)
self.assertEqual(response.status_code, status.HTTP_401_UNAUTHORIZED)
def test_cannot_post_with_invalid_algorithm_in_url_valid_algorithm_in_body_long_url(self):
self.APIClient.credentials(HTTP_AUTHORIZATION='Token ' + self.token.key)
url = '/qa/v1/algorithms/0/relevancyscores/'
response = self.APIClient.post(url, data=self.data_with_algorithm_in_body)
self.assertEqual(response.status_code, status.HTTP_400_BAD_REQUEST)
def test_cannot_post_without_algorithm_in_body_or_url_short_url(self):
self.APIClient.credentials(HTTP_AUTHORIZATION='Token ' + self.token.key)
url = '/qa/v1/relevancyscores/'
response = self.APIClient.post(url, data=self.data_without_algorithm_in_body)
self.assertEqual(response.status_code, status.HTTP_400_BAD_REQUEST)
def test_cannot_post_with_invalid_algorithm_in_url_missing_algorithm_in_body_long_url(self):
self.APIClient.credentials(HTTP_AUTHORIZATION='Token ' + self.token.key)
url = '/qa/v1/algorithms/0/relevancyscores/'
response = self.APIClient.post(url, data=self.data_without_algorithm_in_body)
self.assertEqual(response.status_code, status.HTTP_400_BAD_REQUEST)
def test_cannot_post_with_algorithm_in_body_and_url_short_url(self):
self.APIClient.credentials(HTTP_AUTHORIZATION='Token ' + self.token.key)
algorithm_id = self.data_with_algorithm_in_body['algorithm']
url = '/qa/v1/relevancyscores/{0}/'.format(algorithm_id)
response = self.APIClient.post(url, data=self.data_with_algorithm_in_body)
self.assertEqual(response.status_code, status.HTTP_405_METHOD_NOT_ALLOWED)
def test_cannot_post_with_algorithm_in_body_and_url_long_url(self):
self.APIClient.credentials(HTTP_AUTHORIZATION='Token ' + self.token.key)
algorithm_id = self.data_with_algorithm_in_body['algorithm']
url = '/qa/v1/algorithms/{0}/relevancyscores/'.format(algorithm_id)
response = self.APIClient.post(url, data=self.data_with_algorithm_in_body)
self.assertEqual(response.status_code, status.HTTP_400_BAD_REQUEST)
def test_cannot_post_with_algorithm_in_url_not_in_body_short_url(self):
self.APIClient.credentials(HTTP_AUTHORIZATION='Token ' + self.token.key)
algorithm_id = AlgorithmBuilder().create().id
url = '/qa/v1/relevancyscores/{0}/'.format(algorithm_id)
response = self.APIClient.post(url, data=self.data_without_algorithm_in_body)
self.assertEqual(response.status_code, status.HTTP_405_METHOD_NOT_ALLOWED)
def test_cannot_post_when_missing_fields(self):
self.APIClient.credentials(HTTP_AUTHORIZATION='Token ' + self.token.key)
bad_data = {
'value': an_integer(),
'algorithm': AlgorithmBuilder().create().id,
# 'search_location': missing search_location
'service_at_location': ServiceAtLocationBuilder().create().id,
'topic': create_topic(a_string()).id,
}
url = '/qa/v1/relevancyscores/'
response = self.APIClient.post(url, bad_data)
self.assertEqual(response.status_code, status.HTTP_400_BAD_REQUEST)
| 52.803681
| 113
| 0.70797
| 2,098
| 17,214
| 5.533842
| 0.068637
| 0.071662
| 0.099053
| 0.082429
| 0.886649
| 0.860121
| 0.83006
| 0.801723
| 0.779328
| 0.757623
| 0
| 0.011102
| 0.173231
| 17,214
| 325
| 114
| 52.966154
| 0.804666
| 0.00244
| 0
| 0.660777
| 0
| 0
| 0.101747
| 0.053757
| 0
| 0
| 0
| 0
| 0.194346
| 1
| 0.130742
| false
| 0
| 0.031802
| 0
| 0.176678
| 0
| 0
| 0
| 0
| null | 0
| 0
| 0
| 1
| 1
| 1
| 1
| 1
| 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
| 6
|
1e541512faafd54c0c1676a7bba9c3290d449349
| 81
|
py
|
Python
|
language/python/DeepNudeImage/DeepNude_software_itself/color.py
|
LIU2016/Demo
|
979403d728348c7a14553c8df8a32b21f57ff126
|
[
"Apache-2.0"
] | 1
|
2018-11-25T12:03:16.000Z
|
2018-11-25T12:03:16.000Z
|
language/python/DeepNudeImage/DeepNude_software_itself/color.py
|
LIU2016/Demo
|
979403d728348c7a14553c8df8a32b21f57ff126
|
[
"Apache-2.0"
] | null | null | null |
language/python/DeepNudeImage/DeepNude_software_itself/color.py
|
LIU2016/Demo
|
979403d728348c7a14553c8df8a32b21f57ff126
|
[
"Apache-2.0"
] | null | null | null |
def checkcolor():
return [255, 240, 255]
def newcolor(a, b):
return 255
| 13.5
| 26
| 0.617284
| 12
| 81
| 4.166667
| 0.666667
| 0.36
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0.196721
| 0.246914
| 81
| 6
| 27
| 13.5
| 0.622951
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 1
| 0.5
| false
| 0
| 0
| 0.5
| 1
| 0
| 1
| 0
| 0
| null | 1
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 1
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| null | 0
| 0
| 0
| 0
| 0
| 1
| 0
| 0
| 0
| 1
| 1
| 0
|
0
| 6
|
1e8cfe92c3a2e28d33787196d529b7de43fd0941
| 4,739
|
py
|
Python
|
arch_params/scalenet_cifar_archs.py
|
zhjpqq/scaledensenet
|
5ae56786c7f628b8320b76d559ecaa6fa1d2ac0e
|
[
"MIT"
] | 5
|
2019-08-27T20:15:05.000Z
|
2021-01-18T08:21:37.000Z
|
arch_params/scalenet_cifar_archs.py
|
zhjpqq/scaledensenet
|
5ae56786c7f628b8320b76d559ecaa6fa1d2ac0e
|
[
"MIT"
] | null | null | null |
arch_params/scalenet_cifar_archs.py
|
zhjpqq/scaledensenet
|
5ae56786c7f628b8320b76d559ecaa6fa1d2ac0e
|
[
"MIT"
] | 2
|
2020-03-12T04:41:49.000Z
|
2020-10-11T08:32:34.000Z
|
# cifar10 #####################
ci7 = {'stages': 3, 'depth': 22, 'branch': 3, 'rock': 'U', 'kldloss': False,
'layers': (3, 3, 3), 'blocks': ('D', 'D', 'S'), 'slink': ('A', 'A', 'A'),
'growth': (0, 0, 0), 'classify': (0, 0, 0), 'expand': (1 * 22, 2 * 22),
'dfunc': ('O', 'O'), 'dstyle': 'maxpool', 'fcboost': 'none', 'nclass': 10,
'last_branch': 1, 'last_down': False, 'last_dfuc': 'D', 'last_expand': 32,
'summer': 'split', 'afisok': False, 'version': 2} # 1M 35L 0.22s 88fc
# NET Width
ao1 = {'stages': 1, 'depth': 64, 'branch': 3, 'rock': 'U', 'kldloss': False,
'layers': (10,), 'blocks': ('D',), 'slink': ('A',),
'growth': (0,), 'classify': (0,), 'expand': (), 'dfunc': (),
'fcboost': 'none', 'nclass': 10, 'summer': 'split',
'last_branch': 1, 'last_down': False, 'last_dfuc': 'D', 'last_expand': 36,
'afisok': False, 'version': 2} # 2.06M 0.96G 44L 0.05s 94.57% => ax16@titan but-only-lastfc
ao2 = {'stages': 1, 'depth': 56, 'branch': 3, 'rock': 'U', 'kldloss': False,
'layers': (10,), 'blocks': ('D',), 'slink': ('A',),
'growth': (0,), 'classify': (0,), 'expand': (), 'dfunc': (),
'fcboost': 'none', 'nclass': 10, 'summer': 'split',
'last_branch': 1, 'last_down': False, 'last_dfuc': 'D', 'last_expand': 36,
'afisok': False, 'version': 2} # 1.57M 0.74G 44L 0.05s
ao3 = {'stages': 1, 'depth': 48, 'branch': 3, 'rock': 'U', 'kldloss': False,
'layers': (10,), 'blocks': ('D',), 'slink': ('A',),
'growth': (0,), 'classify': (0,), 'expand': (), 'dfunc': (),
'fcboost': 'none', 'nclass': 10, 'summer': 'split',
'last_branch': 1, 'last_down': False, 'last_dfuc': 'D', 'last_expand': 36,
'afisok': False, 'version': 2} # 1.16M 0.54G 44L 0.05s
ao4 = {'stages': 1, 'depth': 40, 'branch': 3, 'rock': 'U', 'kldloss': False,
'layers': (10,), 'blocks': ('D',), 'slink': ('A',),
'growth': (0,), 'classify': (0,), 'expand': (), 'dfunc': (),
'fcboost': 'none', 'nclass': 10, 'summer': 'split',
'last_branch': 1, 'last_down': False, 'last_dfuc': 'D', 'last_expand': 36,
'afisok': False, 'version': 2} # 0.81M 0.38G 44L 0.04s
ao5 = {'stages': 1, 'depth': 36, 'branch': 3, 'rock': 'U', 'kldloss': False,
'layers': (10,), 'blocks': ('D',), 'slink': ('A',),
'growth': (0,), 'classify': (0,), 'expand': (), 'dfunc': (),
'fcboost': 'none', 'nclass': 10, 'summer': 'split',
'last_branch': 1, 'last_down': False, 'last_dfuc': 'D', 'last_expand': 36,
'afisok': False, 'version': 2} # 0.65M 0.30G 44L 0.03s
# cifar100 #####################
# NET WIDTH
bo1 = {'stages': 1, 'depth': 100, 'branch': 1, 'rock': 'U', 'kldloss': False,
'layers': (10,), 'blocks': ('D',), 'slink': ('A',),
'growth': (0,), 'classify': (0,), 'expand': (), 'dfunc': (),
'fcboost': 'none', 'nclass': 100, 'summer': 'split',
'last_branch': 1, 'last_down': False, 'last_dfuc': 'D', 'last_expand': 36,
'afisok': False, 'version': 3} # 3.62M 1.44G 42L 0.22s
bo2 = {'stages': 1, 'depth': 90, 'branch': 1, 'rock': 'U', 'kldloss': False,
'layers': (10,), 'blocks': ('D',), 'slink': ('A',),
'growth': (0,), 'classify': (0,), 'expand': (), 'dfunc': (),
'fcboost': 'none', 'nclass': 100, 'summer': 'split',
'last_branch': 1, 'last_down': False, 'last_dfuc': 'D', 'last_expand': 36,
'afisok': False, 'version': 3} # 2.93M 1.18G 42L 0.22s
bo3 = {'stages': 1, 'depth': 80, 'branch': 1, 'rock': 'U', 'kldloss': False,
'layers': (10,), 'blocks': ('D',), 'slink': ('A',),
'growth': (0,), 'classify': (0,), 'expand': (), 'dfunc': (),
'fcboost': 'none', 'nclass': 100, 'summer': 'split',
'last_branch': 1, 'last_down': False, 'last_dfuc': 'D', 'last_expand': 36,
'afisok': False, 'version': 3} # 2.32M 0.93G 42L 0.22s
bo4 = {'stages': 1, 'depth': 70, 'branch': 1, 'rock': 'U', 'kldloss': False,
'layers': (10,), 'blocks': ('D',), 'slink': ('A',),
'growth': (0,), 'classify': (0,), 'expand': (), 'dfunc': (),
'fcboost': 'none', 'nclass': 100, 'summer': 'split',
'last_branch': 1, 'last_down': False, 'last_dfuc': 'D', 'last_expand': 36,
'afisok': False, 'version': 3} # 1.78M 0.71G 42L 0.17s
bo5 = {'stages': 1, 'depth': 60, 'branch': 1, 'rock': 'U', 'kldloss': False,
'layers': (10,), 'blocks': ('D',), 'slink': ('A',),
'growth': (0,), 'classify': (0,), 'expand': (), 'dfunc': (),
'fcboost': 'none', 'nclass': 100, 'summer': 'split',
'last_branch': 1, 'last_down': False, 'last_dfuc': 'D', 'last_expand': 36,
'afisok': False, 'version': 3} # 1.30M 0.52G 42L 0.17s
| 57.096386
| 105
| 0.488078
| 601
| 4,739
| 3.775374
| 0.164725
| 0.049361
| 0.058175
| 0.082415
| 0.769502
| 0.769502
| 0.769502
| 0.75628
| 0.75628
| 0.75628
| 0
| 0.083557
| 0.214602
| 4,739
| 83
| 106
| 57.096386
| 0.526061
| 0.073644
| 0
| 0.757576
| 0
| 0
| 0.397877
| 0
| 0
| 0
| 0
| 0
| 0
| 1
| 0
| false
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| null | 0
| 0
| 0
| 0
| 1
| 1
| 1
| 1
| 1
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 1
| 0
| 0
| 0
| 0
| null | 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
|
0
| 6
|
1eb2aeffaa05044599c4d044c5bdf7040314ee56
| 1,562
|
py
|
Python
|
py/pe/pe25.py
|
kittttttan/pe
|
6f87e4527793198c393700fedbdd52274fec5b44
|
[
"MIT"
] | null | null | null |
py/pe/pe25.py
|
kittttttan/pe
|
6f87e4527793198c393700fedbdd52274fec5b44
|
[
"MIT"
] | null | null | null |
py/pe/pe25.py
|
kittttttan/pe
|
6f87e4527793198c393700fedbdd52274fec5b44
|
[
"MIT"
] | 1
|
2016-09-01T22:47:28.000Z
|
2016-09-01T22:47:28.000Z
|
#!/usr/bin/env python
# -*- coding: utf-8 -*-
"""
What is the first term in the Fibonacci sequence to contain 1000 digits?
"""
def pe25(digits=1000):
"""
>>> pe25()
(4782, 1070066266382758936764980584457396885083683896632151665013235203375314520604694040621889147582489792657804694888177591957484336466672569959512996030461262748092482186144069433051234774442750273781753087579391666192149259186759553966422837148943113074699503439547001985432609723067290192870526447243726117715821825548491120525013201478612965931381792235559657452039506137551467837543229119602129934048260706175397706847068202895486902666185435124521900369480641357447470911707619766945691070098024393439617474103736912503231365532164773697023167755051595173518460579954919410967778373229665796581646513903488154256310184224190259846088000110186255550245493937113651657039447629584714548523425950428582425306083544435428212611008992863795048006894330309773217834864543113205765659868456288616808718693835297350643986297640660000723562917905207051164077614812491885830945940566688339109350944456576357666151619317753792891661581327159616877487983821820492520348473874384736771934512787029218636250627816)
"""
a, b, n = 1, 0, 1
while len(str(a)) < digits:
a, b = a + b, a
n += 1
return (n, a)
if __name__ == "__main__":
import doctest
doctest.testmod()
try:
while True:
s = input('> ')
n = int(s)
print(pe25(n))
except (SyntaxError, EOFError, KeyboardInterrupt, NameError):
pass
| 53.862069
| 1,012
| 0.820102
| 72
| 1,562
| 17.680556
| 0.694444
| 0.004713
| 0.004713
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0.747261
| 0.12356
| 1,562
| 28
| 1,013
| 55.785714
| 0.182615
| 0.726633
| 0
| 0
| 0
| 0
| 0.025063
| 0
| 0
| 1
| 0
| 0
| 0
| 1
| 0.0625
| false
| 0.0625
| 0.0625
| 0
| 0.1875
| 0.0625
| 0
| 0
| 1
| null | 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 1
| 0
| 0
| 0
| 1
| 0
| 1
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| null | 1
| 0
| 0
| 0
| 0
| 0
| 0
| 1
| 0
| 0
| 0
| 0
|
0
| 6
|
1eda650c2b7c00404318ab0359a59e2e2949be81
| 22
|
py
|
Python
|
phasortoolbox/parser/pcap/__init__.py
|
ashu704/PhasorToolBox
|
ca9c5a6d35409a369ac73738b0c5e7621fec3bea
|
[
"MIT"
] | 18
|
2017-08-12T19:57:48.000Z
|
2021-12-17T11:39:38.000Z
|
phasortoolbox/parser/pcap/__init__.py
|
ashu704/PhasorToolBox
|
ca9c5a6d35409a369ac73738b0c5e7621fec3bea
|
[
"MIT"
] | 3
|
2017-11-15T22:46:25.000Z
|
2021-07-29T17:48:27.000Z
|
phasortoolbox/parser/pcap/__init__.py
|
ashu704/PhasorToolBox
|
ca9c5a6d35409a369ac73738b0c5e7621fec3bea
|
[
"MIT"
] | 8
|
2018-02-07T15:39:03.000Z
|
2021-03-10T02:44:03.000Z
|
from .pcap import Pcap
| 22
| 22
| 0.818182
| 4
| 22
| 4.5
| 0.75
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0.136364
| 22
| 1
| 22
| 22
| 0.947368
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 1
| 0
| true
| 0
| 1
| 0
| 1
| 0
| 1
| 1
| 0
| null | 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 1
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| null | 0
| 0
| 0
| 0
| 0
| 0
| 1
| 0
| 1
| 0
| 1
| 0
|
0
| 6
|
bf4c642d21fbc3614acd84c05349004ef7263699
| 185
|
py
|
Python
|
hello_world_project/hello_world/views.py
|
pjconnolly12/Django-Practice
|
3383b979f509812504221181d253cef0cb471b51
|
[
"MIT"
] | null | null | null |
hello_world_project/hello_world/views.py
|
pjconnolly12/Django-Practice
|
3383b979f509812504221181d253cef0cb471b51
|
[
"MIT"
] | null | null | null |
hello_world_project/hello_world/views.py
|
pjconnolly12/Django-Practice
|
3383b979f509812504221181d253cef0cb471b51
|
[
"MIT"
] | null | null | null |
from django.shortcuts import render
from django.http import HttpResponse
# Create your views here.
def index(request):
return HttpResponse('<html><body>Hello, World!</body></html>')
| 23.125
| 63
| 0.762162
| 25
| 185
| 5.64
| 0.76
| 0.141844
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0.113514
| 185
| 7
| 64
| 26.428571
| 0.859756
| 0.124324
| 0
| 0
| 0
| 0
| 0.24375
| 0
| 0
| 0
| 0
| 0
| 0
| 1
| 0.25
| false
| 0
| 0.5
| 0.25
| 1
| 0
| 1
| 0
| 0
| null | 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 1
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| null | 0
| 0
| 0
| 0
| 0
| 1
| 0
| 0
| 1
| 1
| 1
| 0
|
0
| 6
|
bf75b5ffbda29fa334b2693eb90a2b1009d3c4e1
| 258
|
py
|
Python
|
uwsgiconf/exceptions.py
|
graceshaw/uwsgiconf
|
205289bb279dfbcc1d9bfd599dd8ca5d6c527077
|
[
"BSD-3-Clause"
] | 77
|
2017-07-15T21:14:24.000Z
|
2021-09-02T13:35:44.000Z
|
uwsgiconf/exceptions.py
|
graceshaw/uwsgiconf
|
205289bb279dfbcc1d9bfd599dd8ca5d6c527077
|
[
"BSD-3-Clause"
] | 5
|
2017-12-01T05:41:02.000Z
|
2022-03-23T07:46:19.000Z
|
uwsgiconf/exceptions.py
|
graceshaw/uwsgiconf
|
205289bb279dfbcc1d9bfd599dd8ca5d6c527077
|
[
"BSD-3-Clause"
] | 1
|
2021-05-20T01:33:04.000Z
|
2021-05-20T01:33:04.000Z
|
class UwsgiconfException(Exception):
"""Base for exceptions."""
class ConfigurationError(UwsgiconfException):
"""Configuration related error."""
class RuntimeConfigurationError(ConfigurationError):
"""Runtime configuration related error."""
| 21.5
| 52
| 0.755814
| 19
| 258
| 10.263158
| 0.631579
| 0.205128
| 0.25641
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0.127907
| 258
| 11
| 53
| 23.454545
| 0.866667
| 0.333333
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 1
| 0
| true
| 0
| 0
| 0
| 1
| 0
| 1
| 0
| 1
| null | 1
| 1
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| null | 0
| 0
| 0
| 0
| 0
| 0
| 1
| 0
| 0
| 0
| 1
| 0
|
0
| 6
|
bf7f0d02905cd1fc78cadd22dbc6fce470928101
| 13,401
|
py
|
Python
|
model/MultiResUNet.py
|
THU-CVlab/JMedSeg
|
1c9c66a1b2c6e4c5e3f70ca9e1ed54447b944755
|
[
"MIT"
] | 26
|
2021-08-19T05:22:44.000Z
|
2022-03-08T05:44:43.000Z
|
model/MultiResUNet.py
|
Jittor/JMedSeg
|
1c9c66a1b2c6e4c5e3f70ca9e1ed54447b944755
|
[
"MIT"
] | null | null | null |
model/MultiResUNet.py
|
Jittor/JMedSeg
|
1c9c66a1b2c6e4c5e3f70ca9e1ed54447b944755
|
[
"MIT"
] | 3
|
2021-08-19T06:12:49.000Z
|
2021-08-19T11:41:16.000Z
|
'''
https://github.com/makifozkanoglu/MultiResUNet-PyTorch/blob/main/multiresunet.py
'''
import jittor as jt
from jittor import init
from jittor import nn
def Conv2dSame(in_channels, out_channels, kernel_size, use_bias=True, padding_layer=nn.ReflectionPad2d):
ka = (kernel_size // 2)
kb = ((ka - 1) if ((kernel_size % 2) == 0) else ka)
return [padding_layer((ka, kb, ka, kb)), nn.Conv(in_channels, out_channels, kernel_size, bias=use_bias)]
def conv2d_bn(in_channels, filters, kernel_size, padding='same', activation='relu'):
assert (padding == 'same')
sequence = []
sequence += Conv2dSame(in_channels, filters, kernel_size, use_bias=False)
sequence += [nn.BatchNorm(filters)]
if (activation == 'relu'):
sequence += [nn.ReLU()]
return nn.Sequential(*sequence)
class MultiResBlock(nn.Module):
def __init__(self, in_channels, u, alpha=1.67, use_dropout = False):
super().__init__()
w = (alpha * u)
self.out_channel = ((int((w * 0.167)) + int((w * 0.333))) + int((w * 0.5)))
self.conv2d_bn = conv2d_bn(in_channels, self.out_channel, 1, activation=None)
self.conv3x3 = conv2d_bn(in_channels, int((w * 0.167)), 3, activation='relu')
self.conv5x5 = conv2d_bn(int((w * 0.167)), int((w * 0.333)), 3, activation='relu')
self.conv7x7 = conv2d_bn(int((w * 0.333)), int((w * 0.5)), 3, activation='relu')
self.bn_1 = nn.BatchNorm(self.out_channel)
self.relu = nn.ReLU()
self.bn_2 = nn.BatchNorm(self.out_channel)
self.use_dropout = use_dropout
if use_dropout:
self.dropout = nn.Dropout(0.5)
def execute(self, inp):
if self.use_dropout:
x = self.dropout(inp)
else:
x = inp
shortcut = self.conv2d_bn(x)
conv3x3 = self.conv3x3(x)
conv5x5 = self.conv5x5(conv3x3)
conv7x7 = self.conv7x7(conv5x5)
out = jt.contrib.concat([conv3x3, conv5x5, conv7x7], dim=1)
out = self.bn_1(out)
out = jt.add(shortcut, out)
out = nn.relu(out)
out = self.bn_2(out)
return out
class ResPathBlock(nn.Module):
def __init__(self, in_channels, filters):
super(ResPathBlock, self).__init__()
self.conv2d_bn1 = conv2d_bn(in_channels, filters, 1, activation=None)
self.conv2d_bn2 = conv2d_bn(in_channels, filters, 3, activation='relu')
self.relu = nn.ReLU()
self.bn = nn.BatchNorm(filters)
def execute(self, inp):
shortcut = self.conv2d_bn1(inp)
out = self.conv2d_bn2(inp)
out = jt.add(shortcut, out)
out = nn.relu(out)
out = self.bn(out)
return out
class ResPath(nn.Module):
def __init__(self, in_channels, filters, length):
super(ResPath, self).__init__()
self.first_block = ResPathBlock(in_channels, filters)
self.blocks = nn.Sequential(*[ResPathBlock(filters, filters) for i in range((length - 1))])
def execute(self, inp):
out = self.first_block(inp)
out = self.blocks(out)
return out
class MultiResUnet(nn.Module):
def __init__(self, in_ch = 3, n_classes = 2, nf=32, use_dropout=False):
super(MultiResUnet, self).__init__()
self.mres_block1 = MultiResBlock(in_ch, u=nf)
self.pool = nn.Pool(2, op='maximum')
self.res_path1 = ResPath(self.mres_block1.out_channel, nf, 4)
self.mres_block2 = MultiResBlock(self.mres_block1.out_channel, u=(nf * 2))
self.res_path2 = ResPath(self.mres_block2.out_channel, (nf * 2), 3)
self.mres_block3 = MultiResBlock(self.mres_block2.out_channel, u=(nf * 4))
self.res_path3 = ResPath(self.mres_block3.out_channel, (nf * 4), 2)
self.mres_block4 = MultiResBlock(self.mres_block3.out_channel, u=(nf * 8))
self.res_path4 = ResPath(self.mres_block4.out_channel, (nf * 8), 1)
self.mres_block5 = MultiResBlock(self.mres_block4.out_channel, u=(nf * 16))
self.deconv1 = nn.ConvTranspose(self.mres_block5.out_channel, (nf * 8), (2, 2), stride=(2, 2))
self.mres_block6 = MultiResBlock(((nf * 8) + (nf * 8)), u=(nf * 8), use_dropout=use_dropout)
self.deconv2 = nn.ConvTranspose(self.mres_block6.out_channel, (nf * 4), (2, 2), stride=(2, 2))
self.mres_block7 = MultiResBlock(((nf * 4) + (nf * 4)), u=(nf * 4), use_dropout=use_dropout)
self.deconv3 = nn.ConvTranspose(self.mres_block7.out_channel, (nf * 2), (2, 2), stride=(2, 2))
self.mres_block8 = MultiResBlock(((nf * 2) + (nf * 2)), u=(nf * 2), use_dropout=use_dropout)
self.deconv4 = nn.ConvTranspose(self.mres_block8.out_channel, nf, (2, 2), stride=(2, 2))
self.mres_block9 = MultiResBlock((nf + nf), u=nf)
self.conv10 = conv2d_bn(self.mres_block9.out_channel, n_classes, 1, padding='same', activation=None)
def execute(self, inp):
mresblock1 = self.mres_block1(inp)
pool = self.pool(mresblock1)
mresblock1 = self.res_path1(mresblock1)
mresblock2 = self.mres_block2(pool)
pool = self.pool(mresblock2)
mresblock2 = self.res_path2(mresblock2)
mresblock3 = self.mres_block3(pool)
pool = self.pool(mresblock3)
mresblock3 = self.res_path3(mresblock3)
mresblock4 = self.mres_block4(pool)
pool = self.pool(mresblock4)
mresblock4 = self.res_path4(mresblock4)
mresblock = self.mres_block5(pool)
up = jt.contrib.concat([self.deconv1(mresblock), mresblock4], dim=1)
mresblock = self.mres_block6(up)
up = jt.contrib.concat([self.deconv2(mresblock), mresblock3], dim=1)
mresblock = self.mres_block7(up)
up = jt.contrib.concat([self.deconv3(mresblock), mresblock2], dim=1)
mresblock = self.mres_block8(up)
up = jt.contrib.concat([self.deconv4(mresblock), mresblock1], dim=1)
mresblock = self.mres_block9(up)
conv10 = self.conv10(mresblock)
return conv10
def get_loss(self, target, pred, ignore_index=None):
loss_pred = nn.cross_entropy_loss(pred, target, ignore_index=ignore_index)
return loss_pred
def update_params(self, loss, optimizer):
optimizer.zero_grad()
loss.backward()
optimizer.step()
def main():
model = MultiResUnet()
x = jt.ones([2, 3, 512, 512])
y = model(x)
print (y.shape)
_ = y.data
if __name__ == '__main__':
main()
# from jittor.utils.pytorch_converter import convert
# pytorch_code="""
# import torch
# def Conv2dSame(in_channels, out_channels, kernel_size, use_bias=True, padding_layer=torch.nn.ReflectionPad2d):
# ka = kernel_size // 2
# kb = ka - 1 if kernel_size % 2 == 0 else ka
# return [
# padding_layer((ka, kb, ka, kb)),
# torch.nn.Conv2d(in_channels, out_channels, kernel_size, bias=use_bias)
# ]
# def conv2d_bn(in_channels, filters, kernel_size, padding='same', activation='relu'):
# assert padding == 'same'
# affine = False if activation == 'relu' or activation == 'sigmoid' else True
# sequence = []
# sequence += Conv2dSame(in_channels, filters, kernel_size, use_bias=False)
# sequence += [torch.nn.BatchNorm2d(filters, affine=affine)]
# if activation == "relu":
# sequence += [torch.nn.ReLU()]
# elif activation == "sigmoid":
# sequence += [torch.nn.Sigmoid()]
# elif activation == 'tanh':
# sequence += [torch.nn.Tanh()]
# return torch.nn.Sequential(*sequence)
# class MultiResBlock(torch.nn.Module):
# def __init__(self, in_channels, u, alpha=1.67, use_dropout=False):
# super().__init__()
# w = alpha * u
# self.out_channel = int(w * 0.167) + int(w * 0.333) + int(w * 0.5)
# self.conv2d_bn = conv2d_bn(in_channels, self.out_channel, 1, activation=None)
# self.conv3x3 = conv2d_bn(in_channels, int(w * 0.167), 3, activation='relu')
# self.conv5x5 = conv2d_bn(int(w * 0.167), int(w * 0.333), 3, activation='relu')
# self.conv7x7 = conv2d_bn(int(w * 0.333), int(w * 0.5), 3, activation='relu')
# self.bn_1 = torch.nn.BatchNorm2d(self.out_channel)
# self.relu = torch.nn.ReLU()
# self.bn_2 = torch.nn.BatchNorm2d(self.out_channel)
# self.use_dropout = use_dropout
# if use_dropout:
# self.dropout = torch.nn.Dropout(0.5)
# def forward(self, inp):
# if self.use_dropout:
# x = self.dropout(inp)
# else:
# x = inp
# shortcut = self.conv2d_bn(x)
# conv3x3 = self.conv3x3(x)
# conv5x5 = self.conv5x5(conv3x3)
# conv7x7 = self.conv7x7(conv5x5)
# out = torch.cat([conv3x3, conv5x5, conv7x7], dim=1)
# out = self.bn_1(out)
# out = torch.add(shortcut, out)
# out = self.relu(out)
# out = self.bn_2(out)
# return out
# class ResPathBlock(torch.nn.Module):
# def __init__(self, in_channels, filters):
# super(ResPathBlock, self).__init__()
# self.conv2d_bn1 = conv2d_bn(in_channels, filters, 1, activation=None)
# self.conv2d_bn2 = conv2d_bn(in_channels, filters, 3, activation='relu')
# self.relu = torch.nn.ReLU()
# self.bn = torch.nn.BatchNorm2d(filters)
# def forward(self, inp):
# shortcut = self.conv2d_bn1(inp)
# out = self.conv2d_bn2(inp)
# out = torch.add(shortcut, out)
# out = self.relu(out)
# out = self.bn(out)
# return out
# class ResPath(torch.nn.Module):
# def __init__(self, in_channels, filters, length):
# super(ResPath, self).__init__()
# self.first_block = ResPathBlock(in_channels, filters)
# self.blocks = torch.nn.Sequential(*[ResPathBlock(filters, filters) for i in range(length - 1)])
# def forward(self, inp):
# out = self.first_block(inp)
# out = self.blocks(out)
# return out
# class MultiResUnet(torch.nn.Module):
# def __init__(self, in_channels, out_channels, nf=32, use_dropout=False):
# super(MultiResUnet, self).__init__()
# self.mres_block1 = MultiResBlock(in_channels, u=nf)
# self.pool = torch.nn.MaxPool2d(kernel_size=2)
# self.res_path1 = ResPath(self.mres_block1.out_channel, nf, 4)
# self.mres_block2 = MultiResBlock(self.mres_block1.out_channel, u=nf * 2)
# # self.pool2 = torch.nn.MaxPool2d(kernel_size=2)
# self.res_path2 = ResPath(self.mres_block2.out_channel, nf * 2, 3)
# self.mres_block3 = MultiResBlock(self.mres_block2.out_channel, u=nf * 4)
# # self.pool3 = torch.nn.MaxPool2d(kernel_size=2)
# self.res_path3 = ResPath(self.mres_block3.out_channel, nf * 4, 2)
# self.mres_block4 = MultiResBlock(self.mres_block3.out_channel, u=nf * 8)
# # self.pool4 = torch.nn.MaxPool2d(kernel_size=2)
# self.res_path4 = ResPath(self.mres_block4.out_channel, nf * 8, 1)
# self.mres_block5 = MultiResBlock(self.mres_block4.out_channel, u=nf * 16)
# self.deconv1 = torch.nn.ConvTranspose2d(self.mres_block5.out_channel, nf * 8, (2, 2), (2, 2))
# self.mres_block6 = MultiResBlock(nf * 8 + nf * 8, u=nf * 8, use_dropout=use_dropout)
# # MultiResBlock(nf * 8 + self.mres_block4.out_channel, u=nf * 8)
# self.deconv2 = torch.nn.ConvTranspose2d(self.mres_block6.out_channel, nf * 4, (2, 2), (2, 2))
# self.mres_block7 = MultiResBlock(nf * 4 + nf * 4, u=nf * 4, use_dropout=use_dropout)
# # MultiResBlock(nf * 4 + self.mres_block3.out_channel, u=nf * 4)
# self.deconv3 = torch.nn.ConvTranspose2d(self.mres_block7.out_channel, nf * 2, (2, 2), (2, 2))
# self.mres_block8 = MultiResBlock(nf * 2 + nf * 2, u=nf * 2, use_dropout=use_dropout)
# # MultiResBlock(nf * 2 + self.mres_block2.out_channel, u=nf * 2)
# self.deconv4 = torch.nn.ConvTranspose2d(self.mres_block8.out_channel, nf, (2, 2), (2, 2))
# self.mres_block9 = MultiResBlock(nf + nf, u=nf)
# # MultiResBlock(nf + self.mres_block1.out_channel, u=nf)
# self.conv10 = conv2d_bn(self.mres_block9.out_channel, out_channels, 1, padding='same', activation='tanh')
# def forward(self, inp):
# mresblock1 = self.mres_block1(inp)
# pool = self.pool(mresblock1)
# mresblock1 = self.res_path1(mresblock1)
# mresblock2 = self.mres_block2(pool)
# pool = self.pool(mresblock2)
# mresblock2 = self.res_path2(mresblock2)
# mresblock3 = self.mres_block3(pool)
# pool = self.pool(mresblock3)
# mresblock3 = self.res_path3(mresblock3)
# mresblock4 = self.mres_block4(pool)
# pool = self.pool(mresblock4)
# mresblock4 = self.res_path4(mresblock4)
# mresblock = self.mres_block5(pool)
# up = torch.cat([self.deconv1(mresblock), mresblock4], dim=1)
# mresblock = self.mres_block6(up)
# up = torch.cat([self.deconv2(mresblock), mresblock3], dim=1)
# mresblock = self.mres_block7(up)
# up = torch.cat([self.deconv3(mresblock), mresblock2], dim=1)
# mresblock = self.mres_block8(up)
# up = torch.cat([self.deconv4(mresblock), mresblock1], dim=1)
# mresblock = self.mres_block9(up)
# conv10 = self.conv10(mresblock)
# return conv10
# """
# jittor_code = convert(pytorch_code)
# print(jittor_code)
| 41.489164
| 115
| 0.62749
| 1,791
| 13,401
| 4.508654
| 0.093802
| 0.065387
| 0.009907
| 0.019319
| 0.849288
| 0.818947
| 0.794923
| 0.767554
| 0.742539
| 0.719752
| 0
| 0.046672
| 0.230953
| 13,401
| 322
| 116
| 41.618012
| 0.736852
| 0.503246
| 0
| 0.100775
| 0
| 0
| 0.007837
| 0
| 0
| 0
| 0
| 0
| 0.007752
| 1
| 0.100775
| false
| 0
| 0.023256
| 0
| 0.209302
| 0.007752
| 0
| 0
| 0
| null | 0
| 0
| 0
| 1
| 1
| 1
| 1
| 1
| 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
| 6
|
44b98794db3d602cfacb309dc1f286f3c1093b0d
| 4,299
|
py
|
Python
|
API/v1/VIF/ipv6_allowed.py
|
MisakaMikoto0502/XenXenXenSe
|
58a4d288dd2ef3f09ee0062b542b50f0b11d1c43
|
[
"MIT"
] | null | null | null |
API/v1/VIF/ipv6_allowed.py
|
MisakaMikoto0502/XenXenXenSe
|
58a4d288dd2ef3f09ee0062b542b50f0b11d1c43
|
[
"MIT"
] | null | null | null |
API/v1/VIF/ipv6_allowed.py
|
MisakaMikoto0502/XenXenXenSe
|
58a4d288dd2ef3f09ee0062b542b50f0b11d1c43
|
[
"MIT"
] | null | null | null |
from http.client import RemoteDisconnected
from xmlrpc.client import Fault
from fastapi import APIRouter, HTTPException
from XenAPI.XenAPI import Failure
from XenGarden.session import create_session
from XenGarden.VIF import VIF
from API.v1.Common import xenapi_failure_jsonify
from app.settings import Settings
from .model import IPAddressesModel, IPAddressModel
router = APIRouter()
@router.get("/{cluster_id}/vif/{vif_uuid}/ipv6/allowed")
async def vif_get_ipv6_by_uuid(cluster_id: str, vif_uuid: str):
"""Get VIF IPv6 by UUID"""
try:
session = create_session(
_id=cluster_id, get_xen_clusters=Settings.get_xen_clusters()
)
vif: VIF = VIF.get_by_uuid(session=session, uuid=vif_uuid)
ret = dict(
success=True,
data=vif.get_allowed_address_v6(),
)
session.xenapi.session.logout()
return ret
except Failure as xenapi_error:
raise HTTPException(
status_code=500, detail=xenapi_failure_jsonify(xenapi_error)
)
except Fault as xml_rpc_error:
raise HTTPException(
status_code=int(xml_rpc_error.faultCode),
detail=xml_rpc_error.faultString,
)
except RemoteDisconnected as rd_error:
raise HTTPException(status_code=500, detail=rd_error.strerror)
@router.post("/{cluster_id}/vif/{vif_uuid}/ipv6/allowed")
async def vif_add_ipv6_by_uuid(cluster_id: str, vif_uuid: str, address: IPAddressModel):
"""Add VIF IPv6 by UUID"""
try:
session = create_session(
_id=cluster_id, get_xen_clusters=Settings.get_xen_clusters()
)
vif: VIF = VIF.get_by_uuid(session=session, uuid=vif_uuid)
vif.add_allowed_address_v6(address.address)
ret = dict(
success=True,
)
session.xenapi.session.logout()
return ret
except Failure as xenapi_error:
raise HTTPException(
status_code=500, detail=xenapi_failure_jsonify(xenapi_error)
)
except Fault as xml_rpc_error:
raise HTTPException(
status_code=int(xml_rpc_error.faultCode),
detail=xml_rpc_error.faultString,
)
except RemoteDisconnected as rd_error:
raise HTTPException(status_code=500, detail=rd_error.strerror)
@router.put("/{cluster_id}/vif/{vif_uuid}/ipv6/allowed")
async def vif_set_ipv6_by_uuid(
cluster_id: str, vif_uuid: str, addresses: IPAddressesModel
):
"""Set VIF IPv6 by UUID"""
try:
session = create_session(
_id=cluster_id, get_xen_clusters=Settings.get_xen_clusters()
)
vif: VIF = VIF.get_by_uuid(session=session, uuid=vif_uuid)
vif.set_allowed_address_v6(addresses.addresses)
ret = dict(
success=True,
)
session.xenapi.session.logout()
return ret
except Failure as xenapi_error:
raise HTTPException(
status_code=500, detail=xenapi_failure_jsonify(xenapi_error)
)
except Fault as xml_rpc_error:
raise HTTPException(
status_code=int(xml_rpc_error.faultCode),
detail=xml_rpc_error.faultString,
)
except RemoteDisconnected as rd_error:
raise HTTPException(status_code=500, detail=rd_error.strerror)
@router.delete("/{cluster_id}/vif/{vif_uuid}/ipv6/allowed")
async def vif_reset_ipv6_by_uuid(
cluster_id: str, vif_uuid: str, address: IPAddressModel
):
"""Set VIF IPv6 by UUID"""
try:
session = create_session(
_id=cluster_id, get_xen_clusters=Settings.get_xen_clusters()
)
vif: VIF = VIF.get_by_uuid(session=session, uuid=vif_uuid)
vif.delete_allowed_address_v6(address.address)
ret = dict(
success=True,
)
session.xenapi.session.logout()
return ret
except Failure as xenapi_error:
raise HTTPException(
status_code=500, detail=xenapi_failure_jsonify(xenapi_error)
)
except Fault as xml_rpc_error:
raise HTTPException(
status_code=int(xml_rpc_error.faultCode),
detail=xml_rpc_error.faultString,
)
except RemoteDisconnected as rd_error:
raise HTTPException(status_code=500, detail=rd_error.strerror)
| 31.152174
| 88
| 0.670854
| 532
| 4,299
| 5.144737
| 0.131579
| 0.039459
| 0.10084
| 0.127147
| 0.823164
| 0.823164
| 0.823164
| 0.823164
| 0.823164
| 0.799781
| 0
| 0.012635
| 0.245173
| 4,299
| 137
| 89
| 31.379562
| 0.830817
| 0
| 0
| 0.636364
| 0
| 0
| 0.039094
| 0.039094
| 0
| 0
| 0
| 0
| 0
| 1
| 0
| false
| 0
| 0.081818
| 0
| 0.118182
| 0
| 0
| 0
| 0
| null | 0
| 0
| 0
| 1
| 1
| 1
| 1
| 1
| 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
| 6
|
785ec3e5feb6e3c232b9e5e5d5cb1b34decb8baf
| 39
|
py
|
Python
|
test/test_Basic.py
|
nogebour/PereBlaiseBot
|
d648993780672bab53d1c5bab418054dd9e2a200
|
[
"Apache-2.0"
] | 1
|
2018-06-04T12:35:06.000Z
|
2018-06-04T12:35:06.000Z
|
test/test_Basic.py
|
paulber/PereBlaiseBot
|
253b5850c4238bafae2f16816e9bec36a72bf439
|
[
"Apache-2.0"
] | 6
|
2018-04-27T18:11:50.000Z
|
2018-05-04T15:14:07.000Z
|
test/test_Basic.py
|
paulber/PereBlaiseBot
|
253b5850c4238bafae2f16816e9bec36a72bf439
|
[
"Apache-2.0"
] | null | null | null |
def test_challenge1():
assert True
| 13
| 22
| 0.717949
| 5
| 39
| 5.4
| 1
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0.032258
| 0.205128
| 39
| 2
| 23
| 19.5
| 0.83871
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0.5
| 1
| 0.5
| true
| 0
| 0
| 0
| 0.5
| 0
| 1
| 1
| 0
| null | 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 1
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| null | 0
| 0
| 0
| 1
| 0
| 1
| 1
| 0
| 0
| 0
| 0
| 0
|
0
| 6
|
78bbb7b336e8f528d9eb95f50556ecb3d4870fee
| 35
|
py
|
Python
|
fhirpipe/load/__init__.py
|
arkhn/fhir-pipe
|
fd54e1910f6f037b12e60cd8d29c033971fe1de0
|
[
"Apache-2.0"
] | 27
|
2018-10-16T13:03:17.000Z
|
2022-01-05T01:21:37.000Z
|
fhirpipe/load/__init__.py
|
arkhn/fhir-pipe
|
fd54e1910f6f037b12e60cd8d29c033971fe1de0
|
[
"Apache-2.0"
] | 45
|
2018-10-21T14:14:11.000Z
|
2020-06-25T14:32:28.000Z
|
fhirpipe/load/__init__.py
|
arkhn/fhir-pipe
|
fd54e1910f6f037b12e60cd8d29c033971fe1de0
|
[
"Apache-2.0"
] | 2
|
2019-03-27T12:39:54.000Z
|
2019-04-06T22:33:20.000Z
|
from .loader import Loader # noqa
| 17.5
| 34
| 0.742857
| 5
| 35
| 5.2
| 0.8
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0.2
| 35
| 1
| 35
| 35
| 0.928571
| 0.114286
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 1
| 0
| true
| 0
| 1
| 0
| 1
| 0
| 1
| 1
| 0
| null | 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 1
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| null | 0
| 0
| 0
| 0
| 0
| 0
| 1
| 0
| 1
| 0
| 1
| 0
|
0
| 6
|
78c1513a8fd125353afa655d7c4bc6a2c0f4a923
| 96
|
py
|
Python
|
venv/lib/python3.8/site-packages/lockfile/symlinklockfile.py
|
Retraces/UkraineBot
|
3d5d7f8aaa58fa0cb8b98733b8808e5dfbdb8b71
|
[
"MIT"
] | 2
|
2022-03-13T01:58:52.000Z
|
2022-03-31T06:07:54.000Z
|
venv/lib/python3.8/site-packages/lockfile/symlinklockfile.py
|
DesmoSearch/Desmobot
|
b70b45df3485351f471080deb5c785c4bc5c4beb
|
[
"MIT"
] | 19
|
2021-11-20T04:09:18.000Z
|
2022-03-23T15:05:55.000Z
|
venv/lib/python3.8/site-packages/lockfile/symlinklockfile.py
|
DesmoSearch/Desmobot
|
b70b45df3485351f471080deb5c785c4bc5c4beb
|
[
"MIT"
] | null | null | null |
/home/runner/.cache/pip/pool/00/1c/17/5e6bd31ef0a5e6f88f6e54a12f73c6fa01ac2e24f5ae800c7c3470862f
| 96
| 96
| 0.895833
| 9
| 96
| 9.555556
| 1
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0.40625
| 0
| 96
| 1
| 96
| 96
| 0.489583
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 1
| 0
| 0
| 0
| 0
| null | null | 0
| 0
| null | null | 0
| 1
| 0
| 0
| null | 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 1
| 0
| 0
| 1
| 0
| 0
| 1
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| null | 1
| 0
| 0
| 0
| 1
| 0
| 0
| 0
| 0
| 0
| 0
| 0
|
0
| 6
|
151ec2916ddec0aa63145c9c4b821caa38df4aef
| 14,075
|
py
|
Python
|
tests/unit/keys/test_authcrypt_keys_selector.py
|
alex-polosky/didcomm-python
|
955866024c9f6191df9c5a898cc77e1979781eae
|
[
"Apache-2.0"
] | 8
|
2021-09-04T19:28:18.000Z
|
2021-12-22T16:00:18.000Z
|
tests/unit/keys/test_authcrypt_keys_selector.py
|
alex-polosky/didcomm-python
|
955866024c9f6191df9c5a898cc77e1979781eae
|
[
"Apache-2.0"
] | 4
|
2021-07-27T23:44:33.000Z
|
2021-10-13T13:29:39.000Z
|
tests/unit/keys/test_authcrypt_keys_selector.py
|
alex-polosky/didcomm-python
|
955866024c9f6191df9c5a898cc77e1979781eae
|
[
"Apache-2.0"
] | 7
|
2021-07-22T08:19:13.000Z
|
2022-01-04T14:46:38.000Z
|
from typing import List
import pytest
from didcomm.common.types import DID_URL
from didcomm.core.keys.authcrypt_keys_selector import (
find_authcrypt_pack_sender_and_recipient_keys,
AuthcryptPackKeys,
find_authcrypt_unpack_sender_and_recipient_keys,
AuthcryptUnpackKeys,
)
from didcomm.did_doc.did_doc import VerificationMethod
from didcomm.errors import (
DIDDocNotResolvedError,
DIDUrlNotFoundError,
SecretNotFoundError,
IncompatibleCryptoError,
)
from tests.test_vectors.common import BOB_DID, ALICE_DID
from tests.test_vectors.utils import (
get_key_agreement_methods,
get_key_agreement_secrets,
Person,
KeyAgreementCurveType,
get_key_agreement_methods_not_in_secrets,
get_key_agreement_methods_in_secrets,
)
@pytest.mark.asyncio
async def test_find_authcrypt_pack_sender_and_recipient_keys_by_did_positive(
resolvers_config_alice,
):
# expect all keys of the same type as the first key
expected = AuthcryptPackKeys(
sender_private_key=get_key_agreement_secrets(Person.ALICE)[0],
recipient_public_keys=get_key_agreement_methods(
Person.BOB, KeyAgreementCurveType.X25519
),
)
res = await find_authcrypt_pack_sender_and_recipient_keys(
ALICE_DID, BOB_DID, resolvers_config_alice
)
assert res == expected
@pytest.mark.asyncio
@pytest.mark.parametrize(
"curve_type",
[
KeyAgreementCurveType.X25519,
KeyAgreementCurveType.P256,
KeyAgreementCurveType.P521,
],
)
async def test_find_authcrypt_pack_sender_and_recipient_keys_sender_by_kid_recipient_by_did_positive(
curve_type, resolvers_config_alice
):
# expect all keys of the same type as the first key
expected_sender_key = get_key_agreement_secrets(Person.ALICE, curve_type)[0]
expected_recipient_public_keys = get_key_agreement_methods(Person.BOB, curve_type)
expected = AuthcryptPackKeys(expected_sender_key, expected_recipient_public_keys)
res = await find_authcrypt_pack_sender_and_recipient_keys(
expected_sender_key.kid, BOB_DID, resolvers_config_alice
)
assert res == expected
@pytest.mark.asyncio
@pytest.mark.parametrize(
"curve_type",
[
KeyAgreementCurveType.X25519,
KeyAgreementCurveType.P256,
KeyAgreementCurveType.P521,
],
)
async def test_find_authcrypt_pack_sender_and_recipient_keys_sender_and_recipient_by_kid_positive(
curve_type, resolvers_config_alice
):
expected_sender_key = get_key_agreement_secrets(Person.ALICE, curve_type)[0]
expected_recipient_public_key = get_key_agreement_methods(Person.BOB, curve_type)[1]
expected = AuthcryptPackKeys(expected_sender_key, [expected_recipient_public_key])
res = await find_authcrypt_pack_sender_and_recipient_keys(
expected_sender_key.kid,
expected_recipient_public_key.id,
resolvers_config_alice,
)
assert res == expected
@pytest.mark.asyncio
@pytest.mark.parametrize(
"curve_type",
[
KeyAgreementCurveType.X25519,
KeyAgreementCurveType.P256,
KeyAgreementCurveType.P521,
],
)
async def test_find_authcrypt_pack_sender_and_recipient_keys_sender_by_did_recipient_by_kid_positive(
curve_type, resolvers_config_alice
):
expected_sender_key = get_key_agreement_secrets(Person.ALICE, curve_type)[0]
expected_recipient_public_key = get_key_agreement_methods(Person.BOB, curve_type)[1]
expected = AuthcryptPackKeys(expected_sender_key, [expected_recipient_public_key])
res = await find_authcrypt_pack_sender_and_recipient_keys(
ALICE_DID, expected_recipient_public_key.id, resolvers_config_alice
)
assert res == expected
@pytest.mark.asyncio
@pytest.mark.parametrize(
"curve_type",
[
KeyAgreementCurveType.X25519,
KeyAgreementCurveType.P256,
KeyAgreementCurveType.P521,
],
)
async def test_find_authcrypt_pack_sender_and_recipient_keys_recipient_kid_not_in_secret(
curve_type, resolvers_config_alice
):
expected_sender_key = get_key_agreement_secrets(Person.ALICE, curve_type)[0]
expected_recipient_public_key = get_key_agreement_methods_not_in_secrets(
Person.BOB, curve_type
)[0]
expected = AuthcryptPackKeys(expected_sender_key, [expected_recipient_public_key])
res = await find_authcrypt_pack_sender_and_recipient_keys(
expected_sender_key.kid,
expected_recipient_public_key.id,
resolvers_config_alice,
)
assert res == expected
@pytest.mark.asyncio
async def test_find_authcrypt_pack_sender_and_recipient_keys_unknown_sender_did(
resolvers_config_alice,
):
with pytest.raises(DIDDocNotResolvedError):
await find_authcrypt_pack_sender_and_recipient_keys(
"did:example:unknown", BOB_DID, resolvers_config_alice
)
@pytest.mark.asyncio
async def test_find_authcrypt_pack_sender_and_recipient_keys_unknown_recipient_did(
resolvers_config_alice,
):
with pytest.raises(DIDDocNotResolvedError):
await find_authcrypt_pack_sender_and_recipient_keys(
ALICE_DID, "did:example:unknown", resolvers_config_alice
)
@pytest.mark.asyncio
async def test_find_authcrypt_pack_sender_and_recipient_keys_unknown_sender_kid(
resolvers_config_alice,
):
with pytest.raises(SecretNotFoundError):
await find_authcrypt_pack_sender_and_recipient_keys(
ALICE_DID + "#unknown-key", BOB_DID, resolvers_config_alice
)
@pytest.mark.asyncio
async def test_find_authcrypt_pack_sender_and_recipient_keys_unknown_recipient_kid(
resolvers_config_alice,
):
with pytest.raises(DIDUrlNotFoundError):
await find_authcrypt_pack_sender_and_recipient_keys(
ALICE_DID, BOB_DID + "#unknown-key", resolvers_config_alice
)
@pytest.mark.asyncio
async def test_find_authcrypt_pack_sender_and_recipient_keys_sender_kid_not_in_secrets(
resolvers_config_alice,
):
with pytest.raises(SecretNotFoundError):
sender_kid = get_key_agreement_methods_not_in_secrets(Person.ALICE)[0].id
await find_authcrypt_pack_sender_and_recipient_keys(
sender_kid, BOB_DID, resolvers_config_alice
)
@pytest.mark.asyncio
@pytest.mark.parametrize(
"curve_type_sender",
[
KeyAgreementCurveType.X25519,
KeyAgreementCurveType.P256,
KeyAgreementCurveType.P521,
],
)
@pytest.mark.parametrize(
"curve_type_recipient",
[
KeyAgreementCurveType.X25519,
KeyAgreementCurveType.P256,
KeyAgreementCurveType.P521,
],
)
async def test_find_authcrypt_pack_sender_and_recipient_keys_different_curve_types(
curve_type_sender, curve_type_recipient, resolvers_config_alice
):
if curve_type_sender == curve_type_recipient:
return
frm_kid = get_key_agreement_methods_in_secrets(Person.ALICE, curve_type_sender)[
0
].id
to_kid = get_key_agreement_methods_in_secrets(Person.BOB, curve_type_recipient)[
0
].id
with pytest.raises(IncompatibleCryptoError):
await find_authcrypt_pack_sender_and_recipient_keys(
frm_kid, to_kid, resolvers_config_alice
)
@pytest.mark.asyncio
@pytest.mark.parametrize(
"curve_type",
[
KeyAgreementCurveType.X25519,
KeyAgreementCurveType.P256,
KeyAgreementCurveType.P521,
],
)
async def test_find_authcrypt_unpack_sender_and_recipient_keys_recipient_kids_in_secrets_same_type_positive(
curve_type, resolvers_config_bob
):
for sender_vm in get_key_agreement_methods(Person.ALICE, curve_type):
to_kids = [s.kid for s in get_key_agreement_secrets(Person.BOB, curve_type)]
await check_find_authcrypt_unpack_sender_and_recipient_keys(
sender_vm, to_kids, curve_type, resolvers_config_bob
)
@pytest.mark.asyncio
@pytest.mark.parametrize(
"curve_type",
[
KeyAgreementCurveType.X25519,
KeyAgreementCurveType.P256,
KeyAgreementCurveType.P521,
],
)
async def test_find_authcrypt_unpack_sender_and_recipient_keys_all_recipient_kids_same_type_positive(
curve_type, resolvers_config_bob
):
for sender_vm in get_key_agreement_methods(Person.ALICE, curve_type):
to_kids = [vm.id for vm in get_key_agreement_methods(Person.BOB, curve_type)]
await check_find_authcrypt_unpack_sender_and_recipient_keys(
sender_vm, to_kids, curve_type, resolvers_config_bob
)
@pytest.mark.asyncio
@pytest.mark.parametrize(
"sender_curve_type",
[
KeyAgreementCurveType.X25519,
KeyAgreementCurveType.P256,
KeyAgreementCurveType.P521,
],
)
async def test_find_authcrypt_unpack_sender_and_recipient_keys_all_recipient_kids_all_types_positive(
sender_curve_type, resolvers_config_bob
):
for sender_vm in get_key_agreement_methods(Person.ALICE, sender_curve_type):
to_kids = [
vm.id
for vm in get_key_agreement_methods(Person.BOB, KeyAgreementCurveType.ALL)
]
await check_find_authcrypt_unpack_sender_and_recipient_keys(
sender_vm, to_kids, sender_curve_type, resolvers_config_bob
)
async def check_find_authcrypt_unpack_sender_and_recipient_keys(
sender_vm: VerificationMethod,
to_kids: List[DID_URL],
curve_type,
resolvers_config_bob,
):
recipient_secrets = get_key_agreement_secrets(Person.BOB, curve_type)
expected = [
AuthcryptUnpackKeys(recipient_secret, sender_vm)
for recipient_secret in recipient_secrets
]
res = [
r
async for r in find_authcrypt_unpack_sender_and_recipient_keys(
sender_vm.id, to_kids, resolvers_config_bob
)
]
assert res == expected
@pytest.mark.asyncio
async def test_find_authcrypt_unpack_sender_and_recipient_keys_unknown_sender_did(
resolvers_config_bob,
):
frm_kid = "did:example:unknown#key-1"
to_kids = [
vm.id
for vm in get_key_agreement_methods(Person.BOB, KeyAgreementCurveType.X25519)
]
with pytest.raises(DIDDocNotResolvedError):
res = [
r
async for r in find_authcrypt_unpack_sender_and_recipient_keys(
frm_kid, to_kids, resolvers_config_bob
)
]
raise AssertionError("Expected DIDUrlNotFoundError but got " + str(res))
@pytest.mark.asyncio
async def test_find_authcrypt_unpack_sender_and_recipient_keys_unknown_sender_kid(
resolvers_config_bob,
):
frm_kid = ALICE_DID + "#unknown-key-1"
to_kids = [
vm.id
for vm in get_key_agreement_methods(Person.BOB, KeyAgreementCurveType.X25519)
]
with pytest.raises(DIDUrlNotFoundError):
res = [
r
async for r in find_authcrypt_unpack_sender_and_recipient_keys(
frm_kid, to_kids, resolvers_config_bob
)
]
raise AssertionError("Expected DIDUrlNotFoundError but got " + str(res))
@pytest.mark.asyncio
async def test_find_authcrypt_unpack_sender_and_recipient_keys_unknown_recipient_did(
resolvers_config_bob,
):
frm_kid = get_key_agreement_methods(Person.ALICE)[0].id
to_kids = ["did:example:unknown#key-1", "did:example:unknown#key-2"]
with pytest.raises(DIDUrlNotFoundError):
res = [
r
async for r in find_authcrypt_unpack_sender_and_recipient_keys(
frm_kid, to_kids, resolvers_config_bob
)
]
raise AssertionError("Expected DIDUrlNotFoundError but got " + str(res))
@pytest.mark.asyncio
async def test_find_authcrypt_unpack_sender_and_recipient_keys_unknown_recipient_kid(
resolvers_config_bob,
):
frm_kid = get_key_agreement_methods(Person.ALICE)[0].id
to_kids = [BOB_DID + "#unknown-1", BOB_DID + "#unknown-2"]
with pytest.raises(DIDUrlNotFoundError):
res = [
r
async for r in find_authcrypt_unpack_sender_and_recipient_keys(
frm_kid, to_kids, resolvers_config_bob
)
]
raise AssertionError("Expected DIDUrlNotFoundError but got " + str(res))
@pytest.mark.asyncio
@pytest.mark.parametrize(
"curve_type",
[
KeyAgreementCurveType.ALL,
KeyAgreementCurveType.X25519,
KeyAgreementCurveType.P256,
KeyAgreementCurveType.P521,
],
)
async def test_find_authcrypt_unpack_sender_and_recipient_keys_recipient_kids_not_in_secrets(
curve_type, resolvers_config_bob
):
frm_kid = get_key_agreement_methods(Person.ALICE)[0].id
to_kids = [
vm.id for vm in get_key_agreement_methods_not_in_secrets(Person.BOB, curve_type)
]
with pytest.raises(DIDUrlNotFoundError):
res = [
r
async for r in find_authcrypt_unpack_sender_and_recipient_keys(
frm_kid, to_kids, resolvers_config_bob
)
]
raise AssertionError("Expected DIDUrlNotFoundError but got " + str(res))
@pytest.mark.asyncio
@pytest.mark.parametrize(
"curve_type_sender",
[
KeyAgreementCurveType.X25519,
KeyAgreementCurveType.P256,
KeyAgreementCurveType.P521,
],
)
@pytest.mark.parametrize(
"curve_type_recipient",
[
KeyAgreementCurveType.X25519,
KeyAgreementCurveType.P256,
KeyAgreementCurveType.P521,
],
)
async def test_find_authcrypt_unpack_sender_and_recipient_keys_incompatible_crypto(
curve_type_sender, curve_type_recipient, resolvers_config_bob
):
if curve_type_sender == curve_type_recipient:
return
frm_kid = get_key_agreement_methods(Person.ALICE, curve_type_sender)[0].id
to_kids = [
s.kid for s in get_key_agreement_secrets(Person.BOB, curve_type_recipient)
]
with pytest.raises(IncompatibleCryptoError):
res = [
r
async for r in find_authcrypt_unpack_sender_and_recipient_keys(
frm_kid, to_kids, resolvers_config_bob
)
]
raise AssertionError("Expected IncompatibleCryptoError but got " + str(res))
| 32.430876
| 108
| 0.737833
| 1,679
| 14,075
| 5.722454
| 0.058964
| 0.047773
| 0.084305
| 0.100749
| 0.891757
| 0.87729
| 0.863239
| 0.834721
| 0.788822
| 0.76353
| 0
| 0.014866
| 0.197087
| 14,075
| 433
| 109
| 32.505774
| 0.835324
| 0.007034
| 0
| 0.581395
| 0
| 0
| 0.039934
| 0.007014
| 0
| 0
| 0
| 0
| 0.031008
| 1
| 0
| false
| 0
| 0.020672
| 0
| 0.02584
| 0
| 0
| 0
| 0
| null | 0
| 0
| 0
| 1
| 1
| 1
| 1
| 1
| 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
| 6
|
15267ceb7fcd5e3527bdf7e5b3e35ee11011762a
| 6,252
|
py
|
Python
|
indicators/migrations/0014_auto_20180119_1323.py
|
meetdatastory/Activity-CE
|
2692e591f08cea7c869c045577b3d9e20d3ed335
|
[
"Apache-2.0"
] | null | null | null |
indicators/migrations/0014_auto_20180119_1323.py
|
meetdatastory/Activity-CE
|
2692e591f08cea7c869c045577b3d9e20d3ed335
|
[
"Apache-2.0"
] | 268
|
2020-03-31T15:46:59.000Z
|
2022-03-31T18:01:08.000Z
|
indicators/migrations/0014_auto_20180119_1323.py
|
meetdatastory/Activity-CE
|
2692e591f08cea7c869c045577b3d9e20d3ed335
|
[
"Apache-2.0"
] | 1
|
2021-01-05T01:58:24.000Z
|
2021-01-05T01:58:24.000Z
|
# -*- coding: utf-8 -*-
# Generated by Django 1.11.2 on 2018-01-19 21:23
from __future__ import unicode_literals
from django.db import migrations, models
import django.db.models.deletion
class Migration(migrations.Migration):
dependencies = [
('indicators', '0013_auto_20180118_1319'),
]
operations = [
migrations.AlterField(
model_name='collecteddata',
name='achieved',
field=models.DecimalField(decimal_places=2, help_text=b' ', max_digits=20, verbose_name=b'Achieved'),
),
migrations.AlterField(
model_name='collecteddata',
name='agreement',
field=models.ForeignKey(blank=True, help_text=b' ', null=True, on_delete=django.db.models.deletion.CASCADE, related_name='q_agreement2', to='workflow.ProjectAgreement', verbose_name=b'Project Initiation'),
),
migrations.AlterField(
model_name='collecteddata',
name='approved_by',
field=models.ForeignKey(blank=True, help_text=b' ', null=True, on_delete=django.db.models.deletion.CASCADE, related_name='approving_data', to='workflow.TolaUser', verbose_name=b'Originated By'),
),
migrations.AlterField(
model_name='collecteddata',
name='comment',
field=models.TextField(blank=True, help_text=b' ', max_length=255, null=True, verbose_name=b'Comment/Explanation'),
),
migrations.AlterField(
model_name='collecteddata',
name='complete',
field=models.ForeignKey(blank=True, help_text=b' ', null=True, on_delete=django.db.models.deletion.SET_NULL, related_name='q_complete2', to='workflow.ProjectComplete'),
),
migrations.AlterField(
model_name='collecteddata',
name='create_date',
field=models.DateTimeField(blank=True, help_text=b' ', null=True),
),
migrations.AlterField(
model_name='collecteddata',
name='date_collected',
field=models.DateTimeField(blank=True, help_text=b' ', null=True),
),
migrations.AlterField(
model_name='collecteddata',
name='description',
field=models.TextField(blank=True, help_text=b' ', null=True, verbose_name=b'Remarks/comments'),
),
migrations.AlterField(
model_name='collecteddata',
name='disaggregation_value',
field=models.ManyToManyField(blank=True, help_text=b' ', to='indicators.DisaggregationValue'),
),
migrations.AlterField(
model_name='collecteddata',
name='edit_date',
field=models.DateTimeField(blank=True, help_text=b' ', null=True),
),
migrations.AlterField(
model_name='collecteddata',
name='evidence',
field=models.ForeignKey(blank=True, help_text=b' ', null=True, on_delete=django.db.models.deletion.CASCADE, to='workflow.Documentation', verbose_name=b'Evidence Document or Link'),
),
migrations.AlterField(
model_name='collecteddata',
name='indicator',
field=models.ForeignKey(help_text=b' ', on_delete=django.db.models.deletion.CASCADE, to='indicators.Indicator'),
),
migrations.AlterField(
model_name='collecteddata',
name='periodic_target',
field=models.ForeignKey(blank=True, help_text=b' ', null=True, on_delete=django.db.models.deletion.CASCADE, to='indicators.PeriodicTarget'),
),
migrations.AlterField(
model_name='collecteddata',
name='program',
field=models.ForeignKey(blank=True, help_text=b' ', null=True, on_delete=django.db.models.deletion.CASCADE, related_name='i_program', to='workflow.Program'),
),
migrations.AlterField(
model_name='collecteddata',
name='site',
field=models.ManyToManyField(blank=True, help_text=b' ', to='workflow.SiteProfile'),
),
migrations.AlterField(
model_name='collecteddata',
name='tola_table',
field=models.ForeignKey(blank=True, help_text=b' ', null=True, on_delete=django.db.models.deletion.CASCADE, to='indicators.TolaTable'),
),
migrations.AlterField(
model_name='collecteddata',
name='update_count_tola_table',
field=models.BooleanField(default=False, help_text=b' ', verbose_name=b'Would you like to update the achieved total with the row count from TolaTables?'),
),
migrations.AlterField(
model_name='historicalcollecteddata',
name='achieved',
field=models.DecimalField(decimal_places=2, help_text=b' ', max_digits=20, verbose_name=b'Achieved'),
),
migrations.AlterField(
model_name='historicalcollecteddata',
name='comment',
field=models.TextField(blank=True, help_text=b' ', max_length=255, null=True, verbose_name=b'Comment/Explanation'),
),
migrations.AlterField(
model_name='historicalcollecteddata',
name='create_date',
field=models.DateTimeField(blank=True, help_text=b' ', null=True),
),
migrations.AlterField(
model_name='historicalcollecteddata',
name='date_collected',
field=models.DateTimeField(blank=True, help_text=b' ', null=True),
),
migrations.AlterField(
model_name='historicalcollecteddata',
name='description',
field=models.TextField(blank=True, help_text=b' ', null=True, verbose_name=b'Remarks/comments'),
),
migrations.AlterField(
model_name='historicalcollecteddata',
name='edit_date',
field=models.DateTimeField(blank=True, help_text=b' ', null=True),
),
migrations.AlterField(
model_name='historicalcollecteddata',
name='update_count_tola_table',
field=models.BooleanField(default=False, help_text=b' ', verbose_name=b'Would you like to update the achieved total with the row count from TolaTables?'),
),
]
| 45.635036
| 217
| 0.62652
| 646
| 6,252
| 5.899381
| 0.185759
| 0.125951
| 0.157439
| 0.182629
| 0.82052
| 0.82052
| 0.647861
| 0.647861
| 0.647861
| 0.610863
| 0
| 0.010028
| 0.25032
| 6,252
| 136
| 218
| 45.970588
| 0.803072
| 0.010877
| 0
| 0.775194
| 1
| 0
| 0.20563
| 0.057596
| 0
| 0
| 0
| 0
| 0
| 1
| 0
| false
| 0
| 0.023256
| 0
| 0.046512
| 0
| 0
| 0
| 0
| null | 0
| 0
| 1
| 1
| 1
| 0
| 0
| 0
| 1
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 1
| 1
| 0
| 0
| 0
| null | 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
|
0
| 6
|
15331aa94eb84d9d1ef62a40978fdd4ba7980452
| 47
|
py
|
Python
|
test.py
|
sunzhaoc/TrackPrediction
|
bcf5e5f71d5d893f562d141915198f5f2578d48c
|
[
"MIT"
] | 1
|
2021-05-10T02:30:14.000Z
|
2021-05-10T02:30:14.000Z
|
test.py
|
sunzhaoc/TrackPrediction
|
bcf5e5f71d5d893f562d141915198f5f2578d48c
|
[
"MIT"
] | null | null | null |
test.py
|
sunzhaoc/TrackPrediction
|
bcf5e5f71d5d893f562d141915198f5f2578d48c
|
[
"MIT"
] | null | null | null |
A = [[1, 2], [3, 4], [5, 6]]
B = max(A)
V = 1
| 9.4
| 28
| 0.297872
| 12
| 47
| 1.166667
| 0.833333
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0.21875
| 0.319149
| 47
| 5
| 29
| 9.4
| 0.21875
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 1
| 0
| false
| 0
| 0
| 0
| 0
| 0
| 1
| 1
| 1
| null | 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 1
| 0
| 0
| 1
| 0
| 0
| 1
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| null | 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
|
0
| 6
|
15807c813af151784d42acbde1a5a4bd4baae841
| 133
|
py
|
Python
|
mnistetude/actfunc/__init__.py
|
aram-father/mnist-etude
|
3f9196a7ae3447c3412507896c3dc3ae81f9d7d0
|
[
"BSD-2-Clause"
] | null | null | null |
mnistetude/actfunc/__init__.py
|
aram-father/mnist-etude
|
3f9196a7ae3447c3412507896c3dc3ae81f9d7d0
|
[
"BSD-2-Clause"
] | 1
|
2022-03-18T03:14:13.000Z
|
2022-03-18T03:14:13.000Z
|
mnistetude/actfunc/__init__.py
|
aram-father/mnist-etude
|
3f9196a7ae3447c3412507896c3dc3ae81f9d7d0
|
[
"BSD-2-Clause"
] | null | null | null |
from .identity import *
from .relu import *
from .sigmoid import *
from .softmax import *
from .step import *
from .iactfunc import *
| 22.166667
| 23
| 0.736842
| 18
| 133
| 5.444444
| 0.444444
| 0.510204
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0.172932
| 133
| 6
| 24
| 22.166667
| 0.890909
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 1
| 0
| true
| 0
| 1
| 0
| 1
| 0
| 1
| 0
| 0
| null | 1
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 1
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| null | 0
| 0
| 0
| 0
| 0
| 0
| 1
| 0
| 1
| 0
| 1
| 0
|
0
| 6
|
158c36c8f6f8fe9353dd89773638b52ad0d3af13
| 143
|
py
|
Python
|
src/hypertag/__init__.py
|
mwojnars/hypertag
|
8cd989127c12d78f6902d4b3dc972de31a3e88d9
|
[
"MIT"
] | 24
|
2021-02-26T18:58:04.000Z
|
2022-03-12T21:46:55.000Z
|
src/hypertag/__init__.py
|
mwojnars/hypertag
|
8cd989127c12d78f6902d4b3dc972de31a3e88d9
|
[
"MIT"
] | null | null | null |
src/hypertag/__init__.py
|
mwojnars/hypertag
|
8cd989127c12d78f6902d4b3dc972de31a3e88d9
|
[
"MIT"
] | null | null | null |
from hypertag.core.run_html import Runtime, HyperHTML
from hypertag.core.tag import Tag, TagFunction, Markup
from hypertag.core.dom import DOM
| 35.75
| 54
| 0.832168
| 22
| 143
| 5.363636
| 0.545455
| 0.305085
| 0.40678
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0.104895
| 143
| 3
| 55
| 47.666667
| 0.921875
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 1
| 0
| true
| 0
| 1
| 0
| 1
| 0
| 1
| 0
| 0
| null | 1
| 1
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 1
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| null | 0
| 0
| 0
| 0
| 0
| 0
| 1
| 0
| 1
| 0
| 0
| 0
|
0
| 6
|
15a06d4d90c0a7796669306c1f501dae9940709e
| 6,372
|
py
|
Python
|
arim/_probes/bristol_ndt.py
|
will-jj/arim
|
fc15efe171a41355090123fcea10406ee75efe31
|
[
"MIT"
] | 14
|
2019-04-05T13:43:36.000Z
|
2022-02-01T21:38:19.000Z
|
arim/_probes/bristol_ndt.py
|
will-jj/arim
|
fc15efe171a41355090123fcea10406ee75efe31
|
[
"MIT"
] | 2
|
2019-04-09T10:38:26.000Z
|
2019-06-17T16:23:16.000Z
|
arim/_probes/bristol_ndt.py
|
will-jj/arim
|
fc15efe171a41355090123fcea10406ee75efe31
|
[
"MIT"
] | 5
|
2019-04-04T17:02:20.000Z
|
2020-09-30T15:36:03.000Z
|
"""
"""
import numpy as np
from .. import core
from .. import geometry as g
from .registry import ProbeMaker
makers = []
def _make_ima_50_MHz_128_1d():
metadata = dict(
probe_type="linear",
short_name="ima_50_MHz_128_1d",
long_name="Imasonic 5.0 MHz 128 elts linear array probe",
version=0,
serial="7186 A101",
)
numelements = 128
shapes = np.full(numelements, core.ElementShape.rectangular, dtype=np.object)
orientations = g.Points.from_xyz(
np.zeros((numelements,), dtype=np.float),
np.zeros((numelements,), dtype=np.float),
np.ones((numelements,), dtype=np.float),
)
dimensions = g.Points.from_xyz(
np.full(numelements, 0.2e-3),
np.full(numelements, 15e-3),
np.full(numelements, 0.0),
)
dead_elements = np.full(numelements, False, dtype=np.bool)
probe = core.Probe.make_matrix_probe(
numx=numelements,
pitch_x=0.3e-3,
numy=1,
pitch_y=np.nan,
frequency=5e6,
shapes=shapes,
orientations=orientations,
dimensions=dimensions,
dead_elements=dead_elements,
metadata=metadata,
)
return probe
makers.append(
ProbeMaker(
_make_ima_50_MHz_128_1d,
"ima_50_MHz_128_1d",
"Imasonic 5.0 MHz 128 elts linear array probe",
)
)
def _make_ima_50_MHz_64_1d():
metadata = dict(
probe_type="linear",
short_name="ima_50_MHz_64_1d",
long_name="Imasonic 5.0 MHz 64 elts linear array probe",
version=0,
serial="12157 1001",
)
numelements = 64
shapes = np.full(numelements, core.ElementShape.rectangular, dtype=np.object)
orientations = g.Points.from_xyz(
np.zeros((numelements,), dtype=np.float),
np.zeros((numelements,), dtype=np.float),
np.ones((numelements,), dtype=np.float),
)
dimensions = g.Points.from_xyz(
np.full(numelements, 0.53e-3),
np.full(numelements, 15e-3),
np.full(numelements, 0.0),
)
dead_elements = np.full(numelements, False, dtype=np.bool)
probe = core.Probe.make_matrix_probe(
numx=numelements,
pitch_x=0.63e-3,
numy=1,
pitch_y=np.nan,
frequency=5e6,
shapes=shapes,
orientations=orientations,
dimensions=dimensions,
dead_elements=dead_elements,
metadata=metadata,
)
return probe
makers.append(
ProbeMaker(
_make_ima_50_MHz_64_1d,
"ima_50_MHz_64_1d",
"Imasonic 5.0 MHz 64 elts linear array probe",
)
)
def _make_ima_25_MHz_64_1d():
metadata = dict(
probe_type="linear",
short_name="ima_25_MHz_64_1d",
long_name="Imasonic 2.5 MHz 64 elts linear array probe",
version=0,
serial="6065 A 101",
)
numelements = 64
shapes = np.full(numelements, core.ElementShape.rectangular, dtype=np.object)
orientations = g.Points.from_xyz(
np.zeros((numelements,), dtype=np.float),
np.zeros((numelements,), dtype=np.float),
np.ones((numelements,), dtype=np.float),
)
dimensions = g.Points.from_xyz(
np.full(numelements, 0.35e-3),
np.full(numelements, 15e-3),
np.full(numelements, 0.0),
)
dead_elements = np.full(numelements, False, dtype=np.bool)
probe = core.Probe.make_matrix_probe(
numx=numelements,
pitch_x=0.5e-3,
numy=1,
pitch_y=np.nan,
frequency=2.5e6,
shapes=shapes,
orientations=orientations,
dimensions=dimensions,
dead_elements=dead_elements,
metadata=metadata,
)
return probe
makers.append(
ProbeMaker(
_make_ima_25_MHz_64_1d,
"ima_25_MHz_64_1d",
"Imasonic 2.5 MHz 64 elts linear array probe",
)
)
def _make_sonaxis_150_MHz_110_1d():
metadata = dict(
probe_type="linear",
short_name="sonaxis_150_MHz_110_1d",
long_name="Sonaxis 15.0 MHz 110 elts linear array probe",
version=0,
serial="unknown",
)
numelements = 110
shapes = np.full(numelements, core.ElementShape.rectangular, dtype=np.object)
orientations = g.Points.from_xyz(
np.zeros((numelements,), dtype=np.float),
np.zeros((numelements,), dtype=np.float),
np.ones((numelements,), dtype=np.float),
)
dimensions = g.Points.from_xyz(
np.full(numelements, 0.14e-3),
np.full(numelements, 3.0e-3),
np.full(numelements, 0.0),
)
dead_elements = np.full(numelements, False, dtype=np.bool)
probe = core.Probe.make_matrix_probe(
numx=numelements,
pitch_x=0.17e-3,
numy=1,
pitch_y=np.nan,
frequency=15e6,
shapes=shapes,
orientations=orientations,
dimensions=dimensions,
dead_elements=dead_elements,
metadata=metadata,
)
return probe
makers.append(
ProbeMaker(
_make_sonaxis_150_MHz_110_1d,
"sonaxis_150_MHz_110_1d",
"Sonaxis 15.0 MHz 110 elts linear array probe",
)
)
def _make_ima_100_MHz_128_1d():
metadata = dict(
probe_type="linear",
short_name="ima_100_MHz_128_1d",
long_name="Imasonic 10.0 MHz 128 elts linear array probe",
version=0,
serial="10345 A101",
)
numelements = 128
shapes = np.full(numelements, core.ElementShape.rectangular, dtype=np.object)
orientations = g.Points.from_xyz(
np.zeros((numelements,), dtype=np.float),
np.zeros((numelements,), dtype=np.float),
np.ones((numelements,), dtype=np.float),
)
dimensions = g.Points.from_xyz(
np.full(numelements, 0.25e-3),
np.full(numelements, 10e-3),
np.full(numelements, 0.0),
)
dead_elements = np.full(numelements, False, dtype=np.bool)
probe = core.Probe.make_matrix_probe(
numx=numelements,
pitch_x=0.3e-3,
numy=1,
pitch_y=np.nan,
frequency=10e6,
shapes=shapes,
orientations=orientations,
dimensions=dimensions,
dead_elements=dead_elements,
metadata=metadata,
)
return probe
makers.append(
ProbeMaker(
_make_ima_100_MHz_128_1d,
"ima_100_MHz_128_1d",
"Imasonic 10.0 MHz 128 elts linear array probe",
)
)
| 26.55
| 81
| 0.617702
| 809
| 6,372
| 4.667491
| 0.118665
| 0.039725
| 0.112553
| 0.091367
| 0.943856
| 0.923464
| 0.888242
| 0.873146
| 0.845604
| 0.75768
| 0
| 0.063784
| 0.266792
| 6,372
| 239
| 82
| 26.661088
| 0.744435
| 0
| 0
| 0.6
| 0
| 0
| 0.10872
| 0.006913
| 0
| 0
| 0
| 0
| 0
| 1
| 0.02381
| false
| 0
| 0.019048
| 0
| 0.066667
| 0
| 0
| 0
| 0
| null | 0
| 0
| 0
| 1
| 1
| 1
| 1
| 1
| 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
| 6
|
ec6bb3961cca5e7894c1c28531de3fded45ed60d
| 20,267
|
py
|
Python
|
prophyc/tests/test_patch.py
|
florczakraf/prophy
|
a42a6151a77b31afa05300fc2e1f52cc15a298cf
|
[
"MIT"
] | 14
|
2015-02-19T22:00:37.000Z
|
2020-11-30T03:03:55.000Z
|
prophyc/tests/test_patch.py
|
florczakraf/prophy
|
a42a6151a77b31afa05300fc2e1f52cc15a298cf
|
[
"MIT"
] | 31
|
2015-06-22T11:11:10.000Z
|
2021-05-12T06:35:47.000Z
|
prophyc/tests/test_patch.py
|
florczakraf/prophy
|
a42a6151a77b31afa05300fc2e1f52cc15a298cf
|
[
"MIT"
] | 16
|
2015-06-12T06:48:06.000Z
|
2019-11-26T22:48:13.000Z
|
import os
import tempfile
import pytest
from prophyc import patch
from prophyc import model
def parse(content):
try:
with tempfile.NamedTemporaryFile(delete=False) as temp:
temp.write(content)
temp.flush()
return patch.parse(temp.name)
finally:
os.unlink(temp.name)
def test_parsing_ignoring_empty_lines():
content = b"""\
MyStruct type lastField MyRealMember
YourStruct type firstField YourRealMember
YourStruct type lastField AnotherRealMember
"""
patches = parse(content)
assert {'MyStruct': [('type', ['lastField', 'MyRealMember'])],
'YourStruct': [('type', ['firstField', 'YourRealMember']),
('type', ['lastField', 'AnotherRealMember'])]} == patches
def test_unknown_action():
nodes = [model.Struct("MyStruct", [model.StructMember("field1", "u32"),
model.StructMember("field2", "u32"),
model.StructMember("field3", "u32")])]
patches = {'MyStruct': [patch.Action('typo_or_something', [])]}
with pytest.raises(Exception) as e:
patch.patch(nodes, patches)
assert "Unknown action: MyStruct Action(action='typo_or_something', params=[])" == str(e.value)
def test_change_field_type():
nodes = [model.Struct("MyStruct", [model.StructMember("field1", "u32"),
model.StructMember("field2", "u32"),
model.StructMember("field3", "u32")])]
patches = {'MyStruct': [patch.Action('type', ['field2', 'TheRealType'])]}
patch.patch(nodes, patches)
assert [model.Struct('MyStruct', [model.StructMember('field1', 'u32'),
model.StructMember('field2', 'TheRealType'),
model.StructMember('field3', 'u32')])] == nodes
def test_change_field_type_not_a_struct():
nodes = [model.Typedef("MyStruct", "MyRealStruct")]
patches = {'MyStruct': [patch.Action('type', ['field2', 'TheRealType'])]}
with pytest.raises(Exception) as e:
patch.patch(nodes, patches)
assert "Can change field only in struct: MyStruct Action(action='type', params=['field2', 'TheRealType'])" == str(
e.value)
def test_change_field_type_no_2_params():
nodes = [model.Struct("MyStruct", [model.StructMember("field1", "u32"),
model.StructMember("field2", "u32"),
model.StructMember("field3", "u32")])]
patches = {'MyStruct': [patch.Action('type', ['field2'])]}
with pytest.raises(Exception) as e:
patch.patch(nodes, patches)
assert 'Change field must have 2 params: MyStruct' in str(e.value)
patches = {'MyStruct': [patch.Action('type', ['field2', 'TheRealType', 'extra'])]}
with pytest.raises(Exception) as e:
patch.patch(nodes, patches)
assert 'Change field must have 2 params: MyStruct' in str(e.value)
def test_change_field_type_member_not_found():
nodes = [model.Struct("MyStruct", [model.StructMember("field1", "u32"),
model.StructMember("field2", "u32"),
model.StructMember("field3", "u32")])]
patches = {'MyStruct': [patch.Action('type', ['field4', 'TheRealType'])]}
with pytest.raises(Exception) as e:
patch.patch(nodes, patches)
assert 'Member not found: MyStruct' in str(e.value)
def test_insert_field():
nodes = [model.Struct("MyStruct", [model.StructMember("field1", "u32"),
model.StructMember("field2", "u32"),
model.StructMember("field3", "u32")])]
patches = {'MyStruct': [patch.Action('insert', ['1', 'additional1', 'u8']),
patch.Action('insert', ['-1', 'additional2', 'u16']),
patch.Action('insert', ['128', 'additional3', 'u64'])]}
patch.patch(nodes, patches)
assert [model.Struct('MyStruct', [model.StructMember('field1', 'u32'),
model.StructMember('additional1', 'u8'),
model.StructMember('field2', 'u32'),
model.StructMember('additional2', 'u16'),
model.StructMember('field3', 'u32'),
model.StructMember('additional3', 'u64')])] == nodes
def test_insert_field_not_a_struct():
nodes = [model.Typedef("MyStruct", "MyRealStruct")]
patches = {'MyStruct': [patch.Action('insert', ['1', 'additional1', 'u8'])]}
with pytest.raises(Exception) as e:
patch.patch(nodes, patches)
assert 'Can insert field only in struct: MyStruct' in str(e.value)
def test_insert_field_no_3_params():
nodes = [model.Struct("MyStruct", [model.StructMember("field1", "u32")])]
patches = {'MyStruct': [patch.Action('insert', ['1', 'additional1', 'u8', 'extra'])]}
with pytest.raises(Exception) as e:
patch.patch(nodes, patches)
assert 'Change field must have 3 params: MyStruct' in str(e.value)
def test_insert_field_index_not_an_int():
nodes = [model.Struct("MyStruct", [model.StructMember("field1", "u32")])]
patches = {'MyStruct': [patch.Action('insert', ['not_a_number', 'additional1', 'u8'])]}
with pytest.raises(Exception) as e:
patch.patch(nodes, patches)
assert 'Index is not a number: MyStruct' in str(e.value)
def test_remove_field():
nodes = [model.Struct("MyStruct", [model.StructMember("field1", "u32"),
model.StructMember("field2", "u32"),
model.StructMember("field3", "u32")])]
patches = {'MyStruct': [patch.Action('remove', ['field2'])]}
patch.patch(nodes, patches)
assert [model.Struct('MyStruct', [model.StructMember('field1', 'u32'),
model.StructMember('field3', 'u32')])] == nodes
def test_remove_field_not_a_struct():
nodes = [model.Typedef("MyStruct", "MyRealStruct")]
patches = {'MyStruct': [patch.Action('remove', ['field2'])]}
with pytest.raises(Exception) as e:
patch.patch(nodes, patches)
assert 'Can remove field only in struct: MyStruct' in str(e.value)
def test_remove_field_no_1_param():
nodes = [model.Struct("MyStruct", [model.StructMember("field1", "u32")])]
patches = {'MyStruct': [patch.Action('remove', ['field1', 'extra_param'])]}
with pytest.raises(Exception) as e:
patch.patch(nodes, patches)
assert 'Remove field must have 1 param: MyStruct' in str(e.value)
def test_remove_field_not_found():
nodes = [model.Struct("MyStruct", [model.StructMember("field1", "u32")])]
patches = {'MyStruct': [patch.Action('remove', ['not_a_field'])]}
with pytest.raises(Exception) as e:
patch.patch(nodes, patches)
assert 'Member not found: MyStruct' in str(e.value)
def test_make_field_dynamic_array():
nodes = [model.Struct("MyStruct", [model.StructMember("field1", "u32"),
model.StructMember("field2", "u32"),
model.StructMember("field3", "u32")])]
patches = {'MyStruct': [patch.Action('dynamic', ['field3', 'field1'])]}
patch.patch(nodes, patches)
assert [model.Struct('MyStruct', [model.StructMember('field1', 'u32'),
model.StructMember('field2', 'u32'),
model.StructMember('field3', 'u32', bound='field1')])] == nodes
def test_make_field_dynamic_array_not_a_struct():
nodes = [model.Typedef("MyStruct", "MyRealStruct")]
patches = {'MyStruct': [patch.Action('dynamic', ['field2', 'field1'])]}
with pytest.raises(Exception) as e:
patch.patch(nodes, patches)
assert "Can change field only in struct: MyStruct" in str(e.value)
def test_make_field_dynamic_array_no_2_params():
nodes = [model.Struct("MyStruct", [model.StructMember("field1", "u32"),
model.StructMember("field2", "u32"),
model.StructMember("field3", "u32")])]
patches = {'MyStruct': [patch.Action('dynamic', ['field2'])]}
with pytest.raises(Exception) as e:
patch.patch(nodes, patches)
assert 'Change field must have 2 params: MyStruct' in str(e.value)
patches = {'MyStruct': [patch.Action('dynamic', ['field2', 'field1', 'extra'])]}
with pytest.raises(Exception) as e:
patch.patch(nodes, patches)
assert 'Change field must have 2 params: MyStruct' in str(e.value)
def test_make_field_dynamic_array_member_not_found():
nodes = [model.Struct("MyStruct", [model.StructMember("field1", "u32"),
model.StructMember("field2", "u32"),
model.StructMember("field3", "u32")])]
patches = {'MyStruct': [patch.Action('dynamic', ['field4', 'field1'])]}
with pytest.raises(Exception) as e:
patch.patch(nodes, patches)
assert 'Member not found: MyStruct' in str(e.value)
def test_make_field_greedy_array():
nodes = [model.Struct("MyStruct", [model.StructMember("field1", "u32"),
model.StructMember("field2", "u32"),
model.StructMember("field3", "u32")])]
patches = {'MyStruct': [patch.Action('greedy', ['field3'])]}
patch.patch(nodes, patches)
assert [model.Struct('MyStruct', [model.StructMember('field1', 'u32'),
model.StructMember('field2', 'u32'),
model.StructMember('field3', 'u32', greedy=True)])] == nodes
def test_make_field_greedy_array_not_a_struct():
nodes = [model.Typedef("MyStruct", "MyRealStruct")]
patches = {'MyStruct': [patch.Action('greedy', ['field2'])]}
with pytest.raises(Exception) as e:
patch.patch(nodes, patches)
assert "Can change field only in struct: MyStruct" in str(e.value)
def test_make_field_greedy_array_no_1_params():
nodes = [model.Struct("MyStruct", [model.StructMember("field1", "u32"),
model.StructMember("field2", "u32"),
model.StructMember("field3", "u32")])]
patches = {'MyStruct': [patch.Action('greedy', ['field2', 'extra_args'])]}
with pytest.raises(Exception) as e:
patch.patch(nodes, patches)
assert 'Change field must have 1 params: MyStruct' in str(e.value)
def test_make_field_greedy_array_with_wrong_name_params():
nodes = [model.Struct("MyStruct", [model.StructMember("field1", "u32"),
model.StructMember("field2", "u32"),
model.StructMember("field3", "u32")])]
patches = {'MyStruct': [patch.Action('greedy', ['field4'])]}
with pytest.raises(Exception) as e:
patch.patch(nodes, patches)
assert 'Member not found: MyStruct' in str(e.value)
def test_make_field_static_array():
nodes = [model.Struct("MyStruct", [model.StructMember("field1", "u32"),
model.StructMember("field2", "u32"),
model.StructMember("field3", "u32")])]
patches = {'MyStruct': [patch.Action('static', ['field3', '3'])]}
patch.patch(nodes, patches)
assert [model.Struct('MyStruct', [model.StructMember('field1', 'u32'),
model.StructMember('field2', 'u32'),
model.StructMember('field3', 'u32', size='3')])] == nodes
def test_make_field_static_array_not_a_struct():
nodes = [model.Typedef("MyStruct", "MyRealStruct")]
patches = {'MyStruct': [patch.Action('static', ['field2', '3'])]}
with pytest.raises(Exception) as e:
patch.patch(nodes, patches)
assert "Can change field only in struct: MyStruct" in str(e.value)
def test_make_field_static_array_no_2_params():
nodes = [model.Struct("MyStruct", [model.StructMember("field1", "u32"),
model.StructMember("field2", "u32"),
model.StructMember("field3", "u32")])]
patches = {'MyStruct': [patch.Action('static', ['field2'])]}
with pytest.raises(Exception) as e:
patch.patch(nodes, patches)
assert 'Change field must have 2 params: MyStruct' in str(e.value)
patches = {'MyStruct': [patch.Action('static', ['field2', '3', 'extra'])]}
with pytest.raises(Exception) as e:
patch.patch(nodes, patches)
assert 'Change field must have 2 params: MyStruct' in str(e.value)
def test_make_field_static_array_with_wrong_name_params():
nodes = [model.Struct("MyStruct", [model.StructMember("field1", "u32"),
model.StructMember("field2", "u32"),
model.StructMember("field3", "u32")])]
patches = {'MyStruct': [patch.Action('static', ['field4', '3'])]}
with pytest.raises(Exception) as e:
patch.patch(nodes, patches)
assert 'Member not found: MyStruct' in str(e.value)
def test_make_field_limited_array():
nodes = [model.Struct("MyStruct", [model.StructMember("field1", "u32"),
model.StructMember("field2", "u32"),
model.StructMember("field3", "u32", size='20')])]
patches = {'MyStruct': [patch.Action('limited', ['field3', 'field2'])]}
patch.patch(nodes, patches)
assert [model.Struct('MyStruct', [model.StructMember('field1', 'u32'),
model.StructMember('field2', 'u32'),
model.StructMember('field3', 'u32', bound='field2', size='20')])] == nodes
def test_fail_to_make_field_limited_array():
nodes = [model.Struct("MyStruct", [model.StructMember("field1", "u32"),
model.StructMember("field2", "u32"),
model.StructMember("after", "u32")])]
patches = {'MyStruct': [patch.Action('limited', ['field2', 'after'])]}
with pytest.raises(Exception, match="Array len member not found: "):
patch.patch(nodes, patches)
def test_make_field_limited_array_not_a_struct():
nodes = [model.Typedef("MyStruct", "MyRealStruct")]
patches = {'MyStruct': [patch.Action('limited', ['field3', 'field2'])]}
with pytest.raises(Exception) as e:
patch.patch(nodes, patches)
assert "Can change field only in struct: MyStruct" in str(e.value)
def test_make_field_limited_array_no_2_params():
nodes = [model.Struct("MyStruct", [model.StructMember("field1", "u32"),
model.StructMember("field2", "u32"),
model.StructMember("field3", "u32")])]
patches = {'MyStruct': [patch.Action('limited', ['field3'])]}
with pytest.raises(Exception) as e:
patch.patch(nodes, patches)
assert 'Change field must have 2 params: MyStruct' in str(e.value)
patches = {'MyStruct': [patch.Action('limited', ['field3', 'field2', 'extra'])]}
with pytest.raises(Exception) as e:
patch.patch(nodes, patches)
assert 'Change field must have 2 params: MyStruct' in str(e.value)
def test_make_field_limited_array_with_wrong_name_params():
nodes = [model.Struct("MyStruct", [model.StructMember("field1", "u32"),
model.StructMember("field2", "u32"),
model.StructMember("field3", "u32")])]
patches = {'MyStruct': [patch.Action('limited', ['field4', 'field2'])]}
with pytest.raises(Exception) as e:
patch.patch(nodes, patches)
assert 'Member not found: MyStruct' in str(e.value)
def test_make_field_limited_array_with_wrong_bound_params():
nodes = [model.Struct("MyStruct", [model.StructMember("field1", "u32"),
model.StructMember("field2", "u32"),
model.StructMember("field3", "u32")])]
patches = {'MyStruct': [patch.Action('limited', ['field3', 'field4'])]}
with pytest.raises(Exception) as e:
patch.patch(nodes, patches)
assert 'Array len member not found: MyStruct' in str(e.value)
def test_change_union_to_struct():
nodes = [model.Union("MyUnion", [model.UnionMember("field1", "u32", 1)])]
patches = {'MyUnion': [patch.Action('struct', [])]}
patch.patch(nodes, patches)
assert [model.Struct('MyUnion', [model.StructMember('field1', 'u32')])] == nodes
def test_change_union_to_struct_and_remove_field():
nodes = [model.Union("MyUnion", [model.UnionMember("field1", "u32", 1),
model.UnionMember("field2", "u32", 2),
model.UnionMember("field3", "u32", 3)])]
patches = {'MyUnion': [patch.Action('struct', []),
patch.Action('remove', ['field2'])]}
patch.patch(nodes, patches)
assert [model.Struct('MyUnion', [model.StructMember('field1', 'u32'),
model.StructMember('field3', 'u32')])] == nodes
def test_change_union_to_struct_not_a_union():
nodes = [model.Struct("MyStruct", [model.StructMember("field1", "u32"),
model.StructMember("field2", "u32")])]
patches = {'MyStruct': [patch.Action('struct', [])]}
with pytest.raises(Exception) as e:
patch.patch(nodes, patches)
assert 'Can only change union to struct: MyStruct' in str(e.value)
def test_change_union_to_struct_excessive_params():
nodes = [model.Union("MyUnion", [model.UnionMember("field1", "u32", 1),
model.UnionMember("field2", "u32", 2)])]
patches = {'MyUnion': [patch.Action('struct', ['surplus_param'])]}
with pytest.raises(Exception) as e:
patch.patch(nodes, patches)
assert 'Change union to struct takes no params: MyUnion' in str(e.value)
def test_rename_node():
nodes = [model.Struct("OldStruct", [model.StructMember("field", "u32")]),
model.Enum("OldEnum", [model.EnumMember("val", "123")])]
patches = {'OldStruct': [patch.Action('rename', ['NewStruct'])],
'OldEnum': [patch.Action('rename', ['NewEnum'])]}
patch.patch(nodes, patches)
assert nodes[0].name == 'NewStruct'
assert nodes[1].name == 'NewEnum'
def test_rename_field():
nodes = [model.Struct("MyStruct", [model.StructMember("field1", "u32"),
model.StructMember("field2", "u32"),
model.StructMember("field3", "u32")])]
patches = {'MyStruct': [patch.Action('rename', ['field2', 'field69'])]}
patch.patch(nodes, patches)
assert [model.Struct('MyStruct', [model.StructMember('field1', 'u32'),
model.StructMember('field69', 'u32'),
model.StructMember('field3', 'u32')])] == nodes
def test_rename_field_not_composite():
nodes = [model.Enum("MyEnum", [model.EnumMember("val", "123")])]
patches = {'MyEnum': [patch.Action('rename', ['field3', 'field69'])]}
with pytest.raises(Exception) as e:
patch.patch(nodes, patches)
assert 'Can rename fields only in composites: MyEnum' in str(e.value)
def test_rename_field_member_not_found():
nodes = [model.Struct("MyStruct", [model.StructMember("field1", "u32")])]
patches = {'MyStruct': [patch.Action('rename', ['unknown1', 'unknown2'])]}
with pytest.raises(Exception) as e:
patch.patch(nodes, patches)
assert 'Member not found: MyStruct' in str(e.value)
def test_rename_field_excessive_params():
nodes = [model.Struct("MyStruct", [model.StructMember("field1", "u32")])]
patches = {'MyStruct': [patch.Action('rename', 3 * ['too_much_params'])]}
with pytest.raises(Exception) as e:
patch.patch(nodes, patches)
assert 'Rename must have 1 or 2 params: MyStruct' in str(e.value)
| 41.193089
| 118
| 0.583954
| 2,131
| 20,267
| 5.444862
| 0.064289
| 0.147979
| 0.101698
| 0.083427
| 0.873826
| 0.856503
| 0.834526
| 0.815565
| 0.779971
| 0.761355
| 0
| 0.028647
| 0.255933
| 20,267
| 491
| 119
| 41.276986
| 0.740782
| 0
| 0
| 0.575221
| 0
| 0.00295
| 0.209256
| 0.002714
| 0
| 0
| 0
| 0
| 0.132743
| 1
| 0.123894
| false
| 0
| 0.014749
| 0
| 0.141593
| 0
| 0
| 0
| 0
| null | 0
| 0
| 0
| 1
| 1
| 1
| 1
| 1
| 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
| 6
|
eca6fbc6bec29883c8e32a2320a8ba325b4469e8
| 133
|
py
|
Python
|
rtamt/exception/stl/exception.py
|
BentleyJOakes/rtamt
|
5366349c44afb53cffa5fb29e43fea1eb23b6c52
|
[
"BSD-2-Clause-FreeBSD",
"BSD-3-Clause"
] | null | null | null |
rtamt/exception/stl/exception.py
|
BentleyJOakes/rtamt
|
5366349c44afb53cffa5fb29e43fea1eb23b6c52
|
[
"BSD-2-Clause-FreeBSD",
"BSD-3-Clause"
] | null | null | null |
rtamt/exception/stl/exception.py
|
BentleyJOakes/rtamt
|
5366349c44afb53cffa5fb29e43fea1eb23b6c52
|
[
"BSD-2-Clause-FreeBSD",
"BSD-3-Clause"
] | null | null | null |
class STLException(Exception):
pass
class STLParseException(Exception):
pass
class STLOfflineException(Exception):
pass
| 16.625
| 37
| 0.766917
| 12
| 133
| 8.5
| 0.5
| 0.382353
| 0.352941
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0.165414
| 133
| 8
| 38
| 16.625
| 0.918919
| 0
| 0
| 0.5
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 1
| 0
| true
| 0.5
| 0
| 0
| 0.5
| 0
| 1
| 0
| 0
| null | 1
| 1
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 1
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| null | 0
| 0
| 0
| 0
| 0
| 0
| 1
| 1
| 0
| 0
| 0
| 0
|
0
| 6
|
ecc7959a69faf00f7939f4c240d2ec3110ca77e2
| 720
|
py
|
Python
|
citrination_client/models/columns/__init__.py
|
matSciMalcolm/python-citrination-client
|
a59a2ddd49b3a4323a3393ce13c81172c9b1b645
|
[
"Apache-2.0"
] | null | null | null |
citrination_client/models/columns/__init__.py
|
matSciMalcolm/python-citrination-client
|
a59a2ddd49b3a4323a3393ce13c81172c9b1b645
|
[
"Apache-2.0"
] | null | null | null |
citrination_client/models/columns/__init__.py
|
matSciMalcolm/python-citrination-client
|
a59a2ddd49b3a4323a3393ce13c81172c9b1b645
|
[
"Apache-2.0"
] | null | null | null |
from citrination_client.models.columns.base import BaseColumn
from citrination_client.models.columns.categorical import CategoricalColumn
from citrination_client.models.columns.real import RealColumn
from citrination_client.models.columns.vector import VectorColumn
from citrination_client.models.columns.organic_chemical_formula import OrganicChemicalFormulaColumn
from citrination_client.models.columns.inorganic_chemical_formula import InorganicChemicalFormulaColumn
from citrination_client.models.columns.alloy_composition import AlloyCompositionColumn
from citrination_client.models.columns.descriptor_converter import DescriptorConverter
from citrination_client.models.columns.formulation import FormulationColumn
| 72
| 103
| 0.9125
| 78
| 720
| 8.230769
| 0.358974
| 0.21028
| 0.294393
| 0.378505
| 0.476636
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0.05
| 720
| 9
| 104
| 80
| 0.938596
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 1
| 0
| true
| 0
| 1
| 0
| 1
| 0
| 0
| 0
| 0
| null | 1
| 1
| 1
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 1
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| null | 0
| 0
| 0
| 0
| 0
| 0
| 1
| 0
| 1
| 0
| 0
| 0
|
0
| 6
|
ece20f1b737966a8efddfc4eba24fdbf076f2f38
| 44
|
py
|
Python
|
sonipy/__init__.py
|
Sabrina-Knappe/sonipy
|
eaf89afaee0d9c2d5ba7a035d43e651b8919b84e
|
[
"MIT"
] | 22
|
2020-07-04T19:05:25.000Z
|
2022-02-25T08:39:01.000Z
|
sonipy/__init__.py
|
Sabrina-Knappe/sonipy
|
eaf89afaee0d9c2d5ba7a035d43e651b8919b84e
|
[
"MIT"
] | 6
|
2020-07-07T17:09:00.000Z
|
2021-04-12T16:37:41.000Z
|
sonipy/__init__.py
|
Sabrina-Knappe/sonipy
|
eaf89afaee0d9c2d5ba7a035d43e651b8919b84e
|
[
"MIT"
] | 6
|
2020-07-07T08:28:33.000Z
|
2021-12-21T03:52:09.000Z
|
from .scales import *
from .sonify import *
| 14.666667
| 21
| 0.727273
| 6
| 44
| 5.333333
| 0.666667
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0.181818
| 44
| 2
| 22
| 22
| 0.888889
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 1
| 0
| true
| 0
| 1
| 0
| 1
| 0
| 1
| 1
| 0
| null | 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 1
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| null | 0
| 0
| 0
| 0
| 0
| 0
| 1
| 0
| 1
| 0
| 1
| 0
|
0
| 6
|
01c47866163e1573d28bc2565b4b02e5f2df9c72
| 350
|
py
|
Python
|
simba/utils.py
|
atra94/simba
|
0bc2df85474f744711dbc5abf972bd52f3d68ef9
|
[
"MIT"
] | 3
|
2021-01-15T12:37:33.000Z
|
2022-01-13T16:30:02.000Z
|
simba/utils.py
|
atra94/simba
|
0bc2df85474f744711dbc5abf972bd52f3d68ef9
|
[
"MIT"
] | null | null | null |
simba/utils.py
|
atra94/simba
|
0bc2df85474f744711dbc5abf972bd52f3d68ef9
|
[
"MIT"
] | null | null | null |
class Event:
def __init__(self):
self._callee_list = set()
def __iadd__(self, fct):
return self._callee_list.add(fct)
def __isub__(self, fct):
return self._callee_list.remove(fct)
def __call__(self, sender, *event_args):
for callee in self._callee_list:
callee(sender, *event_args)
| 23.333333
| 44
| 0.625714
| 45
| 350
| 4.288889
| 0.422222
| 0.207254
| 0.290155
| 0.176166
| 0.279793
| 0.279793
| 0
| 0
| 0
| 0
| 0
| 0
| 0.271429
| 350
| 14
| 45
| 25
| 0.756863
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 1
| 0.4
| false
| 0
| 0
| 0.2
| 0.7
| 0
| 0
| 0
| 0
| null | 1
| 1
| 1
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| null | 0
| 0
| 0
| 0
| 0
| 1
| 0
| 0
| 0
| 1
| 1
| 0
|
0
| 6
|
01e0ff6e40e97eb1802841be592b3476f758545c
| 33
|
py
|
Python
|
final_project/machinetranslation/__init__.py
|
ns12356/xzceb-flask_eng_fr
|
0e91b3014db27c81738c98b64462e8e87f7fc21d
|
[
"Apache-2.0"
] | null | null | null |
final_project/machinetranslation/__init__.py
|
ns12356/xzceb-flask_eng_fr
|
0e91b3014db27c81738c98b64462e8e87f7fc21d
|
[
"Apache-2.0"
] | null | null | null |
final_project/machinetranslation/__init__.py
|
ns12356/xzceb-flask_eng_fr
|
0e91b3014db27c81738c98b64462e8e87f7fc21d
|
[
"Apache-2.0"
] | null | null | null |
from . import machinetranslation
| 16.5
| 32
| 0.848485
| 3
| 33
| 9.333333
| 1
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0.121212
| 33
| 1
| 33
| 33
| 0.965517
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 1
| 0
| true
| 0
| 1
| 0
| 1
| 0
| 1
| 1
| 0
| null | 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 1
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| null | 0
| 0
| 0
| 0
| 0
| 0
| 1
| 0
| 1
| 0
| 1
| 0
|
0
| 6
|
01f37e2627bdf0650bbe37c89b6eb954904efbc3
| 96
|
py
|
Python
|
venv/lib/python3.8/site-packages/attr/converters.py
|
Retraces/UkraineBot
|
3d5d7f8aaa58fa0cb8b98733b8808e5dfbdb8b71
|
[
"MIT"
] | 2
|
2022-03-13T01:58:52.000Z
|
2022-03-31T06:07:54.000Z
|
venv/lib/python3.8/site-packages/attr/converters.py
|
DesmoSearch/Desmobot
|
b70b45df3485351f471080deb5c785c4bc5c4beb
|
[
"MIT"
] | 19
|
2021-11-20T04:09:18.000Z
|
2022-03-23T15:05:55.000Z
|
venv/lib/python3.8/site-packages/attr/converters.py
|
DesmoSearch/Desmobot
|
b70b45df3485351f471080deb5c785c4bc5c4beb
|
[
"MIT"
] | null | null | null |
/home/runner/.cache/pip/pool/ba/28/96/4f3f062c97bc2354f2ed42022b50de815527a874d76ce4a76abee0ecd9
| 96
| 96
| 0.895833
| 9
| 96
| 9.555556
| 1
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0.40625
| 0
| 96
| 1
| 96
| 96
| 0.489583
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 1
| 0
| 0
| 0
| 0
| null | null | 0
| 0
| null | null | 0
| 1
| 0
| 0
| null | 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 1
| 0
| 0
| 1
| 0
| 0
| 1
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| null | 1
| 0
| 0
| 0
| 1
| 0
| 0
| 0
| 0
| 0
| 0
| 0
|
0
| 6
|
bf02cd94f2b530b1f30571406f9a7540d2069698
| 2,503
|
py
|
Python
|
epytope/Data/pssms/smm/mat/A_23_01_10.py
|
christopher-mohr/epytope
|
8ac9fe52c0b263bdb03235a5a6dffcb72012a4fd
|
[
"BSD-3-Clause"
] | 7
|
2021-02-01T18:11:28.000Z
|
2022-01-31T19:14:07.000Z
|
epytope/Data/pssms/smm/mat/A_23_01_10.py
|
christopher-mohr/epytope
|
8ac9fe52c0b263bdb03235a5a6dffcb72012a4fd
|
[
"BSD-3-Clause"
] | 22
|
2021-01-02T15:25:23.000Z
|
2022-03-14T11:32:53.000Z
|
epytope/Data/pssms/smm/mat/A_23_01_10.py
|
christopher-mohr/epytope
|
8ac9fe52c0b263bdb03235a5a6dffcb72012a4fd
|
[
"BSD-3-Clause"
] | 4
|
2021-05-28T08:50:38.000Z
|
2022-03-14T11:45:32.000Z
|
A_23_01_10 = {0: {'A': 0.133, 'C': 0.275, 'E': 0.287, 'D': 0.195, 'G': 0.212, 'F': -0.292, 'I': 0.005, 'H': 0.23, 'K': 0.084, 'M': -0.158, 'L': 0.011, 'N': -0.026, 'Q': -0.011, 'P': -0.026, 'S': 0.069, 'R': -0.333, 'T': 0.047, 'W': -0.113, 'V': -0.224, 'Y': -0.365}, 1: {'A': 0.238, 'C': 0.156, 'E': 0.216, 'D': 0.071, 'G': 0.076, 'F': -0.7, 'I': 0.445, 'H': 0.279, 'K': 0.119, 'M': -0.153, 'L': 0.112, 'N': 0.528, 'Q': 0.132, 'P': 0.523, 'S': 0.138, 'R': -0.011, 'T': 0.492, 'W': -1.217, 'V': 0.047, 'Y': -1.493}, 2: {'A': 0.045, 'C': -0.099, 'E': 0.328, 'D': 0.11, 'G': 0.015, 'F': -0.574, 'I': -0.322, 'H': 0.266, 'K': 0.294, 'M': -0.446, 'L': -0.264, 'N': 0.417, 'Q': 0.339, 'P': -0.104, 'S': 0.105, 'R': 0.207, 'T': 0.188, 'W': -0.192, 'V': 0.126, 'Y': -0.439}, 3: {'A': -0.053, 'C': -0.041, 'E': 0.028, 'D': -0.057, 'G': -0.09, 'F': 0.056, 'I': 0.014, 'H': 0.107, 'K': 0.111, 'M': -0.095, 'L': 0.015, 'N': 0.02, 'Q': 0.072, 'P': 0.014, 'S': -0.134, 'R': 0.028, 'T': 0.038, 'W': -0.062, 'V': 0.096, 'Y': -0.067}, 4: {'A': -0.182, 'C': 0.097, 'E': 0.043, 'D': -0.004, 'G': 0.132, 'F': -0.097, 'I': 0.074, 'H': 0.018, 'K': 0.176, 'M': -0.093, 'L': -0.037, 'N': 0.03, 'Q': 0.16, 'P': -0.035, 'S': -0.084, 'R': -0.032, 'T': 0.044, 'W': 0.064, 'V': -0.04, 'Y': -0.235}, 5: {'A': 0.075, 'C': -0.032, 'E': 0.06, 'D': 0.074, 'G': -0.011, 'F': -0.087, 'I': -0.089, 'H': 0.052, 'K': -0.005, 'M': -0.025, 'L': 0.047, 'N': -0.073, 'Q': -0.011, 'P': 0.082, 'S': 0.062, 'R': 0.113, 'T': -0.159, 'W': -0.055, 'V': 0.029, 'Y': -0.047}, 6: {'A': 0.0, 'C': 0.0, 'E': 0.0, 'D': 0.0, 'G': -0.0, 'F': -0.0, 'I': -0.0, 'H': 0.0, 'K': 0.0, 'M': -0.0, 'L': -0.0, 'N': 0.0, 'Q': 0.0, 'P': -0.0, 'S': 0.0, 'R': 0.0, 'T': -0.0, 'W': -0.0, 'V': -0.0, 'Y': -0.0}, 7: {'A': -0.079, 'C': -0.321, 'E': 0.358, 'D': 0.347, 'G': 0.236, 'F': -0.305, 'I': 0.142, 'H': -0.007, 'K': 0.617, 'M': -0.247, 'L': -0.365, 'N': 0.243, 'Q': -0.01, 'P': -0.31, 'S': -0.138, 'R': 0.397, 'T': 0.165, 'W': -0.148, 'V': -0.057, 'Y': -0.517}, 8: {'A': 0.1, 'C': 0.037, 'E': 0.169, 'D': 0.271, 'G': 0.283, 'F': -0.199, 'I': -0.102, 'H': 0.033, 'K': 0.193, 'M': -0.086, 'L': -0.378, 'N': -0.336, 'Q': 0.161, 'P': 0.293, 'S': -0.066, 'R': 0.31, 'T': -0.325, 'W': 0.153, 'V': -0.251, 'Y': -0.261}, 9: {'A': 0.54, 'C': 0.166, 'E': 0.0, 'D': 0.0, 'G': 0.401, 'F': -1.637, 'I': -0.405, 'H': 0.0, 'K': 0.821, 'M': 0.513, 'L': -0.49, 'N': 0.0, 'Q': -0.506, 'P': 0.0, 'S': 0.0, 'R': 0.737, 'T': 0.006, 'W': -0.809, 'V': 0.376, 'Y': 0.287}, -1: {'con': 4.48671}}
| 2,503
| 2,503
| 0.383939
| 618
| 2,503
| 1.550162
| 0.289644
| 0.05428
| 0.010438
| 0.012526
| 0.083507
| 0.033403
| 0.033403
| 0.033403
| 0
| 0
| 0
| 0.360938
| 0.165402
| 2,503
| 1
| 2,503
| 2,503
| 0.097654
| 0
| 0
| 0
| 0
| 0
| 0.08107
| 0
| 0
| 0
| 0
| 0
| 0
| 1
| 0
| false
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 1
| null | 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 1
| 0
| 0
| 1
| 1
| 1
| 1
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| null | 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
|
0
| 6
|
bf0379b343888a2fdff27906cd8519c1689c9c83
| 4,788
|
py
|
Python
|
coreutils/fileutil.py
|
bcsr0009/pdtf
|
5d3cc7933ac07457f6b4b59f2d4d70e0de1ffaec
|
[
"MIT"
] | null | null | null |
coreutils/fileutil.py
|
bcsr0009/pdtf
|
5d3cc7933ac07457f6b4b59f2d4d70e0de1ffaec
|
[
"MIT"
] | null | null | null |
coreutils/fileutil.py
|
bcsr0009/pdtf
|
5d3cc7933ac07457f6b4b59f2d4d70e0de1ffaec
|
[
"MIT"
] | null | null | null |
# coding: utf-8
import requests
import json
import paramiko
import time
import logging
import os
import difflib
import pdb
from coreutils.logdecorator import logwrap
@logwrap
def execute_command(ssh_connection_handler, cmd):
'''
This method provides execute_command option on device
'''
stdin,stdout,stderr=ssh_connection_handler.exec_command(cmd)
return stdin,stdout,stderr
@logwrap
def build_show_config_from_stdout(stdout, file):
'''
This method redirects stdout from execute command of device to file
'''
with open(file, "w") as rcbsp:
for line in stdout.readlines():
rcbsp.write(line)
def get_running_config(ssh_connection_handler, config_file, cmd):
execute_command_result = execute_command(ssh_connection_handler, cmd)
build_show_config_from_stdout(execute_command_result[1], config_file)
@logwrap
def get_running_config_from_ncs_before_service_push(ssh_connection_handler, before_service_push_config_file, cmd):
'''
This method provides NCS running config before service create
'''
get_running_config(ssh_connection_handler, before_service_push_config_file, cmd)
@logwrap
def get_running_config_from_ncs_before_service_delete(ssh_connection_handler, before_service_delete_config_file, cmd):
'''
This method provides running config before service delete
'''
get_running_config(ssh_connection_handler, before_service_delete_config_file, cmd)
@logwrap
def get_running_config_from_device_before_service_push(ssh_connection_handler, before_service_push_config_file, cmd):
'''
This method provides running config before service create
'''
get_running_config(ssh_connection_handler, before_service_push_config_file, cmd)
@logwrap
def get_running_config_from_device_before_service_delete(ssh_connection_handler, before_service_delete_config_file, cmd):
'''
This method provides running config before service delete
'''
get_running_config(ssh_connection_handler, before_service_delete_config_file, cmd)
@logwrap
def get_running_config_from_device_after_service_push(ssh_connection_handler, after_service_push_config_file, cmd):
'''
This method provides running config after service create
'''
get_running_config(ssh_connection_handler, after_service_push_config_file, cmd)
@logwrap
def get_running_config_from_ncs_after_service_push(ssh_connection_handler, after_service_push_config_file, cmd):
'''
This method provides NCS running config after service create
'''
get_running_config(ssh_connection_handler, after_service_push_config_file, cmd)
@logwrap
def get_running_config_from_ncs_after_service_delete(ssh_connection_handler, after_service_delete_config_file, cmd):
'''
This method provides running config after service delete
'''
get_running_config(ssh_connection_handler, after_service_delete_config_file, cmd)
@logwrap
def get_running_config_from_device_after_service_delete(ssh_connection_handler, after_service_delete_config_file, cmd):
'''
This method provides running config after service delete
'''
get_running_config(ssh_connection_handler, after_service_delete_config_file, cmd)
@logwrap
def get_generated_config_from_service_create(before_service_push, after_service_push, generated_service_config):
'''
This method provides generated config out of (before and after running configs )
'''
with open(before_service_push, 'r') as before_service_push_file_obj, open(after_service_push, 'r') as after_service_push_file_obj:
before_service_push_file_content = before_service_push_file_obj.readlines()
after_service_push_file_content = after_service_push_file_obj.readlines()
with open(generated_service_config, 'w') as generated_service_config_obj:
for line in after_service_push_file_content:
if line in before_service_push_file_content:
continue
generated_service_config_obj.write(line)
@logwrap
def get_generated_config_from_service_delete(before_service_push, after_service_push, generated_service_config):
'''
This method provides generated config out of (before and after running configs )
'''
with open(before_service_push, 'r') as before_service_push_file_obj, open(after_service_push, 'r') as after_service_push_file_obj:
before_service_push_file_content = before_service_push_file_obj.readlines()
after_service_push_file_content = after_service_push_file_obj.readlines()
with open(generated_service_config, 'w') as generated_service_config_obj:
for line in before_service_push_file_content:
if line in after_service_push_file_content:
continue
generated_service_config_obj.write(line)
| 38.926829
| 134
| 0.794277
| 647
| 4,788
| 5.404946
| 0.109737
| 0.11324
| 0.114384
| 0.054046
| 0.861882
| 0.847584
| 0.816128
| 0.774092
| 0.774092
| 0.764655
| 0
| 0.00049
| 0.147452
| 4,788
| 122
| 135
| 39.245902
| 0.856198
| 0.159983
| 0
| 0.492308
| 0
| 0
| 0.001822
| 0
| 0
| 0
| 0
| 0
| 0
| 1
| 0.2
| false
| 0
| 0.138462
| 0
| 0.353846
| 0
| 0
| 0
| 0
| null | 0
| 0
| 0
| 1
| 1
| 1
| 1
| 1
| 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
| 6
|
bf144304fabb494f980405689a5f16c7ec566384
| 361
|
py
|
Python
|
strikethrough_classification/src/__init__.py
|
RaphaelaHeil/strikethrough-removal-cyclegans
|
91555b22cac6b6a379597aa94c23bdf02c9970a7
|
[
"MIT"
] | 3
|
2021-08-30T12:37:14.000Z
|
2022-02-09T16:07:14.000Z
|
strikethrough_classification/src/__init__.py
|
ektavats/strikethrough-removal-cyclegans
|
35456619ff87fa010d2c161cff774af02142bae9
|
[
"MIT"
] | null | null | null |
strikethrough_classification/src/__init__.py
|
ektavats/strikethrough-removal-cyclegans
|
35456619ff87fa010d2c161cff774af02142bae9
|
[
"MIT"
] | 1
|
2022-01-25T10:30:54.000Z
|
2022-01-25T10:30:54.000Z
|
from .configuration import ModelName, Configuration, getConfiguration
from .dataset import StrikeThroughType, StruckDataset
from .utils import PadToSize, composeTransformations, getModelByName
__all__ = ["ModelName", "Configuration", "getConfiguration", "StrikeThroughType", "StruckDataset", "PadToSize",
"composeTransformations", "getModelByName"]
| 51.571429
| 111
| 0.797784
| 26
| 361
| 10.923077
| 0.5
| 0.15493
| 0.267606
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0.108033
| 361
| 6
| 112
| 60.166667
| 0.881988
| 0
| 0
| 0
| 0
| 0
| 0.313019
| 0.060942
| 0
| 0
| 0
| 0
| 0
| 1
| 0
| false
| 0
| 0.6
| 0
| 0.6
| 0
| 1
| 0
| 1
| null | 0
| 1
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 1
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| null | 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 1
| 0
| 1
| 0
|
0
| 6
|
177ed09ba9c9097a94809f1d850752a1a5ffa451
| 31
|
py
|
Python
|
PyCypher/__init__.py
|
medhansh/PyCypher
|
e04a7cbc59cd1a719648b734fe850b3f818d66df
|
[
"MIT"
] | null | null | null |
PyCypher/__init__.py
|
medhansh/PyCypher
|
e04a7cbc59cd1a719648b734fe850b3f818d66df
|
[
"MIT"
] | null | null | null |
PyCypher/__init__.py
|
medhansh/PyCypher
|
e04a7cbc59cd1a719648b734fe850b3f818d66df
|
[
"MIT"
] | null | null | null |
from PyCypher.pycypher import *
| 31
| 31
| 0.83871
| 4
| 31
| 6.5
| 0.75
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0.096774
| 31
| 1
| 31
| 31
| 0.928571
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 1
| 0
| true
| 0
| 1
| 0
| 1
| 0
| 1
| 1
| 0
| null | 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 1
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| null | 0
| 0
| 0
| 0
| 0
| 0
| 1
| 0
| 1
| 0
| 1
| 0
|
0
| 6
|
bd60f38bc43fc347a860583e3556473c295a48ea
| 3,286
|
py
|
Python
|
tests/test_filter.py
|
ttxskk/mmhuman3d
|
f6d39e24a2d5cc216448fc3bd82832ff45eee436
|
[
"Apache-2.0"
] | 1
|
2021-12-03T04:17:52.000Z
|
2021-12-03T04:17:52.000Z
|
tests/test_filter.py
|
ttxskk/mmhuman3d
|
f6d39e24a2d5cc216448fc3bd82832ff45eee436
|
[
"Apache-2.0"
] | null | null | null |
tests/test_filter.py
|
ttxskk/mmhuman3d
|
f6d39e24a2d5cc216448fc3bd82832ff45eee436
|
[
"Apache-2.0"
] | null | null | null |
import numpy as np
import torch
from mmhuman3d.core.filter.builder import build_filter
# test different data type
def test_data_type_torch():
noisy_input = torch.randn((100, 17, 3))
cfg = dict(type='OneEuroFilter', min_cutoff=0.004, beta=0.7)
oneeuro = build_filter(cfg)
out_g = oneeuro(noisy_input)
cfg = dict(type='Gaus1dFilter', window_size=11, sigma=4)
gaus1d = build_filter(cfg)
out_s = gaus1d(noisy_input)
cfg = dict(type='SGFilter', window_size=11, polyorder=2)
savgol = build_filter(cfg)
out_o = savgol(noisy_input)
# verify the correctness
accel_input = noisy_input[:-2] - 2 * noisy_input[1:-1] + noisy_input[2:]
accel_out_g = out_g[:-2] - 2 * out_g[1:-1] + out_g[2:]
accel_input_abs = torch.mean(torch.abs(accel_input))
assert accel_input_abs >= torch.mean(torch.abs(accel_out_g))
accel_out_s = out_s[:-2] - 2 * out_s[1:-1] + out_s[2:]
assert accel_input_abs >= torch.mean(torch.abs(accel_out_s))
accel_out_o = out_o[:-2] - 2 * out_o[1:-1] + out_o[2:]
assert accel_input_abs >= torch.mean(torch.abs(accel_out_o))
assert out_g.shape == noisy_input.shape == out_s.shape == out_o.shape
def test_data_type_torch_zero():
noisy_input = torch.zeros((50, 20, 3))
cfg = dict(type='OneEuroFilter', min_cutoff=0.004, beta=0.7)
oneeuro = build_filter(cfg)
out_g = oneeuro(noisy_input)
cfg = dict(type='Gaus1dFilter', window_size=11, sigma=4)
gaus1d = build_filter(cfg)
out_s = gaus1d(noisy_input)
cfg = dict(type='SGFilter', window_size=11, polyorder=2)
savgol = build_filter(cfg)
out_o = savgol(noisy_input)
# verify the correctness
accel_input = noisy_input[:-2] - 2 * noisy_input[1:-1] + noisy_input[2:]
accel_out_g = out_g[:-2] - 2 * out_g[1:-1] + out_g[2:]
assert torch.mean(accel_input) >= torch.mean(accel_out_g)
accel_out_s = out_s[:-2] - 2 * out_s[1:-1] + out_s[2:]
assert torch.mean(accel_input) >= torch.mean(accel_out_s)
accel_out_o = out_o[:-2] - 2 * out_o[1:-1] + out_o[2:]
assert torch.mean(accel_input) >= torch.mean(accel_out_o)
assert out_g.shape == noisy_input.shape == out_s.shape == out_o.shape
def test_data_type_torch_cuda():
if not torch.cuda.is_available():
return
noisy_input = torch.randn((3, 24, 4)).cuda()
cfg = dict(type='OneEuroFilter', min_cutoff=0.0004, beta=0.7)
oneeuro = build_filter(cfg)
out_g = oneeuro(noisy_input)
cfg = dict(type='Gaus1dFilter', window_size=6, sigma=1)
gaus1d = build_filter(cfg)
out_s = gaus1d(noisy_input)
cfg = dict(type='SGFilter', window_size=7, polyorder=2)
savgol = build_filter(cfg)
out_o = savgol(noisy_input)
assert out_g.shape == noisy_input.shape == out_s.shape == out_o.shape
def test_data_type_np():
noisy_input = np.random.rand(100, 24, 6)
cfg = dict(type='OneEuroFilter', min_cutoff=0.004, beta=0.1)
oneeuro = build_filter(cfg)
out_g = oneeuro(noisy_input)
cfg = dict(type='Gaus1dFilter', window_size=5, sigma=2)
gaus1d = build_filter(cfg)
out_s = gaus1d(noisy_input)
cfg = dict(type='SGFilter', window_size=5, polyorder=2)
savgol = build_filter(cfg)
out_o = savgol(noisy_input)
assert out_g.shape == noisy_input.shape == out_s.shape == out_o.shape
| 40.567901
| 76
| 0.678637
| 541
| 3,286
| 3.852126
| 0.133087
| 0.12476
| 0.06334
| 0.097889
| 0.872361
| 0.862764
| 0.862764
| 0.846449
| 0.829655
| 0.829655
| 0
| 0.044041
| 0.177724
| 3,286
| 80
| 77
| 41.075
| 0.727239
| 0.021303
| 0
| 0.617647
| 0
| 0
| 0.041109
| 0
| 0
| 0
| 0
| 0
| 0.147059
| 1
| 0.058824
| false
| 0
| 0.044118
| 0
| 0.117647
| 0
| 0
| 0
| 0
| null | 0
| 0
| 0
| 1
| 1
| 1
| 1
| 1
| 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
| 6
|
bdeceaf201a59dd5aa4139656609d9bb1898559e
| 135
|
py
|
Python
|
isbit_client/__init__.py
|
ISBITX/isbit-client-python
|
6943b69cb15d12a8c524461467e3806ab5b1ba19
|
[
"MIT"
] | 1
|
2018-04-22T01:30:21.000Z
|
2018-04-22T01:30:21.000Z
|
isbit_client/__init__.py
|
ISBITX/isbit-client-python
|
6943b69cb15d12a8c524461467e3806ab5b1ba19
|
[
"MIT"
] | 1
|
2018-04-26T05:30:41.000Z
|
2018-04-26T05:30:41.000Z
|
isbit_client/__init__.py
|
ISBITX/isbit-client-python
|
6943b69cb15d12a8c524461467e3806ab5b1ba19
|
[
"MIT"
] | 1
|
2018-04-26T01:54:42.000Z
|
2018-04-26T01:54:42.000Z
|
# coding:utf-8
from .client import IsbitClient
from .streaming_client import StreamingIsbitClient
from .error import IsbitClientError
| 22.5
| 50
| 0.844444
| 16
| 135
| 7.0625
| 0.6875
| 0.212389
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0.008333
| 0.111111
| 135
| 5
| 51
| 27
| 0.933333
| 0.088889
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 1
| 0
| true
| 0
| 1
| 0
| 1
| 0
| 1
| 0
| 0
| null | 1
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 1
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| null | 0
| 0
| 0
| 0
| 0
| 0
| 1
| 0
| 1
| 0
| 1
| 0
|
0
| 6
|
bdee3bbbc5846fcbb9c599c3f61ee74ec8b79de2
| 30
|
py
|
Python
|
src/envs/particle/__init__.py
|
MarShin/pymarl2
|
b6598cbd3ca044564270b6cdb1bb495173af7f4c
|
[
"Apache-2.0"
] | 4
|
2022-03-17T05:01:30.000Z
|
2022-03-17T05:09:17.000Z
|
src/envs/particle/__init__.py
|
MarShin/pymarl2
|
b6598cbd3ca044564270b6cdb1bb495173af7f4c
|
[
"Apache-2.0"
] | null | null | null |
src/envs/particle/__init__.py
|
MarShin/pymarl2
|
b6598cbd3ca044564270b6cdb1bb495173af7f4c
|
[
"Apache-2.0"
] | null | null | null |
from .particle import Particle
| 30
| 30
| 0.866667
| 4
| 30
| 6.5
| 0.75
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0.1
| 30
| 1
| 30
| 30
| 0.962963
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 1
| 0
| true
| 0
| 1
| 0
| 1
| 0
| 1
| 1
| 0
| null | 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 1
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| null | 0
| 0
| 0
| 0
| 0
| 0
| 1
| 0
| 1
| 0
| 1
| 0
|
0
| 6
|
da01426a41ad3cb80b0221a75ea0d9536d0d1c0c
| 83
|
py
|
Python
|
moff/node/root_node.py
|
Tikubonn/moff
|
1c363f60959138311068177fca177d0f0dc97380
|
[
"MIT"
] | null | null | null |
moff/node/root_node.py
|
Tikubonn/moff
|
1c363f60959138311068177fca177d0f0dc97380
|
[
"MIT"
] | null | null | null |
moff/node/root_node.py
|
Tikubonn/moff
|
1c363f60959138311068177fca177d0f0dc97380
|
[
"MIT"
] | null | null | null |
from .template import CollectionNode
class RootNode (CollectionNode):
pass
| 10.375
| 36
| 0.759036
| 8
| 83
| 7.875
| 0.875
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0.192771
| 83
| 7
| 37
| 11.857143
| 0.940299
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 1
| 0
| true
| 0.333333
| 0.333333
| 0
| 0.666667
| 0
| 1
| 0
| 0
| null | 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 1
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| null | 0
| 0
| 0
| 0
| 0
| 0
| 1
| 1
| 1
| 0
| 1
| 0
|
0
| 6
|
da0c98cc404659f3bfef5ebfddfa868314744351
| 70
|
py
|
Python
|
core/spectrum/__init__.py
|
VasilyevEvgeny/self-focusing_3D
|
c90b4d78d2d72365566f8a49b325bd48127b1e44
|
[
"MIT"
] | null | null | null |
core/spectrum/__init__.py
|
VasilyevEvgeny/self-focusing_3D
|
c90b4d78d2d72365566f8a49b325bd48127b1e44
|
[
"MIT"
] | null | null | null |
core/spectrum/__init__.py
|
VasilyevEvgeny/self-focusing_3D
|
c90b4d78d2d72365566f8a49b325bd48127b1e44
|
[
"MIT"
] | null | null | null |
from .spectrum_r import SpectrumR
from .spectrum_xy import SpectrumXY
| 23.333333
| 35
| 0.857143
| 10
| 70
| 5.8
| 0.7
| 0.413793
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0.114286
| 70
| 2
| 36
| 35
| 0.935484
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 1
| 0
| true
| 0
| 1
| 0
| 1
| 0
| 1
| 0
| 0
| null | 1
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 1
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| null | 0
| 0
| 0
| 0
| 0
| 0
| 1
| 0
| 1
| 0
| 1
| 0
|
0
| 6
|
16fda72a13b0eb5487524e2c30de028e5cf87eef
| 31
|
py
|
Python
|
rdkit/sping/PS/__init__.py
|
kazuyaujihara/rdkit
|
06027dcd05674787b61f27ba46ec0d42a6037540
|
[
"BSD-3-Clause"
] | 1,609
|
2015-01-05T02:41:13.000Z
|
2022-03-30T21:57:24.000Z
|
rdkit/sping/PS/__init__.py
|
kazuyaujihara/rdkit
|
06027dcd05674787b61f27ba46ec0d42a6037540
|
[
"BSD-3-Clause"
] | 3,412
|
2015-01-06T12:13:33.000Z
|
2022-03-31T17:25:41.000Z
|
rdkit/sping/PS/__init__.py
|
bp-kelley/rdkit
|
e0de7c9622ce73894b1e7d9568532f6d5638058a
|
[
"BSD-3-Clause"
] | 811
|
2015-01-11T03:33:48.000Z
|
2022-03-28T11:57:49.000Z
|
# package
from .pidPS import *
| 10.333333
| 20
| 0.709677
| 4
| 31
| 5.5
| 1
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0.193548
| 31
| 2
| 21
| 15.5
| 0.88
| 0.225806
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 1
| 0
| true
| 0
| 1
| 0
| 1
| 0
| 1
| 1
| 0
| null | 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 1
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| null | 0
| 0
| 0
| 0
| 0
| 0
| 1
| 0
| 1
| 0
| 1
| 0
|
0
| 6
|
e5465270640d52a0c7a9c9e382badf6f800ef8b0
| 53
|
py
|
Python
|
utils/__init__.py
|
xuhaiming1996/Dense_BiLSTM_xhm
|
a08a05572a8c37cd6af4afa6b556d471418761bb
|
[
"MIT"
] | 47
|
2018-02-18T20:07:44.000Z
|
2021-12-03T03:31:03.000Z
|
utils/__init__.py
|
pikaliov/Dense_BiLSTM
|
88bf7389de4cdf976c12636aca15b7c2467bc675
|
[
"MIT"
] | 3
|
2018-09-27T05:59:31.000Z
|
2019-03-10T18:57:32.000Z
|
utils/__init__.py
|
pikaliov/Dense_BiLSTM
|
88bf7389de4cdf976c12636aca15b7c2467bc675
|
[
"MIT"
] | 28
|
2018-03-04T16:50:18.000Z
|
2020-11-03T13:40:36.000Z
|
from utils.logger import *
from utils.funcs import *
| 17.666667
| 26
| 0.773585
| 8
| 53
| 5.125
| 0.625
| 0.439024
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0.150943
| 53
| 2
| 27
| 26.5
| 0.911111
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 1
| 0
| true
| 0
| 1
| 0
| 1
| 0
| 1
| 0
| 0
| null | 1
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 1
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| null | 0
| 0
| 0
| 0
| 0
| 0
| 1
| 0
| 1
| 0
| 1
| 0
|
0
| 6
|
e56c5e3ad957b0648bab0c5379b58831d5345a69
| 94
|
py
|
Python
|
tests/example_test.py
|
StylishTriangles/pyteal-test-template
|
16e0b297de28194435482e6ed3a79334f7c8afa3
|
[
"MIT"
] | 1
|
2021-11-24T18:39:10.000Z
|
2021-11-24T18:39:10.000Z
|
tests/example_test.py
|
StylishTriangles/pyteal-test-template
|
16e0b297de28194435482e6ed3a79334f7c8afa3
|
[
"MIT"
] | null | null | null |
tests/example_test.py
|
StylishTriangles/pyteal-test-template
|
16e0b297de28194435482e6ed3a79334f7c8afa3
|
[
"MIT"
] | null | null | null |
from tests.constants import client
def test_connection():
assert client.health() == None
| 18.8
| 34
| 0.744681
| 12
| 94
| 5.75
| 0.916667
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0.159574
| 94
| 4
| 35
| 23.5
| 0.873418
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0.333333
| 1
| 0.333333
| true
| 0
| 0.333333
| 0
| 0.666667
| 0
| 1
| 0
| 0
| null | 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 1
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| null | 0
| 0
| 0
| 0
| 0
| 1
| 1
| 0
| 1
| 0
| 1
| 0
|
0
| 6
|
e5d0c4a841a9a9eabf0fab1b42e5817c90cf685c
| 1,055
|
py
|
Python
|
ansible/roles/deploywebapp/templates/deploy.py
|
HrishiWorks/AutomationCode
|
ec521bd97309d2a9e215ed817918c82f873333c9
|
[
"Unlicense"
] | null | null | null |
ansible/roles/deploywebapp/templates/deploy.py
|
HrishiWorks/AutomationCode
|
ec521bd97309d2a9e215ed817918c82f873333c9
|
[
"Unlicense"
] | null | null | null |
ansible/roles/deploywebapp/templates/deploy.py
|
HrishiWorks/AutomationCode
|
ec521bd97309d2a9e215ed817918c82f873333c9
|
[
"Unlicense"
] | null | null | null |
AdminApp.install('/tmp/installers/war_app/JspDemo.war', '[ -nopreCompileJSPs -distributeApp -nouseMetaDataFromBinary -nodeployejb -appname JspDemo -createMBeansForResources -noreloadEnabled -nodeployws -validateinstall warn -noprocessEmbeddedConfig -filepermission .*\.dll=755#.*\.so=755#.*\.a=755#.*\.sl=755 -noallowDispatchRemoteInclude -noallowServiceRemoteInclude -asyncRequestDispatchType DISABLED -nouseAutoLink -noenableClientModule -clientMode isolated -novalidateSchema -contextroot /JspDemo -MapModulesToServers [[ JspDemo JspDemo.war,WEB-INF/web.xml WebSphere:cell=mywasNode01Cell,node=mywasNode01,server=server1 ]] -MapWebModToVH [[ JspDemo JspDemo.war,WEB-INF/web.xml default_host ]] -CtxRootForWebMod [[ JspDemo JspDemo.war,WEB-INF/web.xml /JspDemo ]]]' )
AdminConfig.save()
AdminControl.invoke('WebSphere:name=ApplicationManager,process=server1,platform=proxy,node=mywasNode01,version=8.5.5.0,type=ApplicationManager,mbeanIdentifier=ApplicationManager,cell=mywasNode01Cell,spec=1.0', 'startApplication', '[JspDemo]', '[java.lang.String]')
| 211
| 769
| 0.818009
| 106
| 1,055
| 8.122642
| 0.660377
| 0.046458
| 0.059233
| 0.069686
| 0.101045
| 0.101045
| 0.101045
| 0
| 0
| 0
| 0
| 0.027916
| 0.049289
| 1,055
| 4
| 770
| 263.75
| 0.830508
| 0
| 0
| 0
| 0
| 0.666667
| 0.92315
| 0.553131
| 0
| 0
| 0
| 0
| 0
| 1
| 0
| true
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| null | 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 1
| 0
| 1
| 0
| 0
| 0
| 0
| 0
| 1
| 1
| 1
| null | 0
| 0
| 0
| 0
| 0
| 0
| 1
| 0
| 0
| 0
| 0
| 0
|
0
| 6
|
007dc6f5c3f83e72ac5fe59f95b0be11d25512c1
| 41
|
py
|
Python
|
symbench_athens_client/tests/test_uav_workflows.py
|
valtron/symbench-athens-client
|
11482f5d385217898cfc5cb6ff9d76b19a3f7356
|
[
"Apache-2.0"
] | null | null | null |
symbench_athens_client/tests/test_uav_workflows.py
|
valtron/symbench-athens-client
|
11482f5d385217898cfc5cb6ff9d76b19a3f7356
|
[
"Apache-2.0"
] | 43
|
2021-08-19T20:16:43.000Z
|
2022-03-30T18:54:42.000Z
|
symbench_athens_client/tests/test_uav_workflows.py
|
valtron/symbench-athens-client
|
11482f5d385217898cfc5cb6ff9d76b19a3f7356
|
[
"Apache-2.0"
] | 2
|
2021-11-09T06:07:06.000Z
|
2022-01-13T17:04:29.000Z
|
class TestUAVWorkflows:
pass # ToDO
| 13.666667
| 23
| 0.707317
| 4
| 41
| 7.25
| 1
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0.243902
| 41
| 2
| 24
| 20.5
| 0.935484
| 0.097561
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0.5
| 0
| 1
| 0
| true
| 0.5
| 0
| 0
| 0.5
| 0
| 1
| 1
| 0
| null | 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 1
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| null | 0
| 0
| 1
| 0
| 0
| 0
| 1
| 1
| 0
| 0
| 0
| 0
|
0
| 6
|
00e3223d30f93d5303e5b766560597cacdcbb829
| 118
|
py
|
Python
|
models/__init__.py
|
santbetv/modulo_odoo_free_ganaderia
|
07e74c205c8aca45ad56618ede47410d3dd994a8
|
[
"CNRI-Python"
] | 1
|
2020-11-01T00:16:13.000Z
|
2020-11-01T00:16:13.000Z
|
models/__init__.py
|
santbetv/modulo_odoo_free_ganaderia
|
07e74c205c8aca45ad56618ede47410d3dd994a8
|
[
"CNRI-Python"
] | 1
|
2020-10-20T01:33:45.000Z
|
2020-10-20T01:33:45.000Z
|
models/__init__.py
|
santbetv/modulo_odoo_free_ganaderia
|
07e74c205c8aca45ad56618ede47410d3dd994a8
|
[
"CNRI-Python"
] | 1
|
2021-04-03T19:28:03.000Z
|
2021-04-03T19:28:03.000Z
|
# -*- coding: utf-8 -*-
from . import ganaderia_ganado
from . import ganaderia_ganadero
from . import ganaderia_finca
| 23.6
| 32
| 0.754237
| 15
| 118
| 5.733333
| 0.6
| 0.348837
| 0.662791
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0.009901
| 0.144068
| 118
| 5
| 33
| 23.6
| 0.841584
| 0.177966
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 1
| 0
| true
| 0
| 1
| 0
| 1
| 0
| 1
| 0
| 0
| null | 1
| 1
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 1
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| null | 0
| 0
| 0
| 0
| 0
| 0
| 1
| 0
| 1
| 0
| 0
| 0
|
0
| 6
|
da9d172ef39162d8b27115bf6e4ca429a5f8bae4
| 324
|
py
|
Python
|
cabot/metricsapp/forms/__init__.py
|
Affirm/cabot
|
c648d50364efe8506cfbb849d38e328afdaa4e37
|
[
"MIT"
] | 12
|
2016-04-01T18:49:05.000Z
|
2020-10-21T18:25:23.000Z
|
cabot/metricsapp/forms/__init__.py
|
Affirm/cabot
|
c648d50364efe8506cfbb849d38e328afdaa4e37
|
[
"MIT"
] | 125
|
2016-01-19T23:52:11.000Z
|
2021-04-08T00:30:36.000Z
|
cabot/metricsapp/forms/__init__.py
|
Affirm/cabot
|
c648d50364efe8506cfbb849d38e328afdaa4e37
|
[
"MIT"
] | 8
|
2015-12-01T14:54:02.000Z
|
2020-01-13T11:06:40.000Z
|
from .elastic import ElasticsearchSourceForm, ElasticsearchStatusCheckForm
from .grafana_elastic import GrafanaElasticsearchStatusCheckForm
from .grafana import GrafanaInstanceAdminForm, GrafanaDataSourceAdminForm, GrafanaInstanceForm, GrafanaDashboardForm, \
GrafanaPanelForm, GrafanaSeriesForm, GrafanaStatusCheckForm
| 64.8
| 119
| 0.891975
| 20
| 324
| 14.4
| 0.7
| 0.090278
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0.074074
| 324
| 4
| 120
| 81
| 0.96
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 1
| 0
| true
| 0
| 0.75
| 0
| 0.75
| 0
| 1
| 0
| 1
| null | 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 1
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| null | 0
| 0
| 0
| 0
| 0
| 0
| 1
| 0
| 1
| 0
| 1
| 0
|
0
| 6
|
9727f64d1ca6fb3fae0acbc59b4e357a6293a8a1
| 24
|
py
|
Python
|
looker_api/__init__.py
|
nofeet/looker-api
|
fc7f35f01690844a57c16c4899a983d194998861
|
[
"BSD-3-Clause"
] | 1
|
2018-06-20T17:51:28.000Z
|
2018-06-20T17:51:28.000Z
|
looker_api/__init__.py
|
nofeet/looker-api
|
fc7f35f01690844a57c16c4899a983d194998861
|
[
"BSD-3-Clause"
] | 1
|
2018-05-22T19:51:28.000Z
|
2018-05-22T19:51:28.000Z
|
looker_api/__init__.py
|
nofeet/looker-api
|
fc7f35f01690844a57c16c4899a983d194998861
|
[
"BSD-3-Clause"
] | null | null | null |
from looker_api import *
| 24
| 24
| 0.833333
| 4
| 24
| 4.75
| 1
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0.125
| 24
| 1
| 24
| 24
| 0.904762
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 1
| 0
| true
| 0
| 1
| 0
| 1
| 0
| 1
| 1
| 0
| null | 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 1
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| null | 0
| 0
| 0
| 0
| 0
| 0
| 1
| 0
| 1
| 0
| 1
| 0
|
0
| 6
|
9792eaec37333b0bd87b76e280144b01e45c8362
| 102
|
py
|
Python
|
codingbat.com/Warmup-1/monkey_trouble .py
|
ahmedelq/PythonicAlgorithms
|
ce10dbb6e1fd0ea5c922a932b0f920236aa411bf
|
[
"MIT"
] | null | null | null |
codingbat.com/Warmup-1/monkey_trouble .py
|
ahmedelq/PythonicAlgorithms
|
ce10dbb6e1fd0ea5c922a932b0f920236aa411bf
|
[
"MIT"
] | null | null | null |
codingbat.com/Warmup-1/monkey_trouble .py
|
ahmedelq/PythonicAlgorithms
|
ce10dbb6e1fd0ea5c922a932b0f920236aa411bf
|
[
"MIT"
] | null | null | null |
def monkey_trouble(a_smile, b_smile):
return (a_smile and b_smile) or (not a_smile and not b_smile)
| 34
| 63
| 0.77451
| 21
| 102
| 3.428571
| 0.47619
| 0.25
| 0.25
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0.147059
| 102
| 2
| 64
| 51
| 0.827586
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 1
| 0.5
| false
| 0
| 0
| 0.5
| 1
| 0
| 1
| 0
| 0
| null | 1
| 1
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 1
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| null | 0
| 0
| 0
| 0
| 0
| 1
| 0
| 0
| 0
| 1
| 0
| 0
|
0
| 6
|
97a8774db190df1aef3f8228788815dfb27dbc2d
| 70
|
py
|
Python
|
research/cv/ICNet/src/models/__init__.py
|
leelige/mindspore
|
5199e05ba3888963473f2b07da3f7bca5b9ef6dc
|
[
"Apache-2.0"
] | 77
|
2021-10-15T08:32:37.000Z
|
2022-03-30T13:09:11.000Z
|
research/cv/ICNet/src/models/__init__.py
|
leelige/mindspore
|
5199e05ba3888963473f2b07da3f7bca5b9ef6dc
|
[
"Apache-2.0"
] | 3
|
2021-10-30T14:44:57.000Z
|
2022-02-14T06:57:57.000Z
|
research/cv/ICNet/src/models/__init__.py
|
leelige/mindspore
|
5199e05ba3888963473f2b07da3f7bca5b9ef6dc
|
[
"Apache-2.0"
] | 24
|
2021-10-15T08:32:45.000Z
|
2022-03-24T18:45:20.000Z
|
"""__init__"""
from .icnet import ICNet
from .icnet_dc import ICNetdc
| 17.5
| 29
| 0.757143
| 10
| 70
| 4.8
| 0.6
| 0.375
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0.128571
| 70
| 3
| 30
| 23.333333
| 0.786885
| 0.114286
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 1
| 0
| true
| 0
| 1
| 0
| 1
| 0
| 1
| 0
| 0
| null | 1
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 1
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| null | 0
| 0
| 0
| 0
| 0
| 0
| 1
| 0
| 1
| 0
| 1
| 0
|
0
| 6
|
8ae17d5abeb256e0bbe2c79da687ce5b7ac0d803
| 30
|
py
|
Python
|
fiwz13/__init__.py
|
cheezetata/fiwz13
|
915252998c680f830cc36327f7f7300316ee211c
|
[
"MIT"
] | null | null | null |
fiwz13/__init__.py
|
cheezetata/fiwz13
|
915252998c680f830cc36327f7f7300316ee211c
|
[
"MIT"
] | null | null | null |
fiwz13/__init__.py
|
cheezetata/fiwz13
|
915252998c680f830cc36327f7f7300316ee211c
|
[
"MIT"
] | null | null | null |
from fiwz13.fiwz import Fiwz
| 15
| 29
| 0.8
| 5
| 30
| 4.8
| 0.8
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0.08
| 0.166667
| 30
| 1
| 30
| 30
| 0.88
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 1
| 0
| true
| 0
| 1
| 0
| 1
| 0
| 1
| 1
| 0
| null | 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 1
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| null | 0
| 0
| 0
| 0
| 0
| 0
| 1
| 0
| 1
| 0
| 1
| 0
|
0
| 6
|
8af6b6618192b4f3dde3310b3f36acc10688f072
| 628
|
py
|
Python
|
seaice/timeseries/__init__.py
|
andypbarrett/nsidc-seaice
|
167a16309f7eaadd5c613b54a7df26eb1f48c2f3
|
[
"MIT"
] | 2
|
2020-08-27T08:40:22.000Z
|
2021-04-14T15:42:09.000Z
|
seaice/timeseries/__init__.py
|
andypbarrett/nsidc-seaice
|
167a16309f7eaadd5c613b54a7df26eb1f48c2f3
|
[
"MIT"
] | null | null | null |
seaice/timeseries/__init__.py
|
andypbarrett/nsidc-seaice
|
167a16309f7eaadd5c613b54a7df26eb1f48c2f3
|
[
"MIT"
] | null | null | null |
import logging
from .api import daily # noqa
from .api import monthly # noqa
from .api import daily # noqa
from .api import monthly # noqa
from .api import monthly_rates_of_change # noqa
from .api import climatology_average_rates_of_change # noqa
from .api import nday_average # noqa
from .api import scale # noqa
from .api import normal_statistics # noqa
from .api import quantiles # noqa
from .api import monthly_anomaly # noqa
from .api import monthly_percent_anomaly # noqa
from .api import trend # noqa
from .api import climatology_means # noqa
logging.getLogger(__name__).addHandler(logging.NullHandler())
| 33.052632
| 61
| 0.77707
| 91
| 628
| 5.175824
| 0.274725
| 0.208068
| 0.386412
| 0.469214
| 0.615711
| 0.350318
| 0.350318
| 0.22293
| 0.22293
| 0.22293
| 0
| 0
| 0.164013
| 628
| 18
| 62
| 34.888889
| 0.897143
| 0.109873
| 0
| 0.25
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 1
| 0
| true
| 0
| 0.9375
| 0
| 0.9375
| 0
| 0
| 0
| 0
| null | 1
| 1
| 1
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| null | 0
| 0
| 0
| 0
| 0
| 0
| 1
| 0
| 1
| 0
| 1
| 0
|
0
| 6
|
8af70d8727ea30258eaea0ca44dbfbefad7a3df8
| 137
|
py
|
Python
|
pgreaper/html/__init__.py
|
vincentlaucsb/sqlify
|
cc84be6efef7b904aacc463d5b0211b3e52a8f25
|
[
"MIT"
] | 8
|
2017-05-01T10:11:40.000Z
|
2017-07-26T08:52:43.000Z
|
pgreaper/html/__init__.py
|
vincentlaucsb/pgreaper
|
cc84be6efef7b904aacc463d5b0211b3e52a8f25
|
[
"MIT"
] | 4
|
2017-05-01T13:11:05.000Z
|
2017-08-06T06:18:34.000Z
|
pgreaper/html/__init__.py
|
vincentlaucsb/sqlify
|
cc84be6efef7b904aacc463d5b0211b3e52a8f25
|
[
"MIT"
] | null | null | null |
from .parser import get_tables_from_file as from_file, \
get_tables_from_url as from_url, \
get_tables_from_string as from_string
| 45.666667
| 56
| 0.810219
| 24
| 137
| 4.125
| 0.375
| 0.272727
| 0.393939
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0.153285
| 137
| 3
| 57
| 45.666667
| 0.853448
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 1
| 0
| true
| 0
| 0.333333
| 0
| 0.333333
| 0
| 1
| 0
| 0
| null | 1
| 1
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 1
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| null | 0
| 0
| 0
| 0
| 0
| 0
| 1
| 0
| 1
| 0
| 0
| 0
|
0
| 6
|
c104912b56c35454b9c66b70c1b03c6f3b4e0679
| 47
|
py
|
Python
|
tests/java/org/python/indexer/data/pkgload.py
|
jeff5/jython-whinchat
|
65d8e5268189f8197295ff2d91be3decb1ee0081
|
[
"CNRI-Jython"
] | 577
|
2020-06-04T16:34:44.000Z
|
2022-03-31T11:46:07.000Z
|
tests/java/org/python/indexer/data/pkgload.py
|
jeff5/jython-whinchat
|
65d8e5268189f8197295ff2d91be3decb1ee0081
|
[
"CNRI-Jython"
] | 174
|
2015-01-08T20:37:09.000Z
|
2020-06-03T16:48:59.000Z
|
tests/java/org/python/indexer/data/pkgload.py
|
jeff5/jython-whinchat
|
65d8e5268189f8197295ff2d91be3decb1ee0081
|
[
"CNRI-Jython"
] | 162
|
2015-02-07T02:14:38.000Z
|
2020-05-30T16:42:03.000Z
|
# test loading a package by dirname
import pkg
| 15.666667
| 35
| 0.787234
| 8
| 47
| 4.625
| 1
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0.191489
| 47
| 2
| 36
| 23.5
| 0.973684
| 0.702128
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 1
| 0
| true
| 0
| 1
| 0
| 1
| 0
| 1
| 1
| 0
| null | 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 1
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| null | 0
| 0
| 0
| 0
| 0
| 0
| 1
| 0
| 1
| 0
| 1
| 0
|
0
| 6
|
c107331cb6e97b6a762e6d01fe9b444b77d86014
| 116
|
py
|
Python
|
app/auth/__init__.py
|
originaltebas/chmembers
|
983578ec8cb6d1da76e98b1467d996d6fac752ee
|
[
"MIT"
] | null | null | null |
app/auth/__init__.py
|
originaltebas/chmembers
|
983578ec8cb6d1da76e98b1467d996d6fac752ee
|
[
"MIT"
] | 2
|
2021-09-08T01:19:10.000Z
|
2022-03-11T23:59:40.000Z
|
app/auth/__init__.py
|
originaltebas/chmembers
|
983578ec8cb6d1da76e98b1467d996d6fac752ee
|
[
"MIT"
] | 1
|
2019-04-09T10:42:20.000Z
|
2019-04-09T10:42:20.000Z
|
# app/auth/__init__.py
from flask import Blueprint
auth = Blueprint('auth', __name__)
from . import views
| 14.5
| 35
| 0.698276
| 15
| 116
| 4.866667
| 0.666667
| 0.356164
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0.206897
| 116
| 8
| 36
| 14.5
| 0.793478
| 0.172414
| 0
| 0
| 0
| 0
| 0.045455
| 0
| 0
| 0
| 0
| 0
| 0
| 1
| 0
| false
| 0
| 0.666667
| 0
| 0.666667
| 0.666667
| 1
| 0
| 0
| null | 1
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 1
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| null | 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 1
| 0
| 1
| 1
|
0
| 6
|
c12e085f5917a8f2d3ba0827cc224acd754d3280
| 110
|
py
|
Python
|
build-array-from-permutation/build-array-from-permutation.py
|
shaurya-src/code-leet
|
f642b81eb7bead46c66404bd48ca74bdfeb2abbb
|
[
"MIT"
] | null | null | null |
build-array-from-permutation/build-array-from-permutation.py
|
shaurya-src/code-leet
|
f642b81eb7bead46c66404bd48ca74bdfeb2abbb
|
[
"MIT"
] | null | null | null |
build-array-from-permutation/build-array-from-permutation.py
|
shaurya-src/code-leet
|
f642b81eb7bead46c66404bd48ca74bdfeb2abbb
|
[
"MIT"
] | null | null | null |
class Solution:
def buildArray(self, nums: List[int]) -> List[int]:
return [nums[x] for x in nums]
| 36.666667
| 55
| 0.627273
| 17
| 110
| 4.058824
| 0.705882
| 0.202899
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0.227273
| 110
| 3
| 56
| 36.666667
| 0.811765
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 1
| 0.333333
| false
| 0
| 0
| 0.333333
| 1
| 0
| 1
| 0
| 0
| null | 1
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 1
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| null | 0
| 0
| 0
| 0
| 0
| 1
| 0
| 0
| 0
| 1
| 1
| 0
|
0
| 6
|
c162ce6cbc1203e7db1a59631225caf17c86aa74
| 62
|
py
|
Python
|
js/obviel/test_libs.py
|
gocept/js.obviel
|
ccede50709c04139a84d753e95938053ee12d609
|
[
"BSD-3-Clause"
] | null | null | null |
js/obviel/test_libs.py
|
gocept/js.obviel
|
ccede50709c04139a84d753e95938053ee12d609
|
[
"BSD-3-Clause"
] | null | null | null |
js/obviel/test_libs.py
|
gocept/js.obviel
|
ccede50709c04139a84d753e95938053ee12d609
|
[
"BSD-3-Clause"
] | null | null | null |
def test_package_should_be_importable():
import js.obviel
| 20.666667
| 40
| 0.806452
| 9
| 62
| 5.111111
| 1
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0.129032
| 62
| 2
| 41
| 31
| 0.851852
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 1
| 0.5
| true
| 0
| 1
| 0
| 1.5
| 0
| 1
| 0
| 0
| null | 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 1
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| null | 0
| 0
| 0
| 0
| 0
| 1
| 1
| 0
| 1
| 0
| 1
| 0
|
0
| 6
|
c16fff04b4fed8943c2de56c0a67cc3bce81d40f
| 3,427
|
py
|
Python
|
yt/data_objects/tests/test_exclude_functions.py
|
saethlin/yt
|
992ae71974dca933346e91008c5a50f43a0a350e
|
[
"BSD-3-Clause-Clear"
] | 1
|
2020-06-22T10:17:01.000Z
|
2020-06-22T10:17:01.000Z
|
yt/data_objects/tests/test_exclude_functions.py
|
saethlin/yt
|
992ae71974dca933346e91008c5a50f43a0a350e
|
[
"BSD-3-Clause-Clear"
] | 2
|
2020-02-10T22:55:35.000Z
|
2020-02-19T21:01:20.000Z
|
yt/data_objects/tests/test_exclude_functions.py
|
saethlin/yt
|
992ae71974dca933346e91008c5a50f43a0a350e
|
[
"BSD-3-Clause-Clear"
] | 2
|
2020-05-16T15:29:37.000Z
|
2020-06-22T10:17:08.000Z
|
import numpy as np
from yt.testing import fake_random_ds, assert_equal
from yt.frontends.stream.data_structures import load_uniform_grid
def test_exclude_above():
the_ds = fake_random_ds(ndims=3)
all_data = the_ds.all_data()
new_ds = all_data.exclude_above('density', 1)
assert_equal(new_ds['density'], all_data['density'])
new_ds = all_data.exclude_above('density', 1e6, 'g/m**3')
assert_equal(new_ds['density'], all_data['density'])
new_ds = all_data.exclude_above('density', 0)
assert_equal(new_ds['density'], [])
def test_exclude_below():
the_ds = fake_random_ds(ndims=3)
all_data = the_ds.all_data()
new_ds = all_data.exclude_below('density', 1)
assert_equal(new_ds['density'], [])
new_ds = all_data.exclude_below('density', 1e6, 'g/m**3')
assert_equal(new_ds['density'], [])
new_ds = all_data.exclude_below('density', 0)
assert_equal(new_ds['density'], all_data['density'])
def test_exclude_nan():
test_array = np.nan*np.ones((10, 10, 10))
test_array[1,1,:] = 1
data = dict(density=test_array)
ds = load_uniform_grid(data, test_array.shape,
length_unit='cm', nprocs=1)
ad = ds.all_data()
no_nan_ds = ad.exclude_nan('density')
assert_equal(no_nan_ds['density'], np.array(np.ones(10)))
def test_equal():
test_array = np.ones((10, 10, 10))
test_array[1,1,:] = 2.
test_array[2,1,:] = 3.
data = dict(density=test_array)
ds = load_uniform_grid(data, test_array.shape,
length_unit='cm', nprocs=1)
ad = ds.all_data()
no_ones = ad.exclude_equal('density', 1.0)
assert np.all(no_ones['density'] != 1.0)
only_ones = ad.include_equal('density', 1.0)
assert np.all(only_ones['density'] == 1.0)
def test_inside_outside():
test_array = np.ones((10, 10, 10))
test_array[1,1,:] = 2.
test_array[2,1,:] = 3.
data = dict(density=test_array)
ds = load_uniform_grid(data, test_array.shape,
length_unit='cm', nprocs=1)
ad = ds.all_data()
only_ones_and_twos = ad.include_inside('density', 0.9, 2.1)
assert np.all(only_ones_and_twos['density'] != 3.)
assert len(only_ones_and_twos['density']) == 990
only_ones_and_twos = ad.exclude_outside('density', 0.9, 2.1)
assert len(only_ones_and_twos['density']) == 990
assert np.all(only_ones_and_twos['density'] != 3.)
only_threes = ad.include_outside('density', 0.9, 2.1)
assert np.all(only_threes['density'] == 3)
assert len(only_threes['density']) == 10
only_threes = ad.include_outside('density', 0.9, 2.1)
assert np.all(only_threes['density'] == 3)
assert len(only_threes['density']) == 10
# Repeat, but convert units to g/m**3
only_ones_and_twos = ad.include_inside('density', 0.9e6, 2.1e6, 'g/m**3')
assert np.all(only_ones_and_twos['density'] != 3.)
assert len(only_ones_and_twos['density']) == 990
only_ones_and_twos = ad.exclude_outside('density', 0.9e6, 2.1e6, 'g/m**3')
assert len(only_ones_and_twos['density']) == 990
assert np.all(only_ones_and_twos['density'] != 3.)
only_threes = ad.include_outside('density', 0.9e6, 2.1e6, 'g/m**3')
assert np.all(only_threes['density'] == 3)
assert len(only_threes['density']) == 10
only_threes = ad.include_outside('density', 0.9e6, 2.1e6, 'g/m**3')
assert np.all(only_threes['density'] == 3)
assert len(only_threes['density']) == 10
| 37.25
| 78
| 0.660344
| 553
| 3,427
| 3.813743
| 0.115732
| 0.053106
| 0.062589
| 0.085349
| 0.829777
| 0.825984
| 0.825984
| 0.776671
| 0.759128
| 0.714557
| 0
| 0.046224
| 0.173038
| 3,427
| 91
| 79
| 37.659341
| 0.697953
| 0.010213
| 0
| 0.648649
| 0
| 0
| 0.10531
| 0
| 0
| 0
| 0
| 0
| 0.351351
| 1
| 0.067568
| false
| 0
| 0.040541
| 0
| 0.108108
| 0
| 0
| 0
| 0
| null | 0
| 0
| 0
| 1
| 1
| 1
| 1
| 1
| 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
| 6
|
c1ce38b22a43164edc924c24cf345a8baca1c002
| 37
|
py
|
Python
|
tuster/exceptions.py
|
ytopt-team/tuster
|
9ac4edc0ee8ae3e1c6bfd27168917a1afc84e952
|
[
"BSD-2-Clause"
] | 1
|
2020-05-05T01:47:08.000Z
|
2020-05-05T01:47:08.000Z
|
tuster/exceptions.py
|
ytopt-team/tuster
|
9ac4edc0ee8ae3e1c6bfd27168917a1afc84e952
|
[
"BSD-2-Clause"
] | null | null | null |
tuster/exceptions.py
|
ytopt-team/tuster
|
9ac4edc0ee8ae3e1c6bfd27168917a1afc84e952
|
[
"BSD-2-Clause"
] | 1
|
2021-05-19T19:52:25.000Z
|
2021-05-19T19:52:25.000Z
|
class TusterError(RuntimeError): pass
| 37
| 37
| 0.864865
| 4
| 37
| 8
| 1
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0.054054
| 37
| 1
| 37
| 37
| 0.914286
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 1
| 0
| true
| 1
| 0
| 0
| 1
| 0
| 1
| 1
| 0
| null | 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 1
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| null | 0
| 0
| 0
| 0
| 0
| 0
| 1
| 1
| 0
| 0
| 1
| 0
|
0
| 6
|
a9cb9f728eafb5e03cf46a252d8f7f3ba4cc720f
| 2,554
|
py
|
Python
|
Topic 2/resblock.py
|
Rabbit1010/TensorFlow2.0-Tutorial
|
902d9dd55fc87c2bb0a3335002d668b49f9ab3ab
|
[
"MIT"
] | 1
|
2019-10-02T12:32:24.000Z
|
2019-10-02T12:32:24.000Z
|
Topic 2/resblock.py
|
Rabbit1010/TensorFlow2.0-Tutorial
|
902d9dd55fc87c2bb0a3335002d668b49f9ab3ab
|
[
"MIT"
] | null | null | null |
Topic 2/resblock.py
|
Rabbit1010/TensorFlow2.0-Tutorial
|
902d9dd55fc87c2bb0a3335002d668b49f9ab3ab
|
[
"MIT"
] | 2
|
2019-10-24T04:09:44.000Z
|
2020-04-06T23:50:18.000Z
|
# -*- coding: utf-8 -*-
"""
Created on Wed Jun 19 23:11:51 2019
@author: Wei-Hsiang, Shen
"""
from tensorflow.keras import layers
class ResBlock(object):
"""
Residual block (non bottleneck, 2 blocks)
"""
def __init__(self, num_feature_in, num_feature_out, strides=(1,1)):
self.num_feature_in = num_feature_in
self.num_feature_out = num_feature_out
self.strides = strides
def __call__(self, x):
shortcut = x
x = layers.Conv2D(self.num_feature_out, (3,3), strides=self.strides, use_bias=False, padding='same')(x)
x = layers.BatchNormalization()(x)
x = layers.ReLU()(x)
x = layers.Conv2D(self.num_feature_out, (3,3), use_bias=False, padding='same')(x)
x = layers.BatchNormalization()(x)
# projection shortcut is used when input and output are different dimensions
if self.num_feature_in!=self.num_feature_out or self.strides != (1, 1):
shortcut = layers.Conv2D(self.num_feature_out, (1, 1), strides=self.strides, padding='same')(shortcut)
shortcut = layers.BatchNormalization()(shortcut)
x = layers.add([x, shortcut]) # skip connection
x = layers.ReLU()(x)
return x
class ResBlock_Bottleneck(object):
"""
Residual block (bottleneck, 3 blocks)
"""
def __init__(self, num_feature_in, num_feature_mid, num_feature_out, strides=(1,1)):
self.num_feature_in = num_feature_in
self.num_feature_mid = num_feature_mid
self.num_feature_out = num_feature_out
self.strides = strides
def __call__(self, x):
shortcut = x
x = layers.Conv2D(self.num_feature_mid, kernel_size=(1,1), use_bias=False)(x)
x = layers.BatchNormalization()(x)
x = layers.ReLU()(x)
x = layers.Conv2D(self.num_feature_mid, kernel_size=(3,3), use_bias=False, strides=self.strides, padding='same')(x)
x = layers.BatchNormalization()(x)
x = layers.ReLU()(x)
x = layers.Conv2D(self.num_feature_out, kernel_size=(1,1), use_bias=False)(x)
x = layers.BatchNormalization()(x)
# projection shortcut is used when input and output are different dimensions
if self.num_feature_in!=self.num_feature_out or self.strides != (1, 1):
shortcut = layers.Conv2D(self.num_feature_out, kernel_size=(1, 1), use_bias=False, strides=self.strides)(shortcut)
shortcut = layers.BatchNormalization()(shortcut)
x = layers.add([x, shortcut])
x = layers.ReLU()(x)
return x
| 36.485714
| 126
| 0.648003
| 349
| 2,554
| 4.515759
| 0.200573
| 0.164975
| 0.159898
| 0.097081
| 0.858503
| 0.82868
| 0.774112
| 0.774112
| 0.774112
| 0.730964
| 0
| 0.022245
| 0.225529
| 2,554
| 70
| 127
| 36.485714
| 0.77452
| 0.129601
| 0
| 0.682927
| 0
| 0
| 0.007329
| 0
| 0
| 0
| 0
| 0
| 0
| 1
| 0.097561
| false
| 0
| 0.02439
| 0
| 0.219512
| 0
| 0
| 0
| 0
| null | 0
| 0
| 0
| 1
| 1
| 1
| 1
| 1
| 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
| 6
|
e71b51d7c4613566e05193d04a2897878d1820dd
| 100
|
py
|
Python
|
zcrmsdk/src/com/zoho/api/authenticator/store/__init__.py
|
zoho/zohocrm-python-sdk-2.0
|
3a93eb3b57fed4e08f26bd5b311e101cb2995411
|
[
"Apache-2.0"
] | null | null | null |
zcrmsdk/src/com/zoho/api/authenticator/store/__init__.py
|
zoho/zohocrm-python-sdk-2.0
|
3a93eb3b57fed4e08f26bd5b311e101cb2995411
|
[
"Apache-2.0"
] | null | null | null |
zcrmsdk/src/com/zoho/api/authenticator/store/__init__.py
|
zoho/zohocrm-python-sdk-2.0
|
3a93eb3b57fed4e08f26bd5b311e101cb2995411
|
[
"Apache-2.0"
] | null | null | null |
from .db_store import DBStore
from .file_store import FileStore
from .token_store import TokenStore
| 25
| 35
| 0.85
| 15
| 100
| 5.466667
| 0.6
| 0.402439
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0.12
| 100
| 3
| 36
| 33.333333
| 0.931818
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 1
| 0
| true
| 0
| 1
| 0
| 1
| 0
| 1
| 0
| 0
| null | 1
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 1
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| null | 0
| 0
| 0
| 0
| 0
| 0
| 1
| 0
| 1
| 0
| 1
| 0
|
0
| 6
|
e7326b90643430746e7de3a92a98147946aed525
| 11,047
|
py
|
Python
|
computer-labs/CL3/lib/q_learning_app.py
|
JulianoLagana/deep-machine-learning
|
0135a84067be357c8bc3d3a4298b60dcaf7d53d5
|
[
"MIT"
] | 49
|
2017-09-07T19:56:45.000Z
|
2022-02-17T11:19:14.000Z
|
computer-labs/CL3/lib/q_learning_app.py
|
JulianoLagana/deep-machine-learning
|
0135a84067be357c8bc3d3a4298b60dcaf7d53d5
|
[
"MIT"
] | 16
|
2018-09-05T08:10:21.000Z
|
2021-09-06T11:47:54.000Z
|
computer-labs/CL3/lib/q_learning_app.py
|
JulianoLagana/deep-machine-learning
|
0135a84067be357c8bc3d3a4298b60dcaf7d53d5
|
[
"MIT"
] | 103
|
2017-09-19T13:37:32.000Z
|
2021-11-03T14:09:59.000Z
|
import matplotlib.pyplot as plt
import numpy as np
from lib.algos import epsilon_greedy_pi_from_q_table
from lib.plot_utils import plot_all_states, plot_agent, plot_q_table, plot_env_agent_and_policy_at_state, \
plot_env_agent_and_chosen_action, plot_policy
from lib.grid_world import a_index_to_symbol
class QLearning:
def __init__(self, env, initial_q_table, alpha=0.2, initial_epsilon=1.00, vmin=-8, vmax=0.5):
self.env = env
self.q_table = initial_q_table
self.alpha = alpha
self.epsilon = initial_epsilon
self.vmin = vmin
self.vmax = vmax
self.exploratory_policy = epsilon_greedy_pi_from_q_table(self.env, self.q_table, self.epsilon)
self.greedy_policy = epsilon_greedy_pi_from_q_table(self.env, self.q_table, 0.0)
self.fig, self.ax = None, None
self.phase = 'choosing_actions'
self.sampled_a = None
self.current_transition = []
self.env.reset()
@property
def s(self):
return self.env.state
@property
def s_idx(self):
return self.env.states.index(self.s)
@property
def s_centered(self):
return [self.s[0] + 0.5, self.s[1] + 0.5]
def next_step(self, fast_execution=False):
print_string = ''
if self.phase == 'choosing_actions':
if not fast_execution:
self.fig, self.ax = plt.subplots(ncols=3, figsize=(20, 6))
plot_env_agent_and_policy_at_state(self.env, self.s, self.exploratory_policy, self.ax[0])
plot_q_table(self.env, self.q_table, self.ax[1], vmin=self.vmin, vmax=self.vmax)
plot_policy(self.env, self.greedy_policy, self.ax[2])
plt.show()
print('Sampling action...\n')
self.phase = 'showing_sampled_action'
elif self.phase == 'showing_sampled_action':
self.sampled_a = np.random.choice(4, p=self.exploratory_policy[self.s_idx])
if not fast_execution:
self.fig, self.ax = plt.subplots(ncols=3, figsize=(20, 6))
plot_env_agent_and_chosen_action(self.env, self.s, self.sampled_a, self.ax[0])
plot_q_table(self.env, self.q_table, self.ax[1], vmin=self.vmin, vmax=self.vmax)
plot_policy(self.env, self.greedy_policy, self.ax[2])
plt.show()
print(f'Action sampled: {a_index_to_symbol[self.sampled_a]}\n')
self.phase = 'carrying_out_action'
elif self.phase == 'carrying_out_action':
old_s = self.s
s_prime, r, t = self.env.step(self.sampled_a)
self.current_transition = [old_s, self.sampled_a, r, s_prime, t]
if not fast_execution:
self.fig, self.ax = plt.subplots(ncols=3, figsize=(20, 6))
plot_all_states(self.env, self.ax[0])
plot_agent(old_s, self.ax[0], alpha=0.3)
plot_agent(self.s, self.ax[0])
plot_q_table(self.env, self.q_table, self.ax[1], vmin=self.vmin, vmax=self.vmax)
plot_policy(self.env, self.greedy_policy, self.ax[2])
plt.show()
print(f'Action sampled: {a_index_to_symbol[self.sampled_a]}\n')
if t:
if not fast_execution:
print('A terminal state has been reached: end of episode.')
self.phase = 'update_q_value_terminal'
else:
self.phase = 'computing_td_target'
elif self.phase == 'computing_td_target':
# Compute TD target
s, a, r, s_prime, _ = self.current_transition
s_prime_idx = self.env.states.index(s_prime)
greedy_a = np.random.choice(4, p=self.greedy_policy[self.s_idx])
td_target = r + 0.9 * self.q_table[s_prime_idx, greedy_a]
if not fast_execution:
self.fig, self.ax = plt.subplots(ncols=3, figsize=(20, 6))
plot_all_states(self.env, self.ax[0])
plot_agent(self.s, self.ax[0])
plot_agent(s, self.ax[0], alpha=0.3)
plot_q_table(self.env, self.q_table, self.ax[1], vmin=self.vmin, vmax=self.vmax)
plot_policy(self.env, self.greedy_policy, self.ax[2])
plt.show()
if not fast_execution:
print(f'TD target = R + 𝛾 * Q({s_prime}, {a_index_to_symbol[greedy_a]}) = '
f'{r:.2f} + 0.9 * {self.q_table[s_prime_idx, greedy_a]:.2f} = '
f'{td_target:.2f}')
self.phase = 'computing_new_q_value'
elif self.phase == 'computing_new_q_value':
# Compute TD target
s, a, r, s_prime, _ = self.current_transition
s_idx = self.env.states.index(s)
s_prime_idx = self.env.states.index(s_prime)
greedy_a = np.random.choice(4, p=self.greedy_policy[self.s_idx])
td_target = r + 0.9 * self.q_table[s_prime_idx, greedy_a]
# Compute new value
new_value = self.alpha * td_target + (1 - self.alpha) * self.q_table[s_idx, a]
if not fast_execution:
self.fig, self.ax = plt.subplots(ncols=3, figsize=(20, 6))
plot_all_states(self.env, self.ax[0])
plot_agent(self.s, self.ax[0])
plot_agent(s, self.ax[0], alpha=0.3)
plot_q_table(self.env, self.q_table, self.ax[1], vmin=self.vmin, vmax=self.vmax)
plot_policy(self.env, self.greedy_policy, self.ax[2])
plt.show()
if not fast_execution:
print(f'TD target = {td_target:.2f}')
print(f'Q({s}, {a_index_to_symbol[a]}) = {self.q_table[s_idx, a]:.2f} + {self.alpha:.2f} * '
f'({td_target:.2f} - {self.q_table[s_idx, a]:.2f}) = {new_value:.2f}')
self.phase = 'showing_new_q_value'
elif self.phase == 'showing_new_q_value':
# Compute TD target
s, a, r, s_prime, _ = self.current_transition
s_idx = self.env.states.index(s)
s_prime_idx = self.env.states.index(s_prime)
greedy_a = np.random.choice(4, p=self.greedy_policy[self.s_idx])
td_target = r + 0.9 * self.q_table[s_prime_idx, greedy_a]
# Compute new value and update q-table
new_value = self.alpha * td_target + (1 - self.alpha) * self.q_table[s_idx, a]
self.q_table[s_idx, a] = new_value
self.exploratory_policy = epsilon_greedy_pi_from_q_table(self.env, self.q_table, self.epsilon)
self.greedy_policy = epsilon_greedy_pi_from_q_table(self.env, self.q_table, 0)
if not fast_execution:
self.fig, self.ax = plt.subplots(ncols=3, figsize=(20, 6))
plot_all_states(self.env, self.ax[0])
plot_agent(self.s, self.ax[0])
plot_agent(s, self.ax[0], alpha=0.3)
plot_q_table(self.env, self.q_table, self.ax[1], vmin=self.vmin, vmax=self.vmax)
plot_policy(self.env, self.greedy_policy, self.ax[2])
plt.show()
print(f'TD target = {td_target:.2f}')
print(f'Q({s}, {a_index_to_symbol[a]}) = {new_value:.2f}')
self.phase = 'choosing_actions'
elif self.phase == 'update_q_value_terminal':
s, a, r, s_prime, t = self.current_transition
s_idx = self.env.states.index(s)
new_value = self.alpha * r + (1-self.alpha)*self.q_table[s_idx, a]
if not fast_execution:
self.fig, self.ax = plt.subplots(ncols=3, figsize=(20, 6))
plot_all_states(self.env, self.ax[0])
plot_agent(self.s, self.ax[0])
plot_agent(s, self.ax[0], alpha=0.3)
plot_q_table(self.env, self.q_table, self.ax[1], vmin=self.vmin, vmax=self.vmax)
plot_policy(self.env, self.greedy_policy, self.ax[2])
plt.show()
print(f'Action sampled: {a_index_to_symbol[self.sampled_a]}\n')
print('A terminal state has been reached: end of episode.\n')
print(f'TD target = R + 𝛾 * 0 = {r:.2f}')
print(f'Q({s}, {a_index_to_symbol[a]}) = {self.q_table[s_idx, a]:.2f} + {self.alpha:.2f} * '
f'({r:.2f} - {self.q_table[s_idx, a]:.2f}) = {new_value:.2f}')
self.q_table[s_idx, a] = new_value
self.exploratory_policy = epsilon_greedy_pi_from_q_table(self.env, self.q_table, self.epsilon)
self.greedy_policy = epsilon_greedy_pi_from_q_table(self.env, self.q_table, 0)
self.phase = 'showing_new_q_value_terminal'
elif self.phase == 'showing_new_q_value_terminal':
if not fast_execution:
s, a, r, s_prime, t = self.current_transition
s_idx = self.env.states.index(s)
self.fig, self.ax = plt.subplots(ncols=3, figsize=(20, 6))
plot_all_states(self.env, self.ax[0])
plot_agent(self.s, self.ax[0])
plot_agent(s, self.ax[0], alpha=0.3)
plot_q_table(self.env, self.q_table, self.ax[1], vmin=self.vmin, vmax=self.vmax)
plot_policy(self.env, self.greedy_policy, self.ax[2])
plt.show()
print(f'Action sampled: {a_index_to_symbol[self.sampled_a]}\n')
print('A terminal state has been reached: end of episode.\n')
print(f'TD target = R + 𝛾 * 0 = {r:.2f}')
print(f'Q({s}, {a_index_to_symbol[a]}) = {self.q_table[s_idx, a]:.2f}')
self.current_transition = []
self.env.reset()
self.phase = 'choosing_actions'
else:
raise ValueError(f'Phase {self.phase} not recognized.')
return print_string
def finish_episode(self):
print_string = ''
while self.phase != 'showing_new_q_value_terminal':
print_string += f'{self.next_step(fast_execution=True)}'
print_string += f'{self.next_step(fast_execution=True)}'
self.fig, self.ax = plt.subplots(ncols=3, figsize=(20, 6))
plot_all_states(self.env, self.ax[0])
plot_agent(self.s, self.ax[0])
plot_q_table(self.env, self.q_table, self.ax[1], vmin=self.vmin, vmax=self.vmax)
plot_policy(self.env, self.greedy_policy, self.ax[2])
plt.show()
print(print_string)
def update_epsilon(self, epsilon):
self.epsilon = epsilon
self.exploratory_policy = epsilon_greedy_pi_from_q_table(self.env, self.q_table, self.epsilon)
# Display plots
self.fig, self.ax = plt.subplots(ncols=3, figsize=(20, 6))
plot_all_states(self.env, self.ax[0])
plot_agent(self.s, self.ax[0])
plot_q_table(self.env, self.q_table, self.ax[1], vmin=self.vmin, vmax=self.vmax)
plot_policy(self.env, self.greedy_policy, self.ax[2])
plt.show()
| 45.460905
| 108
| 0.583235
| 1,628
| 11,047
| 3.719287
| 0.074324
| 0.0545
| 0.067217
| 0.038646
| 0.824938
| 0.785136
| 0.739389
| 0.708836
| 0.706358
| 0.692816
| 0
| 0.019086
| 0.288585
| 11,047
| 242
| 109
| 45.64876
| 0.751368
| 0.011044
| 0
| 0.666667
| 0
| 0.03125
| 0.141418
| 0.053673
| 0
| 0
| 0
| 0
| 0
| 1
| 0.036458
| false
| 0
| 0.026042
| 0.015625
| 0.088542
| 0.119792
| 0
| 0
| 0
| null | 0
| 0
| 0
| 1
| 1
| 1
| 1
| 1
| 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
| 6
|
e73f226d78946c88fbdbf29e79a99e470f5da58a
| 12,337
|
py
|
Python
|
startup/users/30-user-Wenkai.py
|
NSLS-II-SMI/profile_collection
|
c1e2236a7520f605ac85e7591f05682add06357c
|
[
"BSD-3-Clause"
] | null | null | null |
startup/users/30-user-Wenkai.py
|
NSLS-II-SMI/profile_collection
|
c1e2236a7520f605ac85e7591f05682add06357c
|
[
"BSD-3-Clause"
] | 13
|
2018-09-25T19:35:08.000Z
|
2021-01-15T20:42:26.000Z
|
startup/users/30-user-Wenkai.py
|
NSLS-II-SMI/profile_collection
|
c1e2236a7520f605ac85e7591f05682add06357c
|
[
"BSD-3-Clause"
] | 3
|
2019-09-06T01:40:59.000Z
|
2020-07-01T20:27:39.000Z
|
def giwaxs_S_edge_wenkai(t=1):
dets = [pil300KW]
names = [ 'A2', 'A3', 'A4', 'A5', 'A6']
x = [30000, 16000, 0, -15000, -36000]
energies = np.arange(2450, 2470, 5).tolist() + np.arange(2470, 2480, 0.25).tolist() + np.arange(2480, 2490, 1).tolist()+ np.arange(2490, 2501, 5).tolist()
waxs_arc = np.linspace(0, 26, 5)
ai0 = 0
for name, xs in zip(names, x):
yield from bps.mv(piezo.x, xs)
yield from bps.mv(piezo.th, ai0)
yield from bps.mv(GV7.open_cmd, 1 )
yield from bps.sleep(1)
yield from bps.mv(GV7.open_cmd, 1 )
yield from bps.sleep(1)
yield from alignement_gisaxs(angle = 0.4)
# yield from bps.mv(att2_9, 'Insert')
yield from bps.mv(GV7.close_cmd, 1 )
yield from bps.sleep(1)
# yield from bps.mv(att2_9, 'Insert')
yield from bps.mv(GV7.close_cmd, 1 )
yield from bps.sleep(1)
ai0 = piezo.th.position
yield from bps.mv(piezo.th, ai0 + 0.7)
xss = np.linspace(xs, xs - 8000, 57)
for wa in waxs_arc:
yield from bps.mv(waxs, wa)
det_exposure_time(t,t)
name_fmt = '{sample}_{energy}eV_wa{wax}_bpm{xbpm}'
for e, xsss in zip(energies, xss):
yield from bps.mv(energy, e)
yield from bps.sleep(2)
yield from bps.mv(piezo.x, xsss)
bpm = xbpm2.sumX.value
sample_name = name_fmt.format(sample=name, energy='%6.2f'%e, wax = wa, xbpm = '%4.3f'%bpm)
sample_id(user_name='GF', sample_name=sample_name)
print(f'\n\t=== Sample: {sample_name} ===\n')
yield from bp.count(dets, num=1)
yield from bps.mv(energy, 2470)
yield from bps.mv(energy, 2450)
def nexafs_S_edge_wenkai(t=1):
dets = [pil300KW]
names = ['PFSA_LSC']
x = [41200]
y = [-8000]
z = [ 2700]
energies = np.linspace(2450, 2500, 51)
energies = np.arange(2450, 2470, 5).tolist() + np.arange(2470, 2480, 0.25).tolist() + np.arange(2480, 2490, 1).tolist()+ np.arange(2490, 2501, 5).tolist()
energies1 = 10 + np.asarray(np.arange(2445, 2470, 5).tolist() + np.arange(2470, 2480, 0.25).tolist() + np.arange(2480, 2490, 1).tolist()+ np.arange(2490, 2501, 5).tolist())
for name, xs in zip(names, x):
det_exposure_time(t,t)
name_fmt = 'nexafs_{sample}_{energy}eV_wa52.00_bpm{xbpm}'
for e in energies:
yield from bps.mv(energy, e)
yield from bps.sleep(1)
bpm = xbpm2.sumX.value
sample_name = name_fmt.format(sample=name, energy='%6.2f'%e, xbpm = '%4.3f'%bpm)
sample_id(user_name='GF', sample_name=sample_name)
print(f'\n\t=== Sample: {sample_name} ===\n')
yield from bp.count(dets, num=1)
yield from bps.mv(energy, 2470)
yield from bps.mv(energy, 2450)
def hardxray_wenkai2020_1(t=1):
dets = [pil300KW, pil1M]
names = ['PFSA_LSC', 'PFSA_LSC', 'N2200_vert', 'N2200_hori', 'A1', 'A2', 'B1', 'B2', 'C1', 'C2', 'D1', 'D2', 'A3', 'B3', 'C3', 'D3']
x = [41000, 29000, -8000, -30000, 43800, 37500, 32500, 27500, 22500, 17100, 12100, 5900, -16900, -21900, -27300, -32500]
y = [-8000, -8000, -8000, -8000, 3800, 4000, 4000, 4000, 4000, 4000, 4000, 4000, 4000, 4000, 4000, 4200,]
z = [ 2700, 2700, 2700, 2700, 2700, 2700, 2700, 2700, 2700, 2700, 2700, 2700, 2700, 2700, 2700, 2700]
waxs_arc = np.linspace(0, 39, 7)
for wa in waxs_arc:
yield from bps.mv(waxs, wa)
for name, xs, ys, zs in zip(names, x, y, z):
yield from bps.mv(piezo.x, xs)
yield from bps.mv(piezo.y, ys)
yield from bps.mv(piezo.z, zs)
det_exposure_time(t,t)
name_fmt = '{sample}_16.1keVeV_8.3m_wa{wax}'
yield from bps.sleep(1)
sample_name = name_fmt.format(sample=name, wax = wa)
sample_id(user_name='WZ', sample_name=sample_name)
print(f'\n\t=== Sample: {sample_name} ===\n')
yield from bp.count(dets, num=1)
def waxs_S_edge_wenkai_2021_1(t=1):
dets = [pil1M, pil300KW]
# names = ['PFSA_LSC', 'PFSA_SSC', 'A1', 'A2', 'B1', 'B2', 'C1', 'C2', 'D1', 'D2', 'A3', 'B3', 'C3', 'D3']
# x = [41000, 28000, 43300, 37600, 32700, 27500, 21700, 16600, 11300, 5900, -17600, -22600, -28100, -33100]
# y = [-8500, -8500, 3800, 4000, 3900, 4200, 4100, 4100, 3800, 3900, 3900, 4100, 4100, 4200]
# z = [ 2700, 2700, 2700, 2700, 2700, 2700, 2700, 2700, 2700, 2700, 2700, 2700, 2700, 2700]
energies = np.arange(2450, 2470, 5).tolist() + np.arange(2470, 2480, 0.25).tolist() + np.arange(2480, 2490, 1).tolist()+ np.arange(2490, 2501, 5).tolist()
# energies1 = 10 + np.asarray(np.arange(2445, 2470, 5).tolist() + np.arange(2470, 2480, 0.25).tolist() + np.arange(2480, 2490, 1).tolist()+ np.arange(2490, 2501, 5).tolist())
# waxs_arc = np.linspace(13, 19.5, 2)
# for k, wa in enumerate(waxs_arc):
# yield from bps.mv(waxs, wa)
# for name, xs, ys, zs in zip(names, x, y, z):
# yield from bps.mv(piezo.x, xs)
# yield from bps.mv(piezo.y, ys)
# yield from bps.mv(piezo.z, zs)
# yss = np.linspace(ys, ys + 700, 29)
# xss = np.array([xs, xs + 500])
# yss, xss = np.meshgrid(yss, xss)
# yss = yss.ravel()
# xss = xss.ravel()
# det_exposure_time(t,t)
# name_fmt = '{sample}_{energy}eV_wa{wax}_bpm{xbpm}'
# for e, xsss, ysss in zip(energies1, xss, yss):
# yield from bps.mv(energy, e)
# yield from bps.sleep(1)
# yield from bps.mv(piezo.y, ysss)
# yield from bps.mv(piezo.x, xsss)
# bpm = xbpm2.sumX.value
# sample_name = name_fmt.format(sample=name, energy='%6.2f'%e, wax = wa, xbpm = '%4.3f'%bpm)
# sample_id(user_name='WZ', sample_name=sample_name)
# print(f'\n\t=== Sample: {sample_name} ===\n')
# yield from bp.count(dets, num=1)
# yield from bps.mv(energy, 2470)
# yield from bps.mv(energy, 2450)
names = ['N2200_vert', 'N2200_hori']
x = [-8500, -30500]
y = [-8500, -8000]
z = [ 2700, 2700]
waxs_arc = np.linspace(0, 19.5, 4)
for wa in waxs_arc:
yield from bps.mv(waxs, wa)
for name, xs, ys, zs in zip(names, x, y, z):
yield from bps.mv(piezo.x, xs)
yield from bps.mv(piezo.y, ys)
yield from bps.mv(piezo.z, zs)
yss = np.linspace(ys, ys + 1000, 29)
xss = np.array([xs, xs + 500])
yss, xss = np.meshgrid(yss, xss)
yss = yss.ravel()
xss = xss.ravel()
det_exposure_time(t,t)
name_fmt = '{sample}_{energy}eV_wa{wax}_bpm{xbpm}'
for e, xsss, ysss in zip(energies, xss, yss):
yield from bps.mv(energy, e)
yield from bps.sleep(1)
yield from bps.mv(piezo.y, ysss)
yield from bps.mv(piezo.x, xsss)
bpm = xbpm2.sumX.value
sample_name = name_fmt.format(sample=name, energy='%6.2f'%e, wax = wa, xbpm = '%4.3f'%bpm)
sample_id(user_name='WZ', sample_name=sample_name)
print(f'\n\t=== Sample: {sample_name} ===\n')
yield from bp.count(dets, num=1)
yield from bps.mv(energy, 2470)
yield from bps.mv(energy, 2450)
def wenkai_waxs_tensile_tender_2021_2(t=1):
#85s to do the loop
dets = [pil300KW, pil1M]
names = 'SSC_loop4_waxs'
t0 = time.time()
# yield from bps.mvr(stage.y, -0.4)
for i in range(60):
det_exposure_time(t,t)
yield from bps.mvr(stage.y, 0.03)
if waxs.arc.position > 5:
wa = [19.5, 13, 6.5, 0]
else:
wa = [0, 6.5, 13, 19.5]
t1 = time.time()
for wax in wa:
name_fmt = '{sample}_2455.0eV_sdd3m_{time}s_{i}_wa{wa}'
yield from bps.mv(waxs, wax)
sample_name = name_fmt.format(sample=names, time = '%1.1f'%(t1-t0), i = '%3.3d'%i, wa = '%1.1f'%wax)
sample_id(user_name='GF', sample_name=sample_name)
print(f'\n\t=== Sample: {sample_name} ===\n')
yield from bp.count(dets, num=1)
yield from bps.sleep(5)
t2 = time.time()
print(t2-t0)
def wenkai_waxsonly_tensile_tender_2021_2(t=1):
#85s to do the loop
dets = [pil300KW]
names = 'LSC_loop5_waxs_kaclamp'
t0 = time.time()
# yield from bps.mvr(stage.y, -0.4)
for i in range(1000):
det_exposure_time(t,t)
yield from bps.mvr(stage.y, 0.01)
t1 = time.time()
name_fmt = '{sample}_2484.25eV_sdd3m_{time}s_{i}_wa{wa}'
sample_name = name_fmt.format(sample=names, time = '%1.1f'%(t1-t0), i = '%3.3d'%i, wa = '%1.1f'%0)
sample_id(user_name='GF', sample_name=sample_name)
print(f'\n\t=== Sample: {sample_name} ===\n')
yield from bp.count(dets, num=1)
t2 = time.time()
print(t2-t0)
def wenkai_saxsonly_tensile_tender_2021_2(t=1):
#85s to do the loop
dets = [pil300KW, pil1M]
names = 'SSC_loop3_saxs'
t0 = time.time()
# yield from bps.mvr(stage.y, -0.4)
for i in range(1000):
det_exposure_time(t,t)
yield from bps.mvr(stage.y, 0.005)
t1 = time.time()
name_fmt = '{sample}_2484.24eV_sdd3m_{time}s_{i}_wa{wa}'
sample_name = name_fmt.format(sample=names, time = '%1.1f'%(t1-t0), i = '%3.3d'%i, wa = '%1.1f'%8)
sample_id(user_name='GF', sample_name=sample_name)
print(f'\n\t=== Sample: {sample_name} ===\n')
yield from bp.count(dets, num=1)
yield from bps.sleep(0.5)
t2 = time.time()
print(t2-t0)
def wenkai_saxs_waxs_tensile_hard(t=1):
dets = [pil300KW, pil1M]
names = 'PF-T2PO1_loop1'
t0 = time.time()
for i in range(2000):
det_exposure_time(t,t)
if waxs.arc.position > 5:
wa = [13, 6.5, 0]
else:
wa = [0, 6.5, 13]
name_fmt = '{sample}_14000eV_{time}s_{i}_wa{wa}'
t1 = time.time()
for wax in wa:
yield from bps.mv(waxs, wax)
sample_name = name_fmt.format(sample=names, time = '%1.1f'%(t1-t0), i = '%3.3d'%i, wa = '%1.1f'%wax)
sample_id(user_name='GF', sample_name=sample_name)
print(f'\n\t=== Sample: {sample_name} ===\n')
yield from bp.count(dets, num=1)
def wenkai_waxs_tensile_2021_3(t=0.5):
names = 'LSC_RT_loop1'
dets = [pil900KW, pil300KW]
wa = [0]
yield from bps.mv(stage.y, 0.1)
t0 = time.time()
for i in range(2000):
det_exposure_time(t,t)
name_fmt = '{sample}_14keV_{time}s_{i}_wa{wa}'
t1 = time.time()
for wax in wa:
yield from bps.mv(waxs, wax)
sample_name = name_fmt.format(sample=names, time = '%1.1f'%(t1-t0), i = '%3.3d'%i, wa = '%1.1f'%wax)
sample_id(user_name='GF', sample_name=sample_name)
print(f'\n\t=== Sample: {sample_name} ===\n')
yield from bp.count(dets, num=1)
yield from bps.mvr(stage.y, 0.01)
# yield from bps.sleep(2)
def wenkai_saxs_tensile_2021_3(t=0.5):
names = 'LSC_RT_loop6_samesample'
dets = [pil1M]
wa = [20]
yield from bps.mv(stage.y, -0.3)
t0 = time.time()
for i in range(2000):
det_exposure_time(t,t)
name_fmt = '{sample}_2484.24keV_{time}s_{i}_wa{wa}'
t1 = time.time()
for wax in wa:
yield from bps.mv(waxs, wax)
sample_name = name_fmt.format(sample=names, time = '%1.1f'%(t1-t0), i = '%3.3d'%i, wa = '%1.1f'%wax)
sample_id(user_name='GF', sample_name=sample_name)
print(f'\n\t=== Sample: {sample_name} ===\n')
yield from bp.count(dets, num=1)
yield from bps.mvr(stage.y, 0.01)
# yield from bps.sleep(2)
| 33.163978
| 178
| 0.538299
| 1,868
| 12,337
| 3.432013
| 0.122591
| 0.109499
| 0.123538
| 0.098269
| 0.854937
| 0.851817
| 0.836063
| 0.791452
| 0.772734
| 0.749649
| 0
| 0.131123
| 0.303315
| 12,337
| 372
| 179
| 33.163978
| 0.614776
| 0.163492
| 0
| 0.635945
| 0
| 0
| 0.104096
| 0.041638
| 0
| 0
| 0
| 0
| 0
| 1
| 0.046083
| false
| 0
| 0
| 0
| 0.046083
| 0.059908
| 0
| 0
| 0
| null | 0
| 0
| 0
| 1
| 1
| 1
| 1
| 1
| 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
| 6
|
e765510add5b0b12ab494656486809df24044a5a
| 84
|
py
|
Python
|
webware/Testing/Dir/Forward2Target.py
|
PeaceWorksTechnologySolutions/w4py3
|
7f9e7088034e3e3ac53158edfa4f377b5b2f45fe
|
[
"MIT"
] | 18
|
2016-08-01T20:15:59.000Z
|
2019-12-24T16:00:03.000Z
|
webware/Testing/Dir/Forward2Target.py
|
PeaceWorksTechnologySolutions/w4py3
|
7f9e7088034e3e3ac53158edfa4f377b5b2f45fe
|
[
"MIT"
] | 9
|
2020-01-03T18:58:25.000Z
|
2020-01-09T18:36:23.000Z
|
webware/Testing/Dir/Forward2Target.py
|
PeaceWorksTechnologySolutions/w4py3
|
7f9e7088034e3e3ac53158edfa4f377b5b2f45fe
|
[
"MIT"
] | 6
|
2016-09-16T14:32:29.000Z
|
2020-01-03T18:52:16.000Z
|
from Testing.DebugPage import DebugPage
class Forward2Target(DebugPage):
pass
| 14
| 39
| 0.797619
| 9
| 84
| 7.444444
| 0.777778
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0.014085
| 0.154762
| 84
| 5
| 40
| 16.8
| 0.929577
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 1
| 0
| true
| 0.333333
| 0.333333
| 0
| 0.666667
| 0
| 1
| 0
| 0
| null | 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 1
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| null | 0
| 0
| 0
| 0
| 0
| 0
| 1
| 1
| 1
| 0
| 1
| 0
|
0
| 6
|
e78111dcf809259b881c47606ebde0ff1c876f53
| 158
|
py
|
Python
|
src/aktorz/model/util/base_versioned_model.py
|
jcejohnson/pydantic-demo
|
fb2033db87924210b1ecc1c56fcb057fda735d14
|
[
"MIT"
] | null | null | null |
src/aktorz/model/util/base_versioned_model.py
|
jcejohnson/pydantic-demo
|
fb2033db87924210b1ecc1c56fcb057fda735d14
|
[
"MIT"
] | null | null | null |
src/aktorz/model/util/base_versioned_model.py
|
jcejohnson/pydantic-demo
|
fb2033db87924210b1ecc1c56fcb057fda735d14
|
[
"MIT"
] | null | null | null |
from .base_model import BaseModel
from .mixin_versioned_model import VersionedModelMixin
class BaseVersionedModel(VersionedModelMixin, BaseModel):
pass
| 22.571429
| 57
| 0.848101
| 16
| 158
| 8.1875
| 0.6875
| 0.167939
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0.113924
| 158
| 6
| 58
| 26.333333
| 0.935714
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 1
| 0
| true
| 0.25
| 0.5
| 0
| 0.75
| 0
| 1
| 0
| 0
| null | 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 1
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| null | 0
| 0
| 0
| 0
| 0
| 0
| 1
| 1
| 1
| 0
| 1
| 0
|
0
| 6
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.